Rev 2411 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2411 | Rev 2415 | ||
---|---|---|---|
Line 43... | Line 43... | ||
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 | 47 | ||
- | 48 | /** Initializes page tables. |
|
48 | /** |
49 | * |
49 | * Initializes kernel adress space page tables, sets abourts exceptions vectors |
50 | * 1:1 virtual-physical mapping is created in kernel address space. Mapping |
- | 51 | * for table with exception vectors is also created. |
|
50 | */ |
52 | */ |
51 | void page_arch_init(void) |
53 | void page_arch_init(void) |
52 | { |
54 | { |
53 | uintptr_t cur; |
55 | uintptr_t cur; |
54 | int flags; |
56 | int flags; |
Line 62... | Line 64... | ||
62 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
64 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
63 | } |
65 | } |
64 | 66 | ||
65 | // create mapping for exception table at high offset |
67 | // create mapping for exception table at high offset |
66 | #ifdef HIGH_EXCEPTION_VECTORS |
68 | #ifdef HIGH_EXCEPTION_VECTORS |
67 | /* Note: this mapping cann't be done by hw_map because fixed |
- | |
68 | exception vector is stored at fixed virtual address |
- | |
69 | reserve frame for exception table |
- | |
70 | */ |
- | |
71 | void* virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); |
69 | void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); |
72 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); |
70 | page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); |
73 | #else |
71 | #else |
74 | #error "Only high eception vector supported now" |
72 | #error "Only high exception vector supported now" |
75 | #endif |
73 | #endif |
76 | 74 | ||
77 | as_switch(NULL, AS_KERNEL); |
75 | as_switch(NULL, AS_KERNEL); |
78 | 76 | ||
79 | boot_page_table_free(); |
77 | boot_page_table_free(); |
80 | } |
78 | } |
81 | 79 | ||
82 | /** |
- | |
83 | * Map device into kernel space. |
80 | /** Maps device into the kernel space. |
84 | * |
81 | * |
85 | * This function adds mapping of physical address that is read/write only |
82 | * Maps physical address of device into kernel virtual address space (so it can |
86 | * from kernel and not bufferable. |
83 | * be accessed only by kernel through virtual address). |
87 | * |
84 | * |
88 | * @param physaddr Physical addres where device is connected |
85 | * @param physaddr Physical address where device is connected. |
89 | * @param size Length of area where device is present |
86 | * @param size Length of area where device is present. |
90 | * |
87 | * |
91 | * @return Virtual address where device will be accessable |
88 | * @return Virtual address where device will be accessible. |
92 | */ |
89 | */ |
93 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
90 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
94 | { |
91 | { |
95 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { |
92 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { |
96 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
93 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |