Home
Manual
Contents
1. ere 89 ee gl e 90 si O 91 poems EIER 92 ee EE 93 POCOS eee PEE 94 PO MUSH e SY 95 por ad EE 96 omg idad 97 PO ISCO atese 98 PO UNSC OK d e 99 pO 111 100 eine EE 101 pe getumedia Ta enl bel MILL c eM aro S CE DAP DE S REP ENES 102 pc partition media eiie o tereti Et 103 p format Media M M M 104 pemeni mieb 105 oreste ES A EET LIORUM 108 tekel AES LEEN 109 peget AE 110 pe raw Tread DEE 111 PC RINT d du duat sens e s EE du deve SENE eee seine es Gend es eee ios 112 e E BT DEE 113 pc regression TES ES siia dai 114 TSS er PEE 115 Table of Contents 2 ERTFFS User Guide Section 29 ERTFS Pro API F NGCTIQNS iiiter ieu anaana ee cR d EIA L nd ndotet shi 117 pro bUtfer Statista Sh n ieu sets te Ones AA sl A isa 118 pro assign butter Pool asesino EE 120 Section 30 Failsafe Operating MOdG 2 2 tein e at ed entra e ette tad need hd at ee aspi aea seg ente saa tene basis telat na 121
2. 98 po DEEL sia ataca C LT IDEO DEESSET 99 POO CNNSI e s 100 po IN CAL TED ERUIT LL TII IE 101 pc get media Datis katet ec ndie A e St t ica 102 ores or ario media ORT E HK tete EE EM 103 per Form en ie AE 104 pestonmat UM en ed ee eee 105 reen DEE CME PA 108 pc get file extentS iii ol 109 PC Get free EE 110 po raw FO ER A X ae 111 PC raw Wnit comanda X die 112 po extend file ida T 113 pc regression test oie A A 114 TSE SMM 2 P Um 115 Section 28 ERTFS Application Programmer s Interface ee ERTFS User CTT ER Section 28 ERTFS Application Programmer s Interface ERTFS User Guide SS pc ertfs init This must be the first call to the ERTFS API in order to initialize ERTFS Summary BOOLEAN pc ertfs init void Description This function works in conjunction with pc ertfs config to configure and initialize ERTFS memory target support services and device drivers It also assigns drive letters to devices Note The section of the source code that selects device drivers and drive designators is designed to be user modifiable P
3. ERT S User Guide aaa Section 14 Porting Time Support Functions ERTFS User Guide SECTION 15 PORTING IDENTIFY CURRENT TASK ID ERTFS supports per task contexts for storing the task s current working directory context and the last errno value produced by ERTFS on behalf of that task In order to do this each executing task running ERTFS must have a unique task identifier The user is required to populate the function rtfs port get taskid to provide this service The function is described below Note Before a user task exits if it has used the ERTFS API it must call pc free user Failure to do this will cause ERTFS to run out of user context blocks Note This function requires no modification to run in polled mode If you do not implement this function in an RTOS environ ment you will lose the ability for each task to have it s own current working directory environment All tasks will share the same working directory In this case DO NOT call pc free user before tasks exit unsigned long rtfs port get taskid This function must return an unsigned long number that is unique to the currently executing task such that each time this function is called from the same task it returns this same unique number A typical implementation of this function would get address of the current task control block cast it and return it Note NUM USERS must be large enough to support the number of tasks See S
4. RIES PRINT STRING 1 USTRING TSTSH 19 PRFLG NL Usage WRITE fd data return 0 LSTOPEN Appendix G APPCMDSH C 180 ee i User Guide mmm int dolstop int agc byte agv EM int i RIES ARGSUSED INT agc RIES ARGSUSED PVOID PFVOID agv for i20 i lt MAXRND i if rnds i fd 1 RTFS PRINT LONG 1 dword rnds i fd 0 RTFS PRINT STRING 2 USTRING TSTSH 30 rnds i name PRFLG NL return 1 MKDIR PATH int domkdir int agc byte agv fn if agc 1 if pc mkdir agv return 1 else return 0 RTFS PRINT STRING 1 USTRING TSTSH 20 PRFLG NL Usage MKDIR D PATH return 0 RMDIR PATH int dormdir int agc byte agv EM if agc 1 if pc rmdir agv return 1 else return 0 RTFS PRINT STRING 1 USTRING TSTSH 21 PRFLG NL Usage RMDIR D PATH n return 0 DELTREE PATH int dodeltree int agc byte agv fn if agc 1 if pc deltree agv return 1 else return 0 RTFS PRINT STRING 1 USTRING TSTSH 22 PRFLG NL Usage DELTREE D PATH return 0 Appendix G APPCMDSH C 181 O i User Guide mmm DELETE PATH byte rmfil EMAXPATH byte rmpath EMAXPATH byte tfile EMAXPATH byte rmpath EMAXPATH int dorm int agc byte agv P fn MY DSTAT statobj if agc 1 Get the path rts cs strcpy amp rmfil 0
5. rtfs print prompt user UPROMPT TSTSH12 working buffer partition list 1 dword rtfs atol vvorking buffer partition list 2 0 if partition_list O 0 dword partition_list 0 partition_list 1 gt geometry dev_geometry_lbas Section 28 ERTFS Application Programmer s Interface 106 ERTFS User Guide Format Bad input for partition values Press return rtfs print prompt user UPROMPT TSTSH13 working buffer goto return error else RTFS_PRINT_STRING_1 USTRING_TSTSH_70 0 The drive contains this many cylinders RTFS PRINT LONG _1 dword geometry dev_geometry_cylinders PRFLG_NL Format Select the number of cyls for the first partition rtfs print prompt user UPROMPT TSTSH14 working buffer partition list 0 word rtfs atoi vvorking buffer partition list 1 0 if partition list 0 geometry dev geometry cylinders RTFS PRINT STRING 1 USTRING TSTSH 71 0 There are this many cylinders remainng RTFS PRINT LONG 1 dword geometry dev geometry cylinders partition list 0 PRELG NL Format Select the number of cyls for the second partition rtfs print prompt user UPROMPT TSTSH15 working buffer partition list 1 dword rtfs atol vvorking buffer partition list 2 0 if partition_list O 0 dword partition list 0 partition list 1 gt geometry dev geometry cylinders Format Bad inpu
6. Calling media format if Ipc format media path amp geometry DISPLAY_ERRNO pc_format_media Format Media format failed Press return rtfs print prompt user UPROMPT TSTSH8 working buffer goto return error Partition the drive if it needs it if pdr drive flags amp DRIVE FLAGS PARTITIONED Format Press Y to partition media rtfs print prompt user UPROMPT TSTSHO buf if tstsh is yes buf if geometry dev_geometry_lbas do Format Press Y to USE LBA formatting N to use CHS rtfs_print_prompt_user UPROMPT_TSTSH10 buf while Itstsh is yes buf amp amp tstsh_is_no buf if tstsh_is_no buf geometry dev_geometry_lbas 0 if geometry dev_geometry_lbas RTFS PRINT STRING 1 USTRING TSTSH 68 0 The drive is contains this many logical blocks RTFS PRINT LONG 1 dword geometry dev geometry Ibas PRFLG NL Format Select the number of Ibas for the first partition rtfs print prompt user UPROMPT TSTSH11 working buffer partition list 0 dword rtfs atol vvorking buffer partition list 1 0 if partition list 0 geometry dev geometry Ibas RTFS PRINT STRING 1 USTRING TSTSH 69 0 This many logical blocks remain RTFS PRINT LONG 1 dword geometry dev geometry Ibas partition list 0 PRELG NL Format Select the number of Ibas for the second partition
7. H S ERTFS User Guide uur r r r Example 1 Multilevel directory scan and print int rdir callback byte path DSTAT d printf s n path return 0 rdir byte path byte pattern pc enumerate from path from pattern spath dpath path MATCH DIRIMATCH VOL MATCH FILES pattern 99 rdir callback Example 2 Poor mans deltree package int delfile callback byte path DSTAT d pc unlink path return 0 int deldir_callback byte path DSTAT d pc rmdir path return O deltree byte path int i First delete all of the files pc enumerate from path from pattern spath dpath path MATCH FILES gt 99 delfile callback i7 0 gt Now delete all of the dirs Deleting path won t work until the tree is empty while pc rmdir path amp amp i lt 50 pc enumerate from path from pattern spath dpath path MATCH DIR 99 deldir callback Section 28 ERTFS Application Programmer s Interface ERTFS User Guide mmm get errno Get the last ERTFS assigned errno value for the calling task Summary int get_errno void Description This function retrieves the last ERRNO value set by ERTFS for this task See Also Example If Ipc mkdir Test printf mk dir failed ERRNO d n get errno Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide UOU r roz rtfs set driver errno Provided so device driver writers can
8. USTRING TSTSHCMD 16 dodeltree USTRING_TSTSHHELP_ 16 USTRING TSTSHCMD 17 dodevinfo USTRING TSTSHHELP 17 USTRING TSTSHCMD 18 dodiff USTRING TSTSHHELP 18 USTRING TSTSHCMD 19 dols USTRING TSTSHHELP 19 USTRING TSTSHCMD 20 doselect USTRING TSTSHHELP 20 USTRING TSTSHCMD 21 echo USTRING TSTSHHELP 21 USTRING TSTSHCMD 23 dofillfile USTRING TSTSHHELP 23 USTRING TSTSHCMD 24 doformat USTRING TSTSHHELP 24 USTRING TSTSHCMD 25 dogetattr USTRING TSTSHHELP 25 USTRING TSTSHCMD 27 dolstop USTRING TSTSHHELP 27 USTRING TSTSHCMD 28 domkdir USTRING TSTSHHELP 28 USTRING TSTSHCMD 30 0 USTRING TSTSHHELP 30 USTRING TSTSHCMD 31 doread USTRING TSTSHHELP 31 USTRING TSTSHCMD 32 domv USTRING TSTSHHELP 32 USTRING TSTSHCMD 33 dormdir USTRING TSTSHHELP 33 USTRING TSTSHCMD 34 rndop USTRING TSTSHHELP 34 USTRING TSTSHCMD 35 doseek USTRING TSTSHHELP 35 USTRING TSTSHCMD 36 dosetattr USTRING TSTSHHELP 36 HELP CAT PATH CHSIZE FILENAME NEWSIZE CD PATH or CD for PWD CHKDSK D 0 1 CLOSE FDNO P COPY PATH PATH DELETE PATH DELTREE PATH P DEVINFO DIFF PATH PATH DIR PATH JP DSKSEL D ECHO args FILLFILE PATH PATTERN NTIMES JP FORMAT JP GETATTR FILE LSTOPEN MKDIR PATH P QUIT READ FDNO RENAME PATH NEWNAME RMDIR PATH RNDOP PATH RECLEN SEEK FDNO RECORD
9. else return 0 Section 30 Failsafe Operating Mode 146 n ERTFS User Guide Z Qu Example 4 pro failsafe init has already been called use pro failsafe restore to determine the state of the journal file intfs demo journal status byte drivename int rval rval pro failsafe restore drivename 0 FALSE FALSE Switch rval case FS STATUS OK printf FAILSAFE Volume up to date no restore required break case FS STATUS NO JOURNAL printf FAILSAFE no journal present break case FS STATUS BAD JOURNAL printf FAILSAFE bad journal file presenti break case FS STATUS BAD CHECKSUM printf FAILSAFE journal file has checksum error n break case FS STATUS IO ERROR printf FAILSAFE IO error during restore n break case FS STATUS MUST RESTORE printf FAILSAFE Restore required break case FS STATUS OUT OF DATE printf FAILSAFE Volume and Failsafe File are out of synch Wn break case FS STATUS NO INIT printf FAILSAFE Failsafe must be initialized or a context must be provided to execute restore break default printf FAILSAFE Restore unexpected return code d rval break Section 30 Failsafe Operating Mode 147 ERTFS User Guide Z QQ Qu Example 5 pro failsafe init has not been called use pro failsafe restore to restore the volume from the journal file FAILSAFECONTEXT fscontext int fs demo restore volume byte drivename int
10. Appendix C APICONFG C 160 ERTFS User Guide mmm APPENDIX D APPINIT C EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS run time device driver init file BOOLEAN pc ertfs init void int j DDRIVE par int drives used byte drname 8 Temp buffer for displaying drive letters as strings Call the user supplied configuration function prtfs_cfg 0 if Ipc_ertfs_config return FAL SE if pc memory init return FALSE pdr prtfs cfg mem drives structures drives used 0 if INCLUDE FLOPPY if drives used gt prtfs_cfg gt cfg_NDRIVES goto need more drives Floppy as A pdr gt driveno 0 II MAPS DRIVE structure to A pdr gt dev table drive io floppy io pdr dev table perform device ioctl floppy perform device ioctl STORE DEVICE NAME Floppy unit 0 pdr register file address dword 0 N Not used for floppy pdr z interrupt number 0 1 Not used for floppy pdr gt drive_flags 0 Set by warmstart pdr gt partition_number 0 II pdr gt pcmcia_slot_number 0 1 Not used for floppy pdr controller number 0 pdr gt logical_unit_number 0 pdr endif if INCLUDE IDE VO addresses and interrupts used for ATA devices E Primary Secondary Tertiary Quaternary 0x01f0 0x0170 Ox01e8 0x0168 0x03f6 0x0376 Ox03ee 0x036e k 14 15 11 10 Note 1 for interrupt
11. prtfs cfg fat hash table 3 FATBUFF prtfs cfg fat hash table 4 FATBUFF prtfs cfg fat hash table 5 FATBUFF prtfs cfg fat hash table 6 FATBUFF prtfs cfg fat hash table 7 FATBUFF prifs cfg fat hash table 8 FATBUFF prtfs cfg fat hash table 9 FATBUFF fat hash table OJOJ fat hash table 110 fat hash table 210 fat hash table 3 0 fat hash table 4 0 fat hash table OI fat hash table 6 0 fat hash table 7 0 fat hash table 8 0 fat hash table 9 0 amp amp amp amp amp amp amp amp amp amp prtfs cfg fat primary cache 0 byte prtfs cfg fat primary cache 1 byte prtfs cfg fat primary cache 2 byte prtfs cfg fat primary cache 3 byte prtfs cfg fat primary cache 4 byte prtfs cfg fat primary cache 5 byte prtfs cfg fat primary cache 6 byte prtfs cfg fat primary cache 7 byte prtfs cfg fat primary cache 8 byte prtfs cfg fat primary cache 9 byte amp fat primary cache O 0 A fat primary cache 1 0 amp fat primary cache 210 A fat primary cache 3 0 amp fat primary cache 410 A fat primary cache 5 0 amp fat primary cache 6 0 A fat primary cache 7 0 amp fat primary cache 8 0 A fat primary cache 9 0 YS prtfs cfg fat primary index 0 dword
12. Here is the source code for the model event handler void mgmt isr void i int i byte card status for 120 i lt NSOCKET i i card status pd67xx read i 0x04 Write the status register to clear pd67xx write i 0x04 Oxff if card status i if pcmctrl card is installed i FALSE pcmctr 1 card down i DO int j DDRIVE pdr for j 0 j lt prtfs cfg cfg NDRIVES j i pdr pc drno to drive struct j if pdr amp amp pdr drive flags DRIVE FLAGS PCMCIA amp amp pdr drive flags DRIVE FLAGS VALID amp amp pdr pcmcia slot number i amp amp pdr pcmcia controller number 0 pdr dev table perform device ioctl pdr gt driveno DEVCTL_REPORT_REMOVE PFVOID 0 Section 21 Porting PCMCIA 46 ERTFS User Guide SECTION 22 PORTING 82365 PCMCIA CONTROLLER Note Several routines are provided in the porting layer to support the 82365 pcmcia controller device driver in the file drpc mcil c If you are not using PCMCIA or are not using and 82365 class controller you can skip this section void hook 82365 pcmcia interrupt int irq This routine must establish an interrupt handler that will call the plain C routine void mgmt isr void when the chip s man agement interrupt event occurs The value of the argument irq is the interrupt number that was put into the 82365 s manage ment interrupt selection register and is between 0 and 15
13. INDEX TEST Test mapping with no cache INDEX TEST Filling Journal File in ascending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in descending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in random order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Testing Index Checksum Error INDEX TEST Testing Index Out of Date Error INDEX TEST Testing Journal File Signature Error INDEX TEST Testing Good Journal File INDEX TEST Testing Journal File Full INDEX TEST Test mapping with cache and very large journal INDEX TEST Filling Journal File in ascending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in descending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in random order INDEX TEST Testing Journal Block Searh Section 30 Failsafe Operating Mode 134 ERTFS User Guide mmm INDEX TEST Testing Sorted Journal Block List INDEX TEST Testing Index Checksum Error INDEX TEST Testing Index Out of Date Error INDEX TEST Testing Journal File Signature Error INDEX TEST Testing Good Journal File INDEX TEST Success NVIO TEST Begin NVIO TEST verify jour
14. SETATTR D PATH RDONLY HIDDEN SYSTEM ARCHIVE NORMAL USTRING TSTSHCMD 37 dostat USTRING TSTSHHELP 37 USTRING TSTSHCMD 38 dowrite USTRING TSTSHHELP 38 USTRING TSTSHCMD 39 doregress USTRING TSTSHHELP 39 USTRING TSTSHCMD 40 domkhostdisk USTRING TSTSHHELP 40 USTRING TSTSHCMD 41 domkrom USTRING TSTSHHELP 41 0 E void tst shell void P fn DISPATCHER pcmd int agc 0 byte agv 20 int i rtts memset PFBYTE rnds 0 sizeof RNDFILE MAXRND for i 0 i lt MAXRND i rnds i fd 7 1 dohelp agc agv Execute commands from the command table until the users types QUIT STAT PATH WRITE FDNO QUOTED DATA REGRESSTEST D MKHOSTDISK win9xpath MKROM Appendix G APPCMDSH C 177 ERTFS User Guide uro Q ov pemd lex amp agc amp agv 0 while pcmd if Ipemd gt proc return i pcmd proc agc amp agv 0 pemd lex amp agc amp agv 0 DSKSEL PATH int doselect int agc byte agv EM if agc 1 if Ipc set default drive agv RIES PRINT STRING 1 USTRING TSTSH 03 PRFLG NL Set Default Drive Failed return 0 return 1 else RTFS PRINT STRING 1 USTRING TSTSH 04 PRFLG NL Usage DSKSELECT D return 0 RNDOP PATH RECLEN int rndop int agc byte agv P mn RNDFILE rndf if agc 2 rndf fndrnd 1 if Irndf RTFS PRINT STRING 1
15. Summary include lt ertfs h gt BOOLEAN po useek PCFD fd unsigned long offset unsigned long pnew offset int origin Description Move the file pointer offset bytes from the origin described by origin Origin may have the following values PSEEK SET Seek from beginning of file PSEEK CUR Seek from the current file pointer PSEEK CUR NEG Seek from the current file pointer minus unsigned 32 bit offset PSEEK END Seek from end of file The new file pointer is returned in pnew offset Returns TRUE The seek was succesful and the new offset is in pnew offset FALSE An error occured errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEINVALIDPARMS Attempt to seek past EOF or to a negative offset PEINVALIDCLUSTER Files contains a bad cluster chain An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface i User Guide mmm po chsize Truncate or extend an open file Summary include lt ertfs h gt int po chsize PCFD fd long offset Description Given a file handle and a new file size either extend the file or truncate it If the current file pointer is still within the range of the file it is unmoved otherwise it is moved to the end of
16. You must set this to the size of the block hash table Each entry in the table takes up 4 bytes This value must be a power of two Drive name Null terminated drive designator for example Ay block_hash_table User supplied memory for the block hash table This must be a pointer to an array of data of type BLKBUF containing block hashtable size elements It must remain valid for the whole session and must not be deallocated block buffer pool size You must set this to the size of the block buffer pool Each entry in buffer pool requires ap proximately 540 bytes block buffer pool data User supplied memory for the block buffer pool This must be a pointer to an array of data of type BLKBUF containing block buffer pool size elements It must remain valid for the whole session and must not be deallocated Note Please see section 3 of the ERTFS User s Manual for a more complete discussion of these elements Returns TRUE Success FALSE Failure If FALSE is return errno will be set to one of the following PEINVALIDDRIVEID Drive argument invalid PEINVALIDPARMS Invalid parameters PEINVALIDDRIVEID Invalid drive An ERTFS system error Section 29 ERTFS Pro API Functions 120 ERTFS User Guide SECTION 30 FAILSAFE OPERATING MODE INTRODUCTION Failsafe mode provides a means to eliminate the risk of file system corruption that results from unexpected power interruptions and media removal events Failsafe works by
17. agv if pc gfirst amp statobj amp rmfil 0 do Construct the path to the current entry ASCII 8 3 pc asch mfile byte tfile 0 byte amp statobj fname 0 byte amp statobj fext 0 pc mpath byte amp rmpath 0 byte amp statobj path 0 byte amp tfile 0 Convert to native character set if needed CS OP ASCII TO CS STR amp rmpath 0 amp rmpath 0 if Ipc_isdir rmpath amp amp pc_isvol rmpath RIES PRINT STRING 2 USTRING TSTSH 23 rmpath PRFLG NL P deleting gt if Ipc_unlink rmpath RIES PRINT STRING 2 USTRING TSTSH 24 rmpath PRFLG NL P Can not delete while pc gnext amp statobj pc gdone amp statobj return 1 RTFS PRINT STRING 1 USTRING TSTSH 25 PRFLG NL Usage DELETE D PATH return 0 RENAME PATH NEWNAME int domv int agc byte agv P fn if agc 2 if pc mv agv agv 1 return 1 else return 0 RTFS PRINT STRING 1 USTRING TSTSH 26 PRFLG NL Usage RENAME PATH NEWNAME return 0 CD PATH int docwd int agc byte agv EM byte Ibuff 100 if agc 1 Appendix G APPCMDSH C 182 ee i User Guide mmm if pc set cwd agv return 1 else RTFS PRINT STRING 1 USTRING TSTSH 27 PRFLG NL Set cwd failed return 0 else if pc pwd rtfs strtab user string USTRING SYS NULL Ibuff RIES PRINT STRING 2 USTRING SYS NULL Ibuff P
18. fat buffers array entries for the drives that you are not using If you are not using ALLOC FROM HEAP you should then also add or remove the static memory array declarations we use to reserve the memory at compile time NUM USERS The maximum number of USER contexts Set this to the number of tasks that will simultaneously use ERTFS For polled mode setitto one The default is 1 NBLKBUFFS Number of blocks in the block buffer pool ERTFS uses 536 bytes per block buffer pool entry This setting impacts performance during directory traversals It must be at least 4 More than 20 is rarely required The default is 16 BLKHASHSIZE Size of the block buffer hash table This value must be a power of two for example 2 4 8 16 32 64 128 256 512 If itis not a power of two the behavior is undefined Increasing the hash table size increases the speed of block buffer pool accesses Four bytes are required per hash table entry While the block cache size can impact performance it only has a significant impact on systems performing operations on volumes populated with large numbers of files and or subdirectories The hash table size and the number of buffers do not have to be the same A theoretical increase in performance will be achieved by increasing the hash table size even if it is greater than the number of buffers The default is 16 Notes 1 ERTFS PRO provides an API call named pc assign buffer pool to assign a private buffer pool and hash
19. free prtfs_cfg gt fat_buffers 3 free prtfs_cfg gt fat_buffers 4 free prtfs_cfg gt fat_buffers 5 if prtfs_cfg gt fat_buffers 6 if prtfs_cfg gt fat_buffers 7 if prtfs_cfg gt fat_buffers 8 if prtfs_cfg gt fat_buffers 9 if prtfs_cfg gt fat_hash_table 0 if prtfs_cfg gt fat_hash_table 1 if prtfs_cfg gt fat_hash_table 2 Appendix C APICONFG C 158 free prtfs_cfg gt fat_buffers 6 free prtfs_cfg gt fat_buffers 7 free prtfs_cfg gt fat_buffers 8 free prtfs_cfg gt fat_buffers 9 free prtfs_cfg gt fat_hash_table 0 free prtfs_cfg gt fat_hash_table 1 free prtfs_cfg gt fat_hash_table 2 uS ERTFS User Guide mmm if prtfs cfg fat hash table 3 free prtfs cfg fat hash table 3 if prtfs cfg fat hash table 4 free prtfs_cfg gt fat_hash_table 4 if prtfs_cfg gt fat hash table 5 free prtfs cfg fat hash table 5 if prt s cfg fat hash table 6 free prtfs_cfg gt fat_hash_table 6 if prtfs cfg fat hash table 7 free prtfs cfg fat hash table 7 if prtfs cfg fat hash table 8 free prtfs cfg fat hash table 8 if prtfs cfg fat hash table 9 free prtfs cfg fat hash table 9 if prtfs cfg fat primary cache 0 free prtfs cfg fat primary cache 0 if prtfs cfg fat primary cache 1 free prtfs cfg gt fat primary cache 1 if prtfs cfg fat primary cache 2 free prtfs cfg gt fat primary cache 2 if prtfs cfg fat primary cache 3
20. goto difffail po_close in_fd po_close in_fd1 return 1 else RIES PRINT STRING 1 USTRING TSTSH 55 PRFLG NL Usage DIFF PATH PATH return 0 FILLFILE PATH PATTERN NTIMES int dofillfile int agc byte agv fn PCFD out fd byte workbuf 255 word bufflen int ncopies if agc 3 Appendix G APPCMDSH C 188 M ERTFS User Guide mmm ncopies int rtfs atoi agv 2 if Incopies ncopies 1 if out fd po open agv vvord PO BINARY PO WRONLY PO CREAT word PS IWRITE PS IREAD lt 0 RTFS PRINT STRING 2 USTRING TSTSH 56 agv PRFLG NL Cant open file return 0 rtfs_cs_strcpy workbuf agvt1 rtfs_strcat workbuf r bufflen word rtfs_strlen workbuf while ncopies if po write out fd byte workbuf word bufflen int bufflen RTFS PRINT STRING 1 USTRING TSTSH 57 PRFLG NL write failure po close out fd return 0 po_close out_fd return 1 else RTFS PRINT STRING 1 USTRING TSTSH 58 PRFLG_NL Usage FILLFILE PATH PATTERN NTIMES return 0 STAT PATH int dostat int agc byte agv fn struct stat st byte display buffer 100 if agc 1 if pc stat agv amp st 0 rtfs print format stat display buffer amp st RTFS PRINT STRING 1 USTRING TSTSH 59 0 MODE BITS if st st_mode amp S_IFDIR RIES PRINT STRING 1 USTRI
21. FALSE TRUE FALSE if check media driveno FALSE TRUE FALSE Format check media failed Press return rtfs print prompt user UPROMPT TSTSH5 working buffer return 1 This must be called before calling the later routines if Ipc get media parms path amp geometry Format get media geometry failed Press return rtfs print prompt user UPROMPT TSTSH6 working buffer return 1 Call the low level media format Do not do this if formatting a volume that is the second partition on the drive Format Press Y to format media rtfs print prompt user UPROMPT TSTSHT buf if tstsh is yes buf RTFS PRINT STRING 1 USTRING TSTSH 67 PRFLG NL Calling media format if pc format media path amp geometry Appendix G APPCMDSH C 190 ee i User Guide mmm I Format Media format failed Press return rtfs print prompt user UPROMPT TSTSHSB working buffer return 1 Partition the drive if it needs it if pdr 2drive flags amp DRIVE FLAGS PARTITIONED Format Press Y to partition media rtfs print prompt user UPROMPT TSTSHS buf if tstsh is yes buf if geometry dev geometry Ibas do Format Press Y to USE LBA formatting N to use CHS rtfs_print_prompt_user UPROMPT_TSTSH10 buf while tstsh_is_yes buf amp amp tstsh_is_no buf if tstsh_is_no buf geometry
22. It is passed the drive number a read or write flag the first sector number on the device to read write the count of blocks and the address of a buffer to move the data to or from If the transfer succeeds it must return TRUE if it fails it must return FALSE SECTION 27 2 THE DEVICE I O CONTROL FUNCTION The device I O control subroutine takes three arguments the logical drive number an op code and a void pointer to a parame ter passing memory area The return values of return codes and the structure of the parameter passing array depend on which op code is being processed The requirements for each op code are described in this section int xxx perform device ioctl driveno opcode pargs int driveno driveno is 0 1 2 25 for drives A B C Z int opcode One of op codes described below void pargs A void pointer to an argument block Currently the only defined use of pargs is to pass device geometry information from the driver to the ERTFS format tools The device driver is required to implement an I O control function that handles the following op codes Device I O Control op codes that must be implemented DEVCTL WARMSTART DEVCTL CHECKSTATUS DEVCTL GET GEOMETRY DEVCTL FORMAT DEVCTL REPORT REMOVE Device I O Control op codes that are optional DEVCTL POWER RESTORE DEVCTL POWER LOSS SECTION 27 3 I O CONTROL OP CODE DEVCTL WARMSTART int xxx perform device ioctl driveno DEVCTL WARMSTART 0 Must return
23. Ox1f Hour st st atime time gt gt 5 amp Ox3f Minute printf OPTIMAL BLOCK SIZE 7ld FILE size BLOCKS 7ld n st st blksize st st blocks printf MODE BITS if stst mode amp S IFDIR printf S_IFDIR if s st mode amp S IFREG printf S_IFREG if st st_mode amp S_IWRITE printf S_IWRITE if s st mode amp S IREAD printf S_IREAD n printf n Section 28 ERTFS Application Programmer s Interface m ERTFS User Guide mmm pc fstat Return properties of a file associated with a file descriptor Summary include lt ertfs h gt int pc fstat PCFD file descriptor ERTFS STAT pstat Description This routine uses the file descriptor in the first argument and fills in the stat structure as described here st dev the entry s drive number st mode S IFMT type offile mask S IFCHR character special unused S IFDIR directory S IFBLK block special unused S IFREG regular a file S IWRITE Write permitted S IREAD Read permitted st rdev the entry s drive number st size file size st atime creation date in DATESTR format st mtime creation date in DATESTR format st ctime creation date in DATESTR format t blksize optimal blocksize for I O cluster size t blocks blocks allocated for file fattributes the DOS attributes This is non standard but supplied if you want to look at them NOTE ERTFS STAT structure is equivalent to
24. Returns TRUE Success FALSE Failure If FALSE is returned errno will be set to one of the following PEINVALIDDRIVEID Drive argument invalid PEJOURNALOPENFAIL Journal file or vram init call failed PEIOERRORREAD Error reading FAT or buffer area PEIOERRORWRITEJOURNAL Error writing journal file or NVRAM section PEIOERRORWRITEFAT Error writing FAT area PEIOERRORWRITEBLOCK Error writing directory area An ERTFS system error Section 30 Failsafe Operating Mode 132 ee ERTFS User Guide mmm fs_test Function Test Failsafe mode Summary BOOLEAN fs_test byte path Description Perform a series of tests on ERTFS Pro to verify correct functioning of FailSafe mode Returns TRUE if all test succeeded FALSE Atest failed Review output or use a debugger to determine what failed Note fs test sends output to the console through the macro FSDEBUG FSDEBUG is defined in the source file prfstest c as define FSDEBUG X printf s n X To run quietly replace this definition with the following define FSDEBUG X The following tests are performed INDEX TEST This set of tests checks for correct functioning of the FailSafe indexing and caching functions Over 50 tests are employed to verify correct functioning of the indexing and caching under varying normal conditions and error conditions NVIO TEST This set of tests verifies correct creation and placement of the journal file when the
25. int n clusters cluster size pc cluster size C n clusters n to write cluster size 1 cluster size po extend file fd n clusters PC FIRST FIT Section 28 ERTFS Application Programmer s Interface 108 G S ERTFS User Guide mmm pc get file extents Get the list of block segments that make up a file Summary include lt ertfs h gt int pc get file extents PCFD fd int infolistsize FILESEGINFO plist BOOLEAN raw Where FILESEGINFO is a structure defined as typedef struct fileseginfo long block Block number of the current extent long nblocks Number of blocks in the extent FILESEGINFO And infolistsize is the number of elements in the storage pointed to by plist If raw is TRUE the blocks are reported as block offsets from the physical base of the drive otherwise the block offset origin is the beginning of the partition Set raw to TRUE if you will be using the resultant list to set up DMA transfers to or from the disk Description This routine traverses the cluster chain of the open file fd It logs into the list at plist and gets the block location and length in blocks of each segment of the file The block numbers and block length information can then be used to read and write the file directly using pc raw read and DC raw write or the information may be used to set up DMA transfers to or from the raw block locations If the file contains more extents than will fit in plist as indicated by infolist
26. new bytes If itn bytes is not returned the files was not extended errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEACCES File is read only Section 28 ERTFS Application Programmer s Interface 113 ERTFS User Guide pc regression test ERTFS File system port exercise and test routine Summary include lt ertfs h gt BOOLEAN pc regression test byte driveid BOOLEAN do clean Description This routine stress tests ERTFS exercises most API calls and tests for memory leaks It runs in a loop which creates a direc tory and then creates N subdirectories below that Finally the inner loop creates NUSERFILES files writes to them reads from them seeks truncates closes renames and deletes them Along the way it checks the set current working directory and get working directory calls When the inner loop exits it checks to be sure no free space was lost There are a few functions that do not get tested they are pc gfirst pc gnext pc gdone Note that all modes of po open and po Iseek are tested These are options that may be modified in the source code USEPRINTF Setthis to zero to run completely quiet If this is done you should set a break point in regress error to catch errors test dir The directory where the tes
27. pc get attributes agv amp attr RTFS PRINT STRING 1 USTRING TSTSH 72 0 Attributes if attr amp ARDONLY RTFS PRINT STRING 1 USTRING TSTSH 73 0 ARDONLYN if attr amp AHIDDEN RTFS PRINT STRING 1 USTRING TSTSH 74 0 AHIDDEN if attr amp ASYSTEM RTFS PRINT STRING 1 USTRING TSTSH 75 0 ASYSTEMI Appendix G APPCMDSH C 192 ee i User Guide mmm if attr amp AVOLUME RIES PRINT STRING 1 USTRING TSTSH 76 0 AVOLUME if attr amp ADIRENT RIES PRINT STRING 1 USTRING TSTSH 77 0 ADIRENT if attr 8 ARCHIVE RTFS PRINT STRING 1 USTRING TSTSH 78 0 ARCHIVEN if attr ANORMAL RTFS PRINT STRING 1 USTRING TSTSH 79 0 NORMAL FILE No bits set RIES PRINT STRING 1 USTRING SYS NULL PRFLG NL return 0 else RTFS PRINT STRING 1 USTRING TSTSH 81 PRFLG NL get attributes failed return 0 RTFS PRINT STRING 1 USTRING TSTSH 82 PRFLG NL Usage GETATTR D PATH return 0 GETATTR PATH int dosetattr int agc byte agv fn byte attr attr 0 if agc 2 if Ipc get attributes agv amp attr RIES PRINT STRING 1 USTRING TSTSH 83 PRFLG NL P Can not get attributes return 0 if rtfs cs stremp agv 1 rtfs strtab user string USTRING TSTSH 84 20 RDONLY attr ARDONLY else if rtfs_cs_stremp agv 1 rtfs_strtab_user_string USTRIN
28. 4 IDE_OFF_CYL_LOW of the ide register file register_file_address byte ide_rd_cyl_low dword register_file_address i return RTFS INBYTE word register file address 4 This function must return the byte in location 5 IDE OFF CYL HIGH of the ide register file register file address byte ide_rd_cyl_high dword register_file_address return RTFS_INBYTE word register_file_address 5 This function must return the byte in location 6 IDE OFF DRIVE HEAD of the ide register file register file address byte ide_rd_drive_head dword register_file_address return RTFS_INBYTE word register_file_address 6 This function must return the byte in location 0x207 IDE OFF DRIVE ADDRESS of the ide register file at register file address The offset in the register file may also be 15 rather then 0x207 if the device is running in contiguous I O mode byte ide_rd_drive_address dword register_file_address return RTFS_INBYTE word register_file_address 0x207 Appendix F PORTIO C 173 M i User Guide mmm This function must place the byte in value at location 0x206 IDE OFF ALT STATUS of the ide register file at register file address The offset in the register file may also be 14 rather then 0x206 if the device is running in contiguous I O mode void ide_wr_dig_out dword register_file_address byte value RTFS_OUTBYTE word register_file_address 0x206
29. DISK Note These routines are provided to support the floppy disk device driver in drfloppy c If your application will not be using a floppy disk device please ignore this section The floppy driver is for NEC 756 class controllers and is primarily for PC architectures but it can be made to work in non PC environments Six routines are listed here as routines that may need modification In a standard PC environment the only routine that will need changing is the hook interrupt routine this routine will need modification to support your RTOS interrupt hook and dispatch method void hook floppy interrupt int irq This routine is called by the floppy disk device driver It must establish an interrupt handler such that the plain C function void floppy isr void is called when the floppy disk interrupt occurs The value in irq is always 6 This is the PC s standard map ping of the floppy interrupt If this is not correct for your system just ignore the irq argument get floppy type int driveno The source for this routine is in file drfloppy c It is hardwired to return DT 144 1 44MB 3 5 inch floppy disk by far the most common floppy disk drive type in use The source code is self explanatory and describes what values to return for other drive types BOOLEAN fl dma init This routine must set up a DMA transfer for the floppy device driver The source for this routine is in file drfloppy c It is hardwired to start the appropriate
30. M H OS ERTFS User Guide mmm partition list O word rtfs atoi working buffer partition list 1 0 if partition list 0 geometry dev geometry cylinders RTFS PRINT STRING 1 USTRING TSTSH 71 0 There are this many cylinders remainng RIES PRINT LONG 1 dyvord geometry dev geometry cylinders partition listjoj PRFLG NL Format Select the number of cyls for the second partition rtfs print prompt user UPROMPT TSTSH15 working buffer partition list 1 dword rtfs atol working buffer partition list 2 0 if partition listjoj 0 dword partition_list O partition_list 1 gt geometry dev geometry cylinders Format Bad input for partition values Press return rtfs print prompt user UPROMPT TSTSH13 working buffer return 1 if Ipc partition media path amp geometry amp partition list 0 Format Media partition failed Press return rtfs print prompt user UPROMPT TSTSH16 working buffer return 1 Put the DOS format Format Press Y to format the volume rtfs print prompt user UPROMPT TSTSH17 buf if tstsh is yes buf if pc format volume path amp geometry Format Format volume failed Press return rtfs print prompt user UPROMPT TSTSH18 working buffer return 1 return 0 GETATTR PATH int dogetattr int agc byte agv PPM byte attr if agc 1 if
31. PORTING IDE AND COMPACT FLASH This section describes actions that must be taken by the user to support the ERTFS ATA ATAPI device driver that is imple mented in the file drideata c Note If you are not using ATA ATAPI or compact flash based devices in your application skip this section To support this device driver the user must populate several register access functions and provide an interrupt service layer if he wishes to run the device in interrupt driven mode versus polled mode void hook ide interrupt int irq int controller number The user must provide this function if he desires to use the IDE driver in interrupt mode If you don t wish to use the ATA driver in interrupt mode make sure that the value of pdr z interrupt number is set to 1 inside pc ertfs init for the ide device and skip this section since ide hook interrupt will then not be called hook ide interrupt is called with the interrupt number in the argument irq taken from the user s setting of pdr gt interrupt_ number in pc ertfs init Controller number is taken from the pdr controller number field as set in pc ertfs init by the user hook ide interrupt must establish an interrupt handler such that the plain C function void ide isr int controller _ number is called when the IDE interrupt occurs The argument to ide isr must be the controller number that was passed to hook ide interrupt this value is typically zero for single controller s
32. Set to 1 to include the linear flash driver The FTL device driver is being revised Set to 1 to include the ROM disk driver Set to 1 to include the RAM disk driver Set to 1 to include the windows host disk disk simulator Section 9 Porting Porting Issues For PORTCONF H ERT S User Guide aaa Section 9 Porting Porting Issues For PORTCONF H lli RTF User Guide SECTION 10 PORTING OVERVIEW portkern c contains ERTFS s interface to the RTOS and to some elements of the underlying hardware See Appendix E for example source code for portkern c The RTOS resources required by ERTFS include mutex semaphores interrupt event signals for selected device drivers and some simple timer management routines This section describes ERTFS requirements from the RTOS and discusses porting requirements Device access functions and interrupt management requirements are discussed in another section Section 10 Porting Overview ERT S User Guide aaa Section 10 Porting Overview 24 ERTFS User Guide SECTION 11 PORTING PERIODIC CLOCK SUPPORT ERTFS requires a periodic clock for measuring device watchdog timeouts Also if ERTFS is running in POLLED mode it needs a clock source timed signal tests The user must implement the clock tick function if using any of the non ram or rom media based device drivers This routine takes no arguments
33. This is controlled by the constant MGMT INTERRUPT phys82365 to virtual PFBYTE virt unsigned long phys This routine must take a physical linear 32 bit bus address passed in the phys argument and convert it to an address that is addressable in the logical space of the CPU returning that value in virt Two sample methods are provided a flat version where the virtual address is simply the phys address cast to a pointer and a second segmented version for X86 segmented applications Note This routine must be changed if you are using and 82365 class PCMCIA controller chip in an environment that is not either 16 bit segmented Intel or a flat 32 bit environment where the virtual address is the same as the physical address void write 82365 index register byte value void write 82365 data register byte value byte read 82365 data register Note These routines must be modified if you are using an 82365 class PCMCIA controller in a non PC environment These routines write and read the 82365 index and data registers which in a standard PC environment are located in I O space at address 0x3E0 and 0x3E1 Non PC architectures typically map these as memory mapped locations somewhere high in memory such as 0xB10003E0 and OxB10003E1 Section 22 Porting 82365 PCMCIA Controller ERT S User Guide aaa Section 22 Porting 82365 PCMCIA Controller ERTFS User Guide SECTION 23
34. a few places ERTFS must disable interrupts execute some lines of code and then re enable interrupts Two functions in the porting file must be populated to add this support The functions are rtfs port disable and rtfs port enable The func tions are described in the following section Note Currently ERTFS only requires these functions if either the floppy disk the 82365 PCMCIA controller or the flash chip memory technology driver is being used If you are not using any of these devices please skip this section void rtfs port disable void This function must disable interrupts and return An example implementation of this function for Intel X86 is asm cli void rtfs port enable void This function must re enable interrupts that were disabled via a call to rtfs port disable An example implementation of this function for Intel X86 is asm sti Section 17 Porting Interrupt Enable Disable ERT S User Guide aaa Section 17 Porting Interrupt Enable Disable RTF User Guide SECTION 18 PORTING MISCELLANEOUS FUNCTIONS void rtfs port exit void Note Most embedded systems never exit If your application never exits skip this section This function must exit the RTOS session and return to the user prompt It is only necessary when an RTOS is running inside a shell environment like Windows It is not necessary to implement this function if you are using the ERTFS comm
35. be optimized On x86 based systems the rep insw instruction should be used on non x86 platforms the loop should be as tight as possible void ide outsw register file address unsigned short p int nwords This function must write nwords 16 bit values to the data register at offset O of the ide register file The data is taken from suc cessive memory locations starting at p Since large blocks of data are transferred from the drive in this way this routine should be optimized On x86 based systems the rep outsw instruction should be used on non x86 platforms the loop should be as tight as possible Section 23 Porting IDE and Compact Flash ERTFS User Guide SECTION 24 PORTING IDE ULTRA DMA MODE This section describes actions that must be taken by the user to support the ERTFS ATA ATAPI device driver in ultra dma mode as implemented in the file drideata c These support functions reside in portio c and must be modified for your target if you wish to use Ultra dma dword rtfs port ide bus master address int controller number This function must determine if the specified controller is a PCI bus mastering IDE controller and if so return the location of the control and status region for that controller If it is not a bus mastering controller or ultra dma mode isn t supported it must return zero This will tell the IDE device driver to use PIO mode byte ide rd udma status dword bus master address This function must read the statu
36. be provided by the user if ALLOC FROM HEAP Not using malloc so assign memory arrays to the configuration block prtfs cfg mem drives structures DDRIVE A mem drives structures O prifs cfg mem block pool BLKBUFF A mem block pool O prtfs cfg mem block hash table BLKBUFF A mem block hash table 0 prtfs cfg gt mem file pool PC FILE A mem file pool O prtfs cfg mem drobj pool DROBJ A mem drobj poollol prifs cfg mem finode pool FINODE A mem finode pool O prtfs cfg 2rtfs user table RTFS SYSTEM USER A rtfs user table 0 prtfs_cfg gt fat_buffers 0 FATBUFF amp fat buffer O O prtfs_cfg gt fat_buffers 1 FATBUFF amp fat buffer 1101 Appendix C APICONFG C 155 ERTFS User Guide mmm prtfs_cfg gt fat_buffers 2 FATBUFF prtfs_cfg gt fat_buffers 3 FATBUFF prtfs_cfg gt fat_buffers 4 FATBUFF prtfs_cfg gt fat_buffers 5 FATBUFF prtfs_cfg gt fat_buffers 6 FATBUFF prtfs_cfg gt fat_buffers 7 FATBUFF prtfs_cfg gt fat_buffers 8 FATBUFF prtfs_cfg gt fat_buffers 9 FATBUFF go fat buffer 2101 fat buffer 3 0 fat buffer A O fat buffer 5 0 fat buffer 6 0 fat buffer 7 0 fat buffer 8 O fat buffer 9 0 So Qo Qo go EKE go go go prtfs cfg fat hash table 0 FATBUFF prtfs cfg fat hash table 1 FATBUFF prtfs cfg fat hash table 2 FATBUFF
37. command creates a file and repeatedly fills it with a pattern It is useful when you wish to create some files for experimenting with on an otherwise empty volume Example create and fill the file file dat with the pattern THIS IS A TEST 1000 times FILLFILE FILE DAT THIS IS A TEST 1000 GETATTR Print a file s attributes This command calls the pc get attributes library routine and prints the results Example GETATTR FILE DAT SETATTR Change a file s attributes This command calls the pc set attributes library routine to change a file s attributes Appendix H Command Shell 197 ee i User Guide mmm Example SETATTR FILE DAT RDONLY The following values may be type for the attribute RDONLY HIDDEN SYSTEM ANORMAL STAT Print file properties This command calls the stat library routine and prints the results Example STAT A FILE DAT CHSIZE Truncate or extend a file Example CHSIZE A DATAFILE 4096 Change DATAFILE s size to 4096 bytes RNDOP Open a random access file This routine will open or reopen a file for use by our random access file I O test commands READ WRITE and SEEK It must be given the file name and the record size for the file The record size is stored internally and is used to pad write operations to the correct width Record size should not exceed 512 The Use CLOSE to close a file that was opened with RNDOP and LSTOPEN to display all open files RNDOP does not return the file handle so use L
38. component is invalid PEINVALIDPATH Path specified badly formed PENOENT Path not found PEACCESS Objectis read only An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt byte attribs if pc_get_attributes AMCOMMAND CON amp attribs attribs ARDONLY AHIDDEN pc_set_attributes A COMMAND COM attribs Section 28 ERTFS Application Programmer s Interface ee i User CTT ER pc unlink Delete a file Summary include lt ertfs h gt BOOLEAN pc unlink byte path Description Delete the file in name Fail if not a simple file if it is open does not exist or is read only Returns Returns TRUE if it successfully deleted the file otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEINVALIDPATH Path specified badly formed PENOENT Can tfind file to delete PEACCESS File in use is read only or is not a simple file An ERTFS system error See Appendix J for a description of system errors Example if pc_unlink B USR TEMP TMP001 PRN printf Cant delete file In Section 28 ERTFS Application Programmer s Interface O i User Guide mmm pc diskflush Flush the FAT and all files to a disk Summary include lt ertfs h gt BOOLEAN pc diskflush byte path Description Given a path containing a valid drive specifier flush the file allocat
39. configures FailSafe mode at power on FailSafe may be configured to automatically restore the volume from the journal file when the volume is mounted and to automatically com mit blocks with each API call In this mode the applications code is not required to make any explicit calls in order to achieve the benefits of FailSafe Manual Operation FailSafe may be configured so that one or more of the operations described in the previous section may be invoked manually from the application layer A mix of automatic and manual operations may be created for example the device may be configured for FailSafe operation at boot time but the application layer may wish not to use the auto commit feature and execute the commit operation manually from the API Programmers Interface An API is provided to perform operations such as initialize FailSafe suspend FailSafe resume FailSafe suspend auto commit mode and resume auto commit mode Other API calls provide a means to check ERTFS and Failsafe buffer usage and to perform manual commits restores and journal file queries Reliability Features FailSafe restores checksums index information in the journal file to detect if the file was corrupted outside of the ERTFS It also checks the volume free space versus information stored in the index to detect if the volume was modified on another system that is not running FailSafe The FailSafe auto restore feature may be configured to ignore these errors when
40. dev geometry Ibas 0 if geometry dev geometry Ibas RTFS PRINT STRING 1 USTRING TSTSH 68 0 The drive is contains this many logical blocks RIES PRINT LONG 1 dyvord geometry dev geometry Ibas PRFLG NL Format Select the number of Ibas for the first partition rtfs print prompt user UPROMPT TSTSH11 working buffer partition list O dword rtfs atol working buffer partition list 1 0 if partition list 0 geometry dev geometry Ibas RTFS PRINT STRING 1 USTRING TSTSH 689 0 This many logical blocks remain RIES PRINT LONG 1 dword geometry dev geometry Ibas partition list 0 PRFLG NL Format Select the number of Ibas for the second partition rtfs print prompt user UPROMPT TSTSH12 working buffer partition list 1 dword rtfs atol working buffer partition list 2 0 if partition list 0 0 dword partition list O partition list 1 gt geometry dev geometry Ibas Format Bad input for partition values Press return rtfs print prompt user UPROMPT TSTSH13 working buffer return 1 else RIES PRINT STRING 1 USTRING TSTSH 70 0 The drive contains this many cylinders RIES PRINT LONG 1 dyvord geometry dev geometry cylinders PRFLG NL P Format Select the number of cyls for the first partition rtfs print prompt user UPROMPT TSTSH14 working buffer Appendix G APPCMDSH C 191
41. disk is empty when it is full and when it is fragmented API TEST This series of tests verifies the correct functioning of ERTFS Pro API calls when FailSafe is enabled The following API calls are tested pc mkdir pc rmdir po open pc unlink pc mv pc del tree pc set attributes po extend file po chsize po truncate po write po close The following tests are performed on each API call Test that the API call changes only the virtual view of the volume and not the volume itself when FailSafe is enabled but autocommit mode is not enabled Test that the volume is automatically synchronized with the virtual volume view when auto commit mode is enabled Test that the volume is synchronized with the virtual volume view after pro failsafe com mit is called when autocommit mode is not enabled e Test that the API call fails gracefully and sets errno to PEJOURNALFULL if the Journal File is full RESTORE TEST This set of tests verifies the correct operation of the pro failsafe restore function when itis asked to perform one of its functions clearing the journal file reporting the journal file status and restoring the volume from the journal file This test also verifies correct functioning of FailSafe s auto restore feature FSAPI TEST This set of tests verified the correct operation of all FailSafe API functions including pro fail safe int pro failsafe commit pro failsafe shutdown and pro failsafe restore Sec
42. each time it accesses the device to check for status changes DRIVE FLAGS INSERTED The driver may use this flag to help track the state of removable media It is never looked at by ERTFS but it is a useful bit for the device driver to have when fielding DEVCTL CHECKSTATUS requests and DEVCTL REPORT REMOVE events SECTION 27 4 I O CONTROL OP CODE DEVCTL CHECKSTATUS xxx perform device ioctl driveno DEVCTL CHECKSTATUS 0 Must return one of the following DEVTEST NOCHANGE Non removable media should always return this Removable media must return this if correct media is installed and has not changed since the last DEVCTL_CHECKSTA TUS call DEVTEST NOMEDIA Removable media must return this if no media is installed DEVTEST UNKMEDIA Removable media must return this if media is installed but is not useable DEVTEST CHANGED Removable media must return this the media has been replaced since the last call for DEVCTL CHECKSTATUS The driver must then clear this status so it won t be reported again until another change event occurs SECTION 27 5 I O CONTROL OP CODE DEVCTL REPORT REMOVE The DEVCTL REPORT REMOVE IO control call should be used as follows When an external interrupt or monitoring task detects that the media associated with this drive number has been removed it must call the driver s I O control function with DEVCTL REPORT REMOVE as an op code The device driver must then put itself in a state such that the next time DEV
43. f the device is a non removable drive that is now accessible then return 0 f the device is a non removable drive that fails diagnostics then return 1 Return 0 if the device is a controller for removable media and the controller is accessible f the controller does not function return 1 Do not return 1 if the controller is functional but no media is installed return O in this case This op code is always called first before any other calls to the device driver The device driver must use this call to perform initialization of the controller Section 27 Adding Your Own Device Drivers ee i User Guide mmm The simplest implementation of WARMSTART is one that that can t fail and requires no initialization i e a ROMDISK driver It will simply set the DRIVE FLAGS VALID flag in the pdr drive flags field and return zero For other devices the WARM START routine is more complex The drive structure is used for parameter passing during the WARMSTART call You may want to use some of these parameters Note Even if you don t use any of the fields in the drive structure you must still set the DRIVE FLAGS VALID bit in pdr gt drive flags To access the drive structure perform the following DDRIVE par pdr pc drno to drive struct driveno SECTION 27 3 1 PASSING PARAMETERS TO THE DEVICE DRIVER The ERTFS drive structure pdr pcmcia slot number For PCMCIA device the user may pass the PCMCIA slot number to the driver by
44. fd newsize 0 RTFS PRINT STRING 1 USTRING TSTSH 41 PRFLG_NL Change size function failed po close fd return 1 else RTFS PRINT STRING 1 USTRING TSTSH 42 PRFLG NL Usage CHSIZE PATH NEWSIZE return 0 I COPY PATH PATH int docopy int agc byte agv P fn PCFD in_fd PCFD out fd word nread BOOLEAN forever TRUE use this for while forever to quiet anal compilers Appendix G APPCMDSH C 186 ee ERTFS User Guide mmm if agc 2 if in_fd po_open agv word PO BINARY PO RDONLY word PS IWRITE PS IREAD lt 0 RIES PRINT STRING 2 USTRING TSTSH 43 agv PRFLG NL Cant open file return 0 if out fd po open agv 1 word PO_BINARY PO_WRONLY PO_CREAT word PS_IWRITE PS IREAD lt 0 RTFS_PRINT_STRING_2 USTRING_TSTSH_44 agv 1 PRFLG_NL Cant open file return 0 while forever nread word po read in fd byte shell buf 1024 if nread gt 0 amp amp nread word 0 if po write out fd byte shell buf word nread int nread RTFS PRINT STRING 1 USTRING TSTSH 45 PRFLG NL Write failure break else break po_close in_fd po_close out_fd return 1 else RIES PRINT STRING 1 USTRING TSTSH 46 PRFLG NL Usage COPY FROMPATH TOPATH n return 0 DIFF PATH PATH int dodiff int agc byte agv EM i PCFD in fd PCFD in f
45. file call one of these four macros to write or read the appropriate UO location If tis convenient to use this scheme and it will work for you then please modify these macros to do the appropriate I O operation for the register If this can t be accomplished just modify the appropriate routines manually define RTFS_OUTBYTE ADDRESS VALUE ftdefine RTFS INBYTE ADDRESS 0 ftdefine RTFS_OUTWORD ADDRESS VALUE ftdefine RTFS INWORD ADDRESS 0 ftdefine RTFS_OUTDWORD ADDRESS VALUE The code below must be implemented for all targets rtfs_port_disable and rtfs_port_enable Used by a few device drivers floppy flash chip and pemctrl you may ignore it if not being called but first check to see if floppy flash chip and pcmctrl are still the only drivers using the functions This function must disable interrupts and return void rtfs port disable void This function must re disable interrupts that were disabled via a call to rtfs port disable void rtfs port enable void if INCLUDE_82365_PCMCTRL These routines are required only if the 82365 pcmcia controller driver is included pemctrl c phys82365 to virtual PFBYTE virt dword phys write 82365 index register byte value write 82365 data register byte value read 82365 data register void This routine must take a physical linear 32 bit bus address passed in the phys argument and convert it to an address addressable in the lo
46. ide rd cyl low dword register file address This function must return the byte in location 4 IDE OFF CYL LOW of the ide register file byte ide rd cyl high dword register file address This function must return the byte in location 5 IDE OFF CYL HIGH of the ide register file byte ide rd drive head dword register file address This function must return the byte in location 6 IDE OFF DRIVE HEAD of the ide register file byte ide rd drive address dword register file address int contiguous io mode This function must return the byte in location 0x207 IDE OFF DRIVE ADDRESS of the ide register file at register file address If the value of the argument contiguous io mode is 1 then the register must be 15 rather than 0x207 void ide wr dig out dword register file address int contiguous io mode byte value This function must place the byte in value at location 0x206 IDE OFF ALT STATUS of the ide register file at register file ad dress If the value of the argument contiguous io mode is 1 then the register must be 14 rather than 0x206 void ide wr data dword register file address word value This function must place the word in location 0 IDE OFF DATA of the ide register file at register file address void ide wr sector count dword register file address byte value This function must place the byte in value at location 2 IDE OFF SECTOR COUNT of the ide register file Section 23 Porting IDE and Compact Flash
47. journalling all changes to the File Allocation Table FAT and directory structure until a function is called to commit those blocks to the disk FailSafe may be configured to automatically commit the blocks before returning from the API or it may be configured to hold off until a commit API function is called explicitly to write the directory and FAT blocks from the journal to the disk If the commit function runs to completion without a media removal or a power down then the disk is in sync and correct If the commit function is interrupted some level of corruption lost cluster chains and incorrect file sizes will exist Corruption caused by an interrupted buffer commit may be corrected by executing a procedure to use information stored in the journal file to complete a previously interrupted commit function After the restore operation is complete the disk state is the same as it would have been had the commit function completed The journal file contains state information that indicates if a restore operation is needed at power up FailSafe may be config ured either to require the application to manually check the status and restore or to automatically detect commit failures and restore the file system when the disk is remounted FAILSAFE FEATURES Automatic Operation FailSafe may be configured so that FailSafe operation is completely transparent to the application layer In this mode ERTFS s init function pc ertfs init automatically
48. n t zeger ae Donin A A k n eh 139 EE EE 140 fallsafe read NV Duran a mE 141 IPM MM E EEE 142 Example 1 Auto Initialize failsafe mode ssssssssssssssssssssssseseeneene ener etn nn nn erne 142 Example 2 Manually initialize failsafe mode aaa hana ann eee kene eee reperit eee zetor e eee eee rer nensis 144 Example 3 Commit failsafe buffers to disk and clear the failsafe journal le 146 Example 4 pro failsafe init has already been called use pro failsafe restore to determine the state of the journal file 147 Example 5 pro failsafe init has not been called use pro failsafe restore to restore the volume from the journal file 148 Appendix A PORTGON E H e cai tinas 149 Appendix Bi REFS CON E ERR 151 fvoerepecesielcusmm 153 Appendix D APPINI T G aen M 161 Appendix EJ PORTISERING ert etr ert erret p ere o Bt e mi n er ener AE has d r 163 Appendix F PORTO di aaa 171 PeeropaceiduenHo M 177 Appendix H ERTFS Command Shell Command Reference nn annae en enneeerervennenenereneneneeerenenennenreneeenneneeenenensnenenenen 195 Appendix J ER LES system ertOES iiu noii rcnt a SEL tea KE DRE VECES A 201 Table of Contents 3 ERT S User Guide aaa Table of C
49. prtfs cfg cfg FAT HASHTBL SIZE 7 sizeof dword malloc prtfs cfg cfg FAT HASHTBL SIZE 8 sizeof dword malloc prtfs cfg cfg FAT HASHTBL SIZE 9 sizeof dword Fe Do some sanity checks if Iprtfs cfg mem drives structures Iprtfs cfg mem block pool II prtfs cfg mem block hash table Iprtfs cfg mem file pool II prtfs cfg mem drobj pool Il Iprtfs cfg mem finode pool II prtfs cfg rtfs user table goto malloc failed if prtfs cfg fat buffers 0 ll prtfs_cfg gt fat_buffers 1 Il Iprtfs_cfg gt fat_buffers 2 Il prtfs_cfg gt fat_buffers 3 II Iprtfs_cfg gt fat_buffers 4 II Iprtfs cfg fat buffers 5 Il prtfs_cfg gt fat_buffers 6 II prtfs_cfg gt fat_buffers 7 Il prtfs_cfg gt fat_buffers 8 II prtfs cfg fat buffers 9 Appendix C APICONFG C 157 ee ERTFS User Guide mmm goto malloc_failed if prtfs_cfg gt fat_hash_table 0 Il Iprtfs cfg fat hash table 1 II prtfs cfg fat hash table 2 Il Iprtfs cfg fat hash table 3 II prtfs cfg fat hash table 4 Il Iprtfs cfg fat hash table 5 II Iprtfs cfg fat hash table 6 II Iprtfs cfg fat hash table 7 II prtfs cfg fat hash table 8 Iprtfs cfg fat hash table 9 goto malloc failed if Iprtfs cfg fat primary cache 0 Il Iprtfs cfg fat primary cache 1 prtfs cfg fat primary cache 2 Iprtfs cfg fat primary cache 3 prtfs cfg fat primary ca
50. prtfs cfg fat primary index 1 dword prtfs cfg fat primary index 2 dword prtfs cfg fat primary index 3 dword prtfs cfg fat primary index 4 dword prtfs cfg fat primary index 5 dword prtfs cfg fat primary index 6 dword prtfs cfg fat primary index 7 dword prtfs cfg gt fat primary index 8 dword prtfs cfg fat primary index 9 dword A fat primary index O O amp fat primary index 1101 amp fat primary index 2101 A fat primary index 3 0 A fat primary index 4 0 A fat primary index DOT A fat primary index 6 O0 A fat primary index TO A fat primary index 8 0 amp fat primary index 9 0 5 5 return TRUE else Use Malloc do allocated ERTFS data prtfs_cfg gt mem_drives_structures DDRIVE malloc prtfs_cfg gt cfg_NDRIVES sizeof DDRIVE prtfs_cfg gt mem_block_pool BLKBUFF malloc prtfs_cfg gt cfg_NBLKBUFFS sizeof BLKBUFF prtfs cfg gt mem block hash table BLKBUFF malloc prtfs cfg gt cfg BLK HASHTBLE SIZE sizeof BLKBUFF prtfs cfg gt mem file pool PC FILE malloc prtfs_cfg gt cfg_NUSERFILES sizeof PC_ FILE prtfs_cfg gt mem_drobj_pool DROBJ malloc prtfs_cfg gt cfg_NDROBJS sizeof DROBJ prtfs_cfg gt mem_finode_pool FINODE malloc prtfs_cfg gt cfg_NFINODES sizeof FINODE prtfs_cfg gt rtfs_user_table RTFS SYSTEM USER malloc prtfs_cfg gt cfg
51. rval rval pro failsafe restore drivename amp fscontext TRUE FALSE Switch rval case FS STATUS RESTORED printf FAILSAFE Volume was restored successfully from the journal file n break case FS STATUS OK printf FAILSAFE Volume up to date no restore was required break case FS STATUS NO JOURNAL printf FAILSAFE restore failed no journal present break case FS STATUS BAD JOURNAL printf FAILSAFE restore failed bad journal file presenti break case FS STATUS BAD CHECKSUM printf FAILSAFE restore failed journal file has checksum errori break case FS STATUS IO ERROR printf FAILSAFE restore failed IO error during restore n break case FS STATUS OUT OF DATE printf FAILSAFE Volume and Failsafe File are out of synch n break case FS STATUS NO INIT printf FAILSAFE Failsafe must be initialized to execute restore break default printf FAILSAFE Restore unexpected return code d rval break Section 30 Failsafe Operating Mode 148 ERTFS User Guide mmm APPENDIX A PORTCONF H EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS compile time configuration file ifndef PORTCONF define PORTCONF 1 CPU Configuration section define KS LITTLE ENDIAN 1 See porting reference guide for explanation define KS LITTLE ODD PTR OK 1 See porting reference g
52. selected for a single device This example puts FailSafe in auto restore auto commit and auto recover mode and provides it with a 128 element block map Comments inside the example code explain how these Failsafe options are selected and how other options may be selected See the manual pages for pro fail safe init for a detailed discussion of FailSafe configuration values Reserve some storage for block mapping structure See the description of fscontext blockmap size below for a discussion on block maps FAILSAFECONTEXT fscontext define BLOCKMAPSIZE 128 FSBLOCKMAP failsafe blockmap array BBLOCKMAPSIZE void app failsafe init byte drive name rtfs_memset void amp fscontext 0 sizeof fscontext Initial setting autorestore autocommit and autorecover options all disabled fscontext configuration flags 0 Select AUTORESTORE The volume is autorestored if needed at mount time If restore is needed but the failsafe file is damaged the mount fails unless F5 MODE AUTORECOVER is also enabled fscontext configuration flags FS MODE AUTORESTORE Select AUTORECOVER If autorestore failed because the failsafe file is damaged skip the restore state and proceed with the mount fscontext configuration flags FS MODE AUTORECOVER Enable AUTOCOMMIT mode Force ERTFS to perform the FailSafe commit internally before the return from API calls that may have changed volume fscontext configuration flags
53. set device driver specific 32 bit error codes Summary void rtfs set driver errno dword error Description The device driver error code is similar to errno Each task has its own driver error code and the application can retrieve it by calling rtfs set driver errno At this time ERTFS does not generate driver error codes or interpret them but in the future we may formalize some values For some application environments it is convenient if device drivers signal to the application such conditions as write protect and card removal Then the application can try to correct the problem and restart the operation Note Do not call rtfs set driver errno from an interrupt service routine Example A write is attempted to a read only device define CARD IS WRITE ONLY 0x12345678 BOOLEAN romdisk io driveno block buffer count reading if reading rts set driver _errno CARD IS WRITE PROTECTED return FALSE Section 28 ERTFS Application Programmer s Interface W ERTFS User Guide QQ UU r Cvv or rr rtfs get driver errno This API call is provided so applications developers can retrieve device driver specific 32 bit error codes Summary dword rtfs get driver errno void Description The device driver error code is similar to errno Each task has its own driver error code and the application can retrieve it by calling rtfs set driver errno For some application environments it is convenient if d
54. supporting the device INCLUDE IDE Include the IDE driver INCLUDE_PCMCIA Include the PCMCIA driver INCLUDE PCMCIA SRAM Include the PCMCIA static ram card driver INCLUDE COMPACT FLASH Support compact flash requires IDE and PCMCIA INCLUDE FLASH FTL Include the linear flash driver INCLUDE ROMDISK Include the rom disk driver INCLUDE_RAMDISK nclude the RAM disk driver INCLUDE FLOPPY Include the floppy disk driver INCLUDE HOSTDISK Include the Windows disk simulator INCLUDE_UDMA Include ultra dma support for the ide driver INCLUDE_82365_PCMCTRL Include the 82365 PCMCIA controller driver Note The default configuration is to enable a ram disk and a rom disk driver only These devices require no additional support from the porting layer Section 6 Configuring Device Driver Support 5 ERTFS User Guidey _ _ _ Section 6 Configuring Device Driver Support ERTFS User Guide SECTION 7 INTRODUCTION TO PORTING ERTFS The ERTFS porting layer has been greatly simplified from previous versions There are three files that must be modified to support a new target portconf h portkern c and portio c A fourth file portmain c must be ported if the RTFS test programs will be run in a standalone environment and a main program entry point must be provided Section 7 Introduction to Porting ERTFS AI AC Section 7 Introduct
55. table to an individual drive If you decide to use this feature for all disk buffering you may then wish to reduce BLKHASHSIZE and NBLKBUFFS In this case some shared buffers are still needed because they are used as scratch buffers to perform certain operations thus NBLKBUFFS should never be reduced below two 2 1f the user wishes to use the ERTFS PRO FailSafe API on a particular drive he must assign a private buffer pool to that drive 3 Proper use of the ERTFS PRO FailSafe API provides a good degree of time determinism when creating directory entries and extending or truncating files When the API is used properly and enough ram resources are available the user can guarantee that the disk will not be accessed while these operations are performed Only file data reads and writes will access the disk drive CONFIGURING FAT BUFFER POOLS AND FAT HASH TABLES The user determines for each drive the size of a hash table and the size of a buffer pool to be used for buffering FAT blocks The choice of buffer pool size and hash table size significantly impacts performance As a rule increasing the size of these resources will increase theoretical maximum performance Limitations to this rule are provided in the following paragraph There is no benefit to increasing either the fat buffer pool s size or the hash table s size beyond the size of the volume s on Section 3 Configuring Runtime Features _ERTFS User Guide disk FAT Thus fo
56. the STAT structure available with most posix like run time environ ments Unfortunately certain run time environments like uITRON also use a structure named STAT so in order to avoid namespace collisions ERTFS uses the proprietary name ERTFS STAT If you are porting an application that uses STAT you may put the following preprocessor macro in ERTFS H just below the declaration of ERTFS STAT define STAT ERTFS STAT Returns Returns 0 if all went well otherwise it returns 1 errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the volume po close must be called to clear this condition Example Section 28 ERTFS Application Programmer s Interface ERTFS User Guide include lt ertfs h gt struct ERTFS stat st PCFD fd fd po open A NMYFILE TXT PO BINARY PO RDONLY 0 if pc fstat fd amp st 0 printf DRIVENO 02d SIZE 7ld DATE 02d 02d 02d TIME 02d 02d n st st dev st st size Size in bytes st st atime date gt gt 5 amp Oxf Month st st atime date amp Ox1f P Day 80 st st_atime date gt gt 9 amp Oxff Year st st atime time gt gt 11 amp Ox1f Hour st st_atime time gt gt 5 amp Ox3f Minute printf OPTIMAL BLOCK SIZE 7ld FILE size BLOCKS 7ld n st st_blksize st st_blocks printf MOD
57. the target RTOS The required functions are 1 rtfs port alloc mutex 2 rtfs port claim mutex 3 rtfs port release mutex The requirements for each of these functions is provided here unsigned long rtfs port alloc mutex void This routine takes no arguments and returns an unsigned long The routine must allocate and initialize a Mutex setting it to the not owned state It must return an unsigned long value that will be used as a handle ERTFS will not interpret the value of the retum value The handle will only be used as an argument to the rtfs port claim mutex and rtfs port release mutex calls The handle may be used as an index into a table or it may be cast internally to an RTOS specific pointer If the mutex allocation function fails this routine must return 0 and the ERTFS calling function will return failure void rtfs port claim mutex unsigned long handle This routine takes as an argument a mutex handle that was returned by rtfs port alloc mutexl If the mutex is already claimed it must wait for it to be released and then claim the mutex and return void rtfs port release mutex unsigned long handle This routine takes as an argument a mutex handle that was returned by rtfs port alloc mutex that was previously claimed by a call to rtfs port claim mutex It must release the handle and cause a caller blocked in rtfs port claim mutex for that same handle to unblock Section 12 Porting Mutex Semaphore Supp
58. they occur and skip the restore function or it may be instructed to halt the mount process and report the problem to the application layer Application Specific Journal File By default the journal is maintained in a special file that resides in the volume For some applications it may be preferable to put the journal file into non volatile system ram or flash memory To make this possible the journal file size is user configurable and a journal file access API is defined which may be used to override the standard method FAILSAFE RESOURCE REQUIREMENTS When ERTFS is running in FailSafe mode some additional media i o system memory and CPU resources are required Con sidering the benefits of using FailSafe the additional resources are minimal The following sections describe FailSafe s impact on each of these system resources JOURNAL FILE RESOURCE REQUIREMENTS FailSafe requires a journal file to operate By default the journal file is placed on a disk when it is auto mounted and is set to the size of the disk s File Allocation Table plus 64K These default settings require a very small percentage of the disk space but they are still very conservative and provide more than enough caching even if long periods elapse between commit calls The FailSafe file size is user configurable FAILSAFE S EFFECT ON CPU AND IO UTILIZATION FailSafe s impact on API call performance is negligible During API calls the same number of disk operations occur whe
59. to perform some sort of bank register selection in this routine Section 26 ERTFS Linear Flash Support 55 ee ERTFS User Guide flash erase block Erase one flash erase block int flash erase block dword Blocklndex flash erase block must set the erase block of size flashchip BlockSize at BlockIndex to the erased all 1 s state flash erase block must return 0 on success 1 on failure int flash write bytes byte volatile dest byte src int nbytes flash write bytes must take nbytes of data from the buffer at src and write it to the flash memory at address dest Dest is an address pointer for a location in a region of the flash that was returned by mtd MapVVindovv The region between dest and dest plus nbytes is guaranteed to reside within flashchip_WindowSize bytes of the pointer returned by mtd MapWin dow flash write bytes must return 0 on success 1 on failure SAMPLE MTD DRIVERS Introduction Two sample MTD drivers are provided One is a simple FLASH emulator implemented in RAM the other is a driver for the Intel 28FXX flash series Flash emulation in RAM If define USE EMULATED FLASH is set to 1 the ram flash emulator is enabled The size of the emulated Flash can be changed by changing the constant FLASHEMUTOTALSIZE The default is 64K The flash memory is emulated in the array FlashEmuBuffer The total size of FlashEmuBuffer is FLASHEMUTOTALSIZE bytes The Ram emulator is very simple and may be used a
60. user wishes to successfully use ERTFS PRO s FailSafe mode on a particular drive he must assign enough FAT buffer space to the drive to hold cached changes to the file allocation table See the ERTFS PRO s FailSafe API section for more information included with ERTFS Pro only The hash table size must be a power of two for example 2 4 8 16 32 64 128 256 512 If it is not a power of two the behavior is undefined For convenience we define two sets of values that we use to configure the individual drives SMALL FAT SIZE and SMALL FAT HASHSIZE determine the default size of the buffer pool and hash table for most drives LARGE FAT SIZE and LARGE FAT HASHSIZE determine the default size of the buffer pool and hash table that we arbitrarily assign to drive C which in the default configuration we arbitrarily assign to a fixed IDE disk drive These constants are used only in the file apicnfig c to simplify the configuration process The user is free to replace the use of these constants and individually con figure each drive To do this you must review and modify the source code for apicnfg c Apicnfig c is designed such that the user may edit the source code to precisely tune ERTFS LARGE FAT SIZE The number of 520 byte blocks committed for buffering fat blocks on drive C see above for an explanation The default is 32 LARGE FAT HASHSIZE The number of 12 byte hash table entries committed for use on drive C see above for an explanation The de
61. value This function must place the byte in value at location 2 IDE OFF SECTOR COUNT of the ide register file at register file address void ide_wr_sector_count dword register_file_address byte value RTFS_OUTBYTE word register_file_address 2 value This function must place the byte in value at location 3 IDE OFF SECTOR NUMBER of the ide register file at register file address void ide_wr_sector_number dword register_file_address byte value RTFS_OUTBYTE word register_file_address 3 value This function must place the byte in value at location 4 IDE_OFF_CYL_LOW of the ide register file at register_file_address void ide_wr_cyl_low dword register_file_address byte value RTFS_OUTBYTE word register_file_address 4 value This function must place the byte in value at location 5 IDE OFF CYL HIGH of the ide register file at register file address void ide_wr_cyl_high dword register_file_address byte value RTFS_OUTBYTE word register_file_address 5 value This function must place the byte in value at location 6 IDE_OFF_DRIVE_HEAD of the ide register file at register_file_address void ide_wr_drive_head dword register_file_address byte value RTFS_OUTBYTE word register_file_address 6 value This function must place the byte in value at location 7 IDE OFF COMMAND of the ide register file at register file address
62. 0 Set to 1 to support JIS kanji define INCLUDE CS ASCII 1 Set to 1 to support ASCII only define INCLUDE CS UNICODE 0 Set to 1 to support UNICODE Set to 1 to support long filenames define VFAT 1 Set to 1 to support 32 bit FATs define FAT32 1 Set to 0 to disable file share modes saves 0 5 K define RTFS_SHARE 0 Set to 0 to disable subdirs Feature not implemented must be 1 define RTFS SUBDIRS 1 Set to O to disable write support Feature not implemented must be 1 define RIES WRITE 1 Set to 1 to include failsafe support define INCLUDE FAILSAFE CODE 0 Set to 1 to include support for extended DOS partitions ERTFS contains code to interpret extended DOS partitions but since this feature is rarely used it is provided as a com pile time option define SUPPORT EXTENDED PARTITIONS 0 STORE DEVICE NAMES IN DRIVE STRUCT If this value is set to one then we save device names for future view ing by diagnostics define STORE DEVICE NAMES IN DRIVE STRUCT 1 Set to the maximum file size ERTFS may create If po chsize or po extend file are called with a size request larger than this they fail and set errno to PETOOLARGE When po write is asked to expend the file beyond this maximum the behavior is determined by the value of RTFS_TRUNCATE WRITE TO MAX define RTFS MAX FILE SIZE Oxffffffff Set to 1 to force RTFS to truncate po write requests to fi
63. 0 amp amp fd2 gt 0 while po read fd buff 512 2 512 po write fd2 buff 512 Section 28 ERTFS Application Programmer s Interface i User Guide mmm po Iseek Move file pointer Summary include lt ertfs h gt long po Iseek PCFD fd long offset int origin Description Move the file pointer offset bytes from the origin described by origin Origin may have the following values PSEEK SET Seek from beginning of file PSEEK CUR Seek from the current file pointer PSEEK END Seek from end of file Attempting to seek beyond end of file puts the file pointer one byte past end of file Seeking zero bytes from origin PSEEK_ END returns the file length Returns The new offset or 1 on error errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEINVALIDPARMS Attempt to seek past EOF or to a negative offset PEINVALIDCLUSTER Files contains a bad cluster chain An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt record rec_number rec_size if po Iseek fd record PSEEK SET record printf Cant find record 9eldWn record Section 28 ERTFS Application Programmer s Interface M S ERTFS User Guide mmm po ulseek Move file pointer unsigned
64. 12 Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm po write Write to a file Summary include lt ertfs h gt int po write PCFD fd UNITY buf int count Description Attempt to write count bytes from buf to the current file pointer of file at fd The file pointer is updated Returns Returns the number of bytes written or 1 on error Note If the requested file length exceeds RTFS MAX FILE SIZE po write may be configured to either truncate the write size or to return an error depending on configurations values set in rtfsconf h If RTFS TRUNCATE WRITE TO MAX is set to one the write tries to complete up to that many bytes and returns the number of bytes written If it is 0 no writing occurs errno is set to PETOOLARGE and 1 is returned errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEACCES File is read only PEIOERRORWRITE Error performing write PEIOERRORREAD Error reading block for merge and write PENOSPC Disk full PETOOLARGE Trying to extend a file beyond RTFS MAX FILE SIZE An ERTFS system error See Appendix J for a description of system errors Example PCFD fd PCFD fd2 fd po open FROM FIL PO RDONLY 0 fd2 po_open TO FIL PO_CREAT PO_WRONLY PS_IWRITE if fd gt
65. ABLE To support removable trueide media you must modify this function to interface with your trueide media detect circuit If media is installed it must return TRUE if not it must return FALSE Example BOOLEAN trueide card installed DDRIVE pdr i if read ide installed latch 1 return TRUE else return FALSE 3 void trueide report card removed int driveno Section 25 Supporting Removable TRUE IDE Devices ee i User Guide mmm To support removable trueide media you must modify your media change interrupt service routine to call this function when a card has been removed Drive number of the card that was removed must be passed in The drive number must be the same as the value assigned to the pdr gt driveno in apiinit c Note The DRIVE FLAGS REMOVABLE flag must be set in apiinit c for removable media To do this OR in DRIVE FLAGS REMOVABLE to the drive flags field pdr gt drive_flags DRIVE FLAGS REMOVABLE Example define TRUEIDE DRIVEID 2 C void trueide removal interrupt void trueide_report_card_removed TRUEIDE_DRIVEID 3 Section 25 Supporting Removable TRUE IDE Devices i User Guide QQ OUO u SECTION 26 ERTFS LINEAR FLASH SUPPORT ERTFS linear flash device support is provided through a portable Flash Translation layer FTL implemented in drfldftl c The flash subsystem is included if the following line is true in portconf h def
66. An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface 112 ERTFS User Guide po extend file Extend a file by contiguous clusters Summary BOOLEAN po extend file PCFD fd unsigned long n bytes unsigned long new bytes long start cluster int method Description Given a file descriptor n bytes bytes and method extend the file and update the file size If the file can be extended by n bytes contiguous bytes it will be done Otherwise if there is no contiguous region left on the disk that can contain n bytes the routine DOES NOT extend the file but does return the length of the next largest contiguous region that is available With this scheme an application can request to extend the file by a given contiguous amount If that is not possible the routine will return the largest contiguous region available The application can then decide if it wishes to use this region Please read the notes below for an important discussion about the limitations of this routine The special method PC FIXED FIT may be used to extend the file beginning at a specific cluster With this method start cluster must be provided It is used as the starting point for the allocation With this method it is possible to precisely assign locations on the disk to file section This may be used for example to create interleaved files where several files share a disk segment with interleav
67. CK polled mode only ever uses one signal at a time so we ignore the handle argument if timeout Covert milliseconds to ticks If O set it to 2 ticks timeout timeout MILLISECONDS PER TICK if timeout timeout 2 last time end time 0 keep compiler happy curr time rtfs port get ticks end time curr time dword timeout H Check for a wrap if end time curr time end time dword OxffffffffL last time curr time do N See if we timed out curr time 7 rtfs port get ticks if curr time end time break II if wrap or clearing of clock then start count over if curr time last time end time curr time dword timeout last time curr time while polled signal 0 if polled signal polled signal 1 return 0 else return 1 endif P This routine takes as an argument a handle that was returned by rtfs port alloc signal It must set the signal such that a subsequent call to rtfs port test signal or a call currently blocked in rtfs port test signal will return success This routine is always called from the device driver interrupt service routine while the processor is executing in the inter rupt context Only required for the supplied floppy disk and ide device driver if the ide driver is running in interrupt mode Otherwise leave this function as it is it will not be used void rtfs port set signal dword handle Implement set of
68. CTL CHECKSTATUS is called it should re check if the media is installed and return DEVTEST NOMEDIA if it is not If media is installed the DEVCTL_CHECKSTATUS routine must reinitialize the card If that is successful it may return either DEVTEST NOCHANGE or DEVTEST CHANGED Under these circumstances it should return DEVTEST NOCHANGE only if it is certain that the card that was re inserted is the same card that was removed SECTION 29 5 1 EXAMPLE CARD REMOVAL EVENT HANDLER The following code fragment reports a media removal event to the device driver This simple system has one removable device mapped to the A drive and it is designed such that a routine named card removed interrupt is called whenever the card is removed define REMOVABLE DRIVE 0 System uses A for this drive card removed interrupt pdr pc drno to drive struct REMOVABLE DRIVE if pdr pdr dev table perform device iocti pdr driveno DEVCTL REPORT REMOVE PFVOID 0 SECTION 27 6 I O CONTROL PROCESSING FOR DEVCTL POWER LOSS Section 27 Adding Your Own Device Drivers ERTFS User Guide mmm xxx perform device ioctl driveno DEVCTL POWER LOSS 0 Must return 0 The DEVCTL POWER LOSS IO control call can be used to report to the device driver that it should go into low power mode and be aware that it must exit low power the next time the driver is called The calling sequence is the same as when calling DEVCTL REPORT REMOVE except the op
69. DATESTR format st ctime creation date in DATESTR format t blksize optimal blocksize for I O cluster size t blocks blocks allocated for file fattributes the DOS attributes This is non standard but supplied if you want to look at them NOTE ERTFS STAT structure is equivalent to the STAT structure available with most posix like run time environments Unfortunately certain run time environments like uITRON also use a structure named STAT so in order to avoid namespace collisions ERTFS uses the proprietary name ERTFS STAT If you are porting an application that uses STAT you may put the following preprocessor macro in ERTFS H just below the declaration of ERTFS STAT define STAT ERTFS STAT Returns Returns 0 if successful otherwise 1 errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PENOENT File or directory not found An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface ERTFS User Guide Example include lt ertfs h gt struct ERTFS_stat st if pc_stat A MYFILE TXT amp st 0 printf DRIVENO 02d SIZE 7ld DATE 02d 02d 02d TIME 02d 02d n st st_dev st st_size Size in bytes st st atime date gt gt 5 amp Oxf Month st st atime date amp 0x1f F Day 80 st st_atime date gt gt 9 amp Oxff P Year st st atime time gt gt 11 amp
70. Device Drivers 0 ERTFS User Guide Z QQ SECTION 28 ERTFS APPLICATION PROGRAMMERS INTERFACE Summary of ERTFS API Calls POLS ESL ais cada add td 63 DC etis EE 64 PO MV TL IU III UC UTILIS ME 65 POSO CWd RUPTURE LU UL D UL LL LIU II 66 O 67 PE OEE 68 le LE 69 ojee In cd EEn 70 A CR EET 71 jener 72 get le x S Ae 74 nis SOUTO ve se Aiea M ems 75 nfs get driver e iia a ta 76 POMO E E 77 pe get LLP 78 oe A 79 ore NE 80 POSA EE 81 ole shenoi M 83 pe check disk nto LL Rr 91 59 eee 85 lorems TM O O 86 opt NO T X ate stare cies TEE 12174 S 12 NOA Y E q 87 Pe le NENNEN OREL IM PME rM ER 88 ol ERR LE O 89 ee le 90 emu cem A E 91 el LEE 92 PO OPEN ERE ee 93 2106 615 risi nem 94 emm EE 95 oo ENE 96 om WHS ca coh E E 97 PO ISCO
71. E int flash probe void flash probe must determine if a flash chip is present and if so determine the address of the flash the total size of the flash the size of an erase block and the window of the flash that is addressable at any one time These values that must be set by the flash probe routine flashchip TotalSize Setthis to the total size of the flash in bytes flashchip BlockSiz Setthis to the size of one erase block in bytes flashchip WindowSize Set this to the addressable window If the part is fully addressable set it to the size of the part in bytes flashchip start Setthis byte pointer to the start of the flash flash probe must return 1 if a device is found zero otherwise void mtd MapWindow RTFDrvFlashData DriveData dword BlockIndex dword VVindovvindex mtd MapWindow must map in a flashchip_WindowSize ed region of the flash memory for reading and writing The location of the flash region to map in is calculated by multiplying the BlockIndex times the erase block size flashchip BlockSize and adding in the WindowIndex times the window map size flashchip_WindowSize The included version of mtd MapWindow assumes that the flash part is fully addressable It simply multiplies these values together adds them to the start of flash address and returns the result This version will not need to be changed in most flat 32 bit target environments In some environments it may be necessary to add software
72. E BITS if st st_ mode amp S IFDIR printf S_IFDIR if s st mode amp S IFREG printf S_IFREG if eist mode amp S IWRITE printf S_IWRITE if st st mode amp S IREAD printf S_IREAD n printf n Section 28 ERTFS Application Programmer s Interface ERTFS User Guide pc check disk Check a volume s integrity Summary BOOLEAN pc check disk byte drive id CHKDISK STATS pstat int verbose int fix problems int write chains Description This routine scans the disk searching for lost chains and crossed files and returns information about the scan in the structure at pstat If fix problems is non zero it corrects file sizes if necessary If fix problems is non zero and if write chains is zero it frees lost cluster chains if write chains is non zero it writes lost chains to files names FILE CHK in the root direc tory If fix problems is zero the write chains argument is ignored pstat a pointer to a structure of type CHKDISK STATS pc check disk returns information about the disk in this structure verbose If this parameter is 1 pc check disk prints status information as it runs if itis O pc check disk runs silently fix problems If this parameter is 1 pc check disk will make repairs to the volume if it is zero problems are reported but not fixed write chains If this parameter is 1 pc check disk creates files from lost chains If write chains is O l
73. ENEN sete ter nnns nn nnn nens 142 Example 2 Manually initialize failsafe mode Auen 144 Example 3 Commit failsafe buffers to disk and clear the failsafe journal fil naeve rere nene nenen 146 Example 4 pro failsafe init has already been called use pro failsafe restore to determine the state of the journal FIG p dana 147 Example 5 pro_failsafe_init has not been called use pro_failsafe_restore to restore the volume from the journal UE 148 Section 30 Failsafe Operating Mode 125 00 ERTFS User Guide Z QQ Qu pro failsafe init Function Initiate a failsafe session Summary BOOLEAN pro failsafe init byte drive name FAILSAFECONTEXT pfscntxt int configuration flags Description This routine checks the user supplied parameters initializes the failsafe context structure makes sure that buffers are flushed and places the drive in failsafe mode Once the device is in failsafe mode directory and FAT block writes will be held in a jour nal file until the commit operation is executed This routine may be used to initialize failsafe from the API layer The routine named pro failsafe auto init should be used instead if you wish to automatically enable FailSafe mode at boot time Inputs drive name Null terminated drive designator for example A pfscntxt The address of a block of data that will be used as a context block for failsafe This block must remain valid for the whole session and must not be de allocated Pf
74. ER TICK Depending on what drivers are required one or more of the following void hook 82365 pcmcia interrupt int irq void hook ide interrupt int irq int controller number void hook ide interrupt int irq int controller number void hook floppy interrupt int irq include lt rtfs h gt This routine takes no arguments and returns an unsigned long The routine must return a tick count from the system clock The macro named MILLISECONDS PER TICK must be defined in such a way so that it returns the rate at which the tick increases in milliseconds per tick This routine is declared as static to emphasize that its use is local to the portkern c file only define MILLISECONDS PER TICK 1 Change this to your environment static dword rtfs port get ticks void f This routine takes no arguments and returns an unsigned long The routine must allocate and initialize a Mutex setting it to the not owned state It must return an unsigned long value that will be used as a handle ERTFS will not interpret the value of the return value The handle will only used as an argument to the rtfs port claim mutex and rtfs port release mutex calls The handle may be used as an index into a table or it may be cast internally to an RTOS specific pointer If the mutex allocation function fails this routine must return 0 and the ERTFS calling function will return failure return 0 Return the
75. ERTFS 4 4zb Pro Basic Table of Contents Revised March 2007 Table of Contents Section 1 Getting Started with ERTES snsd ds ade reete deter cde cis 5 Section 2 The source code str ctute ien re ves dini d Huet des 7 Public enm rcmwe n 7 Private Header Files 7 Demonstration sample code and utility programs sauna enen reen renerne erne petet bete teren 7 Poning EI EAE TET seas CO EE DLL E LOEO 7 Source code for user modifiable public functions scissionisti entree enter even eee eee eee ee teze tee tee enet 7 Source code for user API calls See the API Section nnn ane eenen enen enenenrenense verwennen enensense ete eee tete te senes nsn nn nnne eee tete 8 Source code for ERTFS PRO user API calls 1 rrr retrace net tnus n es Xon ak SER rue REL ase E ku ea 8 Source code for the ERTFS core functions eicere irre atea 8 Source code for localization and multiple character set support 8 Source code for ERTFS FAIESAFE FEATURE tiene drive eses daa 8 Source code for ER T S device drivers isa dis sd sis ve dress sado d v AT is 8 Section 3 Configuring Runtime Features un ia eed rice best n pu nee eed ep eka bas Po EL drue vendes sve eens 9 Configuring the Memory Usage and Capacities of ERTFS nnee e ee eee ee vete e ever eee zere eiaeia aadi 9 Configuring FAT Buffer Pools and FAT hash table
76. ERTFS User Guide void ide wr sector number dword register file address byte value This function must place the byte in value at location 3 IDE OFF SECTOR NUMBER of the ide register file void ide wr cyl low dword register file address byte value This function must place the byte in value at location 4 IDE OFF CYL LOW of the ide register file void ide wr cyl high dword register file address byte value This function must place the byte in value at location 5 IDE OFF CYL HIGH of the ide register file register file address is the value that was provided by the user in pc ertfs init in the variable pdr register file address void ide wr drive head dword register file address byte value This function must place the byte in value at location 6 IDE OFF DRIVE HEAD of the ide register file void ide wr command dword register file address byte value This function must place the byte in value at location 0 IDE OFF DATA of the ide register file void ide wr feature dword register file address byte value This function must place the byte in value at location 1 IDE OFF FEATURE of the ide register file void ide insw register file address unsigned short p int nwords This function must read nwords 16 bit values from the data register at offset O of the ide register file and place them in succes sive memory locations starting at p Since large blocks of data are transferred from the drive in this way this routine should
77. EXIST new name already exists An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt Move the a file named USR LETTER TXT to LETTER OLD in the current working directory if pc mv AUSRWTXTWLETTER TXT LETTER OLD printf Can t move LETTER TXT n Move the a directory named users summerhelp joe to users oldemployees joe if lpe_mv users summerhelp joe users oldemployees joe printf Can t move users summerhelp joe n Section 28 ERTFS Application Programmer s Interface S ERTFS User Guide QQ Ur pc rmdir Delete a directory Summary include lt ertfs h gt BOOLEAN pc rmdir byte name Description Delete the directory specified in path Fails if path is not a directory is read only or is not empty Returns TRUE if the directory was successfully removed otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEINVALIDPATH Path specified badly formed PENOENT Directory not found PEACCESS Directory is in use or is read only An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt if pc rmdir D NUSRWTEMP printf Can t delete directory Section 28 ERTFS Application Programmer s Interface ERTFS User Guide mmm pc deltree Delete a directory tree S
78. FS MODE AUTOCOMMIT Optional setting If the user journal size is set prior to the call to pro failsafe init the FailSafe file space is limited to this size Otherwise the Failsafe file size is set to the size of the FAT plus CFG NUM JOURNAL BLOCKS prfs h blocks The default setting is purposely conservative One block must be available for each FAT block and directory block that will be changed between calls to pro failsafe commit The following line if enabled will fix the failsafe journal size to 64K This would be appropriate for example if the journal file was being held in 64K of nvram fscontext user journal size 128 In blocks Provide buffer space for failsafe to cache indexing information pertaining to journaling activities Without adequate caching failsafe will still perform as specified but with lowered performance Each blockmap element required approximately 32 bytes for optimal performance one element should be available for each FAT block and directory block that will be changed between calls to pro failsafe commit In this example we choose 128 entries This is very a conservative setting that will allow failsafe to use caching in a session with up to 128 FAT and directory blocks changed Note that perfor mance will degrade drastically if the number of blocks modified exceeds the size of the block map If you have a need to minimize resources you may reduce blockmap size and user journal size To help det
79. G TSTSH 33 agv PRFLG NL Cant open return 0 else do nread po read fd byte shell buf 512 shell buf nread 0 RTFS PRINT STRING 2 USTRING SYS NULL shell buf 0 while nread gt 0 po close fd return 1 else RTFS PRINT STRING 1 USTRING TSTSH 34 PRFLG NL Usage CAT PATH return 0 Appendix G APPCMDSH C 185 M ERTFS User Guide mmm tj int dochkdsk int agc byte agv P fn int write chains CHKDISK STATS chkstat if agc 2 RTFS PRINT STRING 1 USTRING TSTSH 35 PRFLG NL Usage CHKDSK DRIVE WRITECHAINS RTFS PRINT STRING 1 USTRING TSTSH 36 PRFLG NL Example CHKDSK A 1 RTFS PRINT STRING 1 USTRING TSTSH 37 PRFLG NL Runs chkdsk on A writes lost chains RTFS PRINT STRING 1 USTRING TSTSH 38 PRFLG NL Example CHKDSK A 0 RTFS PRINT STRING 1 USTRING TSTSH 39 PRFLG NL Runs chkdsk on A does not write lost chains return 0 write chains int rtfs atoi agv 1 pc check disk agv amp chkstat 1 write chains write chains return 0 CHSIZE PATH NEWSIZE int dochsize int agc byte agv EM PCFD fd long newsize if agc 2 if fd po open agv word PO BINARY PO WRONLY word PS IWRITE PS IREAD lt 0 RTFS PRINT STRING 2 USTRING TSTSH 40 agv PRFLG NL Cant open file return 0 newsize rtfs atol agv 1 if po_chsize
80. G_TSTSH_85 0 HIDDEN attr AHIDDEN else if rtfs_cs_stremp agv 1 rtfs_strtab_user_string USTRING_TSTSH_86 0 SYSTEM attr ASYSTEM else if rtfs_cs_strcmp agv 1 rtfs_strtab_user_string USTRING_TSTSH_87 0 ARCHIVE attr ARCHIVE else if rtfs cs strcemp agv 1 rtfs strtab user string USTRING TSTSH 88 20 NORMAL attr ANORMAL else goto usage if pc set attributes agv attr return 0 else RTFS PRINT STRING 1 USTRING TSTSH 89 PRFLG NL Set attributes failed return 0 usage RTFS PRINT STRING 1 USTRING TSTSH 90 PRFLG NL Usage SETATTR D PATH RDONLY HIDDEN SYST EMJARCHIVEJNORMAL return 0 Appendix G APPCMDSH C 193 ERTFS User Guide mmm P DEVINFO int dodevinfo int agc byte agv fn RTFS ARGSUSED INT agc RTFS ARGSUSED PVOID PFVOID agv print device names return 1 Appendix G APPCMDSH C 194 ee ER TES User Guide mmm APPENDIX H ERTFS COMMAND SHELL COMMAND REFERENCE Summary of Command Shell Command References FORMAT Format a disk CHKDSK Perform a check disk procedure on a drive DEVINFO Print the names of all disks and their drive designators MKHOSTDISK Duplicate a windows or NT subdirectory inside on an ERTFS file system MKROM Create a ROMDISK Image DIR Print a directory listing MKDIR Create a directory RENAME Rename a file RMDIR Delete a
81. I Example main pc_ertfs_init Don t forget to call the initialization code pc_tstsh Call the test shell It will execute until the user types QUIT exit 0 Section 28 ERTFS Application Programmer s Interface 115 ee ERTFS User CTT ER Section 28 ERTFS Application Programmer s Interface 116 i User Guide QQ rtr ror o r gt f SECTION 29 ERTFS PRO API FUNCTIONS The API functions documented in this section are include in the ERTFS Pro package only They are not included in the Basic package pro UTS Eeer Eeer ees 118 pro assi n buffer PON ER 120 Section 29 ERTFS Pro API Functions 117 ERTFS User Guide pro buffer status Function Return disk and failsafe status Summary BOOLEAN pro buffer status byte drive name struct pro buffer stats pstat Description This routine returns status information about Failsafe the block buffer pools and the fat buffer pools Note This function reports statistics about failsafe but it does not require failsafe to be active It is still useful even if failsafe is not enabled The information is returned to the user in the structure of type pro buffer stats that must be passed to the routine struct pro buffer stats int failsafe mode dword failsafe blocks used dword failsafe blocks free dword total block buffers dword block buffers pending dword block buffers available dword block buffers low dword block buff
82. I TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST po truncate API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST po write API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST po close API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST Success API TEST Success RESTORE TEST Begin RESTORE TEST test manual restore RESTORE TEST test manual restore with bad Journal file RESTORE TEST test auto restore with bad Journal file RESTORE TEST Test pro failsafe restore clear function RESTORE TEST auto recover with bad Journal file RESTORE TEST test auto restore with good Journal file RESTORE TEST Success FSAPI TEST Begin FSAPI TEST pro failsafe init FSAPI TEST pro failsafe init test mount behavior FSAPI TEST pro failsafe init test bad inputs FSAPI TEST pro failsafe init user journal size gt default FSAPI TEST pro failsafe init user journal size default FSAPI TEST pro failsafe init test block map arguments FSAPI TEST pro failsafe init test FS MODE AUTOCOMMIT FSAPI TEST pro failsafe init test F5 MODE AUTORESTORE FSAPI TEST pro failsafe init test F5 MODE AUTORECOVER FSAPI TEST pro failsafe init Success FSAPI TEST pro fa
83. IS Japanese Language included with ERTFS Pro only INCLUDE CS ASCII Setto 1 to support 8 bit ASCII only included with ERTFS Pro only INCLUDE CS UNICODE Set to 1 to support unicode characters Note Unicode support requires VFAT included with ERTFS Pro only File system support By default ERTFS support 12 and 16 bit File Allocation Table and short file names Modify the following constants to enable long filename support and FAT32 VFAT Setto 1 to support long filenames included with ERTFS Pro only FAT32 Setto 1 to support 32 bit FAT included with ERTFS Pro only Failsafe Operating Mode Support Failsafe mode provides a means to eliminate the risk of file system corruption that results from unexpected power interruptions and media removal events INCLUDE FAILSAFE CODE Set to 1 to include failsafe support included with ERTFS Pro only CD ROM Support If the CD ROM support package was purchased the CDFS feature set may be enabled by editing portconf h setting INCLUDE CDROM to 1 If INCLUDE CDROM is enabled INCLUDE IDE must also be enabled Extended DOS Partitions ERTFS contains code to interpret extended DOS partitions but since this feature is rarely used it is provided as a compile time option Modify the following constant to support extended DOS partitions SUPPORT EXTENDED PARTITIONS Set to 1 to include support for extended DOS partitions ERTFS contains code to support extended DOS partitions but they are ra
84. Inconsistent state for unexplained reasons PEINVALIDCLUSTER Invalid cluster number encountered PEINVALIDCLUSTER Invalid cluster number encountered PEINVALIDBLOCKNUMBER Invalid block number encountered PEINVALIDDIR Invalid directory entry encountered Resource allocation system Errors PERESOURCE Out of internal directory allocation structures PERESOURCEBLOCK Out of block buffers PERESOURCEFATBLOCK Out of FAT block buffers Device I O read system errors PEIOERRORREADFAT 1 0 error when reading from the FAT area PEIOERRORREADBLOCK UO error reading from the directory area Device I O write system errors PEIOERRORWRITEBLOCK I O error writing to the directory area PEIOERRORWRITEFAT 1 0 error flushing FAT ram buffers to disk PEIOERRORWRITEINFO32 I O error writing INFO32 structure during FAT flush FailSafe Operating Mode errors PEFSCREATE Disk mount failed could not create a journal file PEJOURNALFULL The API operation failed because there is no room left in the journal file PEIOERRORWRITEJOURNAL Disk mount or API operation failed because a write to the journal file failed PEFSRESTOREERROR Disk mount failed could not restore from journal file PEFSRESTORENEEDED Disk mount failed a restore is needed but the AUTORESTORE feature is not enabled PEIOERRORREADJOURNAL Disk mount or API operation failed because a read from the journal file failed Appendix J System Errors 201 ee ERTFS User CTT ER Appendi
85. KMAP auto failsafe blockmap array AUTO BLOCKMAPSIZE endif BOOLEAN pro_failsafe_auto_init DDRIVE pdrive Section 30 Failsafe Operating Mode 142 00 ERTFS User Guide Qu if INCLUDE FAILSAFE AUTO INIT return FALSE else In this example we set up failsafe mode for one device This code may be modified to enable failsafe on multiple devices and to modify FailSafe settings according to the documentation provided for pro_failsafe_init if auto_fscontext pdrive Only one device supported int this return FALSE Example Add more contexts rtfs_memset void amp auto_fscontext 0 sizeof auto_fscontext Run fully automated auto_fscontext configuration_flags FS MODE AUTORESTORE FS MODE AUTORECOVERIFS MODE AUTOCOMMIT auto fscontext blockmap size AUTO BLOCKMAPSIZE auto fscontext blockmap freelist amp auto failsafe blockmap array 0 Our parameters are correct so we know that the routine will not fail but to demonstrate the principle we return FALSE if the call does fail if Ipro failsafe init internal pdrive amp auto fscontext return FALSE return TRUE endif INCLUDE FAILSAFE AUTO INIT Section 30 Failsafe Operating Mode 143 00 ERTFS User Guide Z Qu Example 2 Manually initialize failsafe mode This example initializes from the API layer by calling pro failsafe init This example code is provided inside the file appcmdsh c FailSafe mode is
86. LITTLE_ODD_PTR_OK KS_CONSTANT KS_FAR INCLUDE_IDE INCLUDE_PCMCIA INCLUDE COMPACT FLASH INCLUDE FLOPPY INCLUDE 82365 PCMCTRL INCLUDE UDMA INCLUDE PCMCIA SRAM INCLUDE FLASH FTL INCLUDE ROMDISK INCLUDE RAMDISK INCLUDE HOSTDISK Set this to 1 for little endian byte architectures such as Intel Set it to O for big endian architectures such as Motorola This value is not relevant if KS LITTLE ENDIAN is 0 If KS LITTLE ENDIAN is 1 then this value should be set to 1 if the CPU is forgiving about accessing words on odd boundaries A good rule of thumb is to set this to 1 on x86 based little endian systems and to zero on non x86 little endian systems Set this to your compiler s const declaration A typical setup is define KS CONSTANT const If this presents problems use the NULL alternative define KS CONSTANT This value is only relevant in segmented architectures such as real mode Intel 8086 The KS FAR modifier is used when declaring data arrays in a few places so the data is put in FAR memory rather than near memory For these architectures use the following defini tion define KS FAR far Otherwise leave the definition as it is define KS FAR Set this to zero if you will not be using the IDE device driver Set it to 1 if you will use the IDE device driver When this constant is set to zero the IDE device driver compiles to nothing and routines required by the IDE device driver in por
87. NG FAILSAFE Before using FailSafe you must decide how it will be used and configured The following topics should be considered Initialization policy Failsafe must be initialized before it is used To initialize it you may either explicitly call pro failsafe init from the API layer once ERTFS is running or you may configure the ERTFS initialization sequence to automatically call pro failsafe auto init While the results of these two operations are the same they each have their place Pro failsafe auto init may be used along with some other features to provide FailSafe functionality while being completely transparent to the application requiring no explicit API calls Pro failfafe init may be used instead if the application wishes to determine specific conditions under which FailSafe will be enabled For more information on the initialization process please see the fol lowing sections on initializing and configuring FailSafe and the manual pages for pro failsafe init and pro failsafe auto init Restore policy FailSafe may be configured to transparently restore the volume from the FailSafe file when a volume is mounted or it may be configured to refuse to mount the disk if a restore is needed and require the user to call pro failsafe re store from the API layer to restore and remount the volume As a third option It may be configured to automatically restore and mount the volume if the journal file is okay but fail to restore and mou
88. NG TSTSH 60 0 S_IFDIR if stst mode amp S IFREG RIES PRINT STRING 1 USTRING TSTSH 61 0 S IFREGI if stst mode amp S IWRITE RIES PRINT STRING 1 USTRING TSTSH 62 0 S IWRITE if s st mode amp S IREAD RIES PRINT STRING 1 USTRING TSTSH 3 0 S IREADW RIES PRINT STRING 1 USTRING SYS NULL PRFLG NL return 1 else RTFS PRINT STRING 1 USTRING TSTSH 65 PRFLG NL FSTAT failed return 0 Appendix G APPCMDSH C 189 M U ERTFS User Guide mmm RTFS PRINT STRING 1 USTRING TSTSH 66 PRFLG_NL Usage FSTAT D PATH return 0 FORMAT D int doformat int agc byte agv PPM byte buf 10 byte working buffer 100 DDRIVE pdr int driveno dword partition list 3 byte path 10 DEV GEOMETRY geometry RTFS ARGSUSED INT agc RTFS ARGSUSED PVOID PFVOID agv Enter the drive to format as A B etc rtfs print prompt user UPROMPT TSTSH3 path driveno pc parse raw drive path if driveno 1 pdr pc drno to drive struct driveno inval Invalid drive selection to format press return rtfs print prompt user UPROMPT TSTSHA working buffer return 1 if pdr drive flags8 DRIVE FLAGS VALID goto inval int driveno BOOLEAN ok to automount BOOLEAN raw access requested BOOLEAN call crit err JI call it twice to clear change conditions if check media driveno
89. Provides many examples of using the ERTFS API This application will run on any target that can get and put lines of text to a console The test shell has a lot of features that are useful for debugging and file system maintenance Your release contains a Win dows version of the shell Please experiment to help you decide if you want to use it For more information about the command shell subroutine see the documentation Section 26 and in the Command Reference in Appendix H winhdisk c Host disk driver Emulates a disk drive in a host file Supported only in the win32 prototyping environment winmkrom c Tool that populates a host disk volume by copying files from a Windows subdirectory tree and creating a virtual disk from the data The tool can then export this virtual file into a header file that may then be used as a rom disk image by the rom disk driver These utility functions are provided pre built in the rtfsdemo exe utility for windows in the tools subdirectory This file runs only in the win32 prototyping environment PORTING FILES These files require modification when moving ERTFS to a new environment Several implementations are provided in the targets subdirectory To select a target copy its porting files to the main tree To create a new port copy one of the existing ports to the main tree and edit the files for your environment If you prefer to start from scratch the subdirectories named template io and template krn contain c
90. R pd word year relative to 1980 word month 1 12 word day 1 31 word hour word minute word sec Note seconds are 2 second per ie 3 6 seconds if O This code will work if you have ANSI time functions otherwise get rid of it and look below where the time is wired to 3 28 8 You may modify that code to work in your environment Struct tm timeptr time t timer time amp timer timeptr localtime amp timer hour word timeptr gt tm hour minute word timeptr gt tm min sec word timeptr gt tm_sec 2 Date comes back relative to 1900 eg 93 The pc wants it relative to 1980 so subtract 80 Appendix E PORTKERN C 167 ee ERTFS User Guide mmm year word timeptr gt tm_year 80 month word timeptr gt tm_mon 1 day word timeptr gt tm_mday else This code is useless but very generic Hardwire for now 1 7 37 28 PM hour 19 minute 37 sec 14 3 28 88 year 8 relative to 1980 month 3 1 12 day 28 F1 31 endif pd gt time word hour lt lt 11 minute lt lt 5 sec pd gt date word year lt lt 9 month lt lt 5 day return pd This routine must establish an interrupt handler that will call the plain C routine void mgmt_isr void when the chip s management interrupt event occurs The value of the argument irq is the interrupt numb
91. RFLG NL return 1 else RIES PRINT STRING 1 USTRING TSTSH 28 PRFLG NL Get cwd failed return 0 DIR PATH int dols int agc byte agv fn MY int fcount int doit addwild byte ppath p dword blocks total blocks free dword nfree byte null str 2 ppath 0 addwild 0 if agc 1 ppath agv p 7 ppath If the second char is and the third is 0 then we have D and we will convert to D CS OP INC PTR p if CS OP CMP ASCII p CS OP INC PTR p if CS OP IS EOS p addwild 1 else null str 0 null str 1 0 Works for all char sets get the working dir of the default dir if pc pwd null str byte shell bur RTFS PRINT STRING 1 USTRING TSTSH 29 PRFLG NL PWD Failed return 1 ppath byte shell buf p 7 ppath Appendix G APPCMDSH C 183 i User Guide mmm If not the root add a doit 1 Add V if true if CS OP CMP ASCII p W CS OP INC PTR p if CS OP IS EOS p doit 7 0 if doit p CS OP GOTO EOS p CS OP ASSIGN ASCII p WI CS OP INC PTR p CS OP TERM STRING p addwild 1 if addwild p ppath p CS OP GOTO EOS p Now tack on CS OP ASSIGN ASCII p CS OP INC PTR p Add for non vfat CS OP ASSIGN ASCII p CS OP INC PTR p CS OP ASSIGN ASCII p CS OP INC PTR p CS OP TERM STRING p No
92. STOPEN Note The file handles are always return 0 1 2 3 Use this knowledge if you want to use random access files in a script Example RNDOP TESTFIL 200 CLOSE Close a random access file This command closes a random access file that was opened with RNDOP See RNDOP for a discussion of random access files Example CLOSE 1 LSTOPEN Display all open random access files This command lists all open random access files along with their file handles This is especially handy since after the initial OPEN all accesses are done VIA the handle and it is easy to forget which handle goes with which file Example LSTOPEN READ Read and display a random access record This command reads data from the random access file and prints its value to the console See WRITE for how to write data to the file SEEK for how to seek to a record in the file LSTOPEN to list all random access files by handle and RNDOP for how to open a random access file Example RNDOP TEST FILE 100 open retums handle 0 SEEK 00 WRITE 0 This is record zero SEEK 0 1 WRITE 0 This is record one SEEK 0 0 READ 0 This will print This is record zero CLOSE 0 WRITE Write data to a random access file This command writes data to the current record of a random access file The data is filled to the correct width with spaces internally Multi word strings should be quoted Example See the READ command for an example SEEK Seek
93. T pdr gt register file address dword 0 Not used pdr interrupt number 0 Not used pdr gt drive_flags 0 Turn on Failsafe if desired pdr gt drive flags DRIVE FLAGS FAILSAFE pdr gt partition number 0 Not used pdr gt pcmcia_slot_number 0 Not used pdr gt controller number 0 pdr gt logical_unit number 0 pdr dev table drive io hostdisk io pdr gt dev table perform device ioctl hostdisk perform device ioctl STORE DEVICE NAME HOST DISK HOSTDISK DAT pdr Now modify pro failsafe auto init in prfsapi c to appropriately initialize the selected device for FailSafe The follow ing example is the default implementation To keep the default implementation easy to understand and to maximize flexibility we purposely kept the example simple It may be modified to support multiple drives with different config uration parameters per drive If you need to modify pro failsafe auto init in this way you may use pdrive gt driveno to identify which device the call is being made for This example auto initializes FailSafe mode for a single device This example puts FailSafe in auto restore auto com mit and auto recover mode and provides it with a 128 element block map See the manual pages for pro failsafe init for a detailed discussion of FailSafe configuration values if INCLUDE FAILSAFE AUTO INIT FAILSAFECONTEXT auto fscontext define AUTO BLOCKMAPSIZE 128 FSBLOC
94. T COMPILE TIME THE PROCESSOR CONFIGURATION CONFIGURATION CONSTANTS FROM PORTCONF H Several CPU configuration constants are provided in PORTCONF H These values must be checked and modified for your configuration Please refer to the Section 9 for a thorough explanation of how to modify the preprocessor constants for your CPU Section 5 Processor Configuration at Compile Time ERT S User Guide aaa Section 5 Processor Configuration at Compile Time ERTFS User Guide SECTION 6 CONFIGURING INCLUSION OF DEVICE DRIVER SUPPORT DEVICE SELECTION CONSTANTS FROM PORTCONF H Compile time constants are used to control whether we compile a device driver and whether we install the driver at startup and in some cases whether we require porting layer code that is required for that device driver to operate PORTCONF H contains a set of defines that control this for ERTFS provided device drivers Note ERTFS fully supports run time binding of device drivers These constants are used to make the process more convenient to the user If you create your own driver you are not required to use this same technique as long as you attach the driver inside the pc ertfs init routine The following constants are defined Set the constant to 1 to include the device driver set it to 0 to exclude it After you have selected a device consult the porting section of the reference guide for any special instruction on
95. USTRING TSTSH 05 PRFLG NL No more random file slots else rts cs strcpy rndf name agv agvt rndf gt reclen int rtfs atoi agv if rndf gt fd po_open rndf gt name PO_BINARY PO_RDWR PO_CREAT PS_IWRITE PS_IREAD lt 0 RTFS PRINT STRING 2 USTRING TSTSH 06 rndf name PRFLG NL Cant open Note rndf gt fd is still 1 on error else return 1 RTFS PRINT STRING 1 USTRING TSTSH 07 PRFLG NL Usage RNDOP D PATH RECLEN return 0 Appendix G APPCMDSH C 178 i User Guide mmm CLOSE fd int doclose int agc byte agv P fn MY PCFD fd RNDFILE rndf if agc 1 fd rtfs atoi agv rndf fndrnd fd if Irndf RTFS PRINT STRING 1 USTRING TSTSH 08 PRFLG NL Cant find file else if po close fd lt 0 RTFS PRINT STRING 1 USTRING TSTSH 09 PRFLG NL Close failed else rndf gt fd 1 return 1 RTFS PRINT STRING 1 USTRING TSTSH 10 PRFLG NL Usage CLOSE fa return 0 SEEK fd recordno int doseek int agc byte agv P MM PCFD fd RNDFILE rndf int recno long foff long seekret if agc 2 fd rtfs atoi agv rndf fndrnd fd if Irndf RTFS PRINT STRING 1 USTRING TSTSH 11 PRFLG NL Cant find file else agvt recno rtfs_atoi agv foff long recno rndf gt reclen if foff seekret po Iseek f
96. User Guide QO OUurr our are pc unlink of a very huge file pc rmdir of a very huge directory or pc deltree of a very large subtree If the call fails because the journal is full the disk will not be changed by the call and when the error is cleared and the disk is remounted it will appear that the call had not been made at all If an application is unusual enough to cause a journal full error it should be modified so that it calls pro failsafe commit more often or it should request a larger journal file when FailSafe is initialized This error is possible for any ERTFS API call that writes to a volume Section 30 Failsafe Operating Mode 124 99 ERTFS User Guide ZQ ANE EE ERTFS PRO FAILSAFE API FUNCTIONS pro Ee IEEE 126 pro failSate auto MIN ci 0022022 shend E 128 pro failsate Committee E Ie 129 I e tada 130 pro tallsat AUTO WN skeda vde and ERROR 132 EE EE 133 Gustomizing Failsafe notaio Eo eic eio dt EDI EXER LAE Ea Dat Edi eden 137 failsafe create ny Buffer UI ne Nock venae L d tuza dan AAN AC de dn 138 failsate reopen nv TC 139 failsafe write nv buffer zen 140 failsafe read nv Dule ne rise E A d ehe E bani Ge Le uua vagas et ca vane an Pas Uu den NER d O 141 EXAMPIES C 142 Example 1 Auto Initialize failsafe mode use RE
97. _GET_GEOMETR Y aaa aand an i E enn eterne nnne nenne 60 Section 27 9 1 0 Control op code DEVCTL FORMAT voni i es t nde n d v n ciere ine tbe tech ide enano d eee e PR brasede 60 Section 28 ERTFS Application Programmers Inter fa CE ua aaa aaa aaa adean enne nnn eee eventet 61 P GRIS 4 eres ce os ue edh ve E e e sd a aa 63 peers CON I ee N 64 re n 65 PERSE CWO M 66 pesset default an ver e E 67 PC OW PUE 68 ee UC EE e 69 21050 EE 70 ee e TEE 71 el 72 A A NN 74 UE SE 15 ris get driver eITDO uie ree ert E ae ht nc 76 0102 j E E O M 7T o rele SS 78 pero m 79 of M 80 pem e se M 81 PG TSUA 83 Ge Check dek essai ci E 85 ole EE 86 LOA E H mm 87 PC LUMI Asc 88 PC CSIC Ss occa cece
98. _NUM_USERS sizeof RTFS SYSTEM USER prtfs_cfg gt fat_buffers 0 FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 0 sizeof FATBUFF prtfs_cfg gt fat_buffers 1 FATBUFF malloc prtfs cfg cfg FAT BUFFER SIZE 1 sizeof FATBUFF prtfs_cfg gt fat_buffers 2 FATBUFF malloc prtfs cfg cfg FAT BUFFER SIZE 2 sizeof FATBUFF Appendix C APICONFG C 156 ee i User Guide mmm prtfs_cfg gt fat_buffers 3 FATBUFF prtfs_cfg gt fat_buffers 4 FATBUFF prtfs_cfg gt fat_buffers 5 FATBUFF malloc prtfs_cfg gt cfg_FAT BUFFER SIZE 5 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT BUFFER SIZE S3 sizeof FATBUFF prtfs_cfg gt fat_buffers 6 FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 6 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 4 sizeof FATBUFF prtfs_cfg gt fat_buffers 7 FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 7 sizeof FATBUFF prtfs_cfg gt fat_buffers 8 FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 8 sizeof FATBUFF prtfs_cfg gt fat_buffers 9 FATBUFF malloc prtfs_cfg gt cfg_FAT_BUFFER_SIZE 9 sizeof FATBUFF prtfs_cfg gt fat_hash_table 0 FATBUFF prtfs_cfg gt fat_hash_table 1 FATBUFF prtfs_cfg gt fat_hash_table 2 FATBUFF prtfs_cfg gt fat_hash_table 3 FATBUFF prtfs_cfg gt fat_hash_table 4 FATBUFF prtfs_cfg gt fat_hash_table 5 FATBUFF prtfs_cfg gt fat
99. _SIZE 5 sizeof byte prtfs_cfg gt fat_primary_cache 6 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 6 sizeof byte prtfs_cfg gt fat_primary_cache 7 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 7 sizeof byte prtfs_cfg gt fat_primary_cache 8 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 8 sizeof byte prtfs_cfg gt fat_primary_cache 9 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 9 sizeof byte LLEI E IEY prtfs_cfg gt fat_primary_index 0 dword prtfs cfg gt fat primary index 1 dword prtfs cfg gt fat primary index 2 dword prtfs cfg gt fat primary index 3 dword prtfs cfg gt fat primary index 4 dword prtfs cfg gt fat primary index 5 dword prtfs_cfg gt fat_primary_index 6 dword prtfs_cfg gt fat_primary_index 7 dword prtfs_cfg gt fat_primary_index 8 dword prtfs_cfg gt fat_primary_index 9 dword malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 0 sizeof dword malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 1 sizeof dword malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 2 sizeof dword malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 3 sizeof dword malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 4 sizeof dword malloc prtfs cfg cfg FAT HASHTBL SIZE S sizeof dword malloc prtfs cfg cfg FAT HASHTBL SIZE 6 sizeof dword malloc
100. _hash_table 6 FATBUFF prtfs_cfg gt fat_hash_table 7 FATBUFF prtfs_cfg gt fat_hash_table 8 FATBUFF prtfs_cfg gt fat_hash_table 9 FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 0 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 1 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 2 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 3 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 4 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 5 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 6 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 7 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 8 sizeof FATBUFF malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 9 sizeof FATBUFF YH YS YS aS prtfs_cfg gt fat_primary_cache 0 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 0 sizeof byte prtfs_cfg gt fat_primary_cache 1 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 1 sizeof byte prtfs_cfg gt fat_primary_cache 2 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 2 sizeof byte prtfs_cfg gt fat_primary_cache 3 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 3 sizeof byte prtfs_cfg gt fat_primary_cache 4 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL_SIZE 4 sizeof byte prtfs_cfg gt fat_primary_cache 5 byte malloc prtfs_cfg gt cfg_FAT_HASHTBL
101. ache 1 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 2 LARGE FAT HASHSIZEJ byte KS FAR fat primary cache 3 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 4 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 5 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 6 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 7 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 8 SMALL FAT HASHSIZEJ byte KS FAR fat primary cache 9 SMALL FAT HASHSIZEJ dword KS FAR fat primary index O SMALL FAT HASHSIZEJ dword KS FAR fat primary index 1 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 2 LARGE FAT HASHSIZEJ dword KS FAR fat primary index 3 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 4 SMALL FAT HASHSIZEJ Appendix C APICONFG C 154 ee ERTFS User Guide ZQ QUO O OUUr rr dword KS FAR fat primary index 5 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 6 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 7 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 8 SMALL FAT HASHSIZEJ dword KS FAR fat primary index 9 SMALL FAT HASHSIZEJ endif ALLOC FROM HEAP BOOLEAN pc ertfs config void Important prtfs cfg must point to a configuration block prtfs_cfg amp rtfs cfg core Important the configuration block must be zeroed rts memset prtfs cho 0 sizeof rtfs cfg core Set Configuration values p
102. ailsafe init must be called first PEJOURNALOPENFAIL Journal file or vram init call failed PEIOERRORREAD Error reading FAT or buffer area PEIOERRORWRITEJOURNAL Error writing journal file or NVRAM section PEIOERRORWRITEFAT Error writing FAT area PEIOERRORWRITEBLOCK Error writing directory area An ERTFS system error Section 30 Failsafe Operating Mode 129 HH ERTFS User Guide mmm pro failsafe restore Function Clear the failsafe journal or check journal status or restore from the failsafe journal Summary int pro failsafe restore byte drname FAILSAFECONTEXT ctxt BOOLEAN dorestore BOOLEAN doclear Description Clearing the Journal File In FailSafe mode unless autorecover and autorestore modes are both enabled and a journal file error is detected when the disk is mounted the disk will not be accessible from the ERTFS API All ERTFS API calls that try to act on the volume will fail and errno will be set to PEFSRESTOREERROR This check condition status will remain until either the error is cleared or FailSafe is shut down Journal file errors are rare They result from one of several causes Either a version miss match occurred between the Journal file and the cur rent ERTFS version or the Journal file was changed or corrupted by an external process or the Journal file is valid and a restore is needed but FailSafe detects that the volume was modified by an external process not running FailSafe To lear
103. al unsigned long handle nst nci cen evene dost eren innen dae randen reen een 29 Section 14 Porting timer Support Functions za ritenuti dios 31 void rtfs port sleeplint sleeptime EE inre eror oe erei euet ege tes Ree ER vinde dann Ee basan c ci a ae de Use dude set 31 unsigned long ris port elapsed zero cion cei aeterne cedens ser inn rada Dre o ree indeed 31 int rtfs port elapsed check unsigned long zero val int timeout sssssenne emen 31 Section 15 Porting identify current task T aiios ira red shit tmt remp io ie a 33 Section 16 Porting console input and output scisco a ente nr nn eee eee kret ee vehen eee even er ra 35 Section 17 Porting interr pt enable disable ver sneren runter dia rai 37 Section 18 Porting miscellaneous functions sassen cinsa aai a ARa Ar arasa io 39 Section 19 Porting clock caleridat oet rtt FO RE nlt eaten c E et RR arcte s debt uus 41 Section 20 Porting Tloppy disk e te aO rtu di iaa 43 Section 21 Gei due D Leiner EE 45 Section 21 1 Porting pcmcia to a non 82365 PCMCIA controller sese emen meme 45 Section 21 2 Implementing Card event handlers for externally supplied pcmcia controller drivers 46 Section 26 ERTFS Linear Flash Support Flash Memory Technology Drivers ica coena etes shti sh e cotra aeta Corsa anne Pega sh debi Seka iaaa a inna ed tastet Adding your own Flash Memory Techn
104. am int socket no dword offset This routine is required only if the pcmcia SRAM card driver is being used It must return a pointer to a block in the pcmcia sram s memory space that is offset bytes from the beginning of the SRAM memory area and make sure that 512 bytes are readable and writable at that location Note The SRAM driver actually passes in the byte offset of the block divided by two plus 256 This is because pcmcia SRAM cards are mapped into CIS space which has mod two addressability and starts at location 512 in CIS space You may modify this algorithm in pcmsram block if needed SECTION 21 2 IMPLEMENTING CARD EVENT HANDLERS FOR EXTERNALLY SUPPLIED PCMCIA CONTROLLER Section 21 Porting PCMCIA ERTFS User CT TB DRIVERS If the user wishes to support hot swapping of compact flash cards a management interrupt service or some other mechanism to announce card removal events to the IDE device driver must be provided The 82365 driver drpcmctl c contains a routine called mgmt isr that should be used as a model for how to approach this The source code is provided below Please note the following about how the routine works and how it must behave The routine detects a card change if the change was a removal event no card in slot then it must turn off VCC power to the card and then look up and call the IDE device driver s device I O control function with the appropriate arguments to report a card removal event
105. and library in an environment that will ever exit i e if ERTFS is running with an RTOS in a Dos Windows or Unix environment you should put a call to your RTOS exit code Section 18 Porting Miscellaneous Functions ERT S User Guide aaa Section 18 Porting Miscellaneous Functions RTF User Guide SECTION 19 PORTING CLOCK CALENDAR DATESTR pc getsysdate DATESTR pd When ERTFS needs to date stamp a file it calls this routine to get the current time and date The sample routine returns a fixed data and time If your target has a clock calendar function you may modify this routine to provide real date and time values The source for this routine is in file portkern c see Appendix F and is self explanatory If you wish to integrate a calendar clock module please see the comments in the source code Device driver specific hardware and system access functions Portio c contains ERTFS s interface underlying hardware Routines in this file must be modified to adapt the portable device drivers to new hardware Most of the required functions are simple I O port access routines Please read the following sections to examine the details See Appendix F for the portio c source code Section 19 Porting Clock Calendar ERT S User Guide aaa Section 19 Porting Clock Calendar ERTFS User i C 17 e Cd SECTION 20 PORTING FLOPPY
106. and returns an unsigned long The routine must return a tick count from the system clock The macro named MILLISECONDS PER TICK also local to portkern c must be defined in such a way that it returns the rate at which the tick increases in milliseconds per tick This routine is declared as static to emphasize that its use is local to the portkern c file only static dword rtfs port get ticks void Section 11 Porting Periodic Clock Support ERT S User Guide aaa Section 11 Porting Periodic Clock Support ERTFS User Guide SECTION 12 PORTING MUTEX SEMAPHORE SUPPORT Note ERTFS does not require mutex semaphore in non multitasking environments If you are porting to a non multitasking environment or if you can guarantee that only one task at a time will use ERTFS then please skip this section ERTFS requires several mutex binary semaphores One mutex semaphore is required per drive to be used and one system wide critical section mutex semaphore is required There are a maximum of 26 possible drives but the actual number to sup port is user configurable as described in Section 3 In addition some device drivers may require their own mutex semaphores to function properly The only stock driver that re quires a mutex is the ATA IDE driver If you are using ATA IDE please plan for one extra mutex The Mutex code is abstracted into three functions that must be modified by the user to support
107. ay or may not contain a partition table DRIVE FLAGS PCMCIA The user must set this bit before calling WARMSTART to tell the device driver that this is a PCMCIA device This is used by the IDE Compact flash to distinguish be tween a native IDE device and a PCMCIA ATA device ERTFS does not look at this bit It is used only by the device drivers These bits may be must be set by device driver not the user Section 27 Adding Your Own Device Drivers H U ERTES User Guide mmm DRIVE FLAGS VALID The driver must set this in the WARMSTART section if the controller is present and accessible For Non Removable media this must imply that the media is now acces sible for removable media this implies only that the controller is available not that the media is accessible If the WARMSTART routine returns 0 it must also set DRIVE FLAGS VALID DRIVE FLAGS FORMAT The driver must set this if the media is not already formatted at power up A simple example of a driver that sets this flag every time WARMSTART is called is the RAM disk driver The linear flash driver sets this flag if it detects that the flash has not been formatted If this bit is set when the WARMSTART call returns the initialization code auto formats the device before it returns DRIVE FLAGS REMOVABLE The driver must set this in the WARMSTART call if the media is removable If this bit is set then ERTFS will call the driver s DEVCTL CHECKSTATUS I O control func tion
108. ber field as set in pc ertfs init by the user Hook ide interrupt must establish an interrupt handler such that the plain C function void ide isr int control ler number is called when the IDE interrupt occurs The argument to ide isr must be the controller number that was passed to hook ide interrupt this value is typically zero for single controller system void hook ide interrupt int irq int controller number endif INCLUDE IDE This routine is called by the floppy disk device driver It must establish an interrupt handler such that the plain C func tion void floppy isr void is called when the floppy disk interrupt occurs The value in irq is always 6 this is the PC s standard mapping of the floppy interrupt If this is not correct for your system just ignore the irq argument if INCLUDE FLOPPY This is a sample floppy disk interrupt handler Modify it to match your target system void floppy isr int void floppy interrupt floppy isr 0 void hook floppy interrupt int irq endif INCLUDE FLOPPY Appendix E PORTKERN C 169 ee ERTFS User CTT ER Appendix E PORTKERN C 170 ee ERTFS User Guide opd APPENDIX F PORTIO C EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS I O porting layer file Hinclude lt rtfs h gt All of the I O in and out functions in this
109. cate a native windows or NT subdirectory inside an ERTFS file system volume The file system is formatted like a disk volume but it resides in a single Win NT file named HOSTDISK DAT This tool is useful for populating an ERTFS volume that you may then experiment with Another important use of this tool is to allow the import of a whole WINDOWS NT subtree that can later be emitted as an embeddable rom disk image See the MKROM command Example MKHOSTDISK C MYROMDISK MKROM command shell running in windows test environment only This command takes the contents of a HOSTDISK volume see MKHOSTDISK and emits a file named drromdsk h in the current Windows directory that may be used by the rom disk driver to provide an exact read only image of that volume in the target system This command when used along with the MKHOSTDISK command allows you to create an exact rom image of a Windows NT subdirectory and it s descendants in the embedded system Example MKROM CHKDSK Perform a check disk procedure on a drive Example CHKDSK C 0 check drive C don t write lost chains CHKDSK C 1 check drive C write lost chains to CHK files DIR Print a directory listing Example DIR DEVINFO Print the names of all disks and their drive designators Example DEVINFO ERTFS Device List Device name HOST DISK HOSTDISK DAT Is mounted on G Device name RAM DISK Is mounted on I Device name STATIC ROM DISK Is mounte
110. che 4 Iprtfs cfg fat primary cache 5 Iprtfs cfg fat primary cache 6 Iprtfs cfg fat primary cache 7 Iprtfs cfg fat primary cache 8 Iprtfs cfg fat primary cache 9 goto malloc failed if Iprtfs cfg fat primary index O Iprtfs cfg fat primary index 1 II Iprtfs cfg fat primary index 2 Il Iprtfs cfg fat primary index 3 II prtfs cfg fat primary index 4 Il Iprtfs cfg fat primary index 5 II Iprtfs cfg fat primary index 6 II Iprtfs cfg fat primary index 7 II prtfs cfg fat primary index 8 Iprtfs cfg fat primary index 9 goto malloc failed return TRUE malloc failed if prtfs cfg mem drives structures free prtfs cfg mem drives structures if prtfs cfg mem block pool free prtfs cfg mem block pool if prtfs cfg mem block hash table free prtfs cfg mem block hash table if prtfs cfg gt mem file pool if prtfs cfg mem drobj pool if prtfs cfg mem finode pool if prtfs cfg rtfs user table free prtfs cfg mem file pool free prtfs cfg mem drobj pool free prtfs cfg mem finode pool free prtfs cfg rtfs user table if prtfs cfg fat buffers 0 if prtfs cfg fat buffers 1 if prtfs cfg gt fat buffers 2 if prtfs cfg fat buffers 3 if prtfs_cfg gt fat_buffers 4 if prtfs cfg fat buffers 5 free prtfs cfg fat buffers 0 free prtfs_cfg gt fat_buffers 1 free prtfs_cfg gt fat_buffers 2
111. cks that were written because they contained changed data but the buffer was required in order to load another block Returns TRUE Success FALSE Failure If FALSE is return errno will be set to one of the following PEINVALIDDRIVEID Drive argument invalid Section 29 ERTFS Pro API Functions 119 7 F ERTFS User Guide Z QQ pro assign buffer pool Function Assign a private buffer pool to a drive Summary BOOLEAN pro assign buffer pool byte drive name int block hashtable size BLKBUFF block hash table int block buffer pool size BLKBUFF block buffer pool data Description This routine provides a way to assign a private block buffer pool to a named drive Normally block buffer space is shared among all drives in the system but this function allows the caller to assign block buffers that are private to the specified drive This function may improve performance by reducing the amount of buffer swapping that occurs when multiple drives compete for buffers in the common pool Inputs Drive name Null terminated drive designator for example A Block buffer context User supplied memory for the block buffer context block that will be assigned to the drive to be used as a private buffer pool management structure This must be a pointer to a structure of type BLKBUFFCNTXT that must remain valid for the whole session and may not be deallo cated If block buffer context is 0 the drive block hashtable size
112. code is DEVCTL POWER LOSS ERTFS does not implement this OPCODE in any drivers but it is an appropriate interface for handling low power management The following code fragment reports a low power request to the device driver This simple system has one power sensitive device mapped to the B drive and it is designed such that a routine named report low power model is called whenever the system enters low power mode define POWER AWARE DRIVE 1 System uses B for this drive report low power mode pdr pc drno to drive struci POVVER AWARE DRIVE if pdr pdr dev table perform device iocti pdr driveno DEVCTL POWER LOSS PFVOID 0 SECTION 27 7 I O CONTROL OP CODE DEVCTL REPORT RESTORE xxx perform device ioctl driveno DEVCTL POWER RESTORE 0 returns nothing The DEVCTL POWER RESTORE IO control call can be used to report to the device driver that power is restored It can either exit low power mode now or ignore this signal and exit low power mode next time the driver is called ERTFS does not implement this op code in any drivers but it may be an appropriate interface for handling power restore SECTION 27 8 I O CONTROL OP CODE DEVCTL GET GEOMETRY xxx perform device ioctl driveno DEVCTL GET GEOMETRY pargs returns 0 if it successfully reported the correct geometry otherwise 1 pargs points to a structure of type DEV GEOMETRY This structure must be first zeroed out by the driver and then filled with appr
113. d foff PSEEK SET RTFS PRINT STRING 1 USTRING TSTSH 12 PRFLG_NL Seek operation failed else return 1 RTFS PRINT STRING 1 USTRING TSTSH 13 PRFLG NL Usage SEEK fd recordno return 0 READ fd Appendix G APPCMDSH C 179 ee ERTFS User Guide mmm int doread int agc byte agv fn PCFD fd RNDFILE rndf int res if agc 1 fd PCFD rtfs atoi agv rndf fndrnd fd if Irndf RTFS PRINT STRING 1 USTRING TSTSH 14 PRFLG NI Cant find file else if res po_read fd byte rnaf gt buff word rnaf gt reclen rndf gt reclen RTFS PRINT STRING 1 USTRING TSTSH 15 PRFLG NL Read operation failed else RTFS PRINT STRING 2 USTRING SYS NULL rndf gt buff PRFLG_NL return 1 RTFS PRINT STRING 1 USTRING TSTSH 16 PRFLG NL Usage READ fd return 0 WRITE fd data int dowrite int agc byte agv fn PCFD fd RNDFILE rndf int res if agc 2 fd rtfs_atoi agv rndf fndrnd fd if Irndf RTFS PRINT STRING 1 USTRING TSTSH 17 PRFLG NL Cant find file else pc_cppad byte rndf gt buff byte agy int rndf gt reclen rndf gt buff maf gt reclen CS OP ASCII 0 if res po_write fd byte rndf gt buff word rndf gt reclen rndf gt reclen RTFS PRINT STRING 1 USTRING TSTSH 18 PRFLG NL Write operation failed else return 1
114. d cor rectly PEINVALIDDRIVEID Invalid drive An ERTFS system error perhaps caused if the FAT and buffer flush failed Section 30 Failsafe Operating Mode 127 Q ERTFS User Guide mmm pro failsafe auto init Function Automatically enable failsafe for a device at boot time You must modify this source code if you wish to auto configure failsafe features for a given device Summary BOOLEAN pro failsafe auto init DDRIVE pdrive Description In pc ertfs init for a given device if the flag value DRIVE FLAGS FAILSAFE is set in pdr 2drive flags field then pro fail safe auto init is called to automatically enable Failsafe mode for that drive When failsafe is initialized this way there is no need to call pro failsafe init from the API layer Note pro failsafe auto init is implemented inside the file prapifs c To use this feature ICLUDE FAILSAFE AUTO INIT must be set to 1 in the source file and the source code for the routine should be modified to configure FailSafe to fit your needs By default the INCLUDE FAILSAFE AUTO INIT is set to zero Inputs Pdrive A pointer to the drive structure for the device Please see the manual page for pro failsafe init for a complete description of FailSafe initialization parameters Returns TRUE Success FALSE Error If pro failsafe auto init returns false the drive is marked invalid and all future volume mount attempts will fail Section 30 Failsafe O
115. d on J Device name FLASH DISK Is mounted on H MKDIR Create a directory This command creates a directory Example MKDIR USR NEWDIR RENAME Rename a file This command will rename a file Appendix H Command Shell 196 ee i User Guide mmm Example RENAME CATESWOSUF TXT JOSEPH TXT RMDIR Remove a subdirectory Example RMDIRC TEMPDIRCAT Display contents of a file This command displays the contents of a file to the console Example CAT A use ASCII budget txt DELETE Delete a file This command deletes a file Example DELETE A use ASCll budget txt CD Set or display working directory This command sets the default directory if an argument is supplied otherwise it displays the current working directory Example CD Display working directory Example CD usr data Change working directory COPY Copy a file to another location This command copies the source file to the destination Example COPY A FILE DAT B FILE DAT DELTREE Delete a directory and its descendants Example DELTREE CATEMP DIFF Compare two files This command compares two files and prints whether or not they are the same Example DIFF A FILE1 DAT B FILE1 DAT DSKSEL Set default drive This command sets the default drive so that subsequent commands that do not explicitly contain a drive specifier will refer to this drive Example DSKSEL D FILLFILE Create a file and fill it with a pattern This
116. d1 int nread int nread1 int i byte buff 256 byte buff1 256 BOOLEAN forever TRUE use this for while forever to quiet anal compilers if agc 2 if Un fd po open agv PO BINARY PO RDONLY PS IWRITE PS IREAD lt 0 RIES PRINT STRING 2 USTRING TSTSH 47 agv PRFLG NL Cant open file return 0 if in_fd1 po_open agv 1 PO BINARY PO RDONLY PS_IWRITE PS_IREAD lt 0 RTFS PRINT STRING 2 USTRING TSTSH 48 agv 1 PRFLG_NL Cant open file return 0 Appendix G APPCMDSH C 187 ERTFS User Guide mmm while forever nread po read in fd byte buff word 255 if nread 0 nread1 po read in fd1 byte buff1 word nread if nread1 nread difffail RTFS PRINT STRING 1 USTRING TSTSH 49 PRFLG NL Files are different po close in fd po close in fd return 0 for i 0 i lt nread i if buff i buff1 i goto difffail else break nread1 po read in fd1 byte buff1 word nread if nread1 lt 0 RTFS PRINT STRING 2 USTRING TSTSH 50 agv 0 File RTFS PRINT STRING 2 USTRING TSTSH 51 agv 1 0 And File RTFS PRINT STRING 1 USTRING TSTSH 52 PRFLG NL are the same else RTFS PRINT STRING 2 USTRING TSTSH 53 agv 1 0 File RTFS PRINT STRING 2 USTRING TSTSH 54 agv PRFLG NL is larger than File
117. de mmm failsafe write nv buffer Function Write a block to the failsafe buffer Summary BOOLEAN failsafe write nv buffer FAILSAFECONTEXT pfscntxt dword block no byte pblock Description This routine must write one block to the block at offset block no in the failsafe buffer on the current disk or in system NV RAM and return TRUE if successful FALSE if it is unsuccessful Section 30 Failsafe Operating Mode 140 r rU ERTFS User Guide mmm failsafe read nv buffer Function Read a block from the failsafe buffer Summary BOOLEAN failsafe read nv buffer FAILSAFECONTEXT pfscntxt dword block no byte pblock Description This routine must read one block from the block at offset block no in the failsafe buffer on the current disk or in system NV RAM and return TRUE if successful FALSE if it is unsuccessful Section 30 Failsafe Operating Mode 141 ERTFS User Guide Z Qu Examples Example 1 Auto Initialize failsafe mode First in apiinit c set the DRIVE FLAGS FAILSAFE flag bits for the device The following block demonstrates this pro cedure for the hostdisk device driver if drives used gt prtfs_cfg gt cfg_NDRIVES goto need more drives pdr gt driveno 0 MAPS DRIVE structure to A Install Using a host driver pdr gt dev table drive io hostdisk io pdr gt dev table perform device ioctl hostdisk perform device ioctl STORE DEVICE NAME HOST DISK HOSTDISK DA
118. dev geometry Ibas is zero the partition sizes must be entered in units of cylinders pc get media parms pc format media pc format volume Returns Returns TRUE if it was able to perform the operation otherwise it returns FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEINVALIDPARMS nconsistent or missing parameters PEIOERRORWRITE Error writing partition table An ERTFS system error See Appendix J for a description of system errors Example Note This routine is designed to work in a specific context See the documentation for routine pc format volume for ex ample usage Section 28 ERTFS Application Programmer s Interface 103 ee ERTFS User Guide pc format media Perform a device level format Summary BOOLEAN pc format media byte path PDEV_GEOMETRY pgeometry path is the device s drive id A B etc pgeometry is the value returned pc get media parms Description This routine performs a device level format on the specified device Returns Returns TRUE if it was able to perform the operation otherwise it returns FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEDEVICEFAILURE Device driver format request failed See Also pc get media parms pc partition media pc format volume Example Note This routine is designed to work in a specific context See the documentation for r
119. directory DELETE Delete a file CAT Display contents of a file CD Set or display working directory COPY Copy a file to another DELTREE Delete a directory and its descendants DIFF Compare two files DSKSEL Set default drive FILLFILE Create a file and fill it with a pattern GETATTR Print a file s attributes SETATTR Change a file s attributes STAT Print file properties CHSIZE Truncate or extend a file RNDOP Open a random access file CLOSE Close a random access file READ Read and display a random access record WRITE Write data to a random access file SEEK Seek to a record in a random access file HELP Display all commands QUIT Exit the command shell Appendix H Command Shell 195 ee i User Guide mmm FORMAT Format a disk This routine will prompt you for the disk letter of the device that you would like to format It prompts you first for the drive ID and then asks if you would like to perform low level media formatting disk partitioning and DOS volume formatting All ERTFS volumes and writable media may be initialized this way Example FORMAT Enter the drive to format as A B etc C Press Y to format media Y Press Y to partition media Y The drive is contains 1024 cylinders Select the number of cyls for first partition 1024 Press Y to format the volume Y MKHOSTDISK command shell running in windows test environment only This command gives the user a method to dupli
120. dma transfer for DMA channel 2 on a standard PC AT architecture It must be analyzed and modified if being used on some other system Floppy disk register access routines Six functions all contained in drfloppy c are provided to access the registers of the NEC765 class floppy disk controller They are all hard wired to use Intel I O out and I O in instructions in the address range 0x3f0 to Ox3ff If the floppy driver is being moved to a non PC environment these routines must be modified fl read data Reads a byte from the 765 data register fl read drr Reads a byte from the 765 data rate register fl read msr Reads a byte from the 765 master status register fl write data Writes a byte to the 765 data register fl write dor Writes a byte to the 765 digital output register fl write drr Writes a byte to the 765 data rate register Section 20 Porting Floppy Disk ERT S User Guide aaa Section 20 Porting Floppy Disk ERTFS User Guide SECTION 21 PORTING PCMCIA ERTFS is supports Compact Flash and PCMCIA Ram cards If these devices are to be used then either the PCMCIA controller must be managed externally or the ERTFS PCMCIA subsystem must be used The subsystem consists of the files drpemcia c which is portable and drpcmctl c a device driver for INTEL 82365 compatible pcmcia controller chips Several functions are required for the portable pcmcia code in drpemcia c to ope
121. e cache when a read request was made block buffers cache misses Number of block reads so far that were not in the cache when a read request was made block buffers low The low water mark or lowest number of block buffers that have been available for allocation so far block buffers fail The number of block allocation failures that have occurred due to insufficient buffer pool space fat buffer primary cache hits Number of fat block accesses so far that were in the fat primary cache when the request was made fat buffer secondary cache hits Number of fat block accesses so far that were in the fat secondary cache when the request was made fat buffer cache misses Number of fat block accesses so far that were not in the fat secondary cache when the request was made total fat buffers Total number of FAT directory buffers for this drive This value is determined by the value as signed to prtfs cfg gt cfg FAT BUFFER SIZE driveno in apiconfig c fat buffers pending Total number of FAT blocks scheduled to write but not yet written fat buffers available Number of FAT blocks still available to store pending writes fat buffers free Number of FAT buffer blocks that have never been used If this value is non zero it means no fat swapping has occurred fat buffer cache loads Number of FAT block reads so far that were not in the cache when the request was made fat buffer cache swaps Number of FAT block swaps so far Blo
122. e elapsed In a multitasking environment this call should yield the cpu unsigned long rtfs port elapsed zero This routine takes no arguments and returns an unsigned long The routine must return an unsigned long value that will later be passed to rtfs port elapsed check to test if a given number of milliseconds or more have elapsed A typical implemen tation of this routine will read the system tick counter and return it as an unsigned long ERTFS makes no assumptions about the value that is returned Note In either a POLLED or RTOS environment this does not need modification as long the routine rtfs port get ticks has been implemented int rtfs port elapsed check unsigned long zero val int timeout This routine takes as arguments an unsigned long value that was returned by a previous call to rtfs port elapsed zero and a timeout value in milliseconds If timeout milliseconds have not elapsed it should return O If timeout milliseconds have elapsed it should return 1 A typical implementation of this routine would read the system tick counter subtract the zero value scale the difference to milliseconds and compare that to timeout If the scaled difference is greater or equal to timeout it should return 1 if less than timeout it should return 0 Note In either a POLLED or RTOS environment this does need modification as long the routine rtfs port get ticks has been implemented Section 14 Porting Time Support Functions
123. e routines MUST be implemented unsigned long rtfs port alloc signal void This routine takes no arguments and returns an unsigned long The routine must allocate and initialize a signaling device typically a counting semaphore and set it to the not signaled state It must return an unsigned long value that will be used as a handle ERTFS will not interpret the value of the return value The handle will only used as an argument to the rtfs port clear signal rtfs port test signal and rtfs port set signal calls void rtfs port clear signal unsigned long handle This routine takes as an argument a handle that was returned by rtfs port alloc signal It must place the signal in an un signalled state such that a subsequent call to rtfs port test signal will not return success until rtfs port set signal has been called This clear function is necessary since it is possible although unlikely that an interrupt service routine could call rtfs port set signal after the intended call to rtfs port test signal timed out A typical implementation of this function for a counting semaphore is to set the count value to zero or to poll it until it returns failure int rtfs port test signal unsigned long handle int timeout This routine takes as an argument a handle that was returned by rtfs port alloc signal and a timeout value in milliseconds It must block until timeout milliseconds have elapsed or rtfs port set signal has been called I
124. ection 3 Section 15 Porting Identify Current Task ID ERT S User Guide aaa Section 15 Porting Identify Current Task ID ERTFS User Guide SECTION 16 PORTING CONSOLE INPUT AND OUTPUT Two console 1 O functions are used by ERTFS to display messages and retrieve user input These routines are not essential for the correct operation of ERTFS but they are useful for printing diagnostics They are essential if you wish to use the interac tive command shell Note If you don t wish to display diagnostic messages or use the command shell skip this section void rtfs port tm gets byte buffer This routine requires porting if you wish to use the interactive test shell It must provide a line of input from the terminal driver The line must be NULL terminated and it must not contain ending newline or carriage return characters void rtfs port puts byte buffer This routine requires porting if you wish to display messages to your console This routine must print a line of text from the supplied buffer to the console The output routine must not issue a carriage or linefeed command unless the text is terminated with the appropriate control character In or V Section 16 Porting Console Input Output ERT S User Guide aaa Section 16 Porting Console Input Output ERTFS User Guide SECTION 17 PORTING INTERRUPT ENABLE DISABLE In
125. efault drive byte drive Description Use this function to set the current default drive that will be used when a path specifier does not contain a drive specifier Returns Returns FALSE if the drive is invalid errno is set to one of the following 0 No error PEINVALIDDRIVEID Driveno is incorrect Example include lt ertfs h gt if nc set default drive C printf Can t change working driveW Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide QUO Urrorvor r vso pc pwd Return the current working directory Summary include lt ertfs h gt BOOLEAN pc_pwa byte drive byte return_buffer Description Fill return buffer with the full path name of the current working directory for the current task for the drive specified in drive If drive points to an empty string or is an invalid drive specifier the current working directory for the default drive is returned In a multitasking system ERTFS maintains a current working directory for each task Note ERTFS must be configured correctly in order for each task have its own current working directory Please see the docu mentation of the routine pc ertfs config for a complete explanation of this requirement Note return buffer must point to enough space to hold the full path without overriding user data The worst case possible is 260 bites Returns Returns YES if a valid path was returned in return buffer otherwise NO if
126. er that was put into the 82365 management interrupt selection register and is between 0 and 15 This is controlled by the constant MGMT_INTER RUPT which is defined in pcmctrl c if INCLUDE 82365 PCMCTRL The routine mgmt isr 0 must execute when the PCMCIA controller interrupts this a sample interrupt service routine that will do this modify it to match your system s interrupt behavior void mgmt isr int void pcmcia isr mgmt_isr 0 This routine must hook the interrupt so the above code is jumped to when the PCMCIA controller interrupts void hook_82365_pcmcia_interrupt int irq endif INCLUDE_82365_PCMCTRL if INCLUDE_IDE The routine ide_isr controller_number must execute when the IDE controller associated with that controller number interrupts These are sample interrupt service routines that will do this modify them to match your system s interrupt behavior void ide_isr int This is a sample interrupt service routine for controller O void ide isr O ide isr 0 This is a sample interrupt service routine for controller 1 void ide isr 1 Appendix E PORTKERN C 168 ide_isr 1 ERTFS User Guide mmm hook ide interrupt is called with the interrupt number in the argument irq taken from the user s setting of pdr gt inter rupt number in pc ertfs init Controller number is taken from the pdr controller num
127. ered IO request is made to a different block number Using the PO BUFF ERED flag increases performance of applications performing reads and writes of small or un alligned data buffers PO AFLUSH Enable auto flush mode The file is flushed automatically by po write whenever the file length changes PO NOSHAREANY Failif already open fail if another open is tried PO NOSHAREWRITE Fail if already open for write and fail if another open for write is tried Mode values are PS IWRITE Write permitted PS IREAD Read permitted Always true anyway Returns Returns a non negative integer to be used as a file descriptor for calling po read po write po Iseek po flush po trun cate and po close otherwise it returns 1 errno is set to one of the following 0 No error PENOENT Notcreating a file and file not found PEMFILE Out of file descriptors PEINVALIDPATH Invalid pathname PENOSPC No space left on disk to create the file PEACCES Is a directory or opening a read only file for write PESHARE Sharing violation on file opened in exclusive mode PEEXIST Opening for exclusive create but file already exists PEEXIST Opening for exclusive create but file already exists An ERTFS system error See Appendix J for a description of system errors Example Zinclude lt ertfs h gt PCFD fd if pcfd po_open USR MYFILE PO CREAT PO EXCL PO WRONLY P S IWRITE 0 printf Cant create file error i n fs_user gt p_
128. ermine appropriate values you may call pro buffer status the failsafe blocks used field in the status structure will contain the number of these resources used In order to gauge the worst case usage pro buffer status should be called immediately prior to calling pro failsafe commit 7 fscontext blockmap size BLOCKMAPSIZE fscontext blockmap freelist amp failsafe_blockmap_array 0 Section 30 Failsafe Operating Mode 144 ERTFS User Guide mmm if Ipro_failsafe_init drive_name amp fscontext RIES PRINT STRING 1 USTRING TSTSH 114 PRFLG NL Failsafe init failed if get errno PEFSREINIT Failsafe already running on a drive n RTFS PRINT STRING 1 USTRING TSTSH 115 PRFLG NL Command shell only supports one failsafe session RTFS PRINT STRING 1 USTRING TSTSH 116 PRFLG NL Section 30 Failsafe Operating Mode 145 ee ERTFS User Guide Example 3 Commit failsafe buffers to disk and clear the failsafe journal file If the commit succeeds reset the journal file Once commit has succeeded the disk image is in sync with the memory image of the directory and fat buffers and the journal file is cleared Note Do not call this function If FailSafe is operating in auto com mit mode int fs demo commit byte drivename int err if Ipro failsafe commit drivename printf Test1 Failsafe commit failed error d n get errno return 1
129. errno Section 28 ERTFS Application Programmer s Interface i User Guide mmm po_close Close a file that was opened with po_open Summary include lt ertfs h gt int po_close PCFD fd Description Close the file and update the disk by flushing the directory entry and file allocation table then free all core associated with FD Returns Returns 0 if all went well otherwise 1 errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition An ERTFS system error See Appendix J for a description of system errors See Also po flush Example include lt ertfs h gt if po close fd lt 0 printf Error closing file i n p_errno Section 28 ERTFS Application Programmer s Interface ee i User Guide mmm po_flush Flush a file to disk Summary include lt ertfs h gt BOOLEAN po_flush PCFD fd Description Write the file s directory entry to disk and flush the FAT After this call completes the on disk view of the file is completely consistent with the in memory view It is a good idea to call this function periodically if a file is being extended If a file is not flushed or closed and a power down occurs the file size will be wrong on disk and the FAT chains will be lost Returns Returns TRUE if flush succeeded otherw
130. ers fail dword block buffers cache hits dword block buffers cache misses dword fat buffer primary cache hits dword fat buffer secondary cache hits dword fat buffer cache loads dword fat buffer cache swaps dword total fat buffers dword fat buffers pending dword fat buffers available dword fat buffers free E If the routine succeeds it will return 0 and the following fields in pstat will be populated failsafe mode Failsafe operating mode 0 Failsafe not initialized 1 Failsafe is initialized but journaling is not active failsafe blocks used If FailSafe journaling is enabled this value contains the number of bocks currently consumed in the FailSafe file failsafe blocks free f FailSafe journaling is enabled this value contains the number of blocks still available in the FailSafe file total block buffers Total number of directory buffers available This may be the number of blocks in the system buffer pool or the number of blocks in the drive specific buffer pool if one was established with pro assign buffers block buffers pending Total number of directory blocks scheduled to write but not yet written This value is always zero block buffers available Number of directory blocks still available to hold pending writes This value is always equal to Section 29 ERTFS Pro API Functions 118 ERTFS User Guide total block buffers block buffers cache hits Number of block reads so far that were in th
131. evice drivers signal to the application such conditions as write protect and card removal Then the application can try to correct the problem and restart the operation Example An applicatoion attempts to create a directory on a read only device define CARD IS WRITE ONLY 0x12345678 if lpe_mkdir DATADIRECTORY if rtfs get driver errno CARD IS WRITE ONLY printf Can t create directory card is write protected Section 28 ERTFS Application Programmer s Interface ERTFS User Guide mmm pc free Return disk free space statistics Summary include lt ertfs h gt long pc free byte drive dword total blocks dword free blocks Description Given a drive ID return the number of free bytes on the drive the total number of blocks on the drive and the number of blocks free Returns The number of bytes free on the disk errno is set to one of the following 0 Noerror PEINVALIDDRIVEID Driveno is incorrect An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt free bytes pc free A amp total blocks amp free blocks printf ld free bytes n free bytes printf ld blocks free out of ld n free blocks total blocks Section 28 ERTFS Application Programmer s Interface ee i User Guide mmm pc_get_attributes Get File Attributes of the named file Summary include lt ertfs h gt BOOLEAN pc
132. f syncin else if s FS STATUS IO ERROR printf lO error accessing journal else if s FS STATUS MUST RESTORE printf Restoring disk from the journal file if pro failsafe restore A amp ctxt TRUE FALSE FS STATUS RESTORED printf Restore was completed successfully n if clear if pro_failsafe_restore A amp ctxt FALSE TRUE FS STATUS OK printf Journal was cleared successfully n Section 30 Failsafe Operating Mode 131 ee ERTFS User Guide mmm pro_failsafe_shutdown Function Close or abort FailSafe mode Summary BOOLEAN pro failsafe shutdown byte drive name BOOLEAN abort Description This routine allows the applications layer to shutdown a FailSafe session that was either auto initialized at startup or was initialized by calling pro failsafe init After pro failsafe shutdown has completed the FailSafe context block that was as signed to the drive may be reused If abort is TRUE then FailSafe mode is immediately disabled for the device and any currently uncommited operations are lost If abort is FALSE FailSafe will attempt to commit any currently journalled operations before disabling FailSafe If the commit operation fails pro failsafe shutdown will return FALSE errno will be set to one of the values listed below and FailSafe will still be active After pro failsafe shutdown has executed pro failsafe init may be called again to re initialize FailSafe
133. f the block buffer hash table define LARGE FAT SIZE 32 Number of 520 byte blocks committed for buffering fat blocks on drive C define LARGE FAT HASHSIZE 32 This value must be a power of two Number of 12 byte hash table entries committed for use on drive C define SMALL FAT SIZE 2 Number of 520 byte blocks committed for buffering fat blocks all other drives define SMALL FAT HASHSIZE 2 This value must be a power of two Number of 12 byte hash table entries committed Appendix C APICONFG C 153 ee ERTFS User Guide mmm for use on all other drives define NUSERFILES 10 Maximum Number of open Files at a time Directory Object Needs Conservative guess is One CWD per user per drive One per file one per User for directory traversal This is calculated do not change define NFINODES 32 NUM USERS NDRIVES NUM USERS NUSERFILES define NDROBJS 32 NUM_USERS NDRIVES NUM USERS NUSERFILES RTFS_CFG prtfs cfg The user must initialize this value to point to a valid configuration block static RTFS CFG rtfs cfg core The user must initialize this value to point Tif ALLOC FROM HEAP Using malloc to allocate memory at startup If malloc is not available but some other heap manager is then change the calls to malloc to call your heap manager instead include lt malloc h gt else Not using malloc to allocate memory so declare arrays that we can send assign to the con
134. f the test succeeds it must return O if it times out it must return a non zero value void rtfs port set signal unsigned long handle This routine takes as an argument a handle that was returned by rtfs port alloc signal It must set the signal such that a subsequent call to rtfs port test signal or a call currently blocked in rtfs port test signal will return success Note rtfs port set signal is always called from the device driver interrupt service routine while the processor is executing in the interrupt context Section 13 Porting Event Signaling Support ERT S User Guide aaa Section 13 Porting Event Signaling Support ERTFS User Guide SECTION 14 PORTING TIMER SUPPORT FUNCTIONS Three abstract timer support functions are included These routines are only used by the floppy disk driver the IDE device driver and the PCMCIA support subsystem If none of these devices is being used then please skip this section Note In a NON RTOS environment the implementation of these functions do not need user modification as long as the routine rtfs port get ticks has been implemented In an RTOS environment these routines MUST be implemented The requirements for each of these functions is defined below void rtfs port sleep int sleeptime This routine takes as an argument the time to sleep milliseconds It must not return to the caller until at least sleeptime mil liseconds hav
135. fault is 32 SMALL FAT SIZE The number of 520 byte blocks committed for buffering fat blocks on drives other than C see above for an explanation The default is 32 SMALL FAT HASHSIZE The number of 12 byte hash table entries committed for use on drives other than C see above for an explanation The default is 32 NUSERFILES The maximum number of files that may be open at one time The default is 10 Section 3 Configuring Runtime Features R RTF User Guide SECTION 4 CONFIGURING COMPILE TIME FEATURE SET OPTIONS There are a few compile time options that must be configured before building the ERTFS library These options are included in the files PORTCONF H and RTFSCONF H Constants in RTFSCONF H control the inclusion of file system features Constants in PORTCONF H are needed to define your CPU configuration A second section in PORTCONF H controls your selection of active device drivers ERTFS fully supports installable device drivers these constants are here only as a convenience to control the inclusion and exclusion of EBS provided drivers They also allow us to exclude unneeded functions from the porting layer when a service is not needed See Appendix B for the RTFSCONF H source code CONFIGURATION CONSTANTS FROM RTFSCONF H Character set support ERTFS supports Unicode JIS and standard 8 bit ASCII character sets Select one character set from the following constants INCLUDE CS JIS Setto 1 to API support J
136. fe functions ERTFS Pro FailSafe internal routines ERTFS Pro FailSafe journal file access routines ERTFS PRO FailSafe test suite SOURCE CODE FOR ERTFS DEVICE DRIVERS All of the provided device drivers are portable and should compile on any system To make the device drivers work in a target environment you must edit the file portio c and perhaps portkern c One exception to this is the floppy disk driver Even though it is actually quite portable we chose to only support it for the x86 environment If you wish to move it to another envi ronment you must modify the driver source code itself You may disable any of these devices by editing the line in portconf h that enables the device drramdsk c drromdsk c drromdsk h drfloppy c drideata c drflash h drfisftl c drfismtd c drmmccrd c drpcmram c drpcmcia c drpcmctl c Portable ram disk driver Portable rom disk driver rom disk data generated by the MKROM function of the ERTFS Command Shell Floppy disk driver IDE ATA Compact flash driver Flash Translation Layer Driver Flash Translation Layer Driver Intel Flash Memory Technology Driver and RAM based Flash Emulator Multi Media card driver PCMCIA SRAM card driver PCMCIA support functions 82365 PCMCIA controller driver Section 2 Source Code Structure 8 ERTFS User Guide SECTION 3 CONFIGURING RUNTIME FEATURES CONFIGURING THE MEMORY USAGE AND CAPACITIES OF ERTFS ERTFS is configured and its working memo
137. figuration block at startup DDRIVE __mem_drives_structures NDRIVES BLKBUFF mem block pool NBLKBUFFS BLKBUFF mem block hash table BLKHASHSIZE PC FILE mem file poolINUSERFILES DROBJ mem drobj poollNDROBJSI FINODE mem finode pool NFINODES RIES SYSTEM USER rtfs user tablejNUM USERS FATBUFF KS FAR fat buffer O SMALL FAT SIZE FATBUFF KS FAR fat buffer 1 SMALL FAT SIZE FATBUFF KS FAR fat buffer 2 LARGE FAT SIZE FATBUFF KS FAR fat buffer 3ISMALL FAT SIZE FATBUFF KS FAR fat buffer 4 SMALL FAT SIZE FATBUFF KS FAR fat buffer 5 SMALL FAT SIZE FATBUFF KS FAR fat buffer 6 SMALL FAT SIZE FATBUFF KS FAR fat buffer 7 SMALL FAT SIZE FATBUFF KS FAR fat buffer 8 SMALL FAT SIZE FATBUFF KS FAR fat buffer 9 SMALL FAT SIZE FATBUFF KS FAR fat hash table Oo SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 1 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table _2 LARGE FAT HASHSIZEJ FATBUFF KS FAR fat hash table 3 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 4 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 5 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 6 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 7 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 8 SMALL FAT HASHSIZEJ FATBUFF KS FAR fat hash table 9 S MALL FAT HASHSIZEJ byte KS FAR fat primary cache O SMALL FAT HASHSIZEJ byte KS FAR fat primary c
138. file This function uses other API calls and does not set errno itself Note This is not an ATOMIC file system operation It uses other API calls po Iseek po truncate and po write to size truncate and extend the file Returns Returns O on success 1 on error errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEACCES File is read only PEINVALIDPARMS Invalid or inconsistent arguments PETOOLARGE Trying to extend a file beyond RTFS MAX FILE SIZE An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface 100 ee i User Guide mmm po_truncate Truncate an open file Summary include lt ertfs h gt BOOLEAN po_truncate PCFD fd long offset Description Truncates the open file at fd to newsize Any file blocks beyond newsize are freed and the file size is adjusted The file pointer is left at the new end of file Returns Returns TRUE if po_truncate succeeded otherwise FALSE is returned errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEACCES File is read only or ope
139. free prtfs cfg gt fat primary cache 3 if prtfs cfg fat primary cache 4 free prtfs cfg fat primary cache 4 if prtfs cfg gt fat primary cache 5 free prtfs cfg fat primary cache 5 VII if prtfs cfg fat primary cache 6 free prtfs cfg fat primary cache 6 if prtfs cfg fat primary cache 7 free prtfs cfg gt fat primary cache 7 if prtfs cfg fat primary cache 8 free prtfs cfg fat primary cache 8 if prtfs cfg fat primary cache 9 free prtfs cfg fat primary cache 9 if prtfs cfg fat primary index 0 free prtfs cfg fat primary index 0 if prtfs cfg fat primary index 1 free prtfs cfg fat primary index 1 if prtfs cfg fat primary index 2 free prtfs cfg fat primary index 2 if prtfs cfg fat primary index 3 free prtfs cfg fat primary index 3 if prtfs cfg fat primary index 4 free prtfs cfg fat primary index 4 if prtfs cfg fat primary index 5 free prtfs cfg fat primary index 5 ML if prtfs cfg fat primary index 6 free prtfs cfg fat primary index 6 if prtfs cfg fat primary index 7 free prtfs cfg gt fat primary index 7 if prtfs cfg fat primary index 8 free prtfs cfg fat primary index 8 if prtfs cfg fat primary index 9 free prtfs cfg fat primary index 9 return FAL SE endif Appendix C APICONFG C 159 ee ERTFS User CTT ER
140. fs port tm gets and rtfs port puts This will allow you to run the ERTFS test environment interactively This makes the process of bringing up a new port much more pleas ant Edit the rest of portkern c to support your RTOS environment See Section 9 for more information One you have a basic build you may now customize ERTFS for your application and target environment Tune your con figuration balancing resource usage with performance See Section 3 for more information on configuring ERTFS Enable support for selected device drivers in PORTCONF H and edit the sections of PORTKERN C and PORTIO C that must be modified to support that device in your environment See Section 17 for a complete explanation Implement your own device drivers if necessary If the ERTFS package does not include a driver for your device type you may be forced to implement your own driver See Section 25 for a complete explanation of how to implement your own device drivers Create populate your own rom disk images for your target application Write your applications code Note Before you use ERTFS you must call the initialization routine pc ertfs init Section 1 Getting Started 5 ERT S User Guide aaa Section 1 Getting Started 6 ERTFS User Guide SECTION 2 THE SOURCE CODE STRUCTURE The ERTFS source code package is comprised of demonstration code core file system code language
141. get attributes byte path byte p return Description Given a file or directory name return the directory entry attributes associated with the entry One or more of the following values will be or ed together BIT Nemonic 0 ARDONLY Returns Returns TRUE if successful otherwise it returns FALSE errno is set to one of the following 0 No error PENOENT Path not found An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt byte attribs if pc_get_attributes A COMMAND COM amp attribs if attribs 8 ARDONLY printf File is Vos ARDONLY if attribs amp AHIDDEN printf File is Vos AHIDDEN if attribs 8 ASYSTEM printf File is Vos ASYSTEM if attribs amp AVOLUME printf File is Vos AVOLUME if attribs amp ADIRENT printf File is Vos ADIRENT if attribs amp ARCHIVE printf File is Vos ARCHIVE Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm pc isdir Test if a path is a directory Summary include lt ertfs h gt BOOLEAN pc isdir byte path Description This is a simple routine that opens a path and checks if it is a directory then closes the path The program cp2pc in the samples directory uses it to test if a destination is a directory The same functionality can be gotten by calling pc gfirst and testing the DSTAT st
142. gical space of the CPU returning that value in virt Two sample methods are provided a flat version where the virtual address is simply the phys address cast to a pointer and a second segmented version for X86 seg mented applications void phys82365 to virtual PFBYTE virt dword phys virt PFBYTE phys example for flat unmapped address space P These routines write and read the 82365 s index and data registers which in a standard PC environment are located in I O space at address 0x3E0 and Ox3E1 Non PC architectures typically map these as memory mapped locations some where high in memory such as 0xB10003E0 and 0xB10003E1 void write_82365_index_register byte value Appendix F PORTIO C 171 a ERTFS User Guide mmm RIES OUTBYTE 0x3e0 value Defined for X86 Replace with your own void write_82365_data_register byte value RTFS_OUTBYTE 0x3e1 value Defined for X86 Replace with your own byte read_82365_data_register void byte v v RTFS INBYTE 0x3e1 Defined for X86 Replace with your own return v endif INCLUDE 82365 PCMCTRL f These routines are only required if INCLUDE IDE is turned on ide drv c byte ide rd status dword register file address byte ide rd sector count dword register file address byte ide rd alt status dword register file address int contiguous io mode byte ide rd error dword register file address byte ide
143. h the necessary ram resources Even though FailSafe will execute properly if no block mapping cache is provided its performance will be significantly diminished It is therefore highly recommended that you enable block mapping FailSafe performance will be reduced drastically if the number of blocks written to the FailSafe file exceeds the number of block map elements Each caching structure requires approxi mately 32 bytes In the examples provided with ERTFS we provide 128 mapping structures To enable block map buffer ing you must assign values to blockmap freelist and blockmap size user journal size This field in the context block may be assigned with a value that prescribes the size of the FailSafe file in blocks If this field is left at zero the FailSafe file will be sized according to the algorithm described in the compile time configuration section blockmap_freelist This field in the context block may be assigned a pointer to an array of structures of type FS BLOCKMAP for example context blockmap freelist amp blockmap arraylol blockmap size This field must be filled in with the number of elements contained in the array assigned to block map freelist Section 30 Failsafe Operating Mode 126 ee i User Guide mmm Returns TRUE Success FALSE Error If it returns FALSE errno will be set to one of the following PEINVALIDPARMS Invalid parameters either no context block was passed or the fields were not initialize
144. hat must be modified by the user to support the target RTOS The required functions are rtfs port alloc signal rtfs port clear signal rtfs port test signal and rtfs port set signal The requirements of each of these functions is defined below This routine takes no arguments and returns an unsigned long The routine must allocate and initialize a signaling de vice typically a counting semaphore and set it to the not signaled state It must return an unsigned long value that will be used as a handle ERTFS will not interpret the value of the return value The handle will only used as an argument to the rtfs_port_clear_signal rtfs_port_test_signal and rtfs_port_set_signal calls Only required for the supplied floppy disk and ide device driver if the ide driver is running in interrupt mode Otherwise leave this function as it is it will not be used dword rtfs_port_alloc_signal void Polled mode has only one global signal Otherwise implement it return 1 This routine takes as an argument a handle that was returned by rtfs port alloc signal It must place the signal in an unsignaled state such that a subsequent call to rtfs port test signal will not return success until rts port set signal has been called This clear function is necessary since it is possible although unlikely that an interrupt service routine could call rtfs port set signal after the intended call to rtfs port test sona
145. he failsafe buffer Summary BOOLEAN failsafe create nv buffer FAILSAFECONTEXT pfscntxt Description This routine must create a failsafe buffer on the current disk or in system NV ram and return TRUE if successful FALSE if it is unsuccessful It may use the nv buffer handle field in the FAILSAFECONTEXT structure at pfscntxt to store a handle for later access The size of the FailSafe file must be at least the following quantity pfscntxt num remap blocks pfscntxt gt num_in dex blocks in 512 byte blocks These values are calculated internally by FailSafe before the context block is passed If the user assigned a file size through the user journal size configuration parameter the quantity pfscntxt 5num remap blocks pfscntxt num index blocks will be equal to the assigned value Section 30 Failsafe Operating Mode 138 ee ERTFS User Guide mmm failsafe reopen nv buffer Function Re open the failsafe buffer Summary BOOLEAN failsafe reopen nv buffer FAILSAFECONTEXT pfscntxt Description This routine must check for the existence of a failsafe buffer on the current disk or in system non volatile RAM and return TRUE if one exists or FALSE if one does not It may use the nv buffer handle field in the structure pointed to by pfscntxt to store a handle for later access by failsafe read nv buffer and failsafe write nv buffer Section 30 Failsafe Operating Mode 139 A 2 ERTFS User Gui
146. he journal file and Section 30 Failsafe Operating Mode 122 ee ERTFS User Guide mmm CFG_NUM_INDEX_BUFFERS controls the amount of ram buffering available for Failsafe operation The constants reside in and may be modified in the file prfs h the default values for these constants are very conservative and they should not require changing under most circumstances CFG_NUM_JOURNAL_BLOCKS This compile time constant determines the number of 512 byte blocks added to failsafe file for journaling directory blocks By default the journal file is made large enough to hold the whole file allocation table plus CFG NUM JOURNAL BLOCKS additional blocks The default value is 128 This is a very small percentage of most disks but it should be adequate for almost any imaginable usage It may be reduced to as little as 1 and FailSafe will still work fine under most conditions The user may override these default settings at run time by providing a non zero value in the journal size field of the FailSafe context block before calling pro failsafe init If the journal file is too small it fills up and API calls fail CFG NUM INDEX BUFFERS This compile time constant determines the number of 512 byte buffers to reserve for buffering FailSafe index pages It must be at least one and it should be set to at least two unless ram resources are very precious The default value is four which should be large enough for almost any application If CFG NUM INDEX BUF FERS
147. ication may call pro failsafe shutdown to disable FailSafe and continue If the appli cation wishes to resume FailSafe operation but the disk is full it may clear the error by using pro failsafe shutdown to disable FailSafe free up some space on the disk with FailSafe mode disabled and then call pro failsafe init to restart failsafe This error is possible for any ERTFS API call that accesses a volume PEFSRESTORENEEDED Autorestore is not enabled and the mount procedure detected that the volume should be restored from the journal file The application may clear this error by calling pro failsafe restore with instructions to either restore the disk or clear the journal file This error is possible for any ERTFS API call that accesses a volume PEFSRESTOREERROR Autorestore and Autorestore are not both enabled and the mount procedure detected that the journal file is invlid The application may query the nature of the error by calling pro failsafe restore with instructions to return status only It may clear the error by calling pro failsafe restore with instructions to clear the journal file This error is possible for any ERTFS API call that accesses a volume PEIOERRORWRITEJOURNAL An error occured writing the journal file while executing automount or writing a FAT or directory block or autocommiting the API call This error is caused by an IO error to the journal possibly due to it being write protected If the application wishes to resume w
148. ield then this call to WARMSTART is for a partitioned device The partition number assigned to the drive must be passed to the driver through this field Other low level code in ERTFS reads this field too so it is important set the field appropriately pdr partition number If the device driver supports removable media that contains several partitions it must return DEVTEST CHANGED the next time DEVCTL CHECKSTATUS is requested for each of the partitions SECTION 29 3 2 STATE FLAGS USED BY THE DEVICE DRIVER Bit flags are used for parameter passing during the WARMSTART call and later for driver state maintenance pdr gt drive flags This field contains bit flags Some of these flags must be set by the user before WARMSTART is called others must be filled in by the device driver These must be set by the user before calling the WARMSTART routine DRIVE FLAGS PARTITIONED The user must set this bit if this is a partitioned device If so then the pdr gt partition_ number field must contain the partition number usually zero ERTFS looks at this bit later on when it mounts the device to determine if it should interpret the first block on the device as a partition table Note When prd partition number is 0 and DRIVE FLAGS PARTITION is true and there is no partition table on the disk but a valid BPB is found on the first block of the device the mount will still succeed This behavior supports certain media such as compact flash that m
149. ilsafe commit FSAPI TEST pro failsafe commit test journal IO error handling FSAPI TEST pro failsafe commit test error handling FSAPI TEST pro failsafe commit test commit process FSAPI TEST pro failsafe commit Success FSAPI TEST pro failsafe restore FSAPI TEST pro failsafe restore test normal restore FSAPI TEST pro failsafe restore test journal data error handling FSAPI TEST pro failsafe restore test clear function FSAPI TEST pro failsafe restore Success FSAPI TEST Success FAILSAFE TEST SUITE Success Section 30 Failsafe Operating Mode 136 ee ERTFS User Guide QQ ur r CUSTOMIZING FAILSAFE In its default configuration failsafe uses a disk file named FAILSAFE in the root directory for its journal file For some applica tions it may be better to store the failsafe journal in flash or non volatile ram All failsafe journal accesses are segregated into four functions that are implemented in prfsnvio c If you wish to use flash or NV ram to store the journal file then these four functions must be modified failsafe create nv buffer Create the failsafe buffer failsafe reopen nv buffer Re open the failsafe buffer failsafe write nv buffer Write a block to the failsafe buffer failsafe read nv buffer Read a block from the failsafe buffer Each of these functions is described below Section 30 Failsafe Operating Mode 137 H ERTFS User Guide Z QQ Qu failsafe create nv buffer Function Create t
150. ine INCLUDE FLASH FTL 1 Include the linear flash driver If INCLUDE FLASH FTL is zero the flash subsystem is not included The FTL layer supports maps logical block addresses to physical block addresses and manages block replacement spare block management and block wear leveling A simple interface to underlying device specific Memory Technology Drivers MTS s is provided MTD s are implemented in drflsmtd c The requirements of MTD s are provided in the next section FLASH MEMORY TECHNOLOGY DRIVERS Introduction The file drflsmtd c contains two Memory Technology drivers One is a driver that implements flash emulation in RAM the other is a driver for Intel 28Fxxx flash parts Other drivers may be implemented by editing three or four routines if drflsmtd c This section describes the required routines and the provided sample implementation for RAM emulation of flash and for Intel flash chips ADDING YOUR OWN FLASH MEMORY TECHNOLOGY DRIVERS To implement a new mtd driver you must implement custom versions of these four functions in this file flash probe must report if flash is present and the total size the erase block size and the address and memory window width of the flash flash eraseblock must initialize one erase block of the flash mtd window must assure that a region of the flash is addressable flash write bytes must program a region of the flash FUNCTIONS THAT MUST BE PROVIDED TO SUPPORT A FLASH DEVIC
151. ing clusters PC FIRST FIT The first chain in which the extension will fit PC BEST FIT The smallest chain in which the extension will fit PC WORST FIT The largest chain in which the extension will fit PC FIXED FIT Extend n clusters from start cluster Please note the following issues and limitations PC FIRST FIT is significantly faster than the others If the current end of file is not on a cluster boundary the region to be tested will start at the cluster immediately following the last cluster in the file and the routine will allocate from the segment that starts with that cluster or it will return the number of contiguous bytes available starting at that cluster If possible you should allocate space in contiguous regions that are a multiple of the drive s cluster size If the PC FIXED FIT option is selected a start cluster must be supplied n bytes must be an even multiple of cluster size and the file to extend must be either zero sized or the end of file must be on a cluster boundary Note If the requested file length exceeds RTFS MAX FILE SIZE po extend file does not extend the file but rather fails and sets errno to PETOOLARGE RIES MAX FILE SIZE defaults to Oxffffffff but may be reduced by chagning the setting in rtfsconf h Returns FALSE if an error occured TRUE if an error did not occur Returns n bytes in new bytes if the file was extended Otherwise it returns the largest contiguous chain of bytes available in
152. int agc byte agv byte buf 10 byte working buffer 100 DDRIVE pdr int driveno dword partition list 3 byte path 10 DEV GEOMETRY geometry Enter the drive to format as A B etc rtfs print prompt user UPROMPT TSTSH3 path pdr 0 driveno pc parse raw drive path if driveno 1 pdr pc drno to drive struct driveno if Ipdr inval Invalid drive selection to format press return rtfs print prompt user UPROMPT TSTSH4 working buffer return 1 if pdr gt drive_flags amp DRIVE FLAGS VALID goto inval OS_CLAIM_LOGDRIVE driveno check media and clear change conditions if Icheck drive number present driveno Format check media failed Press return Section 28 ERTFS Application Programmer s Interface 105 ERTFS User Guide rtfs print prompt user UPROMPT TSTSH5 working buffer goto return error This must be called before calling the later routines if Ipc get media parms path amp geometry Format get media geometry failed Press return rtfs print prompt user UPROMPT TSTSH6 working buffer goto return error Call the low level media format Do not do this if formatting a volume that is the second partition on the drive P Format Press Y to format media rtfs print prompt user UPROMPT TSTSH7 buf if tstsh is yes buf RTFS_PRINT_STRING_1 USTRING_TSTSH_67 PRFLG_NL
153. ion of this routine would read the system tick counter subtract the zero value scale the difference to milliseconds and compare that to timeout If the scaled difference is greater or equal to timeout it should return 1 if less than timeout it should return 0 int rtfs_port_elapsed_check dword zero val int timeout dword curr_time timeout timeout MILLISECONDS_PER_TICK if Itimeout timeout 2 curr_time rtfs_port_get_ticks if curr_time zero_val gt dword timeout return 1 else return 0 F This function must return an unsigned long number that is unique to the currently executing task such that each time this function is called from the same task it returns this same unique number A typical implementation of this function would get address of the current task control block cast it to a long and return it dword rtfs_port_get_taskid void For an RTOS environment return a dword that is unique to this task For example the address of its task control block Otherwise always return 1 For POLLOS return 1 I This routine requires porting if you wish to use the interactive test shell It must provide a line of input from the terminal driver The line must be NULL terminated and it must not contain ending newline or carriage return characters Appendix E PORTKERN C 166 M ERTFS User CTT ER void rtfs port tm gets byte buffer Use Get s or some other cons
154. ion table and all changed files to the disk After this call returns the disk image is synchronized with an ERTFS internal view of the volume Returns Returns TRUE if the disk flush succeeded otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid An ERTFS system error See Appendix J for a description of system errors Example Hinclude lt ertfs h gt if pc_diskflush A printf Flush operation failed In Section 28 ERTFS Application Programmer s Interface 0H ERTFS User Guide mmm po open Open a file Summary include lt ertfs h gt PCFD po_open byte path word flag word mode Description Open the file for access as specified in flag If creating use mode to set the access permissions Flag values are PO APPEND All writes will be appended to the file PO BINARY gnored PO TEXT gnored PO RDONLY Open for read only PO RDWR Read write access allowed PO WRONLY Open for write only PO CREAT Create the file if it does not exist PO EXCL If flag has PO CREAT PO EXCL and the file already exists fail and set fs user p errno to EEXIST PO TRUNC Truncate the file if it already exists PO BUFFERED If this is set reads and writes of less than 512 bytes and operations that do not start or end on block boundaries are buffered The buffer is flushed when po close is called when po flush is called or if a buff
155. ion to Porting ERTFS ERTFS User Guide SECTION 8 PORTING BY BORROWING FROM EXISTING TARGETS The ERTFS install directory contains a subdirectory named targets This directory contains several subdirectories containing sample solutions of the porting layer for several target real time operating systems and microprocessor targets To build ERTFS for a selected target you must use the copies of portkern c portconf h and portio c from the appropriate krn and io subdirectories The simplest way to do this is to copy these files over top of the generic files of the same name in the install directory If you are creating your own port of ERTFS we suggest that you can start with either a reference port that is similar to your own or that you start with the completely generic files provided in the template krn and template io subdirectories The notes in the following sections describe the porting issues for each file Please read them before porting to your environment Section 8 Porting Borrowing From Existing Targets ERT S User Guide aaa Section 8 Porting Borrowing From Existing Targets ERTFS User Guide SECTION 9 PORTING ISSUES FOR THE FILE PORTCONF H See Appendix A for portconf h source code PORTCONF H contains a few simple definitions that are related to porting They must be modified to match your processor architecture KS_LITTLE_ENDIAN KS_RTFS_
156. is too small it has a negative effect on performance CONFIGURING FAILSAFE AT RUN TIME Several features of Failsafe may be configured at run time These include the size of the block replacement cache and the desired restore recover and commit policies The journal file size may also be set at run time to override the compile time defaults Please see the manual page for the function pro failsafe init for specific details on these run time values INITIALIZING FAILSAFE FailSafe mode must be initialized for all drives on which FailSafe will operate The initialization sequence may occur in one of two ways either transparently as part of ERTFS s initialization process or it may be performed explicitly by calling the pro fail safe init API routine The former method is simpler and preferable under most circumstances For details on these two methods please consult the manual pages ADDITIONAL ERRNO HANDLING WHEN USING FAILSAFE When FailSafe mode is enabled for a drive all ERTFS API calls that access that drive use FailSafe services and thus additional API calls errno values are possible for API call failures Six additional errno values are defined when FailSafe is being used PEFSCREATE PEFSRESTORENEEDED PEFSRESTOREERROR PEIOERRORWRITEJOURNAL PEIOERRORREAD JOURNAL and PEJOURNALFULL PEFSCREATE The mount procedure failed in its attempt to create a journal file The disk may be read only or perhaps it is full To clear the error the appl
157. ise FALSE is returned errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEACCES File is read only An ERTFS system error See Appendix J for a description of system errors Example ftinclude ertfs h if po flush fd 0 printf Error flushing file iin p_errno See Also pc dskflush Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm po_read Read from a file Summary include lt ertfs h gt int po_read PCFD fd byte buf int count Description Attempt to read count bytes from the current file pointer of file at fd and place the data in buf The file pointer is updated Returns Returns the actual number of bytes read or 1 on error errno is set to one of the following 0 No error PEBADF Invalid file descriptor PECLOSED Invalid file descriptor because a removal or media failure asynchronously closed the vol ume po close must be called to clear this condition PEIOERRORREAD Read error An ERTFS system error See Appendix J for a description of system errors Example PCFD fd PCFD fd2 fd po open FROM FIL PO RDONLY 0 fd2 po open TO FIL PO CREAT PO WRONLY PS IWRITE if fd gt 0 amp amp fd2 gt 0 while po read fd buff 512 2 512 po write fd2 buff 5
158. ith this media it should either disable FailSafe or clear the cause of the IO error and retry the API call This error is possible for any ERTFS API call that accesses a volume PEIOERRORREADJOURNAL An error occured reading the journal file while executing automount or writing a FAT or directory block or autocommiting the API call This error is caused by an IO error to the journal If the application wishes to resume with this media it should clear the cause of the IO error and retry the API call This error is possible for any ERTFS API call that accesses a volume PEJOURNALFULL An error occured when an ERTFS API call attempted to journal a directory or FAT block but the journal file was full If this error occurs the changes made by all ERTFS API calls since the last succesful FailSafe commit operation are lost The application should not call pro failsafe commmit It should immediately call pro failsafe restore with instructions to clear the journal file If the journal file is full it means that application has modified more FAT and directory blocks then will fit in the journal file This error is most likely the result of misuse of the manual mode of Fail Safe by performing too many API calls without any intervening calls to pro failsafe commit If manual mode FailSafe is being used appropriately or autocommit mode is enabled the only single API calls that could possibly cause this error Section 30 Failsafe Operating Mode 123 ee ERTFS
159. kdsk c apifrmat c apirealt c apideltr c apienum c apifilio c apifilmv c apigetwd c apigfrst c apiinfo c apimkdir c apiregrs c apisetwd c apistat c apiwrite c SOURCE CODE FOR ERTFS PRO USER API CALLS prapipro c SOURCE CODE FOR THE ERTFS CORE FUNCTIONS prblock c rtdevio c rtdrobj c rtlowl c rtutbyte c rtutil c rtregion c rtfat16 c rtfat32 c rtfatxx c rtnvfat c rtvfat c rtkernfn c rttermin c Block buffer pool logic Device access auto mount and media check logic directory object support essential functions parsing code parsing and other utility code Fat region management code Fat management code Fat management code included with ERTFS Pro only Fat management code Long file name support Short file name support included with ERTFS Pro only portable OS resource helper functions portable terminal helper functions SOURCE CODE FOR LOCALIZATION AND MULTIPLE CHARACTER SET SUPPORT csascii c csjis c csjistab c csunicod c csstrtab c csstrtab h ASCII character set specific code Japanese character set specific code included with ERTFS Pro only Japanese character set specific code included with ERTFS Pro only Code to support 16 bit Unicode character sets included with ERTFS Pro only Modifiable string table for localization String table identifiers for localization SOURCE CODE FOR ERTFS FAILSAFE FEATURE prfsapi c prfscore c prfsnvio c prfstest c User API level source code for ERTFS Pro FailSa
160. l timed out A typical implementation of this function for a counting semaphore is to set the count value to zero or to poll it until it returns failure int polled signal 2 0 We only need one signal for polled mode since it is single threaded void rtfs port clear signal dword handle Polled mode has only one global signal Otherwise implement clear of the signal specified by handle polled signal 0 This routine takes as an argument a handle that was returned by rtfs port alloc signal and a timeout value in millisec onds It must block until timeout milliseconds have elapsed or rtfs port set signal has been called If the test succeeds must return 0 if it times out it must return a non zero value Only required for the supplied floppy disk and ide device driver if the ide driver is running in interrupt mode Otherwise leave this function as it is it will not be used int rtfs port test signal dword handle int timeout if IPOLLED MODE Implement timed test of the signal specified by handle here otherwise use the polled mode code provided below return 1 else Appendix E PORTKERN C 164 ee ERTFS User Guide fc vOroovv o vo o ov wv This will work in polled mode dword last_time end_time curr_time Polled mode signal wait with timeout This is portable but the user must implement the routine rtfs port get ticks void and the macro MILLISECONDS PER TI
161. lease see the Porting Section for detailed instructions on this process Returns TRUE if all memory and system resource initialization succeed and ERTFS is usable otherwise FALSE This function does not set errno See Also pc ertfs config Example If pc ertfs init Initialize ERTFS and start the test shell tst shell Section 28 ERTFS Application Programmer s Interface ERTFS User Guide pc ertfs config Do not call this function but modify the source code Summary Description This function is called internally by pc ertfs init Do not call it directly pc ertfs init tells ERTFS what configuration values to use such as buffer size the maximum number of drives maximum number of files and maximum number of users to be supported It is also responsible for passing in the necessary memory and buffer space for the configuration being requested To reconfigure ERTFS please edit this routine in source file apicnfig c Section 3 goes into this in some detail Returns This function does not set errno See Also pc ertfs init Example Section 28 ERTFS Application Programmer s Interface ERTFS User Guide mmm pc free user Release this task s ERTFS user context block Summary include lt ertfs h gt void pc free user Description This routine must be called by all tasks that have used ERTFS before they exit When a task uses the ERTFS API a user context block is automatically c
162. ling po read The maximum allowable value for nblocks is 128 Note It is possible to read any range of blocks in the disk Returns Returns 0 if the read succeeded or 1 on error errno is set to one of the following 0 No error PEINVALIDDRIVEID Driveno is incorrect PEINVALIDPARMS Invalid or inconsistent arguments PEIOERRORREAD The read operation failed An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface 111 ee ERTFS User Guide ZQ QUO pc raw write Write blocks directly to a disk Summary include lt ertfs h gt int pc raw write int driveno byte buf long blockno int nblocks BOOLEAN raw io Description Attempt to write nblocks blocks starting at blockno If raw io is TRUE then blockno is the offset from the beginning of the disk itself If raw io is FALSE then blockno is the offset from the beginning of the partition This routine may be used in conjunction with pc get file extents to find and read blocks without the additional overhead incurred when calling po write The maximum allowable value for nblocks is 128 Note It is possible to write any range of blocks in the disk Returns Returns 0 if the read succeeded or 1 on error errno is set to one of the following 0 No error PEINVALIDDRIVEID Driveno is incorrect PEINVALIDPARMS Invalid or inconsistent arguments PEIOERRORWRITE The read operation failed
163. localization files file system feature set specific files configuration files device drivers and target specific porting files For any files the filename s prefix identifies what type of file it is Demonstration code starts with app code that runs only in a windows demo environment start with win files that contain exported APIs start with api core system files start with rt character set and localization files start with cs drivers start with dr RTFSPRO components start with pr and files that need porting start with port This section contains a description of each of these files PUBLIC HEADER FILES rtfsapi h The ERTFS exported application programmers interface API This header file must be included in all ap plications code that uses the published ERTFS API PRIVATE HEADER FILES rtfs h The ERTFS header file included by all ERTFS source files rtfsconf h Compile time configuration parameters for ERTFS Rtfsconf h controls inclusion of packages such as FAT32 VFAT UNICODE and JIS character sets FAT32 VFAT Unicode and JIS are included with ERTFS Pro only portconf h Compile time configuration parameter for ERTFS Controls device driver inclusion and byte order rtfspro h Defines and structures for RTFSPRO Enhancements DEMONSTRATION SAMPLE CODE AND UTILITY PROGRAMS appdemo c Small entry point that initializes ERTFS and then calls the command shell appcmdsh c Interactive command shell like DOS s command com
164. must be a power of two NUSERFILES 10 The maximum number of open Files at a time LARGE FAT SIZE 32 The number of 520 byte blocks committed for buffering fat blocks on drive C LARGE FAT HASHSIZE 32 The number of 12 byte hash table entries committed for use on drive C This value must be a power of two SMALL FAT SIZE 2 The number of 520 byte blocks committed for buffering fat blocks on drives other than C SMALL FAT HASHSIZE 2 The number of 12 byte hash table entries committed for use on drives other than C This value must be a power of two Note Each drive may have different fat buffer and cache sizes For convenience here we only use two possible different sizes You may tune each drive individually by setting the configuration value prtfs cfg cfg FAT BUFFER SIZE DRIVENUMBER and prtfs cfg cfg FAT CACHE SIZE DRIVENUMBER prtfs_cfg gt fat_buffers DRIVENUMBER prtfs_cfg gt fat_hash_table DRIVENUMBER include lt rtfs h gt define ALLOC_FROM_HEAP 0 Set this to 1 to use malloc to allocate ERTFS memory at startup set to O to use declare memory arrays and provide ertfs with the addresses of those arrays define NDRIVES 10 Number of drives define NUM_USERS 1 Must be one for POLLOS define NBLKBUFFS 4 Number of blocks in the buffer pool Uses 532 bytes per block Impacts performance during directory traversals must be at least 4 define BLKHASHSIZE 16 This value must be a power of two Size o
165. n more about the cause of the error you may call pro failsafe restore with dorestore and doclear both set to FALSE Pro failsafe restore will then return FS STATUS BAD JOURNAL FS STATUS BAD CHECKSUM or FS STATUS OUT OF DATE To clear this condition call pro failsafe restore with doclear set to TRUE Providing a FailSafe context block for pro failsafe restore The ctxt argument is provided so that pro fasilsafe restore may be used even when FailSafe has not been initialized If failsafe has been initialized a zero argument may be passed and pro failsafe restore will use the context block provided by pro failsafe inti Otherwize you must provide the address of a FailSafe context block structure in the ctxt argument pro failsafe restore will fail and return FS STATUS NO INIT if no cointext block is available Checking the status of the FailSafe file If doclear and dorestore are both FALSE then pro failsafe restore will not attempt to restore or to clear the journal file Instead it will return the status of the file returning one of the codes listed below Restoring the volume from the Journal file If doclear is FALSE and dorestore is TRUE and the contents of the journal file indicate that a restore is needed pro fail safe restore will restore the volume from the journal file When the restore process completes the journal file is cleared If the process is interrupted at any time before it completes the contents of the journal file
166. nal file placement NVIO TEST verify journal file placement with fragmentation NVIO TEST verify changing journal file size NVIO TEST test journal file create error with full disk NVIO TEST Success API TEST Begin API TEST API TEST pc mkdir API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST pc rmdir API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST po open API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST pc unlink API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST pc mv API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST pc deltree API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST pc set attributes API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal API TEST po extend file API TEST test journalling API TEST test autocommit API TEST test manual commit API TEST test with full Journal Section 30 Failsafe Operating Mode 135 ee i User Guide mmm API TEST po chsize AP
167. nd dword bus_master_address byte value RTFS_OUTBYTE word bus_master_address value This function must write the byte dword to location 4 of the bus master control region void ide_wr_udma_address dword bus_master_address dword bus_address RIES OUTDWORD word bus master address 4 bus address This function must take a logical pointer and convert it to an unsigned long representation of its address on the system bus unsigned long rtfs port bus address void p dword laddress laddress dword p return laddress endif INCLUDE UDMA endif INCLUDE IDE Appendix F PORTIO C 176 ERTFS User Guide mmm APPENDIX G APPCMDSH C Contains many examples of calling the ERTFS PRO API EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS interactive command shell Note This module contains many examples of calling the ERTFS PRO API include lt rtfsapi h gt DISPATCHER cmds USTRING TSTSHCMD 26 dohelp USTRING TSTSHHELP 26 USTRING TSTSHCMD 01 docat USTRING TSTSHHELP 01 USTRING TSTSHCMD 02 dochsize USTRING TSTSHHELP 02 USTRING TSTSHCMD 03 docwd USTRING TSTSHHELP 03 USTRING TSTSHCMD 12 dochkdsk USTRING TSTSHHELP 12 USTRING TSTSHCMD 13 doclose USTRING TSTSHHELP 13 USTRING TSTSHCMD 14 docopy USTRING TSTSHHELP 14 USTRING TSTSHCMD 15 dorm USTRING TSTSHHELP 15
168. ned more than once PEINVALIDPARMS Invalid or inconsistent arguments An ERTFS system error See Appendix J for a description of system errors Example fd po open DATA FIL PO RDWR 0 if fd gt 0 po truncate fd 1024L Section 28 ERTFS Application Programmer s Interface 101 ee i User Guide mmm pc get media parms Get device geometry for a named device Summary BOOLEAN pc get media parms byte path PDEV GEOMETRY pgeometry Description Query the drive s associated device driver for a description of the installed media This information is used by the pc format media pc partition media and pc format volume routines The application may use the results of this call to calculate how it wishes the media to be partitioned Note The floppy device driver uses a back door to communicate with the format routine through the geometry structure This allows us to not have floppy specific code in the format routine but still use the exact format parameters that DOS uses when it formats a floppy See the following definition of the pgeometry structure typedef struct dev geometry int dev geometry heads Must be 256 int dev geometry cylinders _ Must be lt 1024 int dev geometry secptrack Must be lt 64 dword dev geometry bas For oversized media that supports logical block addressing If this is non zero dev ge ometry cylinders is ignored but dev geometry heads and dev geometr
169. nee 121 Failsafe Resource Requirements iit intraret oce epe etat eae shed tee vce por genu ec stads n s eeu Eae Skab eel ieee 121 Journal Fil Resource Requirements arreter e 121 Failsafe s Effect On CPU And IO Utilization neret ener tnter nm rh pent E Ret o ainda 121 RAM Resource Requirements nnn oane ennneneevenennenenseennnenreneenennneeerenenanneneenveneneeereeenenaneenvenenannenvenveneneeerevenennnennenn 122 Strategies for using Falls af asses deiecit eene enar haee d sh bras Eeee ndan rare dab end enic sR den ERA E an den di den n de 122 Configuring ERTFS To Include Failsafe cu vision 220320 ir da al aanhalen 122 Configuring Failsafe at Compile Time voca iia aaa a dana ege 123 Configuting Failsafe at Run TIM cocida AA A ir precede 123 Initializing FallS e coria A ee de ie eee 123 Additional Errno Handling When Using Failsate u srnensereeuneeeenneersenneneennveevenenrddenneensn tenemen L TT 123 ERTES Pro Failsafe API Functions crore re e a sho ic 125 pro failsate Le BEE 128 AM UL 129 pro failsate restore miss rico sara Led ss NEL c Rue Eu a en 130 pro fallsate SHUtdONIN i shiun iia 132 PS COS C iaa 133 Customizing Fall Ste cist C A A aia 137 failsafe create mv DUNK sce z va duna itet e eeaeee apea E Een bar n eler eeh dh e e ged ec 138 failsafe reopen NV DUE as
170. ng the IDE device driver This function must return the byte in location 7 IDE OFF STATUS of the ide register file at register file address byte ide rd status dword register file address This function must return the byte in location 2 IDE_OFF_SECTOR_COUNT of the ide register file at register file address byte ide rd sector count dword register file address Appendix F PORTIO C 172 return RTFS INBYTE word register file address 7 ee i User Guide mmm return RTFS INBYTE word register file address 2 This function must return the byte in location 0x206 IDE OFF ALT STATUS of the ide register file at register file address The offset in the register file may also be 14 rather then 0x206 if the device is running in contiguous I O mode byte ide_rd_alt_status dword register_file_address return RTFS_INBYTE word register_file_address 0x206 This function must return the byte in location 1 IDE_OFF_ERROR of the ide register file at register file address byte ide_rd_error dword register_file_address return RTFS_INBYTE word register_file_address 1 This function must return the byte in location 3 IDE_OFF_SECTOR_NUMBER of the ide register file at register file address byte ide_rd_sector_number dword register_file_address return RTFS_INBYTE word register_file_address 3 This function must return the byte in location
171. nt if it detects that the journal file was corrupted by an external process In this case the applications layer is alerted that a journal file error is present and the user must call pro failsafe restore from the API layer to clear the journal file and remount the volume Commit policy After a successful commit operation the disk volume is guaranteed to be in sync with the application s view of the disk volume FailSafe may be configured to run in auto commit mode or manual commit mode In auto commit mode ERTFS automatically performs the commit function before it returns from the API and no explicit actions are needed Alterna tively it may be configured to run in manual commit mode In this mode the user must call pro failsafe commit to commit the changes to the volume structure The auto commit method is simpler and guarantees that when ERTFS API calls return the intended changes to the volume structure are committed to disk The manual commit method may be used to improve performance slightly by holding off the commit operation until a group of API call operations has been completed The manual method also provides a way to group multiple API calls into one appar ently atomic operation By this method the user can guarantee that the volume structure contains either none of the changes or all of the changes but it will never contain only some of them If system power is interrupted before the commit function is started then all actions are los
172. ntains a bitwise or one or more of the following MATCH DIR Select directory entries MATCH VOL Select volume labels MATCH FILES Select files MATCH DOT Select entry MATH DIR must be true too MATCH DOTDOT Select entry MATCH DIR must be true too The selection pattern is a standard wildcard pattern such as or txt Note Patterns don t work the same for VFAT and DOS 8 3 If VFAT is enabled the pattern will return any file name that has a in it in 8 3 systems it returns all files Note pc enumerate requires a fair amount of buffer space to function Instead of allocating the space internally we require that the application pass two buffers of size EMAXPATH in to the function See below Note to scan only one level set maxdepth to 1 For all levels set it to 99 Return value Returns 0 unless the callback function returns a non zero value at any point If the callback returns a non zero value the scan terminates immediately and returns the returned value to the application This function does not set errno About the callback The callback function returns an integer and is passed the fully qualified path to the current directory entry and a DSTAT struc ture The callback function must return 0 if it wishes the scan to continue or any other integer value to stop the scan and return the callback s return value to the application layer Example Section 28 ERTFS Application Programmer s Interface
173. o pc_gnext pc_gdone and dols in apptstch c Example See PC_GNEXT Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm pc gnext Return next entry in a directory Summary include lt ertfs h gt BOOLEAN pc gnext DSTAT statobj Description Continue with the directory scan started by a call to pc gfirst Returns Returns TRUE if a match was found otherwise FALSE errno is set to one of the following 0 No error PEINVALIDPARMS statobj argument is not valid PENOENT Not found no match normal termination of scan An ERTFS system error See Appendix J for a description of system errors See Also pc gnext pc gdone and pcls c in the samples directory This function does not set errno Example zinclude lt ertfs h gt if pc_gfirst amp statobj A dev c do print file name extension and size printf 8s 3s 7ld n statobj fname statobj fext statobj fsize while pc_gnext amp statobj Call gdone to free up internal resources pc_gdone amp statobj Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide NGA pc gdone Free directory scan resources originally allocated by pc first Summary include lt ertfs h gt void pc gdone DSTAT statobj Description Given a pointer to a DSTAT structure that was set up by a call to pc gfirst free internal elements used by the statobj Note You MUST call this function af
174. ole input function If you have no console input function then leave it blank gets buffer This routine requires porting if you wish to display messages to your console This routine must print a line of text from the supplied buffer to the console The output routine must not issue a carriage or linefeed command unless the text is terminated with the appropriate control character n or r void rtfs_port_puts byte buffer Use cputs or some other console output function If you have no console output function then leave it blank cputs buffer f This function must exit the RTOS session and return to the user prompt It is only necessary when an RTOS is running in side a shell environment like Windows This function must be implemented if you are using the ERTFS command library in an environment that will ever exit for example if ERTFS is running with an RTOS in a Dos Windows or Unix environment you should put a call to your RTOS s exit code Note Most embedded systems never exit If your application never exits then please skip this section void rtfs port exit void Exit your application here If you never exit then leave it blank l exit 0 When the system needs to date stamp a file it will call this routine to get the current time and date YOU must modify the shipped routine to support your hardware s time and date routines DATESTR pc_getsysdate DATEST
175. ology Drivers 55 Functions that must be provided to support a flash device nnen en cece eee evro ner e eee veper ee tetin tete t eee ee tentene 55 Sample gcc 56 Table of Contents Copyright 2006 EBS Inc 1 ERTFFS User Guide _ X X X X _ Section 27 Adding Your Own Device Drivers oec a dde 57 Section 27 1 The Device block data transfer function anneer eee nennen nemen nennen 57 Section 27 2 The Device l O control MUNCH ON miriam ii 57 Section 27 3 I O Control op code DEVCTL_WARMSTART ann eee eee vene ene eee en nennen nennen cacha ark nere enne nn 57 Section 27 3 1 Passing parameters to the device driver aaa aaa aaa enen even eee vene eee enne enne enne 58 Section 29 3 2 State flags used by the device driver cessisse ciens de tene etn tit hire ea do Eine natn 58 Section 27 4 I O Control op code DEVCTL_CHECKSTATUS sss eh te tereza nnn rn nn sitne renes sinn nnns 59 Section 27 5 I O Control op code DEVCTL REPORT REMOVE eener non LSE NELS EDEN REESE enne 59 Section 29 5 1 Example Card removal event handler ah auuua aaa aaa eee henen eee eee ener nnne tenete nn nnn nnns 59 Section 27 6 UO Control processing for DEVCTL POWER LOSS aaa aaa enen eee eee ene ender eee eee 60 Section 27 7 I O Control op code DEVCTL REPORT RESTORE 22 nanen even 60 Section 27 8 UO Control op code DEVCTL
176. ompletely generic implementations of these files that you may copy and modify portio c Register access functions for external devices This file must be modified if you are porting any of the ERTFS hardware device drivers to a new platform portkern c Kernel and clock services This file must be modified if you are porting ERTFS to a new operating system CPU or target platform See Section 10 Porting Overview portmain c Run time entry point This may need to be modified for your RTOS and development environment It is needed only if you are linking the RTFS demo stand alone If you will link ERTFS to an already running system then you won t need portmain c Instead you need to make sure that you call pc ertfs init first and then begin calling the API If you want to run the test shell from an already running system please call rtfs app entry this routine will initialize ERTFS and then start the test shell interpreter SOURCE CODE FOR USER MODIFIABLE PUBLIC FUNCTIONS apicnfig c User modifiable code that controls resource usage of ERTFS at run time See Section 3 for a thorough discussion of this topic Apiinit c User modifiable code that controls what device drivers ERTFS will control and what drive letters will be assigned to them See Section 6 for a thorough discussion of this topic SOURCE CODE FOR USER API CALLS SEE THE API SECTION Section 2 Source Code Structure 7 RTF User Guide apic
177. ontents 4 ERTFS User Guide SECTION 1 GETTING STARTED WITH ERTFS Start by installing ERTFS on your system The C source code and header files reside in the install directory A subdirectory named targets contains sample porting files that may be used to build ERFTS for several platforms Build ERTFS by following these steps Read through the porting and configuration guide carefully Edit PORTCONF H to set the byte order See Section 9 Edit PORTCONF H making sure all device drivers are disabled except for INCLUDE ROMDISK and INCLUDE RAM DISK Compile all files The only requirement of the compiler is that it pack structures We provide sample Microsoft and GNU make files if you wish to use them A sample MS Visual C project file to build the Windows prototype project is provided in subdirectory rtfsdemo f you choose not to use these make files your requirements are simple compile all of the files and put all of the objects except portmain o into a library If you want to build the ERTFS test shell as a standalone pro gram link portmain o against the library you just created If you wish to just use the API add the library you just created to your project s library list You may if you wish call the test Command shell as a subroutine from your task Be sure to call pc ertfs init before you call the test shell or any other API function If at all possible hook a console device to the routines named rt
178. opriate values in either HCS format head cylinder sector or in LBA linear block address format This information is asked for only when ERTFS is asked to format or partition the device Here is an example implementation case DEVCTL GET GEOMETRY DEV GEOMETRY gc rtts memset amp gc 0 sizeof gc gc dev geometry heads fill in these gc dev geometry cylinders 3 fields with gc dev geometry secptrack the HCN values or leave them blank gc dev geometry Ibas and put the Iba value here copybuff pargs amp gc sizeof gc return 0 An alternate method is available that allows the device driver to return a specific format control structure This method is Used by the floppy disk driver so ERTFS formatted floppies have the identical structure as DOS floppies Please study the source code for the floppy driver if you wish to use this alternate method SECTION 27 9 I O CONTROL OP CODE DEVCTL FORMAT xxx perform device ioctl driveno DEVCTL FORMAT pargs returns 0 if it the low level media is formatted 1 otherwise pargs points to a structure of type DEV GEOMETRY This structure contains the values reported by DEVCTL GET GEOMETRY If the device in question never needs low level formatting this routine should just return 0 for success If the device can be formatted such as formatting a floppy disk then the routine should format the device and return 0 on success or 1 on failure Section 27 Adding Your Own
179. ort ERT S User Guide aaa Section 12 Porting Mutex Semaphore Support ERTFS User Guide SECTION 13 PORTING EVENT SIGNALING SUPPORT A set of signaling functions is required to support interrupt driven device drivers The porting layer provides a set of signal management functions that the user must populate if interrupt driven device drivers are to be used The signals are always al located tested and cleared from the within a task context They are always signaled from the interrupt context Note Currently ERTFS only requires these functions if the floppy disk is used or if the IDE driver is used in interrupt mode rather than polled mode Additional user supplied device drivers may opt to use these calls or they may implement their own native signaling method at the programmer s discretion If you are not using the floppy disk driver or the IDE driver in interrupt mode you may skip this section The signaling code is abstracted into four functions that must be modified by the user to support the target RTOS The required functions are rtfs port alloc signal rtfs port clear signal rtfs port test signal and rtfs port set signal The requirements for each of these functions are provided here Note In a NON RTOS environment the implementation of these functions do not need user modification as long as the routine rtfs port get ticks has been implemented In an RTOS environment thes
180. ort p int nwords while nwords RIES OUTWORD register file address src if INCLUDE UDMA These routines are required only if using an ultra dma controller This function must determine if the specified controller is a PCI bus mastering IDE controller and if so return the location of the control and status region for that controller If it is not a bus bus master controller it should return zero dword rtfs_port_ide_bus_master_address int controller_number return 0 Must be implemented 0 return val disables UDMA This function must read the status byte value at location 2 the bus master control region byte ide_rd_udma_status dword bus_master_address byte value value RTFS_INBYTE word bus_master_address 2 return value This function must write the byte value to location 2 of the bus master control region void ide_wr_udma_status dword bus_master_address byte value RTFS_OUTBYTE word bus_master_address 2 value This function must read the command byte value at location Appendix F PORTIO C 175 ue i User Guide mmm 0 of the bus master control region I byte ide rd udma command dword bus master address byte value value RTFS INBYTE word bus master address return value This function must write the byte value to location O of the bus master control region void ide_wr_udma_comma
181. ost chains are automatically discarded and freed for re use If fix problems is O then write chains has no affect typedef struct chkdisk stats dword n user files dword n hidden files dword n user directories dword n free clusters dword n bad clusters dword n file clusters dword n hidden clusters dword n dir clusters dword n crossed points dword n lost chains dword n lost clusters dword n bad Ifns CHKDISK STATS Total user files found Total hidden files found Total directories found 7 free available clusters clusters marked bad Clusters in non hidden files Clusters in hidden files Clusters in directories Number of crossed chains lost chains lost clusters corrupt disjoint win95 Ifn chains Returns TRUE if there was no ERROR otherwise FALSE errno is set to one of the following pc check disk does not set errno Example CHKDISK STATS chkstat pc check disk A amp chkstat 1 1 0 Check disk be verbose fix problems free lost chains pc check disk A amp chkstat 1 1 1 Check disk run quietly fix problems convert lost chains to files return 0 Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm pc mkdir Create a subdirectory Summary include lt ertfs h gt BOOLEAN pc mkdir byte path Description Create a subdirectory in the
182. outine pc format volume for ex ample usage Section 28 ERTFS Application Programmer s Interface 104 ERTFS User Guide pc format volume Perform a volume format Summary BOOLEAN pc format volume byte path PDEV GEOMETRY pgeometry Description This routine formats the volume referred to by drive letter Drive structure is queried to determine if the device is partitioned or not If the device is partitioned the partition table is read and the volume within the partition is formatted If it is a non parti tioned device the device is formatted according to the supplied pgeometry parameters The pgeometry parameter contains the media size in HCN format See Also pc get media parms pc partition media pc format media Returns Returns TRUE if it was able to perform the operation otherwise it returns FALSE errno is set to one of the following 0 Noerror PEINVALIDDRIVEID Drive component is invalid PEIOERRORREADMBR Partitioned device I O error reading PEINVALIDMBR Partitioned device has no master boot record PEINVALIDMBROFFSET Requested partition has no entry in master boot record PEINVALIDPARMS nconsistent or missing parameters PEIOERRORWRITE Error writing during format An ERTFS system error See Appendix J for a description of system errors Example The following subroutine is included in the test shell program apptstsh c It may be modified for your application Kkkkxk int doformat
183. path specified by path Fails if a file or directory of the same name already exists or if the directory component if there is one of path is not found Returns Returns TRUE if the subdirectory was created otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEINVALIDPATH Path specified badly formed PENOENT Path to new directory not found PEEXIST File or directory of this name already exists An ERTFS system error See Appendix J for a description of system errors Example Hinclude lt ertfs h gt pc mkdir hUSRWLIBAHEADERWSYS Section 28 ERTFS Application Programmer s Interface S i LIGUE User Guide mmm pc mv Rename files and directories Summary include lt ertfs h gt BOOLEAN pc mv char oldpath char newpath Description Moves the file or subdirectory named oldpath to the new name specified in newpath Oldpath and Newpath must be on the same drive but they may be in different directories Both names must be fully qualified see examples Fails if newpath is invalid already exists or oldpath is not found Returns Returns TRUE if the file was renamed otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid or they are not the same PEINVALIDPATH Path specified by old name or new name is badly formed PEACCESS File or directory in use or old name is read only PE
184. perating Mode 128 M U ERTFS User Guide S urUrtr esS pro failsafe commit Function Commit failsafe buffers to disk Summary BOOLEAN pro failsafe commit byte drive name Description This routine commits changed FAT and block buffers to disk When pro failsafe commit completes successfully all changes made to the volume structure since the previous successful call to pro failsafe commit are guaranteed to be committed to disk If pro failsafe commit is interrupted those FAT and directory changes made since the last call to pro failsafe commit may be partially committed to disk This causes inconsis tencies such as lost cluster chains and incorrect file lengths In this case pro failsafe restore may be called to complete the commit process Note If FailSafe is initialized in auto commit mode the commit function is called automatically and it is unnecessary to explicitly call pro failsafe commit pro failsafe commit should be called whenever you wish to guarantee that the disk is up to date Appropriate times to call pro failsafe commit include after a file is closed or flushed after a file is removed or renamed or after directory has been created or removed Typically pro failsafe commit needs to write only a few blocks to disk to complete successfully Returns TRUE Success FALSE Failure If FALSE is returned errno will be set to one of the following PEINVALIDDRIVEID Drive argument invalid PENOINIT pro f
185. r 16 bit volumes there is no benefit to increasing the hash table size or the buffer pool size beyond 256 For 12 bit volumes there is no benefit to increasing the hash table size or the buffer pool size beyond 16 If RAM memory conservation is a high priority in your design note that on all but the slowest media a certain amount of FAT cache swapping is tolerable to human perception and it is possible to assign relatively small FAT buffer pools to drives As little as 1 or 2 blocks of FAT buffering will provide tolerable performance on a fast device FAT block access request patterns are governed mainly by how applications use the file system Applications that access several files at one time and multitasking systems that access the file system from multiple threads will definitely see improved performance with added FAT buffering Applications that sequentially read or write blocks to a single file will not see large overall performance increases but with the ERTFS PRO package by increasing FAT buffer space the user makes it possible to perform file system operations with deterministic behavior FAT buffers consume approximately 520 bytes each Hash table entries consume 12 bytes per entry The hash table size and the number of buffers do not have to be the same A theoretical increase in performance could be achieved by increasing the hash table size up to the size of the actual FAT even if it is greater than the number of buffers Note If the
186. r if he wishes to change the default configuration To simplify the user s task we define some configuration constants in this file that may be modified to change the configuration These constants are only used locally to this file If another method of configuring ERTFS is more appropriate for your environment then devise an alter nate method to initialize the configuration block The default configuration is ALLOC FROM HEAP 1 Use malloc to allocate set to 0 to use declared memory arrays NDRIVES 10 L Max number of drives from 0 to 26 A Z Note A FAT buffer pool must be allocated for each drive If NDRIVES is changed you must add code to allocate or assign more FAT buffer pools The default configuration allocates or assigns 10 fat buffer pools If you increase NDRIVES then add code that duplicates the current code that initializes prtfs_cfg gt fat_buffers 9 to drives 10 11 12 If you decrease NDRIVES then removes the current code that initializes prtfs cfg fat buffers 9 8 7 6 etc If you are not using ALLOC _ FROM HEAP you should also add or remove the memory array declarations NUM USERS 1 Maximum number of USER contexts set to 1 for POLLED mode otherwise set to the num ber of tasks that will simultaneously use ERTFS NBLKBUFFS 10 Number of blocks in the buffer pool Uses 532 bytes per block Impacts performance dur ing directory traversals Must be at least 4 BLKHASHSIZE 16 Size of the block buffer hash table This value
187. r segment is reported Description This routine traverses the file allocation table of the drive It places in the results structure the starting point and size of each free segment The free list information may then be used by po extend file to allocate specific clusters for specific files If the FAT contains more free extents than will fit in plist as indicated by listsize the list is not updated beyond listsize elements but the count is updated and returned so that the list size may be adjusted and the routine may be called again Returns Returns the number of free segments or 1 on error errno is set to one of the following 0 No error PEINVALIDDRIVEID Driveno is incorrect PEINVALIDPARMS Invalid or inconsistent arguments An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface 110 i TES User Guide mmm pc raw read Read raw blocks directly from a disk Summary include lt ertfs h gt int pc_raw_read int driveno byte buf long blockno int nblocks BOOLEAN raw_io Description Attempt to read nblocks blocks starting at blockno If raw_io is TRUE then blockno is the offset from the beginning of the disk itself If raw_io is FALSE then blockno is the offset from the beginning of the partition This routine may be used in conjunction with pc get file extents to find and read blocks without the additional overhead incurred when cal
188. rate They are provided by ERTFS in the file drpcmctl c for the 82365 controller SECTION 21 1 PORTING PCMCIA TO A NON 82365 PCMCIA CONTROLLER Note If you have another type of pcmcia controller you must provide these five functions and possibly the management inter rupt handler we will discuss in this section If you do have an 82365 based controller or you are not using PCMCIA you can skip this section void pcmctrl put cis byte int socket dword offset byte c This function must store the byte c to the location that is offset bytes into the CIS region of the card at slot number 0 or 1 byte pcmctrl get cis byte int socket dword offset This function must read and return the byte stored offset bytes into the CIS region of the card at slot number 0 or 1 void pcmctrl Map ata regs int socket dword ioaddr int interrupt number This function must configure the pcmcia controller such that the IDE driver can access the ATA register in the Compact Flash card It must also map in the PMCIA interrupt line so that it will generate the I O completion interrupt and it must apply VCC power to the card Notes 1 The value ioaddr is the address that was passed into the IDE device driver This value is assigned by the user inside pc ertfs init through the variable pdr register file address This is the range of addresses that the ide register access functions will address see below 2 The value interrupt number is the interrupt number tha
189. rd sector number dword register file address byte ide rd cyl low dword register file address byte ide rd cyl high dword register file address byte ide rd drive head dword register file address byte ide rd drive address dword register file address void ide wr dig out dword register file address byte value void ide wr sector count dword register file address byte value void ide wr sector number dword register file address byte value void ide wr cyl low dword register file address byte value void ide wr cyl high dword register file address byte value void ide wr drive head dword register file address byte value void ide wr command dword register file address byte value void ide wr feature dword register file address byte value unsigned long rtfs port bus address void p void ide insw dword register file address unsigned short p int nwords void ide outsw dword register file address unsigned short p int nwords These routines are only required if INCLUDE IDE and INCLUDE UDMA are turned on dword rtfs port ide bus master address int controller number byte ide rd udma status dword bus master address void ide wr udma status dword bus master address byte value byte ide rd udma command dword bus master address void ide wr udma command dword bus master address byte value void ide wr udma address dword bus master address dword bus address if INCLUDE_IDE These routines are required only if usi
190. real periodic clock tick value here dword rtfs_port_alloc_mutex void POLLED mode does not require mutexes Otherwise implement it return 1 This routine takes as an argument a mutex handle that was returned by rtfs port alloc mutex If the mutex is already claimed it must wait for it to be released and then claim the mutex and return void rtfs_port_claim_mutex dword handle POLLED mode does not require mutexes Otherwise implement it Appendix E PORTKERN C 163 ERTFS User Guide This routine takes as an argument a mutex handle that was returned by rtfs port alloc mutex that was previously claimed by a call to rtfs port claim mutex It must release the handle and cause a caller blocked in rtfs port claim mu tex for that same handle to unblock void rtfs_port_release_mutex dword handle POLLED mode does not require mutexes Otherwise implement it Note Currently ERTFS only requires these functions if the floppy disk device driver is being used or if the IDE device driver is being used in interrupt mode rather than polled mode Additional user supplied device drivers may opt to use these calls or they may implement their own native signaling method at the implementer s discretion If you are not using the floppy disk driver or the IDE driver in interrupt mode please skip this section The signaling code is abstracted into four functions t
191. reated specifically for that task Before the task exits it must release it s context block otherwise ERTFS will run out of context blocks and all new tasks will have to share the same context block Returns Nothing Example void my ftp server task do server session Call the ftp server function here pc free user Free ERTFS resources for this thread exit 0 Terminate the thread Section 28 ERTFS Application Programmer s Interface ee ERTFS USer Guide mmm pc set cwd Set current working directory Summary include lt ertfs h gt BOOLEAN pc set cwd byte path Description Make path the current working directory for this task If path contains a drive component the current working directory is changed for that drive otherwise the current working directory is changed for the default drive Returns Returns TRUE if the current working directory was changed otherwise FALSE errno is set to one of the following 0 No error PEINVALIDPATH Path specified badly formed PENOENT Path not found PEACCESS Nota directory An ERTFS system error See Appendix J for a description of system errors Example include lt ertfs h gt if Ipc set cwd D NUSRWDATAWFINANCE printf Can t change working directory n Section 28 ERTFS Application Programmer s Interface ee i User Guide mmm pc set default drive Set the default drive Summary include lt ertfs h gt BOOLEAN pc set d
192. rely used and their use is not recommended Setting file size limitations and file full policies You may set a limit on the maximum file size and determine the behavior when that limit is reached RTFS MAX FILE SIZE This is the maximum file size in bytes that ERTFS will extend a file to when it is executing po write po chize or po extendfile The default value is Oxffffffff You may change this value to limit file sizes For example to limit the maximum file size to 2 Gigabytes set RTFS MAX FILE SIZE to 0x80000000 If a file reaches this length the operation is either truncated or an error is returned depending on which function is being exectutes and the values of RTFS_ TRUNCATE WRITE TO MAX RIES TRUNCATE WRITE TO MAX If this is set to 1 po write calls are truncated write up to RTFS MAX FILE SIZE bytes If that value is exceeded the write count is truncated and the short write count is returned If this is set to 0 if po write attempts to write beyond RTFS MAX FILE SIZE errno is set to PETOOLARGE and po write returns 1 Regardless of this setting po chsize and po extend file will always fail and set errno to PETOOLARGE if an attempt is made to extend a file beyond RTFS MAX FILE SIZE Section 4 Configuring Compile Time Feature Set Options ERT S User Guide aaa Section 4 Configuring Compile Time Feature Set Options ERTFS User Guide SECTION 5 CONFIGURING A
193. remain valid and the restore process may be restarted when the system is restarted Returns FS STATUS OK Norestore required FS STATUS NO JOURNAL No journal file present FS STATUS BAD JOURNAL Journal present but has invalid fields FS STATUS BAD CHECKSUM Journal data doesn t match stored checksum FS STATUS OUT OF DATE Journal is present but the FAT table has changed perhaps on another computing device since the journal file was last updated FS STATUS IO ERROR 1 O error during restore FS STATUS RESTORED Restore was required and completed FS STATUS MUST RESTORE Disk must be restored from the journal file because flushing of FAT and disk blocks was interrupted FS STATUS NO INIT FailSafe mode is not initialized for this device and the user did not provide an operating context block Section 30 Failsafe Operating Mode 130 ERTFS User Guide Z QQ QQ Example FAILSAFECONTEXT ctx BOOLEAN clear Clear FALSE int s pro_failsafe_restore A amp ctxt FALSE FALSE if s FS STATUS OK printf No restore required else if s FS STATUS RESTORED printf No restore needed else if s FS STATUS NO JOURNAL printf No journal file present else if s FS STATUS BAD JOURNAL clear TRUE printf Journal contains bad data n else if s FS STATUS BAD CHECKSUM clear TRUE printf Journal contains bad data n else if s FS STATUS OUT OF DATE clear TRUE printf Journal out o
194. rtfs cfg cfg NDRIVES NDRIVES prifs cfg cfg NBLKBUFFS NBLKBUFFS prifs cfg gt cfg BLK HASHTBLE SIZE BLKHASHSIZE prtfs_cfg gt c g NUSERFILES NUSERFILES prtfs cfg cfg NDROBJS NDROBJS prtfs cfg cfg NFINODES NFINODES prtfs cfg cfg NUM USERS NUM USERS P Set FAT size configuration values for each drive prtfs cfg cfg FAT BUFFER SIZE 0 SMALL FAT SIZE prtfs_cfg gt cfg_FAT_BUFFER_SIZE 1 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 2 LARGE FAT SIZE prtfs_cfg gt cfg_FAT_BUFFER_SIZE 3 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 4 SMALL FAT SIZE prtfs_cfg gt cfg_FAT_BUFFER_SIZE 5 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 6 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 7 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 8 SMALL FAT SIZE prtfs cfg cfg FAT BUFFER SIZE 9 SMALL FAT SIZE prtfs cfg cfg FAT HASHTBL SIZE 0 SMALL FAT HASHSIZE prifs cfg cfg FAT HASHTBL SIZE 1 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 2 LARGE FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 3 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 4 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE B SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 6 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 7 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 8 SMALL FAT HASHSIZE prtfs cfg cfg FAT HASHTBL SIZE 9 SMALL FAT HASHSIZE Core that must
195. ructure Returns Returns TRUE if path points to a valid existing directory otherwise FALSE errno is set to one of the following 0 No error PENOENT Path not found An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface ee ERTFS User Guide mmm pc isvol Test if a path name is a volume label Summary BOOLEAN pc isvol byte path Description Tests to see if a path specification is a volume label specifier Returns Returns TRUE if it is a volume otherwise FALSE errno is set to one of the following 0 No error PENOENT Path not found An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface i User Guide mmm pc stat Return properties of a named file or directory Summary include lt ertfs h gt int pc stat byte name ERTFS STAT pstat Description This routine searches for the file or directory provided in the first argument If found it fills in the stat structure as described here st dev the entry s drive number st mode S IFMT type offile mask S IFCHR character special unused S IFDIR directory S IFBLK block special unused S IFREG regular a file S IWRITE Write permitted S IREAD Read permitted st rdev the entry s drive number st size file size st atime creation date in DATESTR format st mtime creation date in
196. ry is provided by the user through a user initialized parameter block A helper func tion named pc ertfs config is provided that the user may modify to change from the default configuration The source code resides in apicnfig c See Appendix C to view example source code It initializes the configuration block and provides ERTFS with the addresses of memory that it needs pc ertfs config is called immediately by ERTFS when it enters the initialization routine pc ertfs init This routine was designed to be modifiable by the user to change the default configuration To simplify it we define some configuration constants in this file that may be modified to change the configuration These constants are only used locally to this file The default configuration is ALLOC FROM HEAP Use malloc to allocate set this to 0 to use declared memory arrays instead The default is 1 NDRIVES The default maximum number of drives is set to 10 J the highest possible value is 25 Z The default is 10 Note A FAT buffer pool must be allocated for each drive If NDRIVES is changed you must add code to allocate or assign more FAT buffer pools The default configuration allocates or assigns 10 fat buffer pools If you increase NDRIVES add code that duplicates the current code that initializes the to be changed prtfs cfg fat buffers array to support the added drives If you decrease NDRIVES eliminate the current code that initializes the prtfs cfg
197. s nnen nennen eneen enen eee eee e e eee tee zene re rct 9 Section 4 Configuring compile time feature set options nennen kene eee ene zene etnike eee eee eee eee eee ente eee eee eee 11 Section 5 Configuring at compile time the processor configuration aaaaanaan nanen kene even e evente zene 13 Section 6 Configuring inclusion of device driver support 15 Section 7 Introduction to poring ERT F Ssstt se sh roa en G te Se airada cas 17 Section 8 Porting by borrowing from existing targets sse ener nent reen 19 Section 9 Porting issues for the flle portcontih sacro retenti id do cnet eke Ad had d do dee Bee diana d 21 Section 10 Porting oVelVIgW ona ad 23 Section 11 Porting periodic clock Su PPONES das eene rre ette anika et arret ac e e Rehd anderde Cose E v n m si preh 25 Section 12 Porting mutex semaphore support en san snanseenen cerei tenerent hee tae innate El Cusen Ra Eten e a MER behand 27 Section 13 Porting event signaling SUppoOTt ie s cc Src terrere t Erreur exei tea eH ER e EROR m m r h ae Ene ERES Rae Ere a ees 29 unsigned long rte port alloc signal void niei ciere tenerte ce eee teca eee ce ec heeded Pe ca kd etes ecu e da nea EE 29 vold rt s port clear Signallunsigned long handle eio aaa ia as 29 int rtfs port test signal unsigned long handle int timeout nnee eee eee ee eee eee neren reper t ete zap bekir 29 void rtfs port eet sign
198. s a starting point for other flash device drivers If define USE DISK EMULATOR is also set to 1 the ram will be mirrored to disk Any time a write occurs the disk file will be updated This is only intended for testing purposes in Windows and the disk emulation code is not portable Intel Flash Chip Driver If define USE INTEL FLASH is set to 1 the INTEL flash chip driver is enabled This driver is for Intel several 28FXXX components between 2 and 8 megabytes in size Other components from the series may be added by modifying the routine flash probe to recognize the device and to correctly report its total size erase block size and it s address Two compile time constants must be changed when porting the Intel MTD driver to a new target Two compile time constants tell the device driver the address of the Intel flash part and the width of the address range window through which the part may be read and written The defaults are arbitrarily set to ten million and 64 K respectively define FLASH STARTING ADDRESS 0x10000000 define FLASHWINDOWSIZE 64 1024L These must be changed set FLASH_STARTING_ADDRESS to the base of your flash memory and set FLASHWINDOWSIZE to one of the following If your flash part is fully linearly addressable from FLASH_STARTING_ADDRESS set FLASHWINDOWSIZE to the size of the flash in bytes If it is addressable only through a memory bank that is smaller then the whole part set FLASHWINDOWSIZE to the width of
199. s byte value at location 2 of the bus master control region void ide wr udma status dword bus master address byte value This function must write the byte value to location 2 of the bus master control region byte ide rd udma command dword bus master address This function must read the command byte value at location 0 of the bus master control region void ide wr udma command dword bus master address byte value This function must write the byte value to location 0 of the bus master control region void ide wr udma address dword bus master address dword bus address This function must write the dword to location 4 of the bus master control region unsigned long rtfs port bus address void p This function must take a logical pointer and convert it to an unsigned long representation of its address on the system bus Section 24 Porting IDE Ultra DMA Mode ee ERTFS User CTT ER Section 24 Porting IDE Ultra DMA Mode H O i User Guide mmm SECTION 25 SUPPORTING REMOVABLE TRUE IDE DEVICES This section describes what is required to support hot swapping of removable TRUE IDE devices Hot swapping may be supported if either a card removal interrupt can be generated by the controller or if the controller pro vides a latched mediachange event Three routines related to TRUE IDE hot swapping are provided trueide card changed trueide card installed and trueide report card removed The requirements for each of these ro
200. s means used polled Install DRIVE C As the primary controller master IDE drive first partition if drives_used gt prtfs_cfg gt cfg_NDRIVES goto need_more_drives First IDE as C pdr gt driveno 2 MAPS DRIVE structure to C pdr gt dev_table_drive_io ide io pdr gt dev_table_perform_device_ioctl ide_perform_device_ioctl STORE DEVICE NAME Primary Fixed IDE Master pdr gt register file address dword Ox1f0 Primary I O address N Note Set interrupt number to 1 to use polled mode pdr interrupt number 14 Primary ATA interrupt pdr gt drive flags DRIVE FLAGS PARTITIONED pdr partition number 20 Appendix D APPINIT C 161 O i User Guide mmm pdr gt pcmcia slot number 0 pdr gt controller number 0 pdr gt logical_unit_number 0 pdr Install DRIVE D As the primary controller master IDE drive second partition if drives_used gt prtfs_cfg gt cfg_NDRIVES goto need_more_drives pdr gt driveno 3 MAPS DRIVE structure to D pdr gt dev_table_drive_io ide io pdr gt dev table perform device ioctl ide perform device ioctl STORE DEVICE NAME Primary Fixed IDE Master 2nd Partition pdr gt register file address dword Ox1f0 Primary I O address N Note Set interrupt number to 1 to use polled mode pdr interrupt number 14 Primary ATA interrupt pdr gt drive flags DRIVE FLAGS PARTITIONED pdr partition n
201. scntxt must be zero filled before pro failsafe init is called configuration flags You can optionally enable these features by or ing these values into the configuration flags argu ment FS MODE AUTORESTORE Instruct ERTFS Pro when it mounts a disk to automatically check the status of the Journal file and if the file indicates a restore is needed perform the restore If the restore fails because of an I O error or because of a corrupted journal file then errno is set to PEFSRE STOREERROR and the disk mount fails FS MODE AUTORECOVER FS MODE AUTORECOVER may only be used in conjunction with FS MODE AUTORESTORE In FS MODE AUTORECOVER mode if the auto restore operation fails be cause of an I O error or a corrupted journal file the error is ignored the restore is not executed and the mount process continues FS MODE AUTOCOMMIT If AUTOCOMMIT is enabled the FailSafe commit operation will be performed auto matically by ERTFS at the completion of each API call With AUTOCOMMIT enabled the FailSafe operation is transparent to the user and it is never necessary to call pro failsafe commit Additional Inputs Several fields in the FailSafe context block may be initialized before pro failsafe init is called user journal size may be set under certain special circumstances blockmap freelist and blockmap size should be initialized under most circum stances FailSafe will utilize an optional block map cache if you provide it wit
202. setting this value in the drive structure before the WARMSTART call is made pdr pcmcia cfg opt value This option is only valid for COMPACT FLASH cards It is the user assigned value to be written to the cards configuration option register pdr controller number This is set by the user before calling WARMSTART In most cases this value is unused and should be 0 It may be used to tell the device driver to use another controller For example most PC s today have two ATA controllers with separate I O spaces and interrupts To use the second controller the user must set pdr controller number to 1 before calling WARMSTART This is index of the device on the controller In most cases this value should be O but it may be used to tell the device driver which device to use on the controller For example to mount an ATA slave device you should set pdr logical unit number to 1 pdr logical unit number pdr register file address This is an unsigned long value that the init function may use to pass an l O address to the driver This is shared only between the init function and the device driver The device driver does not have to use it pdr interrupt number This is an integer value that the init function may use to pass an interrupt number to the driver This is shared only between the init function and the device driver The device driver does not have to use it If DRIVE FLAGS PARTITIONED is set by the user in the pdr 2drive flags f
203. size then the list is not updated beyond infolistsize elements but the count is updated and returned so the list size may be adjusted and the routine may be called again Returns Returns the number of extents in the file or 1 on error errno is set to one of the following 0 No error PEINVALIDDRIVEID Driveno is incorrect PEINVALIDPARM Invalid or inconsistent arguments An ERTFS system error See Appendix J for a description of system errors Section 28 ERTFS Application Programmer s Interface 109 ERTFS User Guide pc get free list Get a list free cluster segments on the drive Summary include lt ertfs h gt int pc get free list byte drivename int listsize FREELISTINFO plist long threshhold Where drivename is a valid drive specifier for example C An empty string denotes the current working drive FREELISTINFO is a structure defined as typedef struct freelistinfo CLUSTERTYPE cluster Cluster where the free region starts long nclusters Number of free clusters the free segment FREELISTINFO Listsize is the number of elements in the storage pointed to by plist Threshhold is the smallest contiguous free region to re port This is provided to allow the caller to exclude free chains that are too small to be interesting Setting this to a higher value also reduces the number of entries in plist that will be used up The value of threshold must be at least 1 If it is one then every free cluste
204. t If it is interrupted while the commit function is executing when the system is restarted the restore function will complete the commit process and the volume will then reflect all changes made by all of the API calls Recovery policy There are several error conditions that FailSafe restore checks for before restoring the volume from the FailSafe file If FailSafe restore detects that the file s internal checksum value is incorrect or that the volume s freespace has changed since the previous commit was made it assumes that the FailSafe file and the volume structure are out of sync and it does not perform the restore If this condition occurs while auto restore is enabled the default policy is to abort the mount and set errno to reflect that this error has occurred The application must then call pro failsafe restore to clear the error condi tion and remount the volume This process serves to alert the application later that the volume contains a corrupt or out of synch FailSafe file If this alert is not required FailSafe may be configured in so called to auto recover mode which automati cally clears the FailSafe file if one of these conditions is detected CONFIGURING ERTFS TO INCLUDE FAILSAFE To use FailSafe mode the constant INCLUDE FAILSAFE CODE must be set to 1 in rtfsconf h and all of ERTFS must be recompiled CONFIGURING FAILSAFE AT COMPILE TIME Two compile time constants may be modified CFG NUM JOURNAL BLOCKS controls the size of t
205. t for partition values Press return rtfs print prompt user UPROMPT TSTSH13 working buffer goto return error if Ipc partition media path amp geometry amp partition list 0 Format Media partition failed Press return rtfs print prompt user UPROMPT TSTSH16 working buffer goto return error Put the DOS format Format Press Y to format the volume rtfs print prompt user UPROMPT TSTSH17 buf if tstsh is yes buf if Ipc format volume path amp geometry Format Format volume failed Press return rtfs print prompt user UPROMPT TSTSH18 working buffer goto return error OS RELEASE LOGDRIVE driveno return 0 return error OS RELEASE LOGDRIVE driveno return 1 int doformat int agc byte agv byte buf 10 working buffer 100 byte path 10 Section 28 ERTFS Application Programmer s Interface 107 ERTFS User Guide pc cluster size Return a drive s cluster size Summary int pc cluster size byte drive Description This function will return the cluster size of the mounted device named in the argument Returns The cluster size otherwise 0 if the device is not mounted errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive name is invalid See Also po extend file Example Given a byte count calculate by rounding up how many clusters to extend a file by and then extend the file int cluster size
206. t will be used by hook ide interrupt to field I O completion inter rupts This value is assigned by the User inside pc ertfs init through the variable pdr gt interrupt number If this value is set to 1 the user is requesting polled interaction with the device and no system level interrupt handling is required BOOLEAN pcmctrl card installed int pcmcia slot number This routine must return TRUE if a card is installed in the slot FALSE if it is not BOOLEAN pcmctrl card changed int pcmcia socket number This routine must return TRUE if a media change event has occurred on the card Note If the pcmcia controller supports card removal interrupts then this routine is not needed and may simply return FALSE always If card removal interrupts are not supported then this routine must be implemented if hot swapping is needed If this routine is required it must check the pcmcia interface at the logical socket for the presence of a latched media change condition If a change has occurred then it must clear the latched condition and return TRUE Otherwise it must return FALSE If a change is detected the routine also unmaps the card in pcmcia space and shuts down power to the card This is done to assure that the card powers up appropriately when it is reopened Inputs pcmcia slot number 0 1 Returns TRUE a card has been inserted or removed since last called FALSE no card has been inserted or removed since last called byte pd67xx map sr
207. t will occur INNERLOOP The number of times we run the inner loop OUTERLOOP The number of times we run the outer loop SUBDIRDEPTH The depth of the tested subdirectories NSUBDIRS The number of subdirectories to create at each must be less then 26 Each one of these directories will have SUBDIRDEPTH subdirectories below it Other inputs do clean If do clean is TRUE the regression test executes multiple passes and deletes all files and subdi rectories created in each pass If do clean is FALSE the regression test stops after one pass and leaves all files and directories present Returns Returns TRUE if the test succeeded otherwise FALSE If you have console output informational messages will be written to the screen Example main pc ertfs init Don t forget to call the initialization code If Ipc regression test A TRUE Printf Test failed Section 28 ERTFS Application Programmer s Interface 114 ee ERTFS User Guide mmm tst_shell Interactive command Shell Summary tstsh Description This subroutine provides an interactive command shell for controlling ERTFS It provides a handy method for testing and exercising your port of ERTFS and it may be used to maintain the file system on your target system All commands are sum marized in Appendix H Command Shell Reference Guide Note The source code for this routine in apptstsh c contains many examples of calling and using the ERTFS AP
208. t within RIES MAX FILE SIZE If RTFS_TRUNCATE WRITE TO MAX is set to 0 po write requests that attempt to extend the file beyond RIES TRUNCATE WRITE TO MAX Fail and set errno to PETOOLARGE If RTFS TRUNCATE WRITE TO MAX is set to 1 po write requests that attempt to extend the file beyond RTFS MAX FILE SIZE are trun cated to fill the file until its size reaches RTFS MAX FILE SIZE bytes define RIES TRUNCATE WRITE TO MAX 1 When scanning a directory cluster chain fail if more than this many clusters are in the chain Indicates endless loop define MAX_CLUSTERS_PER_DIR 4096 endif __RTFSCONF__ Appendix B RTFSCONF H 151 ee ERTFS User CTT ER Appendix B RTFSCONF H 152 Q ERTFS User Guide mmm APPENDIX C APICNFIG C EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS run time configuration file PC ERTFS CONFIGY Set up the ERTFS configuration block and allocate or assign memory blocks for ERTFS usage The user must modify this code if he wishes to reconfigure ERTFS He must also initialize the ERTFS configuration structure with the addresses of memory blocks to be used by ERTFS Tutorial pc ertfs config void initializes the ERTFS configuration block and provides ERTFS with the addresses of memory that it needs It is called from the ERTFS initialization routine pc ertfs init This routine is designed to be modified by the use
209. ter you have finished calling pc gfirst and pc gnext or a memory leak will occur Returns Nothing pc gdone does not set errno Example See pc gnext Section 28 ERTFS Application Programmer s Interface ERTFS User Guide pc enumerate Recursively process all directory entries that match a pattern Summary int pc enumerate byte from pattern buffer pointer to a scratch buffer of size EMAXPATH byte spath buffer pointer to a scratch buffer of size EMAXPATH byte dpath buffer pointer to a scratch buffer of size EMAXPATH byte root search Root of the search IE CY or CAUSR etc word match flags Selection flags see above byte match pattern Match pattern see above int maxdepth Maximum depth of the traversal PENUMCALLBACK pcallback Description User callback function see below This routine traverses a subdirectory tree and tests each directory entry to see if it matches user supplied selection criteria If it does match the criteria a user supplied callback function is called with the full path name of the directory entry and a pointer to a DSTAT structure that contains detailed information about the directory entry see the manual page for a detailed description of the DSTAT structure Selection criteria Two arguments are used to determine the selection criteria One is a flags word that specifies attributes the other is a pattern that specifies a wild card pattern The flags argument co
210. the current working directory could not be found errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid An ERTFS system error See Appendix J for a description of system errors The failure mode would be due to either the fact that the drive is not mounted or an I O error occurred Example include lt ertfs h gt byte pwd EMAXPATH if pc pwd A pwd printf Working dir is sin pwd else printf Can t find working dir for AAn Section 28 ERTFS Application Programmer s Interface ERTFS USer Guide mmm pc gfirst Return the first entry in a directory Summary include lt ertfs h gt BOOLEAN pc gfirst DSTAT statobj byte pattern Description Given a pattern which contains both a path specifier and a search pattern fill in the structure at statobj with information about the file and set up internal parts of statobj to supply appropriate information for calls to pc gnext Examples of patterns are D USR RELEASE NETWORK C BIN UU MEMO_ Note You must call pc_gdone to free internal resources if pc_gfirst succeeds Returns Returns TRUE if a match was found otherwise FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEINVALIDPATH Path specified badly formed PENOENT Not found no match An ERTFS system error See Appendix J for a description of system errors See Als
211. the signal specified by handle here This simple implementation is for polled mode polled signal 1 Pp This routine takes as an argument a sleeptime value in milliseconds It must not return to the caller until at least sleeptime Appendix E PORTKERN C 165 ERTFS User Guide milliseconds have elapsed In a multitasking environment this call should yield the task cpu void rtfs_port_sleep int sleeptime Implement simple task sleep call here This simple implementation is for polled mode Call the signaling system to timeout This will in effect sleep rtfs port clear signal 0 rtfs port test signal 0 sleeptime This routine takes no arguments and returns an unsigned long The routine must return an unsigned long value that will later be passed to rtfs port elapsed check to test if a given number of milliseconds or more have elapsed A typical implementation of this routine would read the system tick counter and return it as an unsigned long ERTFS makes no as sumptions about the value that is returned dword rtfs_port_elapsed_zero void return rtfs_port_get_ticks This routine takes as arguments an unsigned long value that was returned by a previous call to rtfs_port_elapsed_zero and a timeout value in milliseconds If timeout milliseconds have not elapsed it should return 0 If timeout milliseconds have elapsed it should return 1 A typical implementat
212. the window The routine mtd_MapWindow will be called to seek to the appropriate window each time a region of the flash is accessed Section 26 ERTFS Linear Flash Support 56 ERTFS User Guide mmm SECTION 27 ADDING YOUR OWN DEVICE DRIVERS ERTFS device drivers are attached and initialized at run time To implement one you must provide two function entry points and attach them to the appropriate drive structure at run time Section 6 explains this process in detail This section explains in detail what is required of your device driver In addition to studying this section you should also study existing device driver Source code All driver file names begin with the prefix dr SECTION 27 1 THE DEVICE BLOCK DATA TRANSFER FUNCTION The device driver must provide a device block data transfer subroutine The routine takes four arguments the logical drive number the sector number to read to or from a count of 512 byte blocks to transfer and a boolean flag reading If reading is TRUE this is a read request if FALSE it is a write request BOOLEAN xxx io driveno sector buffer count reading int driveno Drive number dword sector Starting sector number to read or write void buffer Buffer to read to write from word count Number of sectors to transfer BOOLEAN reading True for a read False for a write request Must return TRUE on success FALSE on failure This is the device driver s read write function
213. ther a volume is mounted in FailSafe mode or not Internally the failsafe layer relies on some smart hashing functions and caching to execute quickly imposing effectively zero cost to the API calls The FailSafe commit function does add some additional over Section 30 Failsafe Operating Mode 121 ERTFS User Guide head The Failsafe commit function always writes at least two blocks to the journal file and then a variable number of blocks to the volume The number of additional block writes depends on the number of API calls made prior to the commit call and on their complexity Typically one or two additional block writes are required In rare cases if ERTFS s buffering space is limited or a complex set of operations is performed a variable number of reads of the journal file may be required RAM RESOURCE REQUIREMENTS FailSafe requires the user to provide at run time one FailSafe context structure for each drive using FailSafe and optionally one pool of block mapping buffers per drive using FailSafe The default configuration consumes approximately 4 K but it may be reduced to as low as 1200 bytes The default size of the FailSafe context structure is approximately 3 K A compile time constant may be adjusted to reduce the structure to its minimum size of approximately 1200 bytes The block mapping pool by default consumes approximately 800 bytes but this may be reduced to as little as zero bytes if desired STRATEGIES FOR USI
214. tion 30 Failsafe Operating Mode 133 H U ERTES User Guide mmm The following output is produced by a successful run of fs_test INDEX TEST Begin INDEX TEST Test mapping with cache gt journaled blocks INDEX TEST Filling Journal File in ascending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in descending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in random order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Testing Index Checksum Error INDEX TEST Testing Index Out of Date Error INDEX TEST Testing Journal File Signature Error INDEX TEST Testing Good Journal File INDEX TEST Test mapping with cache lt journaled blocks INDEX TEST Filling Journal File in ascending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in descending order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Filling Journal File in random order INDEX TEST Testing Journal Block Search INDEX TEST Testing Sorted Journal Block List INDEX TEST Testing Index Checksum Error INDEX TEST Testing Index Out of Date Error INDEX TEST Testing Journal File Signature Error INDEX TEST Testing Good Journal File
215. tkern c and portio c are excluded Set this to zero if you will not be using the PCMCIA compact flash interface or the PCMCIA SRAM device driver Set it to 1 if you will use one of these devices Set this to one if you will be using the PCMCIA compact flash interface to the IDE device driver Set it to O if not Note If you enable INCLUDE COMPACT FLASH you must also manually enable INCLUDE PCMCIA and INCLUDE IDE Set this to zero if you will not be using the floppy disk device driver Set it to 1 if you will use the floppy device driver When this constant is set to zero the floppy device driver compiles to nothing and routines required by the floppy disk device driver in portkern c and portio c are excluded Set this to zero if you will not be using the 82365 PCMCIA controller chip driver in drpc mctl c Set it to 1 if you will use the pcmctrl device driver When this constant is set to zero the floppy device driver compiles to nothing and routines required by the device driver in portkern c and portio c are excluded Set this to one if you will be using the ultra dma mode of the IDE device driver If set to one you must implement the following functions rtfs port ide bus master address ide rd udma status ide wr udma status ide rd udma command Ide wr udma command and ide wr udma address The requirements are explained in Section 24 Set to 1 to include the pcmcia static RAM card driver Note INCLUDE PCMCIA must also be enabled
216. to a record in a random access file Appendix H Command Shell 198 ee ERTFS User Guide mmm This command seeks to a record number in a random access file It takes a file handle and a record number as an argument Example See example for the READ command HELP Display all commands Example HELP QUIT Exit the command shell This command exits the command shell and returns to the caller Appendix H Command Shell 199 ee ERTFS User CTT ER Appendix H Command Shell 200 200 ERTFS User Guide Z Qu APPENDIX J ERTFS SYSTEM ERRORS If an error occurs during an ERTFS API call errno will be set to the values specific to that call or it may be set to any one of the following system detected errors Device check system errors PEINVALIDDRIVEID Invalid driver ID requested PEDEVICECHANGED Device is was flushed but has been swapped PEDEVICEFAILURE Device driver reports device not functional PEDEVICEINIT Device not initialized in PEDEVICENOMEDIA No media is installed PEDEVICEUNKNOWNMEDIA Device driver reports unknown media type PEIOERRORREADMBR Error reading the master boot record PEINVALIDMBR No partition signature found in MBR PEINVALIDMBROFFSET Drives partition offset not found in MBR PEIOERRORREADBPB Error reading the bios parameter block PEINVALIDBPB Signature not found in the bios parameter block PEIOERRORREADINFO32 Error reading the FAT32 info block Internal system Errors PEINTERNAL
217. uide for explanation define KS CONSTANT const See porting reference guide for explanation define KS FAR See porting reference guide for explanation Compile time constants to control device inclusion and inclusion of porting layer subroutines define INCLUDE IDE 0 Include the IDE driver define INCLUDE PCMCIA 0 Include the pcmcia driver define INCLUDE PCMCIA SRAM 0 Include pcmcia static ram card define INCLUDE COMPACT FLASH 0 Support compact flash define INCLUDE FLASH FTL 1 Include the linear flash driver define INCLUDE ROMDISK 1 Include the rom disk driver define INCLUDE RAMDISK 1 Include the rom disk driver define INCLUDE FLOPPY 0 Include the floppy disk driver define INCLUDE HOSTDISK 1 Include windows disk simulator define INCLUDE UDMA 0 Include ultra dma support for ide define INCLUDE 82365 PCMCTRL 0 Include 82365 pcmcia controller endif __PORTCONF__ Appendix A PORTCONF H 149 ee ERTFS User CTT ER Appendix A PORTCONF H 150 ERTFS User Guide mmm APPENDIX B RTFSCONF H EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS compile time configuration file ifndef RTFSCONF define RTFSCONF__ 1 Include CPU and peripheral configuration include lt portconf h gt Character set support define INCLUDE CS JIS
218. umber 21 H pdr pcmcia slot number 0 pdr controller number pdr logical unit number pdr endif 0 etc etc End User initialization section print device names pdr prtfs cfg mem drives structures for j 0 j lt prtfs cfg cfg NDRIVES j pdr i if pdr gt dev table drive io prtfs_cfg gt drno_to_dr_map pdr gt driveno pdr MAPS DRIVE structure to DRIVE if pdr 2dev table perform device ioctl pdr 2driveno DEVCTL_WARMSTART PFVOID 0 0 prtfs cfg drno to dr map pdr 2 driveno 0 It is not there N so forget it Autoformatting RAM Devices pdr prtfs_cfg gt mem_drives_structures for j 0 j lt prtfs_cfg gt cfg_NDRIVES j pdr if pdr drive flags8 DRIVE_FLAGS_VALID 88 pdr gt drive_flags amp DRIVE_FLAGS_FORMAT return TRUE auto_format_disk pdr drno_to_string drname pdr gt driveno Appendix D APPINIT C 162 ee ERTFS User Guide QQ urr n APPENDIX E PORTKERN C EBS ERTFS PRO Real Time File Manager Copyright EBS Inc 2003 This is a representative sample of the ERTFS RTOS porting layer file f portkern c If you are using POLLED mode then this file is actually quite portable Several reference ports are provided for x86 envi ronments To port it to a non supported environment you must provide the following functions and macros unsigned long rtfs port get ticks define MILLISECONDS P
219. ummary include lt ertfs h gt BOOLEAN pc deltree byte directory Description Delete the directory specified in name all subdirectories of that directory and all files contained therein Fail if name is not a directory is read only or is currently in use Note If a portion of the tree being deleted is in use either with an open file or directory traversal then the deltree algorithm will abort leaving the tree partially removed Returns Returns TRUE if the directory was successfully removed errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive name is invalid PEINVALIDPATH Path specified by name is badly formed PENOENT Can tfind path specified by name PEACCES Directory or one of its subdirectories is read only or in use An ERTFS system error See Appendix J for a description of System Errors Section 28 ERTFS Application Programmer s Interface ERTFS User Guide mmm pc set attributes Set File Attributes Summary include lt ertfs h gt BOOLEAN pc set attributes byte path byte attributes Description Given a file or directory name set the directory entry attributes associated with the entry One or more of the following values may be or ed together BIT Nemonic 0 ARDONLY Returns Returns TRUE if successful otherwise FALSE errno is set to one of the following 0 No error PEINVALIDPARMS Attribute argument is invalid PEINVALIDDRIVEID Drive
220. utines is provided in this section BOOLEAN trueide card changed DDRIVE pdr Modify this routine to support removable TRUEIDE devices This routine may be used to provide support for hot swapping of removable TRUEIDE devices in cases where a removal inter rupt source is not available The TRUEIDE circuit must provide a latch that detects a card removal This routine must report the value of the latch TRUE if the media has changed FALSE if it has not It must clear the latch before it returns By default trueide card changed returns FALSE emulating a fixed disk or a removable disk with no media changed latch Note The DRIVE FLAGS REMOVABLE flag must be set in apiinit c for removable media To do this OR in DRIVE FLAGS REMOVABLE to the drive flags field pdr gt drive flags DRIVE FLAGS REMOVABLE Example BOOLEAN trueide card changed DDRIVE pdr i if read ide change latch 1 clear_ide_change_latchQ return TRUE else return FALSE 3 BOOLEAN trueide_card_installed DDRIVE pdr Modify this routine to support removable trueide devices trueide_card_installed must return TRUE if IDE compatible media is installed FALSE if it is not By default trueide_card_installed returns TRUE emulating a fixed disk Note The DRIVE FLAGS REMOVABLE flag must be set in apiinit c for removable media To do this OR in DRIVE FLAGS REMOVABLE to the drive flags field pdr gt drive flags DRIVE FLAGS REMOV
221. void ide wr command dword register file address byte value RTFS_OUTBYTE word register_file_address 7 value This function must place the byte in value at location 1 IDE OFF FEATURE of the ide register file at register file address void ide_wr_feature dword register_file_address byte value Appendix F PORTIO C 174 ERTFS User Guide mmm This function must read nwords 16 bit values from the data register at offset 0 of the ide register file and place them in successive memory locations starting at p Since large blocks of data are transferred from the drive in this way this routine should be optimized On x86 based systems the repinsw instruction should be used on non x86 platforms the loop should be as tight as possible RTFS_OUTBYTE word register_file_address 1 value void ide insw dword register file address unsigned short p int nwords while nwords p word RTFS_INWORD register_file_address J This function must write nwords 16 bit values to the data register at offset 0 of the ide register file The data is taken from successive memory locations starting at p Since large blocks of data are transferred from the drive in this way this routine should be optimized On x86 based systems the repoutsw instruction should be used on non x86 platforms the loop should be as tight as possible void ide_outsw dword register file address unsigned sh
222. w do the dir fcount pc seedir ppath And print the bytes remaining nfree pc free ppath amp blocks total amp blocks free printf 6d File s 8ld KBytes free fcount blocks free 2 RTFS PRINT STRING 1 USTRING TSTSH 30 0 RTFS PRINT LONG 1 dword fcount 0 RTFS PRINT STRING 1 USTRING TSTSH 31 0 File s RTFS PRINT LONG 1 dword blocks free 2 0 RTFS PRINT STRING 1 USTRING TSTSH 32 PRFLG NL Blocks Free return 1 List directory and return number of matching file int pc seedir byte path P MM int fcount 0 DSTAT statobj byte display buffer 100 Get the first match if pc gfirst amp statobj path while TRUE fcount Appendix G APPCMDSH C 184 ee i User Guide mmm rtfs print format dir display buffer amp statobj Get the next if Ipc gnext amp statobj break Call gdone to free up internal resources used by statobj pc gdone amp statobj return fcount int doregress int agc byte agv if agc 1 pc_regression_test agv return 1 else RTFS PRINT STRING 1 USTRING TSTSH 110 PRFLG NL Usage REGRESSTEST D return 0 P CAT PATH int docat int agc byte agv fn PCFD fd int nread if agc 1 if fd po open agv word PO_BINARY PO_RDONLY word PS IWRITE PS IREAD lt 0 RIES PRINT STRING 2 USTRIN
223. x J System Errors 202
224. y secptrack must still be valid BOOLEAN fmt parms valid If the device I O control call sets this TRUE then it tells the applications layer that these format parameters should be used This is a way to format floppy disks exactly as they are formatted by dos FMTPARMS fmt DEV_GEOMETRY typedef struct dev geometry KS FAR PDEV_GEOMETRY Returns Returns TRUE if it was able to get the parameters otherwise it returns FALSE errno is set to one of the following 0 No error PEINVALIDDRIVEID Drive component is invalid PEDEVICEFAILURE Device driver get device geometry request failed PEINVALIDPARMS Device driver returned bad values See Also pc format media pc partition media pc format volume Example Note This routine is designed to work in a specific context See the documentation for routine pc format volume for ex ample usage Section 28 ERTFS Application Programmer s Interface 102 HS ERTFS User Guide ZQ 0o pc partition media Partition a disk Summary BOOLEAN pc partition media byte path PDEV_GEOMETRY pgeometry PFWORD partition list Description Writes a partition table onto the disk at path pgeometry contains the values returned by pc get media parms partition _ list must be provided by the user It is a null terminated list of partition sizes If pgeometry dev geometry Ibas is non zero the partition sizes must be entered in units of logical blocks If pgeometry
225. ystem Note For all ide register access functions register file address is the value that was provided by the user in pc ertfs init in the variable pdr register file address REGISTER ACCESS FUNCTIONS REQUIRED BY THE IDE DRIVER byte ide rd status dword register file address This function must return the byte in location 7 IDE OFF STATUS of the ide register file Note For all ide register access functions register file address is the value that was provided by the user in pc ertfs init in the variable pdr register file address word ide rd data dword register file address This function must return the word in location 0 IDE OFF DATA of the ide register file at register file address byte ide rd sector count dword register file address This function must return the byte in location 2 IDE OFF SECTOR COUNT of the ide register file byte ide rd alt status dword register file address int contiguous io mode This function must return the byte in location 0x206 IDE OFF ALT STATUS of the ide register file at register file address If the value of the argument contiguous io mode is 1 then the register must be 14 rather than 0x206 byte ide rd error dword register file address This function must return the byte in location 1 IDE OFF ERROR of the ide register file byte ide rd sector number dword register file address This function must return the byte in location 3 IDE OFF SECTOR NUMBER of the ide register file byte
Download Pdf Manuals
Related Search
Manual manual manualslib manual car manual timesheet manual transmission manuale digitale manually meaning manual wheelchair manual arts high school manually update your device drivers windows manual labor manual definition manual for courts martial manual muscle testing manual muscle testing grades manually register devices with autopilot manual keyboard manual blood pressure cuff manualidades manual lawn mower manual transfer switch manual transmission cars for sale manual therapy cpt code manual libs manual autopilot enrollment
Related Contents
Mode d`emploi Station intérieure vidéo ALDUP NetVision XS/XC 2.2 User's Guide Philips FW-D550 User's Manual Copyright © All rights reserved.
Failed to retrieve file