1 /* 2 * dos.h 3 * Human68k DOS call interface 4 * 5 * written by Yasha (ITOH Yasufumi) 6 * (based on PD libc 1.1.32 by PROJECT C Library) 7 * public domain 8 * 9 * $NetBSD: dos.h,v 1.2 1999/11/22 01:14:55 itohy Exp $ 10 */ 11 /* 12 * PROJECT C Library, X68000 PROGRAMMING INTERFACE DEFINITION 13 * -------------------------------------------------------------------- 14 * This file is written by the Project C Library Group, and completely 15 * in public domain. You can freely use, copy, modify, and redistribute 16 * the whole contents, without this notice. 17 * -------------------------------------------------------------------- 18 * Id: dos.h,v 1.6 1994/07/27 13:44:11 mura Exp 19 * Id: dos_p.h,v 1.3 1993/10/06 16:46:07 mura Exp 20 */ 21 22 #ifndef __X68K_DOS_H__ 23 #define __X68K_DOS_H__ 24 25 #include <sys/cdefs.h> 26 27 typedef int dos_mode_t; 28 29 struct dos_inpptr { 30 unsigned char max; 31 unsigned char length; 32 char buffer[256]; 33 }; 34 35 struct dos_nameckbuf { 36 char drive[2]; 37 char path[65]; 38 char name[19]; 39 char ext[5]; 40 }; 41 42 union dos_fcb { 43 struct { 44 unsigned char dupcnt; 45 unsigned char devattr; 46 void *deventry; 47 char nouse_1[8]; 48 unsigned char openmode; 49 char nouse_2[21]; 50 char name1[8]; 51 char ext[3]; 52 char nouse_3; 53 char name2[10]; 54 char nouse_4[38]; 55 } __attribute__((__packed__)) chr; 56 struct { 57 unsigned char dupcnt; 58 unsigned mode : 1; 59 unsigned unknown : 2; 60 unsigned physdrv : 5; 61 void *deventry; 62 unsigned int fileptr; 63 unsigned int exclptr; 64 unsigned char openmode; 65 unsigned char entryidx; 66 unsigned char clustidx; 67 char nouse_2; 68 unsigned short acluster; 69 unsigned int asector; 70 void *iobuf; 71 unsigned long dirsec; 72 unsigned int fptrmax; 73 char name1[8]; 74 char ext[3]; 75 unsigned char attr; 76 char name2[10]; 77 unsigned short time; 78 unsigned short date; 79 unsigned short fatno; 80 unsigned long size; 81 char nouse_4[28]; 82 } __attribute__((__packed__)) blk; 83 }; 84 85 struct dos_indos { 86 unsigned short indosf; 87 unsigned char doscmd; 88 unsigned char fat_flg; 89 unsigned short retry_count; 90 unsigned short retry_time; 91 unsigned short verifyf; 92 unsigned char breakf; 93 unsigned char ctrlpf; 94 unsigned char reserved; 95 unsigned char wkcurdrv; 96 }; 97 98 struct dos_mep { 99 void *prev_mp; 100 void *parent_mp; 101 void *block_end; 102 void *next_mp; 103 }; 104 105 struct dos_psp { 106 char *env; 107 void *exit; 108 void *ctrlc; 109 void *errexit; 110 char *comline; 111 unsigned char handle[12]; 112 void *bss; 113 void *heap; 114 void *stack; 115 void *usp; 116 void *ssp; 117 unsigned short sr; 118 unsigned short abort_sr; 119 void *abort_ssp; 120 void *trap10; 121 void *trap11; 122 void *trap12; 123 void *trap13; 124 void *trap14; 125 unsigned int osflg; 126 unsigned char reserve_1[28]; 127 char exe_path[68]; 128 char exe_name[24]; 129 char reserve_2[36]; 130 }; 131 132 struct dos_comline { 133 unsigned char len; 134 char buffer[255]; 135 }; 136 137 struct dos_namestbuf { 138 unsigned char flg; 139 unsigned char drive; 140 char path[65]; 141 char name1[8]; 142 char ext[3]; 143 char name2[10]; 144 }; 145 146 struct dos_freeinf { 147 unsigned short free; 148 unsigned short max; 149 unsigned short sec; 150 unsigned short byte; 151 }; 152 153 struct dos_dpbptr { 154 unsigned char drive; 155 unsigned char unit; 156 unsigned short byte; 157 unsigned char sec; 158 unsigned char shift; 159 unsigned short fatsec; 160 unsigned char fatcount; 161 unsigned char fatlen; 162 unsigned short dircount; 163 unsigned short datasec; 164 unsigned short maxfat; 165 unsigned short dirsec; 166 int driver; 167 unsigned char ide; 168 unsigned char flg; 169 struct dos_dpbptr *next; 170 unsigned short dirfat; 171 char dirbuf[64]; 172 } __attribute__((__packed__)); 173 174 struct dos_filbuf { 175 unsigned char searchatr; 176 unsigned char driveno; 177 unsigned long dirsec; 178 unsigned short dirlft; 179 unsigned short dirpos; 180 char filename[8]; 181 char ext[3]; 182 unsigned char atr; 183 unsigned short time; 184 unsigned short date; 185 unsigned int filelen; 186 char name[23]; 187 } __attribute__((__packed__)); 188 189 struct dos_exfilbuf { 190 unsigned char searchatr; 191 unsigned char driveno; 192 unsigned long dirsec; 193 unsigned short dirlft; 194 unsigned short dirpos; 195 char filename[8]; 196 char ext[3]; 197 unsigned char atr; 198 unsigned short time; 199 unsigned short date; 200 unsigned int filelen; 201 char name[23]; 202 char drive[2]; 203 char path[65]; 204 char unused[21]; 205 } __attribute__((__packed__)); 206 207 struct dos_dregs { 208 int d0; 209 int d1; 210 int d2; 211 int d3; 212 int d4; 213 int d5; 214 int d6; 215 int d7; 216 int a0; 217 int a1; 218 int a2; 219 int a3; 220 int a4; 221 int a5; 222 int a6; 223 }; 224 225 struct dos_prcctrl { 226 long length; 227 unsigned char *buf_ptr; 228 unsigned short command; 229 unsigned short your_id; 230 }; 231 232 struct dos_prcptr { 233 struct dos_prcptr *next_ptr; 234 unsigned char wait_flg; 235 unsigned char counter; 236 unsigned char max_counter; 237 unsigned char doscmd; 238 unsigned int psp_id; 239 unsigned int usp_reg; 240 unsigned int d_reg[8]; 241 unsigned int a_reg[7]; 242 unsigned short sr_reg; 243 unsigned int pc_reg; 244 unsigned int ssp_reg; 245 unsigned short indosf; 246 unsigned int indosp; 247 struct dos_prcctrl *buf_ptr; 248 unsigned char name[16]; 249 long wait_time; 250 } __attribute__((__packed__)); 251 252 /* 253 * arguments: 254 * l 32bit arg -> 32bit DOS arg 255 * w 32bit arg -> lower 16bit DOS arg 256 * lb31 32bit arg -> 32bit (arg | 0x80000000) DOS arg 257 * wb8 32bit arg -> 16bit (arg | 0x100) DOS arg 258 * wb15 32bit arg -> 16bit (arg | 0x8000) DOS arg 259 * (num).l (no C arg)-> 32bit (num) DOS arg 260 * (num).w (no C arg)-> 16bit (num) DOS arg 261 * drvctrl special arg for DOS_DRVCTRL 262 * super special arg for DOS_SUPER 263 * opts: 264 * e d0 < 0 is an error code 265 * estrct d0 > 0xffffff00 (unsigned) is an error code 266 * ealloc error handling of memory allocation 267 * ep error handling of process operation 268 * sv save and restore d2-d7/a2-a6 269 * noret the DOS call never returns 270 * alias NAME specify another entry name 271 * super special for DOS_SUPER 272 * super_jsr special for DOS_SUPER_JSR 273 */ 274 275 /* ff00 ; noret */ __dead void DOS_EXIT __P((void)) __attribute__((__noreturn__)); 276 /* ff01 */ int DOS_GETCHAR __P((void)); 277 /* ff02 w */ void DOS_PUTCHAR __P((int)); 278 /* ff03 */ int DOS_COMINP __P((void)); 279 /* ff04 w */ void DOS_COMOUT __P((int)); 280 /* ff05 w */ void DOS_PRNOUT __P((int)); 281 /* ff06 w */ int DOS_INPOUT __P((int)); 282 /* ff07 */ int DOS_INKEY __P((void)); 283 /* ff08 */ int DOS_GETC __P((void)); 284 /* ff09 l */ void DOS_PRINT __P((const char *)); 285 /* ff0a l */ int DOS_GETS __P((struct dos_inpptr *)); 286 /* ff0b */ int DOS_KEYSNS __P((void)); 287 /* ff0c 1.w */ int DOS_KFLUSHGP __P((void)); 288 /* ff0c 6.w w */ int DOS_KFLUSHIO __P((int)); 289 /* ff0c 7.w */ int DOS_KFLUSHIN __P((void)); 290 /* ff0c 8.w */ int DOS_KFLUSHGC __P((void)); 291 /* ff0c 10.w l */ int DOS_KFLUSHGS __P((struct dos_inpptr *)); 292 /* ff0d */ void DOS_FFLUSH __P((void)); 293 /* ff0e w */ int DOS_CHGDRV __P((int)); 294 /* ff0f drvctrl */ int DOS_DRVCTRL __P((int, int)); 295 /* ff10 */ int DOS_CONSNS __P((void)); 296 /* ff11 */ int DOS_PRNSNS __P((void)); 297 /* ff12 */ int DOS_CINSNS __P((void)); 298 /* ff13 */ int DOS_COUTSNS __P((void)); 299 /* ff17 l l ; e */ int DOS_FATCHK __P((const char *, unsigned short *)); 300 /* ff17 l lb31 w ; e */ int DOS_FATCHK2 __P((const char *, unsigned short *, int)); 301 /* ff18 0.w */ int DOS_HENDSPMO __P((void)); 302 /* ff18 1.w w l */ int DOS_HENDSPMP __P((int, const char *)); 303 /* ff18 2.w w l */ int DOS_HENDSPMR __P((int, const char *)); 304 /* ff18 3.w */ void DOS_HENDSPMC __P((void)); 305 /* ff18 4.w */ int DOS_HENDSPIO __P((void)); 306 /* ff18 5.w w l */ int DOS_HENDSPIP __P((int, const char *)); 307 /* ff18 6.w w l */ int DOS_HENDSPIR __P((int, const char *)); 308 /* ff18 7.w w */ void DOS_HENDSPIC __P((int)); 309 /* ff18 8.w */ int DOS_HENDSPSO __P((void)); 310 /* ff18 9.w w l */ int DOS_HENDSPSP __P((int, const char *)); 311 /* ff18 10.w w l */ int DOS_HENDSPSR __P((int, const char *)); 312 /* ff18 11.w */ void DOS_HENDSPSC __P((void)); 313 /* ff19 */ int DOS_CURDRV __P((void)); 314 /* ff1a l */ int DOS_GETSS __P((struct dos_inpptr *)); 315 /* ff1b w */ int DOS_FGETC __P((int)); 316 /* ff1c l w */ int DOS_FGETS __P((struct dos_inpptr *, int)); 317 /* ff1d w w */ void DOS_FPUTC __P((int, int)); 318 /* ff1e l w */ void DOS_FPUTS __P((const char *, int)); 319 /* ff1f */ void DOS_ALLCLOSE __P((void)); 320 /* ff20 super ; super e */ int DOS_SUPER __P((int)); 321 /* ff21 w l ; e */ void DOS_FNCKEYGT __P((int, char *)); 322 /* ff21 wb8 l ; e */ void DOS_FNCKEYST __P((int, const char *)); 323 /* ff23 0.w w */ int DOS_C_PUTC __P((int)); 324 /* ff23 1.w l */ int DOS_C_PRINT __P((const char *)); 325 /* ff23 2.w w */ int DOS_C_COLOR __P((int)); 326 /* ff23 3.w w w */ int DOS_C_LOCATE __P((int, int)); 327 /* ff23 4.w */ int DOS_C_DOWN_S __P((void)); 328 /* ff23 5.w */ int DOS_C_UP_S __P((void)); 329 /* ff23 6.w w */ int DOS_C_UP __P((int)); 330 /* ff23 7.w w */ int DOS_C_DOWN __P((int)); 331 /* ff23 8.w w */ int DOS_C_RIGHT __P((int)); 332 /* ff23 9.w w */ int DOS_C_LEFT __P((int)); 333 /* ff23 10.w 0.w */ int DOS_C_CLS_ED __P((void)); 334 /* ff23 10.w 1.w */ int DOS_C_CLS_ST __P((void)); 335 /* ff23 10.w 2.w */ int DOS_C_CLS_AL __P((void)); 336 /* ff23 11.w 0.w */ int DOS_C_ERA_ED __P((void)); 337 /* ff23 11.w 1.w */ int DOS_C_ERA_ST __P((void)); 338 /* ff23 11.w 2.w */ int DOS_C_ERA_AL __P((void)); 339 /* ff23 12.w w */ int DOS_C_INS __P((int)); 340 /* ff23 13.w w */ int DOS_C_DEL __P((int)); 341 /* ff23 14.w w */ int DOS_C_FNKMOD __P((int)); 342 /* ff23 15.w w w */ int DOS_C_WINDOW __P((int, int)); 343 /* ff23 16.w w */ int DOS_C_WIDTH __P((int)); 344 /* ff23 17.w */ int DOS_C_CURON __P((void)); 345 /* ff23 18.w */ int DOS_C_CUROFF __P((void)); 346 /* ff24 0.w */ int DOS_K_KEYINP __P((void)); 347 /* ff24 1.w */ int DOS_K_KEYSNS __P((void)); 348 /* ff24 2.w */ int DOS_K_SFTSNS __P((void)); 349 /* ff24 3.w w */ int DOS_K_KEYBIT __P((int)); 350 /* ff24 4.w w */ void DOS_K_INSMOD __P((int)); 351 /* ff25 w l */ void *DOS_INTVCS __P((int, void *)); 352 /* ff26 l */ void DOS_PSPSET __P((struct dos_psp *)); 353 /* ff27 */ int DOS_GETTIM2 __P((void)); 354 /* ff28 l ; e */ int DOS_SETTIM2 __P((int)); 355 /* ff29 l l ; e */ int DOS_NAMESTS __P((const char *, struct dos_namestbuf *)); 356 /* ff2a */ int DOS_GETDATE __P((void)); 357 /* ff2b w ; e */ int DOS_SETDATE __P((int)); 358 /* ff2c */ int DOS_GETTIME __P((void)); 359 /* ff2d w ; e */ int DOS_SETTIME __P((int)); 360 /* ff2e w */ void DOS_VERIFY __P((int)); 361 /* ff2f w w ; e */ int DOS_DUP0 __P((int, int)); 362 /* ff30 */ int __const DOS_VERNUM __P((void)); 363 /* ff31 l w ; noret */ __dead void DOS_KEEPPR __P((int, int)) __attribute__((__noreturn__)); 364 /* ff32 w l ; e */ int DOS_GETDPB __P((int, struct dos_dpbptr *)); 365 /* ff33 w */ int DOS_BREAKCK __P((int)); 366 /* ff34 w w ; e */ void DOS_DRVXCHG __P((int, int)); 367 /* ff35 w */ void *DOS_INTVCG __P((int)); 368 /* ff36 w l ; estrct */ int DOS_DSKFRE __P((int, struct dos_freeinf *)); 369 /* ff37 l l ; e */ int DOS_NAMECK __P((const char *, struct dos_nameckbuf *)); 370 /* ff39 l ; e */ int DOS_MKDIR __P((const char *)); 371 /* ff3a l ; e */ int DOS_RMDIR __P((const char *)); 372 /* ff3b l ; e */ int DOS_CHDIR __P((const char *)); 373 /* ff3c l w ; e */ int DOS_CREATE __P((const char *, dos_mode_t)); 374 /* ff3d l w ; e */ int DOS_OPEN __P((const char *, int)); 375 /* ff3e w ; e */ int DOS_CLOSE __P((int)); 376 /* ff3f w l l ; e */ int DOS_READ __P((int, char *, int)); 377 /* ff40 w l l ; e */ int DOS_WRITE __P((int, const char *, int)); 378 /* ff41 l ; e */ int DOS_DELETE __P((const char *)); 379 /* ff42 w l w ; e */ long DOS_SEEK __P((int, int, int)); 380 /* ff43 l w ; e */ dos_mode_t DOS_CHMOD __P((const char *, dos_mode_t)); 381 /* ff44 0.w w ; e */ int DOS_IOCTRLGT __P((int)); 382 /* ff44 1.w w w ; e */ int DOS_IOCTRLST __P((int, int)); 383 /* ff44 2.w w l l ; e */ int DOS_IOCTRLRH __P((int, char *, int)); 384 /* ff44 3.w w l l ; e */ int DOS_IOCTRLWH __P((int, const char *, int)); 385 /* ff44 4.w w l l ; e */ int DOS_IOCTRLRD __P((int, char *, int)); 386 /* ff44 5.w w l l ; e */ int DOS_IOCTRLWD __P((int, const char *, int)); 387 /* ff44 6.w w ; e */ int DOS_IOCTRLIS __P((int)); 388 /* ff44 7.w w ; e */ int DOS_IOCTRLOS __P((int)); 389 /* ff44 9.w w ; e */ int DOS_IOCTRLDVGT __P((int)); 390 /* ff44 10.w w ; e */ int DOS_IOCTRLFDGT __P((int)); 391 /* ff44 11.w w w ; e */ int DOS_IOCTRLRTSET __P((int, int)); 392 /* ff44 12.w w w l ; e */ int DOS_IOCTRLDVCTL __P((int, int, char *)); 393 /* ff44 13.w w w l ; e */ int DOS_IOCTRLFDCTL __P((int, int, char *)); 394 /* ff45 w ; e */ int DOS_DUP __P((int)); 395 /* ff46 w w ; e */ int DOS_DUP2 __P((int, int)); 396 /* ff47 w l ; e */ int DOS_CURDIR __P((int, char *)); 397 /* ff48 l ; ealloc */ void *DOS_MALLOC __P((int)); 398 /* ff49 l ; e */ int DOS_MFREE __P((void *)); 399 /* ff4a l l ; ealloc */ int DOS_SETBLOCK __P((void *, int)); 400 /* ff4b 0.w l l l ; sv e */ int DOS_LOADEXEC __P((const char *, const struct dos_comline *, const char *)); 401 /* ff4b 1.w l l l ; sv e */ int DOS_LOAD __P((const char *, const struct dos_comline *, const char *)); 402 /* ff4b 2.w l l l ; e */ int DOS_PATHCHK __P((const char *, const struct dos_comline *, const char *)); 403 /* ff4b 3.w l l l ; e */ int DOS_LOADONLY __P((const char *, const void *, const void *)); 404 /* ff4b 4.w l ; sv e */ int DOS_EXECONLY __P((void *)); 405 /* ff4b 5.w l l 0.l ; sv e */ int DOS_BINDNO __P((const char *, const char *)); 406 /*^ 0.l is required?? */ 407 /* ff4b w l l l ; sv e */ int DOS_EXEC2 __P((int, const char *, const char *, const char *)); 408 /* ff4c w ; noret */ __dead void DOS_EXIT2 __P((int)) __attribute__((__noreturn__)); 409 /* ff4d */ int DOS_WAIT __P((void)); 410 /* ff4e l l w ; e */ int DOS_FILES __P((struct dos_filbuf *, const char *, int)); 411 /* ff4e lb31 l w ; e */ int DOS_EXFILES __P((struct dos_exfilbuf *, const char *, int)); 412 /* ff4f l ; e */ int DOS_NFILES __P((struct dos_filbuf *)); 413 /* ff4f lb31 ; e */ int DOS_EXNFILES __P((struct dos_exfilbuf *)); 414 /* ff80 l */ struct dos_psp *DOS_SETPDB __P((struct dos_psp *)); 415 /* ff81 */ struct dos_psp *DOS_GETPDB __P((void)); 416 /* ff82 l l l ; e */ int DOS_SETENV __P((const char *, const char *, const char *)); 417 /* ff83 l l l ; e */ int DOS_GETENV __P((const char *, const char *, char *)); 418 /* ff84 */ int DOS_VERIFYG __P((void)); 419 /* ff85 0.w l ; e */ int DOS_COMMON_CK __P((const char *)); 420 /* ff85 1.w l l l l ; e */ int DOS_COMMON_RD __P((const char *, int, char *, int)); 421 /* ff85 2.w l l l l ; e */ int DOS_COMMON_WT __P((const char *, int, const char *, int)); 422 /* ff85 3.w l l l l ; e */ int DOS_COMMON_LK __P((const char *, int, int, int)); 423 /* ff85 4.w l l l l ; e */ int DOS_COMMON_FRE __P((const char *, int, int, int)); 424 /* ff85 5.w l ; e */ int DOS_COMMON_DEL __P((const char *)); 425 /* ff86 l l ; e */ int DOS_MOVE __P((const char *, const char *)); 426 int DOS_RENAME __P((const char *, const char *)); 427 /* ff87 w l ; estrct */ int DOS_FILEDATE __P((int, int)); 428 /* ff88 w l ; ealloc */ void *DOS_MALLOC2 __P((int, int)); 429 /* ff88 wb15 l l ; ealloc */ void *DOS_MALLOC0 __P((int, int, int)); 430 /* ff8a l w ; e */ int DOS_MAKETMP __P((const char *, int)); 431 /* ff8b l w ; e */ int DOS_NEWFILE __P((const char *, dos_mode_t)); 432 /* ff8c 0.w w l l ; e */ int DOS_LOCK __P((int, int, int)); 433 /* ff8c 1.w w l l ; e */ int DOS_UNLOCK __P((int, int, int)); 434 /* ff8f 0.w l l ; e */ int DOS_GETASSIGN __P((const char *, char *)); 435 /* ff8f 1.w l l w ; e */ int DOS_MAKEASSIGN __P((const char *, const char *, int)); 436 /* ff8f 4.w l ; e */ int DOS_RASSIGN __P((const char *)); 437 /* ffaa w */ int DOS_FFLUSH_SET __P((int)); 438 /* ffab w l ; e */ void *DOS_OS_PATCH __P((unsigned int, void *)); 439 /* ffac w ; e */ union dos_fcb *DOS_GET_FCB_ADR __P((unsigned int)); 440 /* ffad w l ; ealloc */ void *DOS_S_MALLOC __P((int, int)); 441 /* ffad wb15 l l ; ealloc */ void *DOS_S_MALLOC0 __P((int, int)); 442 /* ffae l ; e */ int DOS_S_MFREE __P((void *)); 443 /* ffaf w l l l ; ep */ int DOS_S_PROCESS __P((int, int, int, int)); 444 /* fff0 ; alias DOS_EXITVC noret */ __dead void DOS_RETSHELL __P((void)) __attribute__((__noreturn__)); 445 __dead void DOS_EXITVC __P((void)) __attribute__((__noreturn__)); 446 /* fff1 ; noret */ __dead void DOS_CTLABORT __P((void)) __attribute__((__noreturn__)); 447 /* fff2 ; noret */ __dead void DOS_ERRABORT __P((void)) __attribute__((__noreturn__)); 448 /* fff3 l w w w */ void DOS_DISKRED __P((void *, int, int, int)); 449 /* fff3 lb31 w l l */ void DOS_DISKRED2 __P((void *, int, int, int)); 450 /* fff4 l w w w */ void DOS_DISKWRT __P((const void *, int, int, int)); 451 /* fff4 lb31 w l l */ void DOS_DISKWRT2 __P((const void *, int, int, int)); 452 /* fff5 */ struct dos_indos *DOS_INDOSFLG __P((void)); 453 /* fff6 l ; super_jsr sv */ void DOS_SUPER_JSR __P((void (*) __P((void)), struct dos_dregs *, struct dos_dregs *)); 454 /* fff7 l l w ; alias DOS_BUS_ERR e */ int DOS_MEMCPY __P((void *, void *, int)); 455 int DOS_BUS_ERR __P((void *, void *, int)); 456 /* fff8 l w l l w l l l ; e */ int DOS_OPEN_PR __P((const char *, int, int, int, int, int, struct dos_prcctrl *, long)); 457 /* fff9 ; e */ int DOS_KILL_PR __P((void)); 458 /* fffa w l ; e */ int DOS_GET_PR __P((int, struct dos_prcptr *)); 459 /* fffb w ; ep */ int DOS_SUSPEND_PR __P((int)); 460 /* fffc l */ int DOS_SLEEP_PR __P((long)); 461 /* fffd w w w l l ; ep */ int DOS_SEND_PR __P((int, int, int, char *, long)); 462 /* fffe */ long DOS_TIME_PR __P((void)); 463 /* ffff */ void DOS_CHANGE_PR __P((void)); 464 465 #endif /* __X68K_DOS_H__ */ 466