Changeset 4872160 in mainline for boot/arch/sparc64
- Timestamp:
- 2010-05-04T10:44:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 568db0f
- Parents:
- bb252ca
- Location:
- boot/arch/sparc64
- Files:
-
- 2 added
- 9 deleted
- 1 edited
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/Makefile.inc
rbb252ca r4872160 27 27 # 28 28 29 include Makefile.common 29 BOOT_OUTPUT = image.boot 30 POST_OUTPUT = $(ROOT_PATH)/image.iso 31 POSTBUILD = Makefile.silo 30 32 31 ifeq ($(CONFIG_AOUT_ISOFS_B),y) 32 SILO_PACKAGE = silo.tar.gz 33 else 34 SILO_PACKAGE = silo.patched.tar.gz 35 endif 33 BFD_NAME = elf64-sparc 34 BFD_OUTPUT = $(BFD_NAME) 35 BFD_ARCH = sparc 36 36 37 build: $(BASE)/image.iso 37 BITS = 64 38 ENDIANESS = BE 39 PAGE_SIZE = 16384 40 EXTRA_CFLAGS = -mcpu=ultrasparc -m64 -mno-fpu 38 41 39 $(BASE)/image.iso: arch/$(BARCH)/loader/image.boot 40 mkdir -p $(TMP)/boot 41 mkdir -p $(TMP)/HelenOS 42 cat arch/$(BARCH)/silo/$(SILO_PACKAGE) | (cd $(TMP)/boot; tar xvfz -) 43 cp arch/$(BARCH)/silo/README arch/$(BARCH)/silo/COPYING $(TMP)/boot 44 ifeq ($(CONFIG_RD_EXTERNAL),y) 45 cp arch/$(BARCH)/silo/silo.conf $(TMP)/boot/silo.conf 46 else 47 cat arch/$(BARCH)/silo/silo.conf | grep -v initrd > $(TMP)/boot/silo.conf 48 endif 49 cp arch/$(BARCH)/loader/image.boot $(TMP)/HelenOS/image.boot 50 gzip -f $(TMP)/HelenOS/image.boot 51 ifeq ($(CONFIG_RD_EXTERNAL),y) 52 cp arch/$(BARCH)/loader/initrd.img $(TMP)/HelenOS/initrd.img 53 endif 54 mkisofs -f -G $(TMP)/boot/isofs.b -B ... -r -o $@ $(TMP)/ 42 RD_SRVS += \ 43 $(USPACE_PATH)/srv/hw/cir/fhc/fhc \ 44 $(USPACE_PATH)/srv/hw/cir/obio/obio 55 45 56 arch/$(BARCH)/loader/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG) 57 $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK) 58 59 clean: generic_clean 60 $(MAKE) -C arch/$(BARCH)/loader clean 61 rm -fr $(TMP) 62 rm -f $(BASE)/image.iso 46 SOURCES = \ 47 arch/$(BARCH)/src/asm.S \ 48 arch/$(BARCH)/src/main.c \ 49 arch/$(BARCH)/src/ofw.c \ 50 $(COMPS_C) \ 51 genarch/src/ofw.c \ 52 genarch/src/ofw_tree.c \ 53 generic/src/balloc.c \ 54 generic/src/printf_core.c \ 55 generic/src/vprintf.c \ 56 generic/src/printf.c \ 57 generic/src/str.c \ 58 generic/src/version.c \ 59 generic/src/inflate.c -
boot/arch/sparc64/_link.ld.in
rbb252ca r4872160 2 2 3 3 SECTIONS { 4 .boot 0xbfc00000: AT (0) { 4 . = 0x4000; 5 .boot : { 5 6 *(BOOTSTRAP); 6 7 *(.text); 7 8 9 *(.data); /* initialized data */ 8 10 *(.rodata); 9 11 *(.rodata.*); 10 *(.data); /* initialized data */11 12 *(.sdata); 12 *(. sdata2);13 *(.reginfo); 13 14 *(.sbss); 14 *(.scommon);15 15 *(.bss); /* uninitialized static variables */ 16 16 *(COMMON); /* global variables */ 17 *(.reginfo);18 17 [[COMPONENTS]] 19 18 } 19 20 /DISCARD/ : { 21 *(.gnu.*); 22 *(.mdebug*); 23 *(.pdr); 24 *(.comment); 25 *(.note.*); 26 } 20 27 } -
boot/arch/sparc64/include/asm.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 2006 Martin Decky 2 3 * Copyright (c) 2006 Jakub Jermar 3 4 * All rights reserved. … … 27 28 */ 28 29 29 #ifndef BOOT_sparc64_ REGISTER_H_30 #define BOOT_sparc64_ REGISTER_H_30 #ifndef BOOT_sparc64_ASM_H_ 31 #define BOOT_sparc64_ASM_H_ 31 32 32 #define PSTATE_IE_BIT 2 33 #define PSTATE_PRIV_BIT 4 34 #define PSTATE_AM_BIT 8 33 #include <typedefs.h> 35 34 36 #define ASI_ICBUS_CONFIG 0x4a 37 #define ICBUS_CONFIG_MID_SHIFT 17 35 extern void jump_to_kernel(void *entry, bootinfo_t *bootinfo, 36 uintptr_t physmem_start, uint8_t subarch) __attribute__((noreturn)); 38 37 39 38 #endif -
boot/arch/sparc64/include/main.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 6Martin Decky2 * Copyright (c) 2005 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_ mips32_TYPES_H_30 #define BOOT_ mips32_TYPES_H_29 #ifndef BOOT_sparc64_MAIN_H_ 30 #define BOOT_sparc64_MAIN_H_ 31 31 32 #include <gentypes.h> 32 #include <typedefs.h> 33 #include <balloc.h> 34 #include <genarch/ofw_tree.h> 33 35 34 typedef signed char int8_t; 36 typedef struct { 37 uintptr_t physmem_start; 38 taskmap_t taskmap; 39 memmap_t memmap; 40 ballocs_t ballocs; 41 ofw_tree_node_t *ofw_root; 42 } bootinfo_t; 35 43 36 typedef unsigned char uint8_t; 37 typedef unsigned short uint16_t; 38 typedef unsigned int uint32_t; 39 typedef unsigned long long uint64_t; 40 41 typedef uint32_t uintptr_t; 42 typedef uint32_t unative_t; 44 extern void bootstrap(void); 43 45 44 46 #endif -
boot/arch/sparc64/include/ofw.h
rbb252ca r4872160 27 27 */ 28 28 29 #ifndef BOOT_sparc64_OFW ARCH_H_30 #define BOOT_sparc64_OFW ARCH_H_29 #ifndef BOOT_sparc64_OFW_H_ 30 #define BOOT_sparc64_OFW_H_ 31 31 32 #include "main.h" 33 #include "types.h" 32 #include <typedefs.h> 34 33 35 34 #define OFW_ADDRESS_CELLS 2 36 35 #define OFW_SIZE_CELLS 2 37 36 38 extern int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start);39 extern int ofw_get_physmem_start(uintptr_t *start);37 extern uintptr_t ofw_get_physmem_start(void); 38 extern void ofw_cpu(uint16_t, uintptr_t); 40 39 41 40 #endif -
boot/arch/sparc64/include/types.h
rbb252ca r4872160 30 30 #define BOOT_sparc64_TYPES_H_ 31 31 32 #include <gentypes.h> 32 #define TASKMAP_MAX_RECORDS 32 33 #define BOOTINFO_TASK_NAME_BUFLEN 32 33 34 34 typedef signed char int8_t; 35 36 typedef unsigned char uint8_t; 37 typedef unsigned short uint16_t; 38 typedef unsigned int uint32_t; 39 typedef unsigned long uint64_t; 40 35 typedef uint64_t size_t; 41 36 typedef uint64_t uintptr_t; 42 37 typedef uint64_t unative_t; 38 typedef int64_t native_t; 39 40 typedef struct { 41 void *addr; 42 size_t size; 43 char name[BOOTINFO_TASK_NAME_BUFLEN]; 44 } task_t; 45 46 typedef struct { 47 size_t cnt; 48 task_t tasks[TASKMAP_MAX_RECORDS]; 49 } taskmap_t; 43 50 44 51 #endif -
boot/arch/sparc64/src/asm.S
rbb252ca r4872160 1 1 # 2 2 # Copyright (c) 2006 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 <stack.h> 31 #include <register.h> 30 #include <arch/arch.h> 31 32 #define ICACHE_SIZE 8192 33 #define ICACHE_LINE_SIZE 32 34 #define ICACHE_SET_BIT (1 << 13) 35 #define ASI_ICACHE_TAG 0x67 32 36 33 37 .register %g2, #scratch 34 38 .register %g3, #scratch 35 36 .text 37 39 .register %g6, #scratch 40 .register %g7, #scratch 41 42 .global start 38 43 .global halt 39 44 .global memcpy 40 45 .global jump_to_kernel 41 46 47 .section BOOTSTRAP, "ax" 48 49 start: 50 ba %xcc, 1f 51 nop 52 53 /* 54 * This header forces SILO to load the image at 0x4000. 55 * More precisely, SILO will think this is an old version of Linux. 56 */ 57 .ascii "HdrS" 58 .word 0 59 .half 0 60 .half 0 61 .half 0 62 .half 0 63 .word 0 64 .word 0 65 66 .align 8 67 1: 68 ! Disable interrupts and disable address masking. 69 70 wrpr %g0, PSTATE_PRIV_BIT, %pstate 71 72 wrpr %g0, NWINDOWS - 2, %cansave ! Set maximum saveable windows 73 wrpr %g0, 0, %canrestore ! Get rid of windows we will never need again 74 wrpr %g0, 0, %otherwin ! Make sure the window state is consistent 75 wrpr %g0, NWINDOWS - 1, %cleanwin ! Prevent needless clean_window traps for kernel 76 77 set initial_stack, %sp 78 add %sp, -STACK_BIAS, %sp 79 80 set ofw_cif, %l0 81 82 ! Initialize OpenFirmware 83 84 call ofw_init 85 stx %o4, [%l0] 86 87 ba %xcc, bootstrap 88 nop 89 90 .align STACK_ALIGNMENT 91 .space STACK_SIZE 92 initial_stack: 93 .space STACK_WINDOW_SAVE_AREA_SIZE 94 95 .text 96 42 97 halt: 43 98 ba %xcc, halt … … 45 100 46 101 memcpy: 47 mov %o0, %o3 ! save dst 102 ! Save dst 103 104 mov %o0, %o3 48 105 add %o1, 7, %g1 49 106 and %g1, -8, %g1 … … 66 123 67 124 2: 68 jmp %o7 + 8 ! exit point 125 ! Exit point 126 127 jmp %o7 + 8 69 128 mov %o3, %o0 70 129 … … 104 163 mov %g2, %g3 105 164 106 jmp %o7 + 8 ! exit point 165 ! Exit point 166 167 jmp %o7 + 8 107 168 mov %o3, %o0 108 169 109 170 jump_to_kernel: 110 171 /* 111 * We have copied code and now we need to guarantee cache coherence.172 * Guarantee cache coherence: 112 173 * 1. Make sure that the code we have moved has drained to main memory. 113 174 * 2. Invalidate I-cache. … … 115 176 */ 116 177 117 #if defined (SUN4U)118 178 /* 119 179 * US3 processors have a write-invalidate cache, so explicitly 120 180 * invalidating it is not required. Whether to invalidate I-cache 121 * or not is decided according to the value of the 5thargument122 * (subarch itecture).181 * or not is decided according to the value of the 3rd argument 182 * (subarch). 123 183 */ 124 cmp %i 4,3184 cmp %i2, SUBARCH_US3 125 185 be %xcc, 1f 126 186 nop … … 129 189 call icache_flush 130 190 nop 131 #endif191 132 192 1: 133 193 membar #StoreStore … … 138 198 flush %i7 139 199 200 ! Jump to kernel 140 201 mov %o0, %l1 141 202 mov %o1, %o0 142 mov %o2, %o1 143 mov %o3, %o2 144 jmp %l1 ! jump to kernel 145 nop 146 147 #define ICACHE_SIZE 8192 148 #define ICACHE_LINE_SIZE 32 149 #define ICACHE_SET_BIT (1 << 13) 150 #define ASI_ICACHE_TAG 0x67 203 mov %o3, %o1 204 205 jmp %l1 206 nop 151 207 152 208 # Flush I-cache … … 163 219 membar #Sync 164 220 retl 221 165 222 ! SF Erratum #51 223 166 224 nop 167 225 … … 172 230 ldx [%l0], %l0 173 231 174 rdpr 175 and 176 wrpr 232 rdpr %pstate, %l1 233 and %l1, ~PSTATE_AM_BIT, %l2 234 wrpr %l2, 0, %pstate 177 235 178 236 jmpl %l0, %o7 -
boot/arch/sparc64/src/ofw.c
rbb252ca r4872160 33 33 */ 34 34 35 #include <ofwarch.h> 36 #include <ofw.h> 35 #include <arch/arch.h> 36 #include <arch/ofw.h> 37 #include <genarch/ofw.h> 38 #include <typedefs.h> 37 39 #include <printf.h> 38 #include <string.h> 39 #include <register.h> 40 #include "main.h" 41 #include "asm.h" 40 #include <halt.h> 41 #include <putchar.h> 42 #include <str.h> 42 43 43 void write(const char *str, const int len)44 void putchar(const wchar_t ch) 44 45 { 45 int i; 46 if (ch == '\n') 47 ofw_putchar('\r'); 46 48 47 for (i = 0; i < len; i++) { 48 if (str[i] == '\n') 49 ofw_write("\r", 1); 50 ofw_write(&str[i], 1); 51 } 49 if (ascii_check(ch)) 50 ofw_putchar(ch); 51 else 52 ofw_putchar(U_SPECIAL); 52 53 } 53 54 54 int ofw_translate_failed(ofw_arg_t flag) 55 { 56 return flag != -1; 57 } 58 59 /** 60 * Starts all CPUs represented by following siblings of the given node, 61 * except for the current CPU. 55 /** Start all CPUs represented by following siblings of the given node. 56 * 57 * Except for the current CPU. 62 58 * 63 59 * @param child The first child of the OFW tree node whose children … … 71 67 * 72 68 */ 73 static int wake_cpus_in_node(phandle child, uint64_t current_mid,69 static size_t wake_cpus_in_node(phandle child, uint64_t current_mid, 74 70 uintptr_t physmem_start) 75 71 { 76 int cpus;72 size_t cpus; 77 73 78 for (cpus = 0; (child != 0) && (child != -1);74 for (cpus = 0; (child != 0) && (child != (phandle) -1); 79 75 child = ofw_get_peer_node(child), cpus++) { 80 76 char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN]; … … 83 79 OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) { 84 80 type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0; 85 if (strcmp(type_name, "cpu") == 0) { 81 82 if (str_cmp(type_name, "cpu") == 0) { 86 83 uint32_t mid; 87 84 … … 100 97 */ 101 98 (void) ofw_call("SUNW,start-cpu", 3, 1, 102 NULL, child, KERNEL_ VIRTUAL_ADDRESS,99 NULL, child, KERNEL_ADDRESS, 103 100 physmem_start | AP_PROCESSOR); 104 101 } … … 110 107 } 111 108 112 /** 113 * Finds out the current CPU's MID and wakes up all AP processors.109 /** Find out the current CPU's MID and wake up all AP processors. 110 * 114 111 */ 115 intofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)112 void ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start) 116 113 { 117 114 /* Get the current CPU MID */ … … 119 116 120 117 asm volatile ( 121 "ldxa [%1] %2, %0\n" 122 : "=r" (current_mid) 123 : "r" (0), "i" (ASI_ICBUS_CONFIG) 118 "ldxa [%[zero]] %[asi], %[current_mid]\n" 119 : [current_mid] "=r" (current_mid) 120 : [zero] "r" (0), 121 [asi] "i" (ASI_ICBUS_CONFIG) 124 122 ); 125 123 … … 130 128 131 129 phandle cpus_parent = ofw_find_device("/ssm@0,0"); 132 if ((cpus_parent == 0) || (cpus_parent == -1))130 if ((cpus_parent == 0) || (cpus_parent == (phandle) -1)) 133 131 cpus_parent = ofw_find_device("/"); 134 132 135 133 phandle node = ofw_get_child_node(cpus_parent); 136 int cpus = wake_cpus_in_node(node, current_mid, physmem_start); 137 while ((node != 0) && (node != -1)) { 134 size_t cpus = wake_cpus_in_node(node, current_mid, physmem_start); 135 136 while ((node != 0) && (node != (phandle) -1)) { 138 137 char name[OFW_TREE_PROPERTY_MAX_VALUELEN]; 139 138 … … 141 140 OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) { 142 141 name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0; 143 if (strcmp(name, "cmp") == 0) { 142 143 if (str_cmp(name, "cmp") == 0) { 144 144 phandle subnode = ofw_get_child_node(node); 145 145 cpus += wake_cpus_in_node(subnode, 146 146 current_mid, physmem_start); 147 147 } 148 148 } 149 149 150 node = ofw_get_peer_node(node); 150 151 } 151 152 152 return cpus; 153 if (cpus == 0) 154 printf("Warning: Unable to get CPU properties.\n"); 153 155 } 154 156 155 157 /** Get physical memory starting address. 156 158 * 157 * @param start Pointer to variable where the physical memory starting 158 * address will be stored. 159 * 160 * @return Non-zero on succes, zero on failure. 159 * @return Physical memory starting address. 161 160 * 162 161 */ 163 int ofw_get_physmem_start(uintptr_t *start)162 uintptr_t ofw_get_physmem_start(void) 164 163 { 165 164 uint32_t memreg[4]; 166 if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0) 167 return 0; 165 if ((ofw_ret_t) ofw_get_property(ofw_memory, "reg", &memreg, 166 sizeof(memreg)) <= 0) { 167 printf("Error: Unable to get physical memory starting address, halting.\n"); 168 halt(); 169 } 168 170 169 *start = (((uint64_t) memreg[0]) << 32) | memreg[1]; 170 return 1; 171 return ((((uintptr_t) memreg[0]) << 32) | memreg[1]); 171 172 }
Note:
See TracChangeset
for help on using the changeset viewer.