Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1394 → Rev 1395

/boot/trunk/arch/ppc64/loader/main.c
29,11 → 29,8
#include "main.h"
#include "printf.h"
#include "asm.h"
#include "_components.h"
 
#define KERNEL_START ((void *) &_binary_____________kernel_kernel_bin_start)
#define KERNEL_END ((void *) &_binary_____________kernel_kernel_bin_end)
#define KERNEL_SIZE ((unsigned long) KERNEL_END - (unsigned long) KERNEL_START)
 
#define HEAP_GAP 1024000
 
bootinfo_t bootinfo;
76,24 → 73,30
 
void bootstrap(void)
{
printf("\nHelenOS PPC64 Bootloader\n");
printf("\nHelenOS PPC Bootloader\n");
check_align(KERNEL_START, "Kernel image");
check_align(&real_mode, "Bootstrap trampoline");
check_align(&trans, "Translation table");
init_components();
unsigned int i;
for (i = 0; i < COMPONENTS; i++)
check_align(components[i].start, components[i].name);
check_align(&real_mode, "bootstrap trampoline");
check_align(&trans, "translation table");
if (!ofw_memmap(&bootinfo.memmap)) {
printf("Error: Unable to get memory map, halting.\n");
printf("Error: unable to get memory map, halting.\n");
halt();
}
if (bootinfo.memmap.total == 0) {
printf("Error: No memory detected, halting.\n");
printf("Error: no memory detected, halting.\n");
halt();
}
if (!ofw_screen(&bootinfo.screen)) {
printf("Error: Unable to get screen properties, halting.\n");
printf("Error: unable to get screen properties, halting.\n");
halt();
}
103,26 → 106,49
void *real_mode_pa = ofw_translate(&real_mode);
void *trans_pa = ofw_translate(&trans);
void *bootinfo_pa = ofw_translate(&bootinfo);
void *fb = (void *) (((unsigned long) bootinfo.screen.addr) & ((unsigned long) ~0 << 17));
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(" 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);
printf(" %L: boot info structure (physical %L)\n", &bootinfo, bootinfo_pa);
printf(" %L: bootstrap trampoline (physical %L)\n", &real_mode, real_mode_pa);
printf(" %L: translation table (physical %L)\n", &trans, trans_pa);
for (i = 0; i < COMPONENTS; i++)
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
unsigned long top = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE);
unsigned long addr;
for (addr = 0; addr < KERNEL_SIZE; addr += PAGE_SIZE) {
void *pa = ofw_translate(KERNEL_START + addr);
fix_overlap(KERNEL_START + addr, &pa, "Kernel image", &top);
trans[addr >> PAGE_WIDTH] = pa;
unsigned long top = 0;
for (i = 0; i < COMPONENTS; i++)
top += ALIGN_UP(components[i].size, PAGE_SIZE);
unsigned long pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH;
for (i = 0; i < pages; i++) {
void *pa = ofw_translate(KERNEL_START + (i << PAGE_WIDTH));
fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "kernel", &top);
trans[i] = pa;
}
fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top);
fix_overlap(&trans, &trans_pa, "Translation table", &top);
fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
bootinfo.taskmap.count = 0;
for (i = 1; i < COMPONENTS; i++) {
unsigned long component_pages = ALIGN_UP(components[i].size, PAGE_SIZE) >> PAGE_WIDTH;
unsigned long j;
for (j = 0; j < component_pages; j++) {
void *pa = ofw_translate(components[i].start + (j << PAGE_WIDTH));
fix_overlap(components[i].start + (j << PAGE_WIDTH), &pa, components[i].name, &top);
trans[pages + j] = pa;
if (j == 0) {
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH);
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size;
bootinfo.taskmap.count++;
}
}
pages += component_pages;
}
fix_overlap(&real_mode, &real_mode_pa, "bootstrap trampoline", &top);
fix_overlap(&trans, &trans_pa, "translation table", &top);
fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top);
printf("\nBooting the kernel...\n");
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, fb, real_mode_pa);
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa);
}