Home

Generalplus Confidential For 立 奕 企 業 股 份 有 限 公 司 Use Only

image

Contents

1. G Generalplus GPL32XXX File System Library User Manual V1 0 Jul 16 2009 3F No 8 Dusing RD Hsinchu Science Park Hsinchu City 30078 Taiwan R O G Tel 886 3 666 2118 Fax 886 3 666 2117 ai www generalplus com G Generalplus GPL32XXX File System Library User s Manual Important Notice Generalplus Technology reserves the right to change this documentation without prior notice Information provided by Generalplus Technology is believed to be accurate and reliable However Generalplus Technology makes no warranty for any errors which may appear in this document Contact Generalplus Technology to obtain the latest version of device specifications before placing your order No responsibility is assumed by Generalplus Technology for any infringement of patent or other rights of third parties which may result from its use In addition Generalplus products are not authorized for use as critical components in life support devices systems or aviation devices systems where a malfunction or failure of the product may reasonably be expected to result in significant injury to the user without the express written approval of Generalplus ET Generalplus Technology Inc PAGE 2 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual Table of Content E ep GPL32XXX FILE SYSTEM LIBRARY USER MANUAL sees es sesse se se ee ee sees es se se ee ee ee ee es se se ee ee ee
2. 6 12 TT 21 6 13 FS URE EE OO ME UE 22 6 14 ES UNNE saved 23 TE O Generalplus Technology Inc PAGE 3 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 6 15 JGETFSERRCODE RE OR EE N HER 23 6 16 CESFSERRCODE Ghia 24 6 17 FINDEIRST RE EE RE EE RE EE RE EE ER EE conne 24 6 18 dIE di RE RE ER EE ER EE 26 6 19 de EE EE N ER RE N EE FE 26 6 20 Eie iN EE MA MT OE EE OE RE EA NE 27 6 21 DELETEA EL EE EO RE EE EE RE EE OR AG 28 6 22 aa 9 ales OE EE EE ER EE OE EO FFF NHU HR 29 6 23 SIDEVICEUNMOUNT RE OR EE al 29 6 24 Er eis RR EE RE EE EE VEERA so N 30 7 PROGRAM EXAMPLE ccsssccssssssscscssencedeesseccssssestcncscsvecsestenredeonsvasscsseneeseodeagsacBscele y eer deesdae fe oos see see 31 8 SPECIAL AAA Ye A SE AA 33 S L USERGETIDATE AAA A AA A A A 33 82 USERGETTIME AE RE KEER ii AR A ds 33 8 3 MAXIMUM OPEN FILE NUMBER see oe ese de nono nono ong ge ron rr once none rr nono ron rr Ge oe ee Ge ee 34 8 4 IMPLIED OPEN OPERATIONS esse ee ese ee se Mef ee ee ee se AA DR ee ee ee ee Ge ee ee RA cnn RR RA cnn ee RA cren RA ee 34 8 5 COPY OPERATION PERFORMANCE ef De esse eee Mees Me ee es se nr see ee se rn Gee cnn nr rn nn ee on cn ee rn corners 35 8 6 MAXIMUM PATHNAME STRING LENGTH ee sk ee se de ee Wee ese ee se ee ee ee se ee ee ee ee ee ee ee ee de ee ee Yn ee ee Ge ee ee 35 Generalplus Technology Inc PAGE 4 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library Use
3. make a high performance when user is trying to duplicate a file by _ copy We strongly suggest the user to write a new copy function instead of the _copy in your application 8 6 Maximum Pathname String Length The maximum pathname string length is 255 bytes includes the drive letter and the character and the backslashes but not includes the terminal zero character O Generalplus Technology Inc PAGE 35 V1 0 JUL 16 2009
4. Inc PAGE 25 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual while _findnext amp finfo 0 6 18 _findnext API Name _ findnext Function Find next appointed name and attribute s file Description C v s h Header File ASM C int _findnext struct f info f info Syntax ASM c ffblk Parameters File information struct ASM None This function returns O on successful completion and 1 on error Error code list ENOENT No more file fit the specified file name pattern and the file attribute Return Values nt condition ElO For many devices and for disk files this error code indicates a hardware error Remarks Example See gt findfirst example 6 19 _copy API Name _ copy Function The function can be used to make a copy for a file Description C v s h Header File ASM C int copy LPSTR srcfile LPSTR destfile Syntax ASM srcfile c It is a source path of file and file name Parameters destfile It is a destination path of file and file name ASM None Return Values This function returns O on successful completion and 1 on error Generalplus Technology Inc PAGE 26 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual Error code list ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist Or the file named by filename doesn t exist EEXIST A file name
5. RAM Size IRAM ISRAM RAM SRAM ORAM OSRAM File system 0 0 2194 0 0 0 42 ROM Size TEXT efesla DATA File system 0 40916 0 4 3 Peripheral Timer TimeBase IRO FIG Others Filesystem Av 4 4 Other A I a NE EE e OWwN c O Generalplus Technology Inc PAGE 10 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 5 Project Architecture 5 1 C Architecture System asm Resource 5 2 ASM Architecture O Generalplus Technology Inc PAGE 11 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 6 Application Interface 6 1 open API Name open Function Open the specified file with the specified mode Description C v s h Header File ASM C int open LPSTR pathname int flags Syntax ASM pathname pointer to a path name string flags open flag O_OPEN Open a exists file O_TRUNC Open the file and truncate the file to zero length O_CREAT If set the file will be created if it doesn t already exist C O RDONLY Open the file for read access Parameters O WRONLY Open the file for write access O_RDWR Open the file for both reading and writing O_EXCL If set the open operation will fail when trying to create an existent file The normal return value from open is a non negative integer file descriptor In the case of an error a value of 1 is returned instead NOTE Return value is a file node
6. disk files this error code indicates a hardware error delect a temporary directory if rmdir a temp 1 printf rmdir failed n API Name chdir This function is used to set the process s working directory to filename Remarks Example 6 8 chdir Function Description C Header File ASM C Syntax ASM C Parameters ASM Return Values vfs h int chdir LPSTR pathname pathname pointer to a string specify the directory name will be deleted None The normal successful return value from chdir is O A value of 1 is returned to indicate an error Error code list ENOENT ENOTDIR EIO ENFILE This error is reported when a file referenced as a directory component in the file name doesn t exist A file that is referenced as a directory component in the file name exists but it isn t a directory For many devices and for disk files this error code indicates a hardware error The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions O Generalplus Technology Inc PAGE 18 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual Remarks change current directory if chdir a temp 1 return value 1 means error occurred printf change current directory failed n Example else printf change current directory successfulln 6 9 ge
7. index Maybe zero Error Code List EACCES The file exists but is not readable writable as requested by the flags argument the file does not exist and the directory is unwritable so it cannot be created EEXIST Both O_CREAT and O_EXCL are set and the named file already exists EISDIR The flags argument specified write access and the file is a Return Values f directory ENFILE The entire system or perhaps the file system which contains the directory cannot support any additional open files at the moment ENOENT The named file does not exist and O_CREAT is not specified ENAMETOOLONG Filename specified too long EIO For many devices and for disk files this error code indicates a hardware error ENAMEINVALID Invalid character detected in the filename string ENOSPC No free directory entry left in root directory on a FAT16 or Generalplus Technology Inc PAGE 12 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual FAT12 file system or the file system doesn t have enough room to extend the directory Remarks include lt stdio h gt include lt string h gt include vfs h void main void int fp err char string Hello worldin open with create options Example if fp open A test txt O CREAT O_EXCL 1 printf The file test txt was not created n else printf The file test txt was created n write string to file write fp string
8. 009 G Generalplus GPL32XXX File System Library User s Manual error code process close fd fd open LPSTR a test bin O RDONLY if fd lt 0 ret _ getfserrcode error code process Iseek fd 512 SEEK_SET for i 0 i lt 5 i len read fd UINT32 buffer lt lt 1 1024 2 if len 1 ret _ getfserrcode error code process close fd Generalplus Technology Inc PAGE 32 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 8 Special Note We need some functions for getting system time We list the spec here 8 1 UserGetDate Function Interface void UserGetdate struct dosdate dd Structure Description struct dosdate unsigned short year unsigned char monthday month Function Definition Demo void UserGetDate struct dosdate dd function body should be adapted by user dd gt year 2004 dd gt month 8 dd gt monthday 23 8 2 UserGetTime Function Interface void UserGetTime struct dostime dt Structure Description struct dostime unsigned char minute hour hundredth second Function Definition Demo void UserGetTime struct dostime dt function body should be adapted by user at hour l dt gt minute 54 Gle Ssecomel 37 dt gt hundredth 0 Generalplus Technology Inc PAGE 33 V1 0 JUL 16 2009 G Generalplus GPL32XXX File S
9. Get information about the space of the specified device Description C v s h Header File ASM C int _ getdiskfree short driver struct _ diskfree_t dfreep Syntax ASM driver Specify the device zero based index dfreep The siruct of device information struct _ diskfree_t C Parameters unsigned long total_clusters unsigned long avail_clusters unsigned long sectors_per_cluster unsigned long bytes_per_sector AsM None This function returns 0 on successful completion and 1 on error Return Values Error code list EINVAL Parameter list value error Remarks struct diskfree t space info _ getdiskfree 0 amp space info get space informations about device a Example printf Free clusters 96d space info avail clusters O Generalplus Technology Inc PAGE 30 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 7 Program Example include vfs h int main inti int ret fd long len unsigned int buffer 1024 System_Initial fs_init for i 0 i lt 3 i ret devicemount i can not mount this disk ChangeCodePage UNI_GBK fd open LPSTR aMtest bin O RDWRJO_CREAT if fd lt 0 ret _ getfserrcode error code process for i 0 i lt 10 i len write fd UINT32 buffer lt lt 1 1024 2 if len 1 ret _ getfserrcode Generalplus Technology Inc PAGE 31 V1 0 JUL 16 2
10. at a mounted device Remarks fs_init if format 0 FAT16_Type make a FAT16 file system on the SD card while 1 Example mount for other operations after _format _devicemount 0 6 21 _ deleteall API Name _ deleteall Function Delete all files and folders in the specified directory Description C v s h Header File ASM C int _deleteall LPSTR pathname Syntax ASM c pathname Parameters To appoint path ASM None This function returns O on successful completion and 1 on error Error code list ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist Or the file named by filename doesn t exist EACCES Write permission is denied for the directory from which the file is to Return Values i be removed The deleteall process will terminated after such an accident EIO Low level VO error ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Remarks _ deleteall can be used to empty a directory Example empty a temporary directory int res Example res _ deleteall a temp if res Generalplus Technology Inc PAGE 28 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 6 22 _devicemount API Name _ devicemount Mount a disk load the information about the device and the file syst
11. d filename already exists Remarks EMLINK The parent directory has too many links entries ENOSPC The file system doesn t have enough room to create the new directory ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions intbackup_a_c void int res res _copy a a c a backup a c Example if res return 0 else printf file backup error return 1 6 20 format API Name _ format Function Create a file system with the specified driver Description C v s h Header File ASM C int format unsigned char drv unsigned char fstype Syntax ASM drv Zero based driver set index For example index for SD card is O c fstype Parameters Specify the file system Should be one of these values FAT16_Type Format the disk with FAT16 storage format FAT32_Type Format the disk with FAT32 storage format ASM None This function returns 0 on successful completion and 1 on error Return Values Error code list EIO For many devices and for disk files this error code indicates a Generalplus Technology Inc PAGE 27 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual hardware error EINVAL A argument list error detected May be the drv value is larger than NBLKDEV or the fstype is greater than FAT32 Type EBUSY The target device is a mounted device Can not form
12. ee se Ge Ge ee ee ee Ge 1 1 INTRODUCTION ecsccisesesdcccsstescecscesiccceststeacasusciocesesstesscveccacssescsscscvecconsesaveasostedesossssdsouseeesessbessdbanscsceousssesesees 6 1 1 GENERAL DESCRIPTION ee esse ee ee ee ee ee ee ee ee LL LL ee ee ee GLGC CG GIG GIRL 6 2 FUNCTION LIST RE OE A 7 3 GLOBAL VARIABLE LIST sesevoreevsessnevnvevnevsesssensenneeneenssnnnnenenenensernennnevnestnesel s PMnerVaennnnnvnnnevnerener 000 9 4 RESOURCE LIST AAA A e A 0 PAPA 10 AA RAM SIZE ER EE EE EO si OO DOD 10 42 ROM SIE er ee ese se ee Se a fh AN ie its 10 4 3 PERIPHERAL ee esse sees ee ee esse esse sees ee ee ee ee ee ee ee ee ee ee ee ee MB AN Nee TT cnc ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee 10 AA OTHER ME EK N O A VARK N N AE N 10 5 PROJECT ARCHITECTURE csississcsscesags tt sesse osse gese Moi Mocssasisscesasssosecvcssesacsvincsssevssscesecsessssscseases 11 5 1 CARCHITECTURE AR Deere D ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee 11 5 2 ASMAREBHITEGTURE aa WIE A dia ed Ee ie ee 11 6 APPLICATION INTERFACE ee AED Ee see ee ee esse esse oe se ee ese ea Ge 95 ee GR Ge Gee Re GR Ge de ee Ge Ge Ee ee ee 12 6 1 ASE VEE AO EE EE EE EE EE EI 12 O 2 CLOSE GP NERA ne EE AE das 13 0 3 READ mn LA ARE EE EE IE EN 14 64 WRITE AT 14 O TSB aa 7 sn eee nad 15 66 MR ads 16 Or TUR ee 17 OG POOR innviede OO RR EE addaa 18 QE GET CWI ee 19 6 10 UNN NN 19 6 11 INIA 20
13. em information Function on the device Description C v s h Header File ASM C int_devicemount unsigned char diskid Syntax ASM diskid To appoint mounted disked Access mode c DEVICE_WRITE_ALLOW write permission bit will be masked Parameters DEVICE_READ_ALLOW read permission bit will be masked Note accessmod can be a bitwise OR result of DEVICE_WRITE_ALLOW and DEVICE READ ALLOW ASM None This function returns 0 on successful completion and 1 on error Error code list Return Values EINVAL Parameter list value error EBUSY The device specified by diskid is busy ElO Low level VO error Remarks fs_init if devicemount 0 Example while 1 6 23 _ deviceunmount API Name _ deviceunmount Function Umount the specified device flush all cached data associates to the device Description C v s h Header File ASM C int_deviceunmount unsigned char diskID Syntax ASM diskID Parameters To appoint mounted disked O Generalplus Technology Inc PAGE 29 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual ASM None This function returns 0 on successful completion and 1 on error Error code list Return Values EINVAL Parameter list value error EBUSY The device specified by diskid is busy Remarks fs_init _devicemount 0 0 DEVICE_READ_ALLOW DEVICE_WRITE_ALLOW Example _deviceunmount 0 6 24 _getdiskfree API Name _ getdiskfree Function
14. es res stat file1 txt amp statbuf if res return 1 Example time1 statbuf st mtime res stat file2 txt amp statbuf if res return 1 if time1 gt statbuf st_mtime printf file1 txt is more recent else printf file2 txt is more recent 6 13 fs init API Name fs_init Function Initialize file system Description C v s h Header File ASM C void fs_init void Syntax ASM C None Parameters ASM None Return Values None All the global variables of file system will be forced into the initial values Typically this Remarks function should be used only once at the initialization part of your program fs init _devicemount 0 fp open Hello txt O CREAT O_RDWR write fp 0 14 close fp Example _deviceunmount 0 Generalplus Technology Inc PAGE 22 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 6 14 fs_uninit API Name fs_uninit Function uninitialize file system Description C v s h Header File ASM C void fs uninit void Syntax ASM C None Parameters ASM None Return Values None Remarks Uninitialize the file system to release all resources used by file system fs init _devicemount 0 fp open Hello txt O CREAT O RDWR write fp 0 14 close fp Example fs_uninit 6 15 _getfserrcode API Name _getfserrcode Function Get the last error code of the file system De
15. fd parameter is not an open file descriptor EINVAL The whence argument value is not valid or seek to an invalid position When a file was Iseeked to a place where is out of the size of the file and a write operation followed file size extending operation will be performed It means that file Remarks system will read and adapt the FAT for free cluster allocation The clusters are dirty because file system never try to clean the rubbish data on the free clusters int fid open a text file for reading Example fid open a tempfile txt O OPEN D RDONLY set the read write file pointer Iseek fid 100 SEEK SET 6 6 mkdir Function Directories are created with the mkdir function Description C v s h Header File ASM C int mkdir LPSTR pathname Syntax ASM c pathname Parameters pointer to a string specify the directory name will be created ASM None A return value of 0 indicates successful completion and 1 indicates failure Return Values Error code list Generalplus Technology Inc PAGE 16 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual EACCES Write permission is denied for the parent directory in which the new directory is to be added EEXIST A file named filename already exists ENOSPC The file system doesn t have enough room to create the new directory ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exi
16. file specified int whence by the fd mkdir Create a directory LPSTR pathname int Directories are created with the mkdir function rmdir Remove a directory LPSTR pathname int The rmdir function deletes a directory chdir Change the directory LPSTR pathname int This function is used to set the process s working directory to filename getcwd Get current directory LPSTR buffer LPSTR Get current directory if success int size return buffer address else return NULL unlink Delete a file LPSTR pathname int Delete the specified file rename Rename a file for LPSTR oldname int The function can be used to move directory LPSTR newname or rename a file or a directory stat Get a file s status LPSTR filename int The stat function fills the specified struct stat buf Int structure with the information about the specified file fs_init Initialize file system void void Initialize file system fs_uninit uninitialize file system void void uninitialize file system _ getfserrcode Get the last error code int void Get the last error code of the file system O Generalplus Technology Inc PAGE 7 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual Name Function Input Parameter Return Description C language call _clsfserrcode Clear the error code void void Set the global error code value to zero _findfirst Find the first file LPSTR pathname int Find the f
17. his error code indicates a hardware error EACCES File access mode error Write to a file which is opened with O_RDONLY access mode ENOSPC Media is full File system cannot allocate any free cluster for the new write operation Remarks creat a new file fp open MHello txt O_CREAT O RDWR Example write a string data to file write fp 0 14 Write the first 14 bytes in SRAM into the file close fp 6 5 Iseek Function The lseek sets the read write file pointer for the open file specified by the fd Description C v s h Header File ASM C long Iseek int fd long offset int whence Syntax ASM O Generalplus Technology Inc PAGE 15 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual fd Index of the file node offset The offset will be set Whence Parameters id SEEK_SET Sets the file pointer to the value of the offset parameter SEEK CUR Sets the file pointer to its current location plus the value of the offset parameter SEEK END Sets the file pointer to the size of the file plus the value of the offset parameter ASM None The return value from Iseek is normally the resulting file position measured in bytes from the beginning of the file You can use this feature together with SEEK CUR to read the current file position If the file position cannot be changed or the operation is Return Values in some way invalid Iseek returns a value of 1 Error code list EBADF The
18. irst appointed name and struct f_info f_info attribute s file unsigned int attrib _findnext Find the next file struct f_info f info int Find next appointed name and attribute s file _ copy Make a copy of a file LPSTR srcfile int The function can be used to make LPSTR destfile a copy for a file _format Format the driver unsigned char drv int Create a file system with the unsigned char specified driver fstype _deleteall Delete all files and LPSTR pathname int Delete all files and folders in the folders in the specified specified directory directory _devicemount Mount a disk unsigned char int Mount a disk load the information diskid about the device and the file system information on the device _deviceunmount Umount the specified unsigned char int Umount the specified device device diskid flush all cached data associates to the device _ getdiskfree Get information about short driver int Get information about the space the space struct diskfree t dfreep of the specified device Assembler call Generalplus Technology Inc PAGE 8 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 3 Global Variable List Description Setting Function Getting Function Condition None Generalplus Technology Inc PAGE 9 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 4 Resource List 4 1
19. lete directories ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Remarks if unlink aMWtempfile txt 1 switch _getfserrcode case EACCES Example else printf file has been deleted n 6 11 rename API Name rename Function The function can be used to move or rename a file or a directory Description C vfs h Header File ASM C int rename LPSTR oldname LPSTR newname Syntax ASM oldname c The old name of the file Parameters newname The new name of the file ASM 1 returned when error occurred Return Values Error code list EACCES One of the directories containing newname or oldname refuses O Generalplus Technology Inc PAGE 20 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual write permission or newname and oldname are directories and write permission is refused for one of them EEXIST The file or directory newname is already existed ENOENT The file oldname doesn t exist ENOSPC The directory that would contain newname has no room for another entry and there is no space left in the file system to expand it ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Remarks change the filename of file1 into file2 int res Example res rena
20. me a file1 a file2 if res 1 printf rename failed n 6 12 stat API Name stat The stat function fills the specified structure with the information about the specified Function file Description C v s h Header File ASM C int stat LPSTR filename struct stat buf Syntax ASM Filename Pointer to a pathname string Buf Pointer to a stat structure Data Structure struct stat unsigned short st mode access attribute of the file see file mode bitwise mask long st size the size of the normal file in byte c unsigned long st_mtime the last modification time Parameters E File Mode Bitwise Mask S_READ_ONLY Read only attribute S_HIDDEN Hide attribute A hidden file has this attribute S_SYSTEM System file attribute S_DIRECTORY Directories have this attribute S_ARCHIVE Normal file attribute ASM Return Values The return value is 0 if the operation is successful or 1 on failure Generalplus Technology Inc PAGE 21 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual Error code list EINVAL Parameter list error neither the filename nor the bufcan be NULL ENOENT The file named by filename doesn t exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Remarks Compare two files last modification times struct stat statbuf time ttimel int r
21. not a valid file descriptor or is not open for reading ElO For many devices and for disk files this error code indicates a hardware error Remarks int fp fp open MHello txt O CREAT O_RDWR write fp O 14 write 14 bytes start form SRAM 0 to file Example close fp system will write the data to disk fp open MHello txt O OPEN O_RD read fp 0 14 read 14 byte form the file into the first 14 bytes of the SRAM close fp 6 4 write API Name write Function The write function writes up to size bytes from buffer to the file with descriptor filedes Description C v s h Header File ASM C int write int filedes unsigned long buffer unsigned int size Syntax ASM O Generalplus Technology Inc PAGE 14 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual filedes File node index maybe it s open s return value buffer Parameters Buffer pointer It s data pointer given to specify an offset in the SRAM size Writes up to size bytes from buffer to the file ASM The return value is the number of bytes actually written This may be size but can always be smaller Your program should always call write in a loop iterating until all the data is written In the case of an error write returns 1 Error code list EBADF The filedes argument is not a valid file descriptor or is not open for Return Values BU Ns ElO For many devices and for disk files t
22. nsigned int attrib Syntax ASM O Generalplus Technology Inc PAGE 24 V1 0 JUL 16 2009 G Generalplus Parameters Return Values Remarks Example ASM GPL32XXX File System Library User s Manual pathname Pointer to a pathname string ffblk Pointer to a f info structure struct f info char f name 256 file name unsigned char f attrib file attribute unsigned int f_time file time unsigned int f_date file date unsigned long f fsize file size y attrib D_RDONLY Read only file attribute D_HIDDEN Hidden file attribute D_SYSTEM System file attribute D DIR Directory attribute D ARCHIVE Archive file attribute None This function returns O on successful completion and 1 on error Error code list ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist or when a component is a symbolic link whose target file does not exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions ElO For many devices and for disk files this error code indicates a hardware error void list file char pattern struct f info finfo int idx 0 printf nList s pattern if _findfirst pattern amp finfo D_ALL printf nNo such file return do idx printf n d t s idx finfo f_name Generalplus Technology
23. r s Manual Revision History Revision Date By Remark V1 00 2009 7 16 Jacky Lin Original Version YaoZurong V1 01 2007 8 2 zhangzha Add program example O Generalplus Technology Inc PAGE 5 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 1 Introduction 1 1 General Description This guide describes the functionality and user API of DOS FAT FAT32 File System for GPL32 system O Generalplus Technology Inc PAGE 6 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 2 Function List Name Function Input Parameter Return Description C language call open Open a file LPSTR pathname int Open the specified file with the int flags specified mode close Close a file int filedes int The function close the file specified by the file node index and flush the buffers associates to the file read Read data from a file int filedes int The read function reads up to size unsigned long bytes from the file with descriptor buffer filedes storing the results in the unsigned int size buffer write Write data to a file int filedes int The write function writes up to unsigned long size bytes from buffer to the file buffer with descriptor filedes unsigned int size Iseek Sets the read write file int fd long The Iseek sets the read write file pointer long offset pointer for the open
24. scription C v s h Header File ASM C int _ getfserrcode void Syntax ASM C None Parameters ASM None Return the last error code value It can be one of the following values ENOENT No such file or directory EINVACC Invalid access mode EBADF Bad file number EINVFNC Invalid function number Return Values ENOMEM Not enough core ERANGE Not enough core EACCES Permission denied EEXIST File exists EISDIR Target specified not a file but a directory EINVAL Invalid argument O Generalplus Technology Inc PAGE 23 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual EMFILE Too many open files ENOSPC No space left on device ENOTEMPTY Directory is not empty ElO VO operation error ENOTDIR Not directory ENFILE File not found EROFS Incorrect access mode EPERM Target is a directory EBUSY Target device is busy ENAMETOOLONG Specified path name or file name too long ENAMEINVALID Invalid character detected in the filename string Remarks Example 6 16 clsfserrcode API Name _ clsfserrcode Function Set the global error code value to zero Description C v s h Header File ASM C void _ clsfserrcode void Syntax ASM C None Parameters asm None Return Values None Remarks Example 6 17 _findfirst API Name _ findfirst Function Find the first appointed name and attribute s file Description C v s h Header File ASM C int _findfirst LPSTR pathname struct f info f info u
25. st ElO For many devices and for disk files this error code indicates a hardware error ENAMETOOLONG Filename specified too long ENAMEINVALID Invalid character detected in the filename string ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Remarks void create temp directory I if mkdir a temp 1 printf can not create temporary directoryin Example else printf temporary directory created n 6 7 rmdir API Name rmdir Function The rmdir function deletes a directory Description C v s h Header File ASM C int rmdir LPSTR pathname Syntax ASM c pathname Parameters pointer to a string specify the directory name will be deleted ASM None Generalplus Technology Inc PAGE 17 V1 0 JUL 16 2009 G Generalplus Return Values GPL32XXX File System Library User s Manual This function returns O on successful completion and 1 on error Error code list ENOTEMPTY The directory to be deleted is not empty EACCES ENOENT ENFILE ElO Write permission is denied for the directory from which the file is to be removed This error is reported when a file referenced as a directory component in the file name doesn t exist The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions For many devices and for
26. strlen string close fp 6 2 close API Name close The function close the file specified by the file node index and flush the buffers Function i associates to the file Description C vfs h Header File ASM C int close int filedes Syntax ASM C filedes File node index maybe it s open s return value Parameters ASM None The normal return value from close is 0 a value of 1 is returned in case of failure Return Values Error Code List EBADF The filedes argument is not a valid file descriptor Remarks fp open MHello txt O_CREAT O_RDWR write fp Hello world 14 Example close fp system will write the data to disk Generalplus Technology Inc PAGE 13 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 6 3 read API Name read The read function reads up to size bytes from the file with descriptor filedes storing Function the results in the buffer Description C v s h Header File ASM C int read int filedes unsigned long buffer unsigned int size Syntax ASM Filedes File node index maybe it s open s return value C Buffer Buffer pointer Its data pointer given to specify an offset in the SRAM Parameters Size Reads up to size bytes from the file ASM None The return value is the number of bytes actually read This might be less than size In case of an error read returns 1 Return Values EBADF The filedes argument is
27. tcwd API Name getcwd Function Get current directory if success return buffer address else return NULL Description C v s h Header File ASM C LPSTR getcwd LPSTR buffer int size Syntax ASM buffer c Pointer to directory string buffer Parameters size Maximum length of the directory string can be stored ASM None The return value is buffer on success and a null pointer on failure Error code list Return Values EINVAL The size argument is zero and bufferis not a null pointer ERANGE The size argument is less than the length of the working directory name You need to prepare a bigger array and try again Remarks int size 100 char buffer 100 if getcwd buffer size buffer Example printf AnCurrent path s buffer 6 10 unlink API Name unlink Function Delete the specified file Description C v s h Header File ASM O Generalplus Technology Inc PAGE 19 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual C int unlink LPSTR pathname Syntax ASM c pathname Parameters The file will be unlinked ASM None This function returns O on successful completion and 1 on error Error code list EACCES Write permission is denied for the directory from which the file is to be removed or the file is busy Return Values ENOENT The filename to be deleted doesn t exist EISDIR Unlink cannot be used to delete the name of a directory To avoid such problems use rmdir to de
28. ystem Library User s Manual Some limits exist in this embedded file system We list them as following 8 3 Maximum Open File Number There are only three file node structure variables in this file system So at the same time only three files can be opened at most 8 4 Implied Open Operations Some functions impliedly reguire file node structure variables to work properly With out enough file node structure they will report error These reguirements for file node structure variables are listed in the following table means file node is visibly reguired Function name open close read write Iseek rmdir mkdir chdir getcwd unlink rename utime stat fs init _ getfserrcode _ clserrcode _ findfirst _ findnext _copy _move _ format _ setfattr _ deleteall _ devicemount _ deviceunmount o jo jo jo _ deviceinfoget _ getdiskfree Reguire file node structure variables number 1 alalolo lo la joa j jO IN m O Generalplus Technology Inc PAGE 34 V1 0 JUL 16 2009 G Generalplus GPL32XXX File System Library User s Manual 8 5 Copy Operation Performance We can not make sure which part of the SRAM is available to work as a data buffer when user is calling _copy to duplicate a file So we declared a 64 byte length unsigned char array as buffer in copy function The array size is limited by the size of the memory size on board It means than we can not

Download Pdf Manuals

image

Related Search

Related Contents

WIP Data Capture System - The Barcode Software Center  Philips AVENT Breastcare thermo pads SCF258/02  ThinkCentre Hardware Maintenance Manual      SG-330 - GENTOS  Soundsation GN250 User manual  UniVendor Service Section      

Copyright © All rights reserved.
Failed to retrieve file