Changeset 347 for trunk/softs/tsar_boot/src
- Timestamp:
- Apr 1, 2013, 8:57:02 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/src/boot_ioc.c
r302 r347 1 1 #include <boot_ioc.h> 2 #include <defs.h>3 2 4 3 #ifndef SOCLIB_IOC … … 16 15 int boot_ioc_init() 17 16 { 18 #ifndef SOCLIB_IOC 17 #ifdef SOCLIB_IOC 18 return 0; 19 #else 19 20 unsigned char sdcard_rsp; 20 21 … … 55 56 56 57 boot_puts("Finish block device initialization\n\r"); 57 #endif58 58 59 59 return 0; 60 #endif 60 61 } 61 62 … … 101 102 * has finished 102 103 */ 104 105 #ifdef SOCLIB_IOC 106 /////////////////////////////////////////////////////////////////////////////// 107 // SOCLIB version of the boot_ioc_read function 108 103 109 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 104 110 { 105 #ifdef SOCLIB_IOC106 111 107 112 unsigned int * ioc_address = (unsigned int*)VCIBD_BASE; … … 125 130 _boot_ioc_completed(); 126 131 132 #if (CACHE_COHERENCE == 0) 133 boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512); 134 #endif 135 return 0; 136 } 137 127 138 #else 139 /////////////////////////////////////////////////////////////////////////////// 140 // FPGA version of the boot_ioc_read function 141 142 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count) 143 { 128 144 unsigned int sdcard_rsp; 129 145 … … 147 163 } 148 164 } 149 150 #endif151 165 152 166 return 0; 153 167 } 154 155 /** 156 * boot_ioc_write() 157 * 158 * Transfer data from a memory buffer to a file on the block_device. 159 * 160 * \param lba : first block index on the disk 161 * \param buffer : base address of the memory buffer 162 * \param count : number of blocks to be transfered 163 * 164 * \note The source buffer must be in user address space. 165 * 166 *in_reset int _ioc_write(unsigned int lba, void* buffer, unsigned int count) 167 *{ 168 *#ifdef SOCLIB_IOC 169 * 170 * unsigned int * ioc_address = ( unsigned int * )VCIBD_BASE; 171 * 172 * // block_device configuration 173 * iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER], 174 * ( unsigned int ) buffer ); 175 * 176 * iowrite32( &ioc_address[BLOCK_DEVICE_COUNT], 177 * ( unsigned int ) count ); 178 * 179 * iowrite32( &ioc_address[BLOCK_DEVICE_LBA], 180 * ( unsigned int ) lba ); 181 * 182 * iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE], 183 * ( unsigned int ) 0 ); 184 * 185 * iowrite32( &ioc_address[BLOCK_DEVICE_OP], 186 * ( unsigned int ) BLOCK_DEVICE_WRITE); 187 * 188 * _boot_ioc_completed(); 189 * 190 *#else 191 * 192 * sdcard_dev_lseek(&_sdcard_device, lba); 193 * sdcard_dev_write(&_sdcard_device, buffer, count*512); 194 * 195 *#endif 196 * 197 * return 0; 198 *} 199 */ 168 #endif 200 169 201 170 /** 202 171 * _dcache_buf_invalidate() 203 172 * 204 * Invalidate all cache lines corresponding to a memory buffer. 205 * This is used by the block_device driver. 206 * 207 *in_reset static void _dcache_buf_invalidate(const void * buffer, unsigned int size) 208 *{ 209 * unsigned int i; 210 * unsigned int dcache_line_size; 211 * 212 * // retrieve dcache line size from config register (bits 12:10) 213 * asm volatile("mfc0 %0, $16, 1" : "=r" (dcache_line_size)); 214 * 215 * dcache_line_size = 2 << ((dcache_line_size>>10) & 0x7); 216 * 217 * // iterate on lines to invalidate each one of them 218 * for ( i=0; i<size; i+=dcache_line_size ) 219 * asm volatile 220 * (" mtc2 %0, $7\n" 221 * : 222 * : "r" (*((char*)buffer+i)) 223 * ); 224 *} 173 * Invalidate all data cache lines corresponding to a memory 174 * buffer (identified by an address and a size). 225 175 */ 176 #if (CACHE_COHERENCE == 0) 177 void boot_dbuf_invalidate ( 178 const void * buffer, 179 unsigned int line_size, 180 unsigned int size) 181 { 182 unsigned int i; 183 184 // iterate on cache lines 185 for (i = 0; i < size; i += line_size) { 186 asm volatile( 187 " cache %0, %1" 188 :// no outputs 189 :"i" (0x11), "R" (*((unsigned char *) buffer + i)) 190 ); 191 } 192 } 193 #endif 226 194 227 195 /*
Note: See TracChangeset
for help on using the changeset viewer.