Changeset 586 for trunk/softs/tsar_boot/src/reset_ioc.c
- Timestamp:
- Dec 4, 2013, 7:59:21 PM (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/src/reset_ioc.c
r570 r586 1 #include < boot_ioc.h>1 #include <reset_ioc.h> 2 2 3 3 #ifndef SOCLIB_IOC 4 4 5 static struct sdcard_dev _sdcard_device;5 static struct sdcard_dev _sdcard_device; 6 6 static struct spi_dev *const _spi_device = ( struct spi_dev * )IOC_BASE; 7 7 8 #endif // end ifndef SOCLIB_IOC 9 10 #define SDCARD_RESET_ITER_MAX 4 11 12 inline void boot_sleep(int cycles) 8 #endif 9 10 #define SDCARD_RESET_ITER_MAX 4 11 12 /////////////////////////////////// 13 inline void reset_sleep(int cycles) 13 14 { 14 15 int i; … … 16 17 } 17 18 18 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 19 inline unsigned int boot_proctime() 19 #if RESET_DEBUG 20 //////////////////////////////////// 21 inline unsigned int reset_proctime() 20 22 { 21 23 unsigned int ret; … … 26 28 27 29 #ifndef SOCLIB_IOC 28 int boot_ioc_init() 30 ///////////////////////////////////////////////////////////////////////////////// 31 // reset_ioc_init 32 // This function initializes the SDCARD / required for FPGA. 33 ///////////////////////////////////////////////////////////////////////////////// 34 int reset_ioc_init() 29 35 { 30 36 unsigned char sdcard_rsp; 31 37 32 boot_puts("Initializing block device\n\r");38 reset_puts("Initializing block device\n\r"); 33 39 34 40 /** … … 50 56 while(1) 51 57 { 52 boot_puts("Trying to initialize SD card... ");58 reset_puts("Trying to initialize SD card... "); 53 59 54 60 sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0); 55 61 if (sdcard_rsp == 0) 56 62 { 57 boot_puts("OK\n");63 reset_puts("OK\n"); 58 64 break; 59 65 } 60 66 61 boot_puts("KO\n");62 boot_sleep(1000);67 reset_puts("KO\n"); 68 reset_sleep(1000); 63 69 if (++iter >= SDCARD_RESET_ITER_MAX) 64 70 { 65 boot_puts("\nERROR: During SD card reset to IDLE state\n"71 reset_puts("\nERROR: During SD card reset to IDLE state\n" 66 72 "/ card response = "); 67 boot_putx(sdcard_rsp);68 boot_puts("\n");69 boot_exit();73 reset_putx(sdcard_rsp); 74 reset_puts("\n"); 75 reset_exit(); 70 76 } 71 77 } … … 77 83 if (sdcard_rsp) 78 84 { 79 boot_puts("ERROR: During SD card blocklen initialization\n");80 boot_exit();85 reset_puts("ERROR: During SD card blocklen initialization\n"); 86 reset_exit(); 81 87 } 82 88 … … 93 99 ); 94 100 95 boot_puts("Finish block device initialization\n\r");101 reset_puts("Finish block device initialization\n\r"); 96 102 97 103 return 0; 98 } 99 #endif // end ifndef SOCLIB_IOC 100 101 /** 102 * _boot_ioc_completed() 103 * 104 * This blocking function checks completion of an I/O transfer and reports errors. 105 * 106 * \note It returns 0 if the transfer is successfully completed. 107 * It returns -1 if an error has been reported. 108 */ 104 } // end reset_ioc_init() 105 #endif 106 109 107 #ifdef SOCLIB_IOC 110 static int _boot_ioc_completed() 108 ///////////////////////////////////////////////////////////////////////////////////// 109 // reset_ioc_completed() 110 // This blocking function checks completion of an I/O transfer and reports errors. 111 // It returns 0 if the transfer is successfully completed. 112 // It returns -1 if an error has been reported. 113 ///////////////////////////////////////////////////////////////////////////////////// 114 int reset_ioc_completed() 111 115 { 112 116 unsigned int status = 0; 113 117 114 115 unsigned int * ioc_address = ( unsigned int * )IOC_BASE; 118 unsigned int * ioc_address = ( unsigned int * )IOC_PADDR_BASE; 116 119 117 120 while ( 1 ) … … 125 128 126 129 return status; 127 } 128 #endif 129 130 /** 131 * boot_ioc_read() 132 * 133 * Transfer data from a file on the block device to a memory buffer. 134 * 135 * \param lba : first block index on the disk 136 * \param buffer : base address of the memory buffer 137 * \param count : number of blocks to be transfered 138 * 139 * \note This is a blocking function. The function returns once the transfer 140 * has finished 141 */ 130 } // end reset_ioc_completed() 131 #endif 142 132 143 133 #ifdef SOCLIB_IOC 144 /////////////////////////////////////////////////////////////////////////////// 145 // SOCLIB version of the boot_ioc_read function 146 147 void boot_buf_invalidate ( 148 const void * buffer, 149 unsigned int line_size, 150 unsigned int size); 151 152 void boot_mcc_invalidate ( 153 const void * buffer, 154 unsigned int size); 155 156 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 157 { 158 159 unsigned int * ioc_address = (unsigned int*)IOC_BASE; 160 161 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 134 ///////////////////////////////////////////////////////////////////////////////////// 135 // reset_ioc_read() 136 // Transfer data the block device to a memory buffer: SOCLIB version 137 // - param lba : first block index on the disk 138 // - param buffer : base address of the memory buffer 139 // - param count : number of blocks to be transfered 140 // This is a blocking function. The function returns once the transfer is completed. 141 ///////////////////////////////////////////////////////////////////////////////////// 142 int reset_ioc_read( unsigned int lba, 143 void* buffer, 144 unsigned int count ) 145 { 146 147 unsigned int * ioc_address = (unsigned int*)IOC_PADDR_BASE; 148 149 #if RESET_DEBUG 162 150 unsigned int start_time; 163 151 unsigned int end_time; 164 boot_puts("[ DEBUG] Reading blocks ");165 boot_putd(lba);166 boot_puts(" to ");167 boot_putd(lba + count - 1);168 169 start_time = boot_proctime();152 reset_puts("[RESET DEBUG] Reading blocks "); 153 reset_putd(lba); 154 reset_puts(" to "); 155 reset_putd(lba + count - 1); 156 157 start_time = reset_proctime(); 170 158 #endif 171 159 … … 186 174 ( unsigned int ) BLOCK_DEVICE_READ ); 187 175 188 _boot_ioc_completed();176 reset_ioc_completed(); 189 177 190 178 #if (CACHE_COHERENCE == 0) || (USE_IOB == 1) 191 boot_buf_invalidate(buffer, CACHE_LINE_SIZE, count * 512); 192 #endif 193 194 #if (USE_IOB == 1) 195 boot_mcc_invalidate(buffer, count * 512); 196 #endif 197 198 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 199 end_time = boot_proctime(); 200 201 boot_puts(" / cycles for transfert: "); 202 boot_putd(end_time - start_time); 203 boot_puts("\n"); 179 reset_buf_invalidate(buffer, CACHE_LINE_SIZE, count * 512); 180 #endif 181 182 #if USE_IOB 183 reset_mcc_invalidate(buffer, count * 512); 184 #endif 185 186 #if RESET_DEBUG 187 end_time = reset_proctime(); 188 reset_puts(" / cycles for transfert: "); 189 reset_putd(end_time - start_time); 190 reset_puts("\n"); 204 191 #endif 205 192 206 193 return 0; 207 } 194 } // end reset_ioc_read() 208 195 209 196 #else 210 197 211 /////////////////////////////////////////////////////////////////////////////// 212 // FPGA version of the boot_ioc_read function 213 214 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 198 ///////////////////////////////////////////////////////////////////////////////////// 199 // reset_ioc_read() 200 // Transfer data the block device to a memory buffer: FPGA version 201 // - param lba : first block index on the disk 202 // - param buffer : base address of the memory buffer 203 // - param count : number of blocks to be transfered 204 // This is a blocking function. The function returns once the transfer is completed. 205 ///////////////////////////////////////////////////////////////////////////////////// 206 int reset_ioc_read( unsigned int lba, 207 void* buffer, 208 unsigned int count ) 215 209 { 216 210 unsigned int sdcard_rsp; … … 219 213 sdcard_dev_lseek(&_sdcard_device, lba); 220 214 221 #if (BOOT_DEBUG ==1 && BOOT_DEBUG_IOC == 1)215 #if RESET_DEBUG 222 216 unsigned int start_time; 223 217 unsigned int end_time; 224 boot_puts("[ DEBUG ] Reading blocks "); 225 boot_putd(lba); 226 boot_puts(" to "); 227 boot_putd(lba + count - 1); 228 229 start_time = boot_proctime(); 218 reset_puts("[RESET DEBUG] Reading blocks "); 219 reset_putd(lba); 220 reset_puts(" to "); 221 reset_putd(lba + count - 1); 222 start_time = reset_proctime(); 230 223 #endif 231 224 … … 239 232 )) 240 233 { 241 boot_puts("ERROR during read on the SDCARD device. Code: ");242 boot_putx(sdcard_rsp);243 boot_puts("\n\r");234 reset_puts("ERROR during read on the SDCARD device. Code: "); 235 reset_putx(sdcard_rsp); 236 reset_puts("\n\r"); 244 237 245 238 return 1; … … 247 240 } 248 241 249 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1) 250 end_time = boot_proctime(); 251 252 boot_puts(" / cycles for transfert: "); 253 boot_putd(end_time - start_time); 254 boot_puts("\n"); 242 #if RESET_DEBUG 243 end_time = reset_proctime(); 244 reset_puts(" / cycles for transfert: "); 245 reset_putd(end_time - start_time); 246 reset_puts("\n"); 255 247 #endif 256 248 257 249 return 0; 258 } 259 #endif 260 261 /** 262 * _dcache_buf_invalidate() 263 * 264 * Invalidate all data cache lines corresponding to a memory 265 * buffer (identified by an address and a size). 266 */ 250 } // end reset_ioc_read() 251 #endif 252 253 ////////////////////////////////////////////////////////////////////////////// 254 // reset_dcache_buf_invalidate() 255 // Invalidate all data cache lines corresponding to a memory buffer 256 // (identified by an address and a size) in L1 cache. 257 ///////////////////////////////////////////////////////////////////////////// 267 258 #if (CACHE_COHERENCE == 0) || (USE_IOB == 1) 268 void boot_buf_invalidate ( 269 const void * buffer, 270 unsigned int line_size, 271 unsigned int size) 259 void reset_buf_invalidate ( const void * buffer, 260 unsigned int line_size, 261 unsigned int size) 272 262 { 273 263 unsigned int i; 274 264 275 265 // iterate on cache lines 276 for (i = 0; i <= size; i += line_size) { 266 for (i = 0; i <= size; i += line_size) 267 { 277 268 asm volatile( 278 269 " cache %0, %1" … … 284 275 #endif 285 276 286 /** 287 * boot_mcc_inval() 288 * 289 * Invalidate all data cache lines corresponding to a memory 290 * buffer (identified by an address and a size). 291 */ 292 #if (USE_IOB == 1) 293 void boot_mcc_invalidate ( 294 const void * buffer, 295 unsigned int size) 296 { 297 unsigned int * mcc_address = (unsigned int *)MCC_BASE; 277 ////////////////////////////////////////////////////////////////////////////// 278 // reset_mcc_inval() 279 // Invalidate all data cache lines corresponding to a memory buffer 280 // (identified by an address and a size) in L2 cache. 281 ///////////////////////////////////////////////////////////////////////////// 282 #if USE_IOB 283 void reset_mcc_invalidate ( const void * buffer, 284 unsigned int size) 285 { 286 unsigned int * mcc_address = (unsigned int *)MCC_PADDR_BASE; 298 287 299 288 // get the hard lock assuring exclusive access to MEMC
Note: See TracChangeset
for help on using the changeset viewer.