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