Hi,<br><br>I'm working on a driver which accesses a device implemented in a FPGA that is used as a state machine. That is, there are configuration registers that determine how operations are executed.<br><br>For example,<br>
<br>a register named ADDRESS_MODE determines if address range 0x2000 to 0x2010 will correspond to a register set belonging to UART 1 or SDRAM.<br><br>ADDRESS_MODE = 0x00 ==> UART1 Register set<br>ADDRESS_MODE = 0x80 ==> SDRAM Register set<br>
<br>(in the real device this is a bit more complex, this is just an example to illustrate the nature of the problem)<br><br>I have a driver in a .lib with directives that perform different operations using this device, such as<br>
<br>device_init();<br>...<br>uarts_send()<br>uarts_receive()<br>...<br>sdram_write_block(),<br>sdram_read_block(),<br>...<br>etc.<br><br>each directive has to:<br><br>1. save ADDRESS_MODE value and other "state registers" values.<br>
2. configure ADDRESS_MODE and other registers to target the desired register set and operation mode.<br>3. access registers to perform operation.<br>4. restore original ADDRESS_MODE value and other "state registers" values.<br>
5. return<br><br>The problem with this solution is that it is not multitasking-safe.<br><br>A similar problem occurs when handling errors using (for example) trap 0x9. A global structure is used to read device status registers, but there is no way of knowing from which task they were generated so each task can track its own errors.<br>
<br>Im stucked at this dilemma:<br><br>- I believe the ideal solution would be to provide a context_switch() hook that preserves the critical registers for each device, but this would require altering the BSP, wouldn't it ? Is there a way to provide a custom context_switch() routine with preallocated space in confdefs.h for a number of tasks known at compilation time ?<br>
<br>- In case this is not possible, could RTEMS Task variables be used instead ?<br><br>Any help would be appreciated : )<br><br>Thanks,<br><br>Nicolás Eduardo Horro