Rev 2745 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2745 | Rev 2797 | ||
---|---|---|---|
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 | /** @addtogroup mips32 |
29 | /** @addtogroup mips32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <arch/drivers/arc.h> |
35 | #include <arch/drivers/arc.h> |
36 | #include <arch/mm/page.h> |
36 | #include <arch/mm/page.h> |
37 | #include <print.h> |
37 | #include <print.h> |
38 | #include <arch.h> |
38 | #include <arch.h> |
39 | #include <arch/byteorder.h> |
39 | #include <byteorder.h> |
40 | #include <arch/mm/frame.h> |
40 | #include <arch/mm/frame.h> |
41 | #include <mm/frame.h> |
41 | #include <mm/frame.h> |
42 | #include <interrupt.h> |
42 | #include <interrupt.h> |
43 | #include <align.h> |
43 | #include <align.h> |
44 | #include <console/console.h> |
44 | #include <console/console.h> |
45 | #include <console/kconsole.h> |
45 | #include <console/kconsole.h> |
46 | #include <console/cmd.h> |
46 | #include <console/cmd.h> |
47 | #include <mm/slab.h> |
47 | #include <mm/slab.h> |
48 | 48 | ||
49 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
49 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
50 | /* Here is the SGI type */ |
50 | /* Here is the SGI type */ |
51 | static char *basetypes[] = { |
51 | static char *basetypes[] = { |
52 | "ExceptionBlock", |
52 | "ExceptionBlock", |
53 | "SystemParameterBlock", |
53 | "SystemParameterBlock", |
54 | "FreeContiguous", |
54 | "FreeContiguous", |
55 | "FreeMemory", |
55 | "FreeMemory", |
56 | "BadMemory", |
56 | "BadMemory", |
57 | "LoadedProgram", |
57 | "LoadedProgram", |
58 | "FirmwareTemporary", |
58 | "FirmwareTemporary", |
59 | "FirmwarePermanent" |
59 | "FirmwarePermanent" |
60 | }; |
60 | }; |
61 | 61 | ||
62 | static char *ctypes[] = { |
62 | static char *ctypes[] = { |
63 | "ARC_type", |
63 | "ARC_type", |
64 | "CPU_type", |
64 | "CPU_type", |
65 | "FPU_type", |
65 | "FPU_type", |
66 | "PrimaryICache", |
66 | "PrimaryICache", |
67 | "PrimaryDCache", |
67 | "PrimaryDCache", |
68 | "SecondaryICache", |
68 | "SecondaryICache", |
69 | "SecondaryDCache", |
69 | "SecondaryDCache", |
70 | "SecondaryCache", |
70 | "SecondaryCache", |
71 | "Memory", |
71 | "Memory", |
72 | "EISAAdapter", |
72 | "EISAAdapter", |
73 | "TCAdapter", |
73 | "TCAdapter", |
74 | "SCSIAdapter", |
74 | "SCSIAdapter", |
75 | "DTIAdapter", |
75 | "DTIAdapter", |
76 | "MultiFunctionAdapter", |
76 | "MultiFunctionAdapter", |
77 | "DiskController", |
77 | "DiskController", |
78 | "TapeController", |
78 | "TapeController", |
79 | "CDROMController", |
79 | "CDROMController", |
80 | "WORMController", |
80 | "WORMController", |
81 | "SerialController", |
81 | "SerialController", |
82 | "NetworkController", |
82 | "NetworkController", |
83 | "DisplayController", |
83 | "DisplayController", |
84 | "ParallelController", |
84 | "ParallelController", |
85 | "PointerController", |
85 | "PointerController", |
86 | "KeyboardController", |
86 | "KeyboardController", |
87 | "AudioController", |
87 | "AudioController", |
88 | "OtherController", |
88 | "OtherController", |
89 | "DiskPeripheral", |
89 | "DiskPeripheral", |
90 | "FloppyDiskPeripheral", |
90 | "FloppyDiskPeripheral", |
91 | "TapePeripheral", |
91 | "TapePeripheral", |
92 | "ModemPeripheral", |
92 | "ModemPeripheral", |
93 | "MonitorPeripheral", |
93 | "MonitorPeripheral", |
94 | "PrinterPeripheral", |
94 | "PrinterPeripheral", |
95 | "PointerPeripheral", |
95 | "PointerPeripheral", |
96 | "KeyboardPeripheral", |
96 | "KeyboardPeripheral", |
97 | "TerminalPeripheral", |
97 | "TerminalPeripheral", |
98 | "OtherPeripheral", |
98 | "OtherPeripheral", |
99 | "LinePeripheral", |
99 | "LinePeripheral", |
100 | "NetworkPeripheral" |
100 | "NetworkPeripheral" |
101 | "OtherPeripheral", |
101 | "OtherPeripheral", |
102 | "XTalkAdapter", |
102 | "XTalkAdapter", |
103 | "PCIAdapter", |
103 | "PCIAdapter", |
104 | "GIOAdapter", |
104 | "GIOAdapter", |
105 | "TPUAdapter", |
105 | "TPUAdapter", |
106 | "Anonymous" |
106 | "Anonymous" |
107 | }; |
107 | }; |
108 | 108 | ||
109 | static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000); |
109 | static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000); |
110 | static arc_func_vector_t *arc_entry; |
110 | static arc_func_vector_t *arc_entry; |
111 | 111 | ||
112 | 112 | ||
113 | /** Return true if ARC is available */ |
113 | /** Return true if ARC is available */ |
114 | #define arc_enabled() (sbp != NULL) |
114 | #define arc_enabled() (sbp != NULL) |
115 | 115 | ||
116 | 116 | ||
117 | /** Print configuration data that ARC reports about component */ |
117 | /** Print configuration data that ARC reports about component */ |
118 | static void arc_print_confdata(arc_component *c) |
118 | static void arc_print_confdata(arc_component *c) |
119 | { |
119 | { |
120 | cm_resource_list *configdata; |
120 | cm_resource_list *configdata; |
121 | unsigned int i; |
121 | unsigned int i; |
122 | 122 | ||
123 | if (!c->configdatasize) |
123 | if (!c->configdatasize) |
124 | return; /* No configuration data */ |
124 | return; /* No configuration data */ |
125 | 125 | ||
126 | configdata = malloc(c->configdatasize, 0); |
126 | configdata = malloc(c->configdatasize, 0); |
127 | 127 | ||
128 | if (arc_entry->getconfigurationdata(configdata, c)) { |
128 | if (arc_entry->getconfigurationdata(configdata, c)) { |
129 | free(configdata); |
129 | free(configdata); |
130 | return; |
130 | return; |
131 | } |
131 | } |
132 | /* Does not seem to return meaningful data, don't use now */ |
132 | /* Does not seem to return meaningful data, don't use now */ |
133 | free(configdata); |
133 | free(configdata); |
134 | return; |
134 | return; |
135 | 135 | ||
136 | for (i = 0; i < configdata->count; i++) { |
136 | for (i = 0; i < configdata->count; i++) { |
137 | switch (configdata->descr[i].type) { |
137 | switch (configdata->descr[i].type) { |
138 | case CmResourceTypePort: |
138 | case CmResourceTypePort: |
139 | printf("Port: %p-size:%d ", |
139 | printf("Port: %p-size:%d ", |
140 | (uintptr_t) configdata->descr[i].u.port.start, |
140 | (uintptr_t) configdata->descr[i].u.port.start, |
141 | configdata->descr[i].u.port.length); |
141 | configdata->descr[i].u.port.length); |
142 | break; |
142 | break; |
143 | case CmResourceTypeInterrupt: |
143 | case CmResourceTypeInterrupt: |
144 | printf("Irq: level(%d) vector(%d) ", |
144 | printf("Irq: level(%d) vector(%d) ", |
145 | configdata->descr[i].u.interrupt.level, |
145 | configdata->descr[i].u.interrupt.level, |
146 | configdata->descr[i].u.interrupt.vector); |
146 | configdata->descr[i].u.interrupt.vector); |
147 | break; |
147 | break; |
148 | case CmResourceTypeMemory: |
148 | case CmResourceTypeMemory: |
149 | printf("Memory: %p-size:%d ", |
149 | printf("Memory: %p-size:%d ", |
150 | (uintptr_t)configdata->descr[i].u.port.start, |
150 | (uintptr_t)configdata->descr[i].u.port.start, |
151 | configdata->descr[i].u.port.length); |
151 | configdata->descr[i].u.port.length); |
152 | break; |
152 | break; |
153 | default: |
153 | default: |
154 | break; |
154 | break; |
155 | } |
155 | } |
156 | } |
156 | } |
157 | 157 | ||
158 | free(configdata); |
158 | free(configdata); |
159 | } |
159 | } |
160 | 160 | ||
161 | /** Print information about component */ |
161 | /** Print information about component */ |
162 | static void arc_print_component(arc_component *c) |
162 | static void arc_print_component(arc_component *c) |
163 | { |
163 | { |
164 | unsigned int i; |
164 | unsigned int i; |
165 | 165 | ||
166 | printf("%s: ",ctypes[c->type]); |
166 | printf("%s: ",ctypes[c->type]); |
167 | for (i = 0; i < c->identifier_len; i++) |
167 | for (i = 0; i < c->identifier_len; i++) |
168 | printf("%c", c->identifier[i]); |
168 | printf("%c", c->identifier[i]); |
169 | 169 | ||
170 | printf(" "); |
170 | printf(" "); |
171 | arc_print_confdata(c); |
171 | arc_print_confdata(c); |
172 | printf("\n"); |
172 | printf("\n"); |
173 | } |
173 | } |
174 | 174 | ||
175 | /** |
175 | /** |
176 | * Read from ARC bios configuration data and print it |
176 | * Read from ARC bios configuration data and print it |
177 | */ |
177 | */ |
178 | static int cmd_arc_print_devices(cmd_arg_t *argv) |
178 | static int cmd_arc_print_devices(cmd_arg_t *argv) |
179 | { |
179 | { |
180 | arc_component *c, *next; |
180 | arc_component *c, *next; |
181 | 181 | ||
182 | c = arc_entry->getchild(NULL); |
182 | c = arc_entry->getchild(NULL); |
183 | while (c) { |
183 | while (c) { |
184 | arc_print_component(c); |
184 | arc_print_component(c); |
185 | next = arc_entry->getchild(c); |
185 | next = arc_entry->getchild(c); |
186 | while (!next) { |
186 | while (!next) { |
187 | next = arc_entry->getpeer(c); |
187 | next = arc_entry->getpeer(c); |
188 | if (!next) |
188 | if (!next) |
189 | c = arc_entry->getparent(c); |
189 | c = arc_entry->getparent(c); |
190 | if (!c) |
190 | if (!c) |
191 | return 0; |
191 | return 0; |
192 | } |
192 | } |
193 | c = next; |
193 | c = next; |
194 | } |
194 | } |
195 | return 1; |
195 | return 1; |
196 | } |
196 | } |
197 | static cmd_info_t devlist_info = { |
197 | static cmd_info_t devlist_info = { |
198 | .name = "arcdevlist", |
198 | .name = "arcdevlist", |
199 | .description = "Print arc device list", |
199 | .description = "Print arc device list", |
200 | .func = cmd_arc_print_devices, |
200 | .func = cmd_arc_print_devices, |
201 | .argc = 0 |
201 | .argc = 0 |
202 | }; |
202 | }; |
203 | 203 | ||
204 | 204 | ||
205 | /** Read from arc bios memory map and print it |
205 | /** Read from arc bios memory map and print it |
206 | * |
206 | * |
207 | */ |
207 | */ |
208 | void physmem_print(void) |
208 | void physmem_print(void) |
209 | { |
209 | { |
210 | printf("Base Size Type\n"); |
210 | printf("Base Size Type\n"); |
211 | printf("---------- ---------- ---------\n"); |
211 | printf("---------- ---------- ---------\n"); |
212 | 212 | ||
213 | if (arc_enabled()) { |
213 | if (arc_enabled()) { |
214 | arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL); |
214 | arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL); |
215 | 215 | ||
216 | while (desc) { |
216 | while (desc) { |
217 | printf("%#10x %#10x %s\n", |
217 | printf("%#10x %#10x %s\n", |
218 | desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME, |
218 | desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME, |
219 | basetypes[desc->type]); |
219 | basetypes[desc->type]); |
220 | desc = arc_entry->getmemorydescriptor(desc); |
220 | desc = arc_entry->getmemorydescriptor(desc); |
221 | } |
221 | } |
222 | } else |
222 | } else |
223 | printf("%#10x %#10x free\n", 0, CONFIG_MEMORY_SIZE); |
223 | printf("%#10x %#10x free\n", 0, CONFIG_MEMORY_SIZE); |
224 | } |
224 | } |
225 | 225 | ||
226 | /** Print charactor to console */ |
226 | /** Print charactor to console */ |
227 | static void arc_putchar(char ch) |
227 | static void arc_putchar(char ch) |
228 | { |
228 | { |
229 | uint32_t cnt; |
229 | uint32_t cnt; |
230 | ipl_t ipl; |
230 | ipl_t ipl; |
231 | 231 | ||
232 | /* TODO: Should be spinlock? */ |
232 | /* TODO: Should be spinlock? */ |
233 | ipl = interrupts_disable(); |
233 | ipl = interrupts_disable(); |
234 | arc_entry->write(1, &ch, 1, &cnt); |
234 | arc_entry->write(1, &ch, 1, &cnt); |
235 | interrupts_restore(ipl); |
235 | interrupts_restore(ipl); |
236 | } |
236 | } |
237 | 237 | ||
238 | 238 | ||
239 | /** Initialize ARC structure |
239 | /** Initialize ARC structure |
240 | * |
240 | * |
241 | * @return 0 - ARC OK, -1 - ARC does not exist |
241 | * @return 0 - ARC OK, -1 - ARC does not exist |
242 | */ |
242 | */ |
243 | int arc_init(void) |
243 | int arc_init(void) |
244 | { |
244 | { |
245 | if (sbp->signature != ARC_MAGIC) { |
245 | if (sbp->signature != ARC_MAGIC) { |
246 | sbp = NULL; |
246 | sbp = NULL; |
247 | return -1; |
247 | return -1; |
248 | } |
248 | } |
249 | arc_entry = sbp->firmwarevector; |
249 | arc_entry = sbp->firmwarevector; |
250 | 250 | ||
251 | arc_putchar('A'); |
251 | arc_putchar('A'); |
252 | arc_putchar('R'); |
252 | arc_putchar('R'); |
253 | arc_putchar('C'); |
253 | arc_putchar('C'); |
254 | arc_putchar('\n'); |
254 | arc_putchar('\n'); |
255 | 255 | ||
256 | /* Add command for resetting the computer */ |
256 | /* Add command for resetting the computer */ |
257 | cmd_initialize(&devlist_info); |
257 | cmd_initialize(&devlist_info); |
258 | cmd_register(&devlist_info); |
258 | cmd_register(&devlist_info); |
259 | 259 | ||
260 | return 0; |
260 | return 0; |
261 | } |
261 | } |
262 | 262 | ||
263 | int arc_reboot(void) |
263 | int arc_reboot(void) |
264 | { |
264 | { |
265 | if (arc_enabled()) { |
265 | if (arc_enabled()) { |
266 | arc_entry->reboot(); |
266 | arc_entry->reboot(); |
267 | return true; |
267 | return true; |
268 | } |
268 | } |
269 | 269 | ||
270 | return false; |
270 | return false; |
271 | } |
271 | } |
272 | 272 | ||
273 | 273 | ||
274 | static bool kbd_polling_enabled; |
274 | static bool kbd_polling_enabled; |
275 | static chardev_t console; |
275 | static chardev_t console; |
276 | 276 | ||
277 | /** Try to get character, return character or -1 if not available */ |
277 | /** Try to get character, return character or -1 if not available */ |
278 | static void arc_keyboard_poll(void) |
278 | static void arc_keyboard_poll(void) |
279 | { |
279 | { |
280 | char ch; |
280 | char ch; |
281 | uint32_t count; |
281 | uint32_t count; |
282 | long result; |
282 | long result; |
283 | 283 | ||
284 | if (!kbd_polling_enabled) |
284 | if (!kbd_polling_enabled) |
285 | return; |
285 | return; |
286 | 286 | ||
287 | if (arc_entry->getreadstatus(0)) |
287 | if (arc_entry->getreadstatus(0)) |
288 | return; |
288 | return; |
289 | result = arc_entry->read(0, &ch, 1, &count); |
289 | result = arc_entry->read(0, &ch, 1, &count); |
290 | if ((result) || (count != 1)) { |
290 | if ((result) || (count != 1)) { |
291 | return; |
291 | return; |
292 | } |
292 | } |
293 | if (ch == '\r') |
293 | if (ch == '\r') |
294 | ch = '\n'; |
294 | ch = '\n'; |
295 | if (ch == 0x7f) |
295 | if (ch == 0x7f) |
296 | ch = '\b'; |
296 | ch = '\b'; |
297 | 297 | ||
298 | chardev_push_character(&console, ch); |
298 | chardev_push_character(&console, ch); |
299 | } |
299 | } |
300 | 300 | ||
301 | static char arc_read(chardev_t *dev) |
301 | static char arc_read(chardev_t *dev) |
302 | { |
302 | { |
303 | char ch; |
303 | char ch; |
304 | uint32_t count; |
304 | uint32_t count; |
305 | long result; |
305 | long result; |
306 | 306 | ||
307 | result = arc_entry->read(0, &ch, 1, &count); |
307 | result = arc_entry->read(0, &ch, 1, &count); |
308 | if ((result) || (count != 1)) { |
308 | if ((result) || (count != 1)) { |
309 | printf("Error reading from ARC keyboard.\n"); |
309 | printf("Error reading from ARC keyboard.\n"); |
310 | cpu_halt(); |
310 | cpu_halt(); |
311 | } |
311 | } |
312 | if (ch == '\r') |
312 | if (ch == '\r') |
313 | return '\n'; |
313 | return '\n'; |
314 | if (ch == 0x7f) |
314 | if (ch == 0x7f) |
315 | return '\b'; |
315 | return '\b'; |
316 | return ch; |
316 | return ch; |
317 | } |
317 | } |
318 | 318 | ||
319 | static void arc_write(chardev_t *dev, const char ch) |
319 | static void arc_write(chardev_t *dev, const char ch) |
320 | { |
320 | { |
321 | arc_putchar(ch); |
321 | arc_putchar(ch); |
322 | } |
322 | } |
323 | 323 | ||
324 | static void arc_enable(chardev_t *dev) |
324 | static void arc_enable(chardev_t *dev) |
325 | { |
325 | { |
326 | kbd_polling_enabled = true; |
326 | kbd_polling_enabled = true; |
327 | } |
327 | } |
328 | 328 | ||
329 | static void arc_disable(chardev_t *dev) |
329 | static void arc_disable(chardev_t *dev) |
330 | { |
330 | { |
331 | kbd_polling_enabled = false; |
331 | kbd_polling_enabled = false; |
332 | } |
332 | } |
333 | 333 | ||
334 | static chardev_operations_t arc_ops = { |
334 | static chardev_operations_t arc_ops = { |
335 | .resume = arc_enable, |
335 | .resume = arc_enable, |
336 | .suspend = arc_disable, |
336 | .suspend = arc_disable, |
337 | .write = arc_write, |
337 | .write = arc_write, |
338 | .read = arc_read |
338 | .read = arc_read |
339 | }; |
339 | }; |
340 | 340 | ||
341 | int arc_console(void) |
341 | int arc_console(void) |
342 | { |
342 | { |
343 | if (arc_enabled()) { |
343 | if (arc_enabled()) { |
344 | kbd_polling_enabled = true; |
344 | kbd_polling_enabled = true; |
345 | 345 | ||
346 | chardev_initialize("arc_console", &console, &arc_ops); |
346 | chardev_initialize("arc_console", &console, &arc_ops); |
347 | virtual_timer_fnc = &arc_keyboard_poll; |
347 | virtual_timer_fnc = &arc_keyboard_poll; |
348 | stdin = &console; |
348 | stdin = &console; |
349 | stdout = &console; |
349 | stdout = &console; |
350 | 350 | ||
351 | return true; |
351 | return true; |
352 | } |
352 | } |
353 | 353 | ||
354 | return false; |
354 | return false; |
355 | } |
355 | } |
356 | 356 | ||
357 | /* Initialize frame zones from ARC firmware. |
357 | /* Initialize frame zones from ARC firmware. |
358 | * In the future we may use even the FirmwareTemporary regions, |
358 | * In the future we may use even the FirmwareTemporary regions, |
359 | * currently we use the FreeMemory (what about the LoadedProgram?) |
359 | * currently we use the FreeMemory (what about the LoadedProgram?) |
360 | */ |
360 | */ |
361 | int arc_frame_init(void) |
361 | int arc_frame_init(void) |
362 | { |
362 | { |
363 | if (arc_enabled()) { |
363 | if (arc_enabled()) { |
364 | arc_memdescriptor_t *desc; |
364 | arc_memdescriptor_t *desc; |
365 | uintptr_t base; |
365 | uintptr_t base; |
366 | size_t basesize; |
366 | size_t basesize; |
367 | 367 | ||
368 | desc = arc_entry->getmemorydescriptor(NULL); |
368 | desc = arc_entry->getmemorydescriptor(NULL); |
369 | while (desc) { |
369 | while (desc) { |
370 | if ((desc->type == FreeMemory) || |
370 | if ((desc->type == FreeMemory) || |
371 | (desc->type == FreeContiguous)) { |
371 | (desc->type == FreeContiguous)) { |
372 | base = desc->basepage*ARC_FRAME; |
372 | base = desc->basepage*ARC_FRAME; |
373 | basesize = desc->basecount*ARC_FRAME; |
373 | basesize = desc->basecount*ARC_FRAME; |
374 | 374 | ||
375 | if (base % FRAME_SIZE ) { |
375 | if (base % FRAME_SIZE ) { |
376 | basesize -= FRAME_SIZE - (base % FRAME_SIZE); |
376 | basesize -= FRAME_SIZE - (base % FRAME_SIZE); |
377 | base = ALIGN_UP(base, FRAME_SIZE); |
377 | base = ALIGN_UP(base, FRAME_SIZE); |
378 | } |
378 | } |
379 | basesize = ALIGN_DOWN(basesize, FRAME_SIZE); |
379 | basesize = ALIGN_DOWN(basesize, FRAME_SIZE); |
380 | 380 | ||
381 | zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), |
381 | zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), |
382 | ADDR2PFN(base), 0); |
382 | ADDR2PFN(base), 0); |
383 | } |
383 | } |
384 | desc = arc_entry->getmemorydescriptor(desc); |
384 | desc = arc_entry->getmemorydescriptor(desc); |
385 | } |
385 | } |
386 | 386 | ||
387 | return true; |
387 | return true; |
388 | } |
388 | } |
389 | 389 | ||
390 | return false; |
390 | return false; |
391 | } |
391 | } |
392 | 392 | ||
393 | /** @} |
393 | /** @} |
394 | */ |
394 | */ |
395 | 395 |