Changeset b5ed4f8 in mainline
- Timestamp:
- 2008-02-05T14:48:26Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0b5f9fa
- Parents:
- b07c332
- Location:
- kernel/arch/mips32
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/include/drivers/arc.h
rb07c332 rb5ed4f8 258 258 259 259 extern int arc_init(void); 260 extern int arc_ enabled(void);261 voidarc_frame_init(void);262 voidarc_console(void);260 extern int arc_reboot(void); 261 extern int arc_frame_init(void); 262 extern int arc_console(void); 263 263 264 264 #endif -
kernel/arch/mips32/include/mm/frame.h
rb07c332 rb5ed4f8 43 43 44 44 extern void frame_arch_init(void); 45 #define physmem_print() 45 extern void physmem_print(void); 46 46 47 47 #endif /* __ASM__ */ -
kernel/arch/mips32/src/console.c
rb07c332 rb5ed4f8 41 41 void console_init(devno_t devno) 42 42 { 43 if (arc_enabled()) { 44 arc_console(); 45 } else if (serial_init()) { 46 serial_console(devno); 47 } else { 48 msim_console(devno); 43 if (!arc_console()) { 44 if (serial_init()) 45 serial_console(devno); 46 else 47 msim_console(devno); 49 48 } 50 49 } -
kernel/arch/mips32/src/drivers/arc.c
rb07c332 rb5ed4f8 107 107 }; 108 108 109 static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000);109 static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000); 110 110 static arc_func_vector_t *arc_entry; 111 111 112 112 113 static void arc_putchar(char ch);114 115 113 /** Return true if ARC is available */ 116 int arc_enabled(void) 117 { 118 return sbp != NULL; 119 } 114 #define arc_enabled() (sbp != NULL) 120 115 121 116 … … 139 134 return; 140 135 141 for (i =0; i < configdata->count; i++) {136 for (i = 0; i < configdata->count; i++) { 142 137 switch (configdata->descr[i].type) { 143 138 case CmResourceTypePort: 144 139 printf("Port: %p-size:%d ", 145 (uintptr_t) configdata->descr[i].u.port.start,140 (uintptr_t) configdata->descr[i].u.port.start, 146 141 configdata->descr[i].u.port.length); 147 142 break; … … 170 165 171 166 printf("%s: ",ctypes[c->type]); 172 for (i =0;i < c->identifier_len;i++)173 printf("%c", c->identifier[i]);167 for (i = 0; i < c->identifier_len; i++) 168 printf("%c", c->identifier[i]); 174 169 175 170 printf(" "); … … 183 178 static int cmd_arc_print_devices(cmd_arg_t *argv) 184 179 { 185 arc_component *c, *next;180 arc_component *c, *next; 186 181 187 182 c = arc_entry->getchild(NULL); … … 211 206 * 212 207 */ 213 static int cmd_arc_print_memmap(cmd_arg_t *argv) 214 { 215 arc_memdescriptor_t *desc; 216 217 printf("Memory map:\n"); 218 219 desc = arc_entry->getmemorydescriptor(NULL); 220 while (desc) { 221 printf("%s: %d(%p) (size: %dKB)\n",basetypes[desc->type], 222 desc->basepage * ARC_FRAME, 223 desc->basepage * ARC_FRAME, 224 desc->basecount*ARC_FRAME/1024); 225 desc = arc_entry->getmemorydescriptor(desc); 226 } 227 return 1; 228 } 229 static cmd_info_t memmap_info = { 230 .name = "arcmemmap", 231 .description = "Print arc memory map", 232 .func = cmd_arc_print_memmap, 233 .argc = 0 234 }; 208 void physmem_print(void) 209 { 210 printf("Base Size Type\n"); 211 printf("---------- ---------- ---------\n"); 212 213 if (arc_enabled()) { 214 arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL); 215 216 while (desc) { 217 printf("%#10x %#10x %s\n", 218 desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME, 219 basetypes[desc->type]); 220 desc = arc_entry->getmemorydescriptor(desc); 221 } 222 } else 223 printf("%#10x %#10x free\n", 0, config.memory_size); 224 } 235 225 236 226 /** Print charactor to console */ … … 244 234 arc_entry->write(1, &ch, 1, &cnt); 245 235 interrupts_restore(ipl); 246 247 } 248 249 static int cmd_reboot(cmd_arg_t *argv) 250 { 251 arc_entry->reboot(); 252 return 0; 253 } 254 static cmd_info_t reboot_info = { 255 .name = "reboot", 256 .description = "Reboot computer", 257 .func = cmd_reboot, 258 .argc = 0 259 }; 236 } 237 260 238 261 239 /** Initialize ARC structure … … 277 255 278 256 /* Add command for resetting the computer */ 279 cmd_initialize(&reboot_info);280 cmd_register(&reboot_info);281 cmd_initialize(&memmap_info);282 cmd_register(&memmap_info);283 257 cmd_initialize(&devlist_info); 284 258 cmd_register(&devlist_info); … … 286 260 return 0; 287 261 } 262 263 int arc_reboot(void) 264 { 265 if (arc_enabled()) { 266 arc_entry->reboot(); 267 return true; 268 } 269 270 return false; 271 } 272 288 273 289 274 static bool kbd_polling_enabled; … … 297 282 long result; 298 283 299 if (! 284 if (!kbd_polling_enabled) 300 285 return; 301 286 … … 303 288 return; 304 289 result = arc_entry->read(0, &ch, 1, &count); 305 if ( result || count!=1) {290 if ((result) || (count != 1)) { 306 291 return; 307 292 } … … 321 306 322 307 result = arc_entry->read(0, &ch, 1, &count); 323 if ( result || count!=1) {308 if ((result) || (count != 1)) { 324 309 printf("Error reading from ARC keyboard.\n"); 325 310 cpu_halt(); … … 354 339 }; 355 340 356 void arc_console(void) 357 { 358 kbd_polling_enabled = true; 359 360 chardev_initialize("arc_console", &console, &arc_ops); 361 virtual_timer_fnc = &arc_keyboard_poll; 362 stdin = &console; 363 stdout = &console; 341 int arc_console(void) 342 { 343 if (arc_enabled()) { 344 kbd_polling_enabled = true; 345 346 chardev_initialize("arc_console", &console, &arc_ops); 347 virtual_timer_fnc = &arc_keyboard_poll; 348 stdin = &console; 349 stdout = &console; 350 351 return true; 352 } 353 354 return false; 364 355 } 365 356 … … 368 359 * currently we use the FreeMemory (what about the LoadedProgram?) 369 360 */ 370 void arc_frame_init(void) 371 { 372 arc_memdescriptor_t *desc; 373 int total = 0; 374 uintptr_t base; 375 size_t basesize; 376 377 desc = arc_entry->getmemorydescriptor(NULL); 378 while (desc) { 379 if (desc->type == FreeMemory || 380 desc->type == FreeContiguous) { 381 base = desc->basepage*ARC_FRAME; 382 basesize = desc->basecount*ARC_FRAME; 383 384 if (base % FRAME_SIZE ) { 385 basesize -= FRAME_SIZE - (base % FRAME_SIZE); 386 base = ALIGN_UP(base, FRAME_SIZE); 361 int arc_frame_init(void) 362 { 363 if (arc_enabled()) { 364 arc_memdescriptor_t *desc; 365 int total = 0; 366 uintptr_t base; 367 size_t basesize; 368 369 desc = arc_entry->getmemorydescriptor(NULL); 370 while (desc) { 371 if ((desc->type == FreeMemory) || 372 (desc->type == FreeContiguous)) { 373 base = desc->basepage*ARC_FRAME; 374 basesize = desc->basecount*ARC_FRAME; 375 376 if (base % FRAME_SIZE ) { 377 basesize -= FRAME_SIZE - (base % FRAME_SIZE); 378 base = ALIGN_UP(base, FRAME_SIZE); 379 } 380 basesize = ALIGN_DOWN(basesize, FRAME_SIZE); 381 382 total += basesize; 383 384 zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), 385 ADDR2PFN(base), 0); 387 386 } 388 basesize = ALIGN_DOWN(basesize, FRAME_SIZE); 389 390 total += basesize; 391 392 zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), 393 ADDR2PFN(base), 0); 387 desc = arc_entry->getmemorydescriptor(desc); 394 388 } 395 desc = arc_entry->getmemorydescriptor(desc); 396 } 397 398 config.memory_size = total; 389 390 config.memory_size = total; 391 return true; 392 } 393 394 return false; 399 395 } 400 396 -
kernel/arch/mips32/src/mips32.c
rb07c332 rb5ed4f8 142 142 void userspace(uspace_arg_t *kernel_uarg) 143 143 { 144 /* EXL =1, UM=1, IE=1 */144 /* EXL = 1, UM = 1, IE = 1 */ 145 145 cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit | 146 cp0_status_um_bit | 147 cp0_status_ie_enabled_bit)); 146 cp0_status_um_bit | cp0_status_ie_enabled_bit)); 148 147 cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry); 149 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +PAGE_SIZE),150 151 152 while (1)153 148 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + PAGE_SIZE), 149 (uintptr_t) kernel_uarg->uspace_uarg, 150 (uintptr_t) kernel_uarg->uspace_entry); 151 152 while (1); 154 153 } 155 154 … … 181 180 void arch_reboot(void) 182 181 { 183 ___halt(); 182 if (!arc_reboot()) 183 ___halt(); 184 184 185 while (1); 185 186 } -
kernel/arch/mips32/src/mm/frame.c
rb07c332 rb5ed4f8 46 46 void frame_arch_init(void) 47 47 { 48 if (arc_enabled()) 49 arc_frame_init(); 50 else { 48 if (!arc_frame_init()) { 51 49 zone_create(0, ADDR2PFN(config.memory_size), 1, 0); 52 50 /*
Note:
See TracChangeset
for help on using the changeset viewer.