wwstruct.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #ifndef _WWSTRUCT_H
  2. #define _WWSTRUCT_H
  3. #include <windows.h>
  4. #define MAX_WW_ARG 256
  5. #define MAXFNAME 16
  6. #define MAXPATHLEN 64
  7. #define MAXFINFO 24
  8. #define OPEN_MAX 16 /* max open fils per process */
  9. #define BLOCKSZ 128 /* size of file block */
  10. #define FMODE_X (0x0001) /* executable */
  11. #define FMODE_W (0x0002) /* writable */
  12. #define FMODE_R (0x0004) /* readable */
  13. #define FMODE_MMAP (0x0008) /* disallow mmap */
  14. #define FMODE_STREAM (0x0010) /* StreamIL instance */
  15. #define FMODE_ILIB (0x0020) /* IL instance */
  16. #define FMODE_LINK (0x0040) /* symbolic link */
  17. #define FMODE_DIR (0x0080) /* directory */
  18. #define E_FS_SUCCESS 0
  19. #define E_FS_ERROR 0x8000
  20. #define E_FS_FILE_NOT_FOUND 0x8001
  21. #define E_FS_PERMISSION_DENIED 0x8002
  22. #define E_FS_OUT_OF_BOUNDS 0x8003
  23. #define E_FS_NO_SPACE_LEFT 0x8004
  24. #define E_FS_FILE_NOT_OPEN 0x8005
  25. typedef union {
  26. DWORD farptr;
  27. struct {
  28. WORD off;
  29. WORD seg;
  30. } segoff;
  31. } WW_FARPTR;
  32. #define FARPTR2ADDR(X) ((X.segoff.seg << 4) | X.segoff.off)
  33. #define SEGOFF2FARPTR(SEG, OFF) ((SEG << 16 | OFF))
  34. #define GETSEG(X) (X.segoff.seg)
  35. #define GETOFF(X) (X.segoff.off)
  36. #define GETFARPTR(X) (X.farptr)
  37. typedef WORD WW_NEARPTR;
  38. typedef WORD WW_SHORT;
  39. typedef WORD WW_INT;
  40. typedef DWORD WW_LONG;
  41. #pragma pack( push, beforewwstruct )
  42. #pragma pack(1)
  43. typedef struct {
  44. /* from startup routine
  45. __id db 'TCC', 0
  46. __pid dw ?
  47. __ppid dw ?
  48. __pcbid dw ?
  49. __ppcbid dw ?
  50. __ilib dd ?
  51. __proc dd ?
  52. __cwfs dd ?
  53. __currentdir db MAXPATHLEN dup (?)
  54. __argv dw ?
  55. __resource dd ?
  56. __heap dw ?
  57. */
  58. BYTE id[4];
  59. WW_INT pid;
  60. WW_INT ppid;
  61. WW_INT pcbid;
  62. WW_INT ppcbid;
  63. WW_FARPTR ilib;
  64. WW_FARPTR proc;
  65. WW_FARPTR cwfs;
  66. char currentdir[MAXPATHLEN];
  67. WW_NEARPTR argv;
  68. WW_FARPTR resource;
  69. WW_NEARPTR heap;
  70. } WW_PCB, *LPWW_PCB;
  71. typedef struct {
  72. char name[MAXFNAME];
  73. char info[MAXFINFO];
  74. WW_LONG loc;
  75. WW_LONG len;
  76. WW_INT count;
  77. WW_INT mode;
  78. WW_LONG mtime;
  79. union {
  80. WW_LONG appid;
  81. WW_LONG il;
  82. } handler;
  83. WW_LONG resource;
  84. } WW_FENT_T, *WW_FS;
  85. typedef struct {
  86. BYTE magic[4];
  87. BYTE padding[60];
  88. WW_FENT_T fent;
  89. } WW_FXHEADER, *LPWW_FXHEADER;
  90. typedef struct {
  91. WW_FARPTR className; // char far *className;
  92. WW_FARPTR name; // char far *name;
  93. WW_FARPTR version; // char far *version;
  94. WW_FARPTR description; // char far *description;
  95. WW_FARPTR depends; // char far * far *depends;
  96. } WW_ILInfo, *LPWW_ILInfo;
  97. typedef struct { // IL struct (see sys/indirect.h)
  98. WW_FARPTR link_pos; // void far *link_pos;
  99. WW_INT n_methods; // int n_methods;
  100. WW_FARPTR _get_info; // ILInfo far *(far *_get_info)(void);
  101. } WW_IL, *LPWW_IL;
  102. typedef struct { // IlibIL struct (see sys/indeirect.h)
  103. WW_IL super;
  104. WW_FARPTR _open; // int (far *_open)(char far *ilname, IL far *ilbuf);
  105. WW_FARPTR _open_system; //int (far *_open_system)(char far *ilname, IL far *ilbuf);
  106. } WW_IlibIL, *LPWW_IlibIL;
  107. typedef struct { // ProcIL struct (see sys/indeirect.h)
  108. WW_IL super;
  109. WW_FARPTR _load; // void far *(far *_load)(char far *command);
  110. WW_FARPTR _run; // int (far *_run)(void far *entry, int argc, char far * far *argv);
  111. WW_FARPTR _exec; // int (far *_exec)(char far *command, int argc, char far * far *argv);
  112. WW_FARPTR _exit; // void (far *_exit)(int exitcode);
  113. WW_FARPTR _yield; // void (far *_yield)(void);
  114. WW_FARPTR _suspend; // int (far *_suspend)(int pcbid);
  115. WW_FARPTR _resume; // void (far *_resume)(int pcbid);
  116. WW_FARPTR _swap; // int (far *_swap)(int pcbid);
  117. /*
  118. WW_FARPTR _kill; // int (far *_kill)(child);
  119. */
  120. } WW_ProcIL, *LPWW_ProcIL;
  121. typedef struct { // FsIL struct (see sys/indeirect.h)
  122. WW_IL super;
  123. WW_FARPTR _entries; // fent_t far *(far *_entries)(FS fs);
  124. WW_FARPTR _n_entries; // int (far *_n_entries)(FS fs);
  125. WW_FARPTR _getent; // int (far *_getent)(FS fs, int n, fent_t far *fep);
  126. WW_FARPTR _findent; // int (far *_findent)(FS fs, char far *fname, fent_t far *fep);
  127. WW_FARPTR _mmap; // void far *(far *_mmap)(FS fs, char far *fname);
  128. WW_FARPTR _open; // int (far *_open)(FS fs, char far *fname, int mode, int perms);
  129. WW_FARPTR _close; // int (far *_close)(int fd);
  130. WW_FARPTR _read; // int (far *_read)(int fd, char far *buf, int len);
  131. WW_FARPTR _write; // int (far *_write)(int fd, char far *buf, int len);
  132. WW_FARPTR _lseek; // long (far *_lseek)(int fd, long offset, int origin);
  133. WW_FARPTR _chmod; // int (far *_chmod)(FS fs, char far *fname, int mode);
  134. WW_FARPTR _freeze; // int (far *_freeze)(FS fs, char far *fname);
  135. WW_FARPTR _melt; // int (far *_melt)(FS fs, char far *fname);
  136. WW_FARPTR _creat; // int (far *_creat)(FS fs, fent_t far *fep);
  137. WW_FARPTR _unlink; // int (far *_unlink)(FS fs, char far *fname);
  138. WW_FARPTR _newfs; // int (far *_newfs)(FS fs);
  139. WW_FARPTR _defrag; // int (far *_defrag)(FS fs);
  140. WW_FARPTR _space; // unsigned long (far *_space)(FS fs);
  141. } WW_FsIL, *LPWW_FsIL;
  142. typedef struct {
  143. WW_INT _status; // int _status; /* status of process */
  144. WW_INT _exit_code; // int _exit_code; /* process exit code */
  145. } WW_ProcControl, *LPWW_ProcControl;
  146. typedef struct {
  147. WW_FS fs; // FS fs; /* FS which contains the fent */
  148. WW_FARPTR fentp; // fent_t far *fentp; /* original file entry */
  149. WW_SHORT omode; // fmode_t omode; /* open mode: 0 indicates free handle */
  150. WW_FARPTR floc; // floc_t floc; /* file location */
  151. WW_LONG flen; // flen_t flen; /* file length */
  152. WW_LONG fpos; // fpos_t fpos; /* current seek position */
  153. WW_INT count; // int count; /* total file block count */
  154. WW_FARPTR driver; // StreamIL_p driver; /* stream driver for the file */
  155. WW_INT pcb; // int pcb; /* opening process's pcb */
  156. WW_INT _reserved; // int _reserved; /* reserved */
  157. } WW_fhandle_t, *LPWW_fhandle_t;
  158. #define MAXPROCESSES 3
  159. #define MAXFILES 16
  160. #define ROOTFS_NUM_ENTRIES 16
  161. #define RAM0FS_NUM_ENTRIES 24
  162. #define ROM0FS_NUM_ENTRIES 128
  163. typedef struct { // SRAMWork struct (see sys/oswork.h)
  164. WW_PCB _opsc; // ProcContext _ospc;
  165. WW_ProcControl _pcb[MAXPROCESSES]; // ProcControl _pcb[MAXPROCESSES];
  166. WW_INT _os_version; // unsigned _os_version;
  167. WW_INT _last_pcb; // unsigned _last_pcb;
  168. WW_INT _freefd; // int _freefd;
  169. WW_fhandle_t _openfiles[MAXFILES]; // fhandle_t _openfiles[MAXFILES];
  170. char _shell_work[128];
  171. WW_FENT_T _root_fs_entries[ROOTFS_NUM_ENTRIES]; // fent_t _root_fs_entries[ROOTFS_NUM_ENTRIES];
  172. WW_FENT_T _ram0_fs_entries[RAM0FS_NUM_ENTRIES]; // fent_t _ram0_fs_entries[RAM0FS_NUM_ENTRIES];
  173. WW_FENT_T _rom0_fs_entries[ROM0FS_NUM_ENTRIES]; // fent_t _rom0_fs_entries[ROM0FS_NUM_ENTRIES];
  174. WW_FARPTR _saveports; // unsigned char far * _saveports;
  175. } WW_SRAMWork, *LPWW_SRAMWork;
  176. typedef struct { //
  177. char name[16];
  178. WW_INT birth_year;
  179. char birth_month;
  180. char birth_day;
  181. char sex;
  182. char bloodtype;
  183. } WW_OWNERINFO, *LPWW_OWNERINFO;
  184. #pragma pack( pop, beforewwstruct )
  185. #endif // #ifndef _WWSTRUCT_H