POK(kernelpart)
|
00001 /* 00002 * POK header 00003 * 00004 * The following file is a part of the POK project. Any modification should 00005 * made according to the POK licence. You CANNOT use this file or a part of 00006 * this file is this part of a file for your own project 00007 * 00008 * For more information on the POK licence, please see our LICENCE FILE 00009 * 00010 * Please follow the coding guidelines described in doc/CODING_GUIDELINES 00011 * 00012 * Copyright (c) 2007-2009 POK team 00013 * 00014 * Created by julien on Thu Jan 15 23:34:13 2009 00015 */ 00016 00024 #ifndef __POK_KERNEL_PORTS_H__ 00025 #define __POK_KERNEL_PORTS_H__ 00026 00027 #include <types.h> 00028 #include <errno.h> 00029 #include <core/lockobj.h> 00030 00031 #define POK_PORT_MAX_SIZE 512 00032 00033 typedef enum 00034 { 00035 POK_PORT_QUEUEING_DISCIPLINE_FIFO = 1, 00036 POK_PORT_QUEUEING_DISCIPLINE_PRIORITY = 2 00037 } pok_port_queueing_disciplines_t; 00038 00039 typedef enum 00040 { 00041 POK_PORT_DIRECTION_IN = 1, 00042 POK_PORT_DIRECTION_OUT = 2 00043 } pok_port_directions_t; 00044 00045 typedef pok_queueing_discipline_t pok_port_queueing_discipline_t; 00046 00047 typedef enum 00048 { 00049 POK_PORT_KIND_QUEUEING = 1, 00050 POK_PORT_KIND_SAMPLING = 2, 00051 #ifdef POK_NEEDS_PORTS_VIRTUAL 00052 POK_PORT_KIND_VIRTUAL = 2, 00053 #endif 00054 POK_PORT_KIND_INVALID = 10 00055 } pok_port_kinds_t; 00056 00057 typedef struct 00058 { 00059 pok_port_id_t identifier; 00060 pok_partition_id_t partition; 00061 pok_port_size_t index; 00062 bool_t full; 00063 pok_port_size_t size; 00064 pok_port_size_t off_b; /* Offset of the beginning of the buffer */ 00065 pok_port_size_t off_e; /* Offset of the end of the buffer */ 00066 pok_port_direction_t direction; 00067 pok_port_queueing_discipline_t discipline; 00068 pok_bool_t ready; 00069 bool_t empty; 00070 uint8_t kind; 00071 uint64_t refresh; 00072 uint64_t last_receive; 00073 pok_lockobj_t lock; 00074 bool_t must_be_flushed; 00075 }pok_port_t; 00076 00077 #ifdef POK_NEEDS_PORTS_QUEUEING 00078 /* Queueing port functions */ 00079 typedef struct 00080 { 00081 pok_port_size_t size; 00082 pok_port_direction_t direction; 00083 uint8_t waiting_processes; 00084 }pok_port_queueing_status_t; 00085 00086 00087 pok_ret_t pok_port_queueing_create (char* name, 00088 const pok_port_size_t size, 00089 const pok_port_direction_t direction, 00090 const pok_port_queueing_discipline_t discipline, 00091 pok_port_id_t* id); 00092 00093 pok_ret_t pok_port_queueing_receive (const pok_port_id_t id, 00094 uint64_t timeout, 00095 const pok_port_size_t maxlen, 00096 void* data, 00097 pok_port_size_t* len); 00098 00099 pok_ret_t pok_port_queueing_send (const pok_port_id_t id, 00100 const void* data, 00101 const pok_port_size_t len, 00102 uint64_t timeout); 00103 00104 pok_ret_t pok_port_queueing_status (const pok_port_id_t id, 00105 pok_port_queueing_status_t* status); 00106 00107 pok_ret_t pok_port_queueing_id (char* name, 00108 pok_port_id_t* id); 00109 #endif 00110 00111 #ifdef POK_NEEDS_PORTS_SAMPLING 00112 /* Sampling port functions */ 00113 00114 typedef struct 00115 { 00116 pok_port_size_t size; 00117 pok_port_direction_t direction; 00118 uint64_t refresh; 00119 bool_t validity; 00120 }pok_port_sampling_status_t; 00121 00122 00123 pok_ret_t pok_port_sampling_create (char* name, 00124 const pok_port_size_t size, 00125 const pok_port_direction_t direction, 00126 const uint64_t refresh, 00127 pok_port_id_t* id); 00128 00129 pok_ret_t pok_port_sampling_write (const pok_port_id_t id, 00130 const void* data, 00131 const pok_port_size_t len); 00132 00133 pok_ret_t pok_port_sampling_read (const pok_port_id_t id, 00134 void* message, 00135 pok_port_size_t* len, 00136 bool_t* valid); 00137 00138 pok_ret_t pok_port_sampling_id (char* name, 00139 pok_port_id_t* id); 00140 00141 pok_ret_t pok_port_sampling_status (const pok_port_id_t id, 00142 pok_port_sampling_status_t* status); 00143 #endif 00144 00145 #if defined (POK_NEEDS_PORTS_SAMPLING) || defined (POK_NEEDS_PORTS_QUEUEING) 00146 /* Generic functions */ 00147 pok_ret_t pok_port_create (char* name, 00148 const pok_port_size_t size, 00149 const pok_port_direction_t direction, 00150 uint8_t kind, 00151 pok_port_id_t* id); 00152 00153 pok_ret_t pok_port_transfer (const uint8_t gid_dst, 00154 const uint8_t gid_src); 00155 00156 void pok_port_init(void); 00157 void pok_port_queueing_flushall (void); 00158 uint8_t pok_port_lid_to_gid (uint8_t lid); 00159 pok_port_size_t pok_port_available_size (uint8_t gid); 00160 pok_port_size_t pok_port_consumed_size (uint8_t gid); 00161 pok_ret_t pok_port_get (const uint32_t gid, void *data, const pok_port_size_t size); 00162 pok_ret_t pok_port_write (const uint8_t gid, const void *data, const pok_port_size_t size); 00163 bool_t pok_own_port (const uint8_t partition, const uint8_t port); 00164 #endif 00165 00166 00167 #ifdef POK_NEEDS_PORTS_VIRTUAL 00168 pok_ret_t pok_port_virtual_id (char* name, 00169 pok_port_id_t* id); 00170 00171 pok_ret_t pok_port_virtual_nb_destinations (const pok_port_id_t id, uint32_t* result); 00172 pok_ret_t pok_port_virtual_destination (const pok_port_id_t id, const uint32_t n, uint32_t* result); 00173 pok_ret_t pok_port_virtual_get_global (const pok_port_id_t local, pok_port_id_t* global); 00174 #endif 00175 00176 #endif