Subversion Repositories HelenOS

Rev

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

Rev 3743 Rev 3770
Line 150... Line 150...
150
}
150
}
151
 
151
 
152
/**
152
/**
153
 * Performs sun4u-specific initialization. The components are expected
153
 * Performs sun4u-specific initialization. The components are expected
154
 * to be already copied and boot allocator initialized.
154
 * to be already copied and boot allocator initialized.
-
 
155
 *
-
 
156
 * @param base  kernel base virtual address
-
 
157
 * @param top   virtual address above which the boot allocator
-
 
158
 *      can make allocations
155
 */
159
 */
156
static void bootstrap_sun4u(void)
160
static void bootstrap_sun4u(void *base, unsigned int top)
157
{
161
{
-
 
162
    void *balloc_base;
-
 
163
 
-
 
164
    /*
-
 
165
     * Claim and map the physical memory for the boot allocator.
-
 
166
     * Initialize the boot allocator.
-
 
167
     */
-
 
168
    balloc_base = base + ALIGN_UP(top, PAGE_SIZE);
-
 
169
    (void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
-
 
170
        BALLOC_MAX_SIZE);
-
 
171
    (void) ofw_map(balloc_base, balloc_base, BALLOC_MAX_SIZE, -1);
-
 
172
    balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
-
 
173
 
158
    printf("\nCanonizing OpenFirmware device tree...");
174
    printf("\nCanonizing OpenFirmware device tree...");
159
    bootinfo.ofw_root = ofw_tree_build();
175
    bootinfo.ofw_root = ofw_tree_build();
160
    printf("done.\n");
176
    printf("done.\n");
161
 
177
 
162
    detect_subarchitecture();
178
    detect_subarchitecture();
Line 175... Line 191...
175
 * Performs sun4v-specific initialization. The components are expected
191
 * Performs sun4v-specific initialization. The components are expected
176
 * to be already copied and boot allocator initialized.
192
 * to be already copied and boot allocator initialized.
177
 */
193
 */
178
static void bootstrap_sun4v(void)
194
static void bootstrap_sun4v(void)
179
{
195
{
-
 
196
    /*
-
 
197
     * When SILO booted, the OBP had established a virtual to physical
-
 
198
     * memory mapping. This mapping is not an identity (because the
-
 
199
     * physical memory starts on non-zero address) - this is not
-
 
200
     * surprising. But! The mapping even does not map virtual address
-
 
201
     * 0 onto the starting address of the physical memory, but onto an
-
 
202
     * address which is 0x400000 bytes higher. The reason is that the
-
 
203
     * OBP had already used the memory just at the beginning of the
-
 
204
     * physical memory, so that memory cannot be used by SILO (nor
-
 
205
     * bootloader). As for now, we solve it by a nasty workaround:
-
 
206
     * we pretend that the physical memory starts 0x400000 bytes further
-
 
207
     * than it actually does (and hence pretend that the physical memory
-
 
208
     * is 0x400000 bytes smaller). Of course, the value 0x400000 will most
-
 
209
     * probably depend on the machine and OBP version (the workaround now
-
 
210
     * works on Simics). A solution would be to inspect the "available"
-
 
211
     * property of the "/memory" node to find out which parts of memory
-
 
212
     * are used by OBP and redesign the algorithm of copying
-
 
213
     * kernel/init tasks/ramdisk from the bootable image to memory
-
 
214
     * (which we must do anyway because of issues with claiming the memory
-
 
215
     * on Serengeti).
-
 
216
     */
-
 
217
    bootinfo.physmem_start += 0x400000;
-
 
218
    bootinfo.memmap.zones[0].start += 0x400000;
-
 
219
    bootinfo.memmap.zones[0].size -= 0x400000;
180
}
220
}
181
 
221
 
182
void bootstrap(void)
222
void bootstrap(void)
183
{
223
{
184
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
224
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
185
    void *balloc_base;
-
 
186
    unsigned int top = 0;
225
    unsigned int top = 0;
187
    int i, j;
226
    int i, j;
188
 
227
 
189
    detect_architecture();
228
    detect_architecture();
190
    init_components(components);
229
    init_components(components);
Line 315... Line 354...
315
    (void) ofw_claim_phys(bootinfo.physmem_start + base,
354
    (void) ofw_claim_phys(bootinfo.physmem_start + base,
316
        ALIGN_UP(components[0].size, PAGE_SIZE));
355
        ALIGN_UP(components[0].size, PAGE_SIZE));
317
    memcpy(base, components[0].start, components[0].size);
356
    memcpy(base, components[0].start, components[0].size);
318
    printf("done.\n");
357
    printf("done.\n");
319
 
358
 
320
    /*
-
 
321
     * Claim and map the physical memory for the boot allocator.
-
 
322
     * Initialize the boot allocator.
-
 
323
     */
-
 
324
    balloc_base = base + ALIGN_UP(top, PAGE_SIZE);
-
 
325
    (void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
-
 
326
        BALLOC_MAX_SIZE);
-
 
327
    (void) ofw_map(balloc_base, balloc_base, BALLOC_MAX_SIZE, -1);
-
 
328
    balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
-
 
329
 
-
 
330
    /* perform architecture-specific initialization */
359
    /* perform architecture-specific initialization */
331
    if (architecture == COMPATIBLE_SUN4U) {
360
    if (architecture == COMPATIBLE_SUN4U) {
332
        bootstrap_sun4u();
361
        bootstrap_sun4u(base, top);
333
    } else if (architecture == COMPATIBLE_SUN4V) {
362
    } else if (architecture == COMPATIBLE_SUN4V) {
334
        bootstrap_sun4v();
363
        bootstrap_sun4v();
335
    } else {
364
    } else {
336
        printf("Unknown architecture.\n");
365
        printf("Unknown architecture.\n");
337
        halt();
366
        halt();