@@ -13,7 +13,8 @@ you can call from the 6502. The :doc:`os` does not use any 6502 system RAM
1313and will not interfere with developing a native 6502 OS.
1414
1515The :doc: `os ` is loosely based on POSIX with an Application Binary
16- Interface (ABI) similar to `cc65 <https://cc65.github.io >`__'s fastcall.
16+ Interface (ABI) similar to `cc65's fastcall
17+ <https://cc65.github.io/doc/cc65-intern.html> `__.
1718It provides stdio.h and unistd.h services to both `cc65
1819<https://cc65.github.io> `__ and `llvm-mos <https://llvm-mos.org/ >`_
1920compilers. There are also calls to access RP6502 features and manage
@@ -59,7 +60,7 @@ Application Binary Interface
5960
6061The ABI for calling the operating system is based on
6162fastcall from the `cc65 internals
62- <https://cc65.github.io/doc/cc65-intern.html> `_ . The :doc: `os `
63+ <https://cc65.github.io/doc/cc65-intern.html> `__ . The :doc: `os `
6364does not use or require anything from cc65 and is easy for
6465assembly programmers to use. At its core, the OS ABI is four simple rules.
6566
@@ -384,15 +385,16 @@ ERRNO_OPT
384385
385386 |
386387
387- :doc:`os` calls will set RIA_ERRNO when an error occurs. The compiler
388- libraries use different constants in errno.h. Both cc65
389- and llvm-mos set this automatically for C programs. The RIA_ERRNO value will not
388+ :doc:`os` calls will set RIA_ERRNO when an error occurs. This is used to
389+ select which set of values to use because the compiler
390+ libraries each use different constants in errno.h. Both cc65
391+ and llvm-mos call this automatically in the C runtime. The RIA_ERRNO value will not
390392 change until it is set. Note that the C `errno` maps directly to RIA_ERRNO.
391393
392394 :doc:`os` will map FatFs errors onto errno. RP6502 emulation and simulation
393395 software is expected to map their native errors as well. The table below
394- shows the FatFs mappings. Because FatFs is to integral to the OS,
395- calls are documented here with their native FatFs names to assist when
396+ shows the FatFs mappings. Because FatFs is so integral to the OS,
397+ calls are documented here with their native FatFs errors to assist when
396398 cross referencing the `FatFs documentation <https:// elm-chan.org/fsw/ff/>`__.
397399
398400 :Op code: RIA_OP_ERRNO_OPT 0x06
@@ -831,7 +833,7 @@ LSEEK
831833UNLINK
832834------
833835
834- .. c:function:: int unlink (const char* name)
836+ .. c:function:: int unlink(const char* name)
835837
836838 |
837839
@@ -850,7 +852,7 @@ UNLINK
850852RENAME
851853------
852854
853- .. c:function:: int rename (const char* oldname, const char* newname)
855+ .. c:function:: int rename(const char* oldname, const char* newname)
854856
855857 |
856858
@@ -867,6 +869,55 @@ RENAME
867869 FR_LOCKED, FR_NOT_ENOUGH_CORE
868870
869871
872+ SYNCFS
873+ ------
874+
875+ .. c:function:: int syncfs(int fildes)
876+
877+ |
878+
879+ Finish pending writes for the file descriptor.
880+
881+ :Op code: RIA_OP_SYNCFS 0x1E
882+ :C proto: unistd.h
883+ :param fildes: File descriptor from open().
884+ :returns: 0 on success. -1 on error.
885+ :a regs: return, fildes
886+ :errno: EINVAL, FR_DISK_ERR, FR_INT_ERR, FR_INVALID_OBJECT,
887+ FR_TIMEOUT
888+
889+
890+ STAT
891+ ----
892+
893+ .. c:function:: int f_stat (const char* path, f_stat_t* dirent)
894+
895+ .. code-block:: c
896+
897+ typedef struct {
898+ unsigned long fsize;
899+ unsigned fdate;
900+ unsigned ftime;
901+ unsigned crdate;
902+ unsigned crtime;
903+ unsigned char fattrib;
904+ char altname[12 + 1];
905+ char fname[255 + 1];
906+ } f_stat_t ;
907+
908+ Returns file or directory info for requested path.
909+ See the `FatFs documentation <https://elm-chan.org/fsw/ff/doc/sfileinfo.html >`__
910+ for details about the data structure.
911+
912+ :Op code: RIA_OP_STAT 0x1F
913+ :C proto: rp6502.h
914+ :param path: Pathname to a directory entry.
915+ :param dirent: Returned f_stat_t data.
916+ :returns: 0 on success. -1 on error.
917+ :a regs: return, dirent
918+ :errno: FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_NO_FILE, FR_NO_PATH, FR_INVALID_NAME, FR_INVALID_DRIVE, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT, FR_NOT_ENOUGH_CORE
919+
920+
870921EXIT
871922----
872923
0 commit comments