Changeset 1084a784 in mainline
- Timestamp:
- 2005-10-04T22:09:41Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 342de62
- Parents:
- 8e3f47b3
- Files:
-
- 5 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/mm/page.h
r8e3f47b3 r1084a784 75 75 #ifndef __ASM__ 76 76 77 typedef struct page_specifier pte_t;78 79 77 struct page_specifier { 80 78 unsigned present : 1; -
arch/amd64/include/mm/vm.h
r8e3f47b3 r1084a784 41 41 #define UDATA_ADDRESS_ARCH 0x21000000 42 42 43 #define vm_install_arch(vm) 44 43 45 #endif -
arch/amd64/include/types.h
r8e3f47b3 r1084a784 46 46 typedef __u64 __native; 47 47 48 typedef struct page_specifier pte_t; 49 48 50 #endif -
arch/amd64/src/cpu/cpu.c
r8e3f47b3 r1084a784 35 35 #include <print.h> 36 36 #include <typedefs.h> 37 #include <fpu_context.h> 37 38 38 39 /* -
arch/amd64/src/interrupt.c
r8e3f47b3 r1084a784 40 40 #include <arch/asm.h> 41 41 #include <proc/scheduler.h> 42 #include <proc/thread.h> 42 43 43 44 -
arch/ia32/include/mm/page.h
r8e3f47b3 r1084a784 91 91 } __attribute__ ((packed)); 92 92 93 typedef struct page_specifier pte_t;94 95 93 static inline int get_pt_flags(pte_t *pt, index_t i) 96 94 { -
arch/ia32/include/mm/vm.h
r8e3f47b3 r1084a784 41 41 #define UDATA_ADDRESS_ARCH 0x21000000 42 42 43 #define vm_install_arch(vm) 44 43 45 #endif -
arch/ia32/include/types.h
r8e3f47b3 r1084a784 45 45 typedef __u32 __native; 46 46 47 typedef struct page_specifier pte_t; 48 47 49 #endif -
arch/ia32/src/cpu/cpu.c
r8e3f47b3 r1084a784 35 35 #include <print.h> 36 36 #include <typedefs.h> 37 #include <fpu_context.h> 37 38 38 39 #include <arch/smp/apic.h> -
arch/ia32/src/interrupt.c
r8e3f47b3 r1084a784 38 38 #include <arch.h> 39 39 #include <symtab.h> 40 #include <proc/thread.h> 40 41 41 42 /* -
arch/ia64/include/mm/page.h
r8e3f47b3 r1084a784 71 71 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) 72 72 73 typedef __u64 pte_t;74 75 73 #endif -
arch/ia64/include/mm/vm.h
r8e3f47b3 r1084a784 41 41 #define UDATA_ADDRESS_ARCH 0x0000000001001000 42 42 43 #define vm_install_arch(vm) 44 43 45 #endif -
arch/ia64/include/types.h
r8e3f47b3 r1084a784 45 45 typedef __u64 __native; 46 46 47 typedef __u64 pte_t; 48 47 49 #endif -
arch/mips32/Makefile.inc
r8e3f47b3 r1084a784 11 11 12 12 DEFS=-DARCH=$(ARCH) -DMACHINE=${MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS} 13 CFLAGS=$(DEFS) -mno-abicalls -G 0 -nostdlib -fno-builtin -O2 -fno-zero-initialized-in-bss 14 LFLAGS= -M -N13 CFLAGS=$(DEFS) -mno-abicalls -G 0 -nostdlib -fno-builtin -O2 -fno-zero-initialized-in-bss 14 LFLAGS= 15 15 BFD_ARCH=mips 16 16 … … 87 87 src/arch/cache.c \ 88 88 src/arch/cpu/cpu.c \ 89 src/arch/mm/asid.c \ 89 90 src/arch/mm/frame.c \ 90 91 src/arch/mm/page.c \ 91 92 src/arch/mm/tlb.c \ 93 src/arch/mm/vm.c \ 92 94 src/arch/fpu_context.c \ 93 95 src/arch/fmath.c \ -
arch/mips32/include/cp0.h
r8e3f47b3 r1084a784 31 31 32 32 #include <arch/types.h> 33 #include <arch/mm/tlb.h> 33 34 34 35 #define cp0_status_ie_enabled_bit (1<<0) -
arch/mips32/include/mm/asid.h
r8e3f47b3 r1084a784 1 1 /* 2 * Copyright (C) 2005 Ma trin Decky2 * Copyright (C) 2005 Martin Decky 3 3 * All rights reserved. 4 4 * … … 30 30 #define __mips32_ASID_H__ 31 31 32 extern void asid_bitmap_reset(void); 32 #include <arch/types.h> 33 34 typedef __u8 asid_t; 35 36 extern asid_t asid_get(void); 37 extern void asid_put(asid_t asid); 33 38 34 39 #endif -
arch/mips32/include/mm/page.h
r8e3f47b3 r1084a784 57 57 #define PTL1_INDEX_ARCH(vaddr) 0 58 58 #define PTL2_INDEX_ARCH(vaddr) 0 59 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>1 4)&0xfff)59 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>12)&0xfff) 60 60 61 61 #define GET_PTL0_ADDRESS_ARCH() (PTL0) 62 62 #define SET_PTL0_ADDRESS_ARCH(ptl0) (PTL0 = (pte_t *)(ptl0)) 63 63 64 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<1 4)64 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<12) 65 65 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 66 66 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 67 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<1 4)67 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<12) 68 68 69 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>1 4)69 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>12) 70 70 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 71 71 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 72 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>1 4)72 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>12) 73 73 74 74 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) -
arch/mips32/include/mm/tlb.h
r8e3f47b3 r1084a784 53 53 struct entry_hi { 54 54 unsigned asid : 8; 55 unsigned : 4; 56 unsigned g : 1; 55 unsigned : 5; 57 56 unsigned vpn2 : 19; 58 57 } __attribute__ ((packed)); … … 71 70 } __attribute__ ((packed)); 72 71 73 typedef struct entry_lo pte_t;74 72 75 73 /** Read Indexed TLB Entry -
arch/mips32/include/mm/vm.h
r8e3f47b3 r1084a784 31 31 32 32 #include <arch/types.h> 33 #include <typedefs.h> 33 34 34 35 #define KERNEL_ADDRESS_SPACE_START_ARCH (__address) 0x80000000 … … 41 42 #define UDATA_ADDRESS_ARCH 0x01001000 42 43 44 extern void vm_install_arch(vm_t *vm); 45 43 46 #endif -
arch/mips32/include/types.h
r8e3f47b3 r1084a784 50 50 typedef __u32 __native; 51 51 52 typedef struct entry_lo pte_t; 53 52 54 #endif -
arch/mips32/src/exception.c
r8e3f47b3 r1084a784 34 34 #include <arch.h> 35 35 #include <debug.h> 36 #include <proc/thread.h> 36 37 37 38 void exception(struct exception_regdump *pstate) -
arch/mips32/src/mips32.c
r8e3f47b3 r1084a784 38 38 #include <arch/interrupt.h> 39 39 #include <arch/drivers/arc.h> 40 40 #include <proc/thread.h> 41 41 #include <print.h> 42 42 -
arch/mips32/src/mm/asid.c
r8e3f47b3 r1084a784 27 27 */ 28 28 29 #include <arch/mm/asid.h> 30 #include <synch/spinlock.h> 29 31 #include <arch.h> 30 #include < memstr.h>32 #include <debug.h> 31 33 32 /**< Array of threads that have currently some ASID assigned, 33 NULL means no thread have ASID with number of that index assigned */ 34 struct thread * asids[256]; 35 int last_asid; /**< The number of last assigned ASID */ 36 int asid_bitmap[32]; /**< Bitmap of ASIDs currently in TLB */ 34 #define ASIDS 256 37 35 36 static spinlock_t asid_usage_lock; 37 static count_t asid_usage[ASIDS]; /**< Usage tracking array for ASIDs */ 38 38 39 /** Cleanup asid_bitmap39 /** Get ASID 40 40 * 41 * Get the least used ASID. 42 * 43 * @return ASID 41 44 */ 42 void asid_bitmap_reset(void)45 asid_t asid_get(void) 43 46 { 44 memsetb(asid_bitmap, sizeof(asid_bitmap), 0); 47 pri_t pri; 48 int i, j; 49 count_t min; 50 51 min = (unsigned) -1; 52 53 pri = cpu_priority_high(); 54 spinlock_lock(&asid_usage_lock); 55 56 for (i=0, j = 0; (i<ASIDS); i++) { 57 if (asid_usage[i] < min) { 58 j = i; 59 min = asid_usage[i]; 60 if (!min) 61 break; 62 } 63 } 64 65 asid_usage[i]++; 66 67 spinlock_unlock(&asid_usage_lock); 68 cpu_priority_restore(pri); 69 70 return i; 45 71 } 46 72 73 /** Release ASID 74 * 75 * Release ASID by decrementing its usage count. 76 * 77 * @param asid ASID. 78 */ 79 void asid_put(asid_t asid) 80 { 81 pri_t pri; 47 82 48 /** Initialize manipulating with ASIDs 49 * 50 */ 51 void init_asids(void) 52 { 53 memsetb(asids, sizeof(asids), 0); 54 asid_bitmap_reset();55 last_asid = 0;83 pri = cpu_priority_high(); 84 spinlock_lock(&asid_usage_lock); 85 86 ASSERT(asid_usage[asid] > 0); 87 asid_usage[asid]--; 88 89 spinlock_unlock(&asid_usage_lock); 90 cpu_priority_restore(pri); 56 91 } -
arch/mips32/src/mm/tlb.c
r8e3f47b3 r1084a784 30 30 #include <arch/mm/asid.h> 31 31 #include <mm/tlb.h> 32 #include <mm/page.h> 33 #include <mm/vm.h> 32 34 #include <arch/cp0.h> 33 35 #include <panic.h> 34 36 #include <arch.h> 35 37 #include <symtab.h> 38 #include <synch/spinlock.h> 39 #include <print.h> 36 40 41 static void tlb_refill_fail(struct exception_regdump *pstate); 42 static void tlb_invalid_fail(struct exception_regdump *pstate); 43 static void tlb_modified_fail(struct exception_regdump *pstate); 44 45 /** Initialize TLB 46 * 47 * Initialize TLB. 48 * Invalidate all entries and mark wired entries. 49 */ 37 50 void tlb_init_arch(void) 38 51 { … … 48 61 */ 49 62 for (i = 0; i < TLB_SIZE; i++) { 50 cp0_index_write( 0);63 cp0_index_write(i); 51 64 tlbwi(); 52 65 } … … 54 67 /* 55 68 * The kernel is going to make use of some wired 56 * entries (e.g. mapping kernel stacks ).69 * entries (e.g. mapping kernel stacks in kseg3). 57 70 */ 58 71 cp0_wired_write(TLB_WIRED); 59 72 } 60 73 74 /** Process TLB Refill Exception 75 * 76 * Process TLB Refill Exception. 77 * 78 * @param pstate Interrupted register context. 79 */ 61 80 void tlb_refill(struct exception_regdump *pstate) 81 { 82 struct entry_hi hi; 83 __address badvaddr; 84 pte_t *pte; 85 86 *((__u32 *) &hi) = cp0_entry_hi_read(); 87 badvaddr = cp0_badvaddr_read(); 88 89 spinlock_lock(&VM->lock); 90 91 /* 92 * Refill cannot succeed if the ASIDs don't match. 93 */ 94 if (hi.asid != VM->asid) 95 goto fail; 96 97 /* 98 * Refill cannot succeed if badvaddr is not 99 * associated with any mapping. 100 */ 101 pte = find_mapping(badvaddr, 0); 102 if (!pte) 103 goto fail; 104 105 /* 106 * Refill cannot succeed if the mapping is marked as invalid. 107 */ 108 if (!pte->v) 109 goto fail; 110 111 /* 112 * New entry is to be inserted into TLB 113 */ 114 cp0_pagemask_write(TLB_PAGE_MASK_16K); 115 if ((badvaddr/PAGE_SIZE) % 2 == 0) { 116 cp0_entry_lo0_write(*((__u32 *) pte)); 117 cp0_entry_lo1_write(0); 118 } 119 else { 120 cp0_entry_lo0_write(0); 121 cp0_entry_lo1_write(*((__u32 *) pte)); 122 } 123 tlbwr(); 124 125 spinlock_unlock(&VM->lock); 126 return; 127 128 fail: 129 spinlock_unlock(&VM->lock); 130 tlb_refill_fail(pstate); 131 } 132 133 void tlb_invalid(struct exception_regdump *pstate) 134 { 135 tlb_invalid_fail(pstate); 136 } 137 138 void tlb_modified(struct exception_regdump *pstate) 139 { 140 tlb_modified_fail(pstate); 141 } 142 143 void tlb_refill_fail(struct exception_regdump *pstate) 62 144 { 63 145 char *symbol = ""; … … 70 152 if (s) 71 153 sym2 = s; 72 panic("%X: TLB Refill Exception at %X(%s<-%s)\n", cp0_badvaddr_read(), 73 pstate->epc, symbol, sym2); 154 panic("%X: TLB Refill Exception at %X(%s<-%s)\n", cp0_badvaddr_read(), pstate->epc, symbol, sym2); 74 155 } 75 156 76 void tlb_invalid(struct exception_regdump *pstate) 157 158 void tlb_invalid_fail(struct exception_regdump *pstate) 77 159 { 78 160 char *symbol = ""; … … 85 167 } 86 168 87 void tlb_modified (struct exception_regdump *pstate)169 void tlb_modified_fail(struct exception_regdump *pstate) 88 170 { 89 171 char *symbol = ""; … … 103 185 pri = cpu_priority_high(); 104 186 105 // asid_bitmap_reset();106 107 187 // TODO 108 188 -
arch/ppc32/include/mm/page.h
r8e3f47b3 r1084a784 69 69 extern void page_arch_init(void); 70 70 71 typedef __u32 pte_t;72 73 71 #endif -
arch/ppc32/include/mm/vm.h
r8e3f47b3 r1084a784 41 41 #define UDATA_ADDRESS_ARCH 0x21000000 42 42 43 #define vm_install_arch(vm) 44 43 45 #endif -
arch/ppc32/include/types.h
r8e3f47b3 r1084a784 45 45 typedef __u32 __native; 46 46 47 typedef __u32 pte_t; 48 47 49 #endif -
include/arch.h
r8e3f47b3 r1084a784 37 37 #include <arch/asm.h> 38 38 39 #include <proc/thread.h>40 #include <proc/task.h>41 42 39 #define CPU THE->cpu 43 40 #define THREAD THE->thread 44 41 #define TASK THE->task 42 #define VM THE->vm 45 43 #define PREEMPTION_DISABLED THE->preemption_disabled 46 44 … … 59 57 task_t *task; /* current task */ 60 58 cpu_t *cpu; /* executing cpu */ 59 vm_t *vm; /* current vm */ 61 60 }; 62 61 -
include/mm/page.h
r8e3f47b3 r1084a784 109 109 extern void page_init(void); 110 110 extern void map_page_to_frame(__address page, __address frame, int flags, __address root); 111 extern pte_t *find_mapping(__address page, __address root); 111 112 extern void map_structure(__address s, size_t size); 112 113 -
include/mm/vm.h
r8e3f47b3 r1084a784 32 32 #include <arch/mm/page.h> 33 33 #include <arch/mm/vm.h> 34 #include <arch/mm/asid.h> 34 35 #include <arch/types.h> 35 36 #include <typedefs.h> … … 75 76 link_t vm_area_head; 76 77 pte_t *ptl0; 78 asid_t asid; 77 79 }; 78 80 -
src/main/kinit.c
r8e3f47b3 r1084a784 54 54 #include <test.h> 55 55 #endif /* __TEST__ */ 56 57 #include <mm/frame.h> 56 58 57 59 void kinit(void *arg) -
src/mm/page.c
r8e3f47b3 r1084a784 34 34 #include <arch/asm.h> 35 35 #include <memstr.h> 36 37 36 38 37 void page_init(void) … … 110 109 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags); 111 110 } 111 112 /** Find mapping for virtual page 113 * 114 * Find mapping for virtual page. 115 * 116 * @param page Virtual page. 117 * @param root PTL0 address if non-zero. 118 * 119 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise. 120 */ 121 pte_t *find_mapping(__address page, __address root) 122 { 123 pte_t *ptl0, *ptl1, *ptl2, *ptl3; 124 125 ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS()); 126 127 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) 128 return NULL; 129 130 ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); 131 132 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) 133 return NULL; 134 135 ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); 136 137 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) 138 return NULL; 139 140 ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); 141 142 return &ptl3[PTL3_INDEX(page)]; 143 } -
src/mm/vm.c
r8e3f47b3 r1084a784 33 33 #include <mm/heap.h> 34 34 #include <arch/mm/page.h> 35 #include <arch/mm/asid.h> 36 #include <arch/mm/vm.h> 35 37 #include <arch/types.h> 36 38 #include <typedefs.h> … … 56 58 spinlock_initialize(&m->lock); 57 59 list_initialize(&m->vm_area_head); 60 61 m->asid = asid_get(); 58 62 59 63 /* … … 200 204 201 205 cpu_priority_restore(pri); 202 } 206 207 vm_install_arch(m); 208 209 VM = m; 210 } -
src/proc/the.c
r8e3f47b3 r1084a784 44 44 the->thread = NULL; 45 45 the->task = NULL; 46 the->vm = NULL; 46 47 } 47 48 -
src/time/clock.c
r8e3f47b3 r1084a784 40 40 #include <list.h> 41 41 #include <arch/atomic.h> 42 #include <proc/thread.h> 42 43 43 44 /** Clock routine
Note:
See TracChangeset
for help on using the changeset viewer.