home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / pcosbind.zoo / tos.h < prev   
C/C++ Source or Header  |  1992-09-20  |  17KB  |  577 lines

  1. /* tos.h for Turbo C / Pure C
  2.  
  3.    os structure definitions according to a) mintlib,
  4.                                          b) Atari Profibuch ST/STE/TT
  5.                                    and   c) Pure C                     */
  6.  
  7. #ifndef __TOS
  8. #define __TOS
  9.  
  10. #ifndef __PROTO
  11. #define __PROTO(x) x
  12. #endif
  13.  
  14. /*
  15.  * basepage structure
  16.  *
  17.  */
  18.  
  19. typedef struct basep {
  20.     char    *p_lowtpa;    /* pointer to self (bottom of TPA) */
  21.     char    *p_hitpa;    /* pointer to top of TPA + 1 */
  22.     char    *p_tbase;    /* base of text segment */
  23.     long    p_tlen;        /* length of text segment */
  24.     char    *p_dbase;    /* base of data segment */
  25.     long    p_dlen;        /* length of data segment */
  26.     char    *p_bbase;    /* base of BSS segment */
  27.     long    p_blen;        /* length of BSS segment */
  28.     char    *p_dta;        /* (UNOFFICIAL, DON'T USE) */
  29.     struct basep *p_parent;    /* pointer to parent's basepage */
  30.     char    *p_reserved;    /* reserved for future use */
  31.     char    *p_env;        /* pointer to environment string */
  32. #if 0
  33. /* none of these are documented by Atari. If you try to use them under MiNT,
  34.  * MiNT will laugh at you. So will I.
  35.  */
  36.     char    devx[6];    /* real handles of the standard devices */
  37.     char    res2;        /* reserved */
  38.     char    defdrv;        /* default drv */
  39. #else
  40.     char    p_junk[8];
  41. #endif
  42.     long    p_undef[18];    /* scratch area... don't touch */
  43.     char    p_cmdlin[128];    /* command line image */
  44. } BASEPAGE;
  45.  
  46. extern    BASEPAGE    *_base;
  47.  
  48. #ifndef __NPROFIBUCH
  49. # define basepage basep
  50. #endif
  51.  
  52. #ifndef __NPURECDEF
  53. # define baspag basep
  54. # define BASPAG BASEPAGE
  55. #endif
  56.  
  57. /*
  58.  * General OS specific codes here
  59.  *
  60.  */
  61.  
  62. /*
  63.  * GEMDOS defines and structures
  64.  */
  65.  
  66. /* Structure used by Dfree() */
  67. typedef struct {
  68.     long b_free;    /* number of free clusters */
  69.     long b_total;    /* total number of clusters */
  70.     long b_secsiz;    /* number of bytes per sector */
  71.     long b_clsiz;    /* number of sectors per cluster */
  72. } _DISKINFO;
  73.  
  74. /* Structure returned by Fdatime() */
  75. typedef struct {
  76.   short time;
  77.   short date;
  78. } _DOSTIME;
  79.  
  80. /* Structure used by Fgetdta(), Fsetdta(), Fsfirst(), Fsnext() */
  81. typedef struct _dta {
  82.     char         dta_buf[21];    /* reserved */
  83.     char            dta_attribute;    /* file attribute */
  84.     unsigned short  dta_time;        /* file time stamp */
  85.     unsigned short  dta_date;        /* file date stamp */
  86.     long            dta_size;        /* file size */
  87.     char            dta_name[14];    /* file name */
  88. } _DTA;
  89.  
  90. /* Codes used with Fsfirst() */
  91.  
  92. #define        FA_RDONLY           0x01
  93. #define        FA_HIDDEN           0x02
  94. #define        FA_SYSTEM           0x04
  95. #define        FA_LABEL            0x08
  96. #define        FA_DIR              0x10
  97. #define        FA_CHANGED          0x20
  98.  
  99. /* Codes used with Pexec */
  100.  
  101. #define        PE_LOADGO           0           /* load & go */
  102. #define        PE_LOAD             3           /* just load */
  103. #define        PE_GO               4           /* just go */
  104. #define        PE_CBASEPAGE        5           /* just create basepage */
  105. /* Tos 1.4: like 4, but memory ownership changed to child, and freed
  106.    on exit
  107.  */
  108. #define        PE_GO_FREE          6           /* just go, then free */
  109.  
  110. #ifdef __MINT__
  111. /* ers: what exactly does mode 7 do ??? */
  112. #  define    PE_ASYNC_LOADGO       100           /* load and asynchronously go */
  113. #  define       PE_ASYNC_GO       104           /* asynchronously go         */
  114. #  define       PE_ASYNC_GO_FREE   106           /* asynchronously go and free */
  115. #  define       PE_OVERLAY       200           /* load and overlay         */
  116. #endif
  117.  
  118. /*
  119.  * BIOS defines and structures
  120.  */
  121.  
  122. /* Device codes for Bconin(), Bconout(), Bcostat(), Bconstat() */
  123. #define _PRT    0
  124. #define _AUX    1
  125. #define _CON    2
  126. #define _MIDI   3
  127. #define _IKBD   4
  128. #define _RAWCON 5
  129.  
  130. /* Structure returned by Getbpb() */
  131. typedef struct {
  132.   short recsiz;         /* bytes per sector */
  133.   short clsiz;          /* sectors per cluster */
  134.   short clsizb;         /* bytes per cluster */
  135.   short rdlen;          /* root directory size */
  136.   short fsiz;           /* size of file allocation table */
  137.   short fatrec;         /* startsector of second FAT */
  138.   short datrec;         /* first data sector */
  139.   short numcl;          /* total number of clusters */
  140.   short bflags;         /* some flags */
  141. } _BPB;
  142.  
  143. /* Structures used by Getmpb() */
  144.  
  145. /* Memory descriptor */
  146. typedef struct _md {
  147.     struct _md    *md_next;    /* next descriptor in the chain */
  148.     long     md_start;    /* starting address of block */
  149.     long     md_length;    /* length of the block */
  150.     long     md_owner;    /* owner's process descriptor */
  151. } _MD;
  152.  
  153. /* Memory parameter block */
  154. typedef struct {
  155.     _MD *mp_free;        /* free memory chunks */
  156.     _MD *mp_used;        /* used memory descriptors */
  157.     _MD *mp_rover;        /* rover memory descriptor */
  158. } _MPB;
  159.  
  160.  
  161. /*
  162.  * XBIOS defines and structures
  163.  */
  164.  
  165. /* Codes used with Cursconf() */
  166. #define CURS_HIDE       0
  167. #define CURS_SHOW       1
  168. #define CURS_BLINK      2
  169. #define CURS_NOBLINK    3
  170. #define CURS_SETRATE    4
  171. #define CURS_GETRATE    5
  172.  
  173. /* Structure returned by Iorec() */
  174. typedef struct {
  175.     char    *ibuf;
  176.     short   ibufsiz;
  177.     short   ibufhd;
  178.     short   ibuftl;
  179.     short   ibuflow;
  180.     short   ibufhi;
  181. } _IOREC;
  182.  
  183. /* Structure used by Initmouse() */
  184. typedef struct {
  185.     char    topmode;
  186.     char    buttons;
  187.     char    xparam;
  188.     char    yparam;
  189. } _PARAM;
  190.  
  191. /* Structure returned by Kbdvbase() */
  192. typedef struct {
  193.     void    (*midivec)    __PROTO((void));
  194.     void    (*vkbderr)    __PROTO((void));
  195.     void    (*vmiderr)    __PROTO((void));
  196.     void    (*statvec)    __PROTO((void *));
  197.     void    (*mousevec)    __PROTO((void *));
  198.     void    (*clockvec)    __PROTO((void *));
  199.     void    (*joyvec)    __PROTO((void *));
  200.     long    (*midisys)    __PROTO((void));
  201.     long    (*ikbdsys)    __PROTO((void));
  202.     char    kbstate;
  203. } _KBDVECS;
  204.  
  205. /* Structure returned by Keytbl() */
  206. typedef struct {
  207.     void *unshift;    /* pointer to unshifted keys */
  208.     void *shift;    /* pointer to shifted keys */
  209.     void *caps;        /* pointer to capslock keys */
  210. } _KEYTAB;
  211.  
  212. /* Structure used by Prtblk() */
  213. typedef struct
  214. {
  215.     void    *pb_scrptr;
  216.     short   pb_offset;
  217.     short   pb_width;
  218.     short   pb_height;
  219.     short   pb_left;
  220.     short   pb_right;
  221.     short   pb_screz;
  222.     short   pb_prrez;
  223.     void    *pb_colptr;
  224.     short   pb_prtype;
  225.     short   pb_prport;
  226.     void    *pb_mask;
  227. } _PBDEF;
  228.  
  229. /* Structure returned by Metainit() */
  230. typedef struct
  231. {
  232.     unsigned long drivemap;
  233.     char *version;
  234.     long reserved[2];
  235. } METAINFO;
  236.  
  237. /* Profibuch structure definitions */
  238.  
  239. #ifndef __NPROFIBUCH
  240.  
  241. #define DISKINFO _DISKINFO
  242. #define DOSTIME _DOSTIME
  243.  
  244. typedef struct {
  245.     char         dta_buf[21];    /* reserved */
  246.     char            d_attrib;        /* file attribute */
  247.     unsigned short  d_time;        /* file time stamp */
  248.     unsigned short  d_date;        /* file date stamp */
  249.     long            d_length;        /* file size */
  250.     char            d_fname[14];    /* file name */
  251. } DTA;
  252.  
  253. #define FA_DIREC FA_DIR
  254. #define FA_ARCH 0x20
  255. #define FA_ATTRIB (FA_DIREC|FA_RDONLY|FA_HIDDEN|FA_SYSTEM)
  256.  
  257. #define PRT _PRT
  258. #define AUX _AUX
  259. #define CON _CON
  260. #define MIDI _MIDI
  261. #define IKBD _IKBD
  262. #define RAWCON _RAWCON
  263.  
  264. #define BPB _BPB
  265.  
  266. typedef struct md {
  267.     struct md    *m_link;    /* next descriptor in the chain */
  268.     long     m_start;    /* starting address of block */
  269.     long     m_length;    /* length of the block */
  270.     BASEPAGE    *m_own;        /* owner's process descriptor */
  271. } MD;
  272.  
  273. typedef struct {
  274.     MD *mp_mfl;        /* free memory chunks */
  275.     MD *mp_mal;        /* used memory descriptors */
  276.     MD *mp_rover;    /* rover memory descriptor */
  277. } MPB;
  278.  
  279. #define IOREC _IOREC
  280.  
  281. #define PARAM _PARAM
  282. typedef struct {
  283.     short xmax;
  284.     short ymax;
  285.     short xinitial;
  286.     short yinitial;
  287. } EXTRA;
  288.  
  289. typedef struct {
  290.     void    (*midivec)    __PROTO((void));
  291.     void    (*vkbderr)    __PROTO((void));
  292.     void    (*vmiderr)    __PROTO((void));
  293.     void    (*statvec)    __PROTO((void *));
  294.     void    (*mousevec)    __PROTO((void *));
  295.     void    (*clockvec)    __PROTO((void *));
  296.     void    (*joyvec)    __PROTO((void *));
  297.     long    (*midisys)    __PROTO((void));
  298.     long    (*ikbdsys)    __PROTO((void));
  299.     char    drvstat;
  300. } KBDVECS;
  301.  
  302. typedef struct {
  303.     void *unshift;    /* pointer to unshifted keys */
  304.     void *shift;    /* pointer to shifted keys */
  305.     void *capslock;    /* pointer to capslock keys */
  306. } KEYTAB;
  307.  
  308. #define PBDEF _PBDEF
  309.  
  310. /* Structure used by Cconrs */
  311. typedef struct
  312. {
  313.     unsigned char maxlen;
  314.     unsigned char actuallen;
  315.     char    buffer[255];
  316. } LINE;
  317.  
  318. /* Structures used by Bconmap */
  319. #ifndef Bconin /* this does not work if system functions are macros */
  320. typedef struct {
  321.     short    (*Bconstat) ();
  322.     long    (*Bconin) ();
  323.     long    (*Bcostat) ();
  324.     void    (*Bconout) ();
  325.     long    (*Rsconf) ();
  326.     IOREC    *iorec;
  327. } MAPTAB;
  328. #else
  329. #define MAPTAB void
  330. #endif
  331.  
  332. typedef struct {
  333.     MAPTAB    *maptab;
  334.     short    maptabsize;
  335. } BCONMAP;
  336.  
  337. typedef struct _osheader
  338. {
  339.     unsigned short os_entry;   /* BRA to reset handler */
  340.     unsigned short os_version; /* TOS version number */
  341.     void           *reseth;    /* reset handler */
  342.     struct _osheader *os_beg;  /* OS base */
  343.     void           *os_end;    /* end of OS ram usage */
  344.     void           *os_rsv1;   /* reserved */
  345.     long           *os_magic;  /* GEM memory usage parm. block */
  346.     long           os_date;    /* Date of system build, BCD */
  347.     unsigned short os_conf;    /* OS configuration bits */
  348.     unsigned short os_dosdate; /* DOS-format date of systembuild */
  349. /* The following are available up from TOS 1.02 */
  350.     char           **p_root;   /* base of OS pool */
  351.     char           **kbshift;  /* keyboard shift state variable */
  352.     BASEPAGE       **p_run;    /* GEMDOS PID of current process */
  353.     void           *p_rsv2;    /* reserved */
  354. } OSHEADER;
  355.  
  356. /* These are given for compatibility with Pure C tos.h */
  357.  
  358. #ifndef __NPURECDEF
  359.  
  360. #define FA_READONLY     0x01
  361. #define FA_VOLUME       0x08
  362. #define FA_SUBDIR       0x10
  363. #define FA_ARCHIVE      0x20
  364. #define FO_READ         0
  365. #define FO_WRITE        1
  366. #define FO_RW           2
  367. #define KBDVBASE KBDVECS
  368.  
  369. typedef struct
  370. {
  371.     char    topmode;
  372.     char    buttons;
  373.     char    x_scale;
  374.     char    y_scale;
  375.     short   x_max;
  376.     short   y_max;
  377.     short   x_start;
  378.     short   y_start;
  379. } MOUSE;
  380.  
  381. typedef struct
  382. {
  383.     unsigned char ength;
  384.     char command_tail[128];
  385. } COMMAND;
  386.  
  387. #define __md md
  388.  
  389. typedef struct _syshdr
  390. {
  391.     unsigned os_entry;
  392.     unsigned os_version;
  393.     void *os_start;
  394.     struct _syshdr *os_base;
  395.     void *os_membot;
  396.     void *os_rsv1;
  397.     long *os_magic;
  398.     long os_gendat;
  399.     short os_palmode;
  400.     short os_gendatg;
  401.     void *_root;
  402.     long *kbshift;
  403.     BASPAG **_run;
  404.     void *p_rsv2;
  405. } SYSHDR;
  406.  
  407. #endif /* __PURECDEF */
  408.  
  409. #endif /* __NPROFIBUCH */
  410.  
  411.  
  412. /*
  413.  * os bindings
  414.  *
  415.  */
  416.  
  417. long    gemdos( void, ... );
  418. long    bios( void, ... );
  419. long    xbios( void, ... );
  420.  
  421. /* Gemdos prototypes */
  422.  
  423. void    Pterm0( void );
  424. long    Cconin( void );
  425. void    Cconout( int c );
  426. int     Cauxin( void );
  427. void    Cauxout( int c );
  428. int     Cprnout( int c );
  429. long    Crawio( int w );
  430. long    Crawcin( void );
  431. long    Cnecin( void );
  432. int     Cconws( const char *buf );
  433. void    Cconrs( LINE *buf );
  434. int     Cconis( void );
  435. long    Dsetdrv( int drv );
  436. int     Cconos( void );
  437. int     Cprnos( void );
  438. int     Cauxis( void );
  439. int     Cauxos( void );
  440. int     Dgetdrv( void );
  441. void    Fsetdta( _DTA *buf );
  442. long    Super( void *stack );
  443. unsigned int  Tgetdate( void );
  444. unsigned int  Tsetdate( unsigned int date );
  445. unsigned int  Tgettime( void );
  446. unsigned int  Tsettime( unsigned int time );
  447. _DTA    *Fgetdta( void );
  448. int     Sversion( void );
  449. void    Ptermres( long keepcnt, int retcode );
  450. int     Dfree( _DISKINFO *buf, int driveno );
  451. int     Dcreate( const char *path );
  452. int     Ddelete( const char *path );
  453. int     Dsetpath( const char *path );
  454. long    Fcreate( const char *filename, int attr );
  455. long    Fopen( const char *filename, int mode );
  456. int     Fclose( int handle );
  457. long    Fread( int handle, long count, void *buf );
  458. long    Fwrite( int handle, long count, void *buf );
  459. int     Fdelete( const char *filename );
  460. long    Fseek( long offset, int handle, int seekmode );
  461. int     Fattrib( const char *filename, int wflag, int attrib );
  462. long    Fdup( int handle );
  463. long    Fforce( int stch, int nonstdh );
  464. int     Dgetpath( char *path, int driveno );
  465. void    *Malloc( long number );
  466. int     Mfree( void *block );
  467. int     Mshrink( int zero, void *ptr, long size );
  468. #define Mshrink(ptr, size) Mshrink(0, ptr, size)
  469. long    Pexec( int mode, char *ptr1, void *ptr2, void *ptr3 );
  470. void    Pterm( int retcode );
  471. int     Fsfirst( const char *filename, int attr );
  472. int     Fsnext( void );
  473. int     Frename( int zero, const char *oldname, const char *newname );
  474. int     Fdatime( _DOSTIME *timeptr, int handle, int wflag );
  475.  
  476. /* GEMDOS extensions */
  477.  
  478. void    *Mxalloc( long number, int mode );
  479. long    Maddalt( void *start, long size );
  480.  
  481. /* Network Gemdos Extension */
  482.  
  483. long    Nversion( void );
  484. long    Frlock( int handle, long start, long count );
  485. long    Frunlock( int handle, long start );
  486. long    Flock( int handle, long count );
  487. long    Funlock( int handle );
  488. long    Fflush( int handle );
  489. long    Unlock( const char *path );
  490. long    Lock( const char *path );
  491.  
  492. /* BIOS */
  493.  
  494. void    Getmpb( _MPB *ptr );
  495. int     Bconstat( int dev );
  496. long    Bconin( int dev );
  497. void    Bconout( int dev, int c );
  498. long    Rwabs( int rwflag, void *buf, int cnt, int recnr, int dev );
  499. void    (*Setexc( int number, void (*exchdlr)() )) ();
  500. long    Tickcal( void );
  501. _BPB    *Getbpb( int dev );
  502. long    Bcostat( int dev );
  503. long    Mediach( int dev );
  504. long    Drvmap( void );
  505. long    Kbshift( int mode );
  506. #define Getshift() Kbshift(-1)
  507.  
  508. /* XBios */
  509.  
  510. void    Initmouse( int type, _PARAM *par, void (*mousevec)() );
  511. #define Initmous Initmouse
  512. void    *Ssbrk( int count );
  513. void    *Physbase( void );
  514. void    *Logbase( void );
  515. int     Getrez( void );
  516. void    Setscreen( void *laddr, void *paddr, int rez );
  517. void    Setpalette( void *pallptr );
  518. int     Setcolor( int colornum, int color );
  519. int     Floprd( void *buf, long filler, int devno, int sectno,
  520.                int trackno, int sideno, int count );
  521. int     Flopwr( void *buf, long filler, int devno, int sectno,
  522.                int trackno, int sideno, int count );
  523. int     Flopfmt( void *buf, long filler, int devno, int spt, int trackno,
  524.                 int sideno, int interlv, long magic, int virgin );
  525. void    Midiws( int cnt, void *ptr );
  526. void    Mfpint( int erno, void (*vector)() );
  527. _IOREC   *Iorec( int dev );
  528. long    Rsconf( int baud, int ctr, int ucr, int rsr, int tsr, int scr );
  529. _KEYTAB  *Keytbl( void *unshift, void *shift, void *capslock );
  530. long    Random( void );
  531. void    Protobt( void *buf, long serialno, int disktype, int execflag );
  532. int     Flopver( void *buf, long filler, int devno, int sectno,
  533.                 int trackno, int sideno, int count );
  534. void    Scrdmp( void );
  535. int     Cursconf( int func, int rate );
  536. void    Settime( unsigned long time );
  537. unsigned long  Gettime( void );
  538. void    Bioskeys( void );
  539. void    Ikbdws( int count, void *ptr );
  540. void    Jdisint( int number );
  541. void    Jenabint( int number );
  542. char    Giaccess( char data, int regno );
  543. void    Offgibit( int bitno );
  544. void    Ongibit( int bitno );
  545. void    Xbtimer( int timer, int control, int data, void (*vector)() );
  546. void    *Dosound( void *buf );
  547. int     Setprt( int config );
  548. _KBDVECS *Kbdvbase( void );
  549. int     Kbrate( int initial, int repeat );
  550. void    Prtblk( _PBDEF *par );
  551. void    Vsync( void );
  552. long    Supexec( long (*func)() );
  553. #define Supexec(func) Supexec((long (*) ()) func)
  554. void    Puntaes( void );
  555. int     Floprate( int devno, int newrate );
  556. void    Metainit( METAINFO *buffer) ;
  557. int     Blitmode( int mode );
  558.  
  559. /* TOS030 XBios */
  560. int     DMAread( long sector, int count, void *buffer, int devno );
  561. int     DMAwrite( long sector, int count, void *buffer, int devno );
  562. int     NVMaccess( int opcode, int start, int count, void *buffer );
  563. long    Bconmap( int devno );
  564. int     Esetshift( int shftMode );
  565. #define EsetShift Esetshift
  566. int     Egetshift( void );
  567. #define EgetShift Egetshift
  568. int     EsetBank( int bankNum );
  569. int     EsetColor( int colorNum, int color );
  570. void    EsetPalette( int colorNum, int count, int *palettePtr );
  571. void    EgetPalette( int colorNum, int count, int *palettePtr );
  572. int     EsetGray( int swtch );
  573. int     EsetSmear( int swtch );
  574.  
  575. #endif
  576.  
  577.