Rev 105 | Rev 109 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 105 | Rev 106 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | #include <mm/page.h> |
33 | #include <mm/page.h> |
34 | #include <arch/mm/page.h> |
34 | #include <arch/mm/page.h> |
35 | #include <arch/interrupt.h> |
35 | #include <arch/interrupt.h> |
36 | #include <arch/asm.h> |
36 | #include <arch/asm.h> |
37 | #include <synch/spinlock.h> |
37 | #include <synch/spinlock.h> |
- | 38 | #include <debug.h> |
|
38 | 39 | ||
39 | /* |
40 | /* |
40 | * Note. |
41 | * Note. |
41 | * This is the preliminary code for controlling paging mechanism on ia32. It is |
42 | * This is the preliminary code for controlling paging mechanism on ia32. It is |
42 | * needed by other parts of the kernel for its ability to map virtual addresses |
43 | * needed by other parts of the kernel for its ability to map virtual addresses |
Line 51... | Line 52... | ||
51 | { |
52 | { |
52 | __address dba; |
53 | __address dba; |
53 | __u32 i; |
54 | __u32 i; |
54 | 55 | ||
55 | if (config.cpu_active == 1) { |
56 | if (config.cpu_active == 1) { |
56 | dba = KA2PA(frame_alloc(FRAME_KA | FRAME_PANIC)); |
57 | dba = frame_alloc(FRAME_KA | FRAME_PANIC); |
57 | memsetb(dba, PAGE_SIZE, 0); |
58 | memsetb(dba, PAGE_SIZE, 0); |
58 | 59 | ||
59 | bootstrap_dba = dba; |
60 | bootstrap_dba = dba; |
60 | 61 | ||
61 | /* |
62 | /* |
Line 66... | Line 67... | ||
66 | map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
67 | map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
67 | map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
68 | map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
68 | } |
69 | } |
69 | 70 | ||
70 | trap_register(14, page_fault); |
71 | trap_register(14, page_fault); |
71 | cpu_write_dba(dba); |
72 | cpu_write_dba(KA2PA(dba)); |
72 | } |
73 | } |
73 | else { |
74 | else { |
74 | 75 | ||
75 | /* |
76 | /* |
76 | * Application processors need to create their own view of the |
77 | * Application processors need to create their own view of the |
Line 79... | Line 80... | ||
79 | * processor and adjusts it to fulfill its needs. |
80 | * processor and adjusts it to fulfill its needs. |
80 | */ |
81 | */ |
81 | 82 | ||
82 | dba = frame_alloc(FRAME_KA | FRAME_PANIC); |
83 | dba = frame_alloc(FRAME_KA | FRAME_PANIC); |
83 | memcopy(bootstrap_dba, dba, PAGE_SIZE); |
84 | memcopy(bootstrap_dba, dba, PAGE_SIZE); |
84 | cpu_write_dba(dba); |
85 | cpu_write_dba(KA2PA(dba)); |
85 | } |
86 | } |
86 | 87 | ||
87 | paging_on(); |
88 | paging_on(); |
88 | } |
89 | } |
89 | 90 | ||
Line 119... | Line 120... | ||
119 | if (!pd[pde].present) { |
120 | if (!pd[pde].present) { |
120 | /* |
121 | /* |
121 | * There is currently no page table for this address. Allocate |
122 | * There is currently no page table for this address. Allocate |
122 | * frame for the page table and clean it. |
123 | * frame for the page table and clean it. |
123 | */ |
124 | */ |
124 | newpt = KA2PA(frame_alloc(FRAME_KA)); |
125 | newpt = frame_alloc(FRAME_KA); |
125 | pd[pde].frame_address = newpt >> 12; |
126 | pd[pde].frame_address = KA2PA(newpt) >> 12; |
126 | memsetb(newpt, PAGE_SIZE, 0); |
127 | memsetb(newpt, PAGE_SIZE, 0); |
127 | pd[pde].present = 1; |
128 | pd[pde].present = 1; |
128 | pd[pde].uaccessible = 1; |
129 | pd[pde].uaccessible = 1; |
129 | } |
130 | } |
130 | if (copy) { |
131 | if (copy) { |
131 | newpt = KA2PA(frame_alloc(FRAME_KA)); |
132 | newpt = frame_alloc(FRAME_KA); |
132 | memcopy(pd[pde].frame_address << 12, newpt, PAGE_SIZE); |
133 | memcopy(pd[pde].frame_address << 12, newpt, PAGE_SIZE); |
133 | pd[pde].frame_address = newpt >> 12; |
134 | pd[pde].frame_address = KA2PA(newpt) >> 12; |
134 | } |
135 | } |
135 | 136 | ||
136 | pt = (struct page_specifier *) (pd[pde].frame_address << 12); |
137 | pt = (struct page_specifier *) (pd[pde].frame_address << 12); |
137 | 138 | ||
138 | pt[pte].frame_address = frame >> 12; |
139 | pt[pte].frame_address = frame >> 12; |