diff options
Diffstat (limited to 'src/core/arm/mmu/tlb.h')
| -rw-r--r-- | src/core/arm/mmu/tlb.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/core/arm/mmu/tlb.h b/src/core/arm/mmu/tlb.h new file mode 100644 index 000000000..938c01786 --- /dev/null +++ b/src/core/arm/mmu/tlb.h | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | #ifndef _MMU_TLB_H_ | ||
| 2 | #define _MMU_TLB_H_ | ||
| 3 | |||
| 4 | typedef enum tlb_mapping_t | ||
| 5 | { | ||
| 6 | TLB_INVALID = 0, | ||
| 7 | TLB_SMALLPAGE = 1, | ||
| 8 | TLB_LARGEPAGE = 2, | ||
| 9 | TLB_SECTION = 3, | ||
| 10 | TLB_ESMALLPAGE = 4, | ||
| 11 | TLB_TINYPAGE = 5 | ||
| 12 | } tlb_mapping_t; | ||
| 13 | |||
| 14 | extern ARMword tlb_masks[]; | ||
| 15 | |||
| 16 | /* Permissions bits in a TLB entry: | ||
| 17 | * | ||
| 18 | * 31 12 11 10 9 8 7 6 5 4 3 2 1 0 | ||
| 19 | * +-------------+-----+-----+-----+-----+---+---+-------+ | ||
| 20 | * Page:| | ap3 | ap2 | ap1 | ap0 | C | B | | | ||
| 21 | * +-------------+-----+-----+-----+-----+---+---+-------+ | ||
| 22 | * | ||
| 23 | * 31 12 11 10 9 4 3 2 1 0 | ||
| 24 | * +-------------+-----+-----------------+---+---+-------+ | ||
| 25 | * Section: | | AP | | C | B | | | ||
| 26 | * +-------------+-----+-----------------+---+---+-------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | /* | ||
| 30 | section: | ||
| 31 | section base address [31:20] | ||
| 32 | AP - table 8-2, page 8-8 | ||
| 33 | domain | ||
| 34 | C,B | ||
| 35 | |||
| 36 | page: | ||
| 37 | page base address [31:16] or [31:12] | ||
| 38 | ap[3:0] | ||
| 39 | domain (from L1) | ||
| 40 | C,B | ||
| 41 | */ | ||
| 42 | |||
| 43 | |||
| 44 | typedef struct tlb_entry_t | ||
| 45 | { | ||
| 46 | ARMword virt_addr; | ||
| 47 | ARMword phys_addr; | ||
| 48 | ARMword perms; | ||
| 49 | ARMword domain; | ||
| 50 | tlb_mapping_t mapping; | ||
| 51 | } tlb_entry_t; | ||
| 52 | |||
| 53 | typedef struct tlb_s | ||
| 54 | { | ||
| 55 | int num; /*num of tlb entry */ | ||
| 56 | int cycle; /*current tlb cycle */ | ||
| 57 | tlb_entry_t *entrys; | ||
| 58 | } tlb_s; | ||
| 59 | |||
| 60 | |||
| 61 | #define tlb_c_flag(tlb) \ | ||
| 62 | ((tlb)->perms & 0x8) | ||
| 63 | #define tlb_b_flag(tlb) \ | ||
| 64 | ((tlb)->perms & 0x4) | ||
| 65 | |||
| 66 | #define tlb_va_to_pa(tlb, va) \ | ||
| 67 | (\ | ||
| 68 | {\ | ||
| 69 | ARMword mask = tlb_masks[tlb->mapping]; \ | ||
| 70 | (tlb->phys_addr & mask) | (va & ~mask);\ | ||
| 71 | }\ | ||
| 72 | ) | ||
| 73 | |||
| 74 | fault_t | ||
| 75 | check_access (ARMul_State * state, ARMword virt_addr, tlb_entry_t * tlb, | ||
| 76 | int read); | ||
| 77 | |||
| 78 | fault_t | ||
| 79 | translate (ARMul_State * state, ARMword virt_addr, tlb_s * tlb_t, | ||
| 80 | tlb_entry_t ** tlb); | ||
| 81 | |||
| 82 | int mmu_tlb_init (tlb_s * tlb_t, int num); | ||
| 83 | |||
| 84 | void mmu_tlb_exit (tlb_s * tlb_t); | ||
| 85 | |||
| 86 | void mmu_tlb_invalidate_all (ARMul_State * state, tlb_s * tlb_t); | ||
| 87 | |||
| 88 | void | ||
| 89 | mmu_tlb_invalidate_entry (ARMul_State * state, tlb_s * tlb_t, ARMword addr); | ||
| 90 | |||
| 91 | tlb_entry_t *mmu_tlb_search (ARMul_State * state, tlb_s * tlb_t, | ||
| 92 | ARMword virt_addr); | ||
| 93 | |||
| 94 | #endif /*_MMU_TLB_H_*/ | ||