Changeset 412 for trunk/softs
- Timestamp:
- Jun 17, 2013, 7:10:20 PM (11 years ago)
- Location:
- trunk/softs/tsar_boot
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/conf/platform_fpga_de2-115/defs_platform.h
r399 r412 7 7 #define CACHE_LINE_SIZE 64//bytes 8 8 9 #define INSTRUMENTATION 0 9 #define BOOT_DEBUG 0 10 #define BOOT_DEBUG_IOC 0 10 11 11 12 #define IOC_BASE 0xFB000000 12 #define VCIBD_BASE 0xFB00000013 13 #define TTY_BASE 0xFC000000 14 14 #define ICU_BASE 0xFD000000 -
trunk/softs/tsar_boot/conf/platform_vgsb_xicu_mmu/defs_platform.h
r347 r412 9 9 #define ICU_BASE 0x00F00000 10 10 #define IOC_BASE 0x00F10000 11 #define VCIBD_BASE IOC_BASE12 11 #define TTY_BASE 0x00F20000 -
trunk/softs/tsar_boot/include/boot_ioc.h
r388 r412 15 15 /** 16 16 * boot_ioc_read() 17 * 17 * 18 18 * Transfer data from a file on the block device to a memory buffer. 19 19 * -
trunk/softs/tsar_boot/src/boot_elf_loader.c
r388 r412 37 37 unsigned int i; 38 38 unsigned int segment_req; 39 39 40 40 /* 41 41 * Loader state machine definition 42 */ 42 */ 43 43 enum 44 44 { … … 48 48 ELF_SEGMENT_STATE, 49 49 ELF_END_STATE 50 } init_state; 50 } init_state 51 #if (BOOT_DEBUG ==1) 52 , init_state_debug 53 #endif 54 ; 55 56 #if (BOOT_DEBUG == 1) 57 char* init_state_str[] = { 58 "ELF_HEADER_STATE", 59 "ELF_PROGRAM_HEADER_STATE", 60 "ELF_OFFSET_STATE", 61 "ELF_SEGMENT_STATE", 62 "ELF_END_STATE" 63 }; 64 #endif 65 51 66 52 67 boot_puts("Starting boot_elf_loader function...\n\r"); … … 63 78 64 79 init_state = ELF_HEADER_STATE; 80 #if (BOOT_DEBUG == 1) 81 init_state_debug = ELF_END_STATE; 82 #endif 65 83 66 84 while(init_state != ELF_END_STATE) … … 88 106 offset += nb_read; 89 107 108 #if (BOOT_DEBUG == 1) 109 if (init_state != init_state_debug) 110 { 111 boot_puts("init_state = "); 112 boot_puts(init_state_str[init_state]); 113 boot_puts("\n"); 114 init_state_debug = init_state; 115 } 116 #endif 117 90 118 switch(init_state) 91 119 { … … 113 141 "Input file does not use ELF format" 114 142 "\n" 115 ); 143 ); 116 144 117 145 boot_exit(); 118 146 } 119 147 120 /* 148 /* 121 149 * Verification of Program Headers table size. It must be 122 * smaller than the work size allocated for the 150 * smaller than the work size allocated for the 123 151 * elf_pht[PHDR_ARRAY_SIZE] array 124 152 **/ … … 142 170 /** 143 171 * Reading ELF program headers 144 */ 172 */ 145 173 case ELF_PROGRAM_HEADER_STATE: 146 174 boot_memcpy(elf_pht_ptr, buffer_ptr, nb_read); … … 160 188 if(elf_pht_ptr[pseg].p_type == PT_LOAD) 161 189 { 162 nb_rest = elf_pht_ptr[pseg].p_offset - offset; 190 #if (BOOT_DEBUG == 1) 191 boot_puts("found a loadable segment:\n"); 192 boot_puts("- type : "); boot_putx(elf_pht_ptr[pseg].p_type); boot_puts("\n"); 193 boot_puts("- offset : "); boot_putx(elf_pht_ptr[pseg].p_offset); boot_puts("\n"); 194 boot_puts("- vaddr : "); boot_putx(elf_pht_ptr[pseg].p_vaddr); boot_puts("\n"); 195 boot_puts("- paddr : "); boot_putx(elf_pht_ptr[pseg].p_paddr); boot_puts("\n"); 196 boot_puts("- filesz : "); boot_putx(elf_pht_ptr[pseg].p_filesz); boot_puts("\n"); 197 boot_puts("- memsz : "); boot_putx(elf_pht_ptr[pseg].p_memsz); boot_puts("\n"); 198 boot_puts("- flags : "); boot_putx(elf_pht_ptr[pseg].p_flags); boot_puts("\n"); 199 boot_puts("- align : "); boot_putx(elf_pht_ptr[pseg].p_align); boot_puts("\n"); 200 #endif 201 if (elf_pht_ptr[pseg].p_offset < offset) 202 { 203 /* case where the segment to load includes the elf and program headers */ 204 nb_rest = elf_pht_ptr[pseg].p_filesz - offset; 205 init_state = ELF_SEGMENT_STATE; 206 } 207 else 208 { 209 /* segment to load is further away in memory */ 210 nb_rest = elf_pht_ptr[pseg].p_offset - offset; 211 init_state = ELF_OFFSET_STATE; 212 } 163 213 break; 164 214 } 165 215 } 166 216 167 init_state = ELF_OFFSET_STATE; 217 if (pseg == elf_header_ptr->e_phnum) 218 { 219 boot_puts( 220 "ERROR: " 221 "No PT_LOAD found" 222 "\n" 223 ); 224 boot_exit(); 225 } 226 168 227 } 169 228 … … 191 250 * Copying ELF segment data in memory segments using the virtual 192 251 * address got from the ELF file 193 */ 252 */ 194 253 segment_req = ((elf_pht_ptr[pseg].p_vaddr & 0xBFC00000) != 0xBFC00000); 195 254 … … 201 260 nb_read); 202 261 } 203 262 204 263 nb_rest -= nb_read; 205 264 … … 237 296 /* 238 297 * Program loading finished 239 */ 298 */ 240 299 if(pseg == elf_header_ptr->e_phnum) 241 300 { -
trunk/softs/tsar_boot/src/boot_ioc.c
r388 r412 21 21 } 22 22 23 #if INSTRUMENTATION23 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 24 24 inline unsigned int boot_proctime() 25 25 { … … 28 28 return ret; 29 29 } 30 #endif // end if INSTRUMENTATION30 #endif 31 31 32 32 #ifndef SOCLIB_IOC … … 47 47 SPI_TX_NEGEDGE, 48 48 SPI_RX_POSEDGE 49 ); 49 ); 50 50 51 51 /** … … 53 53 */ 54 54 unsigned int iter = 0; 55 while(1) 55 while(1) 56 56 { 57 57 boot_puts("Trying to initialize SD card... "); … … 118 118 119 119 120 unsigned int * ioc_address = ( unsigned int * ) VCIBD_BASE;121 120 unsigned int * ioc_address = ( unsigned int * )IOC_BASE; 121 122 122 while ( 1 ) 123 { 123 { 124 124 status = ioread32(&ioc_address[BLOCK_DEVICE_STATUS]); 125 125 … … 128 128 break; 129 129 } 130 130 131 131 return status; 132 132 } … … 135 135 /** 136 136 * boot_ioc_read() 137 * 137 * 138 138 * Transfer data from a file on the block device to a memory buffer. 139 139 * … … 153 153 { 154 154 155 unsigned int * ioc_address = (unsigned int*)VCIBD_BASE; 156 157 // block_device configuration 158 iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER], 159 ( unsigned int ) buffer ); 160 161 iowrite32( &ioc_address[BLOCK_DEVICE_COUNT], 162 ( unsigned int ) count ); 163 164 iowrite32( &ioc_address[BLOCK_DEVICE_LBA], 165 ( unsigned int ) lba ); 166 167 iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE], 168 ( unsigned int ) 0 ); 169 170 iowrite32( &ioc_address[BLOCK_DEVICE_OP], 171 ( unsigned int ) BLOCK_DEVICE_READ ); 172 173 _boot_ioc_completed(); 174 175 #if (CACHE_COHERENCE == 0) 176 boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512); 177 #endif 178 return 0; 179 } 180 181 #else 182 183 /////////////////////////////////////////////////////////////////////////////// 184 // FPGA version of the boot_ioc_read function 185 186 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 187 { 188 unsigned int sdcard_rsp; 189 unsigned int i; 190 191 sdcard_dev_lseek(&_sdcard_device, lba); 192 193 #if INSTRUMENTATION 155 unsigned int * ioc_address = (unsigned int*)IOC_BASE; 156 157 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 194 158 unsigned int start_time; 195 159 unsigned int end_time; … … 202 166 #endif 203 167 168 // block_device configuration 169 iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER], 170 ( unsigned int ) buffer ); 171 172 iowrite32( &ioc_address[BLOCK_DEVICE_COUNT], 173 ( unsigned int ) count ); 174 175 iowrite32( &ioc_address[BLOCK_DEVICE_LBA], 176 ( unsigned int ) lba ); 177 178 iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE], 179 ( unsigned int ) 0 ); 180 181 iowrite32( &ioc_address[BLOCK_DEVICE_OP], 182 ( unsigned int ) BLOCK_DEVICE_READ ); 183 184 _boot_ioc_completed(); 185 186 #if (CACHE_COHERENCE == 0) 187 boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512); 188 #endif 189 190 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 191 end_time = boot_proctime(); 192 193 boot_puts(" / cycles for transfert: "); 194 boot_putd(end_time - start_time); 195 boot_puts("\n"); 196 #endif 197 198 return 0; 199 } 200 201 #else 202 203 /////////////////////////////////////////////////////////////////////////////// 204 // FPGA version of the boot_ioc_read function 205 206 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 207 { 208 unsigned int sdcard_rsp; 209 unsigned int i; 210 211 sdcard_dev_lseek(&_sdcard_device, lba); 212 213 #if (BOOT_DEBUG ==1 && BOOT_DEBUG_IOC == 1) 214 unsigned int start_time; 215 unsigned int end_time; 216 boot_puts("[ DEBUG ] Reading blocks "); 217 boot_putd(lba); 218 boot_puts(" to "); 219 boot_putd(lba + count - 1); 220 221 start_time = boot_proctime(); 222 #endif 223 204 224 for(i = 0; i < count; i++) 205 225 { … … 208 228 (unsigned char *) buffer + (512 * i), 209 229 512 210 ) 230 ) 211 231 )) 212 232 { 213 boot_puts("ERROR during read on the SDCARD device. Code: "); 233 boot_puts("ERROR during read on the SDCARD device. Code: "); 214 234 boot_putx(sdcard_rsp); 215 235 boot_puts("\n\r"); … … 219 239 } 220 240 221 #if INSTRUMENTATION241 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 222 242 end_time = boot_proctime(); 223 243 … … 234 254 * _dcache_buf_invalidate() 235 255 * 236 * Invalidate all data cache lines corresponding to a memory 256 * Invalidate all data cache lines corresponding to a memory 237 257 * buffer (identified by an address and a size). 238 258 */ … … 245 265 unsigned int i; 246 266 247 // iterate on cache lines 267 // iterate on cache lines 248 268 for (i = 0; i < size; i += line_size) { 249 269 asm volatile(
Note: See TracChangeset
for help on using the changeset viewer.