Rev 958 | Rev 1411 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 958 | Rev 1382 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | #include <arch/mm/frame.h> |
31 | #include <arch/mm/frame.h> |
32 | #include <mm/frame.h> |
32 | #include <mm/frame.h> |
33 | #include <mm/page.h> |
33 | #include <mm/page.h> |
34 | #include <mm/as.h> |
34 | #include <mm/as.h> |
35 | #include <arch/types.h> |
35 | #include <arch/types.h> |
- | 36 | #include <align.h> |
|
36 | #include <config.h> |
37 | #include <config.h> |
37 | #include <func.h> |
38 | #include <func.h> |
38 | #include <arch/interrupt.h> |
39 | #include <arch/interrupt.h> |
39 | #include <arch/asm.h> |
40 | #include <arch/asm.h> |
40 | #include <debug.h> |
41 | #include <debug.h> |
41 | #include <memstr.h> |
42 | #include <memstr.h> |
42 | #include <print.h> |
43 | #include <print.h> |
43 | #include <interrupt.h> |
44 | #include <interrupt.h> |
44 | 45 | ||
- | 46 | ||
45 | void page_arch_init(void) |
47 | void page_arch_init(void) |
46 | { |
48 | { |
47 | __address cur; |
49 | __address cur; |
48 | int flags; |
50 | int flags; |
49 | 51 | ||
Line 67... | Line 69... | ||
67 | write_cr3((__address) AS_KERNEL->page_table); |
69 | write_cr3((__address) AS_KERNEL->page_table); |
68 | } |
70 | } |
69 | 71 | ||
70 | paging_on(); |
72 | paging_on(); |
71 | } |
73 | } |
- | 74 | ||
- | 75 | ||
- | 76 | __address hw_map(__address physaddr, size_t size) |
|
- | 77 | { |
|
- | 78 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
|
- | 79 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
|
- | 80 | ||
- | 81 | __address virtaddr = PA2KA(last_frame); |
|
- | 82 | pfn_t i; |
|
- | 83 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
|
- | 84 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); |
|
- | 85 | ||
- | 86 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
|
- | 87 | ||
- | 88 | return virtaddr; |
|
- | 89 | } |