Changes in / [bc7d44c:207e208e] in mainline
- Files:
-
- 6 deleted
- 62 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rbc7d44c r207e208e 273 273 274 274 % OpenFirmware tree support 275 ! [PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_OFW_TREE (y) 276 277 % OpenFirmware PCI bus support 278 ! [PLATFORM=sparc64] CONFIG_OFW_PCI (y) 275 ! [PLATFORM=sparc64] CONFIG_OFW_TREE (y) 279 276 280 277 % Multiboot standard support -
boot/arch/arm32/loader/asm.h
rbc7d44c r207e208e 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 42 51 /** Called when the CPU is switched on. 43 52 * -
boot/arch/arm32/loader/main.c
rbc7d44c r207e208e 43 43 #include <macros.h> 44 44 #include <string.h> 45 #include <memstr.h>46 45 47 46 #include "mm.h" -
boot/arch/ia64/loader/asm.h
rbc7d44c r207e208e 34 34 #include "main.h" 35 35 36 #define PAGE_WIDTH 37 #define PAGE_SIZE 36 #define PAGE_WIDTH 14 37 #define PAGE_SIZE (1 << PAGE_WIDTH) 38 38 39 #define BALLOC_MAX_SIZE (128 * 1024)39 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 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 42 45 extern void jump_to_kernel(void *) __attribute__((noreturn)); 43 46 -
boot/arch/ia64/loader/main.h
rbc7d44c r207e208e 34 34 35 35 36 #define CONFIG_INIT_TASKS 32 36 #define CONFIG_INIT_TASKS 32 37 38 37 39 38 40 extern void start(void); -
boot/arch/mips32/loader/asm.h
rbc7d44c r207e208e 33 33 #define PAGE_WIDTH 14 34 34 35 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 36 35 37 void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn)); 36 38 -
boot/arch/mips32/loader/main.c
rbc7d44c r207e208e 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>35 34 #include "msim.h" 36 35 #include "asm.h" -
boot/arch/ppc32/loader/Makefile
rbc7d44c r207e208e 62 62 SOURCES = \ 63 63 main.c \ 64 ofwarch.c \ 64 65 _components.c \ 66 ../../../genarch/ofw.c \ 65 67 ../../../generic/printf.c \ 66 68 ../../../generic/string.c \ 67 ../../../genarch/balloc.c \68 ../../../genarch/ofw.c \69 ../../../genarch/ofw_tree.c \70 ofwarch.c \71 69 asm.S \ 72 70 boot.S … … 75 73 $(KERNELDIR)/kernel.bin \ 76 74 $(USPACEDIR)/srv/ns/ns \ 75 $(USPACEDIR)/srv/loader/loader \ 77 76 $(USPACEDIR)/app/init/init \ 78 $(USPACEDIR)/srv/loader/loader \79 77 $(USPACEDIR)/srv/devmap/devmap \ 80 78 $(USPACEDIR)/srv/bd/rd/rd \ … … 101 99 $(USPACEDIR)/app/tester/tester \ 102 100 $(USPACEDIR)/app/trace/trace \ 103 $(USPACEDIR)/app/ bdsh/bdsh\104 $(USPACEDIR)/app/ klog/klog101 $(USPACEDIR)/app/klog/klog \ 102 $(USPACEDIR)/app/bdsh/bdsh 105 103 106 104 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) -
boot/arch/ppc32/loader/_link.ld.in
rbc7d44c r207e208e 19 19 [[COMPONENTS]] 20 20 } 21 22 /DISCARD/ : {23 *(.comment);24 *(.note*);25 }26 21 } -
boot/arch/ppc32/loader/asm.S
rbc7d44c r207e208e 29 29 #include "asm.h" 30 30 #include "regname.h" 31 #include "ofwarch.h"32 31 33 32 .macro SMC_COHERENCY addr … … 46 45 47 46 .macro TLB_FLUSH reg 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 47 tlbie \reg 48 addi \reg, \reg, 0x1000 59 49 .endm 60 50 … … 64 54 .global memcpy 65 55 .global jump_to_kernel 66 .global balloc_base67 56 68 57 halt: … … 73 62 addi r6, r3, -4 74 63 addi r4, r4, -4 75 beq 64 beq 2f 76 65 77 66 andi. r0, r6, 3 … … 80 69 81 70 1: 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 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 89 79 90 80 2: 91 cmplwi 0, r5, 4 92 blt 3f 93 94 lwzu r0, 4(r4) 95 addi r5, r5, -4 96 stwu r0, 4(r6) 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) 97 88 98 89 3: 99 cmpwi 0, r5, 0 100 beqlr 101 mtctr r5 102 addi r4, r4, 3 103 addi r6, r6, 3 90 91 cmpwi 0, r5, 0 92 beqlr 93 mtctr r5 94 addi r4, r4, 3 95 addi r6, r6, 3 104 96 105 97 4: 106 lbzu r0, 1(r4) 107 stbu r0, 1(r6) 108 bdnz 4b 109 blr 98 99 lbzu r0, 1(r4) 100 stbu r0, 1(r6) 101 bdnz 4b 102 blr 110 103 111 104 5: 112 subfic r0, r0, 4 113 mtctr r0 105 106 subfic r0, r0, 4 107 mtctr r0 114 108 115 109 6: 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 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 126 122 127 123 jump_to_kernel: … … 132 128 # r6 = bytes to copy 133 129 # r7 = real_mode (pa) 130 # r8 = framebuffer (pa) 131 # r9 = scanline 134 132 135 133 # disable interrupts … … 155 153 rfi 156 154 157 .align PAGE_WIDTH158 balloc_base:159 .fill BALLOC_MAX_SIZE160 161 155 .section REALMODE, "ax" 162 163 156 .align PAGE_WIDTH 164 157 .global real_mode 158 165 159 real_mode: 166 160 167 161 # copy kernel to proper location 168 162 # 169 # r3 = bootinfo (pa)170 # r4 = bootinfo_size171 163 # r5 = trans (pa) 172 164 # r6 = bytes to copy 165 # r8 = framebuffer (pa) 166 # r9 = scanline 173 167 174 168 li r31, PAGE_SIZE >> 2 … … 349 343 # flush TLB 350 344 351 TLB_FLUSH r31 345 li r31, 0 346 sync 347 348 TLB_FLUSH r31 349 TLB_FLUSH r31 350 TLB_FLUSH r31 351 TLB_FLUSH r31 352 TLB_FLUSH r31 353 TLB_FLUSH r31 354 TLB_FLUSH r31 355 TLB_FLUSH r31 356 357 TLB_FLUSH r31 358 TLB_FLUSH r31 359 TLB_FLUSH r31 360 TLB_FLUSH r31 361 TLB_FLUSH r31 362 TLB_FLUSH r31 363 TLB_FLUSH r31 364 TLB_FLUSH r31 365 366 TLB_FLUSH r31 367 TLB_FLUSH r31 368 TLB_FLUSH r31 369 TLB_FLUSH r31 370 TLB_FLUSH r31 371 TLB_FLUSH r31 372 TLB_FLUSH r31 373 TLB_FLUSH r31 374 375 TLB_FLUSH r31 376 TLB_FLUSH r31 377 TLB_FLUSH r31 378 TLB_FLUSH r31 379 TLB_FLUSH r31 380 TLB_FLUSH r31 381 TLB_FLUSH r31 382 TLB_FLUSH r31 383 384 TLB_FLUSH r31 385 TLB_FLUSH r31 386 TLB_FLUSH r31 387 TLB_FLUSH r31 388 TLB_FLUSH r31 389 TLB_FLUSH r31 390 TLB_FLUSH r31 391 TLB_FLUSH r31 392 393 TLB_FLUSH r31 394 TLB_FLUSH r31 395 TLB_FLUSH r31 396 TLB_FLUSH r31 397 TLB_FLUSH r31 398 TLB_FLUSH r31 399 TLB_FLUSH r31 400 TLB_FLUSH r31 401 402 TLB_FLUSH r31 403 TLB_FLUSH r31 404 TLB_FLUSH r31 405 TLB_FLUSH r31 406 TLB_FLUSH r31 407 TLB_FLUSH r31 408 TLB_FLUSH r31 409 TLB_FLUSH r31 410 411 TLB_FLUSH r31 412 TLB_FLUSH r31 413 TLB_FLUSH r31 414 TLB_FLUSH r31 415 TLB_FLUSH r31 416 TLB_FLUSH r31 417 TLB_FLUSH r31 418 TLB_FLUSH r31 419 420 eieio 421 tlbsync 422 sync 352 423 353 424 # start the kernel 354 425 # 355 # pc = PA2KA(BOOT_OFFSET)426 # pc = KERNEL_START_ADDR 356 427 # r3 = bootinfo (pa) 357 # sprg0 = BOOT_OFFSET428 # sprg0 = KA2PA(KERNEL_START_ADDR) 358 429 # sprg3 = physical memory size 359 430 # sp = 0 (pa) 360 431 361 lis r31, PA2KA(BOOT_OFFSET)@ha 362 addi r31, r31, PA2KA(BOOT_OFFSET)@l 432 lis r31, KERNEL_START_ADDR@ha 433 addi r31, r31, KERNEL_START_ADDR@l 434 363 435 mtspr srr0, r31 364 436 365 lis r31, BOOT_OFFSET@ha 366 addi r31, r31, BOOT_OFFSET@l 437 subis r31, r31, 0x8000 367 438 mtsprg0 r31 368 439 … … 383 454 .global trans 384 455 trans: 385 .rept TRANS_SIZE 386 .int 0 387 .endr 456 .space (TRANS_SIZE * TRANS_ITEM_SIZE) -
boot/arch/ppc32/loader/asm.h
rbc7d44c r207e208e 30 30 #define BOOT_ppc32_ASM_H_ 31 31 32 #define PAGE_ WIDTH 1233 #define PAGE_ SIZE (1 << PAGE_WIDTH)32 #define PAGE_SIZE 4096 33 #define PAGE_WIDTH 12 34 34 35 #define TRANS_SIZE 36 #define BOOT_OFFSET 0x800035 #define TRANS_SIZE 1024 36 #define TRANS_ITEM_SIZE 4 37 37 38 #define BALLOC_MAX_SIZE (128 * 1024)38 #define KERNEL_START_ADDR 0x80008000 39 39 40 40 #ifndef __ASM__ 41 41 42 #include "types.h" 43 #include "main.h" 44 #include "ofwarch.h" 42 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 45 43 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]; 44 extern void *trans[TRANS_SIZE]; 50 45 51 46 extern void halt(); 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)); 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)); 54 48 extern void real_mode(); 55 56 #else57 58 #define PA2KA(x) ((x) + 0x80000000)59 49 60 50 #endif -
boot/arch/ppc32/loader/main.c
rbc7d44c r207e208e 27 27 */ 28 28 29 #include "main.h" 29 30 #include <printf.h> 31 #include "asm.h" 32 #include "_components.h" 30 33 #include <ofw.h> 31 34 #include <align.h> 32 35 #include <macros.h> 33 36 #include <string.h> 34 #include "main.h"35 #include "asm.h"36 #include "_components.h"37 37 38 static bootinfo_t bootinfo; 39 static component_t components[COMPONENTS]; 40 static char *release = STRING(RELEASE); 38 #define HEAP_GAP 1024000 39 40 bootinfo_t bootinfo; 41 42 43 static void check_align(const void *addr, const char *desc) 44 { 45 if ((unsigned int) addr % PAGE_SIZE != 0) { 46 printf("Error: %s not on page boundary, halting.\n", desc); 47 halt(); 48 } 49 } 50 51 52 static void fix_overlap(void *va, void **pa, const char *desc, unsigned int *top) 53 { 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); 74 } 75 } 76 77 char *release = STRING(RELEASE); 41 78 42 79 #ifdef REVISION 43 staticchar *revision = ", revision " STRING(REVISION);80 char *revision = ", revision " STRING(REVISION); 44 81 #else 45 staticchar *revision = "";82 char *revision = ""; 46 83 #endif 47 84 48 85 #ifdef TIMESTAMP 49 staticchar *timestamp = "\nBuilt on " STRING(TIMESTAMP);86 char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 50 87 #else 51 staticchar *timestamp = "";88 char *timestamp = ""; 52 89 #endif 53 90 … … 55 92 static void version_print(void) 56 93 { 57 printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\n" 58 "Copyright (c) 2006 HelenOS project\n\n", 59 release, revision, timestamp); 60 } 61 62 static void check_align(const void *addr, const char *desc) 63 { 64 if ((uintptr_t) addr % PAGE_SIZE != 0) { 65 printf("Error: %s not on page boundary, halting.\n", desc); 66 halt(); 67 } 68 } 69 70 static void check_overlap(const void *pa, const char *desc, const uintptr_t top) 71 { 72 if ((uintptr_t) pa + PAGE_SIZE < top) { 73 printf("Error: %s overlaps destination physical area\n", desc); 74 halt(); 75 } 94 printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n\n", release, revision, timestamp); 76 95 } 77 96 … … 79 98 { 80 99 version_print(); 100 101 component_t components[COMPONENTS]; 81 102 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"); 82 110 83 111 if (!ofw_memmap(&bootinfo.memmap)) { … … 91 119 } 92 120 93 check_align(&real_mode, "bootstrap trampoline"); 94 check_align(trans, "translation table"); 95 check_align(balloc_base, "boot allocations"); 121 if (!ofw_screen(&bootinfo.screen)) 122 printf("Warning: Unable to get screen properties.\n"); 96 123 97 unsigned int i; 98 for (i = 0; i < COMPONENTS; i++) 99 check_align(components[i].start, components[i].name); 124 if (!ofw_macio(&bootinfo.macio)) 125 printf("Warning: Unable to get macio properties.\n"); 100 126 127 printf("Device statistics\n"); 128 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); 101 137 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);105 138 106 printf(" Memory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);139 printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20); 107 140 printf(" %L: boot info structure (physical %L)\n", &bootinfo, bootinfo_pa); 108 141 printf(" %L: bootstrap trampoline (physical %L)\n", &real_mode, real_mode_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); 142 printf(" %L: translation table (physical %L)\n", &trans, trans_pa); 111 143 for (i = 0; i < COMPONENTS; i++) 112 144 printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size); 113 145 114 u intptr_t top = 0;146 unsigned int top = 0; 115 147 for (i = 0; i < COMPONENTS; i++) 116 148 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);127 149 128 150 unsigned int pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH; … … 130 152 for (i = 0; i < pages; i++) { 131 153 void *pa = ofw_translate(KERNEL_START + (i << PAGE_WIDTH)); 132 check_overlap(pa, "kernel",top);133 trans[i] = (uintptr_t)pa;154 fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "kernel", &top); 155 trans[i] = pa; 134 156 } 135 157 136 158 bootinfo.taskmap.count = 0; 137 159 for (i = 1; i < COMPONENTS; i++) { 138 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {139 printf("\nSkipping superfluous components.\n");140 break;141 }142 143 160 unsigned int component_pages = ALIGN_UP(components[i].size, PAGE_SIZE) >> PAGE_WIDTH; 144 161 unsigned int j; … … 146 163 for (j = 0; j < component_pages; j++) { 147 164 void *pa = ofw_translate(components[i].start + (j << PAGE_WIDTH)); 148 check_overlap(pa, components[i].name,top);149 trans[pages + j] = (uintptr_t)pa;165 fix_overlap(components[i].start + (j << PAGE_WIDTH), &pa, components[i].name, &top); 166 trans[pages + j] = pa; 150 167 if (j == 0) { 151 152 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) PA2KA(pages << PAGE_WIDTH); 168 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH); 153 169 bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size; 154 170 strncpy(bootinfo.taskmap.tasks[bootinfo.taskmap.count].name, 155 171 components[i].name, BOOTINFO_TASK_NAME_BUFLEN); 156 172 157 173 bootinfo.taskmap.count++; 158 174 } … … 162 178 } 163 179 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"); 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); 178 183 179 184 ofw_setup_palette(); 180 185 181 186 printf("\nBooting the kernel...\n"); 182 jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa );187 jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, (void *) bootinfo.screen.addr, bootinfo.screen.scanline); 183 188 } -
boot/arch/ppc32/loader/main.h
rbc7d44c r207e208e 30 30 #define BOOT_ppc32_MAIN_H_ 31 31 32 #include <ofw.h> 33 #include <ofw_tree.h> 34 #include <balloc.h> 35 #include <types.h> 32 #include "ofw.h" 36 33 37 #define TASKMAP_MAX_RECORDS 34 #define TASKMAP_MAX_RECORDS 32 38 35 39 36 /** Size of buffer for storing task name in task_t. */ 40 #define BOOTINFO_TASK_NAME_BUFLEN 37 #define BOOTINFO_TASK_NAME_BUFLEN 32 41 38 39 /** Struct holding information about single loaded task. */ 42 40 typedef struct { 41 /** Address where the task was placed. */ 43 42 void *addr; 44 uint32_t size; 43 /** Size of the task's binary. */ 44 unsigned int size; 45 /** Task name. */ 45 46 char name[BOOTINFO_TASK_NAME_BUFLEN]; 46 47 } task_t; 47 48 48 49 typedef struct { 49 u int32_t count;50 unsigned int count; 50 51 task_t tasks[TASKMAP_MAX_RECORDS]; 51 52 } taskmap_t; … … 54 55 memmap_t memmap; 55 56 taskmap_t taskmap; 56 ballocs_t ballocs;57 ofw_tree_node_t *ofw_root;57 screen_t screen; 58 macio_t macio; 58 59 } bootinfo_t; 59 60 … … 61 62 extern void bootstrap(void); 62 63 64 extern memmap_t memmap; 65 63 66 #endif -
boot/arch/ppc32/loader/ofwarch.c
rbc7d44c r207e208e 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 51 73 int ofw_translate_failed(ofw_arg_t flag) 52 74 { 53 /* PearPC returns buggy flag */54 75 return 0; 55 76 } -
boot/arch/ppc32/loader/ofwarch.h
rbc7d44c r207e208e 30 30 #define BOOT_ppc32_OFWARCH_H_ 31 31 32 #define OFW_ADDRESS_CELLS 33 #define OFW_SIZE_CELLS 32 #define OFW_ADDRESS_CELLS 1 33 #define OFW_SIZE_CELLS 1 34 34 35 35 #endif -
boot/arch/ppc32/loader/regname.h
rbc7d44c r207e208e 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 tlbmiss 980 209 #define ptehi 981 210 #define ptelo 982 211 #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 hid0 1008 212 209 213 210 /* MSR bits */ 214 #define msr_dr 215 #define msr_ir 216 #define msr_pr 217 #define msr_ee 211 #define msr_dr (1 << 4) 212 #define msr_ir (1 << 5) 213 #define msr_pr (1 << 14) 214 #define msr_ee (1 << 15) 218 215 219 216 /* HID0 bits */ 220 #define hid0_sten 221 #define hid0_ice 222 #define hid0_dce 223 #define hid0_icfi 224 #define hid0_dci 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) 225 222 226 223 #endif -
boot/arch/sparc64/loader/asm.S
rbc7d44c r207e208e 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 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 45 98 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 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 99 jmp %o7 + 8 ! exit point 100 mov %o3, %o0 108 101 109 102 jump_to_kernel: … … 114 107 * 3. Flush instruction pipeline. 115 108 */ 116 109 117 110 /* 118 111 * US3 processors have a write-invalidate cache, so explicitly 119 112 * invalidating it is not required. Whether to invalidate I-cache 120 * or not is decided according to the value of the 5th argument121 * (subarchitecture).113 * or not is decided according to the value of the global 114 * "subarchitecture" variable (set in the bootstrap). 122 115 */ 123 cmp %i4, 3 116 set subarchitecture, %g2 117 ldub [%g2], %g2 118 cmp %g2, 3 124 119 be %xcc, 1f 125 120 nop 126 127 0: 128 call icache_flush 129 nop 130 131 1: 132 membar #StoreStore 121 0: 122 call icache_flush 123 nop 124 1: 125 membar #StoreStore 133 126 134 127 /* 135 128 * Flush the instruction pipeline. 136 129 */ 137 flush 138 130 flush %i7 131 139 132 mov %o0, %l1 140 133 mov %o1, %o0 141 134 mov %o2, %o1 142 135 mov %o3, %o2 143 jmp %l1 136 jmp %l1 ! jump to kernel 144 137 nop 145 138 146 #define ICACHE_SIZE 147 #define ICACHE_LINE_SIZE 148 #define ICACHE_SET_BIT 149 #define ASI_ICACHE_TAG 139 #define ICACHE_SIZE 8192 140 #define ICACHE_LINE_SIZE 32 141 #define ICACHE_SET_BIT (1 << 13) 142 #define ASI_ICACHE_TAG 0x67 150 143 151 144 # Flush I-cache 152 145 icache_flush: 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 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 163 153 retl 164 154 ! SF Erratum #51 165 155 nop 166 167 156 .global ofw 168 157 ofw: … … 170 159 set ofw_cif, %l0 171 160 ldx [%l0], %l0 172 161 173 162 rdpr %pstate, %l1 174 163 and %l1, ~PSTATE_AM_BIT, %l2 175 164 wrpr %l2, 0, %pstate 176 165 177 166 jmpl %l0, %o7 178 167 mov %i0, %o0 179 168 180 169 wrpr %l1, 0, %pstate 181 170 182 171 ret 183 172 restore %o0, 0, %o0 -
boot/arch/sparc64/loader/asm.h
rbc7d44c r207e208e 34 34 #include "main.h" 35 35 36 #define PAGE_WIDTH 37 #define PAGE_SIZE 36 #define PAGE_WIDTH 14 37 #define PAGE_SIZE (1 << PAGE_WIDTH) 38 38 39 #define BALLOC_MAX_SIZE (128 * 1024)39 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 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, uint8_t subarchitecture) __attribute__((noreturn));43 unsigned int bootinfo_size) __attribute__((noreturn)); 44 44 45 45 #endif -
boot/arch/sparc64/loader/boot.S
rbc7d44c r207e208e 31 31 #include <register.h> 32 32 33 #define INITIAL_STACK_SIZE 33 #define INITIAL_STACK_SIZE 8192 34 34 35 #define NWINDOWS 35 #define NWINDOWS 8 36 36 37 37 .register %g2, #scratch … … 57 57 .half 0 58 58 .half 0 59 60 59 .global silo_ramdisk_image 61 60 silo_ramdisk_image: 62 61 .word 0 63 64 62 .global silo_ramdisk_size 65 63 silo_ramdisk_size: … … 67 65 68 66 .align 8 69 1: 67 1: 70 68 /* 71 69 * Disable interrupts and disable address masking. … … 73 71 wrpr %g0, PSTATE_PRIV_BIT, %pstate 74 72 75 wrpr %g0, NWINDOWS - 2, %cansave 76 wrpr %g0, 0, %canrestore 77 wrpr %g0, 0, %otherwin 78 wrpr %g0, NWINDOWS - 1, %cleanwin 79 73 wrpr %g0, NWINDOWS - 2, %cansave ! set maximum saveable windows 74 wrpr %g0, 0, %canrestore ! get rid of windows we will never need again 75 wrpr %g0, 0, %otherwin ! make sure the window state is consistent 76 wrpr %g0, NWINDOWS - 1, %cleanwin ! prevent needless clean_window traps for kernel 77 80 78 set initial_stack_top, %sp 81 79 add %sp, -STACK_BIAS, %sp 82 80 83 81 set ofw_cif, %l0 84 85 call ofw_init 82 83 call ofw_init ! initialize OpenFirmware 86 84 stx %o4, [%l0] 87 85 … … 92 90 initial_stack: 93 91 .space INITIAL_STACK_SIZE 94 95 92 initial_stack_top: 96 93 .space STACK_WINDOW_SAVE_AREA_SIZE -
boot/arch/sparc64/loader/main.c
rbc7d44c r207e208e 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 #include <memstr.h> 42 43 static bootinfo_t bootinfo; 44 static component_t components[COMPONENTS]; 45 static char *release = STRING(RELEASE); 41 42 bootinfo_t bootinfo; 43 44 component_t components[COMPONENTS]; 45 46 char *release = STRING(RELEASE); 46 47 47 48 #ifdef REVISION 48 staticchar *revision = ", revision " STRING(REVISION);49 char *revision = ", revision " STRING(REVISION); 49 50 #else 50 staticchar *revision = "";51 char *revision = ""; 51 52 #endif 52 53 53 54 #ifdef TIMESTAMP 54 staticchar *timestamp = "\nBuilt on " STRING(TIMESTAMP);55 char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 55 56 #else 56 staticchar *timestamp = "";57 char *timestamp = ""; 57 58 #endif 58 59 59 60 /** UltraSPARC subarchitecture - 1 for US, 3 for US3 */ 60 staticuint8_t subarchitecture;61 uint8_t subarchitecture; 61 62 62 63 /** … … 64 65 * MID_SHIFT bits to the right 65 66 */ 66 staticuint16_t mid_mask;67 uint16_t mid_mask; 67 68 68 69 /** Print version information. */ … … 75 76 76 77 /* the lowest ID (read from the VER register) of some US3 CPU model */ 77 #define FIRST_US3_CPU 78 #define FIRST_US3_CPU 0x14 78 79 79 80 /* the greatest ID (read from the VER register) of some US3 CPU model */ 80 #define LAST_US3_CPU 81 #define LAST_US3_CPU 0x19 81 82 82 83 /* UltraSPARC IIIi processor implementation code */ 83 #define US_IIIi_CODE 84 #define US_IIIi_CODE 0x15 84 85 85 86 /** … … 90 91 { 91 92 uint64_t v; 92 asm volatile ( 93 "rdpr %%ver, %0\n" 94 : "=r" (v) 95 ); 93 asm volatile ("rdpr %%ver, %0\n" : "=r" (v)); 96 94 97 95 v = (v << 16) >> 48; … … 105 103 subarchitecture = SUBARCH_US; 106 104 mid_mask = (1 << 5) - 1; 107 } else 105 } else { 108 106 printf("\nThis CPU is not supported by HelenOS."); 107 } 109 108 } 110 109 … … 114 113 void *balloc_base; 115 114 unsigned int top = 0; 116 unsigned int i; 117 unsigned int j; 118 115 int i, j; 116 119 117 version_print(); 120 118 121 119 detect_subarchitecture(); 122 120 init_components(components); 123 121 124 122 if (!ofw_get_physmem_start(&bootinfo.physmem_start)) { 125 123 printf("Error: unable to get start of physical memory.\n"); 126 124 halt(); 127 125 } 128 126 129 127 if (!ofw_memmap(&bootinfo.memmap)) { 130 128 printf("Error: unable to get memory map, halting.\n"); 131 129 halt(); 132 130 } 133 131 134 132 if (bootinfo.memmap.total == 0) { 135 133 printf("Error: no memory detected, halting.\n"); 136 134 halt(); 137 135 } 138 136 139 137 /* 140 138 * SILO for some reason adds 0x400000 and subtracts … … 145 143 silo_ramdisk_image += bootinfo.physmem_start; 146 144 silo_ramdisk_image -= 0x400000; 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), 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), 151 148 silo_ramdisk_size, -1) != 0) { 152 printf("Failed to map RAMdisk.\n");149 printf("Failed to map ramdisk.\n"); 153 150 halt(); 154 151 } 155 152 } 156 153 157 printf("\nMemory statistics (total %d MB, starting at %P)\n", 154 printf("\nSystem info\n"); 155 printf(" memory: %dM starting at %P\n", 158 156 bootinfo.memmap.total >> 20, bootinfo.physmem_start); 159 printf(" %P: kernel entry point\n", KERNEL_VIRTUAL_ADDRESS); 157 158 printf("\nMemory statistics\n"); 159 printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS); 160 160 printf(" %P: boot info structure\n", &bootinfo); 161 161 … … 176 176 break; 177 177 } 178 179 178 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = 180 179 base + top; … … 188 187 top += components[i].size; 189 188 } 190 191 /* Do not consider RAM disk */ 192 j = bootinfo.taskmap.count - 1; 193 189 190 j = bootinfo.taskmap.count - 1; /* do not consider ramdisk */ 191 194 192 if (silo_ramdisk_image) { 195 /* Treat the RAMdisk as the last bootinfo task. */193 /* Treat the ramdisk as the last bootinfo task. */ 196 194 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) { 197 printf("Skipping RAMdisk.\n");195 printf("Skipping ramdisk.\n"); 198 196 goto skip_ramdisk; 199 197 } 200 201 198 top = ALIGN_UP(top, PAGE_SIZE); 202 199 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = … … 205 202 silo_ramdisk_size; 206 203 bootinfo.taskmap.count++; 207 printf("\nCopying RAM disk..."); 208 204 printf("\nCopying ramdisk..."); 209 205 /* 210 206 * Claim and map the whole ramdisk as it may exceed the area … … 214 210 (void) ofw_map(bootinfo.physmem_start + base + top, base + top, 215 211 silo_ramdisk_size, -1); 216 memmove(base + top, (void *) ((uintptr_t)silo_ramdisk_image),212 memmove(base + top, (void *)((uintptr_t)silo_ramdisk_image), 217 213 silo_ramdisk_size); 218 219 214 printf("done.\n"); 220 215 top += silo_ramdisk_size; 221 216 } 222 217 skip_ramdisk: 223 218 224 219 /* 225 220 * Now we can proceed to copy the components. We do it in reverse order … … 227 222 * with base. 228 223 */ 229 printf("\nCopying tasks...");224 printf("\nCopying bootinfo tasks\n"); 230 225 for (i = COMPONENTS - 1; i > 0; i--, j--) { 231 printf(" %s", components[i].name);232 226 printf(" %s...", components[i].name); 227 233 228 /* 234 229 * At this point, we claim the physical memory that we are … … 245 240 bootinfo.taskmap.tasks[j].addr, 246 241 ALIGN_UP(components[i].size, PAGE_SIZE)); 247 248 memcpy((void *) 242 243 memcpy((void *)bootinfo.taskmap.tasks[j].addr, 249 244 components[i].start, components[i].size); 250 251 } 252 printf(".\n"); 253 245 printf("done.\n"); 246 } 247 254 248 printf("\nCopying kernel..."); 255 249 (void) ofw_claim_phys(bootinfo.physmem_start + base, … … 257 251 memcpy(base, components[0].start, components[0].size); 258 252 printf("done.\n"); 259 253 260 254 /* 261 255 * Claim and map the physical memory for the boot allocator. … … 267 261 (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base, 268 262 BALLOC_MAX_SIZE, -1); 269 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, 270 (uintptr_t) balloc_base); 271 263 balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base); 264 272 265 printf("\nCanonizing OpenFirmware device tree..."); 273 266 bootinfo.ofw_root = ofw_tree_build(); 274 267 printf("done.\n"); 275 268 276 269 #ifdef CONFIG_AP 277 270 printf("\nChecking for secondary processors..."); 278 if (!ofw_cpu( mid_mask, bootinfo.physmem_start))271 if (!ofw_cpu()) 279 272 printf("Error: unable to get CPU properties\n"); 280 273 printf("done.\n"); 281 274 #endif 282 275 283 276 ofw_setup_palette(); 284 277 285 278 printf("\nBooting the kernel...\n"); 286 279 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 287 280 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 288 sizeof(bootinfo) , subarchitecture);281 sizeof(bootinfo)); 289 282 } -
boot/arch/sparc64/loader/main.h
rbc7d44c r207e208e 35 35 #include <types.h> 36 36 37 #define KERNEL_VIRTUAL_ADDRESS 37 #define KERNEL_VIRTUAL_ADDRESS 0x400000 38 38 39 #define TASKMAP_MAX_RECORDS 39 #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 42 #define BOOTINFO_TASK_NAME_BUFLEN 32 43 43 44 #define BSP_PROCESSOR 45 #define AP_PROCESSOR 44 #define BSP_PROCESSOR 1 45 #define AP_PROCESSOR 0 46 46 47 #define SUBARCH_US 48 #define SUBARCH_US3 47 #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 72 74 extern void start(void); 73 75 extern void bootstrap(void); -
boot/arch/sparc64/loader/ofwarch.c
rbc7d44c r207e208e 30 30 /** 31 31 * @file 32 * @brief 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; 42 46 43 47 void write(const char *str, const int len) … … 61 65 * except for the current CPU. 62 66 * 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 * 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". 72 73 */ 73 static int wake_cpus_in_node(phandle child, uint64_t current_mid, 74 uintptr_t physmem_start) 74 static int wake_cpus_in_node(phandle child, uint64_t current_mid) 75 75 { 76 76 int cpus; 77 char type_name[BUF_SIZE]; 77 78 78 for (cpus = 0; (child != 0) && (child != -1);79 for (cpus = 0; child != 0 && child != -1; 79 80 child = ofw_get_peer_node(child), cpus++) { 80 char type_name[BUF_SIZE];81 82 81 if (ofw_get_property(child, "device_type", type_name, 83 82 sizeof(type_name)) > 0) { … … 89 88 * "cpuid" for US-IV 90 89 */ 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)) 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) 94 97 continue; 95 98 96 99 if (current_mid != mid) { 97 100 /* … … 100 103 (void) ofw_call("SUNW,start-cpu", 3, 1, 101 104 NULL, child, KERNEL_VIRTUAL_ADDRESS, 102 physmem_start | AP_PROCESSOR); 105 bootinfo.physmem_start | 106 AP_PROCESSOR); 103 107 } 104 108 } 105 109 } 106 110 } 107 111 108 112 return cpus; 109 113 } … … 112 116 * Finds out the current CPU's MID and wakes up all AP processors. 113 117 */ 114 int ofw_cpu( uint16_t mid_mask, uintptr_t physmem_start)118 int ofw_cpu(void) 115 119 { 116 /* Get the current CPU MID */ 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 */ 117 128 uint64_t current_mid; 118 129 119 asm volatile ( 120 "ldxa [%1] %2, %0\n" 121 : "=r" (current_mid) 122 : "r" (0), "i" (ASI_ICBUS_CONFIG) 123 ); 130 asm volatile ("ldxa [%1] %2, %0\n" 131 : "=r" (current_mid) 132 : "r" (0), "i" (ASI_ICBUS_CONFIG)); 133 current_mid >>= ICBUS_CONFIG_MID_SHIFT; 134 135 current_mid &= mid_mask; 136 137 /* wake up CPUs */ 124 138 125 current_mid >>= ICBUS_CONFIG_MID_SHIFT; 126 current_mid &= mid_mask; 127 128 /* Wake up the CPUs */ 129 130 phandle cpus_parent = ofw_find_device("/ssm@0,0"); 131 if ((cpus_parent == 0) || (cpus_parent == -1)) 139 cpus_parent = ofw_find_device("/ssm@0,0"); 140 if (cpus_parent == 0 || cpus_parent == -1) { 132 141 cpus_parent = ofw_find_device("/"); 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 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) { 139 147 if (ofw_get_property(node, "name", name, 140 148 sizeof(name)) > 0) { 141 149 if (strcmp(name, "cmp") == 0) { 142 phandlesubnode = ofw_get_child_node(node);150 subnode = ofw_get_child_node(node); 143 151 cpus += wake_cpus_in_node(subnode, 144 current_mid , physmem_start);152 current_mid); 145 153 } 146 154 } … … 149 157 150 158 return cpus; 159 151 160 } 152 161 153 162 /** Get physical memory starting address. 154 163 * 155 * @param start 156 * 164 * @param start Pointer to variable where the physical memory starting 165 * address will be stored. 157 166 * 158 * @return Non-zero on succes, zero on failure. 159 * 167 * @return Non-zero on succes, zero on failure. 160 168 */ 161 169 int ofw_get_physmem_start(uintptr_t *start) 162 170 { 163 171 uint32_t memreg[4]; 172 164 173 if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0) 165 174 return 0; 166 175 167 176 *start = (((uint64_t) memreg[0]) << 32) | memreg[1]; 168 177 return 1; 169 178 } 179 -
boot/arch/sparc64/loader/ofwarch.h
rbc7d44c r207e208e 33 33 #include "types.h" 34 34 35 #define OFW_ADDRESS_CELLS 36 #define OFW_SIZE_CELLS 35 #define OFW_ADDRESS_CELLS 2 36 #define OFW_SIZE_CELLS 2 37 37 38 extern int ofw_cpu( uint16_t mid_mask, uintptr_t physmem_start);39 extern int ofw_get_physmem_start(uintptr_t *start); 38 extern int ofw_cpu(void); 39 extern int ofw_get_physmem_start(uintptr_t *start); 40 40 41 41 #endif -
boot/arch/sparc64/loader/register.h
rbc7d44c r207e208e 30 30 #define BOOT_sparc64_REGISTER_H_ 31 31 32 #define PSTATE_IE_BIT 33 #define PSTATE_PRIV_BIT 34 #define PSTATE_AM_BIT 32 #define PSTATE_IE_BIT 2 33 #define PSTATE_PRIV_BIT 4 34 #define PSTATE_AM_BIT 8 35 35 36 #define ASI_ICBUS_CONFIG 37 #define ICBUS_CONFIG_MID_SHIFT 36 #define ASI_ICBUS_CONFIG 0x4a 37 #define ICBUS_CONFIG_MID_SHIFT 17 38 38 39 39 #endif -
boot/arch/sparc64/loader/stack.h
rbc7d44c r207e208e 30 30 #define BOOT_sparc64_STACK_H_ 31 31 32 #define STACK_ALIGNMENT 33 #define STACK_BIAS 34 #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 -
boot/genarch/balloc.c
rbc7d44c r207e208e 28 28 29 29 #include <balloc.h> 30 #include <asm.h>31 30 #include <types.h> 32 31 #include <align.h> 33 32 34 33 static ballocs_t *ballocs; 35 static uintptr_t phys_base;36 34 37 void balloc_init(ballocs_t *b all, uintptr_t base, uintptr_t kernel_base)35 void balloc_init(ballocs_t *b, uintptr_t base) 38 36 { 39 ballocs = ball; 40 phys_base = base; 41 ballocs->base = kernel_base; 37 ballocs = b; 38 ballocs->base = base; 42 39 ballocs->size = 0; 43 40 } … … 45 42 void *balloc(size_t size, size_t alignment) 46 43 { 44 uintptr_t addr; 45 47 46 /* Enforce minimal alignment. */ 48 47 alignment = ALIGN_UP(alignment, 4); 49 48 50 uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment);51 49 addr = ballocs->base + ALIGN_UP(ballocs->size, alignment); 50 52 51 if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE) 53 52 return NULL; 54 53 55 54 ballocs->size = ALIGN_UP(ballocs->size, alignment) + size; 56 55 57 56 return (void *) addr; 58 57 } 59 60 void *balloc_rebase(void *ptr)61 {62 return (void *) ((uintptr_t) ptr - phys_base + ballocs->base);63 } -
boot/genarch/balloc.h
rbc7d44c r207e208e 32 32 #include <types.h> 33 33 34 #define BALLOC_MAX_SIZE (128 * 1024) 35 34 36 typedef struct { 35 37 uintptr_t base; … … 37 39 } ballocs_t; 38 40 39 extern void balloc_init(ballocs_t *b all, uintptr_t base, uintptr_t kernel_base);41 extern void balloc_init(ballocs_t *b, uintptr_t base); 40 42 extern void *balloc(size_t size, size_t alignment); 41 extern void *balloc_rebase(void *ptr);42 43 43 44 #endif -
boot/genarch/ofw.c
rbc7d44c r207e208e 33 33 #include <types.h> 34 34 35 #define RED(i) (((i) >> 5) & ((1 << 3) - 1))36 #define GREEN(i) (((i) >> 3) & ((1 << 2) - 1))37 #define BLUE(i) ((i) & ((1 << 3) - 1))38 #define CLIP(i) ((i) <= 255 ? (i) : 255)39 40 35 uintptr_t ofw_cif; 41 36 … … 90 85 /** Perform a call to OpenFirmware client interface. 91 86 * 92 * @param service String identifying the service requested. 93 * @param nargs Number of input arguments. 94 * @param nret Number of output arguments. This includes the return 95 * value. 96 * @param rets Buffer for output arguments or NULL. The buffer must 97 * accommodate nret - 1 items. 98 * 99 * @return Return value returned by the client interface. 100 * 87 * @param service String identifying the service requested. 88 * @param nargs Number of input arguments. 89 * @param nret Number of output arguments. This includes the return 90 * value. 91 * @param rets Buffer for output arguments or NULL. The buffer must 92 * accommodate nret - 1 items. 93 * 94 * @return Return value returned by the client interface. 101 95 */ 102 96 unsigned long … … 227 221 } 228 222 229 void *ofw_claim_virt(const void *virt, const unsignedint len)223 void *ofw_claim_virt(const void *virt, const int len) 230 224 { 231 225 ofw_arg_t retaddr; … … 240 234 } 241 235 242 static void *ofw_claim_phys_internal(const void *phys, const unsigned int len, const unsigned int alignment) 243 { 244 /* 245 * Note that the return value check will help 246 * us to discover conflicts between OpenFirmware 247 * allocations and our use of physical memory. 248 * It is better to detect collisions here 249 * than to cope with weird errors later. 250 * 251 * So this is really not to make the loader 252 * more generic; it is here for debugging 253 * purposes. 254 */ 255 236 void *ofw_claim_phys(const void *phys, const int len) 237 { 238 ofw_arg_t retaddr[2]; 239 int shift; 240 256 241 if (sizeof(unative_t) == 8) { 257 ofw_arg_t retaddr[2]; 258 int shift = 32; 259 242 shift = 32; 260 243 if (ofw_call("call-method", 6, 3, retaddr, "claim", 261 ofw_memory_prop, alignment, len, ((uintptr_t) phys) >> shift,244 ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift, 262 245 ((uintptr_t) phys) & ((uint32_t) -1)) != 0) { 246 /* 247 * Note that this will help us to discover 248 * conflicts between OpenFirmware allocations 249 * and our use of physical memory. 250 * It is better to detect collisions here 251 * than to cope with weird errors later. 252 * 253 * So this is really not to make the loader 254 * more generic; it is here for debugging 255 * purposes. 256 */ 263 257 puts("Error: memory method claim() failed, halting.\n"); 264 258 halt(); 265 259 } 266 267 return (void *) ((retaddr[0] << shift) | retaddr[1]);268 260 } else { 269 ofw_arg_t retaddr[1]; 270 271 if (ofw_call("call-method", 5, 2, retaddr, "claim", 272 ofw_memory_prop, alignment, len, (uintptr_t) phys) != 0) { 273 puts("Error: memory method claim() failed, halting.\n"); 274 halt(); 275 } 276 277 return (void *) retaddr[0]; 278 } 279 } 280 281 void *ofw_claim_phys(const void *phys, const unsigned int len) 282 { 283 return ofw_claim_phys_internal(phys, len, 0); 284 } 285 286 void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment) 287 { 288 return ofw_claim_phys_internal(NULL, len, alignment); 289 } 290 291 int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode) 261 shift = 0; 262 /* 263 * FIXME: the number of arguments is probably different... 264 */ 265 puts("Error: 32-bit ofw_claim_phys not implemented.\n"); 266 halt(); 267 } 268 269 return (void *) ((retaddr[0] << shift) | retaddr[1]); 270 } 271 272 int ofw_map(const void *phys, const void *virt, const int size, const int mode) 292 273 { 293 274 uintptr_t phys_hi, phys_lo; … … 333 314 334 315 /* 335 * This is a hot fix of the issue which occurs on machines336 * where there are holes in the physical memory (such as337 * SunBlade 1500). Should we detect a hole in the physical338 * memory, we will ignore any memory detected behind339 * the hole and pretend the hole does not exist.316 * This is a hot fix of the issue which occurs on machines 317 * where there are holes in the physical memory (such as 318 * SunBlade 1500). Should we detect a hole in the physical 319 * memory, we will ignore any memory detected behind 320 * the hole and pretend the hole does not exist. 340 321 */ 341 322 if ((map->count > 0) && (map->zones[map->count - 1].start + … … 354 335 } 355 336 337 int ofw_screen(screen_t *screen) 338 { 339 char device_name[BUF_SIZE]; 340 uint32_t virtaddr; 341 342 if (ofw_get_property(ofw_aliases, "screen", device_name, 343 sizeof(device_name)) <= 0) 344 return false; 345 346 phandle device = ofw_find_device(device_name); 347 if (device == -1) 348 return false; 349 350 if (ofw_get_property(device, "address", &virtaddr, 351 sizeof(virtaddr)) <= 0) 352 return false; 353 354 screen->addr = (void *) ((uintptr_t) virtaddr); 355 356 if (ofw_get_property(device, "width", &screen->width, 357 sizeof(screen->width)) <= 0) 358 return false; 359 360 if (ofw_get_property(device, "height", &screen->height, 361 sizeof(screen->height)) <= 0) 362 return false; 363 364 if (ofw_get_property(device, "depth", &screen->bpp, 365 sizeof(screen->bpp)) <= 0) 366 return false; 367 368 if (ofw_get_property(device, "linebytes", &screen->scanline, 369 sizeof(screen->scanline)) <= 0) 370 return false; 371 372 return true; 373 } 374 375 #define RED(i) (((i) >> 5) & ((1 << 3) - 1)) 376 #define GREEN(i) (((i) >> 3) & ((1 << 2) - 1)) 377 #define BLUE(i) ((i) & ((1 << 3) - 1)) 378 #define CLIP(i) ((i) <= 255 ? (i) : 255) 379 380 356 381 /** 357 382 * Sets up the palette for the 8-bit color depth configuration so that the … … 367 392 char device_name[BUF_SIZE]; 368 393 369 /* Resolve alias */394 /* resolve alias */ 370 395 if (ofw_get_property(ofw_aliases, "screen", device_name, 371 396 sizeof(device_name)) <= 0) 372 397 return false; 373 398 374 /* For depth greater than 8 it makes no sense to set up the palette */399 /* for depth greater than 8 it makes no sense to set up the palette */ 375 400 uint32_t depth; 376 401 phandle device = ofw_find_device(device_name); … … 382 407 return false; 383 408 384 /* Required in order to be able to make a method call */409 /* required in order to be able to make a method call */ 385 410 ihandle screen = ofw_open(device_name); 386 411 if (screen == -1) 387 412 return false; 388 413 389 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */414 /* setup the palette so that the (inverted) 3:2:3 scheme is usable */ 390 415 unsigned int i; 391 416 for (i = 0; i < 256; i++) -
boot/genarch/ofw.h
rbc7d44c r207e208e 33 33 #include <stdarg.h> 34 34 35 #define BUF_SIZE 35 #define BUF_SIZE 1024 36 36 37 #define MEMMAP_MAX_RECORDS 37 #define MEMMAP_MAX_RECORDS 32 38 38 39 #define MAX_OFW_ARGS 1239 #define MAX_OFW_ARGS 12 40 40 41 41 typedef unative_t ofw_arg_t; … … 47 47 */ 48 48 typedef struct { 49 ofw_arg_t service; 50 ofw_arg_t nargs; 51 ofw_arg_t nret; 52 ofw_arg_t args[MAX_OFW_ARGS]; 49 ofw_arg_t service; /**< Command name. */ 50 ofw_arg_t nargs; /**< Number of in arguments. */ 51 ofw_arg_t nret; /**< Number of out arguments. */ 52 ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments. */ 53 53 } ofw_args_t; 54 54 … … 63 63 memzone_t zones[MEMMAP_MAX_RECORDS]; 64 64 } memmap_t; 65 66 typedef struct { 67 void *addr; 68 uint32_t width; 69 uint32_t height; 70 uint32_t bpp; 71 uint32_t scanline; 72 } screen_t; 73 74 typedef struct { 75 void *addr; 76 uint32_t size; 77 } macio_t; 65 78 66 79 typedef struct { … … 105 118 extern void *ofw_translate(const void *virt); 106 119 extern int ofw_translate_failed(ofw_arg_t flag); 107 extern void *ofw_claim_virt(const void *virt, const unsigned int len); 108 extern void *ofw_claim_phys(const void *virt, const unsigned int len); 109 extern void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment); 110 extern int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode); 120 extern void *ofw_claim_virt(const void *virt, const int len); 121 extern void *ofw_claim_phys(const void *virt, const int len); 122 extern int ofw_map(const void *phys, const void *virt, const int size, const int mode); 111 123 extern int ofw_memmap(memmap_t *map); 124 extern int ofw_screen(screen_t *screen); 125 extern int ofw_macio(macio_t *macio); 112 126 extern int ofw_setup_palette(void); 113 127 extern void ofw_quiesce(void); -
boot/genarch/ofw_tree.c
rbc7d44c r207e208e 29 29 #include <ofw_tree.h> 30 30 #include <ofw.h> 31 #include <ofwarch.h>32 31 #include <types.h> 33 32 #include <string.h> 34 33 #include <balloc.h> 35 34 #include <asm.h> 36 #include <memstr.h> 37 38 #define MAX_PATH_LEN 256 35 36 #define MAX_PATH_LEN 256 39 37 40 38 static ofw_tree_node_t *ofw_tree_node_alloc(void) … … 51 49 static void *ofw_tree_space_alloc(size_t size) 52 50 { 51 char *addr; 52 53 53 /* 54 54 * What we do here is a nasty hack :-) … … 61 61 * behind the requested memory. 62 62 */ 63 char *addr = balloc(size + 1, size);63 addr = balloc(size + 1, size); 64 64 if (addr) 65 65 addr[size] = '\0'; 66 67 66 return addr; 68 67 } … … 76 75 * order to prevent stack from overflowing. 77 76 * 78 * @param current_node Pointer to uninitialized ofw_tree_node structure that 79 * will become the memory represenation of 'current'. 80 * @param parent_node Parent ofw_tree_node structure or NULL in case of root 81 * node. 82 * @param current OpenFirmware phandle to the current device tree node. 83 * 77 * @param current_node Pointer to uninitialized ofw_tree_node structure that 78 * will become the memory represenation of 'current'. 79 * @param parent_node Parent ofw_tree_node structure or NULL in case of root 80 * node. 81 * @param current OpenFirmware phandle to the current device tree node. 84 82 */ 85 83 static void ofw_tree_node_process(ofw_tree_node_t *current_node, 86 84 ofw_tree_node_t *parent_node, phandle current) 87 85 { 86 static char path[MAX_PATH_LEN + 1]; 87 static char name[OFW_TREE_PROPERTY_MAX_NAMELEN]; 88 static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN]; 89 phandle peer; 90 phandle child; 91 size_t len; 92 int i; 93 88 94 while (current_node) { 89 95 /* 90 96 * Initialize node. 91 97 */ 92 current_node->parent = (ofw_tree_node_t *) balloc_rebase(parent_node);98 current_node->parent = parent_node; 93 99 current_node->peer = NULL; 94 100 current_node->child = NULL; … … 97 103 current_node->property = NULL; 98 104 current_node->device = NULL; 99 105 100 106 /* 101 107 * Get the disambigued name. 102 108 */ 103 static char path[MAX_PATH_LEN + 1]; 104 size_t len = ofw_package_to_path(current, path, MAX_PATH_LEN); 109 len = ofw_package_to_path(current, path, MAX_PATH_LEN); 105 110 if (len == -1) 106 111 return; 107 112 108 113 path[len] = '\0'; 109 110 /* Find last slash */ 111 int i; 112 for (i = len - 1; (i >= 0) && (path[i] != '/'); i--); 113 114 /* Do not include the slash */ 115 i++; 114 for (i = len - 1; i >= 0 && path[i] != '/'; i--) 115 ; 116 i++; /* do not include '/' */ 117 116 118 len -= i; 117 118 /* Add space for trailing '\0' */ 119 char *da_name = ofw_tree_space_alloc(len + 1); 120 if (!da_name) 121 return; 122 123 memcpy(da_name, &path[i], len); 124 da_name[len] = '\0'; 125 current_node->da_name = (char *) balloc_rebase(da_name); 126 119 120 /* add space for trailing '\0' */ 121 current_node->da_name = ofw_tree_space_alloc(len + 1); 122 if (!current_node->da_name) 123 return; 124 125 memcpy(current_node->da_name, &path[i], len); 126 current_node->da_name[len] = '\0'; 127 127 128 /* 128 129 * Recursively process the potential child node. 129 130 */ 130 phandle child = ofw_get_child_node(current); 131 if ((child != 0) && (child != -1)) { 132 ofw_tree_node_t *child_node = ofw_tree_node_alloc(); 131 child = ofw_get_child_node(current); 132 if (child != 0 && child != -1) { 133 ofw_tree_node_t *child_node; 134 135 child_node = ofw_tree_node_alloc(); 133 136 if (child_node) { 134 137 ofw_tree_node_process(child_node, current_node, 135 138 child); 136 current_node->child = 137 (ofw_tree_node_t *) balloc_rebase(child_node); 139 current_node->child = child_node; 138 140 } 139 141 } 140 142 141 143 /* 142 144 * Count properties. 143 145 */ 144 static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];145 static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN];146 146 name[0] = '\0'; 147 147 while (ofw_next_property(current, name, name2) == 1) { … … 149 149 memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN); 150 150 } 151 151 152 152 if (!current_node->properties) 153 153 return; 154 154 155 155 /* 156 156 * Copy properties. 157 157 */ 158 ofw_tree_property_t *property =158 current_node->property = 159 159 ofw_tree_properties_alloc(current_node->properties); 160 if (! property)160 if (!current_node->property) 161 161 return; 162 162 163 163 name[0] = '\0'; 164 164 for (i = 0; ofw_next_property(current, name, name2) == 1; i++) { 165 size_t size; 166 165 167 if (i == current_node->properties) 166 168 break; 169 170 memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN); 171 memcpy(current_node->property[i].name, name, 172 OFW_TREE_PROPERTY_MAX_NAMELEN); 173 current_node->property[i].name[ 174 OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0'; 175 176 size = ofw_get_proplen(current, name); 177 current_node->property[i].size = size; 178 if (size) { 179 void *buf; 167 180 168 memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN); 169 memcpy(property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN); 170 property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0'; 171 172 size_t size = ofw_get_proplen(current, name); 173 property[i].size = size; 174 175 if (size) { 176 void *buf = ofw_tree_space_alloc(size); 177 if (buf) { 181 buf = ofw_tree_space_alloc(size); 182 if (current_node->property[i].value = buf) { 178 183 /* 179 184 * Copy property value to memory node. 180 185 */ 181 (void) ofw_get_property(current, name, buf, size);182 property[i].value = balloc_rebase(buf);186 (void) ofw_get_property(current, name, 187 buf, size); 183 188 } 184 } else 185 property[i].value = NULL; 186 } 187 189 } else { 190 current_node->property[i].value = NULL; 191 } 192 } 193 188 194 /* Just in case we ran out of memory. */ 189 195 current_node->properties = i; 190 current_node->property = (ofw_tree_property_t *) balloc_rebase(property); 191 192 196 193 197 /* 194 198 * Iteratively process the next peer node. … … 198 202 * risk of overflowing the stack is too real. 199 203 */ 200 phandle peer = ofw_get_peer_node(current); 201 if ((peer != 0) && (peer != -1)) { 202 ofw_tree_node_t *peer_node = ofw_tree_node_alloc(); 203 if (peer_node) { 204 current_node->peer = (ofw_tree_node_t *) balloc_rebase(peer_node); 204 peer = ofw_get_peer_node(current); 205 if (peer != 0 && peer != -1) { 206 ofw_tree_node_t *peer_node; 207 208 peer_node = ofw_tree_node_alloc(); 209 if (peer_node) { 210 current_node->peer = peer_node; 205 211 current_node = peer_node; 206 212 current = peer; … … 211 217 } 212 218 } 213 214 219 /* 215 220 * No more peers on this level. … … 221 226 /** Construct memory representation of OpenFirmware device tree. 222 227 * 223 * @return NULL on failure or kernel pointer to the root node. 224 * 228 * @return NULL on failure or pointer to the root node. 225 229 */ 226 230 ofw_tree_node_t *ofw_tree_build(void) 227 231 { 228 ofw_tree_node_t *root = ofw_tree_node_alloc(); 232 ofw_tree_node_t *root; 233 phandle ssm_node; 234 ofw_tree_node_t *ssm; 235 236 root = ofw_tree_node_alloc(); 229 237 if (root) 230 238 ofw_tree_node_process(root, NULL, ofw_root); 231 239 232 240 /* 233 241 * The firmware client interface does not automatically include the … … 235 243 * solution is to explicitly stick "ssm" to the OFW tree. 236 244 */ 237 phandlessm_node = ofw_find_device("/ssm@0,0");245 ssm_node = ofw_find_device("/ssm@0,0"); 238 246 if (ssm_node != -1) { 239 ofw_tree_node_t *ssm = ofw_tree_node_alloc();247 ssm = ofw_tree_node_alloc(); 240 248 if (ssm) { 241 249 ofw_tree_node_process(ssm, root, 242 250 ofw_find_device("/ssm@0,0")); 243 251 ssm->peer = root->child; 244 root->child = (ofw_tree_node_t *) balloc_rebase(ssm);252 root->child = ssm; 245 253 } 246 254 } 247 255 248 return (ofw_tree_node_t *) balloc_rebase(root);249 } 256 return root; 257 } -
boot/genarch/ofw_tree.h
rbc7d44c r207e208e 33 33 #include <ofw.h> 34 34 35 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 35 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 36 37 typedef struct ofw_tree_node ofw_tree_node_t; 38 typedef struct ofw_tree_property ofw_tree_property_t; 39 40 /** Memory representation of OpenFirmware device tree node. */ 41 struct ofw_tree_node { 42 ofw_tree_node_t *parent; 43 ofw_tree_node_t *peer; 44 ofw_tree_node_t *child; 45 46 uint32_t node_handle; /**< Old OpenFirmware node handle. */ 47 48 char *da_name; /**< Disambigued name. */ 49 50 unsigned properties; /**< Number of properties. */ 51 ofw_tree_property_t *property; 52 53 void *device; /**< Member used solely by the kernel. */ 54 }; 36 55 37 56 /** Memory representation of OpenFirmware device tree node property. */ 38 typedef struct{57 struct ofw_tree_property { 39 58 char name[OFW_TREE_PROPERTY_MAX_NAMELEN]; 40 59 size_t size; 41 60 void *value; 42 } ofw_tree_property_t; 43 44 /** Memory representation of OpenFirmware device tree node. */ 45 typedef struct ofw_tree_node { 46 struct ofw_tree_node *parent; 47 struct ofw_tree_node *peer; 48 struct ofw_tree_node *child; 49 50 uint32_t node_handle; /**< Old OpenFirmware node handle. */ 51 52 char *da_name; /**< Disambigued name. */ 53 54 unsigned int properties; /**< Number of properties. */ 55 ofw_tree_property_t *property; 56 57 void *device; /**< Member used solely by the kernel. */ 58 } ofw_tree_node_t; 61 }; 59 62 60 63 extern ofw_tree_node_t *ofw_tree_build(void); -
boot/generic/printf.c
rbc7d44c r207e208e 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ -
boot/generic/printf.h
rbc7d44c r207e208e 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ -
boot/generic/stdarg.h
rbc7d44c r207e208e 38 38 typedef __builtin_va_list va_list; 39 39 40 #define va_start(ap, last) __builtin_va_start(ap, last)41 #define va_arg(ap, type) __builtin_va_arg(ap, type)42 #define va_end(ap) __builtin_va_end(ap)40 #define va_start(ap, last) __builtin_va_start(ap, last) 41 #define va_arg(ap, type) __builtin_va_arg(ap, type) 42 #define va_end(ap) __builtin_va_end(ap) 43 43 44 44 #endif -
kernel/arch/ia64/src/drivers/ski.c
rbc7d44c r207e208e 129 129 130 130 outdev_initialize("skiout", &skiout, &skiout_ops); 131 stdout _wire(&skiout);131 stdout = &skiout; 132 132 133 133 sysinfo_set_item_val("fb", NULL, false); -
kernel/arch/ppc32/include/asm/regname.h
rbc7d44c r207e208e 27 27 */ 28 28 29 /** @addtogroup ppc32 29 /** @addtogroup ppc32 30 30 * @{ 31 31 */ … … 37 37 38 38 /* Condition Register Bit Fields */ 39 #define cr0040 #define cr1141 #define cr2242 #define cr3343 #define cr4444 #define cr5545 #define cr6646 #define cr7739 #define cr0 0 40 #define cr1 1 41 #define cr2 2 42 #define cr3 3 43 #define cr4 4 44 #define cr5 5 45 #define cr6 6 46 #define cr7 7 47 47 48 48 /* General Purpose Registers (GPRs) */ 49 #define r0050 #define r1151 #define r2252 #define r3353 #define r4454 #define r5555 #define r6656 #define r7757 #define r8858 #define r9959 #define r101060 #define r111161 #define r121262 #define r131363 #define r141464 #define r151565 #define r161666 #define r171767 #define r181868 #define r191969 #define r202070 #define r212171 #define r222272 #define r232373 #define r242474 #define r252575 #define r262676 #define r272777 #define r282878 #define r292979 #define r303080 #define r313149 #define r0 0 50 #define r1 1 51 #define r2 2 52 #define r3 3 53 #define r4 4 54 #define r5 5 55 #define r6 6 56 #define r7 7 57 #define r8 8 58 #define r9 9 59 #define r10 10 60 #define r11 11 61 #define r12 12 62 #define r13 13 63 #define r14 14 64 #define r15 15 65 #define r16 16 66 #define r17 17 67 #define r18 18 68 #define r19 19 69 #define r20 20 70 #define r21 21 71 #define r22 22 72 #define r23 23 73 #define r24 24 74 #define r25 25 75 #define r26 26 76 #define r27 27 77 #define r28 28 78 #define r29 29 79 #define r30 30 80 #define r31 31 81 81 82 82 /* GPR Aliases */ 83 #define sp183 #define sp 1 84 84 85 85 /* Floating Point Registers (FPRs) */ 86 #define fr0087 #define fr1188 #define fr2289 #define fr3390 #define fr4491 #define fr5592 #define fr6693 #define fr7794 #define fr8895 #define fr9996 #define fr101097 #define fr111198 #define fr121299 #define fr1313100 #define fr1414101 #define fr1515102 #define fr1616103 #define fr1717104 #define fr1818105 #define fr1919106 #define fr2020107 #define fr2121108 #define fr2222109 #define fr2323110 #define fr2424111 #define fr2525112 #define fr2626113 #define fr2727114 #define fr2828115 #define fr2929116 #define fr3030117 #define fr3131118 119 #define vr00120 #define vr11121 #define vr22122 #define vr33123 #define vr44124 #define vr55125 #define vr66126 #define vr77127 #define vr88128 #define vr99129 #define vr1010130 #define vr1111131 #define vr1212132 #define vr1313133 #define vr1414134 #define vr1515135 #define vr1616136 #define vr1717137 #define vr1818138 #define vr1919139 #define vr2020140 #define vr2121141 #define vr2222142 #define vr2323143 #define vr2424144 #define vr2525145 #define vr2626146 #define vr2727147 #define vr2828148 #define vr2929149 #define vr3030150 #define vr3131151 152 #define evr00153 #define evr11154 #define evr22155 #define evr33156 #define evr44157 #define evr55158 #define evr66159 #define evr77160 #define evr88161 #define evr99162 #define evr1010163 #define evr1111164 #define evr1212165 #define evr1313166 #define evr1414167 #define evr1515168 #define evr1616169 #define evr1717170 #define evr1818171 #define evr1919172 #define evr2020173 #define evr2121174 #define evr2222175 #define evr2323176 #define evr2424177 #define evr2525178 #define evr2626179 #define evr2727180 #define evr2828181 #define evr2929182 #define evr3030183 #define evr313186 #define fr0 0 87 #define fr1 1 88 #define fr2 2 89 #define fr3 3 90 #define fr4 4 91 #define fr5 5 92 #define fr6 6 93 #define fr7 7 94 #define fr8 8 95 #define fr9 9 96 #define fr10 10 97 #define fr11 11 98 #define fr12 12 99 #define fr13 13 100 #define fr14 14 101 #define fr15 15 102 #define fr16 16 103 #define fr17 17 104 #define fr18 18 105 #define fr19 19 106 #define fr20 20 107 #define fr21 21 108 #define fr22 22 109 #define fr23 23 110 #define fr24 24 111 #define fr25 25 112 #define fr26 26 113 #define fr27 27 114 #define fr28 28 115 #define fr29 29 116 #define fr30 30 117 #define fr31 31 118 119 #define vr0 0 120 #define vr1 1 121 #define vr2 2 122 #define vr3 3 123 #define vr4 4 124 #define vr5 5 125 #define vr6 6 126 #define vr7 7 127 #define vr8 8 128 #define vr9 9 129 #define vr10 10 130 #define vr11 11 131 #define vr12 12 132 #define vr13 13 133 #define vr14 14 134 #define vr15 15 135 #define vr16 16 136 #define vr17 17 137 #define vr18 18 138 #define vr19 19 139 #define vr20 20 140 #define vr21 21 141 #define vr22 22 142 #define vr23 23 143 #define vr24 24 144 #define vr25 25 145 #define vr26 26 146 #define vr27 27 147 #define vr28 28 148 #define vr29 29 149 #define vr30 30 150 #define vr31 31 151 152 #define evr0 0 153 #define evr1 1 154 #define evr2 2 155 #define evr3 3 156 #define evr4 4 157 #define evr5 5 158 #define evr6 6 159 #define evr7 7 160 #define evr8 8 161 #define evr9 9 162 #define evr10 10 163 #define evr11 11 164 #define evr12 12 165 #define evr13 13 166 #define evr14 14 167 #define evr15 15 168 #define evr16 16 169 #define evr17 17 170 #define evr18 18 171 #define evr19 19 172 #define evr20 20 173 #define evr21 21 174 #define evr22 22 175 #define evr23 23 176 #define evr24 24 177 #define evr25 25 178 #define evr26 26 179 #define evr27 27 180 #define evr28 28 181 #define evr29 29 182 #define evr30 30 183 #define evr31 31 184 184 185 185 /* Special Purpose Registers (SPRs) */ 186 #define xer1187 #define lr 188 #define ctr 189 #define dec22190 #define sdr125191 #define srr026192 #define srr1 193 #define sprg0272194 #define sprg1273195 #define sprg2274196 #define sprg3275197 #define prv287198 #define ibat0u 199 #define ibat0l 200 #define ibat1u 201 #define ibat1l 202 #define ibat2u 203 #define ibat2l 204 #define ibat3u 205 #define ibat3l 206 #define dbat0u 207 #define dbat0l 208 #define dbat1u 209 #define dbat1l 210 #define dbat2u 211 #define dbat2l 212 #define dbat3u 213 #define dbat3l 214 #define tlbmiss 215 #define ptehi 216 #define ptelo 217 #define hid0 186 #define xer 1 187 #define lr 8 188 #define ctr 9 189 #define dec 22 190 #define sdr1 25 191 #define srr0 26 192 #define srr1 27 193 #define sprg0 272 194 #define sprg1 273 195 #define sprg2 274 196 #define sprg3 275 197 #define prv 287 198 #define ibat0u 528 199 #define ibat0l 529 200 #define ibat1u 530 201 #define ibat1l 531 202 #define ibat2u 532 203 #define ibat2l 533 204 #define ibat3u 534 205 #define ibat3l 535 206 #define dbat0u 536 207 #define dbat0l 537 208 #define dbat1u 538 209 #define dbat1l 539 210 #define dbat2u 540 211 #define dbat2l 541 212 #define dbat3u 542 213 #define dbat3l 543 214 #define tlbmiss 980 215 #define ptehi 981 216 #define ptelo 982 217 #define hid0 1008 218 218 219 219 /* MSR bits */ 220 #define msr_dr 221 #define msr_ir 222 #define msr_pr 223 #define msr_ee 220 #define msr_dr (1 << 4) 221 #define msr_ir (1 << 5) 222 #define msr_pr (1 << 14) 223 #define msr_ee (1 << 15) 224 224 225 225 /* HID0 bits */ 226 #define hid0_sten 227 #define hid0_ice 228 #define hid0_dce 229 #define hid0_icfi 230 #define hid0_dci 226 #define hid0_sten (1 << 24) 227 #define hid0_ice (1 << 15) 228 #define hid0_dce (1 << 14) 229 #define hid0_icfi (1 << 11) 230 #define hid0_dci (1 << 10) 231 231 232 232 #endif -
kernel/arch/ppc32/include/boot/boot.h
rbc7d44c r207e208e 41 41 #define TEMP_STACK_SIZE 0x1000 42 42 43 #define TASKMAP_MAX_RECORDS 32 44 #define MEMMAP_MAX_RECORDS 32 45 #define BOOTINFO_TASK_NAME_BUFLEN 32 43 #define TASKMAP_MAX_RECORDS 32 44 #define MEMMAP_MAX_RECORDS 32 46 45 47 46 #ifndef __ASM__ 48 47 48 #define BOOTINFO_TASK_NAME_BUFLEN 32 49 49 50 #include <arch/types.h> 50 #include <config.h>51 #include <genarch/ofw/ofw_tree.h>52 51 53 52 typedef struct { … … 74 73 75 74 typedef struct { 75 uintptr_t addr; 76 unsigned int width; 77 unsigned int height; 78 unsigned int bpp; 79 unsigned int scanline; 80 } screen_t; 81 82 typedef struct { 83 uintptr_t addr; 84 unsigned int size; 85 } macio_t; 86 87 typedef struct { 76 88 memmap_t memmap; 77 89 taskmap_t taskmap; 78 ballocs_t ballocs;79 ofw_tree_node_t *ofw_root;90 screen_t screen; 91 macio_t macio; 80 92 } bootinfo_t; 81 93 -
kernel/arch/ppc32/src/mm/tlb.c
rbc7d44c r207e208e 45 45 static unsigned int seed = 10; 46 46 static unsigned int seed_real __attribute__ ((section("K_UNMAPPED_DATA_START"))) = 42; 47 48 49 #define TLB_FLUSH \ 50 "tlbie %0\n" \ 51 "addi %0, %0, 0x1000\n" 47 52 48 53 … … 446 451 "sync\n" 447 452 448 ".rept 64\n" 449 "tlbie %0\n" 450 "addi %0, %0, 0x1000\n" 451 ".endr\n" 453 TLB_FLUSH 454 TLB_FLUSH 455 TLB_FLUSH 456 TLB_FLUSH 457 TLB_FLUSH 458 TLB_FLUSH 459 TLB_FLUSH 460 TLB_FLUSH 461 462 TLB_FLUSH 463 TLB_FLUSH 464 TLB_FLUSH 465 TLB_FLUSH 466 TLB_FLUSH 467 TLB_FLUSH 468 TLB_FLUSH 469 TLB_FLUSH 470 471 TLB_FLUSH 472 TLB_FLUSH 473 TLB_FLUSH 474 TLB_FLUSH 475 TLB_FLUSH 476 TLB_FLUSH 477 TLB_FLUSH 478 TLB_FLUSH 479 480 TLB_FLUSH 481 TLB_FLUSH 482 TLB_FLUSH 483 TLB_FLUSH 484 TLB_FLUSH 485 TLB_FLUSH 486 TLB_FLUSH 487 TLB_FLUSH 488 489 TLB_FLUSH 490 TLB_FLUSH 491 TLB_FLUSH 492 TLB_FLUSH 493 TLB_FLUSH 494 TLB_FLUSH 495 TLB_FLUSH 496 TLB_FLUSH 497 498 TLB_FLUSH 499 TLB_FLUSH 500 TLB_FLUSH 501 TLB_FLUSH 502 TLB_FLUSH 503 TLB_FLUSH 504 TLB_FLUSH 505 TLB_FLUSH 506 507 TLB_FLUSH 508 TLB_FLUSH 509 TLB_FLUSH 510 TLB_FLUSH 511 TLB_FLUSH 512 TLB_FLUSH 513 TLB_FLUSH 514 TLB_FLUSH 515 516 TLB_FLUSH 517 TLB_FLUSH 518 TLB_FLUSH 519 TLB_FLUSH 520 TLB_FLUSH 521 TLB_FLUSH 522 TLB_FLUSH 523 TLB_FLUSH 452 524 453 525 "eieio\n" -
kernel/arch/ppc32/src/ppc32.c
rbc7d44c r207e208e 41 41 #include <genarch/fb/fb.h> 42 42 #include <genarch/fb/visuals.h> 43 #include <genarch/ofw/ofw_tree.h>44 #include <genarch/ofw/pci.h>45 43 #include <userspace.h> 46 44 #include <proc/uarg.h> … … 51 49 #include <macros.h> 52 50 #include <string.h> 53 #include <print.h>54 51 55 52 #define IRQ_COUNT 64 … … 66 63 67 64 for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { 68 init.tasks[i].addr = bootinfo.taskmap.tasks[i].addr;65 init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); 69 66 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 70 67 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 71 68 bootinfo.taskmap.tasks[i].name); 72 69 } 73 74 /* Copy boot allocations info. */75 ballocs.base = bootinfo.ballocs.base;76 ballocs.size = bootinfo.ballocs.size;77 78 ofw_tree_init(bootinfo.ofw_root);79 70 } 80 71 … … 83 74 /* Initialize dispatch table */ 84 75 interrupt_init(); 85 76 86 77 /* Start decrementer */ 87 78 start_decrementer(); 88 79 } 89 80 90 static bool display_register(ofw_tree_node_t *node, void *arg) 91 { 92 uintptr_t fb_addr = 0; 93 uint32_t fb_width = 0; 94 uint32_t fb_height = 0; 95 uint32_t fb_scanline = 0; 96 unsigned int visual = VISUAL_UNKNOWN; 97 98 ofw_tree_property_t *prop = ofw_tree_getprop(node, "address"); 99 if ((prop) && (prop->value)) 100 fb_addr = *((uintptr_t *) prop->value); 101 102 prop = ofw_tree_getprop(node, "width"); 103 if ((prop) && (prop->value)) 104 fb_width = *((uint32_t *) prop->value); 105 106 prop = ofw_tree_getprop(node, "height"); 107 if ((prop) && (prop->value)) 108 fb_height = *((uint32_t *) prop->value); 109 110 prop = ofw_tree_getprop(node, "depth"); 111 if ((prop) && (prop->value)) { 112 uint32_t fb_bpp = *((uint32_t *) prop->value); 113 switch (fb_bpp) { 114 case 8: 115 visual = VISUAL_INDIRECT_8; 116 break; 117 case 16: 118 visual = VISUAL_RGB_5_5_5_BE; 119 break; 120 case 24: 121 visual = VISUAL_BGR_8_8_8; 122 break; 123 case 32: 124 visual = VISUAL_RGB_0_8_8_8; 125 break; 126 default: 127 visual = VISUAL_UNKNOWN; 81 void arch_post_mm_init(void) 82 { 83 if (config.cpu_active == 1) { 84 85 #ifdef CONFIG_FB 86 /* Initialize framebuffer */ 87 if (bootinfo.screen.addr) { 88 unsigned int visual; 89 90 switch (bootinfo.screen.bpp) { 91 case 8: 92 visual = VISUAL_INDIRECT_8; 93 break; 94 case 16: 95 visual = VISUAL_RGB_5_5_5_BE; 96 break; 97 case 24: 98 visual = VISUAL_BGR_8_8_8; 99 break; 100 case 32: 101 visual = VISUAL_RGB_0_8_8_8; 102 break; 103 default: 104 panic("Unsupported bits per pixel."); 105 } 106 fb_properties_t prop = { 107 .addr = bootinfo.screen.addr, 108 .offset = 0, 109 .x = bootinfo.screen.width, 110 .y = bootinfo.screen.height, 111 .scan = bootinfo.screen.scanline, 112 .visual = visual, 113 }; 114 fb_init(&prop); 128 115 } 129 }130 131 prop = ofw_tree_getprop(node, "linebytes");132 if ((prop) && (prop->value))133 fb_scanline = *((uint32_t *) prop->value);134 135 if ((fb_addr) && (fb_width > 0) && (fb_height > 0)136 && (fb_scanline > 0) && (visual != VISUAL_UNKNOWN)) {137 fb_properties_t fb_prop = {138 .addr = fb_addr,139 .offset = 0,140 .x = fb_width,141 .y = fb_height,142 .scan = fb_scanline,143 .visual = visual,144 };145 fb_init(&fb_prop);146 }147 148 /* Consider only a single device for now */149 return false;150 }151 152 void arch_post_mm_init(void)153 {154 if (config.cpu_active == 1) {155 #ifdef CONFIG_FB156 ofw_tree_walk_by_device_type("display", display_register, NULL);157 116 #endif 158 117 … … 173 132 } 174 133 175 static bool macio_register(ofw_tree_node_t *node, void *arg) 176 { 177 ofw_pci_reg_t *assigned_address = NULL; 178 179 ofw_tree_property_t *prop = ofw_tree_getprop(node, "assigned-addresses"); 180 if ((prop) && (prop->value)) 181 assigned_address = ((ofw_pci_reg_t *) prop->value); 182 183 if (assigned_address) { 134 void arch_post_smp_init(void) 135 { 136 if (bootinfo.macio.addr) { 184 137 /* Initialize PIC */ 185 138 cir_t cir; 186 139 void *cir_arg; 187 pic_init( assigned_address[0].addr, PAGE_SIZE, &cir, &cir_arg);188 140 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg); 141 189 142 #ifdef CONFIG_MAC_KBD 190 uintptr_t pa = assigned_address[0].addr + 0x16000;143 uintptr_t pa = bootinfo.macio.addr + 0x16000; 191 144 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 192 145 size_t offset = pa - aligned_addr; 193 146 size_t size = 2 * PAGE_SIZE; 194 147 195 148 cuda_t *cuda = (cuda_t *) 196 149 (hw_map(aligned_addr, offset + size) + offset); 197 150 198 151 /* Initialize I/O controller */ 199 152 cuda_instance_t *cuda_instance = … … 210 163 #endif 211 164 } 212 213 /* Consider only a single device for now */214 return false;215 }216 217 void arch_post_smp_init(void)218 {219 ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);220 165 } 221 166 -
kernel/arch/sparc64/include/drivers/fhc.h
rbc7d44c r207e208e 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ -
kernel/arch/sparc64/src/drivers/fhc.c
rbc7d44c r207e208e 46 46 #include <arch/types.h> 47 47 #include <genarch/ofw/ofw_tree.h> 48 #include <genarch/ofw/fhc.h>49 48 #include <sysinfo/sysinfo.h> 50 49 -
kernel/arch/sparc64/src/drivers/kbd.c
rbc7d44c r207e208e 35 35 #include <arch/drivers/kbd.h> 36 36 #include <genarch/ofw/ofw_tree.h> 37 #include <genarch/ofw/fhc.h> 38 #include <genarch/ofw/ebus.h> 37 38 #ifdef CONFIG_SUN_KBD 39 #include <genarch/kbrd/kbrd.h> 40 #endif 41 #ifdef CONFIG_Z8530 42 #include <genarch/drivers/z8530/z8530.h> 43 #endif 44 #ifdef CONFIG_NS16550 45 #include <genarch/drivers/ns16550/ns16550.h> 46 #endif 47 39 48 #include <console/console.h> 40 49 #include <ddi/irq.h> … … 47 56 48 57 #ifdef CONFIG_SUN_KBD 49 #include <genarch/kbrd/kbrd.h>50 #endif51 52 #ifdef CONFIG_Z853053 #include <genarch/drivers/z8530/z8530.h>54 #endif55 56 #ifdef CONFIG_NS1655057 #include <genarch/drivers/ns16550/ns16550.h>58 #endif59 60 #ifdef CONFIG_SUN_KBD61 58 62 59 #ifdef CONFIG_Z8530 -
kernel/arch/sparc64/src/drivers/pci.c
rbc7d44c r207e208e 37 37 #include <arch/drivers/pci.h> 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/upa.h>40 39 #include <arch/trap/interrupt.h> 41 40 #include <mm/page.h> -
kernel/arch/sparc64/src/drivers/scr.c
rbc7d44c r207e208e 35 35 #include <arch/drivers/scr.h> 36 36 #include <genarch/ofw/ofw_tree.h> 37 #include <genarch/ofw/pci.h>38 #include <genarch/ofw/sbus.h>39 #include <genarch/ofw/upa.h>40 37 #include <genarch/fb/fb.h> 41 38 #include <genarch/fb/visuals.h> -
kernel/arch/sparc64/src/drivers/sgcn.c
rbc7d44c r207e208e 380 380 sysinfo_set_item_val("fb.kind", NULL, 4); 381 381 382 outdev_initialize("sgcnout", &sgcnout, &sgcnout_ops); 383 stdout _wire(&sgcnout);382 outdev_initialize("sgcnout", &sgcnout, &sgcnout_ops); 383 stdout = &sgcnout; 384 384 } 385 385 -
kernel/genarch/Makefile.inc
rbc7d44c r207e208e 130 130 ifeq ($(CONFIG_OFW_TREE),y) 131 131 GENARCH_SOURCES += \ 132 genarch/src/ofw/ofw_tree.c 133 endif 134 135 ifeq ($(CONFIG_OFW_PCI),y) 136 GENARCH_SOURCES += \ 132 genarch/src/ofw/ofw_tree.c \ 137 133 genarch/src/ofw/ebus.c \ 138 134 genarch/src/ofw/fhc.c \ 139 135 genarch/src/ofw/pci.c \ 140 136 genarch/src/ofw/sbus.c \ 141 genarch/src/ofw/upa.c 137 genarch/src/ofw/upa.c 142 138 endif 143 139 -
kernel/genarch/include/fb/fb.h
rbc7d44c r207e208e 68 68 69 69 void fb_redraw(void); 70 boolfb_init(fb_properties_t *props);70 void fb_init(fb_properties_t *props); 71 71 72 72 #endif -
kernel/genarch/include/fb/visuals.h
rbc7d44c r207e208e 37 37 38 38 typedef enum { 39 VISUAL_UNKNOWN = 0,40 39 VISUAL_INDIRECT_8, 41 40 VISUAL_RGB_5_5_5_LE, -
kernel/genarch/include/ofw/ofw_tree.h
rbc7d44c r207e208e 31 31 32 32 #include <arch/types.h> 33 #include <ddi/irq.h> 33 34 #include <typedefs.h> 34 35 35 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 36 37 /** Memory representation of OpenFirmware device tree node property. */ 38 typedef struct { 39 char name[OFW_TREE_PROPERTY_MAX_NAMELEN]; 40 size_t size; 41 void *value; 42 } ofw_tree_property_t; 36 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 37 38 typedef struct ofw_tree_node ofw_tree_node_t; 39 typedef struct ofw_tree_property ofw_tree_property_t; 43 40 44 41 /** Memory representation of OpenFirmware device tree node. */ 45 typedefstruct ofw_tree_node {46 struct ofw_tree_node*parent;47 struct ofw_tree_node*peer;48 struct ofw_tree_node*child;49 50 uint32_t node_handle; 51 52 char *da_name; 53 54 unsigned int properties;/**< Number of properties. */42 struct ofw_tree_node { 43 ofw_tree_node_t *parent; 44 ofw_tree_node_t *peer; 45 ofw_tree_node_t *child; 46 47 uint32_t node_handle; /**< Old OpenFirmware node handle. */ 48 49 char *da_name; /**< Disambigued name. */ 50 51 unsigned properties; /**< Number of properties. */ 55 52 ofw_tree_property_t *property; 56 53 … … 60 57 */ 61 58 void *device; 62 } ofw_tree_node_t; 63 64 /* Walker for visiting OpenFirmware device tree nodes. */ 65 typedef bool (* ofw_tree_walker_t)(ofw_tree_node_t *, void *); 59 }; 60 61 /** Memory representation of OpenFirmware device tree node property. */ 62 struct ofw_tree_property { 63 char name[OFW_TREE_PROPERTY_MAX_NAMELEN]; 64 size_t size; 65 void *value; 66 }; 67 68 /* 69 * Definition of 'reg' and 'ranges' properties for various buses. 70 */ 71 72 struct ofw_fhc_reg { 73 uint64_t addr; 74 uint32_t size; 75 } __attribute__ ((packed)); 76 typedef struct ofw_fhc_reg ofw_fhc_reg_t; 77 78 struct ofw_fhc_range { 79 uint64_t child_base; 80 uint64_t parent_base; 81 uint32_t size; 82 } __attribute__ ((packed)); 83 typedef struct ofw_fhc_range ofw_fhc_range_t; 84 85 struct ofw_central_reg { 86 uint64_t addr; 87 uint32_t size; 88 } __attribute__ ((packed)); 89 typedef struct ofw_central_reg ofw_central_reg_t; 90 91 struct ofw_central_range { 92 uint64_t child_base; 93 uint64_t parent_base; 94 uint32_t size; 95 } __attribute__ ((packed)); 96 typedef struct ofw_central_range ofw_central_range_t; 97 98 struct ofw_ebus_reg { 99 uint32_t space; 100 uint32_t addr; 101 uint32_t size; 102 } __attribute__ ((packed)); 103 typedef struct ofw_ebus_reg ofw_ebus_reg_t; 104 105 struct ofw_ebus_range { 106 uint32_t child_space; 107 uint32_t child_base; 108 uint32_t parent_space; 109 uint64_t parent_base; /* group phys.mid and phys.lo together */ 110 uint32_t size; 111 } __attribute__ ((packed)); 112 typedef struct ofw_ebus_range ofw_ebus_range_t; 113 114 struct ofw_ebus_intr_map { 115 uint32_t space; 116 uint32_t addr; 117 uint32_t intr; 118 uint32_t controller_handle; 119 uint32_t controller_ino; 120 } __attribute__ ((packed)); 121 typedef struct ofw_ebus_intr_map ofw_ebus_intr_map_t; 122 123 struct ofw_ebus_intr_mask { 124 uint32_t space_mask; 125 uint32_t addr_mask; 126 uint32_t intr_mask; 127 } __attribute__ ((packed)); 128 typedef struct ofw_ebus_intr_mask ofw_ebus_intr_mask_t; 129 130 struct ofw_pci_reg { 131 uint32_t space; /* needs to be masked to obtain pure space id */ 132 uint64_t addr; /* group phys.mid and phys.lo together */ 133 uint64_t size; 134 } __attribute__ ((packed)); 135 typedef struct ofw_pci_reg ofw_pci_reg_t; 136 137 struct ofw_pci_range { 138 uint32_t space; 139 uint64_t child_base; /* group phys.mid and phys.lo together */ 140 uint64_t parent_base; 141 uint64_t size; 142 } __attribute__ ((packed)); 143 typedef struct ofw_pci_range ofw_pci_range_t; 144 145 struct ofw_sbus_reg { 146 uint64_t addr; 147 uint32_t size; 148 } __attribute__ ((packed)); 149 typedef struct ofw_sbus_reg ofw_sbus_reg_t; 150 151 struct ofw_sbus_range { 152 uint64_t child_base; 153 uint64_t parent_base; 154 uint32_t size; 155 } __attribute__ ((packed)); 156 typedef struct ofw_sbus_range ofw_sbus_range_t; 157 158 struct ofw_upa_reg { 159 uint64_t addr; 160 uint64_t size; 161 } __attribute__ ((packed)); 162 typedef struct ofw_upa_reg ofw_upa_reg_t; 66 163 67 164 extern void ofw_tree_init(ofw_tree_node_t *); 68 165 extern void ofw_tree_print(void); 69 70 166 extern const char *ofw_tree_node_name(const ofw_tree_node_t *); 71 167 extern ofw_tree_node_t *ofw_tree_lookup(const char *); 72 168 extern ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *, 73 169 const char *); 74 extern void ofw_tree_walk_by_device_type(const char *, ofw_tree_walker_t,75 void *);76 77 170 extern ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *, const char *); 78 171 extern ofw_tree_node_t *ofw_tree_find_child_by_device_type(ofw_tree_node_t *, 79 172 const char *); 80 81 173 extern ofw_tree_node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *, 82 174 const char *); 83 extern ofw_tree_node_t *ofw_tree_find_peer_by_name(ofw_tree_node_t * ,84 const char * );175 extern ofw_tree_node_t *ofw_tree_find_peer_by_name(ofw_tree_node_t *node, 176 const char *name); 85 177 extern ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *, 86 178 uint32_t); 87 179 180 extern bool ofw_fhc_apply_ranges(ofw_tree_node_t *, ofw_fhc_reg_t *, 181 uintptr_t *); 182 extern bool ofw_central_apply_ranges(ofw_tree_node_t *, ofw_central_reg_t *, 183 uintptr_t *); 184 extern bool ofw_ebus_apply_ranges(ofw_tree_node_t *, ofw_ebus_reg_t *, 185 uintptr_t *); 186 extern bool ofw_pci_apply_ranges(ofw_tree_node_t *, ofw_pci_reg_t *, 187 uintptr_t *); 188 extern bool ofw_sbus_apply_ranges(ofw_tree_node_t *, ofw_sbus_reg_t *, 189 uintptr_t *); 190 extern bool ofw_upa_apply_ranges(ofw_tree_node_t *, ofw_upa_reg_t *, 191 uintptr_t *); 192 193 extern bool ofw_pci_reg_absolutize(ofw_tree_node_t *, ofw_pci_reg_t *, 194 ofw_pci_reg_t *); 195 196 extern bool ofw_fhc_map_interrupt(ofw_tree_node_t *, ofw_fhc_reg_t *, 197 uint32_t, int *, cir_t *, void **); 198 extern bool ofw_ebus_map_interrupt(ofw_tree_node_t *, ofw_ebus_reg_t *, 199 uint32_t, int *, cir_t *, void **); 200 extern bool ofw_pci_map_interrupt(ofw_tree_node_t *, ofw_pci_reg_t *, 201 int, int *, cir_t *, void **); 202 88 203 #endif -
kernel/genarch/src/drivers/dsrln/dsrlnout.c
rbc7d44c r207e208e 66 66 67 67 outdev_initialize("dsrlnout", &dsrlnout_console, &dsrlnout_ops); 68 stdout _wire(&dsrlnout_console);68 stdout = &dsrlnout_console; 69 69 70 70 sysinfo_set_item_val("fb", NULL, true); -
kernel/genarch/src/drivers/ega/ega.c
rbc7d44c r207e208e 567 567 568 568 outdev_initialize("ega", &ega_console, &ega_ops); 569 stdout _wire(&ega_console);569 stdout = &ega_console; 570 570 571 571 sysinfo_set_item_val("fb", NULL, true); -
kernel/genarch/src/fb/fb.c
rbc7d44c r207e208e 458 458 * 459 459 */ 460 bool fb_init(fb_properties_t *props) 461 { 462 ASSERT(props); 463 ASSERT(props->x > 0); 464 ASSERT(props->y > 0); 465 ASSERT(props->scan > 0); 466 460 void fb_init(fb_properties_t *props) 461 { 467 462 switch (props->visual) { 468 463 case VISUAL_INDIRECT_8: … … 511 506 break; 512 507 default: 513 LOG("Unsupported visual."); 514 return false; 508 panic("Unsupported visual."); 515 509 } 516 510 … … 542 536 size_t glyphsize = FONT_GLYPHS * glyphbytes; 543 537 538 backbuf = (uint16_t *) malloc(bbsize, 0); 539 if (!backbuf) 540 panic("Unable to allocate backbuffer."); 541 542 glyphs = (uint8_t *) malloc(glyphsize, 0); 543 if (!glyphs) 544 panic("Unable to allocate glyphs."); 545 546 bgscan = malloc(bgscanbytes, 0); 547 if (!bgscan) 548 panic("Unable to allocate background pixel."); 549 550 memsetw(backbuf, cols * rows, 0); 551 552 glyphs_render(); 553 544 554 fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize); 545 if (!fb_addr) {546 LOG("Unable to map framebuffer.");547 return false;548 }549 550 backbuf = (uint16_t *) malloc(bbsize, 0);551 if (!backbuf) {552 LOG("Unable to allocate backbuffer.");553 return false;554 }555 556 glyphs = (uint8_t *) malloc(glyphsize, 0);557 if (!glyphs) {558 free(backbuf);559 LOG("Unable to allocate glyphs.");560 return false;561 }562 563 bgscan = malloc(bgscanbytes, 0);564 if (!bgscan) {565 free(glyphs);566 free(backbuf);567 LOG("Unable to allocate background pixel.");568 return false;569 }570 571 memsetw(backbuf, cols * rows, 0);572 glyphs_render();573 555 574 556 sysinfo_set_item_val("fb", NULL, true); … … 583 565 584 566 outdev_initialize("fb", &fb_console, &fb_ops); 585 stdout_wire(&fb_console); 586 587 return true; 567 stdout = &fb_console; 588 568 } 589 569 -
kernel/genarch/src/ofw/ebus.c
rbc7d44c r207e208e 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/ebus.h>40 #include <genarch/ofw/pci.h>41 39 #include <arch/memstr.h> 40 #include <arch/trap/interrupt.h> 42 41 #include <string.h> 43 42 #include <panic.h> -
kernel/genarch/src/ofw/fhc.c
rbc7d44c r207e208e 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/fhc.h>40 39 #include <arch/drivers/fhc.h> 41 40 #include <arch/memstr.h> -
kernel/genarch/src/ofw/ofw_tree.c
rbc7d44c r207e208e 32 32 /** 33 33 * @file 34 * @brief 34 * @brief OpenFirmware device tree navigation. 35 35 * 36 36 */ … … 40 40 #include <mm/slab.h> 41 41 #include <string.h> 42 #include <print.h> 42 43 #include <panic.h> 43 #include <print.h> 44 45 #define PATH_MAX_LEN 256 46 #define NAME_BUF_LEN 50 44 45 #define PATH_MAX_LEN 80 46 #define NAME_BUF_LEN 50 47 47 48 48 static ofw_tree_node_t *ofw_root; … … 55 55 /** Get OpenFirmware node property. 56 56 * 57 * @param node Node in which to lookup the property. 58 * @param name Name of the property. 59 * 60 * @return Pointer to the property structure or NULL if no such 61 * property. 62 * 63 */ 64 ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, 65 const char *name) 57 * @param node Node in which to lookup the property. 58 * @param name Name of the property. 59 * 60 * @return Pointer to the property structure or NULL if no such 61 * property. 62 */ 63 ofw_tree_property_t * 64 ofw_tree_getprop(const ofw_tree_node_t *node, const char *name) 66 65 { 67 66 unsigned int i; … … 71 70 return &node->property[i]; 72 71 } 73 72 74 73 return NULL; 75 74 } … … 77 76 /** Return value of the 'name' property. 78 77 * 79 * @param node Node of interest. 80 * 81 * @return Value of the 'name' property belonging to the node 82 * or NULL if the property is invalid. 83 * 78 * @param node Node of interest. 79 * 80 * @return Value of the 'name' property belonging to the node. 84 81 */ 85 82 const char *ofw_tree_node_name(const ofw_tree_node_t *node) 86 83 { 87 ofw_tree_property_t *prop = ofw_tree_getprop(node, "name"); 88 if ((!prop) || (prop->size < 2)) 89 return NULL; 84 ofw_tree_property_t *prop; 85 86 prop = ofw_tree_getprop(node, "name"); 87 if (!prop) 88 panic("Node without name property."); 89 90 if (prop->size < 2) 91 panic("Invalid name property."); 90 92 91 93 return prop->value; … … 94 96 /** Lookup child of given name. 95 97 * 96 * @param node Node whose child is being looked up. 97 * @param name Name of the child being looked up. 98 * 99 * @return NULL if there is no such child or pointer to the 100 * matching child node. 101 * 102 */ 103 ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, 104 const char *name) 98 * @param node Node whose child is being looked up. 99 * @param name Name of the child being looked up. 100 * 101 * @return NULL if there is no such child or pointer to the 102 * matching child node. 103 */ 104 ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name) 105 105 { 106 106 ofw_tree_node_t *cur; … … 125 125 return cur; 126 126 } 127 127 128 128 return NULL; 129 129 } … … 131 131 /** Lookup first child of given device type. 132 132 * 133 * @param node 134 * @param dtypeDevice type of the child being looked up.135 * 136 * @return 137 * 138 * 139 */ 140 ofw_tree_ node_t *ofw_tree_find_child_by_device_type(ofw_tree_node_t *node,141 const char *dtype) 142 { 143 ofw_tree_ node_t *cur;133 * @param node Node whose child is being looked up. 134 * @param name Device type of the child being looked up. 135 * 136 * @return NULL if there is no such child or pointer to the 137 * matching child node. 138 */ 139 ofw_tree_node_t * 140 ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name) 141 { 142 ofw_tree_node_t *cur; 143 ofw_tree_property_t *prop; 144 144 145 145 for (cur = node->child; cur; cur = cur->peer) { 146 ofw_tree_property_t *prop = 147 ofw_tree_getprop(cur, "device_type"); 148 149 if ((!prop) || (!prop->value)) 146 prop = ofw_tree_getprop(cur, "device_type"); 147 if (!prop || !prop->value) 150 148 continue; 151 152 if (str_cmp(prop->value, dtype) == 0) 153 return cur; 154 } 155 149 if (str_cmp(prop->value, name) == 0) 150 return cur; 151 } 152 156 153 return NULL; 157 154 } … … 162 159 * are looked up iteratively to avoid stack overflow. 163 160 * 164 * @param root Root of the searched subtree. 165 * @param handle OpenFirmware handle. 166 * 167 * @return NULL if there is no such node or pointer to the matching 168 * node. 169 * 170 */ 171 ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root, 172 uint32_t handle) 173 { 174 ofw_tree_node_t *cur; 175 176 for (cur = root; cur; cur = cur->peer) { 161 * @param root Root of the searched subtree. 162 * @param handle OpenFirmware handle. 163 * 164 * @return NULL if there is no such node or pointer to the matching 165 * node. 166 */ 167 ofw_tree_node_t * 168 ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle) 169 { 170 ofw_tree_node_t *cur; 171 172 for (cur = root; cur; cur = cur->peer) { 177 173 if (cur->node_handle == handle) 178 174 return cur; 179 175 180 176 if (cur->child) { 181 ofw_tree_node_t *node 182 = ofw_tree_find_node_by_handle(cur->child, handle); 177 ofw_tree_node_t *node; 178 179 node = ofw_tree_find_node_by_handle(cur->child, handle); 183 180 if (node) 184 181 return node; … … 186 183 } 187 184 188 return NULL; 185 return NULL; 189 186 } 190 187 191 188 /** Lookup first peer of given device type. 192 189 * 193 * @param node 194 * @param dtypeDevice type of the child being looked up.195 * 196 * @return 197 * 198 * 199 */ 200 ofw_tree_ node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node,201 const char *dtype) 202 { 203 ofw_tree_ node_t *cur;190 * @param node Node whose peer is being looked up. 191 * @param name Device type of the child being looked up. 192 * 193 * @return NULL if there is no such child or pointer to the 194 * matching child node. 195 */ 196 ofw_tree_node_t * 197 ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name) 198 { 199 ofw_tree_node_t *cur; 200 ofw_tree_property_t *prop; 204 201 205 202 for (cur = node->peer; cur; cur = cur->peer) { 206 ofw_tree_property_t *prop = 207 ofw_tree_getprop(cur, "device_type"); 208 209 if ((!prop) || (!prop->value)) 203 prop = ofw_tree_getprop(cur, "device_type"); 204 if (!prop || !prop->value) 210 205 continue; 211 212 if (str_cmp(prop->value, dtype) == 0)213 return cur;214 }215 216 return NULL; 217 } 206 if (str_cmp(prop->value, name) == 0) 207 return cur; 208 } 209 210 return NULL; 211 } 212 218 213 219 214 /** Lookup first peer of given name. 220 215 * 221 * @param node 222 * @param name 223 * 224 * @return 225 * 226 * 227 */ 228 ofw_tree_ node_t *ofw_tree_find_peer_by_name(ofw_tree_node_t *node,229 const char *name) 230 { 231 ofw_tree_ node_t *cur;216 * @param node Node whose peer is being looked up. 217 * @param name Name of the child being looked up. 218 * 219 * @return NULL if there is no such peer or pointer to the matching 220 * peer node. 221 */ 222 ofw_tree_node_t * 223 ofw_tree_find_peer_by_name(ofw_tree_node_t *node, const char *name) 224 { 225 ofw_tree_node_t *cur; 226 ofw_tree_property_t *prop; 232 227 233 228 for (cur = node->peer; cur; cur = cur->peer) { 234 ofw_tree_property_t *prop 235 = ofw_tree_getprop(cur, "name"); 236 237 if ((!prop) || (!prop->value)) 229 prop = ofw_tree_getprop(cur, "name"); 230 if (!prop || !prop->value) 238 231 continue; 239 240 232 if (str_cmp(prop->value, name) == 0) 241 233 return cur; 242 234 } 243 235 244 236 return NULL; 245 237 } … … 247 239 /** Lookup OpenFirmware node by its path. 248 240 * 249 * @param path Path to the node. 250 * 251 * @return NULL if there is no such node or pointer to the leaf 252 * node. 253 * 241 * @param path Path to the node. 242 * 243 * @return NULL if there is no such node or pointer to the leaf 244 * node. 254 245 */ 255 246 ofw_tree_node_t *ofw_tree_lookup(const char *path) 256 247 { 257 if (path[0] != '/') 258 return NULL; 259 248 char buf[NAME_BUF_LEN + 1]; 260 249 ofw_tree_node_t *node = ofw_root; 261 250 size_t i; 262 251 size_t j; 252 253 if (path[0] != '/') 254 return NULL; 263 255 264 256 for (i = 1; (i < str_size(path)) && (node); i = j + 1) { … … 269 261 continue; 270 262 271 char buf[NAME_BUF_LEN + 1];272 263 memcpy(buf, &path[i], j - i); 273 264 buf[j - i] = 0; … … 278 269 } 279 270 280 /** Walk theOpenFirmware device subtree rooted in a node.271 /** Print OpenFirmware device subtree rooted in a node. 281 272 * 282 273 * Child nodes are processed recursively and peer nodes are processed 283 274 * iteratively in order to avoid stack overflow. 284 275 * 285 * @param node Root of the subtree. 286 * @param dtype Device type to look for. 287 * @param walker Routine to be invoked on found device. 288 * @param arg User argument to the walker. 289 * 290 * @return True if the walk should continue. 291 * 292 */ 293 static bool ofw_tree_walk_by_device_type_internal(ofw_tree_node_t *node, 294 const char *dtype, ofw_tree_walker_t walker, void *arg) 295 { 296 ofw_tree_node_t *cur; 297 276 * @param node Root of the subtree. 277 * @param path Current path, NULL for the very root of the entire tree. 278 */ 279 static void ofw_tree_node_print(const ofw_tree_node_t *node, const char *path) 280 { 281 char *p; 282 const ofw_tree_node_t *cur; 283 284 p = (char *) malloc(PATH_MAX_LEN, 0); 285 298 286 for (cur = node; cur; cur = cur->peer) { 299 ofw_tree_property_t *prop = 300 ofw_tree_getprop(cur, "device_type"); 301 302 if ((prop) && (prop->value) && (str_cmp(prop->value, dtype) == 0)) { 303 bool ret = walker(cur, arg); 304 if (!ret) 305 return false; 306 } 307 308 if (cur->child) { 309 bool ret = 310 ofw_tree_walk_by_device_type_internal(cur->child, dtype, walker, arg); 311 if (!ret) 312 return false; 313 } 314 } 315 316 return true; 317 } 318 319 /** Walk the OpenFirmware device tree and find devices by type. 320 * 321 * Walk the whole OpenFirmware device tree and if any node has 322 * the property "device_type" equal to dtype, run a walker on it. 323 * If the walker returns false, the walk does not continue. 324 * 325 * @param dtype Device type to look for. 326 * @param walker Routine to be invoked on found device. 327 * @param arg User argument to the walker. 328 * 329 */ 330 void ofw_tree_walk_by_device_type(const char *dtype, ofw_tree_walker_t walker, 331 void *arg) 332 { 333 (void) ofw_tree_walk_by_device_type_internal(ofw_root, dtype, walker, arg); 334 } 335 336 /** Print OpenFirmware device subtree rooted in a node. 337 * 338 * Child nodes are processed recursively and peer nodes are processed 339 * iteratively in order to avoid stack overflow. 340 * 341 * @param node Root of the subtree. 342 * @param path Current path, NULL for the very root of the entire tree. 343 * 344 */ 345 static void ofw_tree_node_print(ofw_tree_node_t *node, const char *path) 346 { 347 char *cur_path = (char *) malloc(PATH_MAX_LEN, 0); 348 ofw_tree_node_t *cur; 349 350 for (cur = node; cur; cur = cur->peer) { 351 if ((cur->parent) && (path)) { 352 snprintf(cur_path, PATH_MAX_LEN, "%s/%s", path, cur->da_name); 353 printf("%s\n", cur_path); 287 if (cur->parent) { 288 snprintf(p, PATH_MAX_LEN, "%s/%s", path, cur->da_name); 289 printf("%s\n", p); 354 290 } else { 355 snprintf( cur_path, PATH_MAX_LEN, "%s", cur->da_name);291 snprintf(p, PATH_MAX_LEN, "%s", cur->da_name); 356 292 printf("/\n"); 357 293 } 358 294 359 295 if (cur->child) 360 ofw_tree_node_print(cur->child, cur_path);361 } 362 363 free( cur_path);296 ofw_tree_node_print(cur->child, p); 297 } 298 299 free(p); 364 300 } 365 301 -
kernel/genarch/src/ofw/pci.c
rbc7d44c r207e208e 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/pci.h>40 39 #include <arch/drivers/pci.h> 41 40 #include <arch/trap/interrupt.h> -
kernel/genarch/src/ofw/sbus.c
rbc7d44c r207e208e 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/sbus.h>40 39 #include <macros.h> 41 40 -
kernel/genarch/src/ofw/upa.c
rbc7d44c r207e208e 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <genarch/ofw/upa.h>40 39 #include <arch/memstr.h> 41 40 #include <func.h> -
kernel/generic/include/console/chardev.h
rbc7d44c r207e208e 36 36 #define KERN_CHARDEV_H_ 37 37 38 #include <adt/list.h>39 38 #include <arch/types.h> 40 39 #include <synch/waitq.h> … … 76 75 } outdev_operations_t; 77 76 78 /** Character output device. */77 /** Character input device. */ 79 78 typedef struct outdev { 80 79 char *name; … … 82 81 /** Protects everything below. */ 83 82 SPINLOCK_DECLARE(lock); 84 85 /** Fields suitable for multiplexing. */86 link_t link;87 link_t list;88 83 89 84 /** Implementation of outdev operations. */ -
kernel/generic/include/console/console.h
rbc7d44c r207e208e 44 44 45 45 extern indev_t *stdin_wire(void); 46 extern void stdout_wire(outdev_t *outdev);47 46 extern void console_init(void); 48 47 -
kernel/generic/src/console/chardev.c
rbc7d44c r207e208e 33 33 */ 34 34 35 #include <adt/list.h>36 35 #include <console/chardev.h> 37 36 #include <synch/waitq.h> … … 135 134 outdev->name = name; 136 135 spinlock_initialize(&outdev->lock, "outdev"); 137 link_initialize(&outdev->link);138 list_initialize(&outdev->list);139 136 outdev->op = op; 140 137 } -
kernel/generic/src/console/console.c
rbc7d44c r207e208e 76 76 static parea_t klog_parea; 77 77 78 static indev_t stdin_sink;79 static outdev_t stdout_source;80 81 78 static indev_operations_t stdin_ops = { 82 79 .poll = NULL 83 80 }; 84 81 85 static void stdout_write(outdev_t *dev, wchar_t ch, bool silent);86 87 static outdev_operations_t stdout_ops = {88 .write = stdout_write89 };90 91 82 /** Silence output */ 92 83 bool silent = false; … … 99 90 { 100 91 if (stdin == NULL) { 101 indev_initialize("stdin", &stdin_sink, &stdin_ops); 102 stdin = &stdin_sink; 92 stdin = malloc(sizeof(indev_t), FRAME_ATOMIC); 93 if (stdin != NULL) 94 indev_initialize("stdin", stdin, &stdin_ops); 103 95 } 104 96 105 97 return stdin; 106 }107 108 void stdout_wire(outdev_t *outdev)109 {110 if (stdout == NULL) {111 outdev_initialize("stdout", &stdout_source, &stdout_ops);112 stdout = &stdout_source;113 }114 115 list_append(&outdev->link, &stdout->list);116 }117 118 static void stdout_write(outdev_t *dev, wchar_t ch, bool silent)119 {120 link_t *cur;121 122 for (cur = dev->list.next; cur != &dev->list; cur = cur->next) {123 outdev_t *sink = list_get_instance(cur, outdev_t, link);124 sink->op->write(sink, ch, silent);125 }126 98 } 127 99
Note:
See TracChangeset
for help on using the changeset viewer.