home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / System / MorphOS / Developer / include / public / quark / message.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-02  |  8.3 KB  |  360 lines

  1. #ifndef    QUARK_MESSAGE_H
  2. #define    QUARK_MESSAGE_H
  3.  
  4. typedef unsigned long long    q_mid_t;
  5.  
  6. /* the next line is fixed by SED when the file
  7.  * is copied over to public
  8.  */
  9. typedef void            *q_message_t;
  10.  
  11. #define QMSGPORTTAG_DUMMY    (0x2000)
  12.  
  13. /* Sequence: QMSGPORTTAG_NAME, char*
  14.  * Function: Create
  15.  *           defines the public name of the port.
  16.  */
  17. #define    QMSGPORTTAG_NAME        (QMSGPORTTAG_DUMMY + 0x1)
  18.  
  19. /* Sequence: QMSGPORTTAG_TYPE, u_int32_t
  20.  * Function: Create
  21.  *           defines the general access rights for the port.
  22.  */
  23. #define    QMSGPORTTAG_TYPE        (QMSGPORTTAG_DUMMY + 0x2)
  24.  
  25. /* Sequence: QMSGPORTTAG_ALLOWSEND, bool_t (Default is TRUE)
  26.  * Function: Create
  27.  *           allows SendMessage() for the port
  28.  */
  29.  
  30. #define    QMSGPORTTAG_ALLOWSEND    (QMSGPORTTAG_DUMMY + 0x3)
  31.  
  32. /* Sequence: QMSGPORTTAG_ALLOWREPLY, bool_t (Default is TRUE)
  33.  * Function: Create
  34.  *           allows ReplyMessage() for the port
  35.  */
  36.  
  37. #define    QMSGPORTTAG_ALLOWREPLY    (QMSGPORTTAG_DUMMY + 0x4)
  38.  
  39. /* Sequence: QMSGPORTTAG_MAXDATASIZE, u_int32_t
  40.  * Function: Create
  41.  *           sets a limit for message databodies.
  42.  *           If the size is too big the msg is denied.
  43.  */
  44.  
  45. #define    QMSGPORTTAG_MAXDATASIZE    (QMSGPORTTAG_DUMMY + 0x5)
  46.  
  47. /* Sequence: QMSGPORTTAG_SIGNAL, u_int32_t*
  48.  * Function: Create
  49.  *           returns the port`s signal
  50.  */
  51. #define    QMSGPORTTAG_SIGNAL    (QMSGPORTTAG_DUMMY + 0x6)
  52.  
  53. /* Sequence: QMSGPORTTAG_TID, q_tid_t*
  54.  * Function: Get
  55.  *           returns the port`s thread tid
  56.  */
  57. #define    QMSGPORTTAG_TID        (QMSGPORTTAG_DUMMY + 0x7)
  58.  
  59. /* Sequence: QMSGPORTTAG_ERROR, u_int32_t*
  60.  * Function: returns the error code.
  61.  *           (not supported yet)
  62.  */
  63. #define    QMSGPORTTAG_ERROR    (QMSGPORTTAG_DUMMY + 0x10)
  64.  
  65.  
  66. /*
  67.  * QMSGPORTTAG_TYPE
  68.  */
  69. #define    QMSGPORTTYPE_LOCAL    0
  70. #define    QMSGPORTTYPE_CLAN    1
  71. #define    QMSGPORTTYPE_MACHINE    2
  72. #define    QMSGPORTTYPE_NET    3
  73.  
  74.  
  75.  
  76.  
  77. #define QMESSAGETAG_DUMMY    (0x3000)
  78.  
  79. /* Sequence: QMESSAGETAG_LINK
  80.  *   Result: void    *Message
  81.  * Function: Set/Get
  82.  *           Link a msg with another message. The to be linked message
  83.  *           is added with a FIFO system to the root message.
  84.  *           On first look this looks weird but only on first look.
  85.  *  Example:
  86.  *           If an application does scsi io and this an io job
  87.  *           unit runs into an error the full error information
  88.  *           are only available until another job is done so the
  89.  *           the full error context must be handled in synchron.
  90.  *           Basicly 2 different io jobs must then be executed in
  91.  *           synchron...the io job and a request sense operation.
  92.  *           As the result space of a ReplyMsg doesn't always provide
  93.  *           enough space why not (pseudo-send) a direct followup msg
  94.  *           to the replied job msg. Normal sending a weird msg may
  95.  *           confuse the application but folding extended messages inside
  96.  *           of the return message is imho an elegant solution to this
  97.  *           problem.
  98.  *
  99.  */
  100. #define    QMESSAGETAG_LINK            (QMESSAGETAG_DUMMY+0x1)
  101.  
  102. /* Sequence: QMESSAGETAG_TARGETPORT, MID*
  103.  *   Result: 0, real result is passed in the MID* ptr.
  104.  * Function: Get only
  105.  *           Get the MID | TID of the target port
  106.  */
  107. #define    QMESSAGETAG_TARGETPORT        (QMESSAGETAG_DUMMY+0x2)
  108.  
  109. /* Sequence: QMESSAGETAG_REPLYPORT, MID*
  110.  *   Result: 0, real result is passed in the MID* ptr.
  111.  * Function: Get only
  112.  *           Get the MID | TID of the replyport
  113.  */
  114. #define    QMESSAGETAG_REPLYPORT        (QMESSAGETAG_DUMMY+0x3)
  115.  
  116. /* Sequence: QMESSAGETAG_ARG1
  117.  *   Result: Arg1
  118.  * Function: Set/Get
  119.  *           Get the arg1 argument
  120.  */
  121. #define    QMESSAGETAG_ARG1            (QMESSAGETAG_DUMMY+0x4)
  122.  
  123. /* Sequence: QMESSAGETAG_ARG2
  124.  *   Result: Arg2
  125.  *           Get the arg2 argument
  126.  */
  127. #define    QMESSAGETAG_ARG2            (QMESSAGETAG_DUMMY+0x5)
  128.  
  129. /* Sequence: QMESSAGETAG_ARG3
  130.  *   Result: Arg3
  131.  * Function: Set/Get
  132.  *           Get the arg3 argument
  133.  */
  134. #define    QMESSAGETAG_ARG3            (QMESSAGETAG_DUMMY+0x6)
  135.  
  136.  
  137.  
  138. /* Sequence: QMESSAGETAG_LENGTH
  139.  *   Result: Length
  140.  * Function: Get only
  141.  *           Get the length argument.
  142.  *           
  143.  */
  144. #define    QMESSAGETAG_LENGTH        (QMESSAGETAG_DUMMY+0x7)
  145.  
  146. /* Sequence: QMESSAGETAG_DATA, void *Dest, u_int32_t Length
  147.  *   Result: Length, 0 for the Set operation indicates error.
  148.  * Function: Set/Get
  149.  *           (Get)
  150.  *           Copies the data out of the message to the
  151.  *           destination buffer you specified with the
  152.  *           length you specified.
  153.  *
  154.  *           (Set)
  155.  *           Copies the data into the buffer. Makes only
  156.  *           sense before a ReplyMessage.
  157.  */
  158. #define    QMESSAGETAG_DATA            (QMESSAGETAG_DUMMY+0x8)
  159.  
  160. /* Sequence: QMESSAGETAG_FREE
  161.  *   Result: Success
  162.  * Function: Set only
  163.  *           Free unnecessary data resources. For example if you send a
  164.  *           huge message and the message`s internal buffer isn`t needed
  165.  *           anymore.
  166.  */
  167. #define    QMESSAGETAG_FREE            (QMESSAGETAG_DUMMY+0x9)
  168.  
  169. /* Sequence: QMESSAGETAG_ERROR
  170.  *   Result: Success
  171.  * Function: Get only
  172.  *           Get an error id if some message operation failed.
  173.  */
  174. #define    QMESSAGETAG_ERROR        (QMESSAGETAG_DUMMY+0xa)
  175.  
  176. /* Sequence: QMESSAGETAG_ROUTED
  177.  *   Result: Success
  178.  * Function: Get only
  179.  *           Get the state of a message if it was routed
  180.  *           and the receiver thread isn't the real target.
  181.  */
  182. #define    QMESSAGETAG_ROUTED        (QMESSAGETAG_DUMMY+0xb)
  183.  
  184. /* Sequence: QMESSAGETAG_INFO, struct QMessageInfo*
  185.  *   Result: Success
  186.  * Function: Set/Get 
  187.  *           Set/Get the info of a message.
  188.  */
  189. #define    QMESSAGETAG_INFO            (QMESSAGETAG_DUMMY+0xc)
  190.  
  191.  
  192.  
  193.  
  194.  
  195. struct QMessageInfo
  196. {
  197.     q_mid_t        ReplyPort;
  198.     q_mid_t        TargetPort;
  199.     u_int32_t    Flags;
  200.     u_int32_t    Arg1;
  201.     u_int32_t    Arg2;
  202.     u_int32_t    Arg3;
  203.     u_int32_t    Length;
  204. /*
  205.  * If Data != NULL, then it`s a
  206.  * simple DataPtr. This may be
  207.  * a local taskspace ptr for inner
  208.  * taskspace messages or a Ptr
  209.  * for a mapped in shared memory.
  210.  * The flags then specify the case
  211.  * more clearly.
  212.  */
  213.     void        *Data;
  214.  
  215. /*
  216.  * BufferPtr for a buffer copy
  217.  * or NULL.
  218.  */
  219.     void        *Buffer;
  220. /*
  221.  * Max Length of the buffer
  222.  */
  223.     u_int32_t    BufferLength;
  224. };
  225.  
  226. typedef struct QMessageInfo    *q_messageinfo_t;
  227.  
  228.  
  229. /*
  230.  * DataPtr is pointing to the data
  231.  * in the local taskspace
  232.  */
  233. #define    QMESSAGEINFOFLAGB_PTR        16
  234. #define    QMESSAGEINFOFLAGF_PTR        (1<<QMESSAGEINFOFLAGB_PTR)
  235.  
  236. /*
  237.  * DataPtr is pointing to gated
  238.  * mmu pages.
  239.  */
  240. #define    QMESSAGEINFOFLAGB_MAPPED    17
  241. #define    QMESSAGEINFOFLAGF_MAPPED    (1<<QMESSAGEINFOFLAGB_MAPPED)
  242.  
  243. /*
  244.  * Buffercopy overflow
  245.  */
  246. #define    QMESSAGEINFOFLAGB_OVERFLOW    18
  247. #define    QMESSAGEINFOFLAGF_OVERFLOW    (1<<QMESSAGEINFOFLAGB_OVERFLOW)
  248.  
  249.  
  250.  
  251. /*
  252.  * Std Format for public message ports/tids
  253.  * for Arg1..Arg3
  254.  * Send:
  255.  * Arg1
  256.  * is always a methodid that specifies
  257.  * the meaning of the message.
  258.  *
  259.  * Arg2
  260.  * is depending on the methodid
  261.  *
  262.  * Arg3
  263.  * is depending on the methodid
  264.  *
  265.  * Reply:
  266.  * Arg1
  267.  * is always the return status(ok,error)
  268.  *
  269.  * Arg2
  270.  * is depending on the message result
  271.  *
  272.  * Arg3
  273.  * is depending on the message result
  274.  */
  275.  
  276. /* System message ids start at this
  277.  * point.
  278.  */
  279. #define    QMESSAGEMETHOD_SYSTEM    0x0
  280. #define    QMESSAGEMETHOD_QUERY        (QMESSAGEMETHOD_SYSTEM+0x1)
  281. #define    QMESSAGEMETHOD_INIT        (QMESSAGEMETHOD_SYSTEM+0x1)
  282.  
  283. /***********************************************************************
  284.  * Defines the (scope) list in which all following
  285.  * linked jobs are operating.
  286.  * Jobs are linked through the message link system
  287.  * Arg1 == QMESSAGEMETHOD_EXCEPTION
  288.  * Arg2 == ExceptionType...depends on the CPU
  289.  * Arg3 == 0
  290.  * Data == 0
  291.  *
  292.  * Reply:
  293.  * None..msg sent with no replyport. So when your exception
  294.  * handler replies it it gets deleted
  295.  */
  296. #define    QMESSAGEMETHOD_EXCEPTION    (QMESSAGEMETHOD_SYSTEM+0x1000)
  297.  
  298.  
  299. /* User message ids start at this
  300.  * point
  301.  */
  302. #define    QMESSAGEMETHOD_USER        0x80000000
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317. #define    QMSGERROR_OK            0
  318. #define    QMSGERROR_MEMORY        1
  319. #define    QMSGERROR_UNKNOWNMID        2
  320. #define    QMSGERROR_UNKNOWNTID        3
  321.  
  322. /* Illegal MID id..not a MID and not a TID
  323.  * Plain and simple..illegal
  324.  */
  325. #define    QMSGERROR_ILLEGALMID        4
  326.  
  327. /* A message which wasn't sent can't be
  328.  * replied
  329.  */
  330. #define    QMSGERROR_MSGCANTBEREPLIED    5
  331.  
  332. /* The next msgport doesn't allow SendMessage
  333.  */
  334.  
  335. #define    QMSGERROR_SENDDISABLED        6
  336.  
  337. /* The next msgport doesn't allow ReplyMessage.
  338.  */
  339. #define    QMSGERROR_REPLYDISABLED        7
  340.  
  341. /* Msg doesn`t belong to the current task space
  342.  */
  343. #define    QMSGERROR_MSGPIDERROR        8
  344.  
  345. /* Msg can't be linked to itself
  346.  */
  347. #define    QMSGERROR_LINKNOTPOSSIBLE    9
  348.  
  349. /* Msg body length is too large
  350.  */
  351. #define    QMSGERROR_TOOLARGE        10
  352.  
  353.  
  354.  
  355.  
  356. #define    QMSGERROR_NOTIMPLEMENTED    100
  357.  
  358. #endif
  359.  
  360.