- Timestamp:
- 2009-08-22T10:48:00Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04803bf
- Parents:
- 1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- boot/arch
- Files:
-
- 24 edited
-
arm32/loader/asm.h (modified) (1 diff)
-
arm32/loader/main.c (modified) (1 diff)
-
ia64/loader/asm.h (modified) (1 diff)
-
ia64/loader/main.h (modified) (1 diff)
-
mips32/loader/asm.h (modified) (1 diff)
-
mips32/loader/main.c (modified) (1 diff)
-
ppc32/loader/Makefile (modified) (3 diffs)
-
ppc32/loader/_link.ld.in (modified) (1 diff)
-
ppc32/loader/asm.S (modified) (9 diffs)
-
ppc32/loader/asm.h (modified) (1 diff)
-
ppc32/loader/main.c (modified) (7 diffs)
-
ppc32/loader/main.h (modified) (3 diffs)
-
ppc32/loader/ofwarch.c (modified) (2 diffs)
-
ppc32/loader/ofwarch.h (modified) (1 diff)
-
ppc32/loader/regname.h (modified) (1 diff)
-
sparc64/loader/asm.S (modified) (4 diffs)
-
sparc64/loader/asm.h (modified) (1 diff)
-
sparc64/loader/boot.S (modified) (5 diffs)
-
sparc64/loader/main.c (modified) (17 diffs)
-
sparc64/loader/main.h (modified) (2 diffs)
-
sparc64/loader/ofwarch.c (modified) (7 diffs)
-
sparc64/loader/ofwarch.h (modified) (1 diff)
-
sparc64/loader/register.h (modified) (1 diff)
-
sparc64/loader/stack.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/arm32/loader/asm.h
r1ea99cc rb50b5af2 40 40 41 41 42 /** Copies cnt bytes from dst to src.43 *44 * @param dst Destination address.45 * @param src Source address.46 * @param cnt Count of bytes to be copied.47 */48 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))49 50 51 42 /** Called when the CPU is switched on. 52 43 * -
boot/arch/arm32/loader/main.c
r1ea99cc rb50b5af2 43 43 #include <macros.h> 44 44 #include <string.h> 45 #include <memstr.h> 45 46 46 47 #include "mm.h" -
boot/arch/ia64/loader/asm.h
r1ea99cc rb50b5af2 34 34 #include "main.h" 35 35 36 #define PAGE_WIDTH 1437 #define PAGE_SIZE (1 << PAGE_WIDTH)36 #define PAGE_WIDTH 14 37 #define PAGE_SIZE (1 << PAGE_WIDTH) 38 38 39 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))39 #define BALLOC_MAX_SIZE (128 * 1024) 40 40 41 41 extern void halt(void); 42 /*extern void jump_to_kernel(void *entry, uint64_t cfg, bootinfo_t *bootinfo,43 unsigned int bootinfo_size) __attribute__((noreturn));*/44 45 42 extern void jump_to_kernel(void *) __attribute__((noreturn)); 46 43 -
boot/arch/ia64/loader/main.h
r1ea99cc rb50b5af2 34 34 35 35 36 #define CONFIG_INIT_TASKS 32 37 38 36 #define CONFIG_INIT_TASKS 32 39 37 40 38 extern void start(void); -
boot/arch/mips32/loader/asm.h
r1ea99cc rb50b5af2 33 33 #define PAGE_WIDTH 14 34 34 35 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))36 37 35 void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn)); 38 36 -
boot/arch/mips32/loader/main.c
r1ea99cc rb50b5af2 27 27 */ 28 28 29 #include "main.h" 29 #include "main.h" 30 30 #include <printf.h> 31 31 #include <align.h> 32 32 #include <macros.h> 33 33 #include <string.h> 34 #include <memstr.h> 34 35 #include "msim.h" 35 36 #include "asm.h" -
boot/arch/ppc32/loader/Makefile
r1ea99cc rb50b5af2 62 62 SOURCES = \ 63 63 main.c \ 64 ofwarch.c \65 64 _components.c \ 66 ../../../genarch/ofw.c \67 65 ../../../generic/printf.c \ 68 66 ../../../generic/string.c \ 67 ../../../genarch/balloc.c \ 68 ../../../genarch/ofw.c \ 69 ../../../genarch/ofw_tree.c \ 70 ofwarch.c \ 69 71 asm.S \ 70 72 boot.S … … 73 75 $(KERNELDIR)/kernel.bin \ 74 76 $(USPACEDIR)/srv/ns/ns \ 77 $(USPACEDIR)/app/init/init \ 75 78 $(USPACEDIR)/srv/loader/loader \ 76 $(USPACEDIR)/app/init/init \77 79 $(USPACEDIR)/srv/devmap/devmap \ 78 80 $(USPACEDIR)/srv/bd/rd/rd \ … … 102 104 $(USPACEDIR)/app/dltest2/dltest2 \ 103 105 $(USPACEDIR)/app/trace/trace \ 104 $(USPACEDIR)/app/ klog/klog\105 $(USPACEDIR)/app/ bdsh/bdsh106 $(USPACEDIR)/app/bdsh/bdsh \ 107 $(USPACEDIR)/app/klog/klog 106 108 107 109 RD_LIBS = \ -
boot/arch/ppc32/loader/_link.ld.in
r1ea99cc rb50b5af2 19 19 [[COMPONENTS]] 20 20 } 21 22 /DISCARD/ : { 23 *(.comment); 24 *(.note*); 25 } 21 26 } -
boot/arch/ppc32/loader/asm.S
r1ea99cc rb50b5af2 29 29 #include "asm.h" 30 30 #include "regname.h" 31 #include "ofwarch.h" 31 32 32 33 .macro SMC_COHERENCY addr … … 45 46 46 47 .macro TLB_FLUSH reg 47 tlbie \reg 48 addi \reg, \reg, 0x1000 48 li \reg, 0 49 sync 50 51 .rept 64 52 tlbie \reg 53 addi \reg, \reg, 0x1000 54 .endr 55 56 eieio 57 tlbsync 58 sync 49 59 .endm 50 60 … … 54 64 .global memcpy 55 65 .global jump_to_kernel 66 .global balloc_base 56 67 57 68 halt: … … 62 73 addi r6, r3, -4 63 74 addi r4, r4, -4 64 beq 2f75 beq 2f 65 76 66 77 andi. r0, r6, 3 … … 69 80 70 81 1: 71 72 lwz r7, 4(r4) 73 lwzu r8, 8(r4) 74 stw r7, 4(r6) 75 stwu r8, 8(r6) 76 bdnz 1b 77 78 andi. r5, r5, 7 82 lwz r7, 4(r4) 83 lwzu r8, 8(r4) 84 stw r7, 4(r6) 85 stwu r8, 8(r6) 86 bdnz 1b 87 88 andi. r5, r5, 7 79 89 80 90 2: 81 82 cmplwi 0, r5, 4 83 blt 3f 84 85 lwzu r0, 4(r4) 86 addi r5, r5, -4 87 stwu r0, 4(r6) 91 cmplwi 0, r5, 4 92 blt 3f 93 94 lwzu r0, 4(r4) 95 addi r5, r5, -4 96 stwu r0, 4(r6) 88 97 89 98 3: 90 91 cmpwi 0, r5, 0 92 beqlr 93 mtctr r5 94 addi r4, r4, 3 95 addi r6, r6, 3 99 cmpwi 0, r5, 0 100 beqlr 101 mtctr r5 102 addi r4, r4, 3 103 addi r6, r6, 3 96 104 97 105 4: 98 99 lbzu r0, 1(r4) 100 stbu r0, 1(r6) 101 bdnz 4b 102 blr 106 lbzu r0, 1(r4) 107 stbu r0, 1(r6) 108 bdnz 4b 109 blr 103 110 104 111 5: 105 106 subfic r0, r0, 4 107 mtctr r0 112 subfic r0, r0, 4 113 mtctr r0 108 114 109 115 6: 110 111 lbz r7, 4(r4) 112 addi r4, r4, 1 113 stb r7, 4(r6) 114 addi r6, r6, 1 115 bdnz 6b 116 subf r5, r0, r5 117 rlwinm. r7, r5, 32-3, 3, 31 118 beq 2b 119 mtctr r7 120 b 1b 121 116 lbz r7, 4(r4) 117 addi r4, r4, 1 118 stb r7, 4(r6) 119 addi r6, r6, 1 120 bdnz 6b 121 subf r5, r0, r5 122 rlwinm. r7, r5, 32-3, 3, 31 123 beq 2b 124 mtctr r7 125 b 1b 122 126 123 127 jump_to_kernel: … … 128 132 # r6 = bytes to copy 129 133 # r7 = real_mode (pa) 130 # r8 = framebuffer (pa)131 # r9 = scanline132 134 133 135 # disable interrupts … … 153 155 rfi 154 156 157 .align PAGE_WIDTH 158 balloc_base: 159 .fill BALLOC_MAX_SIZE 160 155 161 .section REALMODE, "ax" 162 156 163 .align PAGE_WIDTH 157 164 .global real_mode 158 159 165 real_mode: 160 166 161 167 # copy kernel to proper location 162 168 # 169 # r3 = bootinfo (pa) 170 # r4 = bootinfo_size 163 171 # r5 = trans (pa) 164 172 # r6 = bytes to copy 165 # r8 = framebuffer (pa)166 # r9 = scanline167 173 168 174 li r31, PAGE_SIZE >> 2 … … 343 349 # flush TLB 344 350 345 li r31, 0346 sync347 348 351 TLB_FLUSH r31 349 TLB_FLUSH r31350 TLB_FLUSH r31351 TLB_FLUSH r31352 TLB_FLUSH r31353 TLB_FLUSH r31354 TLB_FLUSH r31355 TLB_FLUSH r31356 357 TLB_FLUSH r31358 TLB_FLUSH r31359 TLB_FLUSH r31360 TLB_FLUSH r31361 TLB_FLUSH r31362 TLB_FLUSH r31363 TLB_FLUSH r31364 TLB_FLUSH r31365 366 TLB_FLUSH r31367 TLB_FLUSH r31368 TLB_FLUSH r31369 TLB_FLUSH r31370 TLB_FLUSH r31371 TLB_FLUSH r31372 TLB_FLUSH r31373 TLB_FLUSH r31374 375 TLB_FLUSH r31376 TLB_FLUSH r31377 TLB_FLUSH r31378 TLB_FLUSH r31379 TLB_FLUSH r31380 TLB_FLUSH r31381 TLB_FLUSH r31382 TLB_FLUSH r31383 384 TLB_FLUSH r31385 TLB_FLUSH r31386 TLB_FLUSH r31387 TLB_FLUSH r31388 TLB_FLUSH r31389 TLB_FLUSH r31390 TLB_FLUSH r31391 TLB_FLUSH r31392 393 TLB_FLUSH r31394 TLB_FLUSH r31395 TLB_FLUSH r31396 TLB_FLUSH r31397 TLB_FLUSH r31398 TLB_FLUSH r31399 TLB_FLUSH r31400 TLB_FLUSH r31401 402 TLB_FLUSH r31403 TLB_FLUSH r31404 TLB_FLUSH r31405 TLB_FLUSH r31406 TLB_FLUSH r31407 TLB_FLUSH r31408 TLB_FLUSH r31409 TLB_FLUSH r31410 411 TLB_FLUSH r31412 TLB_FLUSH r31413 TLB_FLUSH r31414 TLB_FLUSH r31415 TLB_FLUSH r31416 TLB_FLUSH r31417 TLB_FLUSH r31418 TLB_FLUSH r31419 420 eieio421 tlbsync422 sync423 352 424 353 # start the kernel 425 354 # 426 # pc = KERNEL_START_ADDR355 # pc = PA2KA(BOOT_OFFSET) 427 356 # r3 = bootinfo (pa) 428 # sprg0 = KA2PA(KERNEL_START_ADDR)357 # sprg0 = BOOT_OFFSET 429 358 # sprg3 = physical memory size 430 359 # sp = 0 (pa) 431 360 432 lis r31, KERNEL_START_ADDR@ha 433 addi r31, r31, KERNEL_START_ADDR@l 434 361 lis r31, PA2KA(BOOT_OFFSET)@ha 362 addi r31, r31, PA2KA(BOOT_OFFSET)@l 435 363 mtspr srr0, r31 436 364 437 subis r31, r31, 0x8000 365 lis r31, BOOT_OFFSET@ha 366 addi r31, r31, BOOT_OFFSET@l 438 367 mtsprg0 r31 439 368 … … 454 383 .global trans 455 384 trans: 456 .space (TRANS_SIZE * TRANS_ITEM_SIZE) 385 .rept TRANS_SIZE 386 .int 0 387 .endr -
boot/arch/ppc32/loader/asm.h
r1ea99cc rb50b5af2 30 30 #define BOOT_ppc32_ASM_H_ 31 31 32 #define PAGE_ SIZE 409633 #define PAGE_ WIDTH 1232 #define PAGE_WIDTH 12 33 #define PAGE_SIZE (1 << PAGE_WIDTH) 34 34 35 #define TRANS_SIZE 102436 #define TRANS_ITEM_SIZE 435 #define TRANS_SIZE 1024 36 #define BOOT_OFFSET 0x8000 37 37 38 #define KERNEL_START_ADDR 0x8000800038 #define BALLOC_MAX_SIZE (128 * 1024) 39 39 40 40 #ifndef __ASM__ 41 41 42 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 42 #include "types.h" 43 #include "main.h" 44 #include "ofwarch.h" 43 45 44 extern void *trans[TRANS_SIZE]; 46 #define PA2KA(x) (((uintptr_t) (x)) + 0x80000000) 47 48 extern uint8_t balloc_base[BALLOC_MAX_SIZE]; 49 extern uintptr_t trans[TRANS_SIZE]; 45 50 46 51 extern void halt(); 47 extern void jump_to_kernel(void *bootinfo, unsigned int bootinfo_size, void *trans, unsigned int kernel_size, void *real_mode, void *fb, unsigned int scanline) __attribute__((noreturn)); 52 extern void jump_to_kernel(void *bootinfo, unsigned int bootinfo_size, 53 uintptr_t trans[], unsigned int kernel_size, void *real_mode) __attribute__((noreturn)); 48 54 extern void real_mode(); 55 56 #else 57 58 #define PA2KA(x) ((x) + 0x80000000) 49 59 50 60 #endif -
boot/arch/ppc32/loader/main.c
r1ea99cc rb50b5af2 27 27 */ 28 28 29 #include "main.h"30 29 #include <printf.h> 31 #include "asm.h"32 #include "_components.h"33 30 #include <ofw.h> 34 31 #include <align.h> 35 32 #include <macros.h> 36 33 #include <string.h> 34 #include "main.h" 35 #include "asm.h" 36 #include "_components.h" 37 37 38 #define HEAP_GAP 1024000 38 static bootinfo_t bootinfo; 39 static component_t components[COMPONENTS]; 40 static char *release = STRING(RELEASE); 39 41 40 bootinfo_t bootinfo; 42 #ifdef REVISION 43 static char *revision = ", revision " STRING(REVISION); 44 #else 45 static char *revision = ""; 46 #endif 41 47 48 #ifdef TIMESTAMP 49 static char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 50 #else 51 static char *timestamp = ""; 52 #endif 53 54 /** Print version information. */ 55 static void version_print(void) 56 { 57 printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\n" 58 "Copyright (c) 2006 HelenOS project\n\n", 59 release, revision, timestamp); 60 } 42 61 43 62 static void check_align(const void *addr, const char *desc) 44 63 { 45 if ((u nsigned int) addr % PAGE_SIZE != 0) {64 if ((uintptr_t) addr % PAGE_SIZE != 0) { 46 65 printf("Error: %s not on page boundary, halting.\n", desc); 47 66 halt(); … … 49 68 } 50 69 51 52 static void fix_overlap(void *va, void **pa, const char *desc, unsigned int *top) 70 static void check_overlap(const void *pa, const char *desc, const uintptr_t top) 53 71 { 54 if ((unsigned int) *pa + PAGE_SIZE < *top) { 55 printf("Warning: %s overlaps kernel physical area\n", desc); 56 57 void *new_va = (void *) (ALIGN_UP((unsigned int) KERNEL_END + HEAP_GAP, PAGE_SIZE) + *top); 58 void *new_pa = (void *) (HEAP_GAP + *top); 59 *top += PAGE_SIZE; 60 61 if (ofw_map(new_pa, new_va, PAGE_SIZE, 0) != 0) { 62 printf("Error: Unable to map page aligned memory at %L (physical %L), halting.\n", new_va, new_pa); 63 halt(); 64 } 65 66 if ((unsigned int) new_pa + PAGE_SIZE < KERNEL_SIZE) { 67 printf("Error: %s cannot be relocated, halting.\n", desc); 68 halt(); 69 } 70 71 printf("Relocating %L -> %L (physical %L -> %L)\n", va, new_va, *pa, new_pa); 72 *pa = new_pa; 73 memcpy(new_va, va, PAGE_SIZE); 72 if ((uintptr_t) pa + PAGE_SIZE < top) { 73 printf("Error: %s overlaps destination physical area\n", desc); 74 halt(); 74 75 } 75 }76 77 char *release = STRING(RELEASE);78 79 #ifdef REVISION80 char *revision = ", revision " STRING(REVISION);81 #else82 char *revision = "";83 #endif84 85 #ifdef TIMESTAMP86 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);87 #else88 char *timestamp = "";89 #endif90 91 /** Print version information. */92 static void version_print(void)93 {94 printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n\n", release, revision, timestamp);95 76 } 96 77 … … 98 79 { 99 80 version_print(); 100 101 component_t components[COMPONENTS];102 81 init_components(components); 103 104 unsigned int i;105 for (i = 0; i < COMPONENTS; i++)106 check_align(components[i].start, components[i].name);107 108 check_align(&real_mode, "bootstrap trampoline");109 check_align(&trans, "translation table");110 82 111 83 if (!ofw_memmap(&bootinfo.memmap)) { … … 119 91 } 120 92 121 if (!ofw_screen(&bootinfo.screen)) 122 printf("Warning: Unable to get screen properties.\n"); 93 check_align(&real_mode, "bootstrap trampoline"); 94 check_align(trans, "translation table"); 95 check_align(balloc_base, "boot allocations"); 123 96 124 if (!ofw_macio(&bootinfo.macio)) 125 printf("Warning: Unable to get macio properties.\n"); 97 unsigned int i; 98 for (i = 0; i < COMPONENTS; i++) 99 check_align(components[i].start, components[i].name); 126 100 127 printf("Device statistics\n"); 101 void *bootinfo_pa = ofw_translate(&bootinfo); 102 void *real_mode_pa = ofw_translate(&real_mode); 103 void *trans_pa = ofw_translate(trans); 104 void *balloc_base_pa = ofw_translate(balloc_base); 128 105 129 if (bootinfo.screen.addr) 130 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); 131 132 if (bootinfo.macio.addr) 133 printf(" macio at %L (size %d bytes)\n", bootinfo.macio.addr, bootinfo.macio.size); 134 135 void *real_mode_pa = ofw_translate(&real_mode); 136 void *trans_pa = ofw_translate(&trans); 137 void *bootinfo_pa = ofw_translate(&bootinfo); 138 139 printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20); 106 printf("Memory statistics (total %d MB)\n", bootinfo.memmap.total >> 20); 140 107 printf(" %L: boot info structure (physical %L)\n", &bootinfo, bootinfo_pa); 141 108 printf(" %L: bootstrap trampoline (physical %L)\n", &real_mode, real_mode_pa); 142 printf(" %L: translation table (physical %L)\n", &trans, trans_pa); 109 printf(" %L: translation table (physical %L)\n", trans, trans_pa); 110 printf(" %L: boot allocations (physical %L)\n", balloc_base, balloc_base_pa); 143 111 for (i = 0; i < COMPONENTS; i++) 144 112 printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size); 145 113 146 u nsigned int top = 0;114 uintptr_t top = 0; 147 115 for (i = 0; i < COMPONENTS; i++) 148 116 top += ALIGN_UP(components[i].size, PAGE_SIZE); 117 top += ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE); 118 119 if (top >= TRANS_SIZE * PAGE_SIZE) { 120 printf("Error: boot image is too large\n"); 121 halt(); 122 } 123 124 check_overlap(bootinfo_pa, "boot info", top); 125 check_overlap(real_mode_pa, "bootstrap trampoline", top); 126 check_overlap(trans_pa, "translation table", top); 149 127 150 128 unsigned int pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH; … … 152 130 for (i = 0; i < pages; i++) { 153 131 void *pa = ofw_translate(KERNEL_START + (i << PAGE_WIDTH)); 154 fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "kernel", &top);155 trans[i] = pa;132 check_overlap(pa, "kernel", top); 133 trans[i] = (uintptr_t) pa; 156 134 } 157 135 158 136 bootinfo.taskmap.count = 0; 159 137 for (i = 1; i < COMPONENTS; i++) { 138 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) { 139 printf("\nSkipping superfluous components.\n"); 140 break; 141 } 142 160 143 unsigned int component_pages = ALIGN_UP(components[i].size, PAGE_SIZE) >> PAGE_WIDTH; 161 144 unsigned int j; … … 163 146 for (j = 0; j < component_pages; j++) { 164 147 void *pa = ofw_translate(components[i].start + (j << PAGE_WIDTH)); 165 fix_overlap(components[i].start + (j << PAGE_WIDTH), &pa, components[i].name, &top);166 trans[pages + j] = pa;148 check_overlap(pa, components[i].name, top); 149 trans[pages + j] = (uintptr_t) pa; 167 150 if (j == 0) { 168 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH); 151 152 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) PA2KA(pages << PAGE_WIDTH); 169 153 bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size; 170 154 strncpy(bootinfo.taskmap.tasks[bootinfo.taskmap.count].name, 171 155 components[i].name, BOOTINFO_TASK_NAME_BUFLEN); 172 156 173 157 bootinfo.taskmap.count++; 174 158 } … … 178 162 } 179 163 180 fix_overlap(&real_mode, &real_mode_pa, "bootstrap trampoline", &top); 181 fix_overlap(&trans, &trans_pa, "translation table", &top); 182 fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top); 164 uintptr_t balloc_kernel_base = PA2KA(pages << PAGE_WIDTH); 165 unsigned int balloc_pages = ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE) >> PAGE_WIDTH; 166 for (i = 0; i < balloc_pages; i++) { 167 void *pa = ofw_translate(balloc_base + (i << PAGE_WIDTH)); 168 check_overlap(pa, "boot allocations", top); 169 trans[pages + i] = (uintptr_t) pa; 170 } 171 172 pages += balloc_pages; 173 174 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, balloc_kernel_base); 175 printf("\nCanonizing OpenFirmware device tree..."); 176 bootinfo.ofw_root = ofw_tree_build(); 177 printf("done.\n"); 183 178 184 179 ofw_setup_palette(); 185 180 186 181 printf("\nBooting the kernel...\n"); 187 jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa , (void *) bootinfo.screen.addr, bootinfo.screen.scanline);182 jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa); 188 183 } -
boot/arch/ppc32/loader/main.h
r1ea99cc rb50b5af2 30 30 #define BOOT_ppc32_MAIN_H_ 31 31 32 #include "ofw.h" 32 #include <ofw.h> 33 #include <ofw_tree.h> 34 #include <balloc.h> 35 #include <types.h> 33 36 34 #define TASKMAP_MAX_RECORDS 3237 #define TASKMAP_MAX_RECORDS 32 35 38 36 39 /** Size of buffer for storing task name in task_t. */ 37 #define BOOTINFO_TASK_NAME_BUFLEN 3240 #define BOOTINFO_TASK_NAME_BUFLEN 32 38 41 39 /** Struct holding information about single loaded task. */40 42 typedef struct { 41 /** Address where the task was placed. */42 43 void *addr; 43 /** Size of the task's binary. */ 44 unsigned int size; 45 /** Task name. */ 44 uint32_t size; 46 45 char name[BOOTINFO_TASK_NAME_BUFLEN]; 47 46 } task_t; 48 47 49 48 typedef struct { 50 u nsigned int count;49 uint32_t count; 51 50 task_t tasks[TASKMAP_MAX_RECORDS]; 52 51 } taskmap_t; … … 55 54 memmap_t memmap; 56 55 taskmap_t taskmap; 57 screen_t screen;58 macio_t macio;56 ballocs_t ballocs; 57 ofw_tree_node_t *ofw_root; 59 58 } bootinfo_t; 60 59 … … 62 61 extern void bootstrap(void); 63 62 64 extern memmap_t memmap;65 66 63 #endif -
boot/arch/ppc32/loader/ofwarch.c
r1ea99cc rb50b5af2 31 31 #include <printf.h> 32 32 33 typedef int (* ofw_entry_t)(ofw_args_t *args);33 typedef int (*ofw_entry_t)(ofw_args_t *args); 34 34 35 35 int ofw(ofw_args_t *args) … … 49 49 } 50 50 51 int ofw_macio(macio_t *macio)52 {53 char device_name[BUF_SIZE];54 55 if ((ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)56 && (ofw_get_property(ofw_aliases, "mac-io", device_name, sizeof(device_name)) <= 0))57 return false;58 59 phandle device = ofw_find_device(device_name);60 if (device == -1)61 return false;62 63 pci_reg_t pci_reg;64 if (ofw_get_property(device, "assigned-addresses", &pci_reg, sizeof(pci_reg)) <= 0)65 return false;66 67 macio->addr = (void *) pci_reg.addr.addr_lo;68 macio->size = pci_reg.size_lo;69 70 return true;71 }72 73 51 int ofw_translate_failed(ofw_arg_t flag) 74 52 { 53 /* PearPC returns buggy flag */ 75 54 return 0; 76 55 } -
boot/arch/ppc32/loader/ofwarch.h
r1ea99cc rb50b5af2 30 30 #define BOOT_ppc32_OFWARCH_H_ 31 31 32 #define OFW_ADDRESS_CELLS 133 #define OFW_SIZE_CELLS 132 #define OFW_ADDRESS_CELLS 1 33 #define OFW_SIZE_CELLS 1 34 34 35 35 #endif -
boot/arch/ppc32/loader/regname.h
r1ea99cc rb50b5af2 31 31 32 32 /* Condition Register Bit Fields */ 33 #define cr0034 #define cr1135 #define cr2236 #define cr3337 #define cr4438 #define cr5539 #define cr6640 #define cr7733 #define cr0 0 34 #define cr1 1 35 #define cr2 2 36 #define cr3 3 37 #define cr4 4 38 #define cr5 5 39 #define cr6 6 40 #define cr7 7 41 41 42 42 /* General Purpose Registers (GPRs) */ 43 #define r0044 #define r1145 #define r2246 #define r3347 #define r4448 #define r5549 #define r6650 #define r7751 #define r8852 #define r9953 #define r101054 #define r111155 #define r121256 #define r131357 #define r141458 #define r151559 #define r161660 #define r171761 #define r181862 #define r191963 #define r202064 #define r212165 #define r222266 #define r232367 #define r242468 #define r252569 #define r262670 #define r272771 #define r282872 #define r292973 #define r303074 #define r313143 #define r0 0 44 #define r1 1 45 #define r2 2 46 #define r3 3 47 #define r4 4 48 #define r5 5 49 #define r6 6 50 #define r7 7 51 #define r8 8 52 #define r9 9 53 #define r10 10 54 #define r11 11 55 #define r12 12 56 #define r13 13 57 #define r14 14 58 #define r15 15 59 #define r16 16 60 #define r17 17 61 #define r18 18 62 #define r19 19 63 #define r20 20 64 #define r21 21 65 #define r22 22 66 #define r23 23 67 #define r24 24 68 #define r25 25 69 #define r26 26 70 #define r27 27 71 #define r28 28 72 #define r29 29 73 #define r30 30 74 #define r31 31 75 75 76 76 /* GPR Aliases */ 77 #define sp177 #define sp 1 78 78 79 79 /* Floating Point Registers (FPRs) */ 80 #define fr0081 #define fr1182 #define fr2283 #define fr3384 #define fr4485 #define fr5586 #define fr6687 #define fr7788 #define fr8889 #define fr9990 #define fr101091 #define fr111192 #define fr121293 #define fr131394 #define fr141495 #define fr151596 #define fr161697 #define fr171798 #define fr181899 #define fr1919100 #define fr2020101 #define fr2121102 #define fr2222103 #define fr2323104 #define fr2424105 #define fr2525106 #define fr2626107 #define fr2727108 #define fr2828109 #define fr2929110 #define fr3030111 #define fr3131112 113 #define vr00114 #define vr11115 #define vr22116 #define vr33117 #define vr44118 #define vr55119 #define vr66120 #define vr77121 #define vr88122 #define vr99123 #define vr1010124 #define vr1111125 #define vr1212126 #define vr1313127 #define vr1414128 #define vr1515129 #define vr1616130 #define vr1717131 #define vr1818132 #define vr1919133 #define vr2020134 #define vr2121135 #define vr2222136 #define vr2323137 #define vr2424138 #define vr2525139 #define vr2626140 #define vr2727141 #define vr2828142 #define vr2929143 #define vr3030144 #define vr3131145 146 #define evr00147 #define evr11148 #define evr22149 #define evr33150 #define evr44151 #define evr55152 #define evr66153 #define evr77154 #define evr88155 #define evr99156 #define evr1010157 #define evr1111158 #define evr1212159 #define evr1313160 #define evr1414161 #define evr1515162 #define evr1616163 #define evr1717164 #define evr1818165 #define evr1919166 #define evr2020167 #define evr2121168 #define evr2222169 #define evr2323170 #define evr2424171 #define evr2525172 #define evr2626173 #define evr2727174 #define evr2828175 #define evr2929176 #define evr3030177 #define evr313180 #define fr0 0 81 #define fr1 1 82 #define fr2 2 83 #define fr3 3 84 #define fr4 4 85 #define fr5 5 86 #define fr6 6 87 #define fr7 7 88 #define fr8 8 89 #define fr9 9 90 #define fr10 10 91 #define fr11 11 92 #define fr12 12 93 #define fr13 13 94 #define fr14 14 95 #define fr15 15 96 #define fr16 16 97 #define fr17 17 98 #define fr18 18 99 #define fr19 19 100 #define fr20 20 101 #define fr21 21 102 #define fr22 22 103 #define fr23 23 104 #define fr24 24 105 #define fr25 25 106 #define fr26 26 107 #define fr27 27 108 #define fr28 28 109 #define fr29 29 110 #define fr30 30 111 #define fr31 31 112 113 #define vr0 0 114 #define vr1 1 115 #define vr2 2 116 #define vr3 3 117 #define vr4 4 118 #define vr5 5 119 #define vr6 6 120 #define vr7 7 121 #define vr8 8 122 #define vr9 9 123 #define vr10 10 124 #define vr11 11 125 #define vr12 12 126 #define vr13 13 127 #define vr14 14 128 #define vr15 15 129 #define vr16 16 130 #define vr17 17 131 #define vr18 18 132 #define vr19 19 133 #define vr20 20 134 #define vr21 21 135 #define vr22 22 136 #define vr23 23 137 #define vr24 24 138 #define vr25 25 139 #define vr26 26 140 #define vr27 27 141 #define vr28 28 142 #define vr29 29 143 #define vr30 30 144 #define vr31 31 145 146 #define evr0 0 147 #define evr1 1 148 #define evr2 2 149 #define evr3 3 150 #define evr4 4 151 #define evr5 5 152 #define evr6 6 153 #define evr7 7 154 #define evr8 8 155 #define evr9 9 156 #define evr10 10 157 #define evr11 11 158 #define evr12 12 159 #define evr13 13 160 #define evr14 14 161 #define evr15 15 162 #define evr16 16 163 #define evr17 17 164 #define evr18 18 165 #define evr19 19 166 #define evr20 20 167 #define evr21 21 168 #define evr22 22 169 #define evr23 23 170 #define evr24 24 171 #define evr25 25 172 #define evr26 26 173 #define evr27 27 174 #define evr28 28 175 #define evr29 29 176 #define evr30 30 177 #define evr31 31 178 178 179 179 /* Special Purpose Registers (SPRs) */ 180 #define xer 1 181 #define lr 8 182 #define ctr 9 183 #define dec 22 184 #define sdr1 25 185 #define srr0 26 186 #define srr1 27 187 #define sprg0 272 188 #define sprg1 273 189 #define sprg2 274 190 #define sprg3 275 191 #define prv 287 192 #define ibat0u 528 193 #define ibat0l 529 194 #define ibat1u 530 195 #define ibat1l 531 196 #define ibat2u 532 197 #define ibat2l 533 198 #define ibat3u 534 199 #define ibat3l 535 200 #define dbat0u 536 201 #define dbat0l 537 202 #define dbat1u 538 203 #define dbat1l 539 204 #define dbat2u 540 205 #define dbat2l 541 206 #define dbat3u 542 207 #define dbat3l 543 208 #define hid0 1008 180 #define xer 1 181 #define lr 8 182 #define ctr 9 183 #define dec 22 184 #define sdr1 25 185 #define srr0 26 186 #define srr1 27 187 #define sprg0 272 188 #define sprg1 273 189 #define sprg2 274 190 #define sprg3 275 191 #define prv 287 192 #define ibat0u 528 193 #define ibat0l 529 194 #define ibat1u 530 195 #define ibat1l 531 196 #define ibat2u 532 197 #define ibat2l 533 198 #define ibat3u 534 199 #define ibat3l 535 200 #define dbat0u 536 201 #define dbat0l 537 202 #define dbat1u 538 203 #define dbat1l 539 204 #define dbat2u 540 205 #define dbat2l 541 206 #define dbat3u 542 207 #define dbat3l 543 208 #define tlbmiss 980 209 #define ptehi 981 210 #define ptelo 982 211 #define hid0 1008 209 212 210 213 /* MSR bits */ 211 #define msr_dr (1 << 4)212 #define msr_ir (1 << 5)213 #define msr_pr (1 << 14)214 #define msr_ee (1 << 15)214 #define msr_dr (1 << 4) 215 #define msr_ir (1 << 5) 216 #define msr_pr (1 << 14) 217 #define msr_ee (1 << 15) 215 218 216 219 /* HID0 bits */ 217 #define hid0_sten (1 << 24)218 #define hid0_ice (1 << 15)219 #define hid0_dce (1 << 14)220 #define hid0_icfi (1 << 11)221 #define hid0_dci (1 << 10)220 #define hid0_sten (1 << 24) 221 #define hid0_ice (1 << 15) 222 #define hid0_dce (1 << 14) 223 #define hid0_icfi (1 << 11) 224 #define hid0_dci (1 << 10) 222 225 223 226 #endif -
boot/arch/sparc64/loader/asm.S
r1ea99cc rb50b5af2 31 31 #include <register.h> 32 32 33 .register %g2, #scratch34 .register %g3, #scratch33 .register %g2, #scratch 34 .register %g3, #scratch 35 35 36 36 .text … … 43 43 ba %xcc, halt 44 44 nop 45 46 memcpy: 47 mov %o0, %o3 ! save dst 48 add %o1, 7, %g1 49 and %g1, -8, %g1 50 cmp %o1, %g1 51 be,pn %xcc, 3f 52 add %o0, 7, %g1 53 mov 0, %g3 45 54 46 memcpy: 47 mov %o0, %o3 ! save dst 48 add %o1, 7, %g1 49 and %g1, -8, %g1 50 cmp %o1, %g1 51 be,pn %xcc, 3f 52 add %o0, 7, %g1 53 mov 0, %g3 54 0: 55 brz,pn %o2, 2f 56 mov 0, %g2 57 1: 58 ldub [%g3 + %o1], %g1 59 add %g2, 1, %g2 60 cmp %o2, %g2 61 stb %g1, [%g3 + %o0] 62 bne,pt %xcc, 1b 63 mov %g2, %g3 64 2: 65 jmp %o7 + 8 ! exit point 66 mov %o3, %o0 67 3: 68 and %g1, -8, %g1 69 cmp %o0, %g1 70 bne,pt %xcc, 0b 71 mov 0, %g3 72 srlx %o2, 3, %g4 73 brz,pn %g4, 5f 74 mov 0, %g5 75 4: 76 sllx %g3, 3, %g2 77 add %g5, 1, %g3 78 ldx [%o1 + %g2], %g1 79 mov %g3, %g5 80 cmp %g4, %g3 81 bne,pt %xcc, 4b 82 stx %g1, [%o0 + %g2] 83 5: 84 and %o2, 7, %o2 85 brz,pn %o2, 2b 86 sllx %g4, 3, %g1 87 mov 0, %g2 88 add %g1, %o0, %o0 89 add %g1, %o1, %g4 90 mov 0, %g3 91 6: 92 ldub [%g2 + %g4], %g1 93 stb %g1, [%g2 + %o0] 94 add %g3, 1, %g2 95 cmp %o2, %g2 96 bne,pt %xcc, 6b 97 mov %g2, %g3 98 99 jmp %o7 + 8 ! exit point 100 mov %o3, %o0 55 0: 56 brz,pn %o2, 2f 57 mov 0, %g2 58 59 1: 60 ldub [%g3 + %o1], %g1 61 add %g2, 1, %g2 62 cmp %o2, %g2 63 stb %g1, [%g3 + %o0] 64 bne,pt %xcc, 1b 65 mov %g2, %g3 66 67 2: 68 jmp %o7 + 8 ! exit point 69 mov %o3, %o0 70 71 3: 72 and %g1, -8, %g1 73 cmp %o0, %g1 74 bne,pt %xcc, 0b 75 mov 0, %g3 76 srlx %o2, 3, %g4 77 brz,pn %g4, 5f 78 mov 0, %g5 79 80 4: 81 sllx %g3, 3, %g2 82 add %g5, 1, %g3 83 ldx [%o1 + %g2], %g1 84 mov %g3, %g5 85 cmp %g4, %g3 86 bne,pt %xcc, 4b 87 stx %g1, [%o0 + %g2] 88 89 5: 90 and %o2, 7, %o2 91 brz,pn %o2, 2b 92 sllx %g4, 3, %g1 93 mov 0, %g2 94 add %g1, %o0, %o0 95 add %g1, %o1, %g4 96 mov 0, %g3 97 98 6: 99 ldub [%g2 + %g4], %g1 100 stb %g1, [%g2 + %o0] 101 add %g3, 1, %g2 102 cmp %o2, %g2 103 bne,pt %xcc, 6b 104 mov %g2, %g3 105 106 jmp %o7 + 8 ! exit point 107 mov %o3, %o0 101 108 102 109 jump_to_kernel: … … 107 114 * 3. Flush instruction pipeline. 108 115 */ 109 116 110 117 /* 111 118 * US3 processors have a write-invalidate cache, so explicitly 112 119 * invalidating it is not required. Whether to invalidate I-cache 113 * or not is decided according to the value of the global114 * "subarchitecture" variable (set in the bootstrap).120 * or not is decided according to the value of the 5th argument 121 * (subarchitecture). 115 122 */ 116 set subarchitecture, %g2 117 ldub [%g2], %g2 118 cmp %g2, 3 123 cmp %i4, 3 119 124 be %xcc, 1f 120 125 nop 121 0: 122 call icache_flush 123 nop 124 1: 125 membar #StoreStore 126 127 0: 128 call icache_flush 129 nop 130 131 1: 132 membar #StoreStore 126 133 127 134 /* 128 135 * Flush the instruction pipeline. 129 136 */ 130 flush %i7131 137 flush %i7 138 132 139 mov %o0, %l1 133 140 mov %o1, %o0 134 141 mov %o2, %o1 135 142 mov %o3, %o2 136 jmp %l1 ! jump to kernel143 jmp %l1 ! jump to kernel 137 144 nop 138 145 139 #define ICACHE_SIZE 8192140 #define ICACHE_LINE_SIZE 32141 #define ICACHE_SET_BIT (1 << 13)142 #define ASI_ICACHE_TAG 0x67146 #define ICACHE_SIZE 8192 147 #define ICACHE_LINE_SIZE 32 148 #define ICACHE_SET_BIT (1 << 13) 149 #define ASI_ICACHE_TAG 0x67 143 150 144 151 # Flush I-cache 145 152 icache_flush: 146 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1 147 stxa %g0, [%g1] ASI_ICACHE_TAG 148 0: membar #Sync 149 subcc %g1, ICACHE_LINE_SIZE, %g1 150 bnz,pt %xcc, 0b 151 stxa %g0, [%g1] ASI_ICACHE_TAG 152 membar #Sync 153 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1 154 stxa %g0, [%g1] ASI_ICACHE_TAG 155 156 0: 157 membar #Sync 158 subcc %g1, ICACHE_LINE_SIZE, %g1 159 bnz,pt %xcc, 0b 160 161 stxa %g0, [%g1] ASI_ICACHE_TAG 162 membar #Sync 153 163 retl 154 164 ! SF Erratum #51 155 165 nop 166 156 167 .global ofw 157 168 ofw: … … 159 170 set ofw_cif, %l0 160 171 ldx [%l0], %l0 161 172 162 173 rdpr %pstate, %l1 163 174 and %l1, ~PSTATE_AM_BIT, %l2 164 175 wrpr %l2, 0, %pstate 165 176 166 177 jmpl %l0, %o7 167 178 mov %i0, %o0 168 179 169 180 wrpr %l1, 0, %pstate 170 181 171 182 ret 172 183 restore %o0, 0, %o0 -
boot/arch/sparc64/loader/asm.h
r1ea99cc rb50b5af2 34 34 #include "main.h" 35 35 36 #define PAGE_WIDTH 1437 #define PAGE_SIZE (1 << PAGE_WIDTH)36 #define PAGE_WIDTH 14 37 #define PAGE_SIZE (1 << PAGE_WIDTH) 38 38 39 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))39 #define BALLOC_MAX_SIZE (128 * 1024) 40 40 41 41 extern void halt(void); 42 42 extern void jump_to_kernel(void *entry, uint64_t cfg, bootinfo_t *bootinfo, 43 unsigned int bootinfo_size) __attribute__((noreturn));43 unsigned int bootinfo_size, uint8_t subarchitecture) __attribute__((noreturn)); 44 44 45 45 #endif -
boot/arch/sparc64/loader/boot.S
r1ea99cc rb50b5af2 31 31 #include <register.h> 32 32 33 #define INITIAL_STACK_SIZE 819233 #define INITIAL_STACK_SIZE 8192 34 34 35 #define NWINDOWS 835 #define NWINDOWS 8 36 36 37 37 .register %g2, #scratch … … 57 57 .half 0 58 58 .half 0 59 59 60 .global silo_ramdisk_image 60 61 silo_ramdisk_image: 61 62 .word 0 63 62 64 .global silo_ramdisk_size 63 65 silo_ramdisk_size: … … 65 67 66 68 .align 8 67 1: 69 1: 68 70 /* 69 71 * Disable interrupts and disable address masking. … … 71 73 wrpr %g0, PSTATE_PRIV_BIT, %pstate 72 74 73 wrpr %g0, NWINDOWS - 2, %cansave ! set maximum saveable windows74 wrpr %g0, 0, %canrestore ! get rid of windows we will never need again75 wrpr %g0, 0, %otherwin ! make sure the window state is consistent76 wrpr %g0, NWINDOWS - 1, %cleanwin ! prevent needless clean_window traps for kernel77 75 wrpr %g0, NWINDOWS - 2, %cansave ! set maximum saveable windows 76 wrpr %g0, 0, %canrestore ! get rid of windows we will never need again 77 wrpr %g0, 0, %otherwin ! make sure the window state is consistent 78 wrpr %g0, NWINDOWS - 1, %cleanwin ! prevent needless clean_window traps for kernel 79 78 80 set initial_stack_top, %sp 79 81 add %sp, -STACK_BIAS, %sp 80 82 81 83 set ofw_cif, %l0 82 83 call ofw_init ! initialize OpenFirmware84 85 call ofw_init ! initialize OpenFirmware 84 86 stx %o4, [%l0] 85 87 … … 90 92 initial_stack: 91 93 .space INITIAL_STACK_SIZE 94 92 95 initial_stack_top: 93 96 .space STACK_WINDOW_SAVE_AREA_SIZE -
boot/arch/sparc64/loader/main.c
r1ea99cc rb50b5af2 1 1 /* 2 2 * Copyright (c) 2005 Martin Decky 3 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2006 Jakub Jermar 4 4 * All rights reserved. 5 5 * … … 28 28 */ 29 29 30 #include "main.h" 30 #include "main.h" 31 31 #include <printf.h> 32 32 #include "asm.h" … … 39 39 #include <macros.h> 40 40 #include <string.h> 41 42 bootinfo_t bootinfo; 43 44 component_t components[COMPONENTS]; 45 46 char *release = STRING(RELEASE); 41 #include <memstr.h> 42 43 static bootinfo_t bootinfo; 44 static component_t components[COMPONENTS]; 45 static char *release = STRING(RELEASE); 47 46 48 47 #ifdef REVISION 49 char *revision = ", revision " STRING(REVISION);48 static char *revision = ", revision " STRING(REVISION); 50 49 #else 51 char *revision = "";50 static char *revision = ""; 52 51 #endif 53 52 54 53 #ifdef TIMESTAMP 55 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);54 static char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 56 55 #else 57 char *timestamp = "";56 static char *timestamp = ""; 58 57 #endif 59 58 60 59 /** UltraSPARC subarchitecture - 1 for US, 3 for US3 */ 61 uint8_t subarchitecture;60 static uint8_t subarchitecture; 62 61 63 62 /** … … 65 64 * MID_SHIFT bits to the right 66 65 */ 67 uint16_t mid_mask;66 static uint16_t mid_mask; 68 67 69 68 /** Print version information. */ … … 76 75 77 76 /* the lowest ID (read from the VER register) of some US3 CPU model */ 78 #define FIRST_US3_CPU 0x1477 #define FIRST_US3_CPU 0x14 79 78 80 79 /* the greatest ID (read from the VER register) of some US3 CPU model */ 81 #define LAST_US3_CPU 0x1980 #define LAST_US3_CPU 0x19 82 81 83 82 /* UltraSPARC IIIi processor implementation code */ 84 #define US_IIIi_CODE 0x1583 #define US_IIIi_CODE 0x15 85 84 86 85 /** … … 91 90 { 92 91 uint64_t v; 93 asm volatile ("rdpr %%ver, %0\n" : "=r" (v)); 92 asm volatile ( 93 "rdpr %%ver, %0\n" 94 : "=r" (v) 95 ); 94 96 95 97 v = (v << 16) >> 48; … … 103 105 subarchitecture = SUBARCH_US; 104 106 mid_mask = (1 << 5) - 1; 105 } else {107 } else 106 108 printf("\nThis CPU is not supported by HelenOS."); 107 }108 109 } 109 110 … … 113 114 void *balloc_base; 114 115 unsigned int top = 0; 115 int i, j; 116 116 unsigned int i; 117 unsigned int j; 118 117 119 version_print(); 118 120 119 121 detect_subarchitecture(); 120 122 init_components(components); 121 123 122 124 if (!ofw_get_physmem_start(&bootinfo.physmem_start)) { 123 125 printf("Error: unable to get start of physical memory.\n"); 124 126 halt(); 125 127 } 126 128 127 129 if (!ofw_memmap(&bootinfo.memmap)) { 128 130 printf("Error: unable to get memory map, halting.\n"); 129 131 halt(); 130 132 } 131 133 132 134 if (bootinfo.memmap.total == 0) { 133 135 printf("Error: no memory detected, halting.\n"); 134 136 halt(); 135 137 } 136 138 137 139 /* 138 140 * SILO for some reason adds 0x400000 and subtracts … … 143 145 silo_ramdisk_image += bootinfo.physmem_start; 144 146 silo_ramdisk_image -= 0x400000; 145 /* Install 1:1 mapping for the ramdisk. */ 146 if (ofw_map((void *)((uintptr_t) silo_ramdisk_image), 147 (void *)((uintptr_t) silo_ramdisk_image), 147 148 /* Install 1:1 mapping for the RAM disk. */ 149 if (ofw_map((void *) ((uintptr_t) silo_ramdisk_image), 150 (void *) ((uintptr_t) silo_ramdisk_image), 148 151 silo_ramdisk_size, -1) != 0) { 149 printf("Failed to map ramdisk.\n");152 printf("Failed to map RAM disk.\n"); 150 153 halt(); 151 154 } 152 155 } 153 156 154 printf("\nSystem info\n"); 155 printf(" memory: %dM starting at %P\n", 157 printf("\nMemory statistics (total %d MB, starting at %P)\n", 156 158 bootinfo.memmap.total >> 20, bootinfo.physmem_start); 157 158 printf("\nMemory statistics\n"); 159 printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS); 159 printf(" %P: kernel entry point\n", KERNEL_VIRTUAL_ADDRESS); 160 160 printf(" %P: boot info structure\n", &bootinfo); 161 161 … … 176 176 break; 177 177 } 178 178 179 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = 179 180 base + top; … … 187 188 top += components[i].size; 188 189 } 189 190 j = bootinfo.taskmap.count - 1; /* do not consider ramdisk */ 191 190 191 /* Do not consider RAM disk */ 192 j = bootinfo.taskmap.count - 1; 193 192 194 if (silo_ramdisk_image) { 193 /* Treat the ramdisk as the last bootinfo task. */195 /* Treat the RAM disk as the last bootinfo task. */ 194 196 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) { 195 printf("Skipping ramdisk.\n");197 printf("Skipping RAM disk.\n"); 196 198 goto skip_ramdisk; 197 199 } 200 198 201 top = ALIGN_UP(top, PAGE_SIZE); 199 202 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = … … 202 205 silo_ramdisk_size; 203 206 bootinfo.taskmap.count++; 204 printf("\nCopying ramdisk..."); 207 printf("\nCopying RAM disk..."); 208 205 209 /* 206 210 * Claim and map the whole ramdisk as it may exceed the area … … 210 214 (void) ofw_map(bootinfo.physmem_start + base + top, base + top, 211 215 silo_ramdisk_size, -1); 212 /* 213 * FIXME If the source and destination overlap, it may be 214 * desirable to copy in reverse order, depending on how the two 215 * regions overlap. 216 */ 217 memcpy(base + top, (void *)((uintptr_t)silo_ramdisk_image), 216 memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image), 218 217 silo_ramdisk_size); 218 219 219 printf("done.\n"); 220 220 top += silo_ramdisk_size; 221 221 } 222 222 skip_ramdisk: 223 223 224 224 /* 225 225 * Now we can proceed to copy the components. We do it in reverse order … … 227 227 * with base. 228 228 */ 229 printf("\nCopying bootinfo tasks\n");229 printf("\nCopying tasks..."); 230 230 for (i = COMPONENTS - 1; i > 0; i--, j--) { 231 printf(" %s...", components[i].name);232 231 printf("%s ", components[i].name); 232 233 233 /* 234 234 * At this point, we claim the physical memory that we are … … 245 245 bootinfo.taskmap.tasks[j].addr, 246 246 ALIGN_UP(components[i].size, PAGE_SIZE)); 247 248 memcpy((void *) bootinfo.taskmap.tasks[j].addr,247 248 memcpy((void *) bootinfo.taskmap.tasks[j].addr, 249 249 components[i].start, components[i].size); 250 printf("done.\n"); 251 } 252 250 251 } 252 printf(".\n"); 253 253 254 printf("\nCopying kernel..."); 254 255 (void) ofw_claim_phys(bootinfo.physmem_start + base, … … 256 257 memcpy(base, components[0].start, components[0].size); 257 258 printf("done.\n"); 258 259 259 260 /* 260 261 * Claim and map the physical memory for the boot allocator. … … 266 267 (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base, 267 268 BALLOC_MAX_SIZE, -1); 268 balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base); 269 269 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, 270 (uintptr_t) balloc_base); 271 270 272 printf("\nCanonizing OpenFirmware device tree..."); 271 273 bootinfo.ofw_root = ofw_tree_build(); 272 274 printf("done.\n"); 273 275 274 276 #ifdef CONFIG_AP 275 277 printf("\nChecking for secondary processors..."); 276 if (!ofw_cpu( ))278 if (!ofw_cpu(mid_mask, bootinfo.physmem_start)) 277 279 printf("Error: unable to get CPU properties\n"); 278 280 printf("done.\n"); 279 281 #endif 280 282 281 283 ofw_setup_palette(); 282 284 283 285 printf("\nBooting the kernel...\n"); 284 286 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 285 287 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 286 sizeof(bootinfo) );288 sizeof(bootinfo), subarchitecture); 287 289 } -
boot/arch/sparc64/loader/main.h
r1ea99cc rb50b5af2 35 35 #include <types.h> 36 36 37 #define KERNEL_VIRTUAL_ADDRESS 0x40000037 #define KERNEL_VIRTUAL_ADDRESS 0x400000 38 38 39 #define TASKMAP_MAX_RECORDS 3239 #define TASKMAP_MAX_RECORDS 32 40 40 41 41 /** Size of buffer for storing task name in task_t. */ 42 #define BOOTINFO_TASK_NAME_BUFLEN 3242 #define BOOTINFO_TASK_NAME_BUFLEN 32 43 43 44 #define BSP_PROCESSOR 145 #define AP_PROCESSOR 044 #define BSP_PROCESSOR 1 45 #define AP_PROCESSOR 0 46 46 47 #define SUBARCH_US 148 #define SUBARCH_US3 347 #define SUBARCH_US 1 48 #define SUBARCH_US3 3 49 49 50 50 typedef struct { … … 70 70 extern uint32_t silo_ramdisk_size; 71 71 72 extern bootinfo_t bootinfo;73 74 72 extern void start(void); 75 73 extern void bootstrap(void); -
boot/arch/sparc64/loader/ofwarch.c
r1ea99cc rb50b5af2 30 30 /** 31 31 * @file 32 * @brief Architecture dependent parts of OpenFirmware interface.32 * @brief Architecture dependent parts of OpenFirmware interface. 33 33 */ 34 34 … … 40 40 #include "main.h" 41 41 #include "asm.h" 42 43 /* these tho variables will be set by the detect_subarchitecture function */44 extern uint8_t subarchitecture;45 extern uint16_t mid_mask;46 42 47 43 void write(const char *str, const int len) … … 65 61 * except for the current CPU. 66 62 * 67 * @param child The first child of the OFW tree node whose children 68 * represent CPUs to be woken up. 69 * @param current_mid MID of the current CPU, the current CPU will 70 * (of course) not be woken up. 71 * @return Number of CPUs which have the same parent node as 72 * "child". 63 * @param child The first child of the OFW tree node whose children 64 * represent CPUs to be woken up. 65 * @param current_mid MID of the current CPU, the current CPU will 66 * (of course) not be woken up. 67 * @param physmem_start Starting address of the physical memory. 68 * 69 * @return Number of CPUs which have the same parent node as 70 * "child". 71 * 73 72 */ 74 static int wake_cpus_in_node(phandle child, uint64_t current_mid) 73 static int wake_cpus_in_node(phandle child, uint64_t current_mid, 74 uintptr_t physmem_start) 75 75 { 76 76 int cpus; 77 char type_name[BUF_SIZE];78 77 79 for (cpus = 0; child != 0 && child != -1;78 for (cpus = 0; (child != 0) && (child != -1); 80 79 child = ofw_get_peer_node(child), cpus++) { 80 char type_name[BUF_SIZE]; 81 81 82 if (ofw_get_property(child, "device_type", type_name, 82 83 sizeof(type_name)) > 0) { … … 88 89 * "cpuid" for US-IV 89 90 */ 90 if (ofw_get_property( 91 child, "upa-portid", 92 &mid, sizeof(mid)) <= 0 93 && ofw_get_property(child, "portid", 94 &mid, sizeof(mid)) <= 0 95 && ofw_get_property(child, "cpuid", 96 &mid, sizeof(mid)) <= 0) 91 if ((ofw_get_property(child, "upa-portid", &mid, sizeof(mid)) <= 0) 92 && (ofw_get_property(child, "portid", &mid, sizeof(mid)) <= 0) 93 && (ofw_get_property(child, "cpuid", &mid, sizeof(mid)) <= 0)) 97 94 continue; 98 95 99 96 if (current_mid != mid) { 100 97 /* … … 103 100 (void) ofw_call("SUNW,start-cpu", 3, 1, 104 101 NULL, child, KERNEL_VIRTUAL_ADDRESS, 105 bootinfo.physmem_start | 106 AP_PROCESSOR); 102 physmem_start | AP_PROCESSOR); 107 103 } 108 104 } 109 105 } 110 106 } 111 107 112 108 return cpus; 113 109 } … … 116 112 * Finds out the current CPU's MID and wakes up all AP processors. 117 113 */ 118 int ofw_cpu( void)114 int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start) 119 115 { 120 int cpus; 121 phandle node; 122 phandle subnode; 123 phandle cpus_parent; 124 phandle cmp; 125 char name[BUF_SIZE]; 126 127 /* get the current CPU MID */ 116 /* Get the current CPU MID */ 128 117 uint64_t current_mid; 129 118 130 asm volatile ("ldxa [%1] %2, %0\n" 131 : "=r" (current_mid) 132 : "r" (0), "i" (ASI_ICBUS_CONFIG)); 119 asm volatile ( 120 "ldxa [%1] %2, %0\n" 121 : "=r" (current_mid) 122 : "r" (0), "i" (ASI_ICBUS_CONFIG) 123 ); 124 133 125 current_mid >>= ICBUS_CONFIG_MID_SHIFT; 134 135 126 current_mid &= mid_mask; 136 137 /* wake up CPUs */138 127 139 cpus_parent = ofw_find_device("/ssm@0,0"); 140 if (cpus_parent == 0 || cpus_parent == -1) { 128 /* Wake up the CPUs */ 129 130 phandle cpus_parent = ofw_find_device("/ssm@0,0"); 131 if ((cpus_parent == 0) || (cpus_parent == -1)) 141 132 cpus_parent = ofw_find_device("/"); 142 } 143 144 node = ofw_get_child_node(cpus_parent); 145 cpus = wake_cpus_in_node(node, current_mid); 146 while (node != 0 && node != -1) { 133 134 phandle node = ofw_get_child_node(cpus_parent); 135 int cpus = wake_cpus_in_node(node, current_mid, physmem_start); 136 while ((node != 0) && (node != -1)) { 137 char name[BUF_SIZE]; 138 147 139 if (ofw_get_property(node, "name", name, 148 sizeof(name)) > 0) {140 sizeof(name)) > 0) { 149 141 if (strcmp(name, "cmp") == 0) { 150 subnode = ofw_get_child_node(node);142 phandle subnode = ofw_get_child_node(node); 151 143 cpus += wake_cpus_in_node(subnode, 152 current_mid );144 current_mid, physmem_start); 153 145 } 154 146 } … … 157 149 158 150 return cpus; 159 160 151 } 161 152 162 153 /** Get physical memory starting address. 163 154 * 164 * @param start Pointer to variable where the physical memory starting165 * address will be stored.155 * @param start Pointer to variable where the physical memory starting 156 * address will be stored. 166 157 * 167 * @return Non-zero on succes, zero on failure. 158 * @return Non-zero on succes, zero on failure. 159 * 168 160 */ 169 161 int ofw_get_physmem_start(uintptr_t *start) 170 162 { 171 163 uint32_t memreg[4]; 172 173 164 if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0) 174 165 return 0; 175 166 176 167 *start = (((uint64_t) memreg[0]) << 32) | memreg[1]; 177 168 return 1; 178 169 } 179 -
boot/arch/sparc64/loader/ofwarch.h
r1ea99cc rb50b5af2 33 33 #include "types.h" 34 34 35 #define OFW_ADDRESS_CELLS 236 #define OFW_SIZE_CELLS 235 #define OFW_ADDRESS_CELLS 2 36 #define OFW_SIZE_CELLS 2 37 37 38 extern int ofw_cpu( void);39 extern int ofw_get_physmem_start(uintptr_t *start); 38 extern int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start); 39 extern int ofw_get_physmem_start(uintptr_t *start); 40 40 41 41 #endif -
boot/arch/sparc64/loader/register.h
r1ea99cc rb50b5af2 30 30 #define BOOT_sparc64_REGISTER_H_ 31 31 32 #define PSTATE_IE_BIT 233 #define PSTATE_PRIV_BIT 434 #define PSTATE_AM_BIT 832 #define PSTATE_IE_BIT 2 33 #define PSTATE_PRIV_BIT 4 34 #define PSTATE_AM_BIT 8 35 35 36 #define ASI_ICBUS_CONFIG 0x4a37 #define ICBUS_CONFIG_MID_SHIFT 1736 #define ASI_ICBUS_CONFIG 0x4a 37 #define ICBUS_CONFIG_MID_SHIFT 17 38 38 39 39 #endif -
boot/arch/sparc64/loader/stack.h
r1ea99cc rb50b5af2 30 30 #define BOOT_sparc64_STACK_H_ 31 31 32 #define STACK_ALIGNMENT 1633 #define STACK_BIAS 204734 #define STACK_WINDOW_SAVE_AREA_SIZE (16*8)32 #define STACK_ALIGNMENT 16 33 #define STACK_BIAS 2047 34 #define STACK_WINDOW_SAVE_AREA_SIZE (16 * 8) 35 35 36 36 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
