Table of Contents
Introduction 
Specifications  
Hardware  
Flash Card  
Connecting To the Wildcard Bus   
Selecting the Wildcard Address   
Installing the CF Card  
CF Card Software Package User Guide and Glossary    
How To Install the CF Software   
Using the Driver Code with C  
Using the Driver Code with Forth  
CF Card Software   
Categorized List of Functions and Constants 
ATA Failure Codes  
ATA Primitives  
CF Card Information  
Directory   
File Access and Position Modes  
File I/O  
File Processing  
File System Error Handling 
Initialization  
Overview of Glossary Notation  
Using the File System Functions   
Commonly Used Terms   
String Parameters and the Use of THIS_PAGE   
Access Privileges  
Root Directory Only and File Name Restrictions   
File Position Indicator  
Error Handling  
Real-Time Clock on the Host Computer Enables Time/Date Marking of Files 12 
Initialization  
Automatic Initialization and File Processing 
Upgrade note for former Memory Interface Board (MIB) Users  
How To Create and Use an AUTOEXEC.QED File  
Compile a Program into Flash Memory  
Create a Set of Image Files   
Transfer the Image File Contents into Memory  
Restrictions on Software Upgrades  
Recovering from Buggy AUTOSTART.QED Files 
Compact Flash Card Software Package Main Glossary  
Upgrade Notice for Prior Users of the Memory Interface Board   
Sample  FILEDEMO.C  File (pdf) 
Sample  FILEDEMO.4th  File (pdf) 
CF Wildcard Hardware Schematic  
 | 
The Compact-Flash Wildcard and  CF Card Software Package User Guide
 << Previous | Next>> 
Compact Flash Card Software Package Main Glossary
C: APLUS_MODE 
4th:  APLUS_MODE  ( -- n ) 
A constant that is passed as a file-access privilege parameter to the File_Open function to indicate that the file may be read or written.  If APLUS_MODE is specified, random-access reads are allowed, but all data written to the file will automatically be appended (and the file pointer will be moved) to the end of the file regardless of the original file position.  See also R_MODE, W_MODE, A_MODE, RPLUS_MODE, and WPLUS_MODE. 
C:   int ATA_Command( xaddr xbuf, ulong startsector, uint numsectors, int cmd, int xfer_type,             int features) 
4th:  ATA_Command  ( xbuf\startsector\numsectors\cmd\xfer_type\features -- failure_code) 
This primitive function is rarely used by the programmer; it is called by higher level functions that perform Read, Write, ID Drive, and Set Features operations on the ATA device.  This routine performs the ATA command specified by parameter cmd, transferring data to/from the card as indicated by the xfer_type using the specified host data buffer starting at xaddress xbuf (the "host" is the Mosaic controller).  Command codes are specified by the ATA standard.  Valid transfer types are 0 (no transfer), 1 (card-to-host transfer), or 2 (host-to-card transfer).  The features parameter is used by the Set Features command (see ATA_Set_Features).  The returned failure parameter equals 0 if no error occurred; otherwise a FAIL_ code is returned to describe the error (see the glossary entries for the named constants that begin with "FAIL", and ATA_Fail).  If numsectors = 0, no sectors are transferred.  If numsectors > 255, the specified command is sent to the ATA device multiple times,  each time with sector_count constrained to the range 0 to 255.  The maximum value of numsectors is 65,535, leading to a maximum data transfer size of just under 32 Megabytes.  The actual number of sectors transferred can be determined by calling the Numsectors_Transferred function.  Make sure that ATA_ID_Drive has been executed since the last restart before calling this function; otherwise the specified command will not be executed, thereby protecting against reads and writes to an unknown device.  This function Gets and Releases the CF resource variable (located at the 4 bytes starting at FI) to manage multitask access.  This command works on hard drives up to 128 Gigabytes.  NOTE that accesses to the CF Card should NOT be executed from within an interrupt service routine, as the PAUSE operation called by the Get function may cause an infinite delay if invoked from within an interrupt routine. 
C: int ATA_Fail( void ) 
4th:  ATA_Fail  ( -- fail_code ) 
Returns the failure code from the most recently executed ATA command. The returned failure parameter equals 0 if no error occurred; otherwise a nonzero code is returned to describe the error.  If several errors occurred, the relevant bit-mask FAIL_ codes are OR'd together.  See the glossary entries for the named constants that begin with "FAIL". 
C:    int ATA_ID_Drive( xaddr xbuffer) 
4th:  ATA_ID_Drive  ( xbuffer -- failure_code) 
This function transfers 512 bytes of identification information from the ATA card to QED memory starting at the 32-bit QED address xbuffer.  This information is used by the higher level initialization functions to store relevant information about the card in the file system data structures.  The user typically does not invoke this command directly; rather, it is called by the high level functions Init_File_IO or Init_File_System which first call Init_File_Heap (which sets up the data structures used by this function) and then call this ATA_ID_Drive function.  This command must be called (via Init_File_IO or Init_File_System) after every powerup or restart, before other accesses to the ATA card;  otherwise the specified ATA access command will not be executed and higher level commands will return the ERR_FAIL_ID_DRIVE error code.  This scheme protects against reads and writes to an unknown device.   This command must be called (via Init_File_IO or Init_File_System) after a new ATA card is inserted into the CF Card socket.  The returned failure parameter equals 0 if no error occurred; otherwise a FAIL_ code is returned to describe the error (see the glossary entries for the named constants that begin with "FAIL").  If no error occurs during command, this routine initializes  the parameter used by the Card_Size function to report the number of bytes in the card. This function Gets and Releases the CF resource variable (located at the 4 bytes starting at FI) to manage multitask access.  NOTE that accesses to the CF Card should NOT be executed from within an interrupt service routine, as the PAUSE operation called by the Get function may cause an infinite delay if invoked from within an interrupt routine.  For implementation details, see ATA_Command.
C:    int ATA_Read( xaddr xbuf, ulong startsector, uint numsectors ) 
4th:  ATA_Read  ( xbuf\d.startsector\numsectors -- failure_code) 
Transfers data from the ATA flash card to QED memory (the "host").  The source sector in the ATA card is specified by the 32-bit startsector parameter.  The destination data is written starting at extended address xbuf in the QED memory.  The number of bytes transferred equals numsectors times 512 (see SECTOR_SIZE).  The returned failure parameter equals 0 if no error occurred; otherwise a FAIL_ code is returned to describe the error (see the glossary entries for the named constants that begin with "FAIL").  If numsectors = 0, no sectors are transferred.  The maximum value of numsectors is 65,535, leading to a maximum data transfer size of just under 32 Megabytes.  The actual number of sectors transferred can be determined by calling the Numsectors_Transferred function.  Make sure that ATA_ID_Drive has been executed since the last restart before calling this function; otherwise the specified command will not be executed, thereby protecting against reads and writes to an unknown device.  This function Gets and Releases the CF resource variable (located at the 4 bytes starting at FI) to manage multitask access.  This command works on hard drives up to 128 Gigabytes.  NOTE that accesses to the CF Card should NOT be executed from within an interrupt service routine, as the PAUSE operation called by the Get function may cause an infinite delay if invoked from within an interrupt routine.  For implementation details, see ATA_Command.  If for some reason you need to read the master boot record in the hidden sector region at the physical start of the drive, specify a startsector of -{Hidden_Sectors}; see the Hidden_Sectors glossary entry. 
C:  int ATA_Set_Features( int config_contents, int feature_contents ) 
4th:  ATA_Set_Features  ( config_contents\feature_contents -- failure_code) 
Writes to the ATA card to select features.  This command is typically not required and is not called by any of the high level file functions; it is included for completeness.  For example, the default features for Sandisk SDCFB series cards are correct without modification.  For most features, the config_contents parameter is irrelevant; the exception is the Sandisk set-current-limit feature; see the Sandisk product manual for details if you want to use this feature.   This function must be called AFTER invoking Init_File_IO or Init_File_System to ensure that FI points to a block of 300 bytes of available RAM, and a 32-bit zero must be stored into the extended address returned by FI to initialize the CF resource variable. The returned failure parameter equals 0 if no error occurred; otherwise a FAIL_ code is returned to describe the error (see the glossary entries for the named constants that begin with "FAIL").  This function gets and releases the CF resource variable to manage multitask access.  For implementation details, see ATA_Command. 
C: int ATA_Write( xaddr xbuf, ulong startsector, uint numsectors ) 
4th:  ATA_Write  ( xbuf\d.startsector\numsectors -- failure_code) 
Transfers data from QED memory (the "host") to the ATA flash card.  The source data starts at extended address xbuf in the QED memory.  The number of bytes transferred equals numsectors times 512 (see SECTOR_SIZE).  The destination sector in the ATA card is specified by the 32-bit startsector parameter.  The returned failure parameter equals 0 if no error occurred; otherwise a FAIL_ code is returned to describe the error (see the glossary entries for the named constants that begin with "FAIL").  If numsectors = 0, no sectors are transferred.  The maximum value of numsectors is 65,535, leading to a maximum data transfer size of just under 32 Megabytes.  The actual number of sectors transferred can be determined by calling the Numsectors_Transferred function.  Make sure that ATA_ID_Drive has been executed since the last restart before calling this function; otherwise the specified command will not be executed, thereby protecting against reads and writes to an unknown device.  This function Gets and Releases the CF resource variable (located at the 4 bytes starting at FI) to manage multitask access.  This command works on hard drives up to 128 Gigabytes.  NOTE that accesses to the CF Card should NOT be executed from within an interrupt service routine, as the PAUSE operation called by the Get function may cause an infinite delay if invoked from within an interrupt routine.  For implementation details, see ATA_Command. 
 << Previous | Next>> 
 |