Rev 852 | Rev 958 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 852 | Rev 853 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Ondrej Palkovsky |
2 | * Copyright (C) 2005 Ondrej Palkovsky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <arch/drivers/arc.h> |
29 | #include <arch/drivers/arc.h> |
30 | #include <arch/mm/page.h> |
30 | #include <arch/mm/page.h> |
31 | #include <print.h> |
31 | #include <print.h> |
32 | #include <arch.h> |
32 | #include <arch.h> |
33 | #include <arch/byteorder.h> |
33 | #include <arch/byteorder.h> |
34 | #include <arch/mm/frame.h> |
34 | #include <arch/mm/frame.h> |
35 | #include <mm/frame.h> |
35 | #include <mm/frame.h> |
36 | #include <interrupt.h> |
36 | #include <interrupt.h> |
37 | #include <align.h> |
37 | #include <align.h> |
38 | #include <console/console.h> |
38 | #include <console/console.h> |
39 | #include <console/kconsole.h> |
39 | #include <console/kconsole.h> |
40 | #include <console/cmd.h> |
40 | #include <console/cmd.h> |
- | 41 | #include <mm/slab.h> |
|
41 | 42 | ||
42 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
43 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
43 | /* Here is the SGI type */ |
44 | /* Here is the SGI type */ |
44 | static char *basetypes[] = { |
45 | static char *basetypes[] = { |
45 | "ExceptionBlock", |
46 | "ExceptionBlock", |
46 | "SystemParameterBlock", |
47 | "SystemParameterBlock", |
47 | "FreeContiguous", |
48 | "FreeContiguous", |
48 | "FreeMemory", |
49 | "FreeMemory", |
49 | "BadMemory", |
50 | "BadMemory", |
50 | "LoadedProgram", |
51 | "LoadedProgram", |
51 | "FirmwareTemporary", |
52 | "FirmwareTemporary", |
52 | "FirmwarePermanent" |
53 | "FirmwarePermanent" |
53 | }; |
54 | }; |
54 | 55 | ||
55 | static char *ctypes[] = { |
56 | static char *ctypes[] = { |
56 | "ARC_type", |
57 | "ARC_type", |
57 | "CPU_type", |
58 | "CPU_type", |
58 | "FPU_type", |
59 | "FPU_type", |
59 | "PrimaryICache", |
60 | "PrimaryICache", |
60 | "PrimaryDCache", |
61 | "PrimaryDCache", |
61 | "SecondaryICache", |
62 | "SecondaryICache", |
62 | "SecondaryDCache", |
63 | "SecondaryDCache", |
63 | "SecondaryCache", |
64 | "SecondaryCache", |
64 | "Memory", |
65 | "Memory", |
65 | "EISAAdapter", |
66 | "EISAAdapter", |
66 | "TCAdapter", |
67 | "TCAdapter", |
67 | "SCSIAdapter", |
68 | "SCSIAdapter", |
68 | "DTIAdapter", |
69 | "DTIAdapter", |
69 | "MultiFunctionAdapter", |
70 | "MultiFunctionAdapter", |
70 | "DiskController", |
71 | "DiskController", |
71 | "TapeController", |
72 | "TapeController", |
72 | "CDROMController", |
73 | "CDROMController", |
73 | "WORMController", |
74 | "WORMController", |
74 | "SerialController", |
75 | "SerialController", |
75 | "NetworkController", |
76 | "NetworkController", |
76 | "DisplayController", |
77 | "DisplayController", |
77 | "ParallelController", |
78 | "ParallelController", |
78 | "PointerController", |
79 | "PointerController", |
79 | "KeyboardController", |
80 | "KeyboardController", |
80 | "AudioController", |
81 | "AudioController", |
81 | "OtherController", |
82 | "OtherController", |
82 | "DiskPeripheral", |
83 | "DiskPeripheral", |
83 | "FloppyDiskPeripheral", |
84 | "FloppyDiskPeripheral", |
84 | "TapePeripheral", |
85 | "TapePeripheral", |
85 | "ModemPeripheral", |
86 | "ModemPeripheral", |
86 | "MonitorPeripheral", |
87 | "MonitorPeripheral", |
87 | "PrinterPeripheral", |
88 | "PrinterPeripheral", |
88 | "PointerPeripheral", |
89 | "PointerPeripheral", |
89 | "KeyboardPeripheral", |
90 | "KeyboardPeripheral", |
90 | "TerminalPeripheral", |
91 | "TerminalPeripheral", |
91 | "OtherPeripheral", |
92 | "OtherPeripheral", |
92 | "LinePeripheral", |
93 | "LinePeripheral", |
93 | "NetworkPeripheral" |
94 | "NetworkPeripheral" |
94 | "OtherPeripheral", |
95 | "OtherPeripheral", |
95 | "XTalkAdapter", |
96 | "XTalkAdapter", |
96 | "PCIAdapter", |
97 | "PCIAdapter", |
97 | "GIOAdapter", |
98 | "GIOAdapter", |
98 | "TPUAdapter", |
99 | "TPUAdapter", |
99 | "Anonymous" |
100 | "Anonymous" |
100 | }; |
101 | }; |
101 | 102 | ||
102 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
103 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
103 | static arc_func_vector_t *arc_entry; |
104 | static arc_func_vector_t *arc_entry; |
104 | 105 | ||
105 | 106 | ||
106 | static void arc_putchar(char ch); |
107 | static void arc_putchar(char ch); |
107 | 108 | ||
108 | /** Return true if ARC is available */ |
109 | /** Return true if ARC is available */ |
109 | int arc_enabled(void) |
110 | int arc_enabled(void) |
110 | { |
111 | { |
111 | return sbp != NULL; |
112 | return sbp != NULL; |
112 | } |
113 | } |
113 | 114 | ||
- | 115 | ||
- | 116 | /** Print configuration data that ARC reports about component */ |
|
- | 117 | static void arc_print_confdata(arc_component *c) |
|
- | 118 | { |
|
- | 119 | cm_resource_list *configdata; |
|
- | 120 | int i; |
|
- | 121 | ||
- | 122 | if (!c->configdatasize) |
|
- | 123 | return; /* No configuration data */ |
|
- | 124 | ||
- | 125 | configdata = malloc(c->configdatasize, 0); |
|
- | 126 | ||
- | 127 | if (arc_entry->getconfigurationdata(configdata, c)) { |
|
- | 128 | free(configdata); |
|
- | 129 | return; |
|
- | 130 | } |
|
- | 131 | /* Does not seem to return meaningful data, don't use now */ |
|
- | 132 | free(configdata); |
|
- | 133 | return; |
|
- | 134 | ||
- | 135 | for (i=0; i < configdata->count; i++) { |
|
- | 136 | switch (configdata->descr[i].type) { |
|
- | 137 | case CmResourceTypePort: |
|
- | 138 | printf("Port: %P-size:%d ", |
|
- | 139 | (__address)configdata->descr[i].u.port.start, |
|
- | 140 | configdata->descr[i].u.port.length); |
|
- | 141 | break; |
|
- | 142 | case CmResourceTypeInterrupt: |
|
- | 143 | printf("Irq: level(%d) vector(%d) ", |
|
- | 144 | configdata->descr[i].u.interrupt.level, |
|
- | 145 | configdata->descr[i].u.interrupt.vector); |
|
- | 146 | break; |
|
- | 147 | case CmResourceTypeMemory: |
|
- | 148 | printf("Memory: %P-size:%d ", |
|
- | 149 | (__address)configdata->descr[i].u.port.start, |
|
- | 150 | configdata->descr[i].u.port.length); |
|
- | 151 | break; |
|
- | 152 | default: |
|
- | 153 | break; |
|
- | 154 | } |
|
- | 155 | } |
|
- | 156 | ||
- | 157 | free(configdata); |
|
- | 158 | } |
|
- | 159 | ||
- | 160 | /** Print information about component */ |
|
114 | static void arc_print_component(arc_component *c) |
161 | static void arc_print_component(arc_component *c) |
115 | { |
162 | { |
116 | int i; |
163 | int i; |
117 | 164 | ||
118 | printf("%s: ",ctypes[c->type]); |
165 | printf("%s: ",ctypes[c->type]); |
119 | for (i=0;i < c->identifier_len;i++) |
166 | for (i=0;i < c->identifier_len;i++) |
120 | arc_putchar(c->identifier[i]); |
167 | printf("%c",c->identifier[i]); |
- | 168 | ||
- | 169 | printf(" "); |
|
121 | arc_putchar('\n'); |
170 | arc_print_confdata(c); |
- | 171 | printf("\n"); |
|
122 | } |
172 | } |
123 | 173 | ||
- | 174 | /** |
|
- | 175 | * Read from ARC bios configuration data and print it |
|
- | 176 | */ |
|
124 | void arc_print_devices(void) |
177 | static int cmd_arc_print_devices(cmd_arg_t *argv) |
125 | { |
178 | { |
126 | arc_component *c,*next; |
179 | arc_component *c,*next; |
127 | 180 | ||
128 | if (!arc_enabled()) |
- | |
129 | return; |
- | |
130 | - | ||
131 | c = arc_entry->getchild(NULL); |
181 | c = arc_entry->getchild(NULL); |
132 | while (c) { |
182 | while (c) { |
133 | arc_print_component(c); |
183 | arc_print_component(c); |
134 | next = arc_entry->getchild(c); |
184 | next = arc_entry->getchild(c); |
135 | while (!next) { |
185 | while (!next) { |
136 | next = arc_entry->getpeer(c); |
186 | next = arc_entry->getpeer(c); |
137 | if (!next) |
187 | if (!next) |
138 | c = arc_entry->getparent(c); |
188 | c = arc_entry->getparent(c); |
139 | if (!c) |
189 | if (!c) |
140 | return; |
190 | return 0; |
141 | } |
191 | } |
142 | c = next; |
192 | c = next; |
143 | } |
193 | } |
- | 194 | return 1; |
|
144 | } |
195 | } |
- | 196 | static cmd_info_t devlist_info = { |
|
- | 197 | .name = "arcdevlist", |
|
- | 198 | .description = "Print arc device list", |
|
- | 199 | .func = cmd_arc_print_devices, |
|
- | 200 | .argc = 0 |
|
- | 201 | }; |
|
145 | 202 | ||
- | 203 | ||
- | 204 | /** Read from arc bios memory map and print it |
|
- | 205 | * |
|
- | 206 | */ |
|
146 | void arc_print_memory_map(void) |
207 | static int cmd_arc_print_memmap(cmd_arg_t *argv) |
147 | { |
208 | { |
148 | arc_memdescriptor_t *desc; |
209 | arc_memdescriptor_t *desc; |
149 | 210 | ||
150 | if (!arc_enabled()) |
- | |
151 | return; |
- | |
152 | - | ||
153 | printf("Memory map:\n"); |
211 | printf("Memory map:\n"); |
154 | 212 | ||
155 | desc = arc_entry->getmemorydescriptor(NULL); |
213 | desc = arc_entry->getmemorydescriptor(NULL); |
156 | while (desc) { |
214 | while (desc) { |
157 | printf("%s: %d(%P) (size: %dKB)\n",basetypes[desc->type], |
215 | printf("%s: %d(%P) (size: %dKB)\n",basetypes[desc->type], |
158 | desc->basepage * ARC_FRAME, |
216 | desc->basepage * ARC_FRAME, |
159 | desc->basepage * ARC_FRAME, |
217 | desc->basepage * ARC_FRAME, |
160 | desc->basecount*ARC_FRAME/1024); |
218 | desc->basecount*ARC_FRAME/1024); |
161 | desc = arc_entry->getmemorydescriptor(desc); |
219 | desc = arc_entry->getmemorydescriptor(desc); |
162 | } |
220 | } |
- | 221 | return 1; |
|
163 | } |
222 | } |
- | 223 | static cmd_info_t memmap_info = { |
|
- | 224 | .name = "arcmemmap", |
|
- | 225 | .description = "Print arc memory map", |
|
- | 226 | .func = cmd_arc_print_memmap, |
|
- | 227 | .argc = 0 |
|
- | 228 | }; |
|
164 | 229 | ||
165 | /** Print charactor to console */ |
230 | /** Print charactor to console */ |
166 | static void arc_putchar(char ch) |
231 | static void arc_putchar(char ch) |
167 | { |
232 | { |
168 | __u32 cnt; |
233 | __u32 cnt; |
169 | ipl_t ipl; |
234 | ipl_t ipl; |
170 | 235 | ||
171 | /* TODO: Should be spinlock? */ |
236 | /* TODO: Should be spinlock? */ |
172 | ipl = interrupts_disable(); |
237 | ipl = interrupts_disable(); |
173 | arc_entry->write(1, &ch, 1, &cnt); |
238 | arc_entry->write(1, &ch, 1, &cnt); |
174 | interrupts_restore(ipl); |
239 | interrupts_restore(ipl); |
175 | 240 | ||
176 | } |
241 | } |
177 | 242 | ||
178 | static int cmd_reboot(cmd_arg_t *argv) |
243 | static int cmd_reboot(cmd_arg_t *argv) |
179 | { |
244 | { |
180 | arc_entry->reboot(); |
245 | arc_entry->reboot(); |
181 | return 0; |
246 | return 0; |
182 | } |
247 | } |
183 | static cmd_info_t reboot_info = { |
248 | static cmd_info_t reboot_info = { |
184 | .name = "reboot", |
249 | .name = "reboot", |
185 | .description = "Reboot computer", |
250 | .description = "Reboot computer", |
186 | .func = cmd_reboot, |
251 | .func = cmd_reboot, |
187 | .argc = 0 |
252 | .argc = 0 |
188 | }; |
253 | }; |
189 | 254 | ||
190 | /** Initialize ARC structure |
255 | /** Initialize ARC structure |
191 | * |
256 | * |
192 | * @return 0 - ARC OK, -1 - ARC does not exist |
257 | * @return 0 - ARC OK, -1 - ARC does not exist |
193 | */ |
258 | */ |
194 | int arc_init(void) |
259 | int arc_init(void) |
195 | { |
260 | { |
196 | if (sbp->signature != ARC_MAGIC) { |
261 | if (sbp->signature != ARC_MAGIC) { |
197 | sbp = NULL; |
262 | sbp = NULL; |
198 | return -1; |
263 | return -1; |
199 | } |
264 | } |
200 | arc_entry = sbp->firmwarevector; |
265 | arc_entry = sbp->firmwarevector; |
201 | 266 | ||
202 | arc_putchar('A'); |
267 | arc_putchar('A'); |
203 | arc_putchar('R'); |
268 | arc_putchar('R'); |
204 | arc_putchar('C'); |
269 | arc_putchar('C'); |
205 | arc_putchar('\n'); |
270 | arc_putchar('\n'); |
206 | 271 | ||
207 | /* Add command for resetting the computer */ |
272 | /* Add command for resetting the computer */ |
208 | cmd_initialize(&reboot_info); |
273 | cmd_initialize(&reboot_info); |
209 | cmd_register(&reboot_info); |
274 | cmd_register(&reboot_info); |
- | 275 | cmd_initialize(&memmap_info); |
|
- | 276 | cmd_register(&memmap_info); |
|
- | 277 | cmd_initialize(&devlist_info); |
|
- | 278 | cmd_register(&devlist_info); |
|
210 | 279 | ||
211 | return 0; |
280 | return 0; |
212 | } |
281 | } |
213 | 282 | ||
214 | static bool kbd_polling_enabled; |
283 | static bool kbd_polling_enabled; |
215 | static chardev_t console; |
284 | static chardev_t console; |
216 | 285 | ||
217 | /** Try to get character, return character or -1 if not available */ |
286 | /** Try to get character, return character or -1 if not available */ |
218 | static void arc_keyboard_poll(void) |
287 | static void arc_keyboard_poll(void) |
219 | { |
288 | { |
220 | char ch; |
289 | char ch; |
221 | __u32 count; |
290 | __u32 count; |
222 | long result; |
291 | long result; |
223 | 292 | ||
224 | if (! kbd_polling_enabled) |
293 | if (! kbd_polling_enabled) |
225 | return; |
294 | return; |
226 | 295 | ||
227 | if (arc_entry->getreadstatus(0)) |
296 | if (arc_entry->getreadstatus(0)) |
228 | return; |
297 | return; |
229 | result = arc_entry->read(0, &ch, 1, &count); |
298 | result = arc_entry->read(0, &ch, 1, &count); |
230 | if (result || count!=1) { |
299 | if (result || count!=1) { |
231 | return; |
300 | return; |
232 | } |
301 | } |
233 | if (ch == '\r') |
302 | if (ch == '\r') |
234 | ch = '\n'; |
303 | ch = '\n'; |
235 | if (ch == 0x7f) |
304 | if (ch == 0x7f) |
236 | ch = '\b'; |
305 | ch = '\b'; |
237 | 306 | ||
238 | chardev_push_character(&console, ch); |
307 | chardev_push_character(&console, ch); |
239 | } |
308 | } |
240 | 309 | ||
241 | static char arc_read(chardev_t *dev) |
310 | static char arc_read(chardev_t *dev) |
242 | { |
311 | { |
243 | char ch; |
312 | char ch; |
244 | __u32 count; |
313 | __u32 count; |
245 | long result; |
314 | long result; |
246 | 315 | ||
247 | result = arc_entry->read(0, &ch, 1, &count); |
316 | result = arc_entry->read(0, &ch, 1, &count); |
248 | if (result || count!=1) { |
317 | if (result || count!=1) { |
249 | printf("Error reading from ARC keyboard.\n"); |
318 | printf("Error reading from ARC keyboard.\n"); |
250 | cpu_halt(); |
319 | cpu_halt(); |
251 | } |
320 | } |
252 | if (ch == '\r') |
321 | if (ch == '\r') |
253 | return '\n'; |
322 | return '\n'; |
254 | if (ch == 0x7f) |
323 | if (ch == 0x7f) |
255 | return '\b'; |
324 | return '\b'; |
256 | return ch; |
325 | return ch; |
257 | } |
326 | } |
258 | 327 | ||
259 | static void arc_write(chardev_t *dev, const char ch) |
328 | static void arc_write(chardev_t *dev, const char ch) |
260 | { |
329 | { |
261 | arc_putchar(ch); |
330 | arc_putchar(ch); |
262 | } |
331 | } |
263 | 332 | ||
264 | static void arc_enable(chardev_t *dev) |
333 | static void arc_enable(chardev_t *dev) |
265 | { |
334 | { |
266 | kbd_polling_enabled = true; |
335 | kbd_polling_enabled = true; |
267 | } |
336 | } |
268 | 337 | ||
269 | static void arc_disable(chardev_t *dev) |
338 | static void arc_disable(chardev_t *dev) |
270 | { |
339 | { |
271 | kbd_polling_enabled = false; |
340 | kbd_polling_enabled = false; |
272 | } |
341 | } |
273 | 342 | ||
274 | static chardev_operations_t arc_ops = { |
343 | static chardev_operations_t arc_ops = { |
275 | .resume = arc_enable, |
344 | .resume = arc_enable, |
276 | .suspend = arc_disable, |
345 | .suspend = arc_disable, |
277 | .write = arc_write, |
346 | .write = arc_write, |
278 | .read = arc_read |
347 | .read = arc_read |
279 | }; |
348 | }; |
280 | 349 | ||
281 | iroutine old_timer; |
350 | iroutine old_timer; |
282 | /** Do polling on timer interrupt */ |
351 | /** Do polling on timer interrupt */ |
283 | static void timer_replace(int n, void *stack) |
352 | static void timer_replace(int n, void *stack) |
284 | { |
353 | { |
285 | arc_keyboard_poll(); |
354 | arc_keyboard_poll(); |
286 | old_timer(n, stack); |
355 | old_timer(n, stack); |
287 | arc_keyboard_poll(); |
356 | arc_keyboard_poll(); |
288 | } |
357 | } |
289 | 358 | ||
290 | void arc_console(void) |
359 | void arc_console(void) |
291 | { |
360 | { |
292 | kbd_polling_enabled = true; |
361 | kbd_polling_enabled = true; |
293 | 362 | ||
294 | chardev_initialize("arc_console", &console, &arc_ops); |
363 | chardev_initialize("arc_console", &console, &arc_ops); |
295 | old_timer = int_register(TIMER_IRQ, "arc_kb_poll", timer_replace); |
364 | old_timer = int_register(TIMER_IRQ, "arc_kb_poll", timer_replace); |
296 | stdin = &console; |
365 | stdin = &console; |
297 | stdout = &console; |
366 | stdout = &console; |
298 | } |
367 | } |
299 | 368 | ||
300 | /* Initialize frame zones from ARC firmware. |
369 | /* Initialize frame zones from ARC firmware. |
301 | * In the future we may use even the FirmwareTemporary regions, |
370 | * In the future we may use even the FirmwareTemporary regions, |
302 | * currently we use the FreeMemory (what about the LoadedProgram?) |
371 | * currently we use the FreeMemory (what about the LoadedProgram?) |
303 | */ |
372 | */ |
304 | void arc_frame_init(void) |
373 | void arc_frame_init(void) |
305 | { |
374 | { |
306 | arc_memdescriptor_t *desc; |
375 | arc_memdescriptor_t *desc; |
307 | int total = 0; |
376 | int total = 0; |
308 | __address base; |
377 | __address base; |
309 | size_t basesize; |
378 | size_t basesize; |
310 | 379 | ||
311 | desc = arc_entry->getmemorydescriptor(NULL); |
380 | desc = arc_entry->getmemorydescriptor(NULL); |
312 | while (desc) { |
381 | while (desc) { |
313 | if (desc->type == FreeMemory || |
382 | if (desc->type == FreeMemory || |
314 | desc->type == FreeContiguous) { |
383 | desc->type == FreeContiguous) { |
315 | base = desc->basepage*ARC_FRAME; |
384 | base = desc->basepage*ARC_FRAME; |
316 | basesize = desc->basecount*ARC_FRAME; |
385 | basesize = desc->basecount*ARC_FRAME; |
317 | 386 | ||
318 | if (base % FRAME_SIZE ) { |
387 | if (base % FRAME_SIZE ) { |
319 | basesize -= FRAME_SIZE - (base % FRAME_SIZE); |
388 | basesize -= FRAME_SIZE - (base % FRAME_SIZE); |
320 | base = ALIGN_UP(base, FRAME_SIZE); |
389 | base = ALIGN_UP(base, FRAME_SIZE); |
321 | } |
390 | } |
322 | basesize = ALIGN_DOWN(basesize, FRAME_SIZE); |
391 | basesize = ALIGN_DOWN(basesize, FRAME_SIZE); |
323 | 392 | ||
324 | total += basesize; |
393 | total += basesize; |
325 | 394 | ||
326 | zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), |
395 | zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), |
327 | ADDR2PFN(base), 0); |
396 | ADDR2PFN(base), 0); |
328 | } |
397 | } |
329 | desc = arc_entry->getmemorydescriptor(desc); |
398 | desc = arc_entry->getmemorydescriptor(desc); |
330 | } |
399 | } |
331 | 400 | ||
332 | config.memory_size = total; |
401 | config.memory_size = total; |
333 | } |
402 | } |
334 | 403 | ||
335 | 404 |