Rev 34 | Rev 106 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 34 | Rev 105 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | { |
51 | { |
52 | __address dba; |
52 | __address dba; |
53 | __u32 i; |
53 | __u32 i; |
54 | 54 | ||
55 | if (config.cpu_active == 1) { |
55 | if (config.cpu_active == 1) { |
56 | dba = frame_alloc(FRAME_KA | FRAME_PANIC); |
56 | dba = KA2PA(frame_alloc(FRAME_KA | FRAME_PANIC)); |
57 | memsetb(dba, PAGE_SIZE, 0); |
57 | memsetb(dba, PAGE_SIZE, 0); |
58 | cpu_write_dba(dba); |
- | |
59 | 58 | ||
60 | bootstrap_dba = dba; |
59 | bootstrap_dba = dba; |
61 | 60 | ||
62 | /* |
61 | /* |
63 | * Identity mapping for all but 0th page. |
62 | * Identity mapping for all but 0th page. |
- | 63 | * PA2KA(identity) mapping for all but 0th page. |
|
64 | */ |
64 | */ |
65 | for (i = 1; i < frames; i++) |
65 | for (i = 1; i < frames; i++) { |
66 | map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
66 | 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 | } |
|
67 | 69 | ||
68 | trap_register(14, page_fault); |
70 | trap_register(14, page_fault); |
- | 71 | cpu_write_dba(dba); |
|
69 | } |
72 | } |
70 | else { |
73 | else { |
71 | 74 | ||
72 | /* |
75 | /* |
73 | * Application processors need to create their own view of the |
76 | * Application processors need to create their own view of the |
Line 102... | Line 105... | ||
102 | { |
105 | { |
103 | struct page_specifier *pd, *pt; |
106 | struct page_specifier *pd, *pt; |
104 | __address dba, newpt; |
107 | __address dba, newpt; |
105 | int pde, pte; |
108 | int pde, pte; |
106 | 109 | ||
- | 110 | // TODO: map_page_to_frame should take dba as a parameter |
|
107 | dba = cpu_read_dba(); |
111 | // dba = cpu_read_dba(); |
- | 112 | dba = bootstrap_dba; |
|
108 | 113 | ||
109 | pde = page >> 22; /* page directory entry */ |
114 | pde = page >> 22; /* page directory entry */ |
110 | pte = (page >> 12) & 0x3ff; /* page table entry */ |
115 | pte = (page >> 12) & 0x3ff; /* page table entry */ |
111 | 116 | ||
112 | pd = (struct page_specifier *) dba; |
117 | pd = (struct page_specifier *) dba; |
Line 114... | Line 119... | ||
114 | if (!pd[pde].present) { |
119 | if (!pd[pde].present) { |
115 | /* |
120 | /* |
116 | * There is currently no page table for this address. Allocate |
121 | * There is currently no page table for this address. Allocate |
117 | * frame for the page table and clean it. |
122 | * frame for the page table and clean it. |
118 | */ |
123 | */ |
119 | newpt = frame_alloc(FRAME_KA); |
124 | newpt = KA2PA(frame_alloc(FRAME_KA)); |
120 | pd[pde].frame_address = newpt >> 12; |
125 | pd[pde].frame_address = newpt >> 12; |
121 | memsetb(newpt, PAGE_SIZE, 0); |
126 | memsetb(newpt, PAGE_SIZE, 0); |
122 | pd[pde].present = 1; |
127 | pd[pde].present = 1; |
123 | pd[pde].uaccessible = 1; |
128 | pd[pde].uaccessible = 1; |
124 | } |
129 | } |
125 | if (copy) { |
130 | if (copy) { |
126 | newpt = frame_alloc(FRAME_KA); |
131 | newpt = KA2PA(frame_alloc(FRAME_KA)); |
127 | memcopy(pd[pde].frame_address << 12, newpt, PAGE_SIZE); |
132 | memcopy(pd[pde].frame_address << 12, newpt, PAGE_SIZE); |
128 | pd[pde].frame_address = newpt >> 12; |
133 | pd[pde].frame_address = newpt >> 12; |
129 | } |
134 | } |
130 | 135 | ||
131 | pt = (struct page_specifier *) (pd[pde].frame_address << 12); |
136 | pt = (struct page_specifier *) (pd[pde].frame_address << 12); |