home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / boothdr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  6.8 KB  |  211 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_BOOTHDR_H
  11. #define _SYS_BOOTHDR_H
  12.  
  13. #ident    "@(#)/usr/include/sys/boothdr.h.sl 1.1 4.0 12/08/90 5665 AT&T-USL"
  14. /*
  15.  * Each object file existing in the /boot directory contains an 
  16.  * optional header containing the following information.  This header
  17.  * is created by the mkboot(1M) program from the /etc/master data base.
  18.  */
  19.  
  20. #define    OFFSET(ptr,base)    ((offset) ((char*)(ptr) - (char*)(base)))
  21. #define    POINTER(offset,base)    ((char*)(base) + (offset))
  22.  
  23. #define    ROUNDUP(p)        (((int)(p)+sizeof(int)-1) & ~(sizeof(int)-1))
  24.  
  25. typedef    unsigned short        offset;
  26.  
  27. #define    PARAMNMSZ    8    /* maximun size of a parameter name in /etc/master data base */
  28. #define    PREFIXLEN    4    /* length of module prefix */
  29.  
  30. /*
  31.  * Optional header for object files (all offsets are computed
  32.  * from the base of this structure)
  33.  */
  34.  
  35. struct    master
  36.     {
  37.     unsigned short        magic;        /* "3b"; to distinguish from UNIX a.out header */
  38.     unsigned short        flag;        /* /etc/master: flags */
  39.     unsigned char        vec;        /* /etc/master: first vector for integral device */
  40.     unsigned char        nvec;        /* /etc/master: number of interrupt vectors */
  41.     char            prefix[PREFIXLEN+1];    /* /etc/master: module prefix, '\0' terminated */
  42.     unsigned long         soft;        /* /etc/master: software module external major number */
  43.     unsigned long        ndev;        /* /etc/master: number of devices/controller */
  44.     unsigned char        ipl;        /* /etc/master: interrupt priority level */
  45.     short            ndep;        /* number of dependent modules */
  46.     short            nparam;        /* number of parameters */
  47.     short            nrtn;        /* number of routine names */
  48.     short            nvar;        /* number of variables */
  49.     offset            o_depend;    /* ==> additional modules required */
  50.     offset            o_param;    /* ==> parameters for this module */
  51.     offset            o_routine;    /* ==> routines to be stubbed if module is not loaded */
  52.     offset            o_variable;    /* ==> variables to be generated */
  53.     };
  54.  
  55. /*
  56.  *    Magic number to distinguish from UNIX optional a.out header
  57.  */
  58. #define    MMAGIC    0x3362
  59.  
  60. /*
  61.  *    FLAG bits
  62.  */
  63. #define    KERNEL    0x8000        /* this is a kernel a.out file */
  64. #define    FUNDRV    0x0200        /* (f) framework/stream type device */
  65. #define    FUNMOD    0x0100        /* (m) framework/stream module */
  66. #define    ONCE    0x0080        /* (o) allow only one specification of device */
  67. #define    REQADDR    0x0040        /* (a) xx_addr array must be generated */
  68. #define    TTYS    0x0020        /* (t) cdevsw[].d_ttys mustpoint to first generated data structure */
  69. #define    REQ    0x0010        /* (r) required device */
  70. #define    BLOCK    0x0008        /* (b) block type device */
  71. #define    CHAR    0x0004        /* (c) character type device */
  72. #define    SOFT    0x0002        /* (s) software device driver */
  73. #define    NOTADRV    0x0001        /* (x) not a driver; a configurable module */
  74. #define FSTYP    0x0400        /* (j) file system module */
  75. #define EXECTYP 0x800        /* (e) exec system module */
  76. #define SCHEDCLASS 0x1000    /* (d) scheduler class module */
  77. #define NEWDRV    0x2000        /* (n) new driver interface */
  78.  
  79. /*
  80.  * Dependencies: if the current module is loaded, then the following
  81.  *               modules must also be loaded
  82.  */
  83. struct    depend
  84.     {
  85.     offset        name;        /* module name */
  86.     };
  87.  
  88. /*
  89.  * Parameters: each parameter defined for this module is saved to allow
  90.  *             references from other modules
  91.  */
  92. struct    param
  93.     {
  94.     char        name[PARAMNMSZ];/* parameter name */
  95.     char        type;        /* string ("), integer (N) */
  96.     union    {
  97.         int number;        /* integer value */
  98.         offset string;        /* ==> string */
  99.         }
  100.             value;
  101.     };
  102.  
  103. /*
  104.  * Routines: if the current module is not loaded, then the following
  105.  *           routines must be stubbed off
  106.  */
  107. struct    routine
  108.     {
  109.     char        id;        /*  routine type */
  110.     offset        name;        /* ==> routine name */
  111.     };
  112.  
  113. /*
  114.  *    Routine types
  115.  */
  116. #define RNULL        0        /* void rtn() {} */
  117. #define RNOSYS        1        /* rtn() { return(nosys()); } */
  118. #define RNODEV        2        /* rtn() { return(nodev()); } */
  119. #define RTRUE        3        /* rtn() { return(1); } */
  120. #define RFALSE        4        /* rtn() { return(0); } */
  121. #define RFSNULL     5
  122. #define RFSTRAY        6
  123. #define NOPKG       7
  124. #define NOREACH        8
  125. #define RNULLMAG    9
  126. #define RNOEXEC        10
  127. #define RNOCORE        11
  128. #define RNODEVFLAG    12
  129.  
  130. /*
  131.  * Variables: each variable to be generated by the boot program is
  132.  *            described by this structure
  133.  */
  134. struct    variable
  135.     {
  136.     int        size;        /* total size of single element */
  137.     offset        name;        /* ==> variable name */
  138.     offset        dimension;    /* ==> array dimension; NULL if not an array */
  139.     short        ninit;        /* number of elements to be initialized */
  140.     offset        initializer;    /* ==> initialization */
  141.     };
  142.  
  143. /*
  144.  * Initializer structure: a variable is initialized by an array of initializer
  145.  *                        elements; each element contains the type of the field
  146.  *                        and either the initial value, or the offset to the
  147.  *                        expression which, when evaluated, will be the initial
  148.  *                        value.
  149.  */
  150. struct    format
  151.     {
  152.     unsigned char    type;        /* flags and type of the field */
  153.     unsigned char    strlen;        /* %<strlen>c */
  154.  
  155.                     /* type&FEXPR:  ==> expression */
  156.     offset        value;        /* type&FSKIP:  %<number> */
  157.                     /* otherwise:   literal value */
  158.     };
  159.  
  160. /*
  161.  * Format types
  162.  */
  163. #define    FSKIP    0x80            /* %<n>  no initialization; skip `value' bytes */
  164. #define    FEXPR    0x40            /* POINTER((offset)value, &opthdr) -> expression */
  165. #define    FTYPE    0x3F            /* One of:                     */
  166. #define    FCHAR    1            /*    %c    character        */
  167. #define    FSHORT    2            /*    %s    short integer    */
  168. #define    FINT    3            /*    %i    integer          */
  169. #define    FLONG    4            /*    %l    long integer     */
  170. #define    FSTRING    5            /*    %<n>c character string */
  171.  
  172. /*
  173.  * Expressions are stored in prefix polish notation.  Each element of
  174.  * the expression is one of the elements below.
  175.  *
  176.  *        operator:  +, -, * or /
  177.  *        function:  <, or >    (min or max)
  178.  *        builtin:   #Dname\0
  179.  *        builtin:   #Cname\0
  180.  *        builtin:   #Sname\0
  181.  *        builtin:   #Mname\0
  182.  *        sizeof:    #name\0
  183.  *        address:   &name\0
  184.  *        string:    "string\0
  185.  *        identifier:Iname\0
  186.  *        number:    Ninteger
  187.  */
  188.  
  189. #define    ELENGTH    256
  190.  
  191. union    element
  192.     {
  193.     char        operator;        /* +, -, * or / */
  194.     char        function;        /* < or > */
  195.     char        nD[ELENGTH];        /* D number of subdevices */
  196.     char        nC[ELENGTH];        /* C number of controllers */
  197.     char        nS[ELENGTH];        /* S number of logical units */
  198.     char        nM[ELENGTH];        /* M internal major number */
  199.     char        size_of[ELENGTH];    /* # name */
  200.     char        address_of[ELENGTH];    /* & name */
  201.     char        string[ELENGTH];    /* " name */
  202.     char        identifier[1+PARAMNMSZ];/* I name */
  203.     unsigned char    literal[1+sizeof(int)];    /* N integer */
  204.     };
  205.  
  206. #define    XBUMP(p,what)    (union element *)((int)(p) + ((sizeof((p)->what)==ELENGTH)? \
  207.                             1+strlen((char *)((p)->what)) : \
  208.                             sizeof((p)->what)))
  209.  
  210. #endif    /* _SYS_BOOTHDR_H */
  211.