110,8 → 110,13 |
static arc_func_vector_t *arc_entry; |
|
|
static void arc_putchar(char ch); |
|
/** Return true if ARC is available */ |
#define arc_enabled() (sbp != NULL) |
int arc_enabled(void) |
{ |
return sbp != NULL; |
} |
|
|
/** Print configuration data that ARC reports about component */ |
205,23 → 210,28 |
/** Read from arc bios memory map and print it |
* |
*/ |
void physmem_print(void) |
static int cmd_arc_print_memmap(cmd_arg_t *argv) |
{ |
printf("Base Size Type\n"); |
printf("---------- ---------- ---------\n"); |
arc_memdescriptor_t *desc; |
|
if (arc_enabled()) { |
arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL); |
printf("Memory map:\n"); |
|
desc = arc_entry->getmemorydescriptor(NULL); |
while (desc) { |
printf("%#10x %#10x %s\n", |
desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME, |
basetypes[desc->type]); |
printf("%s: %d(%p) (size: %dKB)\n",basetypes[desc->type], |
desc->basepage * ARC_FRAME, |
desc->basepage * ARC_FRAME, |
desc->basecount*ARC_FRAME/1024); |
desc = arc_entry->getmemorydescriptor(desc); |
} |
} else |
printf("%#10x %#10x free\n", 0, config.memory_size); |
return 1; |
} |
static cmd_info_t memmap_info = { |
.name = "arcmemmap", |
.description = "Print arc memory map", |
.func = cmd_arc_print_memmap, |
.argc = 0 |
}; |
|
/** Print charactor to console */ |
static void arc_putchar(char ch) |
233,8 → 243,20 |
ipl = interrupts_disable(); |
arc_entry->write(1, &ch, 1, &cnt); |
interrupts_restore(ipl); |
|
} |
|
static int cmd_reboot(cmd_arg_t *argv) |
{ |
arc_entry->reboot(); |
return 0; |
} |
static cmd_info_t reboot_info = { |
.name = "reboot", |
.description = "Reboot computer", |
.func = cmd_reboot, |
.argc = 0 |
}; |
|
/** Initialize ARC structure |
* |
254,6 → 276,10 |
arc_putchar('\n'); |
|
/* Add command for resetting the computer */ |
cmd_initialize(&reboot_info); |
cmd_register(&reboot_info); |
cmd_initialize(&memmap_info); |
cmd_register(&memmap_info); |
cmd_initialize(&devlist_info); |
cmd_register(&devlist_info); |
|
260,17 → 286,6 |
return 0; |
} |
|
int arc_reboot(void) |
{ |
if (arc_enabled()) { |
arc_entry->reboot(); |
return true; |
} |
|
return false; |
} |
|
|
static bool kbd_polling_enabled; |
static chardev_t console; |
|
287,7 → 302,7 |
if (arc_entry->getreadstatus(0)) |
return; |
result = arc_entry->read(0, &ch, 1, &count); |
if ((result) || (count != 1)) { |
if (result || count!=1) { |
return; |
} |
if (ch == '\r') |
305,7 → 320,7 |
long result; |
|
result = arc_entry->read(0, &ch, 1, &count); |
if ((result) || (count != 1)) { |
if (result || count!=1) { |
printf("Error reading from ARC keyboard.\n"); |
cpu_halt(); |
} |
338,9 → 353,8 |
.read = arc_read |
}; |
|
int arc_console(void) |
void arc_console(void) |
{ |
if (arc_enabled()) { |
kbd_polling_enabled = true; |
|
chardev_initialize("arc_console", &console, &arc_ops); |
347,20 → 361,14 |
virtual_timer_fnc = &arc_keyboard_poll; |
stdin = &console; |
stdout = &console; |
|
return true; |
} |
|
return false; |
} |
|
/* Initialize frame zones from ARC firmware. |
* In the future we may use even the FirmwareTemporary regions, |
* currently we use the FreeMemory (what about the LoadedProgram?) |
*/ |
int arc_frame_init(void) |
void arc_frame_init(void) |
{ |
if (arc_enabled()) { |
arc_memdescriptor_t *desc; |
int total = 0; |
uintptr_t base; |
368,8 → 376,8 |
|
desc = arc_entry->getmemorydescriptor(NULL); |
while (desc) { |
if ((desc->type == FreeMemory) || |
(desc->type == FreeContiguous)) { |
if (desc->type == FreeMemory || |
desc->type == FreeContiguous) { |
base = desc->basepage*ARC_FRAME; |
basesize = desc->basecount*ARC_FRAME; |
|
388,11 → 396,7 |
} |
|
config.memory_size = total; |
return true; |
} |
|
return false; |
} |
|
/** @} |
*/ |