Changeset 357b5f5 in mainline for uspace/lib/c/generic
- Timestamp:
- 2011-01-23T20:09:13Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdb9982c
- Parents:
- cead2aa (diff), 7e36c8d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/c/generic
- Files:
-
- 1 added
- 1 deleted
- 28 edited
- 1 moved
-
adt/char_map.c (modified) (9 diffs)
-
adt/measured_strings.c (modified) (6 diffs)
-
async.c (modified) (29 diffs)
-
async_rel.c (deleted)
-
async_sess.c (added)
-
cap.c (modified) (2 diffs)
-
clipboard.c (modified) (4 diffs)
-
ddi.c (modified) (1 diff)
-
device/char_dev.c (moved) (moved from uspace/lib/c/generic/device/char.c ) (5 diffs)
-
device/hw_res.c (modified) (3 diffs)
-
devman.c (modified) (10 diffs)
-
devmap.c (modified) (13 diffs)
-
event.c (modified) (1 diff)
-
fibril.c (modified) (1 diff)
-
fibril_synch.c (modified) (9 diffs)
-
io/console.c (modified) (4 diffs)
-
io/screenbuffer.c (modified) (3 diffs)
-
io/vprintf.c (modified) (2 diffs)
-
ipc.c (modified) (28 diffs)
-
libc.c (modified) (2 diffs)
-
loader.c (modified) (5 diffs)
-
mem.c (modified) (1 diff)
-
net/icmp_api.c (modified) (2 diffs)
-
net/icmp_common.c (modified) (2 diffs)
-
net/inet.c (modified) (6 diffs)
-
net/modules.c (modified) (10 diffs)
-
net/packet.c (modified) (1 diff)
-
net/socket_client.c (modified) (55 diffs)
-
task.c (modified) (3 diffs)
-
udebug.c (modified) (4 diffs)
-
vfs/vfs.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
rcead2aa r357b5f5 65 65 */ 66 66 static int 67 char_map_add_item(char_map_t *map, const char*identifier, size_t length,67 char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length, 68 68 const int value) 69 69 { … … 90 90 } 91 91 92 map->items[map->next]->c = * identifier;93 ++ identifier;94 ++ map->next;95 if ((length > 1) || ((length == 0) && (*identifier))) {92 map->items[map->next]->c = *identifier; 93 identifier++; 94 map->next++; 95 if ((length > 1) || ((length == 0) && *identifier)) { 96 96 map->items[map->next - 1]->value = CHAR_MAP_NULL; 97 97 return char_map_add_item(map->items[map->next - 1], identifier, … … 139 139 */ 140 140 int 141 char_map_add(char_map_t *map, const char*identifier, size_t length,141 char_map_add(char_map_t *map, const uint8_t *identifier, size_t length, 142 142 const int value) 143 143 { 144 if (char_map_is_valid(map) && (identifier) && 145 ((length) || (*identifier))) { 144 if (char_map_is_valid(map) && identifier && (length || *identifier)) { 146 145 int index; 147 146 148 for (index = 0; index < map->next; ++ index) {147 for (index = 0; index < map->next; index++) { 149 148 if (map->items[index]->c != *identifier) 150 149 continue; 151 150 152 ++ identifier;153 if((length > 1) || ((length == 0) && (*identifier))) {151 identifier++; 152 if((length > 1) || ((length == 0) && *identifier)) { 154 153 return char_map_add(map->items[index], 155 154 identifier, length ? length - 1 : 0, value); … … 178 177 179 178 map->magic = 0; 180 for (index = 0; index < map->next; ++index)179 for (index = 0; index < map->next; index++) 181 180 char_map_destroy(map->items[index]); 182 181 … … 201 200 */ 202 201 static char_map_t * 203 char_map_find_node(const char_map_t *map, const char*identifier,202 char_map_find_node(const char_map_t *map, const uint8_t *identifier, 204 203 size_t length) 205 204 { … … 207 206 return NULL; 208 207 209 if (length || (*identifier)) {208 if (length || *identifier) { 210 209 int index; 211 210 212 for (index = 0; index < map->next; ++index) {211 for (index = 0; index < map->next; index++) { 213 212 if (map->items[index]->c == *identifier) { 214 ++identifier;213 identifier++; 215 214 if (length == 1) 216 215 return map->items[index]; … … 242 241 * @return CHAR_MAP_NULL if the key is not assigned a value. 243 242 */ 244 int char_map_exclude(char_map_t *map, const char*identifier, size_t length)243 int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length) 245 244 { 246 245 char_map_t *node; … … 270 269 * @return CHAR_MAP_NULL if the key is not assigned a value. 271 270 */ 272 int char_map_find(const char_map_t *map, const char*identifier, size_t length)271 int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length) 273 272 { 274 273 char_map_t *node; … … 330 329 */ 331 330 int 332 char_map_update(char_map_t *map, const char*identifier, const size_t length,331 char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length, 333 332 const int value) 334 333 { -
uspace/lib/c/generic/adt/measured_strings.c
rcead2aa r357b5f5 59 59 */ 60 60 measured_string_t * 61 measured_string_create_bulk(const char*string, size_t length)61 measured_string_create_bulk(const uint8_t *string, size_t length) 62 62 { 63 63 measured_string_t *new; … … 68 68 } 69 69 new = (measured_string_t *) malloc(sizeof(measured_string_t) + 70 (sizeof( char) * (length + 1)));70 (sizeof(uint8_t) * (length + 1))); 71 71 if (!new) 72 72 return NULL; 73 73 74 74 new->length = length; 75 new->value = (( char*) new) + sizeof(measured_string_t);75 new->value = ((uint8_t *) new) + sizeof(measured_string_t); 76 76 // append terminating zero explicitly - to be safe 77 77 memcpy(new->value, string, new->length); … … 97 97 new = (measured_string_t *) malloc(sizeof(measured_string_t)); 98 98 if (new) { 99 new->value = ( char*) malloc(source->length + 1);99 new->value = (uint8_t *) malloc(source->length + 1); 100 100 if (new->value) { 101 101 new->length = source->length; … … 131 131 */ 132 132 int 133 measured_strings_receive(measured_string_t **strings, char**data,133 measured_strings_receive(measured_string_t **strings, uint8_t **data, 134 134 size_t count) 135 135 { … … 137 137 size_t index; 138 138 size_t length; 139 char*next;139 uint8_t *next; 140 140 ipc_callid_t callid; 141 141 int rc; … … 311 311 */ 312 312 int 313 measured_strings_return(int phone, measured_string_t **strings, char**data,313 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data, 314 314 size_t count) 315 315 { 316 316 size_t *lengths; 317 317 size_t index; 318 char*next;318 uint8_t *next; 319 319 int rc; 320 320 -
uspace/lib/c/generic/async.c
rcead2aa r357b5f5 120 120 ipc_call_t *dataptr; 121 121 122 ipcarg_t retval;122 sysarg_t retval; 123 123 } amsg_t; 124 124 … … 140 140 141 141 /** Incoming phone hash. */ 142 ipcarg_t in_phone_hash;142 sysarg_t in_phone_hash; 143 143 144 144 /** Messages that should be delivered to this fibril. */ … … 288 288 list_append(&msg->link, &conn->msg_queue); 289 289 290 if (IPC_GET_ METHOD(*call) == IPC_M_PHONE_HUNGUP)290 if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP) 291 291 conn->close_callid = callid; 292 292 … … 401 401 */ 402 402 memset(call, 0, sizeof(ipc_call_t)); 403 IPC_SET_ METHOD(*call, IPC_M_PHONE_HUNGUP);403 IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP); 404 404 futex_up(&async_futex); 405 405 return conn->close_callid; … … 529 529 * 530 530 */ 531 fid_t async_new_connection( ipcarg_t in_phone_hash, ipc_callid_t callid,531 fid_t async_new_connection(sysarg_t in_phone_hash, ipc_callid_t callid, 532 532 ipc_call_t *call, void (*cfibril)(ipc_callid_t, ipc_call_t *)) 533 533 { … … 588 588 } 589 589 590 switch (IPC_GET_ METHOD(*call)) {590 switch (IPC_GET_IMETHOD(*call)) { 591 591 case IPC_M_CONNECT_ME: 592 592 case IPC_M_CONNECT_ME_TO: … … 749 749 return ENOMEM; 750 750 } 751 752 _async_sess_init(); 751 753 752 754 return 0; … … 807 809 * 808 810 */ 809 aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,810 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)811 aid_t async_send_fast(int phoneid, sysarg_t method, sysarg_t arg1, 812 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr) 811 813 { 812 814 amsg_t *msg = malloc(sizeof(*msg)); … … 846 848 * 847 849 */ 848 aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,849 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,850 aid_t async_send_slow(int phoneid, sysarg_t method, sysarg_t arg1, 851 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 850 852 ipc_call_t *dataptr) 851 853 { … … 875 877 * 876 878 */ 877 void async_wait_for(aid_t amsgid, ipcarg_t *retval)879 void async_wait_for(aid_t amsgid, sysarg_t *retval) 878 880 { 879 881 amsg_t *msg = (amsg_t *) amsgid; … … 911 913 * 912 914 */ 913 int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout)915 int async_wait_timeout(aid_t amsgid, sysarg_t *retval, suseconds_t timeout) 914 916 { 915 917 amsg_t *msg = (amsg_t *) amsgid; … … 1023 1025 * 1024 1026 */ 1025 ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,1026 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,1027 ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)1027 sysarg_t async_req_fast(int phoneid, sysarg_t method, sysarg_t arg1, 1028 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2, 1029 sysarg_t *r3, sysarg_t *r4, sysarg_t *r5) 1028 1030 { 1029 1031 ipc_call_t result; … … 1031 1033 &result); 1032 1034 1033 ipcarg_t rc;1035 sysarg_t rc; 1034 1036 async_wait_for(eid, &rc); 1035 1037 … … 1072 1074 * 1073 1075 */ 1074 ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,1075 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,1076 ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)1076 sysarg_t async_req_slow(int phoneid, sysarg_t method, sysarg_t arg1, 1077 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1, 1078 sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5) 1077 1079 { 1078 1080 ipc_call_t result; … … 1080 1082 &result); 1081 1083 1082 ipcarg_t rc;1084 sysarg_t rc; 1083 1085 async_wait_for(eid, &rc); 1084 1086 … … 1113 1115 */ 1114 1116 int 1115 async_connect_me_to(int phoneid, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3)1117 async_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3) 1116 1118 { 1117 1119 int rc; 1118 ipcarg_t newphid;1120 sysarg_t newphid; 1119 1121 1120 1122 rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL, … … 1140 1142 */ 1141 1143 int 1142 async_connect_me_to_blocking(int phoneid, ipcarg_t arg1, ipcarg_t arg2,1143 ipcarg_t arg3)1144 async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2, 1145 sysarg_t arg3) 1144 1146 { 1145 1147 int rc; 1146 ipcarg_t newphid;1148 sysarg_t newphid; 1147 1149 1148 1150 rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, … … 1166 1168 * @return Zero on success or a negative error code from errno.h. 1167 1169 */ 1168 int async_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,1170 int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg, 1169 1171 int *flags) 1170 1172 { 1171 1173 int res; 1172 1174 sysarg_t tmp_flags; 1173 res = async_req_3_2(phoneid, IPC_M_SHARE_IN, ( ipcarg_t) dst,1174 ( ipcarg_t) size, arg, NULL, &tmp_flags);1175 res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst, 1176 (sysarg_t) size, arg, NULL, &tmp_flags); 1175 1177 if (flags) 1176 1178 *flags = tmp_flags; … … 1199 1201 1200 1202 *callid = async_get_call(&data); 1201 if (IPC_GET_ METHOD(data) != IPC_M_SHARE_IN)1203 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN) 1202 1204 return 0; 1203 1205 *size = (size_t) IPC_GET_ARG2(data); … … 1231 1233 int async_share_out_start(int phoneid, void *src, int flags) 1232 1234 { 1233 return async_req_3_0(phoneid, IPC_M_SHARE_OUT, ( ipcarg_t) src, 0,1234 ( ipcarg_t) flags);1235 return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0, 1236 (sysarg_t) flags); 1235 1237 } 1236 1238 … … 1259 1261 1260 1262 *callid = async_get_call(&data); 1261 if (IPC_GET_ METHOD(data) != IPC_M_SHARE_OUT)1263 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT) 1262 1264 return 0; 1263 1265 *size = (size_t) IPC_GET_ARG2(data); … … 1292 1294 int async_data_read_start(int phoneid, void *dst, size_t size) 1293 1295 { 1294 return async_req_2_0(phoneid, IPC_M_DATA_READ, ( ipcarg_t) dst,1295 ( ipcarg_t) size);1296 return async_req_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst, 1297 (sysarg_t) size); 1296 1298 } 1297 1299 … … 1317 1319 1318 1320 *callid = async_get_call(&data); 1319 if (IPC_GET_ METHOD(data) != IPC_M_DATA_READ)1321 if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ) 1320 1322 return 0; 1321 1323 if (size) … … 1345 1347 * 1346 1348 */ 1347 int async_data_read_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,1348 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)1349 int async_data_read_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1, 1350 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr) 1349 1351 { 1350 1352 ipc_callid_t callid; … … 1369 1371 } 1370 1372 1371 ipcarg_t rc;1373 sysarg_t rc; 1372 1374 async_wait_for(msg, &rc); 1373 1375 … … 1386 1388 int async_data_write_start(int phoneid, const void *src, size_t size) 1387 1389 { 1388 return async_req_2_0(phoneid, IPC_M_DATA_WRITE, ( ipcarg_t) src,1389 ( ipcarg_t) size);1390 return async_req_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src, 1391 (sysarg_t) size); 1390 1392 } 1391 1393 … … 1412 1414 1413 1415 *callid = async_get_call(&data); 1414 if (IPC_GET_ METHOD(data) != IPC_M_DATA_WRITE)1416 if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE) 1415 1417 return 0; 1416 1418 … … 1531 1533 * 1532 1534 */ 1533 int async_data_write_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,1534 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)1535 int async_data_write_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1, 1536 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr) 1535 1537 { 1536 1538 ipc_callid_t callid; … … 1555 1557 } 1556 1558 1557 ipcarg_t rc;1559 sysarg_t rc; 1558 1560 async_wait_for(msg, &rc); 1559 1561 -
uspace/lib/c/generic/cap.c
rcead2aa r357b5f5 31 31 */ 32 32 /** 33 * @file cap.c34 * @brief Functions to grant/revoke capabilities to/from a task.33 * @file cap.c 34 * @brief Functions to grant/revoke capabilities to/from a task. 35 35 */ 36 36 … … 38 38 #include <task.h> 39 39 #include <libc.h> 40 #include <kernel/syscall/sysarg64.h>41 40 42 41 /** Grant capabilities to a task. 43 42 * 44 * @param id Destination task ID.43 * @param id Destination task ID. 45 44 * @param caps Capabilities to grant. 46 45 * 47 46 * @return Zero on success or a value from @ref errno.h on failure. 47 * 48 48 */ 49 49 int cap_grant(task_id_t id, unsigned int caps) 50 50 { 51 sysarg64_t arg; 51 #ifdef __32_BITS__ 52 sysarg64_t arg = (sysarg64_t) id; 53 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); 54 #endif 52 55 53 arg.value = (unsigned long long) id; 54 55 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps); 56 #ifdef __64_BITS__ 57 return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) id, (sysarg_t) caps); 58 #endif 56 59 } 57 60 58 61 /** Revoke capabilities from a task. 59 62 * 60 * @param id Destination task ID.63 * @param id Destination task ID. 61 64 * @param caps Capabilities to revoke. 62 65 * 63 66 * @return Zero on success or a value from @ref errno.h on failure. 67 * 64 68 */ 65 69 int cap_revoke(task_id_t id, unsigned int caps) 66 70 { 67 sysarg64_t arg; 71 #ifdef __32_BITS__ 72 sysarg64_t arg = (sysarg64_t) id; 73 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); 74 #endif 68 75 69 arg.value = (unsigned long long) id; 70 71 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps); 76 #ifdef __64_BITS__ 77 return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) id, (sysarg_t) caps); 78 #endif 72 79 } 73 80 -
uspace/lib/c/generic/clipboard.c
rcead2aa r357b5f5 75 75 clip_connect(); 76 76 77 ipcarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE);77 sysarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE); 78 78 79 79 async_serialize_end(); … … 85 85 86 86 aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, NULL); 87 ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size);87 sysarg_t rc = async_data_write_start(clip_phone, (void *) str, size); 88 88 if (rc != EOK) { 89 ipcarg_t rc_orig;89 sysarg_t rc_orig; 90 90 async_wait_for(req, &rc_orig); 91 91 async_serialize_end(); … … 119 119 clip_connect(); 120 120 121 ipcarg_t size;122 ipcarg_t tag;123 ipcarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag);121 sysarg_t size; 122 sysarg_t tag; 123 sysarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag); 124 124 125 125 async_serialize_end(); … … 158 158 159 159 if (rc != EOK) { 160 ipcarg_t rc_orig;160 sysarg_t rc_orig; 161 161 async_wait_for(req, &rc_orig); 162 162 async_serialize_end(); -
uspace/lib/c/generic/ddi.c
rcead2aa r357b5f5 96 96 } 97 97 98 /** Enable an interrupt.99 *100 * @param irq the interrupt.101 *102 * @return Zero on success, negative error code otherwise.103 */104 int interrupt_enable(int irq)105 {106 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1);107 }108 109 /** Disable an interrupt.110 *111 * @param irq the interrupt.112 *113 * @return Zero on success, negative error code otherwise.114 */115 int interrupt_disable(int irq)116 {117 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0);118 }119 120 98 /** Enable PIO for specified I/O range. 121 99 * -
uspace/lib/c/generic/device/char_dev.c
rcead2aa r357b5f5 34 34 35 35 #include <ipc/dev_iface.h> 36 #include <device/char .h>36 #include <device/char_dev.h> 37 37 #include <errno.h> 38 38 #include <async.h> … … 45 45 * using its character interface. 46 46 * 47 * @param dev_phone Phone to the device. 48 * @param buf Buffer for the data read 49 * from or written to the device. 50 * @param len Maximum length of the data to be 51 * read or written. 52 * @param read Read from the device if true, 53 * write to it otherwise. 47 * @param dev_phone Phone to the device. 48 * @param buf Buffer for the data read from or written to the device. 49 * @param size Maximum size of data (in bytes) to be read or written. 50 * @param read Read from the device if true, write to it otherwise. 54 51 * 55 * @return Non-negative number of bytes actually read 56 * from or written to the device on success, 57 * negative error number otherwise. 58 * 52 * @return Non-negative number of bytes actually read from or 53 * written to the device on success, negative error number 54 * otherwise. 59 55 */ 60 static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)56 static ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read) 61 57 { 62 58 async_serialize_start(); … … 68 64 if (read) { 69 65 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), 70 CHAR_ READ_DEV, &answer);71 ret = async_data_read_start(dev_phone, buf, len);66 CHAR_DEV_READ, &answer); 67 ret = async_data_read_start(dev_phone, buf, size); 72 68 } else { 73 69 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), 74 CHAR_ WRITE_DEV, &answer);75 ret = async_data_write_start(dev_phone, buf, len);70 CHAR_DEV_WRITE, &answer); 71 ret = async_data_write_start(dev_phone, buf, size); 76 72 } 77 73 78 ipcarg_t rc;74 sysarg_t rc; 79 75 if (ret != EOK) { 80 76 async_wait_for(req, &rc); … … 82 78 if (rc == EOK) 83 79 return (ssize_t) ret; 84 80 85 81 return (ssize_t) rc; 86 82 } … … 96 92 } 97 93 98 /** Read from device using its character interface.94 /** Read from character device. 99 95 * 100 * @param dev_phone Phone to the device. 101 * @param buf Output buffer for the data 102 * read from the device. 103 * @param len Maximum length of the data to be read. 96 * @param dev_phone Phone to the device. 97 * @param buf Output buffer for the data read from the device. 98 * @param size Maximum size (in bytes) of the data to be read. 104 99 * 105 * @return Non-negative number of bytes actually read 106 * from the device on success, negative error 107 * number otherwise. 108 * 100 * @return Non-negative number of bytes actually read from the 101 * device on success, negative error number otherwise. 109 102 */ 110 ssize_t read_dev(int dev_phone, void *buf, size_t len)103 ssize_t char_dev_read(int dev_phone, void *buf, size_t size) 111 104 { 112 return rw_dev(dev_phone, buf, len, true);105 return char_dev_rw(dev_phone, buf, size, true); 113 106 } 114 107 115 /** Write to device using its character interface.108 /** Write to character device. 116 109 * 117 * @param dev_phone Phone to the device.118 * @param buf Input buffer containg the data119 * to be written to thedevice.120 * @param len Maximum lengthof the data to be written.110 * @param dev_phone Phone to the device. 111 * @param buf Input buffer containg the data to be written to the 112 * device. 113 * @param size Maximum size (in bytes) of the data to be written. 121 114 * 122 * @return Non-negative number of bytes actually written 123 * to the device on success, negative error number 124 * otherwise. 125 * 115 * @return Non-negative number of bytes actually written to the 116 * device on success, negative error number otherwise. 126 117 */ 127 ssize_t write_dev(int dev_phone, void *buf, size_t len)118 ssize_t char_dev_write(int dev_phone, void *buf, size_t size) 128 119 { 129 return rw_dev(dev_phone, buf, len, false);120 return char_dev_rw(dev_phone, buf, size, false); 130 121 } 131 122 -
uspace/lib/c/generic/device/hw_res.c
rcead2aa r357b5f5 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ … … 32 32 /** @file 33 33 */ 34 34 35 35 #include <device/hw_res.h> 36 36 #include <errno.h> … … 38 38 #include <malloc.h> 39 39 40 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)40 int hw_res_get_resource_list(int dev_phone, hw_resource_list_t *hw_resources) 41 41 { 42 ipcarg_t count = 0; 43 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count); 42 sysarg_t count = 0; 43 44 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), 45 HW_RES_GET_RESOURCE_LIST, &count); 46 44 47 hw_resources->count = count; 45 if (EOK != rc) { 46 return false; 47 } 48 if (rc != EOK) 49 return rc; 48 50 49 51 size_t size = count * sizeof(hw_resource_t); 50 52 hw_resources->resources = (hw_resource_t *)malloc(size); 51 if (NULL == hw_resources->resources) { 52 return false; 53 if (!hw_resources->resources) 54 return ENOMEM; 55 56 rc = async_data_read_start(dev_phone, hw_resources->resources, size); 57 if (rc != EOK) { 58 free(hw_resources->resources); 59 hw_resources->resources = NULL; 60 return rc; 53 61 } 54 62 55 rc = async_data_read_start(dev_phone, hw_resources->resources, size); 56 if (EOK != rc) { 57 free(hw_resources->resources); 58 hw_resources->resources = NULL; 59 return false; 60 } 61 62 return true; 63 return EOK; 63 64 } 64 65 65 bool enable_interrupt(int dev_phone)66 bool hw_res_enable_interrupt(int dev_phone) 66 67 { 67 int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT); 68 int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), 69 HW_RES_ENABLE_INTERRUPT); 70 68 71 return rc == EOK; 69 72 } 70 71 72 73 /** @} 73 74 /** @} 74 75 */ -
uspace/lib/c/generic/devman.c
rcead2aa r357b5f5 42 42 #include <devman.h> 43 43 #include <async.h> 44 #include <fibril_synch.h> 44 45 #include <errno.h> 45 46 #include <malloc.h> … … 50 51 static int devman_phone_client = -1; 51 52 53 static FIBRIL_MUTEX_INITIALIZE(devman_phone_mutex); 54 52 55 int devman_get_phone(devman_interface_t iface, unsigned int flags) 53 56 { 54 57 switch (iface) { 55 58 case DEVMAN_DRIVER: 56 if (devman_phone_driver >= 0) 59 fibril_mutex_lock(&devman_phone_mutex); 60 if (devman_phone_driver >= 0) { 61 fibril_mutex_unlock(&devman_phone_mutex); 57 62 return devman_phone_driver; 63 } 58 64 59 65 if (flags & IPC_FLAG_BLOCKING) 60 devman_phone_driver = ipc_connect_me_to_blocking(PHONE_NS, 66 devman_phone_driver = async_connect_me_to_blocking( 67 PHONE_NS, SERVICE_DEVMAN, DEVMAN_DRIVER, 0); 68 else 69 devman_phone_driver = async_connect_me_to(PHONE_NS, 61 70 SERVICE_DEVMAN, DEVMAN_DRIVER, 0); 62 else 63 devman_phone_driver = ipc_connect_me_to(PHONE_NS, 64 SERVICE_DEVMAN, DEVMAN_DRIVER, 0); 65 71 72 fibril_mutex_unlock(&devman_phone_mutex); 66 73 return devman_phone_driver; 67 74 case DEVMAN_CLIENT: 68 if (devman_phone_client >= 0) 75 fibril_mutex_lock(&devman_phone_mutex); 76 if (devman_phone_client >= 0) { 77 fibril_mutex_unlock(&devman_phone_mutex); 69 78 return devman_phone_client; 70 71 if (flags & IPC_FLAG_BLOCKING) 72 devman_phone_client = ipc_connect_me_to_blocking(PHONE_NS, 79 } 80 81 if (flags & IPC_FLAG_BLOCKING) { 82 devman_phone_client = async_connect_me_to_blocking( 83 PHONE_NS, SERVICE_DEVMAN, DEVMAN_CLIENT, 0); 84 } else { 85 devman_phone_client = async_connect_me_to(PHONE_NS, 73 86 SERVICE_DEVMAN, DEVMAN_CLIENT, 0); 74 else 75 devman_phone_client = ipc_connect_me_to(PHONE_NS, 76 SERVICE_DEVMAN, DEVMAN_CLIENT, 0); 77 87 } 88 89 fibril_mutex_unlock(&devman_phone_mutex); 78 90 return devman_phone_client; 79 91 default: … … 95 107 aid_t req = async_send_2(phone, DEVMAN_DRIVER_REGISTER, 0, 0, &answer); 96 108 97 ipcarg_t retval = async_data_write_start(phone, name, str_size(name));109 sysarg_t retval = async_data_write_start(phone, name, str_size(name)); 98 110 if (retval != EOK) { 99 111 async_wait_for(req, NULL); … … 104 116 async_set_client_connection(conn); 105 117 106 ipcarg_t callback_phonehash;118 sysarg_t callback_phonehash; 107 119 ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); 108 120 async_wait_for(req, &retval); … … 116 128 { 117 129 ipc_call_t answer; 118 a sync_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);130 aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer); 119 131 int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id)); 120 return retval; 132 async_wait_for(req, NULL); 133 return retval; 121 134 } 122 135 … … 154 167 aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer); 155 168 156 ipcarg_t retval = async_data_write_start(phone, name, str_size(name));169 sysarg_t retval = async_data_write_start(phone, name, str_size(name)); 157 170 if (retval != EOK) { 158 171 async_wait_for(req, NULL); … … 191 204 aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer); 192 205 193 ipcarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));206 sysarg_t retval = async_data_write_start(phone, class_name, str_size(class_name)); 194 207 if (retval != EOK) { 195 208 async_wait_for(req, NULL); … … 229 242 230 243 if (flags & IPC_FLAG_BLOCKING) { 231 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,244 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN, 232 245 DEVMAN_CONNECT_TO_DEVICE, handle); 233 246 } else { 234 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,247 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN, 235 248 DEVMAN_CONNECT_TO_DEVICE, handle); 236 249 } … … 244 257 245 258 if (flags & IPC_FLAG_BLOCKING) { 246 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,259 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN, 247 260 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle); 248 261 } else { 249 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,262 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN, 250 263 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle); 251 264 } … … 267 280 &answer); 268 281 269 ipcarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));282 sysarg_t retval = async_data_write_start(phone, pathname, str_size(pathname)); 270 283 if (retval != EOK) { 271 284 async_wait_for(req, NULL); -
uspace/lib/c/generic/devmap.c
rcead2aa r357b5f5 107 107 aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); 108 108 109 ipcarg_t retval = async_data_write_start(phone, name, str_size(name));109 sysarg_t retval = async_data_write_start(phone, name, str_size(name)); 110 110 if (retval != EOK) { 111 111 async_wait_for(req, NULL); … … 116 116 async_set_client_connection(conn); 117 117 118 ipcarg_t callback_phonehash;118 sysarg_t callback_phonehash; 119 119 ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); 120 120 async_wait_for(req, &retval); … … 127 127 /** Register new device. 128 128 * 129 * @param namespace Namespace name. 129 * The @p interface is used when forwarding connection to the driver. 130 * If not 0, the first argument is the interface and the second argument 131 * is the devmap handle of the device. 132 * When the interface is zero (default), the first argument is directly 133 * the handle (to ensure backward compatibility). 134 * 135 * @param fqdn Fully qualified device name. 136 * @param[out] handle Handle to the created instance of device. 137 * @param interface Interface when forwarding. 138 * 139 */ 140 int devmap_device_register_with_iface(const char *fqdn, 141 devmap_handle_t *handle, sysarg_t interface) 142 { 143 int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING); 144 145 if (phone < 0) 146 return phone; 147 148 async_serialize_start(); 149 150 ipc_call_t answer; 151 aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, interface, 0, 152 &answer); 153 154 sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn)); 155 if (retval != EOK) { 156 async_wait_for(req, NULL); 157 async_serialize_end(); 158 return retval; 159 } 160 161 async_wait_for(req, &retval); 162 163 async_serialize_end(); 164 165 if (retval != EOK) { 166 if (handle != NULL) 167 *handle = -1; 168 return retval; 169 } 170 171 if (handle != NULL) 172 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 173 174 return retval; 175 } 176 177 /** Register new device. 178 * 130 179 * @param fqdn Fully qualified device name. 131 180 * @param handle Output: Handle to the created instance of device. … … 134 183 int devmap_device_register(const char *fqdn, devmap_handle_t *handle) 135 184 { 136 int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING); 137 138 if (phone < 0) 139 return phone; 140 141 async_serialize_start(); 142 143 ipc_call_t answer; 144 aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, 0, 0, 145 &answer); 146 147 ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn)); 148 if (retval != EOK) { 149 async_wait_for(req, NULL); 150 async_serialize_end(); 151 return retval; 152 } 153 154 async_wait_for(req, &retval); 155 156 async_serialize_end(); 157 158 if (retval != EOK) { 159 if (handle != NULL) 160 *handle = -1; 161 return retval; 162 } 163 164 if (handle != NULL) 165 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 166 167 return retval; 168 } 185 return devmap_device_register_with_iface(fqdn, handle, 0); 186 } 187 169 188 170 189 int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags) … … 181 200 &answer); 182 201 183 ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));202 sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn)); 184 203 if (retval != EOK) { 185 204 async_wait_for(req, NULL); … … 217 236 &answer); 218 237 219 ipcarg_t retval = async_data_write_start(phone, name, str_size(name));238 sysarg_t retval = async_data_write_start(phone, name, str_size(name)); 220 239 if (retval != EOK) { 221 240 async_wait_for(req, NULL); … … 247 266 return phone; 248 267 249 ipcarg_t type;268 sysarg_t type; 250 269 int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type); 251 270 if (retval != EOK) … … 260 279 261 280 if (flags & IPC_FLAG_BLOCKING) { 262 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,281 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, 263 282 DEVMAP_CONNECT_TO_DEVICE, handle); 264 283 } else { 265 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,284 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP, 266 285 DEVMAP_CONNECT_TO_DEVICE, handle); 267 286 } … … 277 296 return -1; 278 297 279 ipcarg_t null_id;298 sysarg_t null_id; 280 299 int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id); 281 300 if (retval != EOK) … … 292 311 return; 293 312 294 async_req_1_0(phone, DEVMAP_NULL_DESTROY, ( ipcarg_t) null_id);313 async_req_1_0(phone, DEVMAP_NULL_DESTROY, (sysarg_t) null_id); 295 314 } 296 315 297 316 static size_t devmap_count_namespaces_internal(int phone) 298 317 { 299 ipcarg_t count;318 sysarg_t count; 300 319 int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count); 301 320 if (retval != EOK) … … 307 326 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle) 308 327 { 309 ipcarg_t count;328 sysarg_t count; 310 329 int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count); 311 330 if (retval != EOK) … … 375 394 } 376 395 377 ipcarg_t retval;396 sysarg_t retval; 378 397 async_wait_for(req, &retval); 379 398 async_serialize_end(); … … 427 446 } 428 447 429 ipcarg_t retval;448 sysarg_t retval; 430 449 async_wait_for(req, &retval); 431 450 async_serialize_end(); -
uspace/lib/c/generic/event.c
rcead2aa r357b5f5 49 49 * @return Value returned by the kernel. 50 50 */ 51 int event_subscribe(event_type_t e, ipcarg_t method)51 int event_subscribe(event_type_t e, sysarg_t method) 52 52 { 53 53 return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) e, (sysarg_t) method); -
uspace/lib/c/generic/fibril.c
rcead2aa r357b5f5 361 361 } 362 362 363 int fibril_get_sercount(void) 364 { 365 return serialization_count; 366 } 367 363 368 /** @} 364 369 */ -
uspace/lib/c/generic/fibril_synch.c
rcead2aa r357b5f5 104 104 fibril_t *f = (fibril_t *) fibril_get_id(); 105 105 106 if (fibril_get_sercount() != 0) 107 core(); 108 106 109 futex_down(&async_futex); 107 110 if (fm->counter-- <= 0) { … … 139 142 static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm) 140 143 { 141 assert(fm->counter <= 0);142 144 if (fm->counter++ < 0) { 143 145 link_t *tmp; … … 165 167 void fibril_mutex_unlock(fibril_mutex_t *fm) 166 168 { 169 assert(fibril_mutex_is_locked(fm)); 167 170 futex_down(&async_futex); 168 171 _fibril_mutex_unlock_unsafe(fm); 169 172 futex_up(&async_futex); 173 } 174 175 bool fibril_mutex_is_locked(fibril_mutex_t *fm) 176 { 177 bool locked = false; 178 179 futex_down(&async_futex); 180 if (fm->counter <= 0) 181 locked = true; 182 futex_up(&async_futex); 183 184 return locked; 170 185 } 171 186 … … 182 197 fibril_t *f = (fibril_t *) fibril_get_id(); 183 198 199 if (fibril_get_sercount() != 0) 200 core(); 201 184 202 futex_down(&async_futex); 185 203 if (frw->writers) { … … 207 225 fibril_t *f = (fibril_t *) fibril_get_id(); 208 226 227 if (fibril_get_sercount() != 0) 228 core(); 229 209 230 futex_down(&async_futex); 210 231 if (frw->writers || frw->readers) { … … 230 251 { 231 252 futex_down(&async_futex); 232 assert(frw->readers || (frw->writers == 1));233 253 if (frw->readers) { 234 254 if (--frw->readers) { … … 296 316 void fibril_rwlock_read_unlock(fibril_rwlock_t *frw) 297 317 { 318 assert(fibril_rwlock_is_read_locked(frw)); 298 319 _fibril_rwlock_common_unlock(frw); 299 320 } … … 301 322 void fibril_rwlock_write_unlock(fibril_rwlock_t *frw) 302 323 { 324 assert(fibril_rwlock_is_write_locked(frw)); 303 325 _fibril_rwlock_common_unlock(frw); 326 } 327 328 bool fibril_rwlock_is_read_locked(fibril_rwlock_t *frw) 329 { 330 bool locked = false; 331 332 futex_down(&async_futex); 333 if (frw->readers) 334 locked = true; 335 futex_up(&async_futex); 336 337 return locked; 338 } 339 340 bool fibril_rwlock_is_write_locked(fibril_rwlock_t *frw) 341 { 342 bool locked = false; 343 344 futex_down(&async_futex); 345 if (frw->writers) { 346 assert(frw->writers == 1); 347 locked = true; 348 } 349 futex_up(&async_futex); 350 351 return locked; 352 } 353 354 bool fibril_rwlock_is_locked(fibril_rwlock_t *frw) 355 { 356 return fibril_rwlock_is_read_locked(frw) || 357 fibril_rwlock_is_write_locked(frw); 304 358 } 305 359 … … 314 368 { 315 369 awaiter_t wdata; 370 371 assert(fibril_mutex_is_locked(fm)); 316 372 317 373 if (timeout < 0) -
uspace/lib/c/generic/io/console.c
rcead2aa r357b5f5 45 45 } 46 46 47 int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows)47 int console_get_size(int phone, sysarg_t *cols, sysarg_t *rows) 48 48 { 49 49 return async_req_0_2(phone, CONSOLE_GET_SIZE, cols, rows); … … 71 71 } 72 72 73 int console_get_color_cap(int phone, ipcarg_t *ccap)73 int console_get_color_cap(int phone, sysarg_t *ccap) 74 74 { 75 75 return async_req_0_1(phone, CONSOLE_GET_COLOR_CAP, ccap); … … 81 81 } 82 82 83 int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row)83 int console_get_pos(int phone, sysarg_t *col, sysarg_t *row) 84 84 { 85 85 return async_req_0_2(phone, CONSOLE_GET_POS, col, row); 86 86 } 87 87 88 void console_set_pos(int phone, ipcarg_t col, ipcarg_t row)88 void console_set_pos(int phone, sysarg_t col, sysarg_t row) 89 89 { 90 90 async_msg_2(phone, CONSOLE_GOTO, col, row); … … 93 93 bool console_get_event(int phone, console_event_t *event) 94 94 { 95 ipcarg_t type;96 ipcarg_t key;97 ipcarg_t mods;98 ipcarg_t c;95 sysarg_t type; 96 sysarg_t key; 97 sysarg_t mods; 98 sysarg_t c; 99 99 100 100 int rc = async_req_0_4(phone, CONSOLE_GET_EVENT, &type, &key, &mods, &c); -
uspace/lib/c/generic/io/screenbuffer.c
rcead2aa r357b5f5 67 67 * 68 68 */ 69 screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, ipcarg_t size_x,70 ipcarg_t size_y)69 screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, sysarg_t size_x, 70 sysarg_t size_y) 71 71 { 72 72 scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y); … … 110 110 * 111 111 */ 112 void screenbuffer_clear_line(screenbuffer_t *scr, ipcarg_t line)112 void screenbuffer_clear_line(screenbuffer_t *scr, sysarg_t line) 113 113 { 114 ipcarg_t x;114 sysarg_t x; 115 115 116 116 for (x = 0; x < scr->size_x; x++) { … … 141 141 * 142 142 */ 143 void screenbuffer_goto(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)143 void screenbuffer_goto(screenbuffer_t *scr, sysarg_t x, sysarg_t y) 144 144 { 145 145 scr->position_x = x % scr->size_x; -
uspace/lib/c/generic/io/vprintf.c
rcead2aa r357b5f5 37 37 #include <unistd.h> 38 38 #include <io/printf_core.h> 39 #include <f utex.h>39 #include <fibril_synch.h> 40 40 #include <async.h> 41 41 #include <str.h> 42 42 43 static atomic_t printf_futex = FUTEX_INITIALIZER;43 static FIBRIL_MUTEX_INITIALIZE(printf_mutex); 44 44 45 45 static int vprintf_str_write(const char *str, size_t size, void *stream) … … 85 85 * Prevent other threads to execute printf_core() 86 86 */ 87 futex_down(&printf_futex); 88 89 /* 90 * Prevent other fibrils of the same thread 91 * to execute printf_core() 92 */ 93 async_serialize_start(); 87 fibril_mutex_lock(&printf_mutex); 94 88 95 89 int ret = printf_core(fmt, &ps, ap); 96 90 97 async_serialize_end(); 98 futex_up(&printf_futex); 91 fibril_mutex_unlock(&printf_mutex); 99 92 100 93 return ret; -
uspace/lib/c/generic/ipc.c
rcead2aa r357b5f5 38 38 */ 39 39 /** @file 40 */ 40 */ 41 41 42 42 #include <ipc/ipc.h> … … 104 104 */ 105 105 int 106 ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,107 ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3,108 ipcarg_t *result4, ipcarg_t *result5)106 ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2, 107 sysarg_t arg3, sysarg_t *result1, sysarg_t *result2, sysarg_t *result3, 108 sysarg_t *result4, sysarg_t *result5) 109 109 { 110 110 ipc_call_t resdata; … … 131 131 /** Make a synchronous call transmitting 5 arguments of payload. 132 132 * 133 * @param phoneid Phone handle for the call. 134 * @param method Requested method. 135 * @param arg1 Service-defined payload argument. 136 * @param arg2 Service-defined payload argument. 137 * @param arg3 Service-defined payload argument. 138 * @param arg4 Service-defined payload argument. 139 * @param arg5 Service-defined payload argument. 140 * @param result1 If non-NULL, storage for the first return argument. 141 * @param result2 If non-NULL, storage for the second return argument. 142 * @param result3 If non-NULL, storage for the third return argument. 143 * @param result4 If non-NULL, storage for the fourth return argument. 144 * @param result5 If non-NULL, storage for the fifth return argument. 145 * 146 * @return Negative value means IPC error. 147 * Otherwise the RETVAL of the answer. 133 * @param phoneid Phone handle for the call. 134 * @param imethod Requested interface and method. 135 * @param arg1 Service-defined payload argument. 136 * @param arg2 Service-defined payload argument. 137 * @param arg3 Service-defined payload argument. 138 * @param arg4 Service-defined payload argument. 139 * @param arg5 Service-defined payload argument. 140 * @param result1 If non-NULL, storage for the first return argument. 141 * @param result2 If non-NULL, storage for the second return argument. 142 * @param result3 If non-NULL, storage for the third return argument. 143 * @param result4 If non-NULL, storage for the fourth return argument. 144 * @param result5 If non-NULL, storage for the fifth return argument. 145 * 146 * @return Negative value means IPC error. 147 * Otherwise the RETVAL of the answer. 148 * 148 149 */ 149 150 int 150 ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,151 ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *result1,152 ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5)151 ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, 152 sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1, 153 sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5) 153 154 { 154 155 ipc_call_t data; 155 int callres; 156 157 IPC_SET_METHOD(data, method); 156 157 IPC_SET_IMETHOD(data, imethod); 158 158 IPC_SET_ARG1(data, arg1); 159 159 IPC_SET_ARG2(data, arg2); … … 161 161 IPC_SET_ARG4(data, arg4); 162 162 IPC_SET_ARG5(data, arg5); 163 164 callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,165 (sysarg_t) &data );163 164 int callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, 165 (sysarg_t) &data, (sysarg_t) &data); 166 166 if (callres) 167 167 return callres; 168 168 169 169 if (result1) 170 170 *result1 = IPC_GET_ARG1(data); … … 177 177 if (result5) 178 178 *result5 = IPC_GET_ARG5(data); 179 179 180 180 return IPC_GET_RETVAL(data); 181 181 } … … 183 183 /** Syscall to send asynchronous message. 184 184 * 185 * @param phoneid Phone handle for the call. 186 * @param data Call data with the request. 187 * 188 * @return Hash of the call or an error code. 185 * @param phoneid Phone handle for the call. 186 * @param data Call data with the request. 187 * 188 * @return Hash of the call or an error code. 189 * 189 190 */ 190 191 static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data) … … 277 278 * If the call cannot be temporarily made, queue it. 278 279 * 279 * @param phoneid Phone handle for the call. 280 * @param method Requested method. 281 * @param arg1 Service-defined payload argument. 282 * @param arg2 Service-defined payload argument. 283 * @param arg3 Service-defined payload argument. 284 * @param arg4 Service-defined payload argument. 285 * @param private Argument to be passed to the answer/error callback. 286 * @param callback Answer or error callback. 287 * @param can_preempt If non-zero, the current fibril will be preempted in 288 * case the kernel temporarily refuses to accept more 289 * asynchronous calls. 290 */ 291 void ipc_call_async_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, 292 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, void *private, 280 * @param phoneid Phone handle for the call. 281 * @param imethod Requested interface and method. 282 * @param arg1 Service-defined payload argument. 283 * @param arg2 Service-defined payload argument. 284 * @param arg3 Service-defined payload argument. 285 * @param arg4 Service-defined payload argument. 286 * @param private Argument to be passed to the answer/error callback. 287 * @param callback Answer or error callback. 288 * @param can_preempt If non-zero, the current fibril will be preempted in 289 * case the kernel temporarily refuses to accept more 290 * asynchronous calls. 291 * 292 */ 293 void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1, 294 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private, 293 295 ipc_async_callback_t callback, int can_preempt) 294 296 { 295 297 async_call_t *call = NULL; 296 ipc_callid_t callid; 297 298 298 299 if (callback) { 299 300 call = ipc_prepare_async(private, callback); … … 301 302 return; 302 303 } 303 304 304 305 /* 305 306 * We need to make sure that we get callid before another thread … … 307 308 */ 308 309 futex_down(&ipc_futex); 309 callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1,310 arg2, arg3, arg4);311 310 ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, 311 imethod, arg1, arg2, arg3, arg4); 312 312 313 if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) { 313 314 if (!call) { … … 316 317 return; 317 318 } 318 IPC_SET_ METHOD(call->u.msg.data,method);319 IPC_SET_IMETHOD(call->u.msg.data, imethod); 319 320 IPC_SET_ARG1(call->u.msg.data, arg1); 320 321 IPC_SET_ARG2(call->u.msg.data, arg2); … … 337 338 * If the call cannot be temporarily made, queue it. 338 339 * 339 * @param phoneid Phone handle for the call.340 * @param method Requested method.341 * @param arg1 Service-defined payload argument.342 * @param arg2 Service-defined payload argument.343 * @param arg3 Service-defined payload argument.344 * @param arg4 Service-defined payload argument.345 * @param arg5 Service-defined payload argument.346 * @param private Argument to be passed to the answer/error callback.347 * @param callback Answer or error callback.348 * @param can_preempt If non-zero, the current fibril will be preempted in349 * case the kernel temporarily refuses to accept more350 * asynchronous calls.351 * 352 */ 353 void ipc_call_async_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,354 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, void *private,340 * @param phoneid Phone handle for the call. 341 * @param imethod Requested interface and method. 342 * @param arg1 Service-defined payload argument. 343 * @param arg2 Service-defined payload argument. 344 * @param arg3 Service-defined payload argument. 345 * @param arg4 Service-defined payload argument. 346 * @param arg5 Service-defined payload argument. 347 * @param private Argument to be passed to the answer/error callback. 348 * @param callback Answer or error callback. 349 * @param can_preempt If non-zero, the current fibril will be preempted in 350 * case the kernel temporarily refuses to accept more 351 * asynchronous calls. 352 * 353 */ 354 void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, 355 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private, 355 356 ipc_async_callback_t callback, int can_preempt) 356 357 { … … 362 363 return; 363 364 364 IPC_SET_ METHOD(call->u.msg.data,method);365 IPC_SET_IMETHOD(call->u.msg.data, imethod); 365 366 IPC_SET_ARG1(call->u.msg.data, arg1); 366 367 IPC_SET_ARG2(call->u.msg.data, arg2); … … 393 394 * @return Zero on success or a value from @ref errno.h on failure. 394 395 */ 395 ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,396 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4)396 sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 397 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 397 398 { 398 399 return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3, … … 412 413 * @return Zero on success or a value from @ref errno.h on failure. 413 414 */ 414 ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,415 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5)415 sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 416 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 416 417 { 417 418 ipc_call_t data; … … 585 586 */ 586 587 int ipc_connect_to_me(int phoneid, int arg1, int arg2, int arg3, 587 ipcarg_t *phonehash)588 sysarg_t *phonehash) 588 589 { 589 590 return ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, … … 602 603 int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3) 603 604 { 604 ipcarg_t newphid;605 sysarg_t newphid; 605 606 int res; 606 607 … … 626 627 int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3) 627 628 { 628 ipcarg_t newphid;629 sysarg_t newphid; 629 630 int res; 630 631 … … 676 677 /** Forward a received call to another destination. 677 678 * 678 * @param callid Hash of the call to forward.679 * @param phoneid Phone handle to use for forwarding.680 * @param method Newmethod for the forwarded call.681 * @param arg1 New value of the first argument for the forwarded call.682 * @param arg2 New value of the second argument for the forwarded call.683 * @param mode Flags specifying mode of the forward operation.684 * 685 * @return Zero on success or an error code.679 * @param callid Hash of the call to forward. 680 * @param phoneid Phone handle to use for forwarding. 681 * @param imethod New interface and method for the forwarded call. 682 * @param arg1 New value of the first argument for the forwarded call. 683 * @param arg2 New value of the second argument for the forwarded call. 684 * @param mode Flags specifying mode of the forward operation. 685 * 686 * @return Zero on success or an error code. 686 687 * 687 688 * For non-system methods, the old method, arg1 and arg2 are rewritten by the … … 690 691 * methods are forwarded verbatim. 691 692 */ 692 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method,693 ipcarg_t arg1, ipcarg_t arg2, int mode)694 { 695 return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1,693 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod, 694 sysarg_t arg1, sysarg_t arg2, int mode) 695 { 696 return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1, 696 697 arg2, mode); 697 698 } 698 699 699 700 700 int ipc_forward_slow(ipc_callid_t callid, int phoneid, int method,701 ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,701 int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod, 702 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 702 703 int mode) 703 704 { 704 705 ipc_call_t data; 705 706 IPC_SET_ METHOD(data,method);706 707 IPC_SET_IMETHOD(data, imethod); 707 708 IPC_SET_ARG1(data, arg1); 708 709 IPC_SET_ARG2(data, arg2); … … 710 711 IPC_SET_ARG4(data, arg4); 711 712 IPC_SET_ARG5(data, arg5); 712 713 713 714 return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode); 714 715 } … … 725 726 * @return Zero on success or a negative error code from errno.h. 726 727 */ 727 int ipc_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,728 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg, 728 729 int *flags) 729 730 { 730 731 sysarg_t tmp_flags = 0; 731 int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, ( ipcarg_t) dst,732 ( ipcarg_t) size, arg, NULL, &tmp_flags);732 int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst, 733 (sysarg_t) size, arg, NULL, &tmp_flags); 733 734 734 735 if (flags) … … 751 752 int ipc_share_in_finalize(ipc_callid_t callid, void *src, int flags) 752 753 { 753 return ipc_answer_2(callid, EOK, ( ipcarg_t) src, (ipcarg_t) flags);754 return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags); 754 755 } 755 756 … … 764 765 int ipc_share_out_start(int phoneid, void *src, int flags) 765 766 { 766 return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, ( ipcarg_t) src, 0,767 ( ipcarg_t) flags);767 return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0, 768 (sysarg_t) flags); 768 769 } 769 770 … … 780 781 int ipc_share_out_finalize(ipc_callid_t callid, void *dst) 781 782 { 782 return ipc_answer_1(callid, EOK, ( ipcarg_t) dst);783 return ipc_answer_1(callid, EOK, (sysarg_t) dst); 783 784 } 784 785 … … 794 795 int ipc_data_read_start(int phoneid, void *dst, size_t size) 795 796 { 796 return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, ( ipcarg_t) dst,797 ( ipcarg_t) size);797 return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst, 798 (sysarg_t) size); 798 799 } 799 800 … … 812 813 int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size) 813 814 { 814 return ipc_answer_2(callid, EOK, ( ipcarg_t) src, (ipcarg_t) size);815 return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size); 815 816 } 816 817 … … 825 826 int ipc_data_write_start(int phoneid, const void *src, size_t size) 826 827 { 827 return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, ( ipcarg_t) src,828 ( ipcarg_t) size);828 return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src, 829 (sysarg_t) size); 829 830 } 830 831 … … 842 843 int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size) 843 844 { 844 return ipc_answer_2(callid, EOK, (ipcarg_t) dst, (ipcarg_t) size); 845 } 846 847 #include <kernel/syscall/sysarg64.h> 845 return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size); 846 } 847 848 848 /** Connect to a task specified by id. 849 * 849 850 */ 850 851 int ipc_connect_kbox(task_id_t id) 851 852 { 852 sysarg64_t arg; 853 854 arg.value = (unsigned long long) id; 855 853 #ifdef __32_BITS__ 854 sysarg64_t arg = (sysarg64_t) id; 856 855 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg); 857 } 858 856 #endif 857 858 #ifdef __64_BITS__ 859 return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id); 860 #endif 861 } 862 859 863 /** @} 860 864 */ -
uspace/lib/c/generic/libc.c
rcead2aa r357b5f5 50 50 #include <ipc/ipc.h> 51 51 #include <async.h> 52 #include <async_rel.h>53 52 #include <as.h> 54 53 #include <loader/pcb.h> … … 66 65 __heap_init(); 67 66 __async_init(); 68 (void) async_rel_init();69 67 fibril_t *fibril = fibril_setup(); 70 68 __tcb_set(fibril->tcb); -
uspace/lib/c/generic/loader.c
rcead2aa r357b5f5 96 96 } 97 97 98 ipcarg_t retval;98 sysarg_t retval; 99 99 async_wait_for(req, &retval); 100 100 return (int) retval; … … 131 131 } 132 132 133 ipcarg_t retval;133 sysarg_t retval; 134 134 async_wait_for(req, &retval); 135 135 return (int) retval; … … 166 166 free(pa); 167 167 168 ipcarg_t retval;168 sysarg_t retval; 169 169 async_wait_for(req, &retval); 170 170 return (int) retval; … … 213 213 ipc_call_t answer; 214 214 aid_t req = async_send_0(ldr->phone_id, LOADER_SET_ARGS, &answer); 215 ipcarg_t rc = async_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size);215 sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size); 216 216 if (rc != EOK) { 217 217 async_wait_for(req, NULL); … … 267 267 ipc_call_t answer; 268 268 aid_t req = async_send_0(ldr->phone_id, LOADER_SET_FILES, &answer); 269 ipcarg_t rc = async_data_write_start(ldr->phone_id, (void *) files_buf,269 sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) files_buf, 270 270 count * sizeof(fdi_node_t)); 271 271 if (rc != EOK) { -
uspace/lib/c/generic/mem.c
rcead2aa r357b5f5 222 222 /** Compare two memory areas. 223 223 * 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * @return If len is 0, return zero. If the areas match, return 229 * zero. Otherwise return non-zero. 230 */ 231 int bcmp(const char *s1, const char *s2, size_t len) 232 { 233 for (; len && *s1++ == *s2++; len--) 234 ; 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * 229 * @return If len is 0, return zero. If the areas match, return 230 * zero. Otherwise return non-zero. 231 * 232 */ 233 int bcmp(const void *s1, const void *s2, size_t len) 234 { 235 uint8_t *u1 = (uint8_t *) s1; 236 uint8_t *u2 = (uint8_t *) s2; 237 238 for (; (len != 0) && (*u1++ == *u2++); len--); 239 235 240 return len; 236 241 } -
uspace/lib/c/generic/net/icmp_api.c
rcead2aa r357b5f5 81 81 { 82 82 aid_t message_id; 83 ipcarg_t result;83 sysarg_t result; 84 84 85 85 if (addrlen <= 0) … … 87 87 88 88 message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, 89 tos, ( ipcarg_t) dont_fragment, NULL);89 tos, (sysarg_t) dont_fragment, NULL); 90 90 91 / / send the address91 /* Send the address */ 92 92 async_data_write_start(icmp_phone, addr, (size_t) addrlen); 93 93 -
uspace/lib/c/generic/net/icmp_common.c
rcead2aa r357b5f5 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 38 38 #include <net/modules.h> 39 39 #include <net/icmp_common.h> 40 41 40 #include <ipc/services.h> 42 41 #include <ipc/icmp.h> 43 44 42 #include <sys/time.h> 45 43 #include <async.h> 46 44 47 /** Connect sto the ICMP module.45 /** Connect to the ICMP module. 48 46 * 49 * @param service The ICMP module service. Ignored parameter. 50 * @param[in] timeout The connection timeout in microseconds. No timeout if 51 * set to zero. 52 * @return The ICMP module phone on success. 53 * @return ETIMEOUT if the connection timeouted. 47 * @param[in] timeout Connection timeout in microseconds, zero 48 * for no timeout. 49 * 50 * @return ICMP module phone on success. 51 * @return ETIMEOUT if the connection timeouted. 52 * 54 53 */ 55 int icmp_connect_module(s ervices_t service, suseconds_t timeout)54 int icmp_connect_module(suseconds_t timeout) 56 55 { 57 int phone; 58 59 phone = connect_to_service_timeout(SERVICE_ICMP, timeout); 60 if (phone >= 0) 61 async_req_0_0(phone, NET_ICMP_INIT); 62 63 return phone; 56 return connect_to_service_timeout(SERVICE_ICMP, timeout); 64 57 } 65 58 -
uspace/lib/c/generic/net/inet.c
rcead2aa r357b5f5 64 64 switch (family) { 65 65 case AF_INET: 66 / / check the output buffer size66 /* Check output buffer size */ 67 67 if (length < INET_ADDRSTRLEN) 68 68 return ENOMEM; 69 69 70 / / fill the buffer with the IPv4 address70 /* Fill buffer with IPv4 address */ 71 71 snprintf(address, length, "%hhu.%hhu.%hhu.%hhu", 72 72 data[0], data[1], data[2], data[3]); … … 75 75 76 76 case AF_INET6: 77 / / check the output buffer size77 /* Check output buffer size */ 78 78 if (length < INET6_ADDRSTRLEN) 79 79 return ENOMEM; 80 80 81 / / fill the buffer with the IPv6 address81 /* Fill buffer with IPv6 address */ 82 82 snprintf(address, length, 83 83 "%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:" … … 124 124 return EINVAL; 125 125 126 / / set the processing parameters126 /* Set processing parameters */ 127 127 switch (family) { 128 128 case AF_INET: … … 142 142 } 143 143 144 / / erase if no address144 /* Erase if no address */ 145 145 if (!address) { 146 146 bzero(data, count); … … 148 148 } 149 149 150 / / process the string from the beginning150 /* Process string from the beginning */ 151 151 next = address; 152 152 index = 0; 153 153 do { 154 / / if the actual character is set154 /* If the actual character is set */ 155 155 if (next && *next) { 156 156 157 / / if not on the first character157 /* If not on the first character */ 158 158 if (index) { 159 / / move to the next character159 /* Move to the next character */ 160 160 ++next; 161 161 } 162 162 163 / / parse the actual integral value163 /* Parse the actual integral value */ 164 164 value = strtoul(next, &last, base); 165 // remember the last problematic character 166 // should be either '.' or ':' but is ignored to be more 167 // generic 165 /* 166 * Remember the last problematic character 167 * should be either '.' or ':' but is ignored to be 168 * more generic 169 */ 168 170 next = last; 169 171 170 / / fill the address data byte by byte172 /* Fill the address data byte by byte */ 171 173 shift = bytes - 1; 172 174 do { 173 / / like little endian175 /* like little endian */ 174 176 data[index + shift] = value; 175 177 value >>= 8; … … 178 180 index += bytes; 179 181 } else { 180 / / erase the rest of the address182 /* Erase the rest of the address */ 181 183 bzero(data + index, count - index); 182 184 return EOK; -
uspace/lib/c/generic/net/modules.c
rcead2aa r357b5f5 32 32 33 33 /** @file 34 * Generic module functions implementation. 34 * Generic module functions implementation. 35 35 * 36 36 * @todo MAKE IT POSSIBLE TO REMOVE THIS FILE VIA EITHER REPLACING PART OF ITS … … 52 52 #define MODULE_WAIT_TIME (10 * 1000) 53 53 54 /** Answer s thecall.55 * 56 * @param[in] callid The call identifier.57 * @param[in] result The message processing result.58 * @param[in] answer The message processing answer.59 * @param[in] answer_count The number of answer parameters.60 * /61 void 62 answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,63 int answer_count)64 { 65 / / choose the most efficient answer function66 if ( answer || (!answer_count)) {67 switch ( answer_count) {54 /** Answer a call. 55 * 56 * @param[in] callid Call identifier. 57 * @param[in] result Message processing result. 58 * @param[in] answer Message processing answer. 59 * @param[in] count Number of answer parameters. 60 * 61 */ 62 void answer_call(ipc_callid_t callid, int result, ipc_call_t *answer, 63 size_t count) 64 { 65 /* Choose the most efficient function */ 66 if ((answer != NULL) || (count == 0)) { 67 switch (count) { 68 68 case 0: 69 ipc_answer_0(callid, ( ipcarg_t) result);69 ipc_answer_0(callid, (sysarg_t) result); 70 70 break; 71 71 case 1: 72 ipc_answer_1(callid, ( ipcarg_t) result,72 ipc_answer_1(callid, (sysarg_t) result, 73 73 IPC_GET_ARG1(*answer)); 74 74 break; 75 75 case 2: 76 ipc_answer_2(callid, ( ipcarg_t) result,76 ipc_answer_2(callid, (sysarg_t) result, 77 77 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer)); 78 78 break; 79 79 case 3: 80 ipc_answer_3(callid, ( ipcarg_t) result,80 ipc_answer_3(callid, (sysarg_t) result, 81 81 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 82 82 IPC_GET_ARG3(*answer)); 83 83 break; 84 84 case 4: 85 ipc_answer_4(callid, ( ipcarg_t) result,85 ipc_answer_4(callid, (sysarg_t) result, 86 86 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 87 87 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer)); … … 89 89 case 5: 90 90 default: 91 ipc_answer_5(callid, ( ipcarg_t) result,91 ipc_answer_5(callid, (sysarg_t) result, 92 92 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 93 93 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer), … … 111 111 * function. 112 112 */ 113 int bind_service(services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3,113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 114 114 async_client_conn_t client_receiver) 115 115 { … … 134 134 * 135 135 */ 136 int bind_service_timeout(services_t need, ipcarg_t arg1, ipcarg_t arg2,137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)136 int bind_service_timeout(services_t need, sysarg_t arg1, sysarg_t arg2, 137 sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 139 int rc; … … 143 143 if (phone >= 0) { 144 144 /* Request the bidirectional connection */ 145 ipcarg_t phonehash;145 sysarg_t phonehash; 146 146 147 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); … … 178 178 int phone; 179 179 180 / / if no timeout is set180 /* If no timeout is set */ 181 181 if (timeout <= 0) 182 182 return async_connect_me_to_blocking(PHONE_NS, need, 0, 0); … … 187 187 return phone; 188 188 189 / / end if no time is left189 /* Abort if no time is left */ 190 190 if (timeout <= 0) 191 191 return ETIMEOUT; 192 192 193 / / wait the minimum of the module wait time and the timeout193 /* Wait the minimum of the module wait time and the timeout */ 194 194 usleep((timeout <= MODULE_WAIT_TIME) ? 195 195 timeout : MODULE_WAIT_TIME); 196 196 timeout -= MODULE_WAIT_TIME; 197 197 } 198 }199 200 /** Receives data from the other party.201 *202 * The received data buffer is allocated and returned.203 *204 * @param[out] data The data buffer to be filled.205 * @param[out] length The buffer length.206 * @return EOK on success.207 * @return EBADMEM if the data or the length parameter is NULL.208 * @return EINVAL if the client does not send data.209 * @return ENOMEM if there is not enough memory left.210 * @return Other error codes as defined for the211 * async_data_write_finalize() function.212 */213 int data_receive(void **data, size_t *length)214 {215 ipc_callid_t callid;216 int rc;217 218 if (!data || !length)219 return EBADMEM;220 221 // fetch the request222 if (!async_data_write_receive(&callid, length))223 return EINVAL;224 225 // allocate the buffer226 *data = malloc(*length);227 if (!*data)228 return ENOMEM;229 230 // fetch the data231 rc = async_data_write_finalize(callid, *data, *length);232 if (rc != EOK) {233 free(data);234 return rc;235 }236 237 return EOK;238 198 } 239 199 … … 254 214 ipc_callid_t callid; 255 215 256 / / fetch the request216 /* Fetch the request */ 257 217 if (!async_data_read_receive(&callid, &length)) 258 218 return EINVAL; 259 219 260 / / check the requested data size220 /* Check the requested data size */ 261 221 if (length < data_length) { 262 222 async_data_read_finalize(callid, data, length); … … 264 224 } 265 225 266 / / send the data226 /* Send the data */ 267 227 return async_data_read_finalize(callid, data, data_length); 268 228 } 269 229 270 /** Refreshes answer structure and parameters count. 271 * 272 * Erases all attributes. 273 * 274 * @param[in,out] answer The message processing answer structure. 275 * @param[in,out] answer_count The number of answer parameters. 276 */ 277 void refresh_answer(ipc_call_t *answer, int *answer_count) 278 { 279 if (answer_count) 280 *answer_count = 0; 281 282 if (answer) { 230 /** Refresh answer structure and argument count. 231 * 232 * Erase all arguments. 233 * 234 * @param[in,out] answer Message processing answer structure. 235 * @param[in,out] count Number of answer arguments. 236 * 237 */ 238 void refresh_answer(ipc_call_t *answer, size_t *count) 239 { 240 if (count != NULL) 241 *count = 0; 242 243 if (answer != NULL) { 283 244 IPC_SET_RETVAL(*answer, 0); 284 // just to be precize 285 IPC_SET_METHOD(*answer, 0); 245 IPC_SET_IMETHOD(*answer, 0); 286 246 IPC_SET_ARG1(*answer, 0); 287 247 IPC_SET_ARG2(*answer, 0); -
uspace/lib/c/generic/net/packet.c
rcead2aa r357b5f5 191 191 } 192 192 gpm_destroy(&pm_globals.packet_map); 193 / / leave locked193 /* leave locked */ 194 194 } 195 195 -
uspace/lib/c/generic/net/socket_client.c
rcead2aa r357b5f5 214 214 callid = async_get_call(&call); 215 215 216 switch (IPC_GET_ METHOD(call)) {216 switch (IPC_GET_IMETHOD(call)) { 217 217 case NET_SOCKET_RECEIVED: 218 218 case NET_SOCKET_ACCEPTED: … … 220 220 fibril_rwlock_read_lock(&socket_globals.lock); 221 221 222 / / find the socket222 /* Find the socket */ 223 223 socket = sockets_find(socket_get_sockets(), 224 224 SOCKET_GET_SOCKET_ID(call)); … … 229 229 } 230 230 231 switch (IPC_GET_ METHOD(call)) {231 switch (IPC_GET_IMETHOD(call)) { 232 232 case NET_SOCKET_RECEIVED: 233 233 fibril_mutex_lock(&socket->receive_lock); 234 / / push the number of received packet fragments234 /* Push the number of received packet fragments */ 235 235 rc = dyn_fifo_push(&socket->received, 236 236 SOCKET_GET_DATA_FRAGMENTS(call), 237 237 SOCKET_MAX_RECEIVED_SIZE); 238 238 if (rc == EOK) { 239 / / signal the received packet239 /* Signal the received packet */ 240 240 fibril_condvar_signal(&socket->receive_signal); 241 241 } … … 244 244 245 245 case NET_SOCKET_ACCEPTED: 246 / / push the new socket identifier246 /* Push the new socket identifier */ 247 247 fibril_mutex_lock(&socket->accept_lock); 248 248 rc = dyn_fifo_push(&socket->accepted, 1, 249 249 SOCKET_MAX_ACCEPTED_SIZE); 250 250 if (rc == EOK) { 251 / / signal the accepted socket251 /* Signal the accepted socket */ 252 252 fibril_condvar_signal(&socket->accept_signal); 253 253 } … … 264 264 fibril_rwlock_write_lock(&socket->sending_lock); 265 265 266 / / set the data fragment size266 /* Set the data fragment size */ 267 267 socket->data_fragment_size = 268 268 SOCKET_GET_DATA_FRAGMENT_SIZE(call); … … 278 278 } 279 279 280 ipc_answer_0(callid, ( ipcarg_t) rc);280 ipc_answer_0(callid, (sysarg_t) rc); 281 281 goto loop; 282 282 } … … 342 342 socket_id = 1; 343 343 ++count; 344 / / only this branch for last_id344 /* Only this branch for last_id */ 345 345 } else { 346 346 if (socket_id < INT_MAX) { … … 404 404 int socket_id; 405 405 services_t service; 406 ipcarg_t fragment_size;407 ipcarg_t header_size;406 sysarg_t fragment_size; 407 sysarg_t header_size; 408 408 int rc; 409 409 410 / / find the appropriate service410 /* Find the appropriate service */ 411 411 switch (domain) { 412 412 case PF_INET: … … 457 457 return phone; 458 458 459 / / create a new socket structure459 /* Create a new socket structure */ 460 460 socket = (socket_t *) malloc(sizeof(socket_t)); 461 461 if (!socket) … … 465 465 fibril_rwlock_write_lock(&socket_globals.lock); 466 466 467 / / request a new socket467 /* Request a new socket */ 468 468 socket_id = socket_generate_new_id(); 469 469 if (socket_id <= 0) { … … 484 484 socket->header_size = (size_t) header_size; 485 485 486 / / finish the new socket initialization486 /* Finish the new socket initialization */ 487 487 socket_initialize(socket, socket_id, phone, service); 488 / / store the new socket488 /* Store the new socket */ 489 489 rc = sockets_add(socket_get_sockets(), socket_id, socket); 490 490 … … 494 494 dyn_fifo_destroy(&socket->accepted); 495 495 free(socket); 496 async_msg_3(phone, NET_SOCKET_CLOSE, ( ipcarg_t) socket_id, 0,496 async_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0, 497 497 service); 498 498 return rc; … … 516 516 */ 517 517 static int 518 socket_send_data(int socket_id, ipcarg_t message, ipcarg_t arg2,518 socket_send_data(int socket_id, sysarg_t message, sysarg_t arg2, 519 519 const void *data, size_t datalength) 520 520 { 521 521 socket_t *socket; 522 522 aid_t message_id; 523 ipcarg_t result;523 sysarg_t result; 524 524 525 525 if (!data) … … 531 531 fibril_rwlock_read_lock(&socket_globals.lock); 532 532 533 / / find the socket533 /* Find the socket */ 534 534 socket = sockets_find(socket_get_sockets(), socket_id); 535 535 if (!socket) { … … 538 538 } 539 539 540 / / request the message540 /* Request the message */ 541 541 message_id = async_send_3(socket->phone, message, 542 ( ipcarg_t) socket->socket_id, arg2, socket->service, NULL);543 / / send the address542 (sysarg_t) socket->socket_id, arg2, socket->service, NULL); 543 /* Send the address */ 544 544 async_data_write_start(socket->phone, data, datalength); 545 545 … … 566 566 return EINVAL; 567 567 568 / / send the address568 /* Send the address */ 569 569 return socket_send_data(socket_id, NET_SOCKET_BIND, 0, my_addr, 570 570 (size_t) addrlen); … … 591 591 fibril_rwlock_read_lock(&socket_globals.lock); 592 592 593 / / find the socket593 /* Find the socket */ 594 594 socket = sockets_find(socket_get_sockets(), socket_id); 595 595 if (!socket) { … … 598 598 } 599 599 600 / / request listen backlog change600 /* Request listen backlog change */ 601 601 result = (int) async_req_3_0(socket->phone, NET_SOCKET_LISTEN, 602 ( ipcarg_t) socket->socket_id, (ipcarg_t) backlog, socket->service);602 (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service); 603 603 604 604 fibril_rwlock_read_unlock(&socket_globals.lock); … … 625 625 socket_t *new_socket; 626 626 aid_t message_id; 627 ipcarg_t ipc_result;627 sysarg_t ipc_result; 628 628 int result; 629 629 ipc_call_t answer; … … 634 634 fibril_rwlock_write_lock(&socket_globals.lock); 635 635 636 / / find the socket636 /* Find the socket */ 637 637 socket = sockets_find(socket_get_sockets(), socket_id); 638 638 if (!socket) { … … 643 643 fibril_mutex_lock(&socket->accept_lock); 644 644 645 / / wait for an accepted socket645 /* Wait for an accepted socket */ 646 646 ++ socket->blocked; 647 647 while (dyn_fifo_value(&socket->accepted) <= 0) { 648 648 fibril_rwlock_write_unlock(&socket_globals.lock); 649 649 fibril_condvar_wait(&socket->accept_signal, &socket->accept_lock); 650 / / drop the accept lock to avoid deadlock650 /* Drop the accept lock to avoid deadlock */ 651 651 fibril_mutex_unlock(&socket->accept_lock); 652 652 fibril_rwlock_write_lock(&socket_globals.lock); … … 655 655 -- socket->blocked; 656 656 657 / / create a new scoket657 /* Create a new socket */ 658 658 new_socket = (socket_t *) malloc(sizeof(socket_t)); 659 659 if (!new_socket) { … … 681 681 } 682 682 683 / / request accept683 /* Request accept */ 684 684 message_id = async_send_5(socket->phone, NET_SOCKET_ACCEPT, 685 ( ipcarg_t) socket->socket_id, 0, socket->service, 0,685 (sysarg_t) socket->socket_id, 0, socket->service, 0, 686 686 new_socket->socket_id, &answer); 687 687 688 / / read address688 /* Read address */ 689 689 ipc_data_read_start(socket->phone, cliaddr, *addrlen); 690 690 fibril_rwlock_write_unlock(&socket_globals.lock); … … 695 695 result = EINVAL; 696 696 697 / / dequeue the accepted socket if successful697 /* Dequeue the accepted socket if successful */ 698 698 dyn_fifo_pop(&socket->accepted); 699 / / set address length699 /* Set address length */ 700 700 *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer); 701 701 new_socket->data_fragment_size = 702 702 SOCKET_GET_DATA_FRAGMENT_SIZE(answer); 703 703 } else if (result == ENOTSOCK) { 704 / / empty the queue if no accepted sockets704 /* Empty the queue if no accepted sockets */ 705 705 while (dyn_fifo_pop(&socket->accepted) > 0) 706 706 ; … … 731 731 return EDESTADDRREQ; 732 732 733 / / send the address733 /* Send the address */ 734 734 return socket_send_data(socket_id, NET_SOCKET_CONNECT, 0, serv_addr, 735 735 addrlen); … … 744 744 int accepted_id; 745 745 746 / / destroy all accepted sockets746 /* Destroy all accepted sockets */ 747 747 while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0) 748 748 socket_destroy(sockets_find(socket_get_sockets(), accepted_id)); … … 780 780 } 781 781 782 / / request close782 /* Request close */ 783 783 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 784 ( ipcarg_t) socket->socket_id, 0, socket->service);784 (sysarg_t) socket->socket_id, 0, socket->service); 785 785 if (rc != EOK) { 786 786 fibril_rwlock_write_unlock(&socket_globals.lock); 787 787 return rc; 788 788 } 789 / / free the socket structure789 /* Free the socket structure */ 790 790 socket_destroy(socket); 791 791 … … 815 815 */ 816 816 static int 817 sendto_core( ipcarg_t message, int socket_id, const void *data,817 sendto_core(sysarg_t message, int socket_id, const void *data, 818 818 size_t datalength, int flags, const struct sockaddr *toaddr, 819 819 socklen_t addrlen) … … 821 821 socket_t *socket; 822 822 aid_t message_id; 823 ipcarg_t result;823 sysarg_t result; 824 824 size_t fragments; 825 825 ipc_call_t answer; … … 833 833 fibril_rwlock_read_lock(&socket_globals.lock); 834 834 835 / / find socket835 /* Find socket */ 836 836 socket = sockets_find(socket_get_sockets(), socket_id); 837 837 if (!socket) { … … 842 842 fibril_rwlock_read_lock(&socket->sending_lock); 843 843 844 / / compute data fragment count844 /* Compute data fragment count */ 845 845 if (socket->data_fragment_size > 0) { 846 846 fragments = (datalength + socket->header_size) / … … 853 853 } 854 854 855 / / request send855 /* Request send */ 856 856 message_id = async_send_5(socket->phone, message, 857 ( ipcarg_t) socket->socket_id,857 (sysarg_t) socket->socket_id, 858 858 (fragments == 1 ? datalength : socket->data_fragment_size), 859 socket->service, ( ipcarg_t) flags, fragments, &answer);860 861 / / send the address if given859 socket->service, (sysarg_t) flags, fragments, &answer); 860 861 /* Send the address if given */ 862 862 if (!toaddr || 863 863 (async_data_write_start(socket->phone, toaddr, addrlen) == EOK)) { 864 864 if (fragments == 1) { 865 / / send all if only one fragment865 /* Send all if only one fragment */ 866 866 async_data_write_start(socket->phone, data, datalength); 867 867 } else { 868 / / send the first fragment868 /* Send the first fragment */ 869 869 async_data_write_start(socket->phone, data, 870 870 socket->data_fragment_size - socket->header_size); … … 872 872 socket->data_fragment_size - socket->header_size; 873 873 874 / / send the middle fragments874 /* Send the middle fragments */ 875 875 while (--fragments > 1) { 876 876 async_data_write_start(socket->phone, data, … … 880 880 } 881 881 882 / / send the last fragment882 /* Send the last fragment */ 883 883 async_data_write_start(socket->phone, data, 884 884 (datalength + socket->header_size) % … … 892 892 (SOCKET_GET_DATA_FRAGMENT_SIZE(answer) != 893 893 socket->data_fragment_size)) { 894 / / set the data fragment size894 /* Set the data fragment size */ 895 895 socket->data_fragment_size = 896 896 SOCKET_GET_DATA_FRAGMENT_SIZE(answer); … … 917 917 int send(int socket_id, void *data, size_t datalength, int flags) 918 918 { 919 / / without the address919 /* Without the address */ 920 920 return sendto_core(NET_SOCKET_SEND, socket_id, data, datalength, flags, 921 921 NULL, 0); … … 950 950 return EDESTADDRREQ; 951 951 952 / / with the address952 /* With the address */ 953 953 return sendto_core(NET_SOCKET_SENDTO, socket_id, data, datalength, 954 954 flags, toaddr, addrlen); … … 966 966 * read. The actual address length is set. Used only if 967 967 * fromaddr is not NULL. 968 * @return EOK on success. 968 * @return Positive received message size in bytes on success. 969 * @return Zero if no more data (other side closed the connection). 969 970 * @return ENOTSOCK if the socket is not found. 970 971 * @return EBADMEM if the data parameter is NULL. … … 972 973 * @return Other error codes as defined for the spcific message. 973 974 */ 974 static int975 recvfrom_core( ipcarg_t message, int socket_id, void *data, size_t datalength,975 static ssize_t 976 recvfrom_core(sysarg_t message, int socket_id, void *data, size_t datalength, 976 977 int flags, struct sockaddr *fromaddr, socklen_t *addrlen) 977 978 { 978 979 socket_t *socket; 979 980 aid_t message_id; 980 ipcarg_t ipc_result;981 sysarg_t ipc_result; 981 982 int result; 982 983 size_t fragments; … … 984 985 size_t index; 985 986 ipc_call_t answer; 987 ssize_t retval; 986 988 987 989 if (!data) … … 996 998 fibril_rwlock_read_lock(&socket_globals.lock); 997 999 998 / / find the socket1000 /* Find the socket */ 999 1001 socket = sockets_find(socket_get_sockets(), socket_id); 1000 1002 if (!socket) { … … 1004 1006 1005 1007 fibril_mutex_lock(&socket->receive_lock); 1006 / / wait for a received packet1008 /* Wait for a received packet */ 1007 1009 ++socket->blocked; 1008 while ((result = dyn_fifo_value(&socket->received)) < =0) {1010 while ((result = dyn_fifo_value(&socket->received)) < 0) { 1009 1011 fibril_rwlock_read_unlock(&socket_globals.lock); 1010 1012 fibril_condvar_wait(&socket->receive_signal, 1011 1013 &socket->receive_lock); 1012 1014 1013 / / drop the receive lock to avoid deadlock1015 /* Drop the receive lock to avoid deadlock */ 1014 1016 fibril_mutex_unlock(&socket->receive_lock); 1015 1017 fibril_rwlock_read_lock(&socket_globals.lock); … … 1019 1021 fragments = (size_t) result; 1020 1022 1021 // prepare lengths if more fragments 1023 if (fragments == 0) { 1024 /* No more data, other side has closed the connection. */ 1025 fibril_mutex_unlock(&socket->receive_lock); 1026 fibril_rwlock_read_unlock(&socket_globals.lock); 1027 return 0; 1028 } 1029 1030 /* Prepare lengths if more fragments */ 1022 1031 if (fragments > 1) { 1023 1032 lengths = (size_t *) malloc(sizeof(size_t) * fragments + … … 1029 1038 } 1030 1039 1031 / / request packet data1040 /* Request packet data */ 1032 1041 message_id = async_send_4(socket->phone, message, 1033 ( ipcarg_t) socket->socket_id, 0, socket->service,1034 ( ipcarg_t) flags, &answer);1035 1036 / / read the address if desired1042 (sysarg_t) socket->socket_id, 0, socket->service, 1043 (sysarg_t) flags, &answer); 1044 1045 /* Read the address if desired */ 1037 1046 if(!fromaddr || 1038 1047 (async_data_read_start(socket->phone, fromaddr, 1039 1048 *addrlen) == EOK)) { 1040 / / read the fragment lengths1049 /* Read the fragment lengths */ 1041 1050 if (async_data_read_start(socket->phone, lengths, 1042 1051 sizeof(int) * (fragments + 1)) == EOK) { 1043 1052 if (lengths[fragments] <= datalength) { 1044 1053 1045 / / read all fragments if long enough1054 /* Read all fragments if long enough */ 1046 1055 for (index = 0; index < fragments; 1047 1056 ++index) { … … 1057 1066 1058 1067 free(lengths); 1059 } else { 1060 / / request packet data1068 } else { /* fragments == 1 */ 1069 /* Request packet data */ 1061 1070 message_id = async_send_4(socket->phone, message, 1062 ( ipcarg_t) socket->socket_id, 0, socket->service,1063 ( ipcarg_t) flags, &answer);1064 1065 / / read the address if desired1071 (sysarg_t) socket->socket_id, 0, socket->service, 1072 (sysarg_t) flags, &answer); 1073 1074 /* Read the address if desired */ 1066 1075 if (!fromaddr || 1067 1076 (async_data_read_start(socket->phone, fromaddr, 1068 1077 *addrlen) == EOK)) { 1069 / / read all if only one fragment1078 /* Read all if only one fragment */ 1070 1079 async_data_read_start(socket->phone, data, datalength); 1071 1080 } … … 1075 1084 result = (int) ipc_result; 1076 1085 if (result == EOK) { 1077 / / dequeue the received packet1086 /* Dequeue the received packet */ 1078 1087 dyn_fifo_pop(&socket->received); 1079 / / return read data length1080 re sult= SOCKET_GET_READ_DATA_LENGTH(answer);1081 / / set address length1088 /* Return read data length */ 1089 retval = SOCKET_GET_READ_DATA_LENGTH(answer); 1090 /* Set address length */ 1082 1091 if (fromaddr && addrlen) 1083 1092 *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer); 1093 } else { 1094 retval = (ssize_t) result; 1084 1095 } 1085 1096 1086 1097 fibril_mutex_unlock(&socket->receive_lock); 1087 1098 fibril_rwlock_read_unlock(&socket_globals.lock); 1088 return re sult;1099 return retval; 1089 1100 } 1090 1101 … … 1095 1106 * @param[in] datalength The data length. 1096 1107 * @param[in] flags Various receive flags. 1097 * @return EOK on success. 1108 * @return Positive received message size in bytes on success. 1109 * @return Zero if no more data (other side closed the connection). 1098 1110 * @return ENOTSOCK if the socket is not found. 1099 1111 * @return EBADMEM if the data parameter is NULL. … … 1102 1114 * message. 1103 1115 */ 1104 int recv(int socket_id, void *data, size_t datalength, int flags)1105 { 1106 / / without the address1116 ssize_t recv(int socket_id, void *data, size_t datalength, int flags) 1117 { 1118 /* Without the address */ 1107 1119 return recvfrom_core(NET_SOCKET_RECV, socket_id, data, datalength, 1108 1120 flags, NULL, NULL); … … 1118 1130 * @param[in,out] addrlen The address length. The maximum address length is 1119 1131 * read. The actual address length is set. 1120 * @return EOK on success. 1132 * @return Positive received message size in bytes on success. 1133 * @return Zero if no more data (other side closed the connection). 1121 1134 * @return ENOTSOCK if the socket is not found. 1122 1135 * @return EBADMEM if the data or fromaddr parameter is NULL. … … 1125 1138 * message. 1126 1139 */ 1127 int1140 ssize_t 1128 1141 recvfrom(int socket_id, void *data, size_t datalength, int flags, 1129 1142 struct sockaddr *fromaddr, socklen_t *addrlen) … … 1135 1148 return NO_DATA; 1136 1149 1137 / / with the address1150 /* With the address */ 1138 1151 return recvfrom_core(NET_SOCKET_RECVFROM, socket_id, data, datalength, 1139 1152 flags, fromaddr, addrlen); … … 1160 1173 socket_t *socket; 1161 1174 aid_t message_id; 1162 ipcarg_t result;1175 sysarg_t result; 1163 1176 1164 1177 if (!value || !optlen) … … 1170 1183 fibril_rwlock_read_lock(&socket_globals.lock); 1171 1184 1172 / / find the socket1185 /* Find the socket */ 1173 1186 socket = sockets_find(socket_get_sockets(), socket_id); 1174 1187 if (!socket) { … … 1177 1190 } 1178 1191 1179 / / request option value1192 /* Request option value */ 1180 1193 message_id = async_send_3(socket->phone, NET_SOCKET_GETSOCKOPT, 1181 ( ipcarg_t) socket->socket_id, (ipcarg_t) optname, socket->service,1194 (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service, 1182 1195 NULL); 1183 1196 1184 / / read the length1197 /* Read the length */ 1185 1198 if (async_data_read_start(socket->phone, optlen, 1186 1199 sizeof(*optlen)) == EOK) { 1187 / / read the value1200 /* Read the value */ 1188 1201 async_data_read_start(socket->phone, value, *optlen); 1189 1202 } … … 1212 1225 size_t optlen) 1213 1226 { 1214 / / send the value1227 /* Send the value */ 1215 1228 return socket_send_data(socket_id, NET_SOCKET_SETSOCKOPT, 1216 ( ipcarg_t) optname, value, optlen);1229 (sysarg_t) optname, value, optlen); 1217 1230 } 1218 1231 -
uspace/lib/c/generic/task.c
rcead2aa r357b5f5 47 47 task_id_t task_get_id(void) 48 48 { 49 #ifdef __32_BITS__ 49 50 task_id_t task_id; 50 51 (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); 51 52 52 53 return task_id; 54 #endif /* __32_BITS__ */ 55 56 #ifdef __64_BITS__ 57 return (task_id_t) __SYSCALL0(SYS_TASK_GET_ID); 58 #endif /* __64_BITS__ */ 53 59 } 54 60 … … 59 65 * 60 66 * @return Zero on success or negative error code. 61 *62 67 */ 63 68 int task_set_name(const char *name) 64 69 { 65 70 return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name)); 71 } 72 73 /** Kill a task. 74 * 75 * @param task_id ID of task to kill. 76 * 77 * @return Zero on success or negative error code. 78 */ 79 80 int task_kill(task_id_t task_id) 81 { 82 return (int) __SYSCALL1(SYS_TASK_KILL, (sysarg_t) &task_id); 66 83 } 67 84 … … 211 228 int task_wait(task_id_t id, task_exit_t *texit, int *retval) 212 229 { 213 ipcarg_t te, rv;230 sysarg_t te, rv; 214 231 int rc; 215 232 -
uspace/lib/c/generic/udebug.c
rcead2aa r357b5f5 57 57 size_t *copied, size_t *needed) 58 58 { 59 ipcarg_t a_copied, a_needed;59 sysarg_t a_copied, a_needed; 60 60 int rc; 61 61 … … 72 72 size_t *copied, size_t *needed) 73 73 { 74 ipcarg_t a_copied, a_needed;74 sysarg_t a_copied, a_needed; 75 75 int rc; 76 76 … … 87 87 size_t *copied, size_t *needed) 88 88 { 89 ipcarg_t a_copied, a_needed;89 sysarg_t a_copied, a_needed; 90 90 int rc; 91 91 … … 120 120 sysarg_t *val0, sysarg_t *val1) 121 121 { 122 ipcarg_t a_ev_type;122 sysarg_t a_ev_type; 123 123 int rc; 124 124 -
uspace/lib/c/generic/vfs/vfs.c
rcead2aa r357b5f5 158 158 vfs_connect(); 159 159 160 ipcarg_t rc_orig;160 sysarg_t rc_orig; 161 161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, devmap_handle, flags, NULL); 162 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);162 sysarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 163 163 if (rc != EOK) { 164 164 async_wait_for(req, &rc_orig); … … 238 238 int unmount(const char *mp) 239 239 { 240 ipcarg_t rc;241 ipcarg_t rc_orig;240 sysarg_t rc; 241 sysarg_t rc_orig; 242 242 aid_t req; 243 243 size_t mpa_size; … … 282 282 ipc_call_t answer; 283 283 aid_t req = async_send_3(vfs_phone, VFS_IN_OPEN, lflag, oflag, 0, &answer); 284 ipcarg_t rc = async_data_write_start(vfs_phone, abs, abs_size);285 286 if (rc != EOK) { 287 ipcarg_t rc_orig;284 sysarg_t rc = async_data_write_start(vfs_phone, abs, abs_size); 285 286 if (rc != EOK) { 287 sysarg_t rc_orig; 288 288 async_wait_for(req, &rc_orig); 289 289 … … 330 330 node->devmap_handle, node->index, oflag, &answer); 331 331 332 ipcarg_t rc;332 sysarg_t rc; 333 333 async_wait_for(req, &rc); 334 334 async_serialize_end(); … … 343 343 int close(int fildes) 344 344 { 345 ipcarg_t rc;345 sysarg_t rc; 346 346 347 347 futex_down(&vfs_phone_futex); … … 359 359 ssize_t read(int fildes, void *buf, size_t nbyte) 360 360 { 361 ipcarg_t rc;361 sysarg_t rc; 362 362 ipc_call_t answer; 363 363 aid_t req; … … 370 370 rc = async_data_read_start(vfs_phone, (void *)buf, nbyte); 371 371 if (rc != EOK) { 372 ipcarg_t rc_orig;372 sysarg_t rc_orig; 373 373 374 374 async_wait_for(req, &rc_orig); … … 391 391 ssize_t write(int fildes, const void *buf, size_t nbyte) 392 392 { 393 ipcarg_t rc;393 sysarg_t rc; 394 394 ipc_call_t answer; 395 395 aid_t req; … … 402 402 rc = async_data_write_start(vfs_phone, (void *)buf, nbyte); 403 403 if (rc != EOK) { 404 ipcarg_t rc_orig;404 sysarg_t rc_orig; 405 405 406 406 async_wait_for(req, &rc_orig); … … 427 427 vfs_connect(); 428 428 429 ipcarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes);429 sysarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes); 430 430 431 431 async_serialize_end(); … … 441 441 vfs_connect(); 442 442 443 ipcarg_t newoff_lo;444 ipcarg_t newoff_hi;445 ipcarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes,443 sysarg_t newoff_lo; 444 sysarg_t newoff_hi; 445 sysarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes, 446 446 LOWER32(offset), UPPER32(offset), whence, 447 447 &newoff_lo, &newoff_hi); … … 458 458 int ftruncate(int fildes, aoff64_t length) 459 459 { 460 ipcarg_t rc;460 sysarg_t rc; 461 461 462 462 futex_down(&vfs_phone_futex); … … 474 474 int fstat(int fildes, struct stat *stat) 475 475 { 476 ipcarg_t rc;476 sysarg_t rc; 477 477 aid_t req; 478 478 … … 484 484 rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat)); 485 485 if (rc != EOK) { 486 ipcarg_t rc_orig;486 sysarg_t rc_orig; 487 487 488 488 async_wait_for(req, &rc_orig); … … 503 503 int stat(const char *path, struct stat *stat) 504 504 { 505 ipcarg_t rc;506 ipcarg_t rc_orig;505 sysarg_t rc; 506 sysarg_t rc_orig; 507 507 aid_t req; 508 508 … … 593 593 int mkdir(const char *path, mode_t mode) 594 594 { 595 ipcarg_t rc;595 sysarg_t rc; 596 596 aid_t req; 597 597 … … 608 608 rc = async_data_write_start(vfs_phone, pa, pa_size); 609 609 if (rc != EOK) { 610 ipcarg_t rc_orig;610 sysarg_t rc_orig; 611 611 612 612 async_wait_for(req, &rc_orig); … … 628 628 static int _unlink(const char *path, int lflag) 629 629 { 630 ipcarg_t rc;630 sysarg_t rc; 631 631 aid_t req; 632 632 … … 643 643 rc = async_data_write_start(vfs_phone, pa, pa_size); 644 644 if (rc != EOK) { 645 ipcarg_t rc_orig;645 sysarg_t rc_orig; 646 646 647 647 async_wait_for(req, &rc_orig); … … 673 673 int rename(const char *old, const char *new) 674 674 { 675 ipcarg_t rc;676 ipcarg_t rc_orig;675 sysarg_t rc; 676 sysarg_t rc_orig; 677 677 aid_t req; 678 678 … … 810 810 vfs_connect(); 811 811 812 ipcarg_t ret;813 ipcarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret);812 sysarg_t ret; 813 sysarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret); 814 814 815 815 async_serialize_end();
Note:
See TracChangeset
for help on using the changeset viewer.
