home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / MIDICOM.LZH / MC_UTILS / MC_XFS / FILESYS.H < prev    next >
C/C++ Source or Header  |  1993-07-25  |  21KB  |  606 lines

  1. /*
  2.  * NOTE: This file only works if sizeof(int) == 2!
  3.  * UNLESS: you have an ANSI compiler and use prototypes
  4.  *
  5.  * Copyright 1991,1992 Eric R. Smith. This file may be re-distributed
  6.  * as long as this notice remains intact.
  7.  */
  8.  
  9. #ifndef _filesys_h
  10. #define _filesys_h
  11.  
  12. #define NAME_MAX 32
  13. #define PATH_MAX 128
  14.  
  15. struct filesys;        /* forward declaration */
  16. struct devdrv;        /* ditto */
  17.  
  18. typedef struct f_cookie {
  19.     struct filesys *fs;    /* filesystem that knows about this cookie */
  20.     unsigned int    dev;        /* device info (e.g. Rwabs device number) */
  21.     unsigned int    aux;        /* extra data that the file system may want */
  22.     long    index;        /* this+dev uniquely identifies a file */
  23. } fcookie;
  24.  
  25. /* structure for opendir/readdir/closedir */
  26. typedef struct dirstruct {
  27.     fcookie fc;        /* cookie for this directory */
  28.     unsigned int    index;        /* index of the current entry */
  29.     unsigned int    flags;        /* flags (e.g. tos or not) */
  30. #define TOS_SEARCH    0x01
  31.     char    fsstuff[60];    /* anything else the file system wants */
  32.                 /* NOTE: this must be at least 45 bytes */
  33. } DIR;
  34.  
  35. /* structure for getxattr */
  36. typedef struct xattr {
  37.     unsigned int    mode;
  38. /* file types */
  39. #define S_IFMT    0170000        /* mask to select file type */
  40. #define S_IFCHR    0020000        /* BIOS special file */
  41. #define S_IFDIR    0040000        /* directory file */
  42. #define S_IFREG 0100000        /* regular file */
  43. #define S_IFIFO 0120000        /* FIFO */
  44. #define S_IMEM    0140000        /* memory region or process */
  45. #define S_IFLNK    0160000        /* symbolic link */
  46.  
  47. /* special bits: setuid, setgid, sticky bit */
  48. #define S_ISUID    04000
  49. #define S_ISGID 02000
  50. #define S_ISVTX    01000
  51.  
  52. /* file access modes for user, group, and other*/
  53. #define S_IRUSR    0400
  54. #define S_IWUSR 0200
  55. #define S_IXUSR 0100
  56. #define S_IRGRP 0040
  57. #define S_IWGRP    0020
  58. #define S_IXGRP    0010
  59. #define S_IROTH    0004
  60. #define S_IWOTH    0002
  61. #define S_IXOTH    0001
  62. #define DEFAULT_DIRMODE (0777)
  63. #define DEFAULT_MODE    (0666)
  64.     long    index;
  65.     unsigned int    dev;
  66.     unsigned int    reserved1;
  67.     unsigned int    nlink;
  68.     unsigned int    uid;
  69.     unsigned int    gid;
  70.     long    size;
  71.     long    blksize, nblocks;
  72.     int    mtime, mdate;
  73.     int    atime, adate;
  74.     int    ctime, cdate;
  75.     int    attr;
  76.     int    reserved2;
  77.     long    reserved3[2];
  78. } XATTR;
  79.  
  80. typedef struct fileptr {
  81.     int                links;    /* number of copies of this descriptor */
  82.     unsigned int    flags;    /* file open mode and other file flags */
  83.     long            pos;    /* position in file */
  84.     long            devinfo;    /* device driver specific info */
  85.     fcookie            fc;        /* file system cookie for this file */
  86.     struct devdrv     *dev;     /* device driver that knows how to deal with this */
  87.     struct fileptr     *next;    /* link to next fileptr for this file */
  88. } FILEPTR;
  89.  
  90. /* lock structure */
  91. struct flock {
  92.     int l_type;            /* type of lock */
  93. #define F_RDLCK        O_RDONLY
  94. #define F_WRLCK        O_WRONLY
  95. #define F_UNLCK        3
  96.     int l_whence;            /* SEEK_SET, SEEK_CUR, SEEK_END */
  97.     long l_start;            /* start of locked region */
  98.     long l_len;            /* length of locked region */
  99.     int l_pid;            /* pid of locking process
  100.                         (F_GETLK only) */
  101. };
  102.  
  103. /* LOCK structure used by the kernel internally */
  104.  
  105. typedef struct ilock {
  106.     struct flock l;
  107.     struct ilock *next;
  108.     long  reserved[4];
  109. } LOCK;
  110.  
  111. typedef struct devdrv{
  112.     long cdecl    (*mcopen)    (FILEPTR *f);
  113.     long cdecl    (*mcwrite)    (FILEPTR *f,const char *buf, long bytes);
  114.     long cdecl    (*mcread)    (FILEPTR *f, char *buf, long bytes);
  115.     long cdecl    (*mclseek)    (FILEPTR *f, long where, int whence);
  116.     long cdecl    (*mcioctl)    (FILEPTR *f, int mode, void *buf);
  117.     long cdecl    (*mcdatime)    (FILEPTR *f, int *timeptr, int rwflag);
  118.     long cdecl    (*mcclose)    (FILEPTR *f, int pid);
  119.     long cdecl    (*mcselect)    (FILEPTR *f, long proc, int mode);
  120.     void cdecl    (*mcunselect) (FILEPTR *f, long proc, int mode);
  121.     long    reserved[3];    /* reserved for future use */
  122. } DEVDRV;
  123.  
  124. typedef struct filesys {
  125.     struct    filesys    *next;    /* link to next file system on chain */
  126.     long    fsflags;
  127. #define FS_KNOPARSE    0x01    /* kernel shouldn't do parsing */
  128. #define FS_CASESENSITIVE    0x02    /* file names are case sensitive */
  129. #define FS_NOXBIT    0x04    /* if a file can be read, it can be executed */
  130. #define    FS_LONGPATH    0x08    /* file system understands "size" argument to */
  131.  
  132.     long    cdecl    (*root) (int drv, fcookie *fc);
  133.     long    cdecl    (*lookup) (fcookie *dir, const char *name, fcookie *fc);
  134.     long    cdecl    (*creat) (fcookie *dir, const char *name, unsigned mode,int attrib, fcookie *fc);
  135.     DEVDRV * cdecl    (*getdev) (fcookie *fc, long *devspecial);
  136.     long    cdecl    (*getxattr) (fcookie *fc, XATTR *xattr);
  137.     long    cdecl    (*chattr) (fcookie *fc, int attr);
  138.     long    cdecl    (*chown) (fcookie *fc, int uid, int gid);
  139.     long    cdecl    (*chmode) (fcookie *fc, unsigned int mode);
  140.     long    cdecl    (*mkdir) (fcookie *dir, const char *name, unsigned mode);
  141.     long    cdecl    (*rmdir) (fcookie *dir, const char *name);
  142.     long    cdecl    (*remove) (fcookie *dir, const char *name);
  143.     long    cdecl    (*getname) (fcookie *root, fcookie *dir,char *pathname,int size);
  144.     long    cdecl    (*rename) (fcookie *olddir, char *oldname,fcookie *newdir, const char *newname);
  145.     long    cdecl    (*opendir) (DIR *dirh, int tosflag);
  146.     long    cdecl    (*readdir) (DIR *dirh, char *nm, int nmlen, fcookie *fc);
  147.     long    cdecl    (*rewinddir) (DIR *dirh);
  148.     long    cdecl    (*closedir) (DIR *dirh);
  149.     long    cdecl    (*pathconf) (fcookie *dir, int which);
  150.     long    cdecl    (*dfree) (fcookie *dir, long *buf);
  151.     long    cdecl    (*writelabel) (fcookie *dir, const char *name);
  152.     long    cdecl    (*readlabel) (fcookie *dir, char *name, int namelen);
  153.     long    cdecl    (*symlink) (fcookie *dir,const char *name,const char *to);
  154.     long    cdecl    (*readlink) (fcookie *dir, char *buf, int len);
  155.     long    cdecl    (*hardlink) (fcookie *fromdir,fcookie *todir,const char *fromname,    const char *toname);
  156.     long    cdecl    (*fscntl) (fcookie *dir,const char *name,int cmd,long arg);
  157.     long    cdecl    (*dskchng) (int drv);
  158.     long    cdecl    (*release) (fcookie *);
  159.     long    cdecl    (*dupcookie) (fcookie *new, fcookie *old);
  160. } FILESYS;
  161.  
  162. /*
  163.  * this is the structure passed to loaded file systems to tell them
  164.  * about the kernel
  165.  */
  166.  
  167. typedef long (*_LongFunc)();
  168.  
  169. struct kerinfo {
  170.     short    maj_version;    /* kernel version number */
  171.     short    min_version;    /* minor kernel version number */
  172.     unsigned    default_perm;    /* default file permissions */
  173.     short    reserved1;    /* room for expansion */
  174.  
  175. /* OS functions */
  176.     _LongFunc    *bios_tab;    /* pointer to the BIOS entry points */
  177.     _LongFunc    *dos_tab;    /* pointer to the GEMDOS entry points */
  178.  
  179. /* media change vector */
  180.     void    cdecl (*drvchng) (unsigned);
  181.  
  182. /* Debugging stuff */
  183.     void    cdecl (*trace) (const char *, ...);
  184.     void    cdecl (*debug) (const char *, ...);
  185.     void    cdecl (*alert) (const char *, ...);
  186.     void    cdecl (*fatal) (const char *, ...);
  187.  
  188. /* memory allocation functions */
  189.     void *    cdecl (*kmalloc) (long);
  190.     void    cdecl (*kfree) (void *);
  191.     void *    cdecl (*umalloc) (long);
  192.     void    cdecl (*ufree) (void *);
  193.  
  194. /* utility functions for string manipulation */
  195.     int    cdecl (*strnicmp) (const char *, const char *, int);
  196.     int    cdecl (*stricmp) (const char *, const char *);
  197.     char *    cdecl (*strlwr) (char *);
  198.     char *    cdecl (*strupr) (char *);
  199.     int    cdecl (*sprintf) (char *, const char *, ...);
  200.  
  201. /* utility functions for manipulating time */
  202.     void    cdecl (*millis_time) (unsigned long, short *);
  203.     long    cdecl (*unixtim) (unsigned, unsigned);
  204.     long    cdecl (*dostim) (long);
  205.  
  206. /* utility functions for dealing with pauses, or for putting processes
  207.  * to sleep
  208.  */
  209.     void    cdecl (*nap) (unsigned);
  210.     void    cdecl (*sleep) (int que, long cond);
  211.     void    cdecl (*wake) (int que, long cond);
  212.     void    cdecl (*wakeselect) (long param);
  213.  
  214. /* file system utility functions */
  215.     int    cdecl (*denyshare) (FILEPTR *, FILEPTR *);
  216.  
  217. /* reserved for future use */
  218.     LOCK *    cdecl (*denylock) (LOCK *, LOCK *);
  219.     long    res2[9];
  220. };
  221.  
  222. #ifndef NEWWAY
  223. typedef struct _context {
  224.     long    regs[15];    /* registers d0-d7, a0-a6 */
  225.     long    usp;        /* user stack pointer (a7) */
  226.     short    sr;        /* status register */
  227.     long    pc;        /* program counter */
  228.     long    ssp;        /* supervisor stack pointer */
  229.     long    term_vec;    /* GEMDOS terminate vector (0x102) */
  230. /*
  231.  * AGK: if running on a TT and the user is playing with the FPU then we
  232.  * must save and restore the context. We should also consider this for
  233.  * I/O based co-processors, although this may be difficult due to
  234.  * possibility of a context switch in the middle of an I/O handshaking
  235.  * exchange.
  236.  */
  237.     unsigned char    fstate[216];    /* FPU internal state */
  238.     long    fregs[3*8];    /* registers fp0-fp7 */
  239.     long    fctrl[3];    /* FPCR/FPSR/FPIAR */
  240.     char    ptrace;        /* trace exception is pending */
  241.     char    pad1;        /* junk */
  242.     long    iar;        /* unused */
  243.     short    res[4];        /* unused, reserved */
  244. /*
  245.  * Saved CRP and TC values.  These are necessary for memory protection.
  246.  */
  247.  
  248.     /*crp_reg crp;*/            /* 64 bits */
  249.     long    crp[2];
  250.     /*tc_reg tc;*/            /* 32 bits */
  251.     long    tc;
  252. /*
  253.  * AGK: for long (time-wise) co-processor instructions (FMUL etc.), the
  254.  * FPU returns NULL, come-again with interrupts allowed primitives. It
  255.  * is highly likely that a context switch will occur in one of these if
  256.  * running a mathematically intensive application, hence we must handle
  257.  * the mid-instruction interrupt stack. We do this by saving the extra
  258.  * 3 long words and the stack format word here.
  259.  */
  260.     unsigned short    sfmt;    /* stack frame format identifier */
  261.     short    internal[42];    /* internal state -- see framesizes[] for size */
  262. } CONTEXT;
  263.  
  264. #define PROC_CTXTS    2
  265. #define SYSCALL        0    /* saved context from system call    */
  266. #define CURRENT        1    /* current saved context        */
  267. #define PNAMSIZ        8    /* no. of characters in a process name */
  268.  
  269. #define DOM_TOS        0    /* TOS process domain */
  270. #define DOM_MINT    1    /* MiNT process domain */
  271. #define MIN_HANDLE    (-5)    /* minimum handle number        */
  272. #define MIN_OPEN    6    /* 0..MIN_OPEN-1 are reserved for system */
  273. #define MAX_OPEN    32    /* max. number of open files for a proc    */
  274. #define    NSIG        31        /* number of signals recognized */
  275. #define SSTKSIZE    8000    /* size of supervisor stack (in bytes)     */
  276. #define ISTKSIZE    2000    /* size of interrupt stack (in bytes)    */
  277. #define STKSIZE        (ISTKSIZE + SSTKSIZE)
  278.  
  279. typedef struct proc {
  280.     long    sysstack;        /* must be first        */
  281.     CONTEXT    ctxt[PROC_CTXTS];    /* must be second        */
  282.  
  283. /* this is stuff that the public can know about */
  284.     long    magic;            /* validation for proc struct    */
  285.  
  286. /*    BASEPAGE *base;*/            /* process base page        */
  287.     long     *base;            /* process base page        */
  288.     short    pid, ppid, pgrp;
  289.     short    ruid;            /* process real user id     */
  290.     short    rgid;            /* process real group id     */
  291.     short    euid, egid;        /* effective user and group ids */
  292.  
  293.     unsigned
  294.     unsigned memflags;        /* e.g. malloc from alternate ram */
  295.     short    pri;            /* base process priority     */
  296.     short    wait_q;            /* current process queue    */
  297.  
  298. /* note: wait_cond should be unique for each kind of condition we might
  299.  * want to wait for. Put a define below, or use an address in the
  300.  * kernel as the wait condition to ensure uniqueness.
  301.  */
  302.     long    wait_cond;        /* condition we're waiting on    */
  303.                     /* (also return code from wait) */
  304.  
  305. #define WAIT_MB        0x3a140001L    /* wait_cond for p_msg call    */
  306. #define WAIT_SEMA    0x3a140003L    /* wait_cond for p_semaphore    */
  307.  
  308.     /* (all times are in milliseconds) */
  309.     /* usrtime must always follow systime */
  310.     unsigned long    systime;        /* time spent in kernel        */
  311.     unsigned long    usrtime;        /* time spent out of kernel    */
  312.     unsigned long    chldstime;        /* children's kernel time     */
  313.     unsigned long    chldutime;        /* children's user time        */
  314.  
  315.     unsigned long    maxmem;            /* max. amount of memory to use */
  316.     unsigned long    maxdata;        /* max. data region for process */
  317.     unsigned long    maxcore;        /* max. core memory for process */
  318.     unsigned long    maxcpu;            /* max. cpu time to use     */
  319.  
  320.     short    domain;            /* process domain (TOS or UNIX)    */
  321.  
  322.     short    curpri;            /* current process priority    */
  323. #define MIN_NICE -20
  324. #define MAX_NICE 20
  325.  
  326. /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
  327.  * programs should *not* try to read this stuff via the U:\PROC dir.
  328.  */
  329.  
  330.     char    name[PNAMSIZ+1];    /* process name            */
  331. /*    TIMEOUT    *alarmtim;    */    /* alarm() event        */
  332.     long    *alarmtim;        /* alarm() event        */
  333.     short    slices;            /* number of time slices before this
  334.                        process gets to run again */
  335.  
  336.     short    bconmap;        /* Bconmap mapping        */
  337.     FILEPTR *midiout;        /* MIDI output            */
  338.     FILEPTR *midiin;        /* MIDI input            */
  339.     FILEPTR    *prn;            /* printer            */
  340.     FILEPTR *aux;            /* auxiliary tty        */
  341.     FILEPTR    *control;        /* control tty            */
  342.     FILEPTR    *handle[MAX_OPEN];    /* file handles            */
  343.  
  344.     unsigned char    fdflags[MAX_OPEN];    /* file descriptor flags    */
  345.  
  346.     unsigned    num_reg;        /* number of memory regions allocated */
  347. /*    MEMREGION **mem;    */    /* allocated memory regions    */
  348.     long     **mem;        /* allocated memory regions    */
  349. /*    virtaddr *addr;        */    /* addresses of regions        */
  350.     long    *addr;            /* addresses of regions        */
  351.  
  352.     unsigned long    sigpending;        /* pending signals        */
  353.     unsigned long    sigmask;        /* signals that are masked    */
  354.     unsigned long    sighandle[NSIG];    /* signal handlers        */
  355.     unsigned    sigflags[NSIG];        /* signal flags            */
  356.     unsigned long    sigextra[NSIG];        /* additional signals to be masked
  357.                        on delivery     */
  358.     char    *mb_ptr;        /* p_msg buffer ptr        */
  359.     long    mb_long1, mb_long2;    /* p_msg storage        */
  360.     long    mb_mbid;        /* p_msg id being waited for    */
  361.     short    mb_mode;        /* p_msg mode being waiting in    */
  362.     short    mb_writer;        /* p_msg pid of writer of msg    */
  363.  
  364.     short    curdrv;            /* current drive        */
  365.     fcookie root[NUM_DRIVES];    /* root directories        */
  366.     fcookie    curdir[NUM_DRIVES];    /* current directory        */
  367.  
  368.     long    usrdata;        /* user-supplied data        */
  369.     unsigned    umask;            /* file creation mask        */
  370.  
  371.     DTABUF    *dta;            /* current DTA            */
  372. #define NUM_SEARCH    6        /* max. number of searches    */
  373.     DTABUF *srchdta[NUM_SEARCH];    /* for Fsfirst/next        */
  374.     DIR    srchdir[NUM_SEARCH];    /* for Fsfirst/next        */
  375.     long    srchtim[NUM_SEARCH];    /* for Fsfirst/next        */
  376.     
  377.     DIR    *searches;        /* open directory searches    */
  378.  
  379.     long    txtsize;        /* size of text region (for fork()) */
  380.  
  381.     long    cdecl         (*criticerr) (long l); /* critical error handler    */
  382.     void    *logbase;        /* logical screen base        */
  383.  
  384.     struct proc *ptracer;        /* process which is tracing this one */
  385.     short    ptraceflags;        /* flags for process tracing */
  386.     short    starttime;        /* time and date when process    */
  387.     short    startdate;        /* was started            */
  388.  
  389.     void    *page_table;        /* rounded page table pointer    */
  390.     void    *pt_mem;        /* original kmalloc'd block for above */
  391.  
  392.     unsigned long    exception_pc;        /* pc at time of bombs        */
  393.     unsigned long    exception_ssp;        /* ssp at time of bomb (e.g. bus error)    */
  394.     unsigned long    exception_tbl;        /* table in use at exception time */
  395.     unsigned    exception_mmusr;    /* result from ptest insn    */
  396.     unsigned long    exception_addr;        /* access address from stack    */
  397.  
  398.     struct    proc *q_next;        /* next process on queue    */
  399.     struct     proc *gl_next;        /* next process in system    */
  400.     char    stack[STKSIZE+4];    /* stack for system calls    */
  401. } PROC;
  402. #endif
  403.  
  404. /* flags for open() modes */
  405. #define O_RWMODE      0x03    /* isolates file read/write mode */
  406. #    define O_RDONLY    0x00
  407. #    define O_WRONLY    0x01
  408. #    define O_RDWR    0x02
  409. #    define O_EXEC    0x03    /* execute file; used by kernel only */
  410.  
  411. #define O_SHMODE    0x70    /* isolates file sharing mode */
  412. #    define O_COMPAT    0x00    /* compatibility mode */
  413. #    define O_DENYRW    0x10    /* deny both read and write access */
  414. #    define O_DENYW    0x20    /* deny write access to others */
  415. #    define O_DENYR    0x30    /* deny read access to others */
  416. #    define O_DENYNONE 0x40    /* don't deny any access to others */
  417.  
  418. #define O_NOINHERIT    0x80    /* this is currently ignored by MiNT */
  419.  
  420. #define O_NDELAY    0x100    /* don't block for i/o on this file */
  421. #define O_CREAT        0x200    /* create file if it doesn't exist */
  422. #define O_TRUNC        0x400    /* truncate file to 0 bytes if it does exist */
  423. #define O_EXCL        0x800    /* fail open if file exists */
  424.  
  425. #define O_USER        0x0fff    /* isolates user-settable flag bits */
  426.  
  427. #define O_GLOBAL    0x1000    /* for Fopen: opens a global file handle */
  428.  
  429. /* kernel mode bits -- the user can't set these! */
  430. #define O_TTY        0x2000    /* FILEPTR refers to a terminal */
  431. #define O_HEAD        0x4000    /* FILEPTR is the master side of a fifo */
  432. #define O_LOCK        0x8000    /* FILEPTR has had locking Fcntl's performed */
  433.  
  434.  
  435. /* GEMDOS file attributes */
  436.  
  437. /* macros to be applied to FILEPTRS to determine their type */
  438. #define is_terminal(f) (f->flags & O_TTY)
  439.  
  440. /* lseek() origins */
  441. #define    SEEK_SET    0        /* from beginning of file */
  442. #define    SEEK_CUR    1        /* from current location */
  443. #define    SEEK_END    2        /* from end of file */
  444.  
  445. /* The requests for Dpathconf() */
  446. #define DP_IOPEN    0    /* internal limit on # of open files */
  447. #define DP_MAXLINKS    1    /* max number of hard links to a file */
  448. #define DP_PATHMAX    2    /* max path name length */
  449. #define DP_NAMEMAX    3    /* max length of an individual file name */
  450. #define DP_ATOMIC    4    /* # of bytes that can be written atomically */
  451. #define DP_TRUNC    5    /* file name truncation behavior */
  452. #    define    DP_NOTRUNC    0    /* long filenames give an error */
  453. #    define    DP_AUTOTRUNC    1    /* long filenames truncated */
  454. #    define    DP_DOSTRUNC    2    /* DOS truncation rules in effect */
  455.  
  456. #define DP_MAXREQ    5    /* highest legal request */
  457.  
  458. /* Dpathconf and Sysconf return this when a value is not limited
  459.    (or is limited only by available memory) */
  460.  
  461. #define UNLIMITED    0x7fffffffL
  462.  
  463. /* various character constants and defines for TTY's */
  464. #define MiNTEOF 0x0000ff1a    /* 1a == ^Z */
  465.  
  466. /* defines for tty_read */
  467. #define RAW    0
  468. #define COOKED    0x1
  469. #define NOECHO    0
  470. #define ECHO    0x2
  471. #define ESCSEQ    0x04        /* cursor keys, etc. get escape sequences */
  472.  
  473. /* constants for various Fcntl commands */
  474. /* constants for Fcntl calls */
  475. #define F_DUPFD        0        /* handled by kernel */
  476. #define F_GETFD        1        /* handled by kernel */
  477. #define F_SETFD        2        /* handled by kernel */
  478. #    define FD_CLOEXEC    1    /* close on exec flag */
  479.  
  480. #define F_GETFL        3        /* handled by kernel */
  481. #define F_SETFL        4        /* handled by kernel */
  482. #define F_GETLK        5
  483. #define F_SETLK        6
  484.  
  485. #define FSTAT        (('F'<< 8) | 0)    /* handled by kernel */
  486. #define FIONREAD    (('F'<< 8) | 1)
  487. #define FIONWRITE    (('F'<< 8) | 2)
  488. #define TIOCGETP    (('T'<< 8) | 0)
  489. #define TIOCSETP    (('T'<< 8) | 1)
  490. #define TIOCSETN    TIOCSETP
  491. #define TIOCGETC    (('T'<< 8) | 2)
  492. #define TIOCSETC    (('T'<< 8) | 3)
  493. #define TIOCGLTC    (('T'<< 8) | 4)
  494. #define TIOCSLTC    (('T'<< 8) | 5)
  495. #define TIOCGPGRP    (('T'<< 8) | 6)
  496. #define TIOCSPGRP    (('T'<< 8) | 7)
  497. #define TIOCFLUSH    (('T'<< 8) | 8)
  498. #define TIOCSTOP    (('T'<< 8) | 9)
  499. #define TIOCSTART    (('T'<< 8) | 10)
  500. #define TIOCGWINSZ    (('T'<< 8) | 11)
  501. #define TIOCSWINSZ    (('T'<< 8) | 12)
  502. #define TIOCGXKEY    (('T'<< 8) | 13)
  503. #define TIOCSXKEY    (('T'<< 8) | 14)
  504.  
  505. #define PPROCADDR    (('P'<< 8) | 1)
  506. #define PBASEADDR    (('P'<< 8) | 2)
  507. #define PCTXTSIZE    (('P'<< 8) | 3)
  508.  
  509. /* terminal control constants (tty.sg_flags) */
  510. #define T_CRMOD        0x0001
  511. #define T_CBREAK    0x0002
  512. #define T_ECHO        0x0004
  513. #define T_RAW        0x0010
  514. #define T_TOS        0x0080
  515. #define T_TOSTOP    0x0100
  516. #define T_XKEY        0x0200        /* Fread returns escape sequences for
  517.                        cursor keys, etc. */
  518.  
  519. /* the following are terminal status flags (tty.state) */
  520. /* (the low byte of tty.state indicates a part of an escape sequence still
  521.  * hasn't been read by Fread, and is an index into that escape sequence)
  522.  */
  523. #define TS_ESC        0x00ff
  524. #define TS_HOLD        0x1000        /* hold (e.g. ^S/^Q) */
  525. #define TS_COOKED    0x8000        /* interpret control chars */
  526.  
  527. /* structures for terminals */
  528. struct tchars {
  529.     char t_intrc;
  530.     char t_quitc;
  531.     char t_startc;
  532.     char t_stopc;
  533.     char t_eofc;
  534.     char t_brkc;
  535. };
  536.  
  537. struct ltchars {
  538.     char t_suspc;
  539.     char t_dsuspc;
  540.     char t_rprntc;
  541.     char t_flushc;
  542.     char t_werasc;
  543.     char t_lnextc;
  544. };
  545.  
  546. struct sgttyb {
  547.     char sg_ispeed;
  548.     char sg_ospeed;
  549.     char sg_erase;
  550.     char sg_kill;
  551.     unsigned int sg_flags;
  552. };
  553.  
  554. struct winsize {
  555.     int    ws_row;
  556.     int    ws_col;
  557.     int    ws_xpixel;
  558.     int    ws_ypixel;
  559. };
  560.  
  561. struct xkey {
  562.     int    xk_num;
  563.     char    xk_def[8];
  564. };
  565.  
  566. struct tty {
  567.     int        pgrp;        /* process group of terminal */
  568.     int        state;        /* terminal status, e.g. stopped */
  569.     int        use_cnt;    /* number of times terminal is open */
  570.     int        res1;        /* reserved for future expansion */
  571.     struct sgttyb     sg;
  572.     struct tchars     tc;
  573.     struct ltchars     ltc;
  574.     struct winsize    wsiz;
  575.     long        rsel;        /* selecting process for read */
  576.     long        wsel;        /* selecting process for write */
  577.     char        *xkey;        /* extended keyboard table */
  578.     long        rsrvd[3];    /* reserved for future expansion */
  579. };
  580.  
  581. /* defines and declarations for Dcntl operations */
  582.  
  583. #define DEV_INSTALL    0xde02
  584. #define DEV_NEWBIOS    0xde01
  585. #define DEV_NEWTTY    0xde00
  586.  
  587. struct dev_descr {
  588.     DEVDRV    *driver;
  589.     int    dinfo;
  590.     int    flags;
  591.     struct tty *tty;
  592.     long    reserved[4];
  593. };
  594.  
  595. /* defines for TOS attribute bytes */
  596. #ifndef FA_RDONLY
  597. #define           FA_RDONLY           0x01
  598. #define           FA_HIDDEN           0x02
  599. #define           FA_SYSTEM           0x04
  600. #define           FA_LABEL               0x08
  601. #define           FA_DIR               0x10
  602. #define           FA_CHANGED           0x20
  603. #endif
  604.  
  605. #endif _filesys_h
  606.