page_table.hh (12460:0f221912b014) | page_table.hh (12461:a4cb506cda74) |
---|---|
1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2003 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35 */ 36 37#ifndef __MEM_PAGE_TABLE_HH__ 38#define __MEM_PAGE_TABLE_HH__ 39 40#include <string> 41#include <unordered_map> 42 | 1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2003 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35 */ 36 37#ifndef __MEM_PAGE_TABLE_HH__ 38#define __MEM_PAGE_TABLE_HH__ 39 40#include <string> 41#include <unordered_map> 42 |
43#include "arch/isa_traits.hh" 44#include "arch/tlb.hh" | |
45#include "base/intmath.hh" 46#include "base/types.hh" | 43#include "base/intmath.hh" 44#include "base/types.hh" |
47#include "config/the_isa.hh" | |
48#include "mem/request.hh" 49#include "sim/serialize.hh" 50 51class ThreadContext; 52 53class EmulationPageTable : public Serializable 54{ | 45#include "mem/request.hh" 46#include "sim/serialize.hh" 47 48class ThreadContext; 49 50class EmulationPageTable : public Serializable 51{ |
52 public: 53 struct Entry 54 { 55 Addr paddr; 56 uint64_t flags; 57 58 Entry(Addr paddr, uint64_t flags) : paddr(paddr), flags(flags) {} 59 Entry() {} 60 }; 61 |
|
55 protected: | 62 protected: |
56 typedef std::unordered_map<Addr, TheISA::TlbEntry *> PTable; | 63 typedef std::unordered_map<Addr, Entry> PTable; |
57 typedef PTable::iterator PTableItr; 58 PTable pTable; 59 60 const Addr pageSize; 61 const Addr offsetMask; 62 | 64 typedef PTable::iterator PTableItr; 65 PTable pTable; 66 67 const Addr pageSize; 68 const Addr offsetMask; 69 |
63 const uint64_t pid; | 70 const uint64_t _pid; |
64 const std::string _name; 65 66 public: 67 68 EmulationPageTable( 69 const std::string &__name, uint64_t _pid, Addr _pageSize) : 70 pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize))), | 71 const std::string _name; 72 73 public: 74 75 EmulationPageTable( 76 const std::string &__name, uint64_t _pid, Addr _pageSize) : 77 pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize))), |
71 pid(_pid), _name(__name) | 78 _pid(_pid), _name(__name) |
72 { 73 assert(isPowerOf2(pageSize)); 74 } 75 | 79 { 80 assert(isPowerOf2(pageSize)); 81 } 82 |
76 virtual ~EmulationPageTable(); | 83 uint64_t pid() const { return _pid; }; |
77 | 84 |
85 virtual ~EmulationPageTable() {}; 86 |
|
78 /* generic page table mapping flags 79 * unset | set 80 * bit 0 - no-clobber | clobber 81 * bit 2 - cacheable | uncacheable 82 * bit 3 - read-write | read-only 83 */ 84 enum MappingFlags : uint32_t { 85 Clobber = 1, --- 29 unchanged lines hidden (view full) --- 115 */ 116 virtual bool isUnmapped(Addr vaddr, int64_t size); 117 118 /** 119 * Lookup function 120 * @param vaddr The virtual address. 121 * @return The page table entry corresponding to vaddr. 122 */ | 87 /* generic page table mapping flags 88 * unset | set 89 * bit 0 - no-clobber | clobber 90 * bit 2 - cacheable | uncacheable 91 * bit 3 - read-write | read-only 92 */ 93 enum MappingFlags : uint32_t { 94 Clobber = 1, --- 29 unchanged lines hidden (view full) --- 124 */ 125 virtual bool isUnmapped(Addr vaddr, int64_t size); 126 127 /** 128 * Lookup function 129 * @param vaddr The virtual address. 130 * @return The page table entry corresponding to vaddr. 131 */ |
123 virtual TheISA::TlbEntry *lookup(Addr vaddr); | 132 const Entry *lookup(Addr vaddr); |
124 125 /** 126 * Translate function 127 * @param vaddr The virtual address. 128 * @param paddr Physical address from translation. 129 * @return True if translation exists 130 */ 131 bool translate(Addr vaddr, Addr &paddr); --- 22 unchanged lines hidden --- | 133 134 /** 135 * Translate function 136 * @param vaddr The virtual address. 137 * @param paddr Physical address from translation. 138 * @return True if translation exists 139 */ 140 bool translate(Addr vaddr, Addr &paddr); --- 22 unchanged lines hidden --- |