/boot/trunk/arch/ppc32/loader/ofw.h |
---|
51,7 → 51,15 |
memzone_t zones[MEMMAP_MAX_RECORDS]; |
} memmap_t; |
typedef struct { |
unsigned int addr; |
unsigned int width; |
unsigned int height; |
unsigned int bpp; |
unsigned int scanline; |
} screen_t; |
extern void init(void); |
extern void ofw_write(const char *str, const int len); |
58,5 → 66,6 |
extern void *ofw_translate(const void *virt); |
extern int ofw_map(const void *phys, const void *virt, const int size, const int mode); |
extern int ofw_memmap(memmap_t *map); |
extern int ofw_screen(screen_t *screen); |
#endif |
/boot/trunk/arch/ppc32/loader/main.c |
---|
36,9 → 36,14 |
#define HEAP_GAP 1024000 |
memmap_t memmap; |
typedef struct { |
memmap_t memmap; |
screen_t screen; |
} bootinfo_t; |
bootinfo_t bootinfo; |
static void check_align(const void *addr, const char *desc) |
{ |
if ((unsigned int) addr % PAGE_SIZE != 0) { |
82,18 → 87,26 |
check_align(&real_mode, "Bootstrap trampoline"); |
check_align(&trans, "Translation table"); |
if (!ofw_memmap(&memmap)) { |
if (!ofw_memmap(&bootinfo.memmap)) { |
printf("Error: Unable to get memory map\n"); |
halt(); |
} |
if (!ofw_screen(&bootinfo.screen)) { |
printf("Error: Unable to get screen properties\n"); |
halt(); |
} |
printf("\nDevice statistics\n"); |
printf(" screen at %L, resolution %dx%d, %d bpp (scanline %d bytes)\n", bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline); |
void *real_mode_pa = ofw_translate(&real_mode); |
void *trans_pa = ofw_translate(&trans); |
void *memmap_pa = ofw_translate(&memmap); |
void *bootinfo_pa = ofw_translate(&bootinfo); |
printf("Memory statistics (total %d MB)\n", memmap.total >> 20); |
printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20); |
printf(" kernel image at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE); |
printf(" memory map at %L (physical %L)\n", &memmap, memmap_pa); |
printf(" boot info at %L (physical %L)\n", &bootinfo, bootinfo_pa); |
printf(" bootstrap trampoline at %L (physical %L)\n", &real_mode, real_mode_pa); |
printf(" translation table at %L (physical %L)\n", &trans, trans_pa); |
107,8 → 120,8 |
fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top); |
fix_overlap(&trans, &trans_pa, "Translation table", &top); |
fix_overlap(&memmap, &memmap_pa, "Memory map", &top); |
fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top); |
printf("Booting the kernel...\n"); |
jump_to_kernel(memmap_pa, trans_pa, KERNEL_SIZE, real_mode_pa); |
printf("\nBooting the kernel...\n"); |
jump_to_kernel(bootinfo_pa, trans_pa, KERNEL_SIZE, real_mode_pa); |
} |
/boot/trunk/arch/ppc32/loader/ofw.c |
---|
31,6 → 31,7 |
#include "printf.h" |
#define MAX_OFW_ARGS 10 |
#define STRING_SIZE 1024 |
typedef unsigned int ofw_arg_t; |
typedef unsigned int ihandle; |
52,6 → 53,7 |
ofw_entry ofw; |
phandle ofw_chosen; |
phandle ofw_aliases; |
ihandle ofw_mmu; |
ihandle ofw_stdout; |
106,9 → 108,15 |
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0) |
ofw_stdout = 0; |
ofw_aliases = ofw_find_device("/aliases"); |
if (ofw_aliases == -1) { |
puts("\nUnable to find /aliases device\n"); |
halt(); |
} |
ofw_mmu = ofw_open("/mmu"); |
if (ofw_mmu == -1) { |
puts("Unable to open /mmu node\n"); |
puts("\nUnable to open /mmu node\n"); |
halt(); |
} |
} |
157,3 → 165,33 |
map->total += map->zones[i].size; |
} |
} |
int ofw_screen(screen_t *screen) |
{ |
char device_name[STRING_SIZE]; |
if (ofw_get_property(ofw_aliases, "screen", device_name, STRING_SIZE) <= 0) |
return false; |
phandle device = ofw_find_device(device_name); |
if (device == -1) |
return false; |
if (ofw_get_property(device, "address", &screen->addr, sizeof(screen->addr)) <= 0) |
return false; |
if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0) |
return false; |
if (ofw_get_property(device, "height", &screen->height, sizeof(screen->height)) <= 0) |
return false; |
if (ofw_get_property(device, "depth", &screen->bpp, sizeof(screen->bpp)) <= 0) |
return false; |
if (ofw_get_property(device, "linebytes", &screen->scanline, sizeof(screen->scanline)) <= 0) |
return false; |
return true; |
} |