Changeset 388 for trunk/softs/tsar_boot/src
- Timestamp:
- May 16, 2013, 3:01:37 PM (12 years ago)
- Location:
- trunk/softs/tsar_boot/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/src/boot_elf_loader.c
r292 r388 73 73 { 74 74 boot_puts ( 75 76 77 78 75 "ERROR: " 76 "IOC_FAILED" 77 "\n" 78 ); 79 79 80 80 boot_exit(); 81 81 } 82 82 83 83 nb_block += 1; 84 84 nb_available = 512; … … 102 102 nb_rest = elf_header_ptr->e_phnum * elf_header_ptr->e_phentsize; 103 103 104 105 106 107 108 109 110 111 112 113 114 115 ); 116 117 118 119 120 121 122 123 124 104 /* Verification of ELF Magic Number */ 105 if ( 106 (elf_header_ptr->e_ident[EI_MAG0] != ELFMAG0) || 107 (elf_header_ptr->e_ident[EI_MAG1] != ELFMAG1) || 108 (elf_header_ptr->e_ident[EI_MAG2] != ELFMAG2) || 109 (elf_header_ptr->e_ident[EI_MAG3] != ELFMAG3) ) 110 { 111 boot_puts( 112 "ERROR: " 113 "Input file does not use ELF format" 114 "\n" 115 ); 116 117 boot_exit(); 118 } 119 120 /* 121 * Verification of Program Headers table size. It must be 122 * smaller than the work size allocated for the 123 * elf_pht[PHDR_ARRAY_SIZE] array 124 **/ 125 125 if (elf_header_ptr->e_phnum > PHDR_ARRAY_SIZE) 126 126 { 127 127 boot_puts( 128 129 130 131 132 128 "ERROR: " 129 "ELF PHDR table size is bigger than " 130 "the allocated work space" 131 "\n" 132 ); 133 133 134 134 boot_exit(); … … 257 257 258 258 boot_puts ( 259 260 261 259 "Finishing boot_elf_loader function.\n" 260 "Entry point address: " 261 ); 262 262 boot_putx(elf_header_ptr->e_entry); 263 263 boot_puts("\n"); -
trunk/softs/tsar_boot/src/boot_ioc.c
r347 r388 2 2 3 3 #ifndef SOCLIB_IOC 4 5 static struct sdcard_dev _sdcard_device; 6 static struct spi_dev * _spi_device = ( struct spi_dev * )IOC_BASE; 4 7 5 8 #ifndef SYSCLK_FREQ 6 9 #warning "Using default value for SYSCLK_FREQ = 50000000" 7 10 #define SYSCLK_FREQ 50000000U 8 #endif 9 10 static struct sdcard_dev _sdcard_device; 11 static struct spi_dev * _spi_device = ( struct spi_dev * )IOC_BASE; 12 #endif 13 14 11 #endif // end ifndef SYSCLK_FREQ 12 13 #endif // end ifndef SOCLIB_IOC 14 15 #define SDCARD_RESET_ITER_MAX 4 16 17 inline void boot_sleep(int cycles) 18 { 19 int i; 20 for (i = 0; i < cycles; i++); 21 } 22 23 #if INSTRUMENTATION 24 inline unsigned int boot_proctime() 25 { 26 unsigned int ret; 27 asm volatile ("mfc0 %0, $9":"=r" (ret)); 28 return ret; 29 } 30 #endif // end if INSTRUMENTATION 31 32 #ifndef SOCLIB_IOC 15 33 int boot_ioc_init() 16 34 { 17 #ifdef SOCLIB_IOC18 return 0;19 #else20 35 unsigned char sdcard_rsp; 21 36 … … 37 52 * Initializing the SD Card 38 53 */ 39 if ( (sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0)) ) 40 return sdcard_rsp; 41 42 if ( (sdcard_rsp = sdcard_dev_set_blocklen(&_sdcard_device, 512)) ) 43 return sdcard_rsp; 54 unsigned int iter = 0; 55 while(1) 56 { 57 boot_puts("Trying to initialize SD card... "); 58 59 sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0); 60 if (sdcard_rsp == 0) 61 { 62 boot_puts("OK\n"); 63 break; 64 } 65 66 boot_puts("KO\n"); 67 boot_sleep(1000); 68 if (++iter >= SDCARD_RESET_ITER_MAX) 69 { 70 boot_puts("\nERROR: During SD card reset to IDLE state\n" 71 "/ card response = "); 72 boot_putx(sdcard_rsp); 73 boot_puts("\n"); 74 boot_exit(); 75 } 76 } 77 78 /** 79 * Set the block length of the SD Card 80 */ 81 sdcard_rsp = sdcard_dev_set_blocklen(&_sdcard_device, 512); 82 if (sdcard_rsp) 83 { 84 boot_puts("ERROR: During SD card blocklen initialization\n"); 85 boot_exit(); 86 } 44 87 45 88 /** … … 48 91 spi_dev_config ( 49 92 _spi_device , 50 10000000 , /**< SPI_clk L10 Mhz */51 SYSCLK_FREQ , /**< Sys_clk 52 -1 , /**< Charlen: 8 93 10000000 , /**< SPI_clk 10 Mhz */ 94 SYSCLK_FREQ , /**< Sys_clk */ 95 -1 , /**< Charlen: 8 */ 53 96 -1 , 54 97 -1 … … 58 101 59 102 return 0; 60 #endif 61 } 103 } 104 #endif // end ifndef SOCLIB_IOC 62 105 63 106 /** … … 137 180 138 181 #else 182 139 183 /////////////////////////////////////////////////////////////////////////////// 140 184 // FPGA version of the boot_ioc_read function … … 143 187 { 144 188 unsigned int sdcard_rsp; 189 unsigned int i; 145 190 146 191 sdcard_dev_lseek(&_sdcard_device, lba); 147 192 148 unsigned int i; 193 #if INSTRUMENTATION 194 unsigned int start_time; 195 unsigned int end_time; 196 boot_puts("[ DEBUG ] Reading blocks "); 197 boot_putd(lba); 198 boot_puts(" to "); 199 boot_putd(lba + count - 1); 200 201 start_time = boot_proctime(); 202 #endif 203 149 204 for(i = 0; i < count; i++) 150 205 { … … 161 216 162 217 return 1; 163 } 164 } 218 } 219 } 220 221 #if INSTRUMENTATION 222 end_time = boot_proctime(); 223 224 boot_puts(" / cycles for transfert: "); 225 boot_putd(end_time - start_time); 226 boot_puts("\n"); 227 #endif 165 228 166 229 return 0; -
trunk/softs/tsar_boot/src/exceptions.c
r292 r388 4 4 * \author : Manuel Bouyer 5 5 * 6 * This file defines a simple ex eptions handler6 * This file defines a simple exceptions handler 7 7 */ 8 8 -
trunk/softs/tsar_boot/src/sdcard.c
r292 r388 43 43 static void _sdcard_gen_tick(struct sdcard_dev * sdcard, unsigned int tick_count) 44 44 { 45 volatileregister int i = 0;45 register int i = 0; 46 46 while(i++ < tick_count) spi_put_tx(sdcard->spi, 0xFF, 0); 47 47 } … … 213 213 214 214 for (i = 0; i < 4; i++) 215 { 215 216 args[i] = (sdcard->access_pointer >> (32 - (i+1)*8)) & 0xFF; 217 } 216 218 217 219 _sdcard_enable(sdcard); -
trunk/softs/tsar_boot/src/spi.c
r292 r388 1 /* 1 /** 2 2 * \file spi.c 3 * \dat a31 August 20123 * \date 31 August 2012 4 4 * \author Cesar Fuguet <cesar.fuguet-tortolero@lip6.fr> 5 5 */ … … 15 15 static void _spi_wait_if_busy(struct spi_dev * spi) 16 16 { 17 volatileregister int delay;17 register int delay; 18 18 19 19 while(SPI_IS_BUSY(spi)) 20 20 { 21 for (delay = 0; delay < 100 00; delay++);21 for (delay = 0; delay < 100; delay++); 22 22 } 23 23 } … … 58 58 iowrite8(&spi->rx_tx[index % 4], byte); 59 59 _spi_init_transfer(spi); 60 61 asm volatile("sync");62 60 } 63 61 _spi_wait_if_busy(spi); … … 104 102 if (spi_freq > 0 && sys_freq > 0) 105 103 iowrite32(&spi->divider, _spi_calc_divider_value(spi_freq, sys_freq)); 106 107 104 } 108 105
Note: See TracChangeset
for help on using the changeset viewer.