Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /***************************************************************************************************
  2.  *  Copyright (C) Vasiliy Kosenko (vkos), 2009                                                     *
  3.  *  This program is free software: you can redistribute it and/or modify it under the terms of the *
  4.  *  GNU General Public License as published by the Free Software Foundation, either version 3      *
  5.  *  of the License, or (at your option) any later version.                                         *
  6.  *                                                                                                 *
  7.  *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;      *
  8.  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See  *
  9.  *  the GNU General Public License for more details.                                               *
  10.  *                                                                                                 *
  11.  *  You should have received a copy of the GNU General Public License along with this program.     *
  12.  *  If not, see <http://www.gnu.org/licenses/>.                                                    *
  13.  ***************************************************************************************************/
  14.  
  15. #ifndef _IPC_H_
  16. #define _IPC_H_
  17.  
  18. #include "defs.h"
  19.  
  20. #define IPC_BUFFER_SIZE 0x1000
  21.  
  22. #define IPC_MAX_ERRORS 10
  23.  
  24. #define IPC_NO_MEMORY 1
  25. #define IPC_CANNOT_SET_MASK 2
  26.  
  27. #define IPC_NO_AREA 1
  28. #define IPC_BUFFER_LOCKED 2
  29. #define IPC_OVERFLOW 3
  30. #define IPC_NO_TID 4
  31.  
  32. /*
  33.  * Data types
  34.  */
  35.  
  36. //
  37. typedef struct kolibri_IPC_area {
  38.         unsigned long lock;
  39.         unsigned long size;
  40. } IPCArea;
  41.  
  42. typedef struct kolibri_IPC_area kolibri_IPC_area_t;
  43.  
  44. //
  45. typedef struct kolibri_IPC_message {
  46.         unsigned long tid;
  47.         unsigned long length;
  48. } Message;
  49.  
  50. typedef struct kolibri_IPC_message kolibri_IPC_message_t;
  51.  
  52. /*
  53.  * High level IPC functions
  54.  */
  55.  
  56. extern IPCArea *ipc_area;
  57.  
  58. int IPCInit(void);
  59.  
  60. int IPCSend(int tid, void *message, int length);
  61.  
  62. bool IPCCheck(void);
  63.  
  64. bool IPCCheckWait(int time);
  65.  
  66. Message *IPCGetNextMessage(void);
  67.  
  68. Message *IPCWaitMessage(int time);
  69.  
  70. void IPCLock(void);
  71.  
  72. void IPCUnlock(void);
  73.  
  74. /*
  75.  * Kolibri IPC functions & data
  76.  */
  77.  
  78. extern kolibri_IPC_area_t *kolibri_IPC_area;
  79.  
  80. int kolibri_IPC_set_area(void *area, int size);
  81.  
  82. int kolibri_IPC_send(int tid, void *msg, int length);
  83.  
  84. void kolibri_IPC_unlock();
  85.  
  86. void kolibri_IPC_lock();
  87.  
  88. int kolibri_IPC_init(void *area, int size);
  89.  
  90. kolibri_IPC_message_t *kolibri_IPC_get_next_message();
  91.  
  92. // void kolibri_IPC_clear_buff();
  93.  
  94. #endif
  95.