/* sysTffs.c - Motorola MVME177 system-dependent TrueFFS library */
/* Copyright 1984-1997 Wind River Systems, Inc. */
#include "copyright_wrs.h"
#include "vxWorks.h"
#include "config.h"
#include "tffs/flsocket.h"
#include "tffs/tffsDrv.h"
/* defines */
#define INCLUDE_MTD_SST39VF160
#undef INCLUDE_MTD_I28F016
#undef INCLUDE_MTD_I28F008
#undef INCLUDE_MTD_AMD
#undef INCLUDE_MTD_CDSN
#undef INCLUDE_MTD_DOC2
#undef INCLUDE_MTD_CFISCS /* CFI/SCS */
#undef INCLUDE_MTD_WAMD /* AMD, Fujitsu: 29f0{40,80,16} 16bit */
#undef INCLUDE_TL_NFTL /* NFTL translation layer */
#define INCLUDE_TL_FTL /* FTL translation layer */
#undef INCLUDE_TL_SSFDC /* SSFDC translation layer */
#undef INCLUDE_TFFS_BOOT_IMAGE /* include tffsBootImagePut() */
#define FLASH_BASE_ADRS ROM_SIZE
#define FLASH_SIZE (0x00400000-ROM_SIZE)
/* locals */
/* forward declarations */
LOCAL void rfaWriteProtect (void);
LOCAL void rfaWriteEnable (void);
LOCAL FLBoolean rfaCardDetected (FLSocket vol);
LOCAL void rfaVccOn (FLSocket vol);
LOCAL void rfaVccOff (FLSocket vol);
#ifdef SOCKET_12_VOLTS
LOCAL FLStatus rfaVppOn (FLSocket vol);
LOCAL void rfaVppOff (FLSocket vol);
#endif /* SOCKET_12_VOLTS */
LOCAL FLBoolean rfaGetAndClearCardChangeIndicator (FLSocket vol);
LOCAL FLBoolean rfaWriteProtected (FLSocket vol);
LOCAL void rfaSetWindow (FLSocket vol);
LOCAL void rfaSetMappingContext (FLSocket vol, unsigned page);
LOCAL FLStatus rfaSocketInit (FLSocket vol);
LOCAL FLStatus rfaRegister (void);
#ifndef DOC
#include "tffsConfig.c"
#endif /* DOC */
/*******************************************************************************
*
* sysTffsInit - board-level initialization for TrueFFS
*
* This routine calls the socket registration routines for the socket component
* drivers that will be used with this BSP. The order of registration determines
* the logical drive number given to the drive associated with the socket.
*
* RETURNS: N/A
*/
LOCAL void sysTffsInit (void)
{
rfaRegister ();
}
/*******************************************************************************
*
* rfaRegister - registration routine for the RFA on MVME177
*
* This routine populates the 'vol' structure for a logical drive with the
* socket component driver routines for the RFA on the MVME177 board. All
* socket routines are referanced through the 'vol' structure and never
* from here directly
*
* RETURNS: flOK, or flTooManyComponents if there're too many drives
*/
LOCAL FLStatus rfaRegister (void)
{
FLSocket vol = flSocketOf (noOfDrives);
if (noOfDrives >= DRIVES)
return (flTooManyComponents);
tffsSocket[noOfDrives] = "RFA";
noOfDrives++;
vol.serialNo = 0;
vol.window.baseAddress = FLASH_BASE_ADRS >> 12;
/* fill in function pointers */
vol.cardDetected = rfaCardDetected;
vol.VccOn = rfaVccOn;
vol.VccOff = rfaVccOff;
#ifdef SOCKET_12_VOLTS
vol.VppOn = rfaVppOn;
vol.VppOff = rfaVppOff;
#endif
vol.initSocket = rfaSocketInit;
vol.setWindow = rfaSetWindow;
vol.setMappingContext = rfaSetMappingContext;
vol.getAndClearCardChangeIndicator =
rfaGetAndClearCardChangeIndicator;
vol.writeProtected = rfaWriteProtected;
return (flOK);
}
/*******************************************************************************
*
* rfaCardDetected - detect if a card is present (inserted)
*
* This routine detects if a card is present (inserted).
*
* RETURNS: TRUE, or FALSE if the card is not present.
*/
LOCAL FLBoolean rfaCardDetected
(
FLSocket vol
)
{
return (TRUE);
}
/*******************************************************************************
*
* rfaVccOn - turn on Vcc (3.3/5 Volts)
*
* This routine turns on Vcc (3.3/5 Volts). Vcc must be known to be good
* on exit.
*
* RETURNS: N/A
*/
LOCAL void rfaVccOn
(
FLSocket vol
)
{
rfaWriteEnable ();
}
/*******************************************************************************
*
* rfaVccOff - turn off Vcc (3.3/5 Volts)
*
* This routine turns off Vcc (3.3/5 Volts).
*
* RETURNS: N/A
*/
LOCAL void rfaVccOff
(
FLSocket vol
)
{
rfaWriteProtect ();
}
#ifdef SOCKET_12_VOLTS
/*******************************************************************************
*
* rfaVppOn - turns on Vpp (12 Volts)
*
* This routine turns on Vpp (12 Volts). Vpp must be known to be good on exit.
*
* RETURNS: flOK always
*/
LOCAL FLStatus rfaVppOn
(
FLSocket vol /* pointer identifying drive */
)
{
return (flOK);
}
/*******************************************************************************
*
* rfaVppOff - turns off Vpp (12 Volts)
*
* This routine turns off Vpp (12 Volts).
*
* RETURNS: N/A
*/
LOCAL void rfaVppOff
(
FLSocket vol /* pointer identifying drive */
)
{
}
#endif /* SOCKET_12_VOLTS */
/*******************************************************************************
*
* rfaSocketInit - perform all necessary initializations of the socket
*
* This routine performs all necessary initializations of the socket.
*
* RETURNS: flOK always
*/
LOCAL FLStatus rfaSocketInit
(
FLSocket vol /* pointer identifying drive */
)
{
rfaWriteEnable ();
vol.cardChanged = FALSE;
/* enable memory window and map it at address 0 */
rfaSetWindow (&vol);
return (flOK);
}
/*******************************************************************************
*
* rfaSetWindow - set current window attributes, Base address, size, etc
*
* This routine sets current window hardware attributes: Base address, size,
* speed and bus width. The requested settings are given in the 'vol.window'
* structure. If it is not possible to set the window size requested in
* 'vol.window.size', the window size should be set to a larger value,
* if possible. In any case, 'vol.window.size' should contain the
* actual window size (in 4 KB units) on exit.
*
* RETURNS: N/A
*/
LOCAL void rfaSetWindow
(
FLSocket vol /* pointer identifying drive */
)
{
/* Physical base as a 4K page */
vol.window.baseAddress = FLASH_BASE_ADRS >> 12;
flSetWindowSize (&vol, FLASH_SIZE >> 12);
}
/*******************************************************************************
*
* rfaSetMappingContext - sets the window mapping register to a card address
*
* This routine sets the window mapping register to a card address.
* The window should be set to the value of 'vol.window.currentPage',
* which is the card address divided by 4 KB. An address over 128MB,
* (page over 32K) specifies an attribute-space address. On entry to this
* routine vol.window.currentPage is the page already mapped into the window.
* (In otherwords the page that was mapped by the last call to this routine.)
*
* The page to map is guaranteed to be on a full window-size boundary.
*
* RETURNS: N/A
*/
LOCAL void rfaSetMappingContext
(
FLSocket vol, /* pointer identifying drive */
unsigned page /* page to be mapped */
)
{
}
/*******************************************************************************
*
* rfaGetAndClearCardChangeIndicator - return the hardware card-change indicator
*
* This routine returns the hardware card-change indicator and clears it if set.
*
* RETURNS: FALSE, or TRUE if the card has been changed
*/
LOCAL FLBoolean rfaGetAndClearCardChangeIndicator
(
FLSocket vol /* pointer identifying drive */
)
{
return (FALSE);
}
/*******************************************************************************
*
* rfaWriteProtected - return the write-protect state of the media
*
* This routine returns the write-protect state of the media
*
* RETURNS: FALSE, or TRUE if the card is write-protected
*/
LOCAL FLBoolean rfaWriteProtected
(
FLSocket vol /* pointer identifying drive */
)
{
return (FALSE);
}
/*******************************************************************************
*
* rfaWriteProtect - disable write access to the RFA
*
* This routine disables write access to the RFA.
*
* RETURNS: N/A
*/
LOCAL void rfaWriteProtect (void)
{
/* clear GPOEN1 bit (#17), make sure GPIO1 bit (#13) is clear */
/*VMECHIP2_IOCR = (*VMECHIP2_IOCR) & ((~IOCR_GPOEN1) & (~IOCR_GPIOO1_HIGH));*/
}
/*******************************************************************************
*
* rfaWriteEnable - enable write access to the RFA
*
* This routine enables write access to the RFA.
*
* RETURNS: N/A
*/
LOCAL void rfaWriteEnable (void)
{
/* set GPOEN1 bit (#17), make sure GPIO1 bit (#13) is clear */
/*VMECHIP2_IOCR = ((*VMECHIP2_IOCR) | IOCR_GPOEN1) & (~IOCR_GPIOO1_HIGH);*/
}
/*******************************************************************************
*
* flFitInSocketWindow - check whether the flash array fits in the socket window
*
* This routine checks whether the flash array fits in the socket window.
*
* RETURNS: A chip size guaranteed to fit in the socket window.
*/
long int flFitInSocketWindow
(
long int chipSize, /* size of single physical chip in bytes */
int interleaving, /* flash chip interleaving (1,2,4 etc) */
long int windowSize /* socket window size in bytes */
)
{
if (chipSize*interleaving > windowSize) /* doesn't fit in socket window */
{
int roundedSizeBits;
/* fit chip in the socket window */
chipSize = windowSize / interleaving;
/* round chip size at powers of 2 */
for (roundedSizeBits = 0; (0x1L << roundedSizeBits) <= chipSize;
roundedSizeBits++)
;
chipSize = (0x1L << (roundedSizeBits - 1));
}
return (chipSize);
}
#if FALSE
/*******************************************************************************
*
* sysTffsCpy - copy memory from one location to another
*
* This routine copies characters from the object pointed
* to by into the object pointed to by . If copying
* takes place between objects that overlap, the behavior is undefined.
*
* INCLUDE FILES: string.h
*
* RETURNS: A pointer to .
*
* NOMANUAL
*/
void * sysTffsCpy
(
void * destination, /* destination of copy */
const void * source, /* source of copy */
size_t size /* size of memory to copy */
)
{
bcopy ((char *) source, (char *) destination, (size_t) size);
return (destination);
}
/*******************************************************************************
*
* sysTffsSet - set a block of memory
*
* This routine stores converted to an `unsigned char' in each of the
* elements of the array of `unsigned char' beginning at , with size .
*
* INCLUDE FILES: string.h
*
* RETURNS: A pointer to .
*
* NOMANUAL
*/
void * sysTffsSet
(
void * m, /* block of memory */
int c, /* character to store */
size_t size /* size of memory */
)
{
bfill ((char *) m, (int) size, c);
return (m);
}
#endif /* FALSE */
/*******************************************************************************
*
* flDelayLoop - consume the specified time
*
* This routine consumes the specified time.
*
* RETURNS: N/A
*/
void flDelayLoop
(
int cycles /* loop count to be consumed */
)
{
while (--cycles)
;
}