GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > VXW / V7-1-1

Constituent: vxw_flight     Tag: rad750


Interface   Data Structures   File List   Data Fields   Globals  

eemtd.c File Reference

TrueFFS EEPROM MTD Driver. More...

#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"

Include dependency graph for eemtd.c:


Data Structures

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 _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_HandlereeErrHandler = eeMTDHandler
static int eeErrArg

Detailed Description

TrueFFS EEPROM MTD Driver.

Author:
D.L. Wood
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 Documentation

#define EEPROM_ADDR_MAP _offset   )     ((vol.socket->window.baseAddress << 12) + (_offset))
 

Maps a TFFS partition local offset address into a EEPROM physical address.

Parameters:
_offset The TFFS local offset.
Returns:
The EEPROM physical address.

#define EEPROM_ADDR_OFFSET _addr   )     ((_addr) - (vol.socket->window.baseAddress << 12))
 

Maps an EEPROM physical address into a TFFS partition local offset.

Parameters:
_addr The EEPROM physical address.
Returns:
The TFFS local offset

#define EEPROM_BUFFER_SIZE   1024
 

The size in bytes of the map emulation buffer.

#define EEPROM_CHIP_SIZE   0x20000
 

The size in bytes of one EEPROM chip.

#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).

#define EEPROM_ERASE_VALUE   0xffffffff
 

The value to write to simulate an erase operation.

#define EEPROM_MTD_LOG _lev,
_msg,
_x0,
_x1,
_x2,
_x3,
_x4,
_x5   ) 
 

Macro to control debug log messages.

Parameters:
_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().

#define EEPROM_MTD_TYPE   2
 

Fake JTEC ID to indicate EEPROM.

#define EEPROM_PAGE_SIZE   (128 * EEPROM_WORD_SIZE)
 

The size in bytes of one EEPROM write page.

#define EEPROM_RETRY_CALC   ((sysClkRateGet() / EEPROM_CLK_DIVISOR) + 1)
 

Macro to calculate write retry count based on the current system clock rate.

#define EEPROM_TOGGLE_MASK   0x40404040
 

The D6 toggle bit mask for an EEPROM location.

#define EEPROM_WORD_SIZE   4
 

The size of an addressable EEPROM location.


Typedef Documentation

EEPROM_Desc
 

The typedef for _EEPROM_Desc.


Function Documentation

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.

Parameters:
vol The volume descriptor.
firstBlock The first erase unit number to erase.
numBlocks The number of erase units to erase.
Return values:
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.

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.

Parameters:
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.

void eeMTDHandler FLStatus  error,
int  drv,
unsigned int  offset,
int  arg
[static]
 

The default error handler callback. Simply logs the callback parameters.

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.

FLStatus eeMTDIdentify FLFlash  vol  ) 
 

Registers EEPROM driver.

MTD vol structure is initialized. The vol structure function pointers are initialized to the EEPROM MTD callbacks.

Parameters:
vol The volume descriptor.
Return values:
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.

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.

Parameters:
vol The volume descriptor.
address The offset into the volume to map.
length The number of bytes to map.
Returns:
A pointer to a buffer containing the requested drive data.

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.

Parameters:
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.
Return values:
flOK Success.

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.

Parameters:
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.
Return values:
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.

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.

Parameters:
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.
Return values:
flOK Success.
flTimedOut The EEPROM toggle status did not stabalize within 20 msec.
flWriteFault The data could not be written; failed read verification.

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.

Parameters:
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.
Return values:
flOK Success.
flTimedOut The EEPROM toggle status did not stabalize within retry limit.

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.

Parameters:
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.
Return values:
flOK Success.
flTimedOut The EEPROM toggle status did not stabalize within retry limit.
flWriteFault The data could not be written; failed read verification.

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.

Parameters:
funcCode One of the TFFS_IOC values specifying the action to take.
arg0 Function specific parameter.
arg1 Function specific parameter.
arg2 Function specific parameter.
Return values:
OK Success.
ERROR Error.


Variable Documentation

eeDesc [static]
 

Local driver partition descriptors.

eeErrArg [static]
 

The user argument for eeErrHandler.

eeErrHandler = eeMTDHandler [static]
 

The user installed error callback.


Generated on Sat Feb 2 01:36:13 2008 by  doxygen 1.4.4