Rev 2284 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2284 | Rev 2290 | ||
---|---|---|---|
Line 54... | Line 54... | ||
54 | 54 | ||
55 | page_mapping_operations = &pt_mapping_operations; |
55 | page_mapping_operations = &pt_mapping_operations; |
56 | 56 | ||
57 | flags = PAGE_CACHEABLE; |
57 | flags = PAGE_CACHEABLE; |
58 | 58 | ||
59 | /* PA2KA(identity) mapping for all frames until last_frame */ |
59 | // PA2KA(identity) mapping for all frames until last_frame |
60 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
60 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
61 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
61 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
62 | } |
62 | } |
63 | 63 | ||
64 | // Create mapping for exception table at high offcet |
64 | // create mapping for exception table at high offset |
65 | #ifdef HIGH_EXCEPTION_VECTORS |
65 | #ifdef HIGH_EXCEPTION_VECTORS |
66 | /* Note: this mapping cann't be done by hw_map because fixed exception |
66 | // Note: this mapping cann't be done by hw_map because fixed exception |
67 | vector is stored at fixed virtual address |
67 | // vector is stored at fixed virtual address |
68 | */ |
- | |
69 | // reserve frame for exception table |
68 | // reserve frame for exception table |
70 | void* virtaddr = frame_alloc( ONE_FRAME ,FRAME_KA); |
69 | void* virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); |
71 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags ); |
70 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); |
72 | #endif |
71 | #endif |
73 | - | ||
74 | // TODO: move to the kernel space |
72 | // TODO: #else |
75 | // page_mapping_insert(AS_KERNEL, 0xffff0000, 0x00000000, flags); |
- | |
76 | // TODO: remove when aux_printf not needed |
- | |
77 | // page_mapping_insert(AS_KERNEL, 0x0000000, 0x0000000, flags); |
- | |
78 | page_mapping_insert(AS_KERNEL, 0x1000000, 0x1000000, flags); |
- | |
79 | // page_mapping_insert(AS_KERNEL, 0x1100000, 0x1100000, flags); |
- | |
80 | // page_mapping_insert(AS_KERNEL, 0x1500000, 0x1500000, flags); |
- | |
81 | // page_mapping_insert(AS_KERNEL, 0x1600000, 0x1600000, flags); |
- | |
82 | - | ||
83 | // page_mapping_insert(AS_KERNEL, 0xffff0000, 0xffff0000, flags); |
- | |
84 | - | ||
85 | 73 | ||
86 | as_switch(NULL, AS_KERNEL); |
74 | as_switch(NULL, AS_KERNEL); |
87 | - | ||
88 | } |
75 | } |
89 | 76 | ||
90 | /** |
77 | /** |
91 | * Map device into kernel space. |
78 | * Map device into kernel space. |
92 | * |
79 | * |
Line 94... | Line 81... | ||
94 | * from kernel and not bufferable. |
81 | * from kernel and not bufferable. |
95 | * |
82 | * |
96 | * \param physaddr Physical addres where device is connected |
83 | * \param physaddr Physical addres where device is connected |
97 | * \param size Length of area where device is present |
84 | * \param size Length of area where device is present |
98 | * \return Virtual address where device will be accessable |
85 | * \return Virtual address where device will be accessable |
99 | * Note: This is copy of IA32 hw_map code |
- | |
100 | */ |
86 | */ |
101 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
87 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
102 | { |
88 | { |
103 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
89 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { |
104 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
90 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
- | 91 | } |
|
105 | 92 | ||
106 | uintptr_t virtaddr = PA2KA(last_frame); |
93 | uintptr_t virtaddr = PA2KA(last_frame); |
107 | pfn_t i; |
94 | pfn_t i; |
108 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
95 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { |
109 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); |
96 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), |
- | 97 | PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); |
|
- | 98 | } |
|
110 | 99 | ||
111 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
100 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
112 | - | ||
113 | return virtaddr; |
101 | return virtaddr; |
114 | } |
102 | } |
115 | 103 | ||
116 | 104 | ||
117 | /** @} |
105 | /** @} |