home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / apl2 / aplap.h__ / aplap.h
Encoding:
C/C++ Source or Header  |  1993-12-15  |  13.7 KB  |  298 lines

  1. /*-m-aplap-----------------------------------------------------------
  2.  *
  3.  * Module Name: aplap.h
  4.  *
  5.  * Descriptive Name: SVP interfaces for Auxiliary Processors
  6.  *
  7.  * Copyright:   APL2/6000               Version 1.2
  8.  *              APL2 for OS/2           Version 1.0
  9.  *              APL2 for Sun Solaris    Version 1.0
  10.  *              Licensed Materials - Property of IBM
  11.  *              (C) COPYRIGHT IBM CORP. 1994
  12.  *
  13.  * Function: Provide structures and constants for Auxiliary Processors
  14.  *           to interface with the SVP
  15.  *
  16.  * Notes:
  17.  *
  18.  *    Dependencies: None
  19.  *
  20.  *    Restrictions: None
  21.  *
  22.  * Module Type: Header
  23.  *
  24.  * Change Activity:
  25.  *
  26.  *-Z----------------------------------------------------------------*/
  27.  
  28. /*******************************************************************/
  29. /* Extended ID Structure                                           */
  30. /*******************************************************************/
  31. struct xid {                 /* Extended ID structure               */
  32.     unsigned long pparent;   /*  Parent's Parent ID                 */
  33.     unsigned long parent;    /*  Parent ID                          */
  34.     unsigned long procid;    /*  Processor ID                       */
  35.     unsigned long hostid;    /*  Host ID (TCP/IP address)           */
  36.     unsigned long res1;      /*  Reserved                           */
  37.     unsigned long res2;      /*  Reserved                           */
  38.     char userid[8];          /*  User ID                            */
  39.     char surrid[8];          /*  Surrogate ID                       */
  40.     };
  41.  
  42. struct flags {
  43.     unsigned int b1:1;
  44.     unsigned int b2:1;
  45.     unsigned int b3:1;
  46.     unsigned int b4:1;
  47.     unsigned int b5:1;
  48.     unsigned int b6:1;
  49.     unsigned int b7:1;
  50.     unsigned int b8:1;
  51.     unsigned int b9:1;
  52.     unsigned int b10:1;
  53.     unsigned int b11:1;
  54.     unsigned int b12:1;
  55.     unsigned int b13:1;
  56.     unsigned int b14:1;
  57.     unsigned int b15:1;
  58.     unsigned int b16:1;
  59.     unsigned int b17:1;
  60.     unsigned int b18:1;
  61.     unsigned int b19:1;
  62.     unsigned int b20:1;
  63.     unsigned int b21:1;
  64.     unsigned int b22:1;
  65.     unsigned int b23:1;
  66.     unsigned int b24:1;
  67.     unsigned int b25:1;
  68.     unsigned int b26:1;
  69.     unsigned int b27:1;
  70.     unsigned int b28:1;
  71.     unsigned int b29:1;
  72.     unsigned int b30:1;
  73.     unsigned int b31:1;
  74.     unsigned int b32:1;
  75.     };
  76.  
  77. /*******************************************************************/
  78. /* Processor Request Block                                         */
  79. /*******************************************************************/
  80. struct prb {
  81.     short req;                 /*  Request code              */
  82.     short rc;                  /*  Return code               */
  83.     short reason;              /*  Reason code               */
  84.     short res1;                /*  Reserved                  */
  85.     struct xid xid;            /*  Extended ID               */
  86.     void *user;                /*  User field                */
  87.     unsigned long emask;       /*  Event mask                */
  88.     unsigned long ntoken;      /*  Notification token        */
  89.     unsigned long pcbx;        /*  PCB index                 */
  90.     unsigned long socket;      /*  Socket number             */
  91.     unsigned long socksem;     /*  Socket semaphore          */
  92.     char ** argv;              /*  Command line args ptr     */
  93.     int argc;                  /*  Count of args             */
  94.     void *res2;                /*  Reserved                  */
  95.     struct flags prbflags;     /*  Processor flags           */
  96.     char reserved[32];         /*  Reserved                  */
  97.     };
  98.  
  99. #define PRBFOFFS  prbflags.b1  /*  Offers outstanding        */
  100. #define PRBFNPOST prbflags.b3  /*  Don't post                */
  101. #define PRBFNOTRC prbflags.b4  /*  Don't trace               */
  102.  
  103. /*******************************************************************/
  104. /* Share Request Block                                             */
  105. /*******************************************************************/
  106. struct srb {
  107.     short req;                 /*  Request code              */
  108.     short rc;                  /*  Return code               */
  109.     short reason;              /*  Reason code               */
  110.     short res1;                /*  Reserved                  */
  111.     void *user;                /*  User field                */
  112.     unsigned long ntoken;      /*  Notification token        */
  113.     unsigned long pcbx;        /*  PCB index                 */
  114.     unsigned long scbx;        /*  SCB index                 */
  115.     struct xid pxid;           /*  Extended Partner ID       */
  116.     long osn;                  /*  Offer sequence number     */
  117.     long vlen;                 /*  Length of value           */
  118.     void *value;               /*  Pointer to value          */
  119.     unsigned long pvrba;       /*  Reserved                  */
  120.     unsigned short acv;        /*  Access control            */
  121.     unsigned short state;      /*  State                     */
  122.     unsigned short coupling;   /*  Coupling                  */
  123.     unsigned short res2;       /*  Reserved                  */
  124.     struct flags srbflags;     /*  Flags                     */
  125.     unsigned long socket;      /*  socket number             */
  126.     unsigned long socksem;     /*  socket send sem-id (UNIX) */
  127.     char reserved[32];         /*  Reserved                  */
  128.     char name[256];            /*  Variable name             */
  129.     };
  130.  
  131. #define SRBFIGNV  srbflags.b1  /*  Ignore value waiting      */
  132. #define SRBFNEWQ  srbflags.b2  /*  Request new event queue   */
  133. #define SRBFNPOST srbflags.b4  /*  Don't post                */
  134. #define SRBFNOFFR srbflags.b5  /*  No offer back on retract  */
  135.  
  136. /*******************************************************************/
  137. /* Wait Request Block                                              */
  138. /*******************************************************************/
  139. struct wrb {
  140.    short req;                  /* Request code               */
  141.    short rc;                   /* Return code                */
  142.    short reason;               /* Reason code                */
  143.    short res1;                 /* Reserved                   */
  144.    void *user;                 /* User field                 */
  145.    unsigned long ntoken;       /* Notification token         */
  146.    unsigned long pcbx;         /* PCB index                  */
  147.    unsigned long scbx;         /* SCB index                  */
  148.    unsigned long osn;          /* offer sequence number      */
  149.    long timeout;               /* Timeout value              */
  150.    unsigned long event;        /* Event code                 */
  151.    struct flags wrbflags;      /* Flags                      */
  152.    char reserved[16];          /* Reserved                   */
  153.    };
  154.  
  155. #define WRBFFLUSH wrbflags.b1  /*  Flush event queue         */
  156.  
  157. /*******************************************************************/
  158. /* SVP requests                                                    */
  159. /*******************************************************************/
  160. #define SVINIT         0
  161. #define SVSIGNON       1
  162. #define SVSIGNOFF      2
  163. #define SVSCAN         3
  164. #define SVSHARE        4
  165. #define SVSEEACV       5
  166. #define SVSETACV       6
  167. #define SVREF          7
  168. #define SVSPEC         8
  169. #define SVRELEASE      11
  170. #define SVRETRACT      12
  171. #define SVSTATE        13
  172. #define SVQUERY        14
  173. #define SVPREREF       15
  174. #define SVPRESPEC      16
  175. #define SVEVENT        17
  176. #define SVPOST         18
  177. #define SVGETTOKEN     19
  178.  
  179.  
  180. /*******************************************************************/
  181. /* SVP return codes                                                */
  182. /*******************************************************************/
  183. #define SVP_ERROR_SYSTEM  - 3     /* System Error                  */
  184. #define SVP_SMNOSPACE     - 2     /* No space for object           */
  185. #define SVP_INTERLOCK     - 1     /* variable interlocked          */
  186. #define SVP_OK              0     /* A-OK                          */
  187. #define SVP_UNAVAILABLE     1     /* SVP is unavailable            */
  188. #define SVP_ERROR_PROTEXCP  2     /* Protection exception          */
  189. #define SVP_ERROR_NSO       3     /* Not signed on                 */
  190. #define SVP_ERROR_ASO       4     /* Already signed on             */
  191. #define SVP_ERROR_PUSED     5     /* Processor in use              */
  192. #define SVP_ERROR_SHRSELF   8     /* Share with self               */
  193. #define SVP_ERROR_VTL       10    /* Value too large               */
  194. #define SVP_ERROR_NOVALUE   11    /* No value                      */
  195. #define SVP_ERROR_NOOFFER   12    /* No offer found                */
  196. #define SVP_ERROR_INVREQ    13    /* Invalid request               */
  197. #define SVP_ERROR_VOS       14    /* Unread value exists           */
  198. #define SVP_ERROR_INVARG    15    /* Invalid argument              */
  199. #define SVP_ERROR_NOEVENT   16    /* No event found                */
  200. #define SVP_ERROR_TIMEOUT   17    /* Timeout on SVEVENT            */
  201. #define SVP_ERROR_INTERRUPT 18    /* Interrupt on wait             */
  202.  
  203. /*******************************************************************/
  204. /* SVP reason codes                                                */
  205. /*******************************************************************/
  206. #define SVP_ERRSYS_GETNMEM   100   /* Error getting named sh mem    */
  207. #define SVP_ERRSYS_FREEMEM   101   /* Error freeing sh mem          */
  208. #define SVP_ERRSYS_SUBFREE   102   /* Error freeing pcb/scb space   */
  209. #define SVP_ERRSYS_NOPCBS    103   /* Unable to obtain new PCB      */
  210. #define SVP_ERRSYS_NOSCBS    104   /* Unable to obtain new SCB      */
  211. #define SVP_ERRSYS_GETESEM   105   /* Error creating event sem      */
  212. #define SVP_ERRSYS_POSTQUEUE 106   /* Error on post of queue        */
  213. #define SVP_ERRSYS_WAITESEM  107   /* Error on wait for semaphore   */
  214. #define SVP_ERRSYS_RESETESEM 108   /* Reset semaphore error         */
  215. #define SVP_ERRSYS_OPENSEM   109   /* Error opening a semaphore     */
  216. #define SVP_ERRSYS_REQSEM    110   /* Error requesting sm semaphore */
  217. #define SVP_ERRSYS_RELSEM    111   /* Error releasing sm semaphore  */
  218. #define SVP_ERRSYS_CREATESEM 112   /* Error creating sm semaphore   */
  219. #define SVP_ERRSYS_GETXID    113   /* Error in side file lookup     */
  220. #define SVP_ERRSYS_GETQUEUE  114   /* Error creating msg queue      */
  221. #define SVP_ERRSYS_FREESEM   115   /* Error freeing semaphore       */
  222. #define SVP_ERRSYS_FREEQUEUE 116   /* Error freeing queue           */
  223. #define SVP_ERRSYS_WAITQUEUE 117   /* Error waiting on queue        */
  224. #define SVP_ERRSYS_PEEKQUEUE 118   /* Error peeking queue           */
  225. #define SVP_ERRSYS_OPENFAIL  119   /* Error opening file            */
  226. #define SVP_ERRSYS_QEMPTY    120   /* Error queue is empty          */
  227. #define SVP_ERRSYS_PURGEQUE  121   /* Error purging queue           */
  228.  
  229. #define SVP_ERRPRF_FNF       201   /* Profile not found             */
  230. #define SVP_ERRPRF_SNF       202   /* Svopid not found              */
  231. #define SVP_ERRPRF_INVF      203   /* Invalid file                  */
  232. #define SVP_ERRPRF_IOERR     204   /* I/O Error                     */
  233. #define SVP_ERRPRF_INVWC     205   /* Invalid wild card             */
  234. #define SVP_ERRPRF_NOAUTH    206   /* Authorization failed          */
  235.  
  236. #define SVP_ARGERR_INVPCBX   301   /* Invalid PCB Index             */
  237. #define SVP_ARGERR_INVSCBX   302   /* Invalid SCB Index             */
  238. #define SVP_ARGERR_INVNAME   303   /* Invalid Variable name         */
  239. #define SVP_ARGERR_NOLOCK    304   /* Lock not held on post-op      */
  240. #define SVP_ARGERR_INVTOKEN  305   /* Invalid token on SVEVENT      */
  241. #define SVP_ARGERR_INVPARENT 306   /* Parent not signed on          */
  242. #define SVP_ARGERR_INVOSN    307   /* Invalid Offer Sequence Number */
  243.  
  244. /*******************************************************************/
  245. /* SVP event codes                                                 */
  246. /*******************************************************************/
  247. #define SVP_EVENT_OFFEREX     0x01     /* Offer extended           */
  248. #define SVP_EVENT_OFFERAC     0x02     /* Offer accepted           */
  249. #define SVP_EVENT_SMAVAIL     0x04     /* Shared Memory Available  */
  250. #define SVP_EVENT_PRETRACT    0x08     /* Partner retracted        */
  251. #define SVP_EVENT_PSETACV     0x10     /* Partner set ACV          */
  252. #define SVP_EVENT_PSPEC       0x20     /* Partner specified        */
  253. #define SVP_EVENT_PREF        0x40     /* Partner referenced       */
  254. #define SVP_EVENT_FSPEC       0x80     /* Partner failed spec      */
  255. #define SVP_EVENT_FREF        0x100    /* Partner failed ref       */
  256. #define SVP_EVENT_SHUTDOWN    0x200    /* SVP shutdown             */
  257. #define SVP_EVENT_PRELEASE    0x400    /* Partner released var     */
  258.  
  259.  
  260. /*******************************************************************/
  261. /* Function Prototypes                                             */
  262. /*******************************************************************/
  263. #ifndef __OS2__
  264. #define _System
  265. #endif
  266.  
  267. int _System svpp(struct prb *);
  268. int _System svps(struct srb *);
  269. int _System svpe(struct wrb *);
  270. void _System svsleep(unsigned long);
  271. unsigned long _System aplobjsize(char, char, unsigned long);
  272. char * _System GetEnvOpt(char *, int, char **);
  273.  
  274. #ifdef __OS2__
  275. #define BeginThread(x,y,z) _beginthread(x,NULL,65536,y)
  276. #else
  277. long BeginThread(void (*fn)(void *), void *, unsigned long);
  278. #endif
  279.  
  280.  
  281. /* sv state    */
  282. #define INITSTATE      0x03
  283. #define PARTSPEC       0x05
  284. #define USERSPEC       0x0A
  285.  
  286. /* sv coupling */
  287. #define ISSHARED       0x02
  288. #define ISOFFER        0x01
  289. #define ISNTSHAR       0x00
  290.  
  291. /* sv acv      */
  292. #define ACVMYSET       0x08
  293. #define ACVPARTSET     0x04
  294. #define ACVMYUSE       0x02
  295. #define ACVPARTUSE     0x01
  296.  
  297.  
  298.