Rev 1051 | Rev 1064 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1051 | Rev 1063 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #include <config.h> |
37 | #include <config.h> |
38 | #include <memstr.h> |
38 | #include <memstr.h> |
39 | #include <interrupt.h> |
39 | #include <interrupt.h> |
40 | #include <print.h> |
40 | #include <print.h> |
41 | #include <panic.h> |
41 | #include <panic.h> |
- | 42 | #include <align.h> |
|
42 | 43 | ||
43 | /* Definitions for identity page mapper */ |
44 | /* Definitions for identity page mapper */ |
44 | pte_t helper_ptl1[512] __attribute__((aligned (PAGE_SIZE))); |
45 | pte_t helper_ptl1[512] __attribute__((aligned (PAGE_SIZE))); |
45 | pte_t helper_ptl2[512] __attribute__((aligned (PAGE_SIZE))); |
46 | pte_t helper_ptl2[512] __attribute__((aligned (PAGE_SIZE))); |
46 | pte_t helper_ptl3[512] __attribute__((aligned (PAGE_SIZE))); |
47 | pte_t helper_ptl3[512] __attribute__((aligned (PAGE_SIZE))); |
Line 68... | Line 69... | ||
68 | } |
69 | } |
69 | #define SETUP_FRAME(ptl3, page, tgt) { \ |
70 | #define SETUP_FRAME(ptl3, page, tgt) { \ |
70 | SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ |
71 | SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ |
71 | SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ |
72 | SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ |
72 | } |
73 | } |
73 | - | ||
74 | void page_arch_init(void) |
74 | void page_arch_init(void) |
75 | { |
75 | { |
76 | __address cur; |
76 | __address cur; |
77 | int flags; |
77 | int i; |
- | 78 | int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL; |
|
78 | 79 | ||
79 | if (config.cpu_active == 1) { |
80 | if (config.cpu_active == 1) { |
80 | page_mapping_operations = &pt_mapping_operations; |
81 | page_mapping_operations = &pt_mapping_operations; |
81 | 82 | ||
82 | /* |
83 | /* |
83 | * PA2KA(identity) mapping for all frames. |
84 | * PA2KA(identity) mapping for all frames. |
84 | */ |
85 | */ |
85 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
86 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
86 | flags = PAGE_CACHEABLE | PAGE_EXEC; |
87 | /* Standard identity mapping */ |
87 | if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) |
88 | page_mapping_insert(AS_KERNEL, PA2KA_IDENT(cur), cur, identity_flags); |
- | 89 | } |
|
88 | flags |= PAGE_GLOBAL; |
90 | /* Upper kernel mapping |
- | 91 | * - from zero to top of kernel (include bottom addresses |
|
- | 92 | * because some are needed for init ) |
|
- | 93 | */ |
|
- | 94 | for (cur = PA2KA_CODE(0); cur < config.base+config.kernel_size; cur += FRAME_SIZE) { |
|
89 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
95 | page_mapping_insert(AS_KERNEL, cur, KA2PA(cur), identity_flags); |
90 | } |
96 | } |
- | 97 | for (i=0; i < init.cnt; i++) { |
|
- | 98 | for (cur=init.tasks[i].addr;cur < init.tasks[i].size; cur += FRAME_SIZE) { |
|
- | 99 | page_mapping_insert(AS_KERNEL, PA2KA_CODE(KA2PA(cur)), KA2PA(cur), identity_flags); |
|
- | 100 | } |
|
- | 101 | } |
|
- | 102 | ||
91 | exc_register(14, "page_fault", (iroutine)page_fault); |
103 | exc_register(14, "page_fault", (iroutine)page_fault); |
92 | write_cr3((__address) AS_KERNEL->page_table); |
104 | write_cr3((__address) AS_KERNEL->page_table); |
93 | } |
105 | } |
94 | else { |
106 | else { |
95 | write_cr3((__address) AS_KERNEL->page_table); |
107 | write_cr3((__address) AS_KERNEL->page_table); |