Changeset db3341e in mainline
- Timestamp:
- 2005-09-01T14:28:00Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 623ba26c
- Parents:
- 1dde3b61
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/asm.h
r1dde3b61 rdb3341e 37 37 void asm_fake_loop(__u32 t); 38 38 39 /* TODO: implement the real stuff */40 39 static inline __address get_stack_base(void) 41 40 { 42 return NULL; 41 __address v; 42 43 __asm__ volatile ("andq %%rsp, %0\n" : "=r" (v) : "0" (~((__u64)STACK_SIZE-1))); 44 45 return v; 43 46 } 44 47 … … 52 55 53 56 asm ( 54 "mov % 0, %%dx;"57 "mov %1, %%dx;" 55 58 "inb %%dx,%%al;" 56 "mov %%al, % 1;"59 "mov %%al, %0;" 57 60 :"=m"(out) 58 61 :"m"(port) -
arch/amd64/include/mm/page.h
r1dde3b61 rdb3341e 39 39 40 40 #ifndef __ASM__ 41 # define KA2PA(x) 42 # define PA2KA(x) 41 # define KA2PA(x) (((__address) (x)) + 0x80000000) 42 # define PA2KA(x) (((__address) (x)) - 0x80000000) 43 43 #else 44 # define KA2PA(x) 45 # define PA2KA(x)((x)) - 0x80000000)44 # define KA2PA(x) ((x) + 0x80000000) 45 //# define PA2KA(x) ((x)) - 0x80000000) 46 46 #endif 47 47 48 #define PTL0_INDEX_ARCH(vaddr) 049 #define PTL1_INDEX_ARCH(vaddr) 050 #define PTL2_INDEX_ARCH(vaddr) 051 #define PTL3_INDEX_ARCH(vaddr) 048 #define PTL0_INDEX_ARCH(vaddr) (((vaddr)>>39)&0x1ff) 49 #define PTL1_INDEX_ARCH(vaddr) (((vaddr)>>30)&0x1ff) 50 #define PTL2_INDEX_ARCH(vaddr) (((vaddr)>>21)&0x1ff) 51 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>12)&0x1ff) 52 52 53 #define GET_PTL0_ADDRESS_ARCH() 0 54 #define SET_PTL0_ADDRESS_ARCH(ptl0) 53 #define GET_PTL0_ADDRESS_ARCH() ((pte_t *) read_cr3()) 54 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) ((((__u64) ((pte_t *)(ptl0))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl0))[(i)].addr_32_51)<<32 ))) 55 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) ((pte_t *) ((((__u64) ((pte_t *)(ptl1))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl1))[(i)].addr_32_51)<<32 ))) 56 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) ((pte_t *) ((((__u64) ((pte_t *)(ptl2))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl2))[(i)].addr_32_51)<<32 ))) 57 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((__address *) ((((__u64) ((pte_t *)(ptl3))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl3))[(i)].addr_32_51)<<32 ))) 55 58 56 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) 0) 57 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) ((pte_t *) 0) 58 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) ((pte_t *) 0) 59 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((pte_t *) 0) 59 #define SET_PTL0_ADDRESS_ARCH(ptl0) (write_cr3((__address) (ptl0))) 60 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) set_pt_addr((pte_t *)(ptl0), (index_t)(i), a) 61 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) set_pt_addr((pte_t *)(ptl1), (index_t)(i), a) 62 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) set_pt_addr((pte_t *)(ptl2), (index_t)(i), a) 63 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) set_pt_addr((pte_t *)(ptl3), (index_t)(i), a) 60 64 61 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)62 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)63 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)64 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)65 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) 66 #define GET_PTL2_FLAGS_ARCH(ptl1, i) get_pt_flags((pte_t *)(ptl1), (index_t)(i)) 67 #define GET_PTL3_FLAGS_ARCH(ptl2, i) get_pt_flags((pte_t *)(ptl2), (index_t)(i)) 68 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *)(ptl3), (index_t)(i)) 65 69 66 #define GET_PTL1_FLAGS_ARCH(ptl0, i) 0 67 #define GET_PTL2_FLAGS_ARCH(ptl1, i) 0 68 #define GET_PTL3_FLAGS_ARCH(ptl2, i) 0 69 #define GET_FRAME_FLAGS_ARCH(ptl3, i) 0 70 71 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) 72 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 73 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 74 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) 70 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x)) 71 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) set_pt_flags((pte_t *)(ptl1), (index_t)(i), (x)) 72 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) set_pt_flags((pte_t *)(ptl2), (index_t)(i), (x)) 73 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) 75 74 76 75 #ifndef __ASM__ 76 77 typedef struct page_specifier pte_t; 78 79 struct page_specifier { 80 unsigned present : 1; 81 unsigned writeable : 1; 82 unsigned uaccessible : 1; 83 unsigned page_write_through : 1; 84 unsigned page_cache_disable : 1; 85 unsigned accessed : 1; 86 unsigned dirty : 1; 87 unsigned unused: 1; 88 unsigned global : 1; 89 unsigned avl : 3; 90 unsigned addr_12_31 : 30; 91 unsigned addr_32_51 : 21; 92 unsigned no_execute : 1; 93 } __attribute__ ((packed)); 94 95 static inline int get_pt_flags(pte_t *pt, index_t i) 96 { 97 pte_t *p = &pt[i]; 98 99 return ( 100 (!p->page_cache_disable)<<PAGE_CACHEABLE_SHIFT | 101 (!p->present)<<PAGE_PRESENT_SHIFT | 102 p->uaccessible<<PAGE_USER_SHIFT | 103 1<<PAGE_READ_SHIFT | 104 p->writeable<<PAGE_WRITE_SHIFT | 105 (!p->no_execute)<<PAGE_EXEC_SHIFT 106 ); 107 } 108 109 static inline void set_pt_addr(pte_t *pt, index_t i, __address a) 110 { 111 pte_t *p = &pt[i]; 112 113 p->addr_12_31 = (a >> 12) & 0xfffff; 114 p->addr_32_51 = a >> 32; 115 } 116 117 static inline void set_pt_flags(pte_t *pt, index_t i, int flags) 118 { 119 pte_t *p = &pt[i]; 120 121 p->page_cache_disable = !(flags & PAGE_CACHEABLE); 122 p->present = !(flags & PAGE_NOT_PRESENT); 123 p->uaccessible = (flags & PAGE_USER) != 0; 124 p->writeable = (flags & PAGE_WRITE) != 0; 125 p->no_execute = (flags & PAGE_EXEC) == 0; 126 } 127 77 128 extern void page_arch_init(void); 78 129 79 typedef __u64 pte_t;80 130 #endif 81 131 -
arch/amd64/src/mm/page.c
r1dde3b61 rdb3341e 28 28 29 29 #include <mm/page.h> 30 #include <mm/frame.h> 30 31 #include <arch/mm/page.h> 32 #include <arch/interrupt.h> 33 #include <arch/asm.h> 34 #include <config.h> 35 36 #include <memstr.h> 37 38 39 __address bootstrap_dba; 31 40 32 41 void page_arch_init(void) 33 42 { 43 __address dba; 44 count_t i; 45 46 if (config.cpu_active == 1) { 47 dba = frame_alloc(FRAME_KA | FRAME_PANIC); 48 memsetb(dba, PAGE_SIZE, 0); 49 50 bootstrap_dba = dba; 51 52 /* 53 * Identity mapping for all frames. 54 * PA2KA(identity) mapping for all frames. 55 */ 56 for (i = 0; i < frames; i++) { 57 map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE | PAGE_EXEC, KA2PA(dba)); 58 map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE | PAGE_EXEC, KA2PA(dba)); 59 } 60 61 trap_register(14, page_fault); 62 write_cr3(KA2PA(dba)); 63 } 64 else { 65 /* 66 * Application processors need to create their own view of the 67 * virtual address space. Because of that, each AP copies 68 * already-initialized paging information from the bootstrap 69 * processor and adjusts it to fulfill its needs. 70 */ 71 72 dba = frame_alloc(FRAME_KA | FRAME_PANIC); 73 memcpy((void *)dba, (void *)bootstrap_dba , PAGE_SIZE); 74 write_cr3(KA2PA(dba)); 75 } 34 76 } -
src/build.amd64
r1dde3b61 rdb3341e 5 5 (cd ../arch/amd64/src;make gencontext;./gencontext) 6 6 # Create links to ia32 architecture 7 for a in drivers bios interrupt.c; do7 for a in drivers bios; do 8 8 ln -sf ../../ia32/src/$a ../arch/amd64/src/ 9 9 done -
src/mm/page.c
r1dde3b61 rdb3341e 37 37 38 38 void page_init(void) 39 { 39 { 40 40 page_arch_init(); 41 41 map_page_to_frame(0x0, 0x0, PAGE_NOT_PRESENT, 0); … … 55 55 int i, cnt, length; 56 56 57 /* TODO: implement portable way of computing page address from address */ 58 length = size + (s - (s & 0xfffff000)); 57 length = size + (s - (s & ~(PAGE_SIZE-1))); 59 58 cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); 60 59
Note:
See TracChangeset
for help on using the changeset viewer.