Subversion Repositories HelenOS-historic

Rev

Rev 1131 | Rev 1219 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1131 Rev 1146
Line 40... Line 40...
40
 
40
 
41
 
41
 
42
static void check_align(const void *addr, const char *desc)
42
static void check_align(const void *addr, const char *desc)
43
{
43
{
44
    if ((unsigned int) addr % PAGE_SIZE != 0) {
44
    if ((unsigned int) addr % PAGE_SIZE != 0) {
45
        printf("Error: %s not on page boundary\n", desc);
45
        printf("Error: %s not on page boundary, halting.\n", desc);
46
        halt();
46
        halt();
47
    }
47
    }
48
}
48
}
49
 
49
 
50
 
50
 
Line 56... Line 56...
56
        void *new_va = (void *) (ALIGN_UP((unsigned int) KERNEL_END + HEAP_GAP, PAGE_SIZE) + *top);
56
        void *new_va = (void *) (ALIGN_UP((unsigned int) KERNEL_END + HEAP_GAP, PAGE_SIZE) + *top);
57
        void *new_pa = (void *) (HEAP_GAP + *top);
57
        void *new_pa = (void *) (HEAP_GAP + *top);
58
        *top += PAGE_SIZE;
58
        *top += PAGE_SIZE;
59
       
59
       
60
        if (ofw_map(new_pa, new_va, PAGE_SIZE, 0) != 0) {
60
        if (ofw_map(new_pa, new_va, PAGE_SIZE, 0) != 0) {
61
            printf("Error: Unable to map page aligned memory at %L (physical %L)\n", new_va, new_pa);
61
            printf("Error: Unable to map page aligned memory at %L (physical %L), halting.\n", new_va, new_pa);
62
            halt();
62
            halt();
63
        }
63
        }
64
       
64
       
65
        if ((unsigned int) new_pa + PAGE_SIZE < KERNEL_SIZE) {
65
        if ((unsigned int) new_pa + PAGE_SIZE < KERNEL_SIZE) {
66
            printf("Error: %s cannot be relocated\n", desc);
66
            printf("Error: %s cannot be relocated, halting.\n", desc);
67
            halt();
67
            halt();
68
        }
68
        }
69
       
69
       
70
        printf("Relocating %L -> %L (physical %L -> %L)\n", va, new_va, *pa, new_pa);
70
        printf("Relocating %L -> %L (physical %L -> %L)\n", va, new_va, *pa, new_pa);
71
        *pa = new_pa;
71
        *pa = new_pa;
Line 81... Line 81...
81
    check_align(KERNEL_START, "Kernel image");
81
    check_align(KERNEL_START, "Kernel image");
82
    check_align(&real_mode, "Bootstrap trampoline");
82
    check_align(&real_mode, "Bootstrap trampoline");
83
    check_align(&trans, "Translation table");
83
    check_align(&trans, "Translation table");
84
   
84
   
85
    if (!ofw_memmap(&bootinfo.memmap)) {
85
    if (!ofw_memmap(&bootinfo.memmap)) {
86
        printf("Error: Unable to get memory map\n");
86
        printf("Error: Unable to get memory map, halting.\n");
-
 
87
        halt();
-
 
88
    }
-
 
89
   
-
 
90
    if (bootinfo.memmap.total == 0) {
-
 
91
        printf("Error: No memory detected, halting.\n");
87
        halt();
92
        halt();
88
    }
93
    }
89
   
94
   
90
    if (!ofw_screen(&bootinfo.screen)) {
95
    if (!ofw_screen(&bootinfo.screen)) {
91
        printf("Error: Unable to get screen properties\n");
96
        printf("Error: Unable to get screen properties, halting.\n");
92
        halt();
97
        halt();
93
    }
98
    }
94
   
99
   
95
    printf("\nDevice statistics\n");
100
    printf("\nDevice statistics\n");
96
    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);
101
    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);
97
   
102
   
98
    void *real_mode_pa = ofw_translate(&real_mode);
103
    void *real_mode_pa = ofw_translate(&real_mode);
99
    void *trans_pa = ofw_translate(&trans);
104
    void *trans_pa = ofw_translate(&trans);
100
    void *bootinfo_pa = ofw_translate(&bootinfo);
105
    void *bootinfo_pa = ofw_translate(&bootinfo);
-
 
106
    void *fb = (void *) (((unsigned int) bootinfo.screen.addr) & ((unsigned int) ~0 << 17));
101
   
107
   
102
    printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);
108
    printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);
103
    printf(" kernel image         at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE);
109
    printf(" kernel image         at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE);
104
    printf(" boot info            at %L (physical %L)\n", &bootinfo, bootinfo_pa);
110
    printf(" boot info            at %L (physical %L)\n", &bootinfo, bootinfo_pa);
105
    printf(" bootstrap trampoline at %L (physical %L)\n", &real_mode, real_mode_pa);
111
    printf(" bootstrap trampoline at %L (physical %L)\n", &real_mode, real_mode_pa);
Line 116... Line 122...
116
    fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top);
122
    fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top);
117
    fix_overlap(&trans, &trans_pa, "Translation table", &top);
123
    fix_overlap(&trans, &trans_pa, "Translation table", &top);
118
    fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
124
    fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
119
   
125
   
120
    printf("\nBooting the kernel...\n");
126
    printf("\nBooting the kernel...\n");
121
    jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, real_mode_pa);
127
    jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, fb, real_mode_pa);
122
}
128
}