gemdos.inc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by Free Pascal development team
  4. GEMDOS related defines for Atari TOS
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { The API description of this file is based on the information available
  12. online at: http://toshyp.atari.org }
  13. const
  14. E_OK = 0; // OK. No error has arisen
  15. ESPIPE = -6; // Illegal seek
  16. EINVFN = -32; // Unknown function number
  17. EFILNF = -33; // File not found
  18. EPTHNF = -34; // Directory (folder) not found
  19. ENHNDL = -35; // No more handles available
  20. EACCDN = -36; // Access denied
  21. EIHNDL = -37; // Invalid file handle
  22. EPERM = -38; // Permission denied
  23. ENSMEM = -39; // Insufficient memory
  24. EIMBA = -40; // Invalid memory block address
  25. EDRIVE = -46; // Invalid drive specification
  26. ECWD = -47; // Current directory cannot be deleted
  27. ENSAME = -48; // Files on different logical drives
  28. ENMFIL = -49; // No more files can be opened
  29. ELOCKED = -58; // Segment of a file is protected (network)
  30. ENSLOCK = -59; // Invalid lock removal request
  31. ERANGE = -64; // File pointer in invalid segment (see also FreeMiNT message -88)
  32. EINTRN = -65; // Internal error of GEMDOS
  33. EPLFMT = -66; // Invalid program load format
  34. EGSBF = -67; // Allocated memory block could not be enlarged
  35. EBREAK = -68; // Program termination by Control-C
  36. EXCPT = -69; // 68000 exception (bombs)
  37. EPTHOV = -70; // Path overflow
  38. ELOOP = -80; // Endless loop with symbolic links
  39. EPIPE = -81; // Write to broken pipe.
  40. // as used by fseek
  41. const
  42. SEEK_FROM_START = 0;
  43. SEEK_FROM_CURRENT = 1;
  44. SEEK_FROM_END = 2;
  45. // as used by fcreate and fattrib
  46. const
  47. ATTRIB_WRITE_PROT = ( 1 shl 0 );
  48. ATTRIB_HIDDEN = ( 1 shl 1 );
  49. ATTRIB_SYSTEM = ( 1 shl 2 );
  50. ATTRIB_VOLUME_LABEL = ( 1 shl 3 );
  51. ATTRIB_DIRECTORY = ( 1 shl 4 );
  52. ATTRIB_ARCHIVE = ( 1 shl 5 );
  53. // as used by fopen
  54. const
  55. OPEN_READ_ONLY = ( 1 shl 0 );
  56. OPEN_WRITE_ONLY = ( 1 shl 1 );
  57. OPEN_READ_WRITE = ( 1 shl 2 );
  58. // as used by fattrib
  59. const
  60. FLAG_GET = 0;
  61. FLAG_SET = 1;
  62. type
  63. PDTA = ^TDTA;
  64. TDTA = packed record
  65. d_reserved: array[0..20] of shortint; {* Reserved for GEMDOS *}
  66. d_attrib: byte; {* File attributes *}
  67. d_time: word; {* Time *}
  68. d_date: word; {* Date *}
  69. d_length: dword; {* File length *}
  70. d_fname: array[0..13] of char; {* Filename *}
  71. end;
  72. type
  73. PDISKINFO = ^TDISKINFO;
  74. TDISKINFO = record
  75. b_free: dword; {* Number of free clusters *}
  76. b_total: dword; {* Total number of clusters *}
  77. b_secsiz: dword; {* Bytes per sector *}
  78. b_clsiz: dword; {* Sector per cluster *}
  79. end;
  80. type
  81. PDOSTIME = ^TDOSTIME;
  82. TDOSTIME = record
  83. time: word; {* Time like Tgettime *}
  84. date: word; {* Date like Tgetdate *}
  85. end;
  86. type
  87. PPD = ^TPD;
  88. TPD = record
  89. p_lowtpa: pointer; {* Start address of the TPA *}
  90. p_hitpa: pointer; {* First byte after the end of the TPA *}
  91. p_tbase: pointer; {* Start address of the program code *}
  92. p_tlen: longint; {* Length of the program code *}
  93. p_dbase: pointer; {* Start address of the DATA segment *}
  94. p_dlen: longint; {* Length of the DATA section *}
  95. p_bbase: pointer; {* Start address of the BSS segment *}
  96. p_blen: longint; {* Length of the BSS section *}
  97. p_dta: PDTA; {* Pointer to the default DTA *}
  98. {* Warning: Points first to the *}
  99. {* command line ! *}
  100. p_parent: PPD; {* Pointer to the basepage of the *}
  101. {* calling processes *}
  102. p_resrvd0: longint; {* Reserved *}
  103. p_env: pchar; {* Address of the environment string *}
  104. p_resrvd1: array[0..79] of char; {* Reserved *}
  105. p_cmdlin: array[0..127] of char; {* Command line *}
  106. end;
  107. TBASEPAGE = TPD; {* alias types... *}
  108. PBASEPAGE = ^TBASEPAGE;
  109. procedure gemdos_cconws(p: pchar); syscall 1 9;
  110. function gemdos_dsetdrv(drv: smallint): longint; syscall 1 14;
  111. function gemdos_dgetdrv: smallint; syscall 1 25;
  112. procedure gemdos_setdta(buf: PDTA); syscall 1 26;
  113. function gemdos_tgetdate: longint; syscall 1 42;
  114. function gemdos_tsetdate(date: word): smallint; syscall 1 43;
  115. function gemdos_tgettime: longint; syscall 1 44;
  116. function gemdos_tsettime(time: word): smallint; syscall 1 45;
  117. function gemdos_getdta: PDTA; syscall 1 47;
  118. function gemdos_sversion: smallint; syscall 1 48;
  119. function gemdos_dfree(buf: PDISKINFO; driveno: smallint): smallint; syscall 1 54;
  120. function gemdos_dcreate(const path: pchar): longint; syscall 1 57;
  121. function gemdos_ddelete(const path: pchar): longint; syscall 1 58;
  122. function gemdos_dsetpath(path: pchar): smallint; syscall 1 59;
  123. function gemdos_fcreate(fname: pchar; attr: smallint): smallint; syscall 1 60;
  124. function gemdos_fopen(fname: pchar; mode: smallint): longint; syscall 1 61;
  125. function gemdos_fclose(handle: smallint): smallint; syscall 1 62;
  126. function gemdos_fread(handle: smallint; count: longint; buf: pointer): longint; syscall 1 63;
  127. function gemdos_fwrite(handle: smallint; count: longint; buf: pointer): longint; syscall 1 64;
  128. function gemdos_fdelete(fname: pchar): smallint; syscall 1 65;
  129. function gemdos_fseek(offset: longint; handle: smallint; seekmode: smallint): longint; syscall 1 66;
  130. function gemdos_fattrib(filename: pchar; wflag: smallint; attrib: smallint): smallint; syscall 1 67;
  131. function gemdos_dgetpath(path: pchar; driveno: smallint): smallint; syscall 1 71;
  132. function gemdos_malloc(number: dword): pointer; syscall 1 72;
  133. function gemdos_mfree(block: pointer): dword; syscall 1 73;
  134. function gemdos_mshrink(zero: word; block: pointer; newsiz: longint): longint; syscall 1 74;
  135. function gemdos_pexec(mode: word; name: pchar; cmdline: pchar; env: pchar): longint; syscall 1 75;
  136. procedure gemdos_pterm(returncode: smallint); syscall 1 76;
  137. function gemdos_fsfirst(filename: pchar; attr: smallint): longint; syscall 1 78;
  138. function gemdos_fsnext: smallint; syscall 1 79;
  139. function gemdos_frename(zero: word; oldname: pchar; newname: pchar): longint; syscall 1 86;
  140. procedure gemdos_fdatime(timeptr: PDOSTIME; handle: smallint; wflag: smallint); syscall 1 87;