Changes in / [63a1e60:7494fb4] in mainline
- Files:
-
- 1 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/pm.h
r63a1e60 r7494fb4 83 83 84 84 #define TSS_BASIC_SIZE 104 85 #define TSS_IOMAP_SIZE ( 16 * 1024 + 1) /* 16K for bitmap + 1 terminating byte for convenience */85 #define TSS_IOMAP_SIZE (8 * 1024 + 1) /* 8K for bitmap + 1 terminating byte for convenience */ 86 86 87 87 #define IO_PORTS (64 * 1024) -
kernel/arch/amd64/src/ddi/ddi.c
r63a1e60 r7494fb4 126 126 bitmap_initialize(&iomap, CPU->arch.tss->iomap, 127 127 TSS_IOMAP_SIZE * 8); 128 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);128 bitmap_copy(&iomap, &TASK->arch.iomap, bits); 129 129 130 /* 131 * Set the trailing bits in the last byte of the map to disable 132 * I/O access. 133 */ 134 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 130 135 /* 131 136 * It is safe to set the trailing eight bits because of the 132 137 * extra convenience byte in TSS_IOMAP_SIZE. 133 138 */ 134 bitmap_set_range(&iomap, ALIGN_UP( TASK->arch.iomap.bits, 8), 8);139 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8); 135 140 } 136 141 irq_spinlock_unlock(&TASK->lock, false); -
kernel/arch/ia32/include/pm.h
r63a1e60 r7494fb4 75 75 76 76 #define TSS_BASIC_SIZE 104 77 #define TSS_IOMAP_SIZE ( 16 * 1024 + 1) /* 16K for bitmap + 1 terminating byte for convenience */77 #define TSS_IOMAP_SIZE (8 * 1024 + 1) /* 8K for bitmap + 1 terminating byte for convenience */ 78 78 79 79 #define IO_PORTS (64 * 1024) -
kernel/arch/ia32/src/ddi/ddi.c
r63a1e60 r7494fb4 127 127 bitmap_initialize(&iomap, CPU->arch.tss->iomap, 128 128 TSS_IOMAP_SIZE * 8); 129 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);129 bitmap_copy(&iomap, &TASK->arch.iomap, bits); 130 130 131 /* 132 * Set the trailing bits in the last byte of the map to disable 133 * I/O access. 134 */ 135 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 131 136 /* 132 137 * It is safe to set the trailing eight bits because of the 133 138 * extra convenience byte in TSS_IOMAP_SIZE. 134 139 */ 135 bitmap_set_range(&iomap, ALIGN_UP( TASK->arch.iomap.bits, 8), 8);140 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8); 136 141 } 137 142 irq_spinlock_unlock(&TASK->lock, false); -
kernel/generic/src/adt/bitmap.c
r63a1e60 r7494fb4 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Implementation of bitmap ADT. 35 35 * 36 36 * This file implements bitmap ADT and provides functions for … … 51 51 * No portion of the bitmap is set or cleared by this function. 52 52 * 53 * @param bitmap 54 * @param map 55 * @param bits 53 * @param bitmap Bitmap structure. 54 * @param map Address of the memory used to hold the map. 55 * @param bits Number of bits stored in bitmap. 56 56 */ 57 57 void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, size_t bits) … … 63 63 /** Set range of bits. 64 64 * 65 * @param bitmap 66 * @param start 67 * @param bits 65 * @param bitmap Bitmap structure. 66 * @param start Starting bit. 67 * @param bits Number of bits to set. 68 68 */ 69 69 void bitmap_set_range(bitmap_t *bitmap, size_t start, size_t bits) … … 71 71 size_t i = 0; 72 72 size_t aligned_start; 73 size_t lub; 74 size_t amb; 75 size_t tab; 73 size_t lub; /* leading unaligned bits */ 74 size_t amb; /* aligned middle bits */ 75 size_t tab; /* trailing aligned bits */ 76 76 77 77 ASSERT(start + bits <= bitmap->bits); … … 82 82 tab = amb % 8; 83 83 84 if ( start + bits < aligned_start ) { 85 /* 86 * Set bits in the middle of byte 87 */ 88 bitmap->map[start / 8] |= ((1 << lub)-1) << (start&7); 89 return; 84 if (!bits) 85 return; 86 87 if (start + bits < aligned_start) { 88 /* Set bits in the middle of byte. */ 89 bitmap->map[start / 8] |= ((1 << lub) - 1) << (start & 7); 90 return; 90 91 } 91 92 92 93 if (lub) { 93 /* 94 * Make sure to set any leading unaligned bits. 95 */ 94 /* Make sure to set any leading unaligned bits. */ 96 95 bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1); 97 96 } 98 97 for (i = 0; i < amb / 8; i++) { 99 /* 100 * The middle bits can be set byte by byte. 101 */ 98 /* The middle bits can be set byte by byte. */ 102 99 bitmap->map[aligned_start / 8 + i] = ALL_ONES; 103 100 } 104 101 if (tab) { 105 /* 106 * Make sure to set any trailing aligned bits. 107 */ 102 /* Make sure to set any trailing aligned bits. */ 108 103 bitmap->map[aligned_start / 8 + i] |= (1 << tab) - 1; 109 104 } … … 113 108 /** Clear range of bits. 114 109 * 115 * @param bitmap 116 * @param start 117 * @param bits 110 * @param bitmap Bitmap structure. 111 * @param start Starting bit. 112 * @param bits Number of bits to clear. 118 113 */ 119 114 void bitmap_clear_range(bitmap_t *bitmap, size_t start, size_t bits) … … 121 116 size_t i = 0; 122 117 size_t aligned_start; 123 size_t lub; 124 size_t amb; 125 size_t tab; 118 size_t lub; /* leading unaligned bits */ 119 size_t amb; /* aligned middle bits */ 120 size_t tab; /* trailing aligned bits */ 126 121 127 122 ASSERT(start + bits <= bitmap->bits); … … 132 127 tab = amb % 8; 133 128 134 if ( start + bits < aligned_start)135 {136 /* 137 * Set bits in the middle of byte138 139 bitmap->map[start / 8] &= ~(((1 << lub)-1) << (start&7));140 129 if (!bits) 130 return; 131 132 if (start + bits < aligned_start) { 133 /* Set bits in the middle of byte */ 134 bitmap->map[start / 8] &= ~(((1 << lub) - 1) << (start & 7)); 135 return; 141 136 } 142 137 143 144 138 if (lub) { 145 /* 146 * Make sure to clear any leading unaligned bits. 147 */ 139 /* Make sure to clear any leading unaligned bits. */ 148 140 bitmap->map[start / 8] &= (1 << (8 - lub)) - 1; 149 141 } 150 142 for (i = 0; i < amb / 8; i++) { 151 /* 152 * The middle bits can be cleared byte by byte. 153 */ 143 /* The middle bits can be cleared byte by byte. */ 154 144 bitmap->map[aligned_start / 8 + i] = ALL_ZEROES; 155 145 } 156 146 if (tab) { 157 /* 158 * Make sure to clear any trailing aligned bits. 159 */ 147 /* Make sure to clear any trailing aligned bits. */ 160 148 bitmap->map[aligned_start / 8 + i] &= ~((1 << tab) - 1); 161 149 } … … 165 153 /** Copy portion of one bitmap into another bitmap. 166 154 * 167 * @param dst 168 * @param src 169 * @param bits 155 * @param dst Destination bitmap. 156 * @param src Source bitmap. 157 * @param bits Number of bits to copy. 170 158 */ 171 159 void bitmap_copy(bitmap_t *dst, bitmap_t *src, size_t bits) -
tools/toolchain.sh
r63a1e60 r7494fb4 62 62 echo " ia32 IA-32 (x86, i386)" 63 63 echo " ia64 IA-64 (Itanium)" 64 echo " mips32 MIPS little-endian" 65 echo " mips32eb MIPS big-endian" 64 echo " mips32 MIPS little-endian 32b" 65 echo " mips32eb MIPS big-endian 32b" 66 echo " mips64 MIPS little-endian 64b" 66 67 echo " ppc32 32-bit PowerPC" 67 68 echo " ppc64 64-bit PowerPC" … … 303 304 build_target "mips32eb" "mips-linux-gnu" 304 305 ;; 306 "mips64") 307 build_target "mips64" "mips64el-linux-gnu" 308 ;; 305 309 "ppc32") 306 310 build_target "ppc32" "ppc-linux-gnu" … … 320 324 build_target "mips32" "mipsel-linux-gnu" 321 325 build_target "mips32eb" "mips-linux-gnu" 326 build_target "mips64" "mips64el-linux-gnu" 322 327 build_target "ppc32" "ppc-linux-gnu" 323 328 build_target "ppc64" "ppc64-linux-gnu" -
uspace/app/netstart/Makefile
r63a1e60 r7494fb4 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBNET_PREFIX)/libnet.a32 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include31 LIBS = 32 EXTRA_CFLAGS = 33 33 34 34 BINARY = netstart -
uspace/lib/c/generic/adt/measured_strings.c
r63a1e60 r7494fb4 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 #include <async.h> 45 44 … … 135 134 size_t count) 136 135 { 137 ERROR_DECLARE;138 139 136 size_t *lengths; 140 137 size_t index; … … 142 139 char *next; 143 140 ipc_callid_t callid; 141 int rc; 144 142 145 143 if ((!strings) || (!data) || (count <= 0)) … … 155 153 return EINVAL; 156 154 } 157 if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths,158 length))) {159 free(lengths); 160 return ERROR_CODE;155 rc = async_data_write_finalize(callid, lengths, length); 156 if (rc != EOK) { 157 free(lengths); 158 return rc; 161 159 } 162 160 … … 187 185 return EINVAL; 188 186 } 189 if (ERROR_OCCURRED(async_data_write_finalize(callid, 190 next, lengths[index]))) { 187 rc = async_data_write_finalize(callid, next, 188 lengths[index]); 189 if (rc != EOK) { 191 190 free(*data); 192 191 free(*strings); 193 192 free(lengths); 194 return ERROR_CODE;193 return rc; 195 194 } 196 195 (*strings)[index].value = next; … … 251 250 int measured_strings_reply(const measured_string_ref strings, size_t count) 252 251 { 253 ERROR_DECLARE;254 255 252 size_t *lengths; 256 253 size_t index; 257 254 size_t length; 258 255 ipc_callid_t callid; 256 int rc; 259 257 260 258 if ((!strings) || (count <= 0)) … … 270 268 return EINVAL; 271 269 } 272 if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) { 273 free(lengths); 274 return ERROR_CODE; 270 rc = async_data_read_finalize(callid, lengths, length); 271 if (rc != EOK) { 272 free(lengths); 273 return rc; 275 274 } 276 275 free(lengths); … … 282 281 return EINVAL; 283 282 } 284 ERROR_PROPAGATE(async_data_read_finalize(callid, 285 strings[index].value, strings[index].length)); 283 rc = async_data_read_finalize(callid, 284 strings[index].value, strings[index].length); 285 if (rc != EOK) 286 return rc; 286 287 } 287 288 } … … 313 314 size_t count) 314 315 { 315 ERROR_DECLARE;316 317 316 size_t *lengths; 318 317 size_t index; 319 318 char *next; 319 int rc; 320 320 321 321 if ((phone < 0) || (!strings) || (!data) || (count <= 0)) … … 326 326 return ENOMEM; 327 327 328 if (ERROR_OCCURRED(async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)))) { 330 free(lengths); 331 return ERROR_CODE; 328 rc = async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)); 330 if (rc != EOK) { 331 free(lengths); 332 return rc; 332 333 } 333 334 … … 350 351 (*strings)[index].length = lengths[index]; 351 352 if (lengths[index] > 0) { 352 if (ERROR_OCCURRED(async_data_read_start(phone, next,353 lengths[index]))) {353 rc = async_data_read_start(phone, next, lengths[index]); 354 if (rc != EOK) { 354 355 free(lengths); 355 356 free(data); 356 357 free(strings); 357 return ERROR_CODE;358 return rc; 358 359 } 359 360 (*strings)[index].value = next; … … 387 388 size_t count) 388 389 { 389 ERROR_DECLARE;390 391 390 size_t *lengths; 392 391 size_t index; 392 int rc; 393 393 394 394 if ((phone < 0) || (!strings) || (count <= 0)) … … 399 399 return ENOMEM; 400 400 401 if (ERROR_OCCURRED(async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)))) { 403 free(lengths); 404 return ERROR_CODE; 401 rc = async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)); 403 if (rc != EOK) { 404 free(lengths); 405 return rc; 405 406 } 406 407 … … 409 410 for (index = 0; index < count; index++) { 410 411 if (strings[index].length > 0) { 411 ERROR_PROPAGATE(async_data_write_start(phone, 412 strings[index].value, strings[index].length)); 412 rc = async_data_write_start(phone, strings[index].value, 413 strings[index].length); 414 if (rc != EOK) 415 return rc; 413 416 } 414 417 } -
uspace/lib/c/generic/net/modules.c
r63a1e60 r7494fb4 41 41 #include <async.h> 42 42 #include <malloc.h> 43 #include <err .h>43 #include <errno.h> 44 44 #include <sys/time.h> 45 45 … … 137 137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 ERROR_DECLARE;139 int rc; 140 140 141 141 /* Connect to the needed service */ … … 144 144 /* Request the bidirectional connection */ 145 145 ipcarg_t phonehash; 146 if (ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, 147 &phonehash))) { 146 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); 148 if (rc != EOK) { 148 149 ipc_hangup(phone); 149 return ERROR_CODE;150 return rc; 150 151 } 151 152 async_new_connection(phonehash, 0, NULL, client_receiver); … … 212 213 int data_receive(void **data, size_t *length) 213 214 { 214 ERROR_DECLARE;215 216 215 ipc_callid_t callid; 216 int rc; 217 217 218 218 if (!data || !length) … … 229 229 230 230 // fetch the data 231 if (ERROR_OCCURRED(async_data_write_finalize(callid, *data, *length))) { 231 rc = async_data_write_finalize(callid, *data, *length); 232 if (rc != EOK) { 232 233 free(data); 233 return ERROR_CODE;234 return rc; 234 235 } 235 236 -
uspace/lib/c/generic/net/packet.c
r63a1e60 r7494fb4 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 45 44 #include <sys/mman.h> … … 91 90 int pm_init(void) 92 91 { 93 ERROR_DECLARE;92 int rc; 94 93 95 94 fibril_rwlock_initialize(&pm_globals.lock); 95 96 96 fibril_rwlock_write_lock(&pm_globals.lock); 97 ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));97 rc = gpm_initialize(&pm_globals.packet_map); 98 98 fibril_rwlock_write_unlock(&pm_globals.lock); 99 return EOK; 99 100 return rc; 100 101 } 101 102 … … 139 140 int pm_add(packet_t packet) 140 141 { 141 ERROR_DECLARE;142 143 142 packet_map_ref map; 143 int rc; 144 144 145 145 if (!packet_is_valid(packet)) … … 160 160 } 161 161 bzero(map, sizeof(packet_map_t)); 162 if ((ERROR_CODE =163 gpm_add(&pm_globals.packet_map, map))< 0) {162 rc = gpm_add(&pm_globals.packet_map, map); 163 if (rc < 0) { 164 164 fibril_rwlock_write_unlock(&pm_globals.lock); 165 165 free(map); 166 return ERROR_CODE;166 return rc; 167 167 } 168 168 } while (PACKET_MAP_PAGE(packet->packet_id) >= -
uspace/lib/c/generic/net/socket_client.c
r63a1e60 r7494fb4 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 #include <err.h>46 45 47 46 #include <ipc/services.h> … … 212 211 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 213 212 { 214 ERROR_DECLARE;215 216 213 ipc_callid_t callid; 217 214 ipc_call_t call; 218 215 socket_ref socket; 216 int rc; 219 217 220 218 loop: … … 231 229 SOCKET_GET_SOCKET_ID(call)); 232 230 if (!socket) { 233 ERROR_CODE= ENOTSOCK;231 rc = ENOTSOCK; 234 232 fibril_rwlock_read_unlock(&socket_globals.lock); 235 233 break; … … 240 238 fibril_mutex_lock(&socket->receive_lock); 241 239 // push the number of received packet fragments 242 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->received,240 rc = dyn_fifo_push(&socket->received, 243 241 SOCKET_GET_DATA_FRAGMENTS(call), 244 SOCKET_MAX_RECEIVED_SIZE))) { 242 SOCKET_MAX_RECEIVED_SIZE); 243 if (rc == EOK) { 245 244 // signal the received packet 246 245 fibril_condvar_signal(&socket->receive_signal); … … 252 251 // push the new socket identifier 253 252 fibril_mutex_lock(&socket->accept_lock); 254 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 255 1, SOCKET_MAX_ACCEPTED_SIZE))) { 253 rc = dyn_fifo_push(&socket->accepted, 1, 254 SOCKET_MAX_ACCEPTED_SIZE); 255 if (rc != EOK) { 256 256 // signal the accepted socket 257 257 fibril_condvar_signal(&socket->accept_signal); … … 261 261 262 262 default: 263 ERROR_CODE= ENOTSUP;263 rc = ENOTSUP; 264 264 } 265 265 … … 280 280 281 281 default: 282 ERROR_CODE= ENOTSUP;283 } 284 285 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE);282 rc = ENOTSUP; 283 } 284 285 ipc_answer_0(callid, (ipcarg_t) rc); 286 286 goto loop; 287 287 } … … 405 405 int socket(int domain, int type, int protocol) 406 406 { 407 ERROR_DECLARE;408 409 407 socket_ref socket; 410 408 int phone; … … 413 411 ipcarg_t fragment_size; 414 412 ipcarg_t header_size; 413 int rc; 415 414 416 415 // find the appropriate service … … 479 478 } 480 479 481 if (ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, 482 service, NULL, &fragment_size, &header_size))) { 480 rc = (int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 481 &fragment_size, &header_size); 482 if (rc != EOK) { 483 483 fibril_rwlock_write_unlock(&socket_globals.lock); 484 484 free(socket); 485 return ERROR_CODE;485 return rc; 486 486 } 487 487 … … 492 492 socket_initialize(socket, socket_id, phone, service); 493 493 // store the new socket 494 ERROR_CODE= sockets_add(socket_get_sockets(), socket_id, socket);494 rc = sockets_add(socket_get_sockets(), socket_id, socket); 495 495 496 496 fibril_rwlock_write_unlock(&socket_globals.lock); 497 if ( ERROR_CODE< 0) {497 if (rc < 0) { 498 498 dyn_fifo_destroy(&socket->received); 499 499 dyn_fifo_destroy(&socket->accepted); … … 501 501 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, 502 502 service); 503 return ERROR_CODE;503 return rc; 504 504 } 505 505 … … 770 770 int closesocket(int socket_id) 771 771 { 772 ERROR_DECLARE;773 774 772 socket_ref socket; 773 int rc; 775 774 776 775 fibril_rwlock_write_lock(&socket_globals.lock); … … 787 786 788 787 // request close 789 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 790 (ipcarg_t) socket->socket_id, 0, socket->service)); 788 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 789 (ipcarg_t) socket->socket_id, 0, socket->service); 790 if (rc != EOK) { 791 fibril_rwlock_write_unlock(&socket_globals.lock); 792 return rc; 793 } 791 794 // free the socket structure 792 795 socket_destroy(socket); -
uspace/lib/c/include/adt/generic_char_map.h
r63a1e60 r7494fb4 40 40 #include <unistd.h> 41 41 #include <errno.h> 42 #include <err.h>43 42 44 43 #include <adt/char_map.h> … … 85 84 type *value) \ 86 85 { \ 87 ERROR_DECLARE; \86 int rc; \ 88 87 int index; \ 89 88 if (!name##_is_valid(map)) \ … … 92 91 if (index < 0) \ 93 92 return index; \ 94 if (ERROR_OCCURRED(char_map_add(&map->names, name, length,\95 index))) { \93 rc = char_map_add(&map->names, name, length, index); \ 94 if (rc != EOK) { \ 96 95 name##_items_exclude_index(&map->values, index); \ 97 return ERROR_CODE; \96 return rc; \ 98 97 } \ 99 98 return EOK; \ … … 141 140 int name##_initialize(name##_ref map) \ 142 141 { \ 143 ERROR_DECLARE; \142 int rc; \ 144 143 if (!map) \ 145 144 return EINVAL; \ 146 ERROR_PROPAGATE(char_map_initialize(&map->names)); \ 147 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \ 145 rc = char_map_initialize(&map->names); \ 146 if (rc != EOK) \ 147 return rc; \ 148 rc = name##_items_initialize(&map->values); \ 149 if (rc != EOK) { \ 148 150 char_map_destroy(&map->names); \ 149 return ERROR_CODE; \151 return rc; \ 150 152 } \ 151 153 map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \ -
uspace/lib/c/include/err.h
r63a1e60 r7494fb4 37 37 38 38 #include <stdio.h> 39 #include <errno.h>40 41 #ifdef CONFIG_DEBUG42 #include <str_error.h>43 #endif44 39 45 40 #define errx(status, fmt, ...) { \ … … 48 43 } 49 44 50 51 /** An actual stored error code. */52 #define ERROR_CODE error_check_return_value53 54 /** An error processing routines declaration.55 *56 * This has to be declared in the block where the error processing57 * is desired.58 */59 #define ERROR_DECLARE int ERROR_CODE60 61 /** Store the value as an error code and checks if an error occurred.62 *63 * @param[in] value The value to be checked. May be a function call.64 * @return False if the value indicates success (EOK).65 * @return True otherwise.66 */67 #ifdef CONFIG_DEBUG68 69 #define ERROR_OCCURRED(value) \70 (((ERROR_CODE = (value)) != EOK) && \71 ({ \72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \73 __FILE__, __LINE__, str_error(ERROR_CODE)); \74 1; \75 }))76 77 #else78 79 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK)80 81 #endif82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value))84 85 /** Error propagation86 *87 * Check if an error occurred and immediately exit the actual88 * function returning the error code.89 *90 * @param[in] value The value to be checked. May be a function call.91 *92 */93 94 #define ERROR_PROPAGATE(value) \95 if (ERROR_OCCURRED(value)) \96 return ERROR_CODE97 98 45 #endif 99 46 100 47 /** @} 101 48 */ 49 -
uspace/lib/c/include/stdio.h
r63a1e60 r7494fb4 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) se\48 #define DEBUG(fmt, ...) \ 49 49 { \ 50 50 char _buf[256]; \ -
uspace/lib/net/adt/module_map.c
r63a1e60 r7494fb4 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <err .h>40 #include <errno.h> 41 41 42 42 #include <ipc/services.h> … … 67 67 connect_module_t connect_module) 68 68 { 69 ERROR_DECLARE;70 71 69 module_ref tmp_module; 70 int rc; 72 71 73 72 tmp_module = (module_ref) malloc(sizeof(module_t)); … … 83 82 tmp_module->connect_module = connect_module; 84 83 85 if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,86 tmp_module))) {84 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 if (rc != EOK) { 87 86 free(tmp_module); 88 return ERROR_CODE;87 return rc; 89 88 } 90 89 if (module) -
uspace/lib/net/generic/packet_remote.c
r63a1e60 r7494fb4 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <err.h>41 40 #include <ipc/ipc.h> 42 41 #include <ipc/packet.h> … … 67 66 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size) 68 67 { 69 ERROR_DECLARE;70 71 68 ipc_call_t answer; 72 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 73 74 74 *packet = (packet_t) as_get_mappable_page(size); 75 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||76 ERROR_OCCURRED(pm_add(*packet))) {75 rc = async_share_in_start_0_0(phone, *packet, size); 76 if (rc != EOK) { 77 77 munmap(*packet, size); 78 78 async_wait_for(message, NULL); 79 return ERROR_CODE; 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 80 86 } 81 87 … … 103 109 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 104 110 { 105 ERROR_DECLARE;111 int rc; 106 112 107 113 if (!packet) … … 112 118 ipcarg_t size; 113 119 114 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 115 packet_id, &size)); 116 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 117 127 } 118 128 if ((*packet)->next) { … … 141 151 size_t max_prefix, size_t max_suffix) 142 152 { 143 ERROR_DECLARE;144 145 153 ipcarg_t packet_id; 146 154 ipcarg_t size; 147 148 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, 149 max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))) 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 150 160 return NULL; 151 161 … … 153 163 packet_t packet = pm_find(packet_id); 154 164 if (!packet) { 155 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,156 size)))165 rc = packet_return(phone, &packet, packet_id, size); 166 if (rc != EOK) 157 167 return NULL; 158 168 } … … 172 182 packet_t packet_get_1_remote(int phone, size_t content) 173 183 { 174 ERROR_DECLARE;175 176 184 ipcarg_t packet_id; 177 185 ipcarg_t size; 178 179 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 180 &packet_id, &size))) 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 181 191 return NULL; 182 192 183 193 packet_t packet = pm_find(packet_id); 184 194 if (!packet) { 185 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,186 size)))195 rc = packet_return(phone, &packet, packet_id, size); 196 if (rc != EOK) 187 197 return NULL; 188 198 } -
uspace/lib/net/netif/netif_local.c
r63a1e60 r7494fb4 43 43 #include <ipc/services.h> 44 44 #include <ipc/netif.h> 45 #include <err .h>45 #include <errno.h> 46 46 47 47 #include <generic.h> … … 113 113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 114 { 115 ERROR_DECLARE;115 int rc; 116 116 117 117 fibril_rwlock_write_lock(&netif_globals.lock); 118 118 119 119 netif_device_t *device; 120 if (ERROR_OCCURRED(find_device(device_id, &device))) { 120 rc = find_device(device_id, &device); 121 if (rc != EOK) { 121 122 fibril_rwlock_write_unlock(&netif_globals.lock); 122 return ERROR_CODE;123 return rc; 123 124 } 124 125 … … 148 149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 149 150 { 150 ERROR_DECLARE;151 int rc; 151 152 152 153 fibril_rwlock_write_lock(&netif_globals.lock); 153 154 154 155 netif_device_t *device; 155 if (ERROR_OCCURRED(find_device(device_id, &device))) { 156 rc = find_device(device_id, &device); 157 if (rc != EOK) { 156 158 fibril_rwlock_write_unlock(&netif_globals.lock); 157 return ERROR_CODE;159 return rc; 158 160 } 159 161 … … 203 205 measured_string_ref *address, char **data) 204 206 { 205 ERROR_DECLARE;207 int rc; 206 208 207 209 if (!address || !data) … … 211 213 212 214 measured_string_t translation; 213 if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) { 215 rc = netif_get_addr_message(device_id, &translation); 216 if (rc == EOK) { 214 217 *address = measured_string_copy(&translation); 215 ERROR_CODE= (*address) ? EOK : ENOMEM;218 rc = (*address) ? EOK : ENOMEM; 216 219 } 217 220 … … 220 223 *data = (**address).value; 221 224 222 return ERROR_CODE;225 return rc; 223 226 } 224 227 … … 264 267 int netif_init_module(async_client_conn_t client_connection) 265 268 { 266 ERROR_DECLARE;269 int rc; 267 270 268 271 async_set_client_connection(client_connection); … … 271 274 netif_device_map_initialize(&netif_globals.device_map); 272 275 273 ERROR_PROPAGATE(pm_init()); 276 rc = pm_init(); 277 if (rc != EOK) 278 return rc; 274 279 275 280 fibril_rwlock_initialize(&netif_globals.lock); 276 if (ERROR_OCCURRED(netif_initialize())) { 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 277 284 pm_destroy(); 278 return ERROR_CODE;285 return rc; 279 286 } 280 287 … … 317 324 static int register_message(const char *name, device_id_t device_id, int phone) 318 325 { 319 ERROR_DECLARE;320 321 326 netif_device_t *device; 322 ERROR_PROPAGATE(find_device(device_id, &device)); 323 if(device->nil_phone > 0) 327 int rc; 328 329 rc = find_device(device_id, &device); 330 if (rc != EOK) 331 return rc; 332 333 if (device->nil_phone > 0) 324 334 return ELIMIT; 325 335 … … 349 359 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 350 360 { 351 ERROR_DECLARE;352 353 361 size_t length; 354 362 device_stats_t stats; 355 363 packet_t packet; 356 364 measured_string_t address; 365 int rc; 357 366 358 367 *answer_count = 0; … … 367 376 case IPC_M_CONNECT_TO_ME: 368 377 fibril_rwlock_write_lock(&netif_globals.lock); 369 ERROR_CODE= register_message(name, IPC_GET_DEVICE(call),378 rc = register_message(name, IPC_GET_DEVICE(call), 370 379 IPC_GET_PHONE(call)); 371 380 fibril_rwlock_write_unlock(&netif_globals.lock); 372 return ERROR_CODE;381 return rc; 373 382 374 383 case NET_NETIF_SEND: 375 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone, 376 &packet, IPC_GET_PACKET(call))); 384 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET(call)); 386 if (rc != EOK) 387 return rc; 377 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 378 389 IPC_GET_SENDER(call)); 379 390 380 391 case NET_NETIF_START: 381 392 return netif_start_req_local(0, IPC_GET_DEVICE(call)); … … 384 395 fibril_rwlock_read_lock(&netif_globals.lock); 385 396 386 if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) { 397 rc = async_data_read_receive(&callid, &length); 398 if (rc != EOK) { 387 399 fibril_rwlock_read_unlock(&netif_globals.lock); 388 return ERROR_CODE;400 return rc; 389 401 } 390 402 if (length < sizeof(device_stats_t)) { … … 393 405 } 394 406 395 if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call),396 &stats))) {397 ERROR_CODE= async_data_read_finalize(callid, &stats,407 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats); 408 if (rc == EOK) { 409 rc = async_data_read_finalize(callid, &stats, 398 410 sizeof(device_stats_t)); 399 411 } 400 412 401 413 fibril_rwlock_read_unlock(&netif_globals.lock); 402 return ERROR_CODE;414 return rc; 403 415 404 416 case NET_NETIF_STOP: … … 407 419 case NET_NETIF_GET_ADDR: 408 420 fibril_rwlock_read_lock(&netif_globals.lock); 409 if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call),410 &address)))411 ERROR_CODE= measured_strings_reply(&address, 1);421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 422 if (rc == EOK) 423 rc = measured_strings_reply(&address, 1); 412 424 fibril_rwlock_read_unlock(&netif_globals.lock); 413 return ERROR_CODE;425 return rc; 414 426 } 415 427 … … 431 443 int netif_module_start_standalone(async_client_conn_t client_connection) 432 444 { 433 ERROR_DECLARE; 434 435 ERROR_PROPAGATE(netif_init_module(client_connection)); 445 int rc; 446 447 rc = netif_init_module(client_connection); 448 if (rc != EOK) 449 return rc; 436 450 437 451 async_manager(); -
uspace/lib/net/tl/socket_core.c
r63a1e60 r7494fb4 48 48 #include <stdlib.h> 49 49 #include <errno.h> 50 #include <err.h>51 50 52 51 #include <adt/dynamic_fifo.h> … … 164 163 const char *key, size_t key_length) 165 164 { 166 ERROR_DECLARE;167 168 165 socket_core_ref *socket_ref; 166 int rc; 169 167 170 168 // create a wrapper … … 175 173 *socket_ref = socket; 176 174 // add the wrapper 177 if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key, 178 key_length, socket_ref))) { 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 socket_ref); 177 if (rc != EOK) { 179 178 free(socket_ref); 180 return ERROR_CODE;179 return rc; 181 180 } 182 181 … … 204 203 int port) 205 204 { 206 ERROR_DECLARE;207 208 205 socket_port_ref socket_port; 206 int rc; 209 207 210 208 // create a wrapper … … 214 212 215 213 socket_port->count = 0; 216 if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) || 217 ERROR_OCCURRED(socket_port_add_core(socket_port, socket, 218 SOCKET_MAP_KEY_LISTENING, 0))) { 219 socket_port_map_destroy(&socket_port->map); 220 free(socket_port); 221 return ERROR_CODE; 222 } 214 rc = socket_port_map_initialize(&socket_port->map); 215 if (rc != EOK) 216 goto fail; 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING, 219 0); 220 if (rc != EOK) 221 goto fail; 223 222 224 223 // register the incomming port 225 ERROR_CODE = socket_ports_add(global_sockets, port, socket_port); 226 if (ERROR_CODE < 0) { 227 socket_port_map_destroy(&socket_port->map); 228 free(socket_port); 229 return ERROR_CODE; 230 } 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 if (rc < 0) 226 goto fail; 231 227 232 228 socket->port = port; 233 229 return EOK; 230 231 fail: 232 socket_port_map_destroy(&socket_port->map); 233 free(socket_port); 234 return rc; 235 234 236 } 235 237 … … 416 418 void *specific_data, int *socket_id) 417 419 { 418 ERROR_DECLARE;419 420 420 socket_core_ref socket; 421 int res;422 421 int positive; 422 int rc; 423 423 424 424 if (!socket_id) … … 447 447 socket->key_length = 0; 448 448 socket->specific_data = specific_data; 449 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,450 SOCKET_INITIAL_RECEIVED_SIZE))) {449 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 450 if (rc != EOK) { 451 451 free(socket); 452 return ERROR_CODE; 453 } 454 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted, 455 SOCKET_INITIAL_ACCEPTED_SIZE))) { 452 return rc; 453 } 454 455 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 456 if (rc != EOK) { 456 457 dyn_fifo_destroy(&socket->received); 457 458 free(socket); 458 return ERROR_CODE;459 return rc; 459 460 } 460 461 socket->socket_id = *socket_id; 461 r es= socket_cores_add(local_sockets, socket->socket_id, socket);462 if (r es< 0) {462 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 463 if (rc < 0) { 463 464 dyn_fifo_destroy(&socket->received); 464 465 dyn_fifo_destroy(&socket->accepted); 465 466 free(socket); 466 return r es;467 return rc; 467 468 } 468 469 … … 523 524 int socket_reply_packets(packet_t packet, size_t *length) 524 525 { 525 ERROR_DECLARE;526 527 526 packet_t next_packet; 528 527 size_t fragments; 529 528 size_t *lengths; 530 529 size_t index; 530 int rc; 531 531 532 532 if (!length) … … 536 536 if (!next_packet) { 537 537 // write all if only one fragment 538 ERROR_PROPAGATE(data_reply(packet_get_data(packet), 539 packet_get_data_length(packet))); 538 rc = data_reply(packet_get_data(packet), 539 packet_get_data_length(packet)); 540 if (rc != EOK) 541 return rc; 540 542 // store the total length 541 543 *length = packet_get_data_length(packet); … … 564 566 565 567 // write the fragment lengths 566 if (ERROR_OCCURRED(data_reply(lengths,567 sizeof(int) * (fragments + 1)))) {568 rc = data_reply(lengths, sizeof(int) * (fragments + 1)); 569 if (rc != EOK) { 568 570 free(lengths); 569 return ERROR_CODE;571 return rc; 570 572 } 571 573 next_packet = packet; … … 573 575 // write the fragments 574 576 for (index = 0; index < fragments; ++index) { 575 ERROR_CODE= data_reply(packet_get_data(next_packet),577 rc = data_reply(packet_get_data(next_packet), 576 578 lengths[index]); 577 if ( ERROR_OCCURRED(ERROR_CODE)) {579 if (rc != EOK) { 578 580 free(lengths); 579 return ERROR_CODE;581 return rc; 580 582 } 581 583 next_packet = pq_next(next_packet); … … 680 682 socket_core_ref socket, const char *key, size_t key_length) 681 683 { 682 ERROR_DECLARE;683 684 684 socket_port_ref socket_port; 685 int rc; 685 686 686 687 // find ports … … 690 691 691 692 // add the socket 692 ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key, 693 key_length)); 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 if (rc != EOK) 695 return rc; 694 696 695 697 socket->port = port; -
uspace/lib/net/tl/tl_common.c
r63a1e60 r7494fb4 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h>57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 124 123 packet_dimension_ref *packet_dimension) 125 124 { 126 ERROR_DECLARE;125 int rc; 127 126 128 127 if (!packet_dimension) … … 137 136 return ENOMEM; 138 137 139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,140 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 141 140 free(*packet_dimension); 142 return ERROR_CODE;141 return rc; 143 142 } 144 143 145 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 146 145 *packet_dimension); 147 if ( ERROR_CODE< 0) {146 if (rc < 0) { 148 147 free(*packet_dimension); 149 return ERROR_CODE;148 return rc; 150 149 } 151 150 } … … 292 291 socklen_t addrlen) 293 292 { 294 ERROR_DECLARE;295 296 293 ipc_callid_t callid; 297 294 size_t length; 298 void * data; 295 void *data; 296 int rc; 299 297 300 298 if (!dimension) … … 319 317 320 318 // read the data into the packet 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 325 321 pq_release_remote(packet_phone, packet_get_id(*packet)); 326 return ERROR_CODE; 322 return rc; 323 } 324 325 // set the packet destination address 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 329 return rc; 327 330 } 328 331 -
uspace/lib/packet/generic/packet_server.c
r63a1e60 r7494fb4 42 42 #include <async.h> 43 43 #include <errno.h> 44 #include <err.h>45 44 #include <fibril_synch.h> 46 45 #include <unistd.h> … … 162 161 size_t max_content, size_t max_suffix) 163 162 { 164 ERROR_DECLARE;165 166 163 packet_t packet; 164 int rc; 167 165 168 166 // already locked … … 177 175 packet_init(packet, addr_len, max_prefix, max_content, max_suffix); 178 176 packet->magic_value = PACKET_MAGIC_VALUE; 179 if (ERROR_OCCURRED(pm_add(packet))) { 177 rc = pm_add(packet); 178 if (rc != EOK) { 180 179 munmap(packet, packet->length); 181 180 return NULL; -
uspace/srv/hw/netif/dp8390/dp8390.h
r63a1e60 r7494fb4 43 43 /** Input/output size. 44 44 */ 45 #define DP8390_IO_SIZE 0x0 1f45 #define DP8390_IO_SIZE 0x020 46 46 47 47 /* -
uspace/srv/hw/netif/dp8390/dp8390_module.c
r63a1e60 r7494fb4 158 158 159 159 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 160 ERROR_DECLARE;161 162 160 netif_device_t * device; 163 161 eth_stat_t * de_stat; 162 int rc; 164 163 165 164 if(! stats){ 166 165 return EBADMEM; 167 166 } 168 ERROR_PROPAGATE(find_device(device_id, &device)); 167 rc = find_device(device_id, &device); 168 if (rc != EOK) 169 return rc; 169 170 de_stat = &((dpeth_t *) device->specific)->de_stat; 170 171 null_device_stats(stats); … … 185 186 186 187 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 187 ERROR_DECLARE; 188 189 netif_device_t * device; 188 netif_device_t * device; 189 int rc; 190 190 191 191 if(! address){ 192 192 return EBADMEM; 193 193 } 194 ERROR_PROPAGATE(find_device(device_id, &device)); 194 rc = find_device(device_id, &device); 195 if (rc != EOK) 196 return rc; 195 197 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 196 198 address->length = CONVERT_SIZE(ether_addr_t, char, 1); … … 201 203 202 204 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 203 ERROR_DECLARE; 204 205 netif_device_t * device; 206 dpeth_t * dep; 205 netif_device_t * device; 206 dpeth_t * dep; 207 int rc; 207 208 208 209 device = (netif_device_t *) malloc(sizeof(netif_device_t)); … … 224 225 dep->de_mode = DEM_DISABLED; 225 226 //TODO address? 226 if(ERROR_OCCURRED(pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port))227 || ERROR_OCCURRED(do_probe(dep))){227 rc = pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port); 228 if (rc != EOK) { 228 229 free(dep); 229 230 free(device); 230 return ERROR_CODE; 231 } 232 if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){ 231 return rc; 232 } 233 rc = do_probe(dep); 234 if (rc != EOK) { 233 235 free(dep); 234 236 free(device); 235 return ERROR_CODE; 237 return rc; 238 } 239 rc = netif_device_map_add(&netif_globals.device_map, device->device_id, device); 240 if (rc != EOK){ 241 free(dep); 242 free(device); 243 return rc; 236 244 } 237 245 return EOK; … … 239 247 240 248 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){ 241 ERROR_DECLARE;242 243 249 netif_device_t * device; 244 250 dpeth_t * dep; 245 251 packet_t next; 246 247 ERROR_PROPAGATE(find_device(device_id, &device)); 252 int rc; 253 254 rc = find_device(device_id, &device); 255 if (rc != EOK) 256 return rc; 248 257 if(device->state != NETIF_ACTIVE){ 249 258 netif_pq_release(packet_get_id(packet)); … … 263 272 264 273 int netif_start_message(netif_device_t * device){ 265 ERROR_DECLARE; 266 267 dpeth_t * dep; 274 dpeth_t * dep; 275 int rc; 268 276 269 277 if(device->state != NETIF_ACTIVE){ … … 271 279 dp8390_cmds[0].addr = (void *) (uintptr_t) (dep->de_dp8390_port + DP_ISR); 272 280 dp8390_cmds[2].addr = dp8390_cmds[0].addr; 273 ERROR_PROPAGATE(ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code)); 274 if(ERROR_OCCURRED(do_init(dep, DL_BROAD_REQ))){ 281 rc = ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code); 282 if (rc != EOK) 283 return rc; 284 rc = do_init(dep, DL_BROAD_REQ); 285 if (rc != EOK) { 275 286 ipc_unregister_irq(dep->de_irq, device->device_id); 276 return ERROR_CODE;287 return rc; 277 288 } 278 289 return change_state(device, NETIF_ACTIVE); … … 350 361 int main(int argc, char *argv[]) 351 362 { 352 ERROR_DECLARE;363 int rc; 353 364 354 365 /* Start the module */ 355 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) 356 return ERROR_CODE; 357 358 return EOK; 366 rc = netif_module_start(netif_client_connection); 367 return rc; 359 368 } 360 369 -
uspace/srv/net/net/net.c
r63a1e60 r7494fb4 42 42 #include <ddi.h> 43 43 #include <errno.h> 44 #include <err.h>45 44 #include <malloc.h> 46 45 #include <stdio.h> … … 92 91 const char *value) 93 92 { 94 ERROR_DECLARE;93 int rc; 95 94 96 95 measured_string_ref setting = … … 100 99 101 100 /* Add the configuration setting */ 102 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 101 rc = measured_strings_add(configuration, name, 0, setting); 102 if (rc != EOK) { 103 103 free(setting); 104 return ERROR_CODE;104 return rc; 105 105 } 106 106 … … 110 110 /** Generate new system-unique device identifier. 111 111 * 112 * @returns The system-unique devic identifier. 113 * 112 * @returns The system-unique devic identifier. 114 113 */ 115 114 static device_id_t generate_new_device_id(void) … … 120 119 static int parse_line(measured_strings_ref configuration, char *line) 121 120 { 122 ERROR_DECLARE;121 int rc; 123 122 124 123 /* From the beginning */ … … 170 169 171 170 /* Add the configuration setting */ 172 if (ERROR_OCCURRED(measured_strings_add(configuration, name, 0, setting))) { 171 rc = measured_strings_add(configuration, name, 0, setting); 172 if (rc != EOK) { 173 173 free(setting); 174 return ERROR_CODE;174 return rc; 175 175 } 176 176 … … 181 181 measured_strings_ref configuration) 182 182 { 183 ERROR_DECLARE;184 185 183 printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename); 186 184 … … 206 204 if (index >= BUFFER_SIZE) { 207 205 line[BUFFER_SIZE - 1] = '\0'; 208 fprintf(stderr, "%s: Configuration line %u too long: %s\n",209 NAME, line_number, line);206 fprintf(stderr, "%s: Configuration line %u too " 207 "long: %s\n", NAME, line_number, line); 210 208 211 209 /* No space left in the line buffer */ 212 210 return EOVERFLOW; 213 } else {214 /* Append the character */215 line[index] = (char) read;216 index++;217 211 } 212 /* Append the character */ 213 line[index] = (char) read; 214 index++; 218 215 } else { 219 216 /* On error or new line */ 220 217 line[index] = '\0'; 221 218 line_number++; 222 if (ERROR_OCCURRED(parse_line(configuration, line))) 223 fprintf(stderr, "%s: Configuration error on line %u: %s\n", 224 NAME, line_number, line); 219 if (parse_line(configuration, line) != EOK) { 220 fprintf(stderr, "%s: Configuration error on " 221 "line %u: %s\n", NAME, line_number, line); 222 } 225 223 226 224 index = 0; … … 270 268 static int net_initialize(async_client_conn_t client_connection) 271 269 { 272 ERROR_DECLARE;270 int rc; 273 271 274 272 netifs_initialize(&net_globals.netifs); … … 278 276 279 277 // TODO: dynamic configuration 280 ERROR_PROPAGATE(read_configuration()); 281 282 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 283 LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service)); 284 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 285 DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service)); 286 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 287 ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, 288 connect_to_service)); 289 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, 290 NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, 291 connect_to_service)); 278 rc = read_configuration(); 279 if (rc != EOK) 280 return rc; 281 282 rc = add_module(NULL, &net_globals.modules, LO_NAME, LO_FILENAME, 283 SERVICE_LO, 0, connect_to_service); 284 if (rc != EOK) 285 return rc; 286 rc = add_module(NULL, &net_globals.modules, DP8390_NAME, 287 DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service); 288 if (rc != EOK) 289 return rc; 290 rc = add_module(NULL, &net_globals.modules, ETHERNET_NAME, 291 ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service); 292 if (rc != EOK) 293 return rc; 294 rc = add_module(NULL, &net_globals.modules, NILDUMMY_NAME, 295 NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service); 296 if (rc != EOK) 297 return rc; 292 298 293 299 /* Build specific initialization */ … … 314 320 static int net_module_start(async_client_conn_t client_connection) 315 321 { 316 ERROR_DECLARE; 322 ipcarg_t phonehash; 323 int rc; 317 324 318 325 async_set_client_connection(client_connection); 319 ERROR_PROPAGATE(pm_init()); 320 321 ipcarg_t phonehash; 322 323 if (ERROR_OCCURRED(net_initialize(client_connection)) || 324 ERROR_OCCURRED(REGISTER_ME(SERVICE_NETWORKING, &phonehash))) { 325 pm_destroy(); 326 return ERROR_CODE; 327 } 326 rc = pm_init(); 327 if (rc != EOK) 328 return rc; 329 330 331 rc = net_initialize(client_connection); 332 if (rc != EOK) 333 goto out; 334 335 rc = REGISTER_ME(SERVICE_NETWORKING, &phonehash); 336 if (rc != EOK) 337 goto out; 328 338 329 339 async_manager(); 330 340 341 out: 331 342 pm_destroy(); 332 return EOK;343 return rc; 333 344 } 334 345 … … 415 426 static int start_device(netif_t *netif) 416 427 { 417 ERROR_DECLARE;428 int rc; 418 429 419 430 /* Mandatory netif */ … … 456 467 int io = setting ? strtol(setting->value, NULL, 16) : 0; 457 468 458 ERROR_PROPAGATE(netif_probe_req_remote(netif->driver->phone, netif->id, irq, io)); 469 rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io); 470 if (rc != EOK) 471 return rc; 459 472 460 473 /* Network interface layer startup */ … … 468 481 int mtu = setting ? strtol(setting->value, NULL, 10) : 0; 469 482 470 ERROR_PROPAGATE(nil_device_req(netif->nil->phone, netif->id, mtu, 471 netif->driver->service)); 483 rc = nil_device_req(netif->nil->phone, netif->id, mtu, 484 netif->driver->service); 485 if (rc != EOK) 486 return rc; 472 487 473 488 internet_service = netif->nil->service; … … 478 493 switch (netif->il->service) { 479 494 case SERVICE_IP: 480 ERROR_PROPAGATE(ip_device_req(netif->il->phone, netif->id, 481 internet_service)); 495 rc = ip_device_req(netif->il->phone, netif->id, 496 internet_service); 497 if (rc != EOK) 498 return rc; 482 499 break; 483 500 default: … … 485 502 } 486 503 487 ERROR_PROPAGATE(netif_start_req_remote(netif->driver->phone, netif->id)); 488 return EOK; 504 return netif_start_req_remote(netif->driver->phone, netif->id); 489 505 } 490 506 … … 504 520 static int startup(void) 505 521 { 506 ERROR_DECLARE;507 508 522 const char *conf_files[] = { 509 523 "lo", … … 511 525 }; 512 526 size_t count = sizeof(conf_files) / sizeof(char *); 527 int rc; 513 528 514 529 size_t i; … … 522 537 return EXDEV; 523 538 524 ERROR_PROPAGATE(measured_strings_initialize(&netif->configuration)); 539 rc = measured_strings_initialize(&netif->configuration); 540 if (rc != EOK) 541 return rc; 525 542 526 543 /* Read configuration files */ 527 if (ERROR_OCCURRED(read_netif_configuration(conf_files[i], netif))) { 544 rc = read_netif_configuration(conf_files[i], netif); 545 if (rc != EOK) { 528 546 measured_strings_destroy(&netif->configuration); 529 547 free(netif); 530 return ERROR_CODE;548 return rc; 531 549 } 532 550 … … 554 572 * and needed modules. 555 573 */ 556 if ((ERROR_OCCURRED(char_map_add(&net_globals.netif_names, 557 netif->name, 0, index))) || (ERROR_OCCURRED(start_device(netif)))) { 574 rc = char_map_add(&net_globals.netif_names, netif->name, 0, 575 index); 576 if (rc != EOK) { 558 577 measured_strings_destroy(&netif->configuration); 559 578 netifs_exclude_index(&net_globals.netifs, index); 560 return ERROR_CODE; 579 return rc; 580 } 581 582 rc = start_device(netif); 583 if (rc != EOK) { 584 measured_strings_destroy(&netif->configuration); 585 netifs_exclude_index(&net_globals.netifs, index); 586 return rc; 561 587 } 562 588 … … 594 620 int *answer_count) 595 621 { 596 ERROR_DECLARE;597 598 622 measured_string_ref strings; 599 623 char *data; 624 int rc; 600 625 601 626 *answer_count = 0; … … 604 629 return EOK; 605 630 case NET_NET_GET_DEVICE_CONF: 606 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 607 IPC_GET_COUNT(call))); 631 rc = measured_strings_receive(&strings, &data, 632 IPC_GET_COUNT(call)); 633 if (rc != EOK) 634 return rc; 608 635 net_get_device_conf_req(0, IPC_GET_DEVICE(call), &strings, 609 636 IPC_GET_COUNT(call), NULL); … … 612 639 free(data); 613 640 614 ERROR_CODE= measured_strings_reply(strings, IPC_GET_COUNT(call));641 rc = measured_strings_reply(strings, IPC_GET_COUNT(call)); 615 642 free(strings); 616 return ERROR_CODE;643 return rc; 617 644 case NET_NET_GET_CONF: 618 ERROR_PROPAGATE(measured_strings_receive(&strings, &data, 619 IPC_GET_COUNT(call))); 645 rc = measured_strings_receive(&strings, &data, 646 IPC_GET_COUNT(call)); 647 if (rc != EOK) 648 return rc; 620 649 net_get_conf_req(0, &strings, IPC_GET_COUNT(call), NULL); 621 650 … … 623 652 free(data); 624 653 625 ERROR_CODE= measured_strings_reply(strings, IPC_GET_COUNT(call));654 rc = measured_strings_reply(strings, IPC_GET_COUNT(call)); 626 655 free(strings); 627 return ERROR_CODE;656 return rc; 628 657 case NET_NET_STARTUP: 629 658 return startup(); 630 659 } 660 631 661 return ENOTSUP; 632 662 } … … 670 700 int main(int argc, char *argv[]) 671 701 { 672 ERROR_DECLARE; 673 674 if (ERROR_OCCURRED(net_module_start(net_client_connection))) { 675 fprintf(stderr, "%s: net_module_start error %i\n", NAME, ERROR_CODE); 676 return ERROR_CODE; 702 int rc; 703 704 rc = net_module_start(net_client_connection); 705 if (rc != EOK) { 706 fprintf(stderr, "%s: net_module_start error %i\n", NAME, rc); 707 return rc; 677 708 } 678 709 -
uspace/srv/net/net/net_standalone.c
r63a1e60 r7494fb4 42 42 #include <ipc/ipc.h> 43 43 #include <ipc/net.h> 44 #include <errno.h> 44 45 45 46 #include <ip_interface.h> … … 60 61 int net_initialize_build(async_client_conn_t client_connection) 61 62 { 62 ERROR_DECLARE;63 int rc; 63 64 64 65 task_id_t task_id = spawn("/srv/ip"); … … 66 67 return EINVAL; 67 68 68 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME, 69 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module)); 69 rc = add_module(NULL, &net_globals.modules, IP_NAME, 70 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module); 71 if (rc != EOK) 72 return rc; 70 73 71 74 if (!spawn("/srv/icmp"))
Note:
See TracChangeset
for help on using the changeset viewer.