#include #include #define in_reset __attribute__((section (".reset"))) #define in_reset_data __attribute__((section (".reset_data"))) #define in_unckdata __attribute__((section (".unckdata"))) in_unckdata int volatile _ioc_lock = 0; in_reset_data int volatile _ioc_done = 0; in_reset_data int volatile _ioc_status; #ifndef SOCLIB_IOC /*in_reset_data volatile unsigned int _ioc_init_ok = 0;*/ static in_reset_data struct sdcard_dev _sdcard_device; static in_reset_data struct spi_dev * _spi_device = ( struct spi_dev * )IOC_BASE; #endif ////////////////////////////////////////////////////////////////////////////////////////// // I/O BLOCK_DEVICE // The three functions below use the three variables _ioc_lock _ioc_done, // and _ioc_status for synchronsation. // - As the IOC component can be used by several programs running in parallel, // the _ioc_lock variable guaranties exclusive access to the device. // The _ioc_read() and _ioc_write() functions use atomic LL/SC to get the lock. // and set _ioc_lock to a non zero value. // The _ioc_write() and _ioc_read() functions are blocking, polling the _ioc_lock // variable until the device is available. // - When the tranfer is completed, the ISR routine activated by the IOC IRQ // set the _ioc_done variable to a non-zero value. Possible address errors detected // by the IOC peripheral are reported by the ISR in the _ioc_status variable. // The _ioc_completed() function is polling the _ioc_done variable, waiting for // tranfer conpletion. When the completion is signaled, the _ioc_completed() function // reset the _ioc_done variable to zero, and releases the _ioc_lock variable. // // In a multi-tasks environment, this polling policy must be replaced by a // descheduling policy for the requesting process. ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // _dcache_buf_invalidate() // Invalidate all cache lines corresponding to a memory buffer. // This is used by the block_device driver. ///////////////////////////////////////////////////////////////////////// //in_reset static void _dcache_buf_invalidate(const void * buffer, size_t size) //{ // size_t i; // size_t dcache_line_size; // // // retrieve dcache line size from config register (bits 12:10) // asm volatile("mfc0 %0, $16, 1" : "=r" (dcache_line_size)); // // dcache_line_size = 2 << ((dcache_line_size>>10) & 0x7); // // // iterate on lines to invalidate each one of them // for ( i=0; i