Rev 2415 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2415 | Rev 2464 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | #include <typedefs.h> |
42 | #include <typedefs.h> |
43 | #include <arch/types.h> |
43 | #include <arch/types.h> |
44 | #include <interrupt.h> |
44 | #include <interrupt.h> |
45 | #include <arch/mm/frame.h> |
45 | #include <arch/mm/frame.h> |
46 | 46 | ||
47 | - | ||
48 | /** Initializes page tables. |
47 | /** Initializes page tables. |
49 | * |
48 | * |
50 | * 1:1 virtual-physical mapping is created in kernel address space. Mapping |
49 | * 1:1 virtual-physical mapping is created in kernel address space. Mapping |
51 | * for table with exception vectors is also created. |
50 | * for table with exception vectors is also created. |
52 | */ |
51 | */ |
Line 57... | Line 56... | ||
57 | 56 | ||
58 | page_mapping_operations = &pt_mapping_operations; |
57 | page_mapping_operations = &pt_mapping_operations; |
59 | 58 | ||
60 | flags = PAGE_CACHEABLE; |
59 | flags = PAGE_CACHEABLE; |
61 | 60 | ||
62 | // PA2KA(identity) mapping for all frames until last_frame |
61 | /* PA2KA(identity) mapping for all frames until last_frame */ |
63 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
62 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
64 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
63 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
65 | } |
64 | } |
66 | 65 | ||
67 | // create mapping for exception table at high offset |
66 | /* create mapping for exception table at high offset */ |
68 | #ifdef HIGH_EXCEPTION_VECTORS |
67 | #ifdef HIGH_EXCEPTION_VECTORS |
69 | void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); |
68 | void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); |
70 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); |
69 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); |
71 | #else |
70 | #else |
72 | #error "Only high exception vector supported now" |
71 | #error "Only high exception vector supported now" |
73 | #endif |
72 | #endif |
74 | 73 | ||
75 | as_switch(NULL, AS_KERNEL); |
74 | as_switch(NULL, AS_KERNEL); |
76 | 75 | ||
77 | boot_page_table_free(); |
76 | boot_page_table_free(); |
78 | } |
77 | } |
Line 87... | Line 86... | ||
87 | * |
86 | * |
88 | * @return Virtual address where device will be accessible. |
87 | * @return Virtual address where device will be accessible. |
89 | */ |
88 | */ |
90 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
89 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
91 | { |
90 | { |
92 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { |
91 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > |
- | 92 | KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { |
|
93 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
93 | panic("Unable to map physical memory %p (%d bytes)", |
- | 94 | physaddr, size) |
|
94 | } |
95 | } |
95 | 96 | ||
96 | uintptr_t virtaddr = PA2KA(last_frame); |
97 | uintptr_t virtaddr = PA2KA(last_frame); |
97 | pfn_t i; |
98 | pfn_t i; |
98 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { |
99 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { |
99 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), |
100 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), |
- | 101 | physaddr + PFN2ADDR(i), |
|
100 | PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); |
102 | PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); |
101 | } |
103 | } |
102 | 104 | ||
103 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
105 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
104 | return virtaddr; |
106 | return virtaddr; |
105 | } |
107 | } |
106 | 108 | ||
107 | - | ||
108 | /** @} |
109 | /** @} |
109 | */ |
110 | */ |
110 | - |