GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> VXW / dev > vxw_symbol / rad750
#include <vxWorks.h>
#include <string.h>
#include <sysLib.h>
#include <wdLib.h>
#include <semLib.h>
#include <tffs/flflash.h>
#include <tffs/flsocket.h>
#include <tffs/tffsIoctl.h>
Classes | |
struct | _EEPROM_Desc |
Defines | |
#define | EEPROM_MTD_LOG(_lev, _msg, _x0, _x1, _x2, _x3, _x4, _x5) |
#define | EEPROM_MTD_TYPE 2 |
#define | EEPROM_CHIP_SIZE 0x20000 |
#define | EEPROM_ERASE_SIZE 0x10000 |
#define | EEPROM_WORD_SIZE 4 |
#define | EEPROM_BUFFER_SIZE 1024 |
#define | EEPROM_PAGE_SIZE (128 * EEPROM_WORD_SIZE) |
#define | EEPROM_TOGGLE_MASK 0x40404040 |
#define | EEPROM_ERASE_VALUE 0xffffffff |
#define | EEPROM_CLK_DIVISOR 25 |
#define | EEPROM_RETRY_CALC ((sysClkRateGet() / EEPROM_CLK_DIVISOR) + 1) |
#define | EEPROM_ADDR_MAP(_offset) ((vol.socket->window.baseAddress << 12) + (_offset)) |
#define | EEPROM_ADDR_OFFSET(_addr) ((_addr) - (vol.socket->window.baseAddress << 12)) |
Typedefs | |
typedef struct _EEPROM_Desc | EEPROM_Desc |
Functions | |
static FLStatus | eeMTDWriteWord (EEPROM_Desc *desc, unsigned int addr, unsigned int data, int retry) |
Writes to one EEPROM location. | |
static FLStatus | eeMTDWritePage (EEPROM_Desc *desc, unsigned int pageBase, const void FAR1 *buffer, unsigned int numPages) |
static FLStatus | eeMTDWriteQuery (EEPROM_Desc *desc, unsigned int addr, int retry) |
Waits for write completion. | |
static void | eeMTDError (FLFlash vol, FLStatus error, unsigned int offset) |
static void | eeMTDHandler (FLStatus error, int drv, unsigned int offset, int arg) |
static FLStatus | eeMTDWrite (FLFlash vol, CardAddress address, const void FAR1 *buffer, int length, FLBoolean overwrite) |
Write to EEPROM. | |
static FLStatus | eeMTDRead (FLFlash vol, CardAddress address, void FAR1 *buffer, int length, int modes) |
Read from EEPROM. | |
static FLStatus | eeMTDErase (FLFlash vol, int firstBlock, int numBlocks) |
Erase EEPROM. | |
static void FAR0 * | eeMTDMap (FLFlash vol, CardAddress address, int length) |
Map EEPROM into local memory. | |
FLStatus | eeMTDIdentify (FLFlash vol) |
Registers EEPROM driver. | |
STATUS | tffsIoctl (TFFS_IOC funcCode, int arg0, int arg1, int arg2) |
TFFS driver low-level control. | |
Variables | |
static EEPROM_Desc | eeDesc [DRIVES] |
static TFFS_Error_Handler * | eeErrHandler = eeMTDHandler |
static int | eeErrArg |
This TFFS MTD driver supports Maxwell/Austin/Hitachi EEPROM media technology. Current implementation assumes that the EEPROM chips are accessed via the PCI bus. This driver only works with the SIB board socket layer driver.
#define EEPROM_ADDR_MAP | ( | _offset | ) | ((vol.socket->window.baseAddress << 12) + (_offset)) |
Maps a TFFS partition local offset address into a EEPROM physical address.
_offset | The TFFS local offset. |
Referenced by eeMTDErase(), eeMTDRead(), and eeMTDWrite().
#define EEPROM_ADDR_OFFSET | ( | _addr | ) | ((_addr) - (vol.socket->window.baseAddress << 12)) |
Maps an EEPROM physical address into a TFFS partition local offset.
_addr | The EEPROM physical address. |
Referenced by eeMTDErase(), and eeMTDWrite().
#define EEPROM_BUFFER_SIZE 1024 |
The size in bytes of the map emulation buffer.
Referenced by eeMTDIdentify(), and eeMTDMap().
#define EEPROM_CHIP_SIZE 0x20000 |
The size in bytes of one EEPROM chip.
Referenced by eeMTDIdentify().
#define EEPROM_CLK_DIVISOR 25 |
The system clock divisor used to calculate the write retry value.
#define EEPROM_ERASE_SIZE 0x10000 |
The size of an erase block (simulated).
Referenced by eeMTDIdentify().
#define EEPROM_ERASE_VALUE 0xffffffff |
The value to write to simulate an erase operation.
Referenced by eeMTDErase().
#define EEPROM_MTD_LOG | ( | _lev, | |||
_msg, | |||||
_x0, | |||||
_x1, | |||||
_x2, | |||||
_x3, | |||||
_x4, | |||||
_x5 | ) |
Macro to control debug log messages.
_lev | The debug logging level (0 is lowest output). | |
_msg | The message string to print. | |
_x0 | Print parameter for logMsg(). | |
_x1 | Print parameter for logMsg(). | |
_x2 | Print parameter for logMsg(). | |
_x3 | Print parameter for logMsg(). | |
_x4 | Print parameter for logMsg(). | |
_x5 | Print parameter for logMsg(). |
_lev | The debug logging level (0 is lowest output). | |
_msg | The message string to print. | |
_x0 | Print parameter for logMsg(). | |
_x1 | Print parameter for logMsg(). | |
_x2 | Print parameter for logMsg(). | |
_x3 | Print parameter for logMsg(). | |
_x4 | Print parameter for logMsg(). | |
_x5 | Print parameter for logMsg(). |
Referenced by eeMTDErase(), eeMTDHandler(), eeMTDIdentify(), eeMTDMap(), eeMTDRead(), eeMTDWrite(), eeMTDWritePage(), eeMTDWriteQuery(), and eeMTDWriteWord().
#define EEPROM_MTD_TYPE 2 |
Fake JTEC ID to indicate EEPROM.
Referenced by eeMTDIdentify().
#define EEPROM_PAGE_SIZE (128 * EEPROM_WORD_SIZE) |
The size in bytes of one EEPROM write page.
Referenced by eeMTDErase(), eeMTDWrite(), and eeMTDWritePage().
#define EEPROM_RETRY_CALC ((sysClkRateGet() / EEPROM_CLK_DIVISOR) + 1) |
Macro to calculate write retry count based on the current system clock rate.
Referenced by eeMTDErase(), eeMTDWrite(), and eeMTDWritePage().
#define EEPROM_TOGGLE_MASK 0x40404040 |
The D6 toggle bit mask for an EEPROM location.
Referenced by eeMTDWriteQuery().
#define EEPROM_WORD_SIZE 4 |
The size of an addressable EEPROM location.
Referenced by eeMTDErase(), eeMTDIdentify(), eeMTDRead(), eeMTDWrite(), and eeMTDWritePage().
The typedef for _EEPROM_Desc.
FLStatus eeMTDErase | ( | FLFlash | vol, | |
int | firstBlock, | |||
int | numBlocks | |||
) | [static] |
Erase EEPROM.
This routine is registered as MTD vol.erase.
The EEPROM media does not actually support a hardware erase operation. In fact, writes can always be done to a location at any time. TFFS, however, assumes that an erased block is set to value 0xffffffff. This function emulates the erase operation by writing 0xfffffff to all EEPROM locations within the erase block.
This function takes advantage of the EEPROM page mode programming feature to write all of the locations in an erase block.
vol | The volume descriptor. | |
firstBlock | The first erase unit number to erase. | |
numBlocks | The number of erase units to erase. |
flOK | Success. | |
flWriteProtect | The volume socket is write protected. | |
flVppFail | The socket could not be write enabled. | |
flTimedOut | The EEPROM toggle status did not stabalize within 20 msec. | |
flWriteFault | The data could not be written; failed read verification. |
References eeMTDError(), eeMTDWriteQuery(), eeMTDWriteWord(), EEPROM_ADDR_MAP, EEPROM_ADDR_OFFSET, EEPROM_ERASE_VALUE, EEPROM_MTD_LOG, EEPROM_PAGE_SIZE, EEPROM_RETRY_CALC, and EEPROM_WORD_SIZE.
Referenced by eeMTDIdentify().
static void eeMTDError | ( | FLFlash | vol, | |
FLStatus | error, | |||
unsigned int | offset | |||
) | [static] |
This function is called when the EEPROM driver encounters an error. If a user error handler callback is installed, it is called.
vol | The volume descriptor. | |
error | The error code reported by the EEPROM driver. | |
offset | The offset into the EEPROM bank at which the error occurred. |
References eeErrArg, and eeErrHandler.
Referenced by eeMTDErase(), eeMTDMap(), eeMTDRead(), and eeMTDWrite().
void eeMTDHandler | ( | FLStatus | error, | |
int | drv, | |||
unsigned int | offset, | |||
int | arg | |||
) | [static] |
The default error handler callback. Simply logs the callback parameters.
error | The error code reported by the EEPROM driver. | |
drv | The TFFS drive number. | |
offset | The offset into the EEPROM bank at which the error occurred. | |
arg | Igonored. |
References EEPROM_MTD_LOG.
FLStatus eeMTDIdentify | ( | FLFlash | vol | ) |
Registers EEPROM driver.
MTD vol structure is initialized. The vol structure function pointers are initialized to the EEPROM MTD callbacks.
vol | The volume descriptor. |
flOK | An EEPROM socket was detected. | |
flUnknownMedia | This is not an EEPROM socket. | |
flNotEnoughMemory | The driver could not allocate private memory. | |
flGeneralFailure | A VxWorks system call failed. |
References _EEPROM_Desc::buffer, eeMTDErase(), eeMTDMap(), eeMTDRead(), eeMTDWrite(), EEPROM_BUFFER_SIZE, EEPROM_CHIP_SIZE, EEPROM_ERASE_SIZE, EEPROM_MTD_LOG, EEPROM_MTD_TYPE, EEPROM_WORD_SIZE, _EEPROM_Desc::flag, and _EEPROM_Desc::timer.
void FAR0 * eeMTDMap | ( | FLFlash | vol, | |
CardAddress | address, | |||
int | length | |||
) | [static] |
Map EEPROM into local memory.
This routine is registered as MTD vol.map. Because the EEPROM bank memory cannot be read directly by TFFS, this function provides mapping through copy emulation. The eeMTDRead() function is used to read the requested partition data into the driver private read buffer. A pointer to the read buffer is then returned.
vol | The volume descriptor. | |
address | The offset into the volume to map. | |
length | The number of bytes to map. |
References _EEPROM_Desc::buffer, eeMTDError(), eeMTDRead(), EEPROM_BUFFER_SIZE, and EEPROM_MTD_LOG.
Referenced by eeMTDIdentify().
FLStatus eeMTDRead | ( | FLFlash | vol, | |
CardAddress | address, | |||
void FAR1 * | buffer, | |||
int | length, | |||
int | modes | |||
) | [static] |
Read from EEPROM.
This routine is registered as MTD vol.read. Data is read as requested. Because the EEPROM chips can only be read in groups of 4, this function does the appropriate byte extraction to handle any size or address alignments.
vol | The volume descriptor. | |
address | The offset into the volume to read from. | |
buffer | The location holding the read data. | |
length | The number of bytes to read. | |
modes | Ignored. |
flOK | Success. |
References eeMTDError(), EEPROM_ADDR_MAP, EEPROM_MTD_LOG, and EEPROM_WORD_SIZE.
Referenced by eeMTDIdentify(), and eeMTDMap().
FLStatus eeMTDWrite | ( | FLFlash | vol, | |
CardAddress | address, | |||
const void FAR1 * | buffer, | |||
int | length, | |||
FLBoolean | overwrite | |||
) | [static] |
Write to EEPROM.
This routine is registered as MTD vol.write. Because the EEPROM chips can only be writen in groups of 4, this function does a general read-modify-write routine when inserting new data.
vol | The volume descriptor. | |
address | The offset into the volume to write to. | |
buffer | The location holding the data to write. | |
length | The number of bytes to write. | |
overwrite | Ignored. |
flOK | Success. | |
flWriteProtect | The volume socket is write protected. | |
flVppFail | The socket could not be write enabled. | |
flTimedOut | The EEPROM toggle status did not stabalize within the timeout period. | |
flWriteFault | The data could not be written; failed read verification. |
References eeMTDError(), eeMTDWritePage(), eeMTDWriteWord(), EEPROM_ADDR_MAP, EEPROM_ADDR_OFFSET, EEPROM_MTD_LOG, EEPROM_PAGE_SIZE, EEPROM_RETRY_CALC, and EEPROM_WORD_SIZE.
Referenced by eeMTDIdentify().
static FLStatus eeMTDWritePage | ( | EEPROM_Desc * | desc, | |
unsigned int | pageBase, | |||
const void FAR1 * | buffer, | |||
unsigned int | numPages | |||
) | [static] |
This function takes advantage of the EEPROM page mode programming feature to write all of the locations in hardware page. After the initial page write, all of the locations are read to verify the write success. Any failures from the page write are tried again using the single word write mode.
desc | A pointer to the driver descriptor. | |
pageBase | The logical CPU address of the EEPROM page base. | |
buffer | A buffer holding the write data. | |
numPages | The number of pages to write. |
flOK | Success. | |
flTimedOut | The EEPROM toggle status did not stabalize within 20 msec. | |
flWriteFault | The data could not be written; failed read verification. |
References eeMTDWriteQuery(), eeMTDWriteWord(), EEPROM_MTD_LOG, EEPROM_PAGE_SIZE, EEPROM_RETRY_CALC, and EEPROM_WORD_SIZE.
Referenced by eeMTDWrite().
static FLStatus eeMTDWriteQuery | ( | EEPROM_Desc * | desc, | |
unsigned int | addr, | |||
int | retry | |||
) | [static] |
Waits for write completion.
The address just written is read once every system clock tick to check for completion status. The EEPROM chip returns undefined data while it is in write programming mode, except for bit 6 of the written location. Bit 6 will toggle back and forth until the internal write process has completed. This function does back to back reads of the address and checks for the stability of bit 6. The retry parameter limits the number of times that the location is checked for completion status. Once bit 6 stabalizes, the location is read once more and compared to the original write data value before declaring success.
desc | A pointer to the driver descriptor. | |
addr | An address to read for status. This should be one of the addresses in the row of EEPROM chips which is being programmed. | |
retry | The number of times to poll the location for completion before declaring a write timeout. |
flOK | Success. | |
flTimedOut | The EEPROM toggle status did not stabalize within retry limit. |
References EEPROM_MTD_LOG, EEPROM_TOGGLE_MASK, _EEPROM_Desc::flag, and _EEPROM_Desc::timer.
Referenced by eeMTDErase(), eeMTDWritePage(), and eeMTDWriteWord().
static FLStatus eeMTDWriteWord | ( | EEPROM_Desc * | desc, | |
unsigned int | addr, | |||
unsigned int | data, | |||
int | retry | |||
) | [static] |
Writes to one EEPROM location.
Writes one 4 byte word to a single EEPROM address. After the data is written to the location, the location is polled for completion, and a read is performed to verify the write success.
desc | A pointer to the driver descriptor. | |
addr | The address of the word to write. | |
data | The data value to write. | |
retry | The number of times to poll the location for completion before declaring a write timeout. |
flOK | Success. | |
flTimedOut | The EEPROM toggle status did not stabalize within retry limit. | |
flWriteFault | The data could not be written; failed read verification. |
References eeMTDWriteQuery(), and EEPROM_MTD_LOG.
Referenced by eeMTDErase(), eeMTDWrite(), and eeMTDWritePage().
STATUS tffsIoctl | ( | TFFS_IOC | funcCode, | |
int | arg0, | |||
int | arg1, | |||
int | arg2 | |||
) |
TFFS driver low-level control.
This function provides extended control over the EEPROM MTD driver not available with the standard VxWorks TFFS interface. The funcCode parameter specifies the action to perform.
TFFS_IOC_ERROR_HANDLER - Installs a callback which will catch EEPROM MTD driver errors. Set arg0 to the address of the function and arg1 to a user parmeter value which will be passed to the callback. The callback is in the form TFFS_Error_Handler.
funcCode | One of the TFFS_IOC values specifying the action to take. | |
arg0 | Function specific parameter. | |
arg1 | Function specific parameter. | |
arg2 | Function specific parameter. |
OK | Success. | |
ERROR | Error. |
References eeErrArg, eeErrHandler, and TFFS_IOC_ERROR_HANDLER.
eeDesc [static] |
Local driver partition descriptors.
eeErrArg [static] |
The user argument for eeErrHandler.
Referenced by eeMTDError(), and tffsIoctl().
eeErrHandler = eeMTDHandler [static] |
The user installed error callback.
Referenced by eeMTDError(), and tffsIoctl().