Changes in uspace/lib/packet/generic/packet_server.c [88b127b:dd5046dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/packet/generic/packet_server.c
r88b127b rdd5046dd 36 36 37 37 #include <packet_server.h> 38 #include <packet_local.h>39 38 40 39 #include <align.h> … … 69 68 fibril_mutex_t lock; 70 69 /** Free packet queues. */ 71 packet_t free[FREE_QUEUES_COUNT];70 packet_t *free[FREE_QUEUES_COUNT]; 72 71 73 72 /** … … 103 102 }; 104 103 105 int packet_translate_local(int phone, packet_ref packet, packet_id_t packet_id)106 {107 if (!packet)108 return EINVAL;109 110 *packet = pm_find(packet_id);111 return (*packet) ? EOK : ENOENT;112 }113 114 104 /** Clears and initializes the packet according to the given dimensions. 115 105 * … … 122 112 */ 123 113 static void 124 packet_init(packet_t packet, size_t addr_len, size_t max_prefix,114 packet_init(packet_t *packet, size_t addr_len, size_t max_prefix, 125 115 size_t max_content, size_t max_suffix) 126 116 { 127 117 // clear the packet content 128 bzero(((void *) packet) + sizeof( struct packet),129 packet->length - sizeof( struct packet));118 bzero(((void *) packet) + sizeof(packet_t), 119 packet->length - sizeof(packet_t)); 130 120 131 121 // clear the packet header … … 135 125 packet->next = 0; 136 126 packet->addr_len = 0; 137 packet->src_addr = sizeof( struct packet);127 packet->src_addr = sizeof(packet_t); 138 128 packet->dest_addr = packet->src_addr + addr_len; 139 129 packet->max_prefix = max_prefix; … … 154 144 * @param[in] max_content The maximal content length in bytes. 155 145 * @param[in] max_suffix The maximal suffix length in bytes. 156 * @return sThe packet of dimensions at least as given.157 * @return sNULL if there is not enough memory left.158 */ 159 static packet_t 146 * @return The packet of dimensions at least as given. 147 * @return NULL if there is not enough memory left. 148 */ 149 static packet_t * 160 150 packet_create(size_t length, size_t addr_len, size_t max_prefix, 161 151 size_t max_content, size_t max_suffix) 162 152 { 163 packet_t packet;153 packet_t *packet; 164 154 int rc; 165 155 166 156 // already locked 167 packet = (packet_t ) mmap(NULL, length, PROTO_READ | PROTO_WRITE,157 packet = (packet_t *) mmap(NULL, length, PROTO_READ | PROTO_WRITE, 168 158 MAP_SHARED | MAP_ANONYMOUS, 0, 0); 169 159 if (packet == MAP_FAILED) … … 198 188 * @return NULL if there is not enough memory left. 199 189 */ 200 static packet_t 190 static packet_t * 201 191 packet_get_local(size_t addr_len, size_t max_prefix, size_t max_content, 202 192 size_t max_suffix) 203 193 { 204 size_t length = ALIGN_UP(sizeof( struct packet) + 2 * addr_len +194 size_t length = ALIGN_UP(sizeof(packet_t) + 2 * addr_len + 205 195 max_prefix + max_content + max_suffix, PAGE_SIZE); 206 196 207 197 fibril_mutex_lock(&ps_globals.lock); 208 198 209 packet_t packet;199 packet_t *packet; 210 200 unsigned int index; 211 201 … … 241 231 } 242 232 243 packet_t packet_get_4_local(int phone, size_t max_content, size_t addr_len,244 size_t max_prefix, size_t max_suffix)245 {246 return packet_get_local(addr_len, max_prefix, max_content, max_suffix);247 }248 249 packet_t packet_get_1_local(int phone, size_t content)250 {251 return packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX, content,252 DEFAULT_SUFFIX);253 }254 255 233 /** Release the packet and returns it to the appropriate free packet queue. 256 234 * … … 260 238 * 261 239 */ 262 static void packet_release(packet_t packet)240 static void packet_release(packet_t *packet) 263 241 { 264 242 int index; … … 278 256 * 279 257 * @param[in] packet_id The first packet identifier. 280 * @return sEOK on success.281 * @return sENOENT if there is no such packet.258 * @return EOK on success. 259 * @return ENOENT if there is no such packet. 282 260 */ 283 261 static int packet_release_wrapper(packet_id_t packet_id) 284 262 { 285 packet_t packet;263 packet_t *packet; 286 264 287 265 packet = pm_find(packet_id); … … 296 274 } 297 275 298 void pq_release_local(int phone, packet_id_t packet_id)299 {300 (void) packet_release_wrapper(packet_id);301 }302 303 276 /** Shares the packet memory block. 304 277 * @param[in] packet The packet to be shared. 305 * @return sEOK on success.306 * @return sEINVAL if the packet is not valid.307 * @return sEINVAL if the calling module does not accept the memory.308 * @return sENOMEM if the desired and actual sizes differ.309 * @return sOther error codes as defined for the278 * @return EOK on success. 279 * @return EINVAL if the packet is not valid. 280 * @return EINVAL if the calling module does not accept the memory. 281 * @return ENOMEM if the desired and actual sizes differ. 282 * @return Other error codes as defined for the 310 283 * async_share_in_finalize() function. 311 284 */ 312 static int packet_reply( const packet_tpacket)285 static int packet_reply(packet_t *packet) 313 286 { 314 287 ipc_callid_t callid; … … 339 312 * @param[out] answer_count The last parameter for the actual answer in the 340 313 * answer parameter. 341 * @return sEOK on success.342 * @return sENOMEM if there is not enough memory left.343 * @return sENOENT if there is no such packet as in the packet314 * @return EOK on success. 315 * @return ENOMEM if there is not enough memory left. 316 * @return ENOENT if there is no such packet as in the packet 344 317 * message parameter. 345 * @return sENOTSUP if the message is not known.346 * @return sOther error codes as defined for the318 * @return ENOTSUP if the message is not known. 319 * @return Other error codes as defined for the 347 320 * packet_release_wrapper() function. 348 321 */ … … 351 324 int *answer_count) 352 325 { 353 packet_t packet;326 packet_t *packet; 354 327 355 328 *answer_count = 0;
Note:
See TracChangeset
for help on using the changeset viewer.