Changeset 755 for trunk/softs/tsar_boot
- Timestamp:
- Jul 23, 2014, 6:02:09 PM (10 years ago)
- Location:
- trunk/softs/tsar_boot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/include/defs.h
r705 r755 2 2 3 3 #define RESET_VERSION 0x00010002 4 #define RESET_STACK_SIZE 0x2000 4 5 5 6 #define BOOT_LOADER_LBA 2 -
trunk/softs/tsar_boot/src/reset.S
r704 r755 5 5 * 6 6 * This is a generic reset code for a generic multi-clusters / multi-processors 7 * TSAR architecture (up to 256 clusters / up to 4 7 * TSAR architecture (up to 256 clusters / up to 4 processors per cluster). 8 8 * 9 9 * There is one XICU, one TTY, one DMA, and one memory bank per cluster. 10 10 * 11 * This preloader uses a stack segment allocated in cluster 0, defined 12 * by the seg_reset_stack_base parameters in ldscript, of size 0x10000 (64k) 13 * - Processor 0 uses a larger stack: 64 Kbytes. 14 * - Other processors use a smaller stack: 256 bytes. 15 * => the seg_stack_size cannot be smaller than 0x50000 bytes (320 Kytes). 16 * (64K + 1024 * 256 = 320 Kbytes) 17 * Those stacks can be used by both the preloader and the boot-loader code. 18 * 11 * This preloader uses a stack segment allocated in cluster 0 for processor 0. 12 * The stack allocation is not performed for other processors as they do not 13 * need it during the preloader execution. Therefore, this allocation should be 14 * done by the loaded Operating System. 15 * 19 16 * The replicated XICU is used to awake the sleeping processors: 20 17 * xicu_paddr_base = ICU_PADDR_BASE + (cluster_xy << 32) 21 18 * 22 19 * It is intended to be used with various operating systems or nano kernels, 23 * including NetBSD, ALMOS, and GIET_VM.20 * including NetBSD, Linux, ALMOS, and GIET_VM. 24 21 * 25 22 * - Each processor initializes its Status Register (SR) to disable interrupts. 26 23 * - Each processor initializes its Count Register. 27 24 * - Each processor initialises its private XICU WTI mask register. 28 * - Each processor initializes its Stack Pointer. 29 * - Only processor 0 executes the reset_load_elf function to load into memory 30 * the system specific boot-loader stored on disk at BOOT_LOADER_LBA 25 * - Only processor 0 executes the reset_load_elf function to load into memory 26 * the system specific boot-loader stored on disk at BOOT_LOADER_LBA 31 27 * - All other processors wait in a low power consumption mode that the 32 28 * processor 0 wakes them using an IPI (Inter Processor Interruption) … … 37 33 38 34 /* These define should be consistent with values defined in map.xml file */ 39 40 .extern seg_reset_stack_base41 35 42 36 .section .reset,"ax",@progbits … … 61 55 62 56 reset: 63 b _reset /* 0xbfc0000 */64 nop /* 0xbfc0004 */57 b _reset /* 0xbfc0000 */ 58 nop /* 0xbfc0004 */ 65 59 66 60 /* Addresses of the functions provided by this reset code */ 67 61 68 62 preloader_vector: 69 .word RESET_VERSION /* 0xbfc0008 */70 .word dtb_addr /* 0xbfc000c */71 .word reset_putc /* 0xbfc0010 */72 .word reset_getc /* 0xbfc0014 */73 .word reset_ioc_read /* 0xbfc0018 */74 .word reset_elf_loader /* 0xbfc001C */75 .word memcpy /* 0xbfc0020 */76 .word reset_puts /* 0xbfc0024 */77 .word reset_putx /* 0xbfc0028 */78 .word reset_putd /* 0xbfc002C */63 .word RESET_VERSION /* 0xbfc0008 */ 64 .word dtb_addr /* 0xbfc000c */ 65 .word reset_putc /* 0xbfc0010 */ 66 .word reset_getc /* 0xbfc0014 */ 67 .word reset_ioc_read /* 0xbfc0018 */ 68 .word reset_elf_loader /* 0xbfc001C */ 69 .word memcpy /* 0xbfc0020 */ 70 .word reset_puts /* 0xbfc0024 */ 71 .word reset_putx /* 0xbfc0028 */ 72 .word reset_putd /* 0xbfc002C */ 79 73 80 74 _reset: … … 85 79 mtc0 k0, CP0_STATUS 86 80 87 /* All processors compute p roc_id, lpid, cluster_xy */81 /* All processors compute pid, lpid, cluster_xy */ 88 82 89 83 mfc0 k0, CP0_EBASE 90 andi t0, k0, 0x3FF /* t0 <= proc_id (at most 1024 processors)*/84 andi t0, k0, 0x3FF /* t0 <= pid (at most 1024 procs) */ 91 85 92 86 move t3, t0 93 87 94 la k0, NB_PROCS /* k0 <= number of processors per cluster*/88 la k0, NB_PROCS /* k0 <= # of processors per cluster */ 95 89 divu t3, k0 96 mfhi t1 /* t1 <= lpid = proc_id % NB_PROCS*/97 mflo t2 /* t2 <= cluster_xy = proc_id / NB_PROCS*/90 mfhi t1 /* t1 <= lpid = pid % NB_PROCS */ 91 mflo t2 /* t2 <= cluster_xy = pid / NB_PROCS */ 98 92 99 93 /* All processors initialise the count register in CP0 */ … … 102 96 103 97 /* 104 * All processors enable the WTI for XICU 98 * All processors enable the WTI for XICU 105 99 * Each processor may have IRQ_PER_PROC irq outputs from the XICU 106 * In each cluster, the XICU base address depends on the cluster_xy 107 */ 108 109 la t3, ICU_PADDR_BASE /* t3 <= ICU base address*/110 move t4, t1 /* t4 <= local_id*/111 li t5, IRQ_PER_PROC /* t5 <= IRQ_PER_PROC*/112 multu t4, t5 113 mflo t6 /* t6 <= IRQ_PER_PROC * local_id*/114 sll t4, t6, 2 /* t4 <= OUT_INDEX = t6 * 4*/115 116 li t5, (0xC << 7) /* t5 <= FUNC = XICU_MSK_WTI*/117 or t4, t4, t5 /* t4 <= FUNC | INDEX | 00*/118 or t5, t3, t4 /* t5 <= &XICU[MSK_WTI][OUT_INDEX]*/119 120 /* All processors set WTI mask using the physical address extension 100 * In each cluster, the XICU base address depends on the cluster_xy 101 */ 102 103 la t3, ICU_PADDR_BASE /* t3 <= ICU base address */ 104 move t4, t1 /* t4 <= local_id */ 105 li t5, IRQ_PER_PROC /* t5 <= IRQ_PER_PROC */ 106 multu t4, t5 107 mflo t6 /* t6 <= IRQ_PER_PROC * local_id */ 108 sll t4, t6, 2 /* t4 <= OUT_INDEX = t6 * 4 */ 109 110 li t5, (0xC << 7) /* t5 <= FUNC = XICU_MSK_WTI */ 111 or t4, t4, t5 /* t4 <= FUNC | INDEX | 00 */ 112 or t5, t3, t4 /* t5 <= &XICU[MSK_WTI][OUT_INDEX] */ 113 114 /* All processors set WTI mask using the physical address extension */ 121 115 122 116 li t4, 1 123 sllv t4, t4, t1 /* Set XICU[MSK_WTI][INDEX][local_id] */ 124 125 mtc2 t2, CP2_PADDR_EXT /* set PADDR extension */ 126 sw t4, 0(t5) /* XICU[MSK_WTI][INDEX] <= t4 */ 127 mtc2 zero, CP2_PADDR_EXT /* reset PADDR extension */ 128 129 /* All processors initializes stack pointer, depending on proc_id */ 130 131 la k0, seg_reset_stack_base 132 li k1, 0x10000 /* k1 <= P0 stack size == 64 Kbytes */ 133 addu sp, k0, k1 /* P0 stack from base to (base + 64K) */ 134 135 li k1, 0x200 /* k1 <= Pi stack size == 512 bytes */ 136 multu k1, t0 137 mflo k0 /* k0 <= 256 * proc_id */ 138 addu sp, sp, k1 139 addu sp, sp, k0 /* Pi stacks from base + 64K + proc_id*256 */ 140 141 /* 142 * Only processor 0 in cluster 0 loads and executes the boot-loader 117 sllv t4, t4, t1 /* Set XICU[MSK_WTI][INDEX][local_id] */ 118 119 mtc2 t2, CP2_PADDR_EXT /* set PADDR extension */ 120 sw t4, 0(t5) /* XICU[MSK_WTI][INDEX] <= t4 */ 121 mtc2 zero, CP2_PADDR_EXT /* reset PADDR extension */ 122 123 /* 124 * Only processor 0 in cluster 0 loads and executes the boot-loader 143 125 * We have: 144 * t0: global p roc_id145 * t1: local p roc_id126 * t0: global pid 127 * t1: local pid 146 128 * t2: cluster_xy 147 129 * t3: xicu physical base address in cluster 0 … … 151 133 nop 152 134 135 /* Processor 0 initializes stack pointer */ 136 137 la k0, _stack 138 li k1, RESET_STACK_SIZE /* k1 <= P0 stack size */ 139 addu sp, k0, k1 /* P0 stack from base to (base + size) */ 140 153 141 /* Processor 0 displays version for this reset code */ 154 142 155 143 la a0, versionstr 156 la 144 la k0, reset_puts 157 145 jalr k0 158 146 nop … … 170 158 171 159 /* 172 * Processor 0 jumps to the reset_elf_loader routine 173 * Passing as argumentthe block number in which is loaded the .elf file160 * Processor 0 jumps to the reset_elf_loader routine passing as argument 161 * the block number in which is loaded the .elf file 174 162 */ 175 163 … … 179 167 nop 180 168 181 /* 182 * Processor O jumps to the entry address defined in the .elf file, 183 * andreturned by reset_elf_loader function.184 * First argument is pointer to the preloader function vectors 185 * otherfunction arguments are 0186 */ 187 188 la 169 /* 170 * Processor O jumps to the entry address defined in the .elf file, and 171 * returned by reset_elf_loader function. 172 * First argument is pointer to the preloader function vectors other 173 * function arguments are 0 174 */ 175 176 la a0, preloader_vector 189 177 move a1, zero 190 178 move a2, zero … … 194 182 195 183 /* 196 * All processor (but processor 0) wait in low power mode 197 * until processor 0wakes them using an IPI.184 * All processor (but processor 0) wait in low power mode until processor 0 185 * wakes them using an IPI. 198 186 * We have: 199 187 * t0: global id … … 205 193 _reset_wait: 206 194 207 sll t4, t1, 2 /* t4 <= local_id * 4*/208 addu t5, t4, t3 /* t5 <= &XICU[WTI_REG][local_id]*/195 sll t4, t1, 2 /* t4 <= local_id * 4 */ 196 addu t5, t4, t3 /* t5 <= &XICU[WTI_REG][local_id] */ 209 197 210 198 wait 211 199 212 /* 213 * All other processors, when exiting wait mode, 214 * read from XICU the addressto jump.215 * This address is the boot-loader entry address that has been 216 * written inthe mailbox by the IPI sent by processor 0217 */ 218 219 mtc2 t2, CP2_PADDR_EXT /* set PADDR extension*/220 lw k0, 0(t5) /* k0 <= XICU[WTI_REG][local_id]*/221 mtc2 zero, CP2_PADDR_EXT /* reset PADDR extension*/200 /* 201 * All other processors, when exiting wait mode, read from XICU the address 202 * to jump. 203 * This address is the boot-loader entry address that has been written in 204 * the mailbox by the IPI sent by processor 0 205 */ 206 207 mtc2 t2, CP2_PADDR_EXT /* set PADDR extension */ 208 lw k0, 0(t5) /* k0 <= XICU[WTI_REG][local_id] */ 209 mtc2 zero, CP2_PADDR_EXT /* reset PADDR extension */ 222 210 223 211 jr k0 … … 228 216 .org 0x0380 229 217 _excep: 230 mfc0 a0, CP0_STATUS /* first arg is status*/231 mfc0 a1, CP0_CAUSE /* second arg is cause*/232 mfc0 a2, CP0_EPC /* third argc is epc*/233 mfc2 a3, CP2_DBVAR /* fourth argc is dbvar*/218 mfc0 a0, CP0_STATUS /* first arg is status */ 219 mfc0 a1, CP0_CAUSE /* second arg is cause */ 220 mfc0 a2, CP0_EPC /* third argc is epc */ 221 mfc2 a3, CP2_DBVAR /* fourth argc is dbvar */ 234 222 nop 235 223 j handle_except … … 239 227 240 228 .set reorder 229 230 .section .data 231 232 _stack: 233 234 .space RESET_STACK_SIZE 241 235 242 236 /*
Note: See TracChangeset
for help on using the changeset viewer.