Changeset 1ffa73b in mainline for uspace/lib
- Timestamp:
- 2011-01-10T16:33:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b207803
- Parents:
- 863d45e (diff), 6610565b (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
- Files:
-
- 1 deleted
- 56 edited
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r863d45e r1ffa73b 59 59 generic/devman.c \ 60 60 generic/device/hw_res.c \ 61 generic/device/char .c \61 generic/device/char_dev.c \ 62 62 generic/event.c \ 63 63 generic/errno.c \ -
uspace/lib/c/generic/adt/char_map.c
r863d45e r1ffa73b 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 { … … 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 { … … 200 200 */ 201 201 static char_map_t * 202 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, 203 203 size_t length) 204 204 { … … 241 241 * @return CHAR_MAP_NULL if the key is not assigned a value. 242 242 */ 243 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) 244 244 { 245 245 char_map_t *node; … … 269 269 * @return CHAR_MAP_NULL if the key is not assigned a value. 270 270 */ 271 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) 272 272 { 273 273 char_map_t *node; … … 329 329 */ 330 330 int 331 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, 332 332 const int value) 333 333 { -
uspace/lib/c/generic/adt/measured_strings.c
r863d45e r1ffa73b 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_sess.c
r863d45e r1ffa73b 110 110 typedef struct { 111 111 link_t sess_link; /**< Link for the session list of inactive connections. */ 112 link_t global_link; /**< Link for the global list of inactive connecti nos. */112 link_t global_link; /**< Link for the global list of inactive connections. */ 113 113 int data_phone; /**< Connected data phone. */ 114 114 } conn_node_t; 115 115 116 116 /** 117 * Mutex protecting the inactive_conn_head list and the session list. 117 * Mutex protecting the inactive_conn_head list, the session list and the 118 * avail_phone condition variable. 118 119 */ 119 120 static fibril_mutex_t async_sess_mutex; … … 128 129 */ 129 130 static LIST_INITIALIZE(session_list_head); 131 132 /** 133 * Condition variable used to wait for a phone to become available. 134 */ 135 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv); 130 136 131 137 /** Initialize the async_sess subsystem. … … 150 156 * @param sess Session structure provided by caller, will be filled in. 151 157 * @param phone Phone connected to the desired server task. 152 */ 153 void async_session_create(async_sess_t *sess, int phone) 158 * @param arg1 Value to pass as first argument upon creating a new 159 * connection. Typical use is to identify a resource within 160 * the server that the caller wants to access (port ID, 161 * interface ID, device ID, etc.). 162 */ 163 void async_session_create(async_sess_t *sess, int phone, sysarg_t arg1) 154 164 { 155 165 sess->sess_phone = phone; 166 sess->connect_arg1 = arg1; 156 167 list_initialize(&sess->conn_head); 157 168 … … 192 203 free(conn); 193 204 } 205 206 fibril_condvar_broadcast(&avail_phone_cv); 194 207 } 195 208 … … 231 244 */ 232 245 retry: 233 data_phone = async_connect_me_to(sess->sess_phone, 0, 0, 0); 246 data_phone = async_connect_me_to(sess->sess_phone, 247 sess->connect_arg1, 0, 0); 234 248 if (data_phone >= 0) { 235 249 /* success, do nothing */ … … 250 264 } else { 251 265 /* 252 * This is unfortunate. We failed both to find a cached 253 * connection or to create a new one even after cleaning up 254 * the cache. This is most likely due to too many 255 * open sessions (connected session phones). 266 * Wait for a phone to become available. 256 267 */ 257 data_phone = ELIMIT; 268 fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex); 269 goto retry; 258 270 } 259 271 } … … 273 285 274 286 fibril_mutex_lock(&async_sess_mutex); 287 fibril_condvar_signal(&avail_phone_cv); 275 288 conn = (conn_node_t *) malloc(sizeof(conn_node_t)); 276 289 if (!conn) { … … 279 292 * means that we simply hang up. 280 293 */ 294 ipc_hangup(data_phone); 281 295 fibril_mutex_unlock(&async_sess_mutex); 282 ipc_hangup(data_phone);283 296 return; 284 297 } -
uspace/lib/c/generic/device/char_dev.c
r863d45e r1ffa73b 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 … … 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 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
r863d45e r1ffa73b 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 int 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 42 sysarg_t count = 0; 43 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count); 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 48 if (rc != EOK) … … 57 60 return rc; 58 61 } 59 62 60 63 return EOK; 61 64 } 62 65 63 bool enable_interrupt(int dev_phone)66 bool hw_res_enable_interrupt(int dev_phone) 64 67 { 65 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 66 71 return rc == EOK; 67 72 } 68 69 70 71 /** @} 73 74 /** @} 72 75 */ -
uspace/lib/c/generic/devman.c
r863d45e r1ffa73b 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; 79 } 70 80 71 81 if (flags & IPC_FLAG_BLOCKING) 72 devman_phone_client = ipc_connect_me_to_blocking(PHONE_NS, 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 fibril_mutex_unlock(&devman_phone_mutex); 78 89 return devman_phone_client; 79 90 default: … … 245 256 246 257 if (flags & IPC_FLAG_BLOCKING) { 247 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,258 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN, 248 259 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle); 249 260 } else { 250 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,261 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN, 251 262 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle); 252 263 } -
uspace/lib/c/generic/fibril.c
r863d45e r1ffa73b 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
r863d45e r1ffa73b 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) { … … 194 197 fibril_t *f = (fibril_t *) fibril_get_id(); 195 198 199 if (fibril_get_sercount() != 0) 200 core(); 201 196 202 futex_down(&async_futex); 197 203 if (frw->writers) { … … 219 225 fibril_t *f = (fibril_t *) fibril_get_id(); 220 226 227 if (fibril_get_sercount() != 0) 228 core(); 229 221 230 futex_down(&async_futex); 222 231 if (frw->writers || frw->readers) { -
uspace/lib/c/generic/io/vprintf.c
r863d45e r1ffa73b 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/mem.c
r863d45e r1ffa73b 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/modules.c
r863d45e r1ffa73b 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 answerfunction */66 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 69 ipc_answer_0(callid, (sysarg_t) result); … … 228 228 } 229 229 230 /** Refreshes answer structure and parameters count. 231 * 232 * Erases all attributes. 233 * 234 * @param[in,out] answer The message processing answer structure. 235 * @param[in,out] answer_count The number of answer parameters. 236 */ 237 void refresh_answer(ipc_call_t *answer, int *answer_count) 238 { 239 if (answer_count) 240 *answer_count = 0; 241 242 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) { 243 244 IPC_SET_RETVAL(*answer, 0); 244 /* Just to be precise */245 245 IPC_SET_IMETHOD(*answer, 0); 246 246 IPC_SET_ARG1(*answer, 0); -
uspace/lib/c/include/adt/char_map.h
r863d45e r1ffa73b 41 41 42 42 /** Invalid assigned value used also if an entry does not exist. */ 43 #define CHAR_MAP_NULL 43 #define CHAR_MAP_NULL (-1) 44 44 45 45 /** Type definition of the character string to integer map. 46 46 * @see char_map 47 47 */ 48 typedef struct char_map 48 typedef struct char_map char_map_t; 49 49 50 50 /** Character string to integer map item. … … 56 56 struct char_map { 57 57 /** Actually mapped character. */ 58 charc;58 uint8_t c; 59 59 /** Stored integral value. */ 60 60 int value; … … 71 71 extern int char_map_initialize(char_map_t *); 72 72 extern void char_map_destroy(char_map_t *); 73 extern int char_map_exclude(char_map_t *, const char*, size_t);74 extern int char_map_add(char_map_t *, const char*, size_t, const int);75 extern int char_map_find(const char_map_t *, const char*, size_t);76 extern int char_map_update(char_map_t *, const char*, size_t, const int);73 extern int char_map_exclude(char_map_t *, const uint8_t *, size_t); 74 extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int); 75 extern int char_map_find(const char_map_t *, const uint8_t *, size_t); 76 extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int); 77 77 78 78 #endif -
uspace/lib/c/include/adt/generic_char_map.h
r863d45e r1ffa73b 62 62 }; \ 63 63 \ 64 int name##_add(name##_t *, const char*, const size_t, type *); \64 int name##_add(name##_t *, const uint8_t *, const size_t, type *); \ 65 65 int name##_count(name##_t *); \ 66 66 void name##_destroy(name##_t *); \ 67 void name##_exclude(name##_t *, const char*, const size_t); \68 type *name##_find(name##_t *, const char*, const size_t); \67 void name##_exclude(name##_t *, const uint8_t *, const size_t); \ 68 type *name##_find(name##_t *, const uint8_t *, const size_t); \ 69 69 int name##_initialize(name##_t *); \ 70 70 int name##_is_valid(name##_t *); … … 74 74 * Should follow declaration with the same parameters. 75 75 * 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 78 * 78 79 */ 79 80 #define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \ 80 81 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 81 82 \ 82 int name##_add(name##_t *map, const char*name, const size_t length, \83 int name##_add(name##_t *map, const uint8_t *name, const size_t length, \ 83 84 type *value) \ 84 85 { \ … … 112 113 } \ 113 114 \ 114 void name##_exclude(name##_t *map, const char*name, \115 void name##_exclude(name##_t *map, const uint8_t *name, \ 115 116 const size_t length) \ 116 117 { \ … … 124 125 } \ 125 126 \ 126 type *name##_find(name##_t *map, const char*name, \127 type *name##_find(name##_t *map, const uint8_t *name, \ 127 128 const size_t length) \ 128 129 { \ -
uspace/lib/c/include/adt/measured_strings.h
r863d45e r1ffa73b 54 54 struct measured_string { 55 55 /** Character string data. */ 56 char*value;56 uint8_t *value; 57 57 /** Character string length. */ 58 58 size_t length; 59 59 }; 60 60 61 extern measured_string_t *measured_string_create_bulk(const char*, size_t);61 extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t); 62 62 extern measured_string_t *measured_string_copy(measured_string_t *); 63 extern int measured_strings_receive(measured_string_t **, char**, size_t);63 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t); 64 64 extern int measured_strings_reply(const measured_string_t *, size_t); 65 extern int measured_strings_return(int, measured_string_t **, char**, size_t);65 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t); 66 66 extern int measured_strings_send(int, const measured_string_t *, size_t); 67 67 -
uspace/lib/c/include/assert.h
r863d45e r1ffa73b 57 57 printf("Assertion failed (%s) at file '%s', " \ 58 58 "line %d.\n", #expr, __FILE__, __LINE__); \ 59 stacktrace_print(); \ 60 core(); \ 59 61 abort(); \ 60 62 } \ -
uspace/lib/c/include/async_sess.h
r863d45e r1ffa73b 40 40 typedef struct { 41 41 int sess_phone; /**< Phone for cloning off the connections. */ 42 sysarg_t connect_arg1; /**< Argument for CONNECT_ME_TO. */ 42 43 link_t conn_head; /**< List of open data connections. */ 43 44 link_t sess_link; /**< Link in global list of open sessions. */ … … 45 46 46 47 extern void _async_sess_init(void); 47 extern void async_session_create(async_sess_t *, int );48 extern void async_session_create(async_sess_t *, int, sysarg_t); 48 49 extern void async_session_destroy(async_sess_t *); 49 50 extern int async_exchange_begin(async_sess_t *); -
uspace/lib/c/include/device/char_dev.h
r863d45e r1ffa73b 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_DEVICE_ HW_RES_H_36 #define LIBC_DEVICE_ HW_RES_H_35 #ifndef LIBC_DEVICE_CHAR_DEV_H_ 36 #define LIBC_DEVICE_CHAR_DEV_H_ 37 37 38 38 typedef enum { 39 CHAR_ READ_DEV= 0,40 CHAR_ WRITE_DEV41 } hw_res_funcs_t;39 CHAR_DEV_READ = 0, 40 CHAR_DEV_WRITE 41 } char_dev_method_t; 42 42 43 ssize_t read_dev(int dev_phone, void *buf, size_t len);44 ssize_t write_dev(int dev_phone, void *buf, size_t len);43 ssize_t char_dev_read(int dev_phone, void *buf, size_t len); 44 ssize_t char_dev_write(int dev_phone, void *buf, size_t len); 45 45 46 46 #endif -
uspace/lib/c/include/device/hw_res.h
r863d45e r1ffa73b 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 39 39 #include <bool.h> 40 40 41 // HW resource provider interface 41 /** HW resource provider interface */ 42 typedef enum { 43 HW_RES_GET_RESOURCE_LIST = 0, 44 HW_RES_ENABLE_INTERRUPT 45 } hw_res_method_t; 42 46 43 typedef enum { 44 GET_RESOURCE_LIST = 0, 45 ENABLE_INTERRUPT 46 } hw_res_funcs_t; 47 48 /** HW resource types. */ 47 /** HW resource types */ 49 48 typedef enum { 50 49 INTERRUPT, … … 58 57 } endianness_t; 59 58 60 61 /** HW resource (e.g. interrupt, memory register, i/o register etc.). */ 62 typedef struct hw_resource { 59 /** HW resource (e.g. interrupt, memory register, i/o register etc.) */ 60 typedef struct { 63 61 hw_res_type_t type; 64 62 union { 65 63 struct { 66 64 uint64_t address; 67 endianness_t endianness; 68 size_t size; 65 endianness_t endianness; 66 size_t size; 69 67 } mem_range; 68 70 69 struct { 71 70 uint64_t address; 72 endianness_t endianness; 73 size_t size; 71 endianness_t endianness; 72 size_t size; 74 73 } io_range; 74 75 75 struct { 76 int irq; 77 } interrupt; 78 } res; 76 int irq; 77 } interrupt; 78 } res; 79 79 } hw_resource_t; 80 80 81 typedef struct hw_resource_list{81 typedef struct { 82 82 size_t count; 83 hw_resource_t *resources; 83 hw_resource_t *resources; 84 84 } hw_resource_list_t; 85 85 86 static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)86 static inline void hw_res_clean_resource_list(hw_resource_list_t *hw_res) 87 87 { 88 if (NULL != hw_res->resources) {88 if (hw_res->resources != NULL) { 89 89 free(hw_res->resources); 90 90 91 hw_res->resources = NULL; 91 92 } 92 hw_res->count = 0; 93 94 hw_res->count = 0; 93 95 } 94 96 95 96 97 extern int get_hw_resources(int, hw_resource_list_t *); 98 extern bool enable_interrupt(int); 99 97 extern int hw_res_get_resource_list(int, hw_resource_list_t *); 98 extern bool hw_res_enable_interrupt(int); 100 99 101 100 #endif -
uspace/lib/c/include/fibril.h
r863d45e r1ffa73b 94 94 extern void fibril_inc_sercount(void); 95 95 extern void fibril_dec_sercount(void); 96 extern int fibril_get_sercount(void); 96 97 97 98 static inline int fibril_yield(void) -
uspace/lib/c/include/ipc/arp.h
r863d45e r1ffa73b 69 69 /*@{*/ 70 70 71 /** Returns the protocol service message parameter. 72 * @param[in] call The message call structure. 71 /** Return the protocol service message parameter. 72 * 73 * @param[in] call Message call structure. 74 * 73 75 */ 74 #define ARP_GET_NETIF(call) \ 75 ({ \ 76 services_t service = (services_t) IPC_GET_ARG2(*call); \ 77 service; \ 78 }) 76 #define ARP_GET_NETIF(call) ((services_t) IPC_GET_ARG2(call)) 79 77 80 78 /*@}*/ -
uspace/lib/c/include/ipc/dev_iface.h
r863d45e r1ffa73b 35 35 #include <libarch/types.h> 36 36 37 typedef enum { 38 HW_RES_DEV_IFACE = 0, 37 typedef enum { 38 HW_RES_DEV_IFACE = 0, 39 39 CHAR_DEV_IFACE, 40 40 … … 44 44 USBHC_DEV_IFACE, 45 45 46 // TODO add more interfaces47 46 DEV_IFACE_MAX 48 47 } dev_inferface_idx_t; -
uspace/lib/c/include/ipc/icmp.h
r863d45e r1ffa73b 82 82 /*@{*/ 83 83 84 /** Return sthe ICMP code message parameter.84 /** Return the ICMP code message parameter. 85 85 * 86 * @param[in] call The message call structure. 86 * @param[in] call Message call structure. 87 * 87 88 */ 88 #define ICMP_GET_CODE(call) \ 89 ({ \ 90 icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \ 91 code; \ 92 }) 89 #define ICMP_GET_CODE(call) ((icmp_code_t) IPC_GET_ARG1(call)) 93 90 94 /** Return sthe ICMP link MTU message parameter.91 /** Return the ICMP link MTU message parameter. 95 92 * 96 * @param[in] call The message call structure. 93 * @param[in] call Message call structure. 94 * 97 95 */ 98 #define ICMP_GET_MTU(call) \ 99 ({ \ 100 icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \ 101 mtu; \ 102 }) 96 #define ICMP_GET_MTU(call) ((icmp_param_t) IPC_GET_ARG3(call)) 103 97 104 /** Return sthe pointer message parameter.98 /** Return the pointer message parameter. 105 99 * 106 * @param[in] call The message call structure. 100 * @param[in] call Message call structure. 101 * 107 102 */ 108 #define ICMP_GET_POINTER(call) \ 109 ({ \ 110 icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \ 111 pointer; \ 112 }) 103 #define ICMP_GET_POINTER(call) ((icmp_param_t) IPC_GET_ARG3(call)) 113 104 114 /** Return sthe size message parameter.105 /** Return the size message parameter. 115 106 * 116 * @param[in] call The message call structure. 107 * @param[in] call Message call structure. 108 * 117 109 */ 118 #define ICMP_GET_SIZE(call) \ 119 ({ \ 120 size_t size = (size_t) IPC_GET_ARG1(call); \ 121 size; \ 122 }) 110 #define ICMP_GET_SIZE(call) ((size_t) IPC_GET_ARG1(call)) 123 111 124 /** Return sthe timeout message parameter.112 /** Return the timeout message parameter. 125 113 * 126 * @param[in] call The message call structure. 114 * @param[in] call Message call structure. 115 * 127 116 */ 128 #define ICMP_GET_TIMEOUT(call) \ 129 ({ \ 130 suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \ 131 timeout; \ 132 }) 117 #define ICMP_GET_TIMEOUT(call) ((suseconds_t) IPC_GET_ARG2(call)) 133 118 134 /** Return sthe time to live message parameter.119 /** Return the time to live message parameter. 135 120 * 136 * @param[in] call The message call structure. 121 * @param[in] call Message call structure. 122 * 137 123 */ 138 #define ICMP_GET_TTL(call) \ 139 ({ \ 140 ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \ 141 ttl; \ 142 }) 124 #define ICMP_GET_TTL(call) ((ip_ttl_t) IPC_GET_ARG3(call)) 143 125 144 /** Return sthe type of service message parameter.126 /** Return the type of service message parameter. 145 127 * 146 * @param[in] call The message call structure. 128 * @param[in] call Message call structure. 129 * 147 130 */ 148 #define ICMP_GET_TOS(call) \ 149 ({ \ 150 ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \ 151 tos; \ 152 }) 131 #define ICMP_GET_TOS(call) ((ip_tos_t) IPC_GET_ARG4(call)) 153 132 154 /** Return sthe dont fragment message parameter.133 /** Return the dont fragment message parameter. 155 134 * 156 * @param[in] call The message call structure.135 * @param[in] call Message call structure. 157 136 */ 158 #define ICMP_GET_DONT_FRAGMENT(call) \ 159 ({ \ 160 int dont_fragment = (int) IPC_GET_ARG5(call); \ 161 dont_fragment; \ 162 }) 137 #define ICMP_GET_DONT_FRAGMENT(call) ((int) IPC_GET_ARG5(call)) 163 138 164 139 /*@}*/ -
uspace/lib/c/include/ipc/il.h
r863d45e r1ffa73b 75 75 76 76 /** Return the protocol number message parameter. 77 * @param[in] call The message call structure. 77 * 78 * @param[in] call Message call structure. 79 * 78 80 */ 79 #define IL_GET_PROTO(call) (int) IPC_GET_ARG1(*call)81 #define IL_GET_PROTO(call) ((int) IPC_GET_ARG1(call)) 80 82 81 83 /** Return the registering service message parameter. 82 * @param[in] call The message call structure. 84 * 85 * @param[in] call Message call structure. 86 * 83 87 */ 84 #define IL_GET_SERVICE(call) (services_t) IPC_GET_ARG2(*call)88 #define IL_GET_SERVICE(call) ((services_t) IPC_GET_ARG2(call)) 85 89 86 90 /*@}*/ -
uspace/lib/c/include/ipc/ip.h
r863d45e r1ffa73b 51 51 */ 52 52 NET_IP_ADD_ROUTE = NET_IP_FIRST, 53 53 54 /** Gets the actual route information. 54 55 * @see ip_get_route() 55 56 */ 56 57 NET_IP_GET_ROUTE, 58 57 59 /** Processes the received error notification. 58 60 * @see ip_received_error_msg() 59 61 */ 60 62 NET_IP_RECEIVED_ERROR, 63 61 64 /** Sets the default gateway. 62 65 * @see ip_set_default_gateway() … … 68 71 /*@{*/ 69 72 70 /** Returns the address message parameter. 71 * @param[in] call The message call structure. 73 /** Return the address message parameter. 74 * 75 * @param[in] call Message call structure. 76 * 72 77 */ 73 78 #define IP_GET_ADDRESS(call) \ 74 79 ({ \ 75 80 in_addr_t addr; \ 76 addr.s_addr = IPC_GET_ARG3( *call); \81 addr.s_addr = IPC_GET_ARG3(call); \ 77 82 addr; \ 78 83 }) 79 84 80 /** Returns the gateway message parameter. 81 * @param[in] call The message call structure. 85 /** Return the gateway message parameter. 86 * 87 * @param[in] call Message call structure. 88 * 82 89 */ 83 90 #define IP_GET_GATEWAY(call) \ 84 91 ({ \ 85 92 in_addr_t addr; \ 86 addr.s_addr = IPC_GET_ARG2( *call); \93 addr.s_addr = IPC_GET_ARG2(call); \ 87 94 addr; \ 88 95 }) 89 96 90 /** Sets the header length in the message answer. 91 * @param[out] answer The message answer structure. 97 /** Set the header length in the message answer. 98 * 99 * @param[out] answer Message answer structure. 100 * 92 101 */ 93 #define IP_SET_HEADERLEN(answer, value) \ 94 do { \ 95 sysarg_t argument = (sysarg_t) (value); \ 96 IPC_SET_ARG2(*answer, argument); \ 97 } while (0) 102 #define IP_SET_HEADERLEN(answer, value) IPC_SET_ARG2(answer, (sysarg_t) (value)) 98 103 99 /** Returns the network mask message parameter. 100 * @param[in] call The message call structure. 104 /** Return the network mask message parameter. 105 * 106 * @param[in] call Message call structure. 107 * 101 108 */ 102 109 #define IP_GET_NETMASK(call) \ 103 110 ({ \ 104 111 in_addr_t addr; \ 105 addr.s_addr = IPC_GET_ARG4( *call); \112 addr.s_addr = IPC_GET_ARG4(call); \ 106 113 addr; \ 107 114 }) 108 115 109 /** Returns the protocol message parameter. 110 * @param[in] call The message call structure. 116 /** Return the protocol message parameter. 117 * 118 * @param[in] call Message call structure. 119 * 111 120 */ 112 #define IP_GET_PROTOCOL(call) \ 113 ({ \ 114 ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \ 115 protocol; \ 116 }) 121 #define IP_GET_PROTOCOL(call) ((ip_protocol_t) IPC_GET_ARG1(call)) 117 122 118 123 /*@}*/ -
uspace/lib/c/include/ipc/irc.h
r863d45e r1ffa73b 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 #ifndef LIBC_ BUS_H_36 #define LIBC_ BUS_H_35 #ifndef LIBC_IRC_H_ 36 #define LIBC_IRC_H_ 37 37 38 38 #include <ipc/ipc.h> 39 39 40 40 typedef enum { 41 BUS_CLEAR_INTERRUPT = IPC_FIRST_USER_METHOD 42 } bus_request_t; 41 IRC_ENABLE_INTERRUPT = IPC_FIRST_USER_METHOD, 42 IRC_CLEAR_INTERRUPT 43 } irc_request_t; 43 44 44 45 #endif -
uspace/lib/c/include/ipc/net.h
r863d45e r1ffa73b 44 44 #include <net/packet.h> 45 45 46 /** Returns a value indicating whether the value is in the interval. 47 * @param[in] item The value to be checked. 48 * @param[in] first_inclusive The first value in the interval inclusive. 49 * @param[in] last_exclusive The first value after the interval. 46 /** Return a value indicating whether the value is in the interval. 47 * 48 * @param[in] item Value to be checked. 49 * @param[in] first_inclusive First value in the interval inclusive. 50 * @param[in] last_exclusive First value after the interval. 51 * 50 52 */ 51 53 #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \ … … 55 57 /*@{*/ 56 58 57 /** The number of ARP messages. */ 58 #define NET_ARP_COUNT 5 59 60 /** The number of Ethernet messages. */ 61 #define NET_ETH_COUNT 0 62 63 /** The number of ICMP messages. */ 64 #define NET_ICMP_COUNT 6 65 66 /** The number of inter-network messages. */ 67 #define NET_IL_COUNT 6 68 69 /** The number of IP messages. */ 70 #define NET_IP_COUNT 4 71 72 /** The number of general networking messages. */ 73 #define NET_NET_COUNT 3 74 75 /** The number of network interface driver messages. */ 76 #define NET_NETIF_COUNT 6 77 78 /** The number of network interface layer messages. */ 79 #define NET_NIL_COUNT 7 80 81 /** The number of packet management system messages. */ 82 #define NET_PACKET_COUNT 5 83 84 /** The number of socket messages. */ 85 #define NET_SOCKET_COUNT 14 86 87 /** The number of TCP messages. */ 88 #define NET_TCP_COUNT 0 89 90 /** The number of transport layer messages. */ 91 #define NET_TL_COUNT 1 92 93 /** The number of UDP messages. */ 94 #define NET_UDP_COUNT 0 59 #define NET_ARP_COUNT 5 /**< Number of ARP messages. */ 60 #define NET_ETH_COUNT 0 /**< Number of Ethernet messages. */ 61 #define NET_ICMP_COUNT 6 /**< Number of ICMP messages. */ 62 #define NET_IL_COUNT 6 /**< Number of inter-network messages. */ 63 #define NET_IP_COUNT 4 /**< Number of IP messages. */ 64 #define NET_NET_COUNT 3 /**< Number of general networking messages. */ 65 #define NET_NETIF_COUNT 6 /**< Number of network interface driver messages. */ 66 #define NET_NIL_COUNT 7 /**< Number of network interface layer messages. */ 67 #define NET_PACKET_COUNT 5 /**< Number of packet management system messages. */ 68 #define NET_SOCKET_COUNT 14 /**< Number of socket messages. */ 69 #define NET_TCP_COUNT 0 /**< Number of TCP messages. */ 70 #define NET_TL_COUNT 1 /**< Number of transport layer messages. */ 71 #define NET_UDP_COUNT 0 /**< Number of UDP messages. */ 95 72 96 73 /*@}*/ … … 100 77 /*@{*/ 101 78 102 /** The first networking message. */ 103 #define NET_FIRST 2000 104 105 /** The first network interface layer message. */ 106 #define NET_NETIF_FIRST NET_FIRST 107 108 /** The last network interface layer message. */ 109 #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT) 110 111 /** The first general networking message. */ 112 #define NET_NET_FIRST (NET_NETIF_LAST + 0) 113 114 /** The last general networking message. */ 115 #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT) 116 117 /** The first network interface layer message. */ 118 #define NET_NIL_FIRST (NET_NET_LAST + 0) 119 120 /** The last network interface layer message. */ 121 #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT) 122 123 /** The first Ethernet message. */ 124 #define NET_ETH_FIRST (NET_NIL_LAST + 0) 125 126 /** The last Ethernet message. */ 127 #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT) 128 129 /** The first inter-network message. */ 130 #define NET_IL_FIRST (NET_ETH_LAST + 0) 131 132 /** The last inter-network message. */ 133 #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT) 134 135 /** The first IP message. */ 136 #define NET_IP_FIRST (NET_IL_LAST + 0) 137 138 /** The last IP message. */ 139 #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT) 140 141 /** The first ARP message. */ 142 #define NET_ARP_FIRST (NET_IP_LAST + 0) 143 144 /** The last ARP message. */ 145 #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT) 146 147 /** The first ICMP message. */ 148 #define NET_ICMP_FIRST (NET_ARP_LAST + 0) 149 150 /** The last ICMP message. */ 151 #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT) 152 153 /** The first ICMP message. */ 154 #define NET_TL_FIRST (NET_ICMP_LAST + 0) 155 156 /** The last ICMP message. */ 157 #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT) 158 159 /** The first UDP message. */ 160 #define NET_UDP_FIRST (NET_TL_LAST + 0) 161 162 /** The last UDP message. */ 163 #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT) 164 165 /** The first TCP message. */ 166 #define NET_TCP_FIRST (NET_UDP_LAST + 0) 167 168 /** The last TCP message. */ 169 #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT) 170 171 /** The first socket message. */ 172 #define NET_SOCKET_FIRST (NET_TCP_LAST + 0) 173 174 /** The last socket message. */ 175 #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT) 176 177 /** The first packet management system message. */ 178 #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0) 179 180 /** The last packet management system message. */ 181 #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT) 182 183 /** The last networking message. */ 184 #define NET_LAST NET_PACKET_LAST 185 186 /** The number of networking messages. */ 187 #define NET_COUNT (NET_LAST - NET_FIRST) 188 189 /** Returns a value indicating whether the IPC call is a generic networking 190 * message. 191 * @param[in] call The IPC call to be checked. 79 80 /** First networking message. */ 81 #define NET_FIRST 2000 82 83 /** First network interface layer message. */ 84 #define NET_NETIF_FIRST NET_FIRST 85 86 /** Last network interface layer message. */ 87 #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT) 88 89 /** First general networking message. */ 90 #define NET_NET_FIRST (NET_NETIF_LAST + 0) 91 92 /** Last general networking message. */ 93 #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT) 94 95 /** First network interface layer message. */ 96 #define NET_NIL_FIRST (NET_NET_LAST + 0) 97 98 /** Last network interface layer message. */ 99 #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT) 100 101 /** First Ethernet message. */ 102 #define NET_ETH_FIRST (NET_NIL_LAST + 0) 103 104 /** Last Ethernet message. */ 105 #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT) 106 107 /** First inter-network message. */ 108 #define NET_IL_FIRST (NET_ETH_LAST + 0) 109 110 /** Last inter-network message. */ 111 #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT) 112 113 /** First IP message. */ 114 #define NET_IP_FIRST (NET_IL_LAST + 0) 115 116 /** Last IP message. */ 117 #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT) 118 119 /** First ARP message. */ 120 #define NET_ARP_FIRST (NET_IP_LAST + 0) 121 122 /** Last ARP message. */ 123 #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT) 124 125 /** First ICMP message. */ 126 #define NET_ICMP_FIRST (NET_ARP_LAST + 0) 127 128 /** Last ICMP message. */ 129 #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT) 130 131 /** First ICMP message. */ 132 #define NET_TL_FIRST (NET_ICMP_LAST + 0) 133 134 /** Last ICMP message. */ 135 #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT) 136 137 /** First UDP message. */ 138 #define NET_UDP_FIRST (NET_TL_LAST + 0) 139 140 /** Last UDP message. */ 141 #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT) 142 143 /** First TCP message. */ 144 #define NET_TCP_FIRST (NET_UDP_LAST + 0) 145 146 /** Last TCP message. */ 147 #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT) 148 149 /** First socket message. */ 150 #define NET_SOCKET_FIRST (NET_TCP_LAST + 0) 151 152 /** Last socket message. */ 153 #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT) 154 155 /** First packet management system message. */ 156 #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0) 157 158 /** Last packet management system message. */ 159 #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT) 160 161 /** Last networking message. */ 162 #define NET_LAST NET_PACKET_LAST 163 164 /** Number of networking messages. */ 165 #define NET_COUNT (NET_LAST - NET_FIRST) 166 167 /** Check if the IPC call is a generic networking message. 168 * 169 * @param[in] call IPC call to be checked. 170 * 192 171 */ 193 172 #define IS_NET_MESSAGE(call) \ 194 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST) 195 196 /** Returns a value indicating whether the IPC call is an ARP message. 197 * @param[in] call The IPC call to be checked. 173 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_FIRST, NET_LAST) 174 175 /** Check if the IPC call is an ARP message. 176 * 177 * @param[in] call IPC call to be checked. 178 * 198 179 */ 199 180 #define IS_NET_ARP_MESSAGE(call) \ 200 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST) 201 202 /** Returns a value indicating whether the IPC call is an Ethernet message. 203 * @param[in] call The IPC call to be checked. 181 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ARP_FIRST, NET_ARP_LAST) 182 183 /** Check if the IPC call is an Ethernet message. 184 * 185 * @param[in] call IPC call to be checked. 186 * 204 187 */ 205 188 #define IS_NET_ETH_MESSAGE(call) \ 206 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST) 207 208 /** Returns a value indicating whether the IPC call is an ICMP message. 209 * @param[in] call The IPC call to be checked. 189 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ETH_FIRST, NET_ETH_LAST) 190 191 /** Check if the IPC call is an ICMP message. 192 * 193 * @param[in] call IPC call to be checked. 194 * 210 195 */ 211 196 #define IS_NET_ICMP_MESSAGE(call) \ 212 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST) 213 214 /** Returns a value indicating whether the IPC call is an inter-network layer 215 * message. 216 * @param[in] call The IPC call to be checked. 197 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ICMP_FIRST, NET_ICMP_LAST) 198 199 /** Check if the IPC call is an inter-network layer message. 200 * 201 * @param[in] call IPC call to be checked. 202 * 217 203 */ 218 204 #define IS_NET_IL_MESSAGE(call) \ 219 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST) 220 221 /** Returns a value indicating whether the IPC call is an IP message. 222 * @param[in] call The IPC call to be checked. 205 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IL_FIRST, NET_IL_LAST) 206 207 /** Check if the IPC call is an IP message. 208 * 209 * @param[in] call IPC call to be checked. 210 * 223 211 */ 224 212 #define IS_NET_IP_MESSAGE(call) \ 225 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST) 226 227 /** Returns a value indicating whether the IPC call is a generic networking 228 * message. 229 * @param[in] call The IPC call to be checked. 213 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IP_FIRST, NET_IP_LAST) 214 215 /** Check if the IPC call is a generic networking message. 216 * 217 * @param[in] call IPC call to be checked. 218 * 230 219 */ 231 220 #define IS_NET_NET_MESSAGE(call) \ 232 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST) 233 234 /** Returns a value indicating whether the IPC call is a network interface layer 235 * message. 236 * @param[in] call The IPC call to be checked. 221 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NET_FIRST, NET_NET_LAST) 222 223 /** Check if the IPC call is a network interface layer message. 224 * 225 * @param[in] call IPC call to be checked. 226 * 237 227 */ 238 228 #define IS_NET_NIL_MESSAGE(call) \ 239 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST) 240 241 /** Returns a value indicating whether the IPC call is a packet manaagement 242 * system message. 243 * @param[in] call The IPC call to be checked. 229 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NIL_FIRST, NET_NIL_LAST) 230 231 /** Check if the IPC call is a packet manaagement system message. 232 * 233 * @param[in] call IPC call to be checked. 234 * 244 235 */ 245 236 #define IS_NET_PACKET_MESSAGE(call) \ 246 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST) 247 248 /** Returns a value indicating whether the IPC call is a socket message. 249 * @param[in] call The IPC call to be checked. 237 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_PACKET_FIRST, NET_PACKET_LAST) 238 239 /** Check if the IPC call is a socket message. 240 * 241 * @param[in] call IPC call to be checked. 242 * 250 243 */ 251 244 #define IS_NET_SOCKET_MESSAGE(call) \ 252 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST) 253 254 /** Returns a value indicating whether the IPC call is a TCP message. 255 * @param[in] call The IPC call to be checked. 245 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_SOCKET_FIRST, NET_SOCKET_LAST) 246 247 /** Check if the IPC call is a TCP message. 248 * 249 * @param[in] call IPC call to be checked. 250 * 256 251 */ 257 252 #define IS_NET_TCP_MESSAGE(call) \ 258 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST) 259 260 /** Returns a value indicating whether the IPC call is a transport layer message. 261 * @param[in] call The IPC call to be checked. 253 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TCP_FIRST, NET_TCP_LAST) 254 255 /** Check if the IPC call is a transport layer message. 256 * 257 * @param[in] call IPC call to be checked. 258 * 262 259 */ 263 260 #define IS_NET_TL_MESSAGE(call) \ 264 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST) 265 266 /** Returns a value indicating whether the IPC call is a UDP message. 267 * @param[in] call The IPC call to be checked. 261 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TL_FIRST, NET_TL_LAST) 262 263 /** Check if the IPC call is a UDP message. 264 * 265 * @param[in] call IPC call to be checked. 266 * 268 267 */ 269 268 #define IS_NET_UDP_MESSAGE(call) \ 270 IS_IN_INTERVAL(IPC_GET_IMETHOD( *call), NET_UDP_FIRST, NET_UDP_LAST)269 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_UDP_FIRST, NET_UDP_LAST) 271 270 272 271 /*@}*/ … … 275 274 /*@{*/ 276 275 277 /** Returns the device identifier message argument. 278 * @param[in] call The message call structure. 279 */ 280 #define IPC_GET_DEVICE(call) \ 281 ({ \ 282 device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); \ 283 device_id; \ 284 }) 285 286 /** Returns the packet identifier message argument. 287 * @param[in] call The message call structure. 288 */ 289 #define IPC_GET_PACKET(call) \ 290 ({ \ 291 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); \ 292 packet_id; \ 293 }) 294 295 /** Returns the count message argument. 296 * @param[in] call The message call structure. 297 */ 298 #define IPC_GET_COUNT(call) \ 299 ({ \ 300 size_t size = (size_t) IPC_GET_ARG2(*call); \ 301 size; \ 302 }) 303 304 /** Returns the device state message argument. 305 * @param[in] call The message call structure. 306 */ 307 #define IPC_GET_STATE(call) \ 308 ({ \ 309 device_state_t state = (device_state_t) IPC_GET_ARG2(*call); \ 310 state; \ 311 }) 312 313 /** Returns the maximum transmission unit message argument. 314 * @param[in] call The message call structure. 315 */ 316 #define IPC_GET_MTU(call) \ 317 ({ \ 318 size_t size = (size_t) IPC_GET_ARG2(*call); \ 319 size; \ 320 }) 321 322 /** Returns the device driver service message argument. 323 * @param[in] call The message call structure. 324 */ 325 #define IPC_GET_SERVICE(call) \ 326 ({ \ 327 services_t service = (services_t) IPC_GET_ARG3(*call); \ 328 service; \ 329 }) 330 331 /** Returns the target service message argument. 332 * @param[in] call The message call structure. 333 */ 334 #define IPC_GET_TARGET(call) \ 335 ({ \ 336 services_t service = (services_t) IPC_GET_ARG3(*call); \ 337 service; \ 338 }) 339 340 /** Returns the sender service message argument. 341 * @param[in] call The message call structure. 342 */ 343 #define IPC_GET_SENDER(call) \ 344 ({ \ 345 services_t service = (services_t) IPC_GET_ARG3(*call); \ 346 service; \ 347 }) 348 349 /** Returns the error service message argument. 350 * @param[in] call The message call structure. 351 */ 352 #define IPC_GET_ERROR(call) \ 353 ({ \ 354 services_t service = (services_t) IPC_GET_ARG4(*call); \ 355 service; \ 356 }) 357 358 /** Returns the phone message argument. 359 * @param[in] call The message call structure. 360 */ 361 #define IPC_GET_PHONE(call) \ 362 ({ \ 363 int phone = (int) IPC_GET_ARG5(*call); \ 364 phone; \ 365 }) 366 367 /** Sets the device identifier in the message answer. 368 * @param[out] answer The message answer structure. 369 */ 370 #define IPC_SET_DEVICE(answer, value) \ 371 do { \ 372 sysarg_t argument = (sysarg_t) (value); \ 373 IPC_SET_ARG1(*answer, argument); \ 374 } while (0) 375 376 /** Sets the minimum address length in the message answer. 377 * @param[out] answer The message answer structure. 378 */ 379 #define IPC_SET_ADDR(answer, value) \ 380 do { \ 381 sysarg_t argument = (sysarg_t) (value); \ 382 IPC_SET_ARG1(*answer, argument); \ 383 } while (0) 384 385 /** Sets the minimum prefix size in the message answer. 386 * @param[out] answer The message answer structure. 387 */ 388 #define IPC_SET_PREFIX(answer, value) \ 389 do { \ 390 sysarg_t argument = (sysarg_t) (value); \ 391 IPC_SET_ARG2(*answer, argument); \ 392 } while (0) 393 394 /** Sets the maximum content size in the message answer. 395 * @param[out] answer The message answer structure. 396 */ 397 #define IPC_SET_CONTENT(answer, value) \ 398 do { \ 399 sysarg_t argument = (sysarg_t) (value); \ 400 IPC_SET_ARG3(*answer, argument); \ 401 } while (0) 402 403 /** Sets the minimum suffix size in the message answer. 404 * @param[out] answer The message answer structure. 405 */ 406 #define IPC_SET_SUFFIX(answer, value) \ 407 do { \ 408 sysarg_t argument = (sysarg_t) (value); \ 409 IPC_SET_ARG4(*answer, argument); \ 410 } while (0) 276 /** Return the device identifier message argument. 277 * 278 * @param[in] call Message call structure. 279 * 280 */ 281 #define IPC_GET_DEVICE(call) ((device_id_t) IPC_GET_ARG1(call)) 282 283 /** Return the packet identifier message argument. 284 * 285 * @param[in] call Message call structure. 286 * 287 */ 288 #define IPC_GET_PACKET(call) ((packet_id_t) IPC_GET_ARG2(call)) 289 290 /** Return the count message argument. 291 * 292 * @param[in] call Message call structure. 293 * 294 */ 295 #define IPC_GET_COUNT(call) ((size_t) IPC_GET_ARG2(call)) 296 297 /** Return the device state message argument. 298 * 299 * @param[in] call Message call structure. 300 * 301 */ 302 #define IPC_GET_STATE(call) ((device_state_t) IPC_GET_ARG2(call)) 303 304 /** Return the maximum transmission unit message argument. 305 * 306 * @param[in] call Message call structure. 307 * 308 */ 309 #define IPC_GET_MTU(call) ((size_t) IPC_GET_ARG2(call)) 310 311 /** Return the device driver service message argument. 312 * 313 * @param[in] call Message call structure. 314 * 315 */ 316 #define IPC_GET_SERVICE(call) ((services_t) IPC_GET_ARG3(call)) 317 318 /** Return the target service message argument. 319 * 320 * @param[in] call Message call structure. 321 * 322 */ 323 #define IPC_GET_TARGET(call) ((services_t) IPC_GET_ARG3(call)) 324 325 /** Return the sender service message argument. 326 * 327 * @param[in] call Message call structure. 328 * 329 */ 330 #define IPC_GET_SENDER(call) ((services_t) IPC_GET_ARG3(call)) 331 332 /** Return the error service message argument. 333 & 334 * @param[in] call Message call structure. 335 * 336 */ 337 #define IPC_GET_ERROR(call) ((services_t) IPC_GET_ARG4(call)) 338 339 /** Return the phone message argument. 340 * 341 * @param[in] call Message call structure. 342 * 343 */ 344 #define IPC_GET_PHONE(call) ((int) IPC_GET_ARG5(call)) 345 346 /** Set the device identifier in the message answer. 347 * 348 * @param[out] answer Message answer structure. 349 * @param[in] value Value to set. 350 * 351 */ 352 #define IPC_SET_DEVICE(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value)) 353 354 /** Set the minimum address length in the message answer. 355 * 356 * @param[out] answer Message answer structure. 357 * @param[in] value Value to set. 358 * 359 */ 360 #define IPC_SET_ADDR(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value)) 361 362 /** Set the minimum prefix size in the message answer. 363 * 364 * @param[out] answer Message answer structure. 365 * @param[in] value Value to set. 366 * 367 */ 368 #define IPC_SET_PREFIX(answer, value) IPC_SET_ARG2(answer, (sysarg_t) (value)) 369 370 /** Set the maximum content size in the message answer. 371 * 372 * @param[out] answer Message answer structure. 373 * @param[in] value Value to set. 374 * 375 */ 376 #define IPC_SET_CONTENT(answer, value) IPC_SET_ARG3(answer, (sysarg_t) (value)) 377 378 /** Set the minimum suffix size in the message answer. 379 * 380 * @param[out] answer Message answer structure. 381 * @param[in] value Value to set. 382 * 383 */ 384 #define IPC_SET_SUFFIX(answer, value) IPC_SET_ARG4(answer, (sysarg_t) (value)) 411 385 412 386 /*@}*/ -
uspace/lib/c/include/ipc/netif.h
r863d45e r1ffa73b 47 47 */ 48 48 NET_NETIF_PROBE = NET_NETIF_FIRST, 49 49 50 /** Send packet message. 50 51 * @see netif_send_msg() 51 52 */ 52 53 NET_NETIF_SEND, 54 53 55 /** Start device message. 54 56 * @see netif_start_req() 55 57 */ 56 58 NET_NETIF_START, 59 57 60 /** Get device usage statistics message. 58 61 * @see netif_stats_req() 59 62 */ 60 63 NET_NETIF_STATS, 64 61 65 /** Stop device message. 62 66 * @see netif_stop_req() 63 67 */ 64 68 NET_NETIF_STOP, 69 65 70 /** Get device address message. 66 71 * @see netif_get_addr_req() … … 73 78 74 79 /** Return the interrupt number message parameter. 75 * @param[in] call The message call structure. 80 * 81 * @param[in] call Mmessage call structure. 82 * 76 83 */ 77 #define NETIF_GET_IRQ(call) \ 78 ({ \ 79 int irq = (int) IPC_GET_ARG2(*call); \ 80 irq; \ 81 }) 84 #define NETIF_GET_IRQ(call) ((int) IPC_GET_ARG2(call)) 82 85 83 86 /** Return the input/output address message parameter. 84 * @param[in] call The message call structure. 87 * 88 * @param[in] call Message call structure. 89 * 85 90 */ 86 #define NETIF_GET_IO(call) \ 87 ({ \ 88 int io = (int) IPC_GET_ARG3(*call); \ 89 io; \ 90 }) 91 #define NETIF_GET_IO(call) ((void *) IPC_GET_ARG3(call)) 91 92 92 93 /*@}*/ -
uspace/lib/c/include/ipc/nil.h
r863d45e r1ffa73b 77 77 78 78 /** Return the protocol service message parameter. */ 79 #define NIL_GET_PROTO(call) \ 80 ({ \ 81 services_t service = (services_t) IPC_GET_ARG2(*call); \ 82 service; \ 83 }) 79 #define NIL_GET_PROTO(call) ((services_t) IPC_GET_ARG2(call)) 84 80 85 81 /*@}*/ -
uspace/lib/c/include/ipc/packet.h
r863d45e r1ffa73b 70 70 } packet_messages; 71 71 72 /** Return sthe protocol service message parameter. */73 #define ARP_GET_PROTO(call) (services_t) IPC_GET_ARG2(*call)72 /** Return the protocol service message parameter. */ 73 #define ARP_GET_PROTO(call) ((services_t) IPC_GET_ARG2(call)) 74 74 75 /** Return sthe packet identifier message parameter. */76 #define IPC_GET_ID(call) (packet_id_t) IPC_GET_ARG1(*call)75 /** Return the packet identifier message parameter. */ 76 #define IPC_GET_ID(call) ((packet_id_t) IPC_GET_ARG1(call)) 77 77 78 /** Return sthe maximal content length message parameter. */79 #define IPC_GET_CONTENT(call) (size_t) IPC_GET_ARG1(*call)78 /** Return the maximal content length message parameter. */ 79 #define IPC_GET_CONTENT(call) ((size_t) IPC_GET_ARG1(call)) 80 80 81 /** Return sthe maximal address length message parameter. */82 #define IPC_GET_ADDR_LEN(call) (size_t) IPC_GET_ARG2(*call)81 /** Return the maximal address length message parameter. */ 82 #define IPC_GET_ADDR_LEN(call) ((size_t) IPC_GET_ARG2(call)) 83 83 84 /** Return sthe maximal prefix length message parameter. */85 #define IPC_GET_PREFIX(call) (size_t) IPC_GET_ARG3(*call)84 /** Return the maximal prefix length message parameter. */ 85 #define IPC_GET_PREFIX(call) ((size_t) IPC_GET_ARG3(call)) 86 86 87 /** Return sthe maximal suffix length message parameter. */88 #define IPC_GET_SUFFIX(call) (size_t) IPC_GET_ARG4(*call)87 /** Return the maximal suffix length message parameter. */ 88 #define IPC_GET_SUFFIX(call) ((size_t) IPC_GET_ARG4(call)) 89 89 90 90 #endif -
uspace/lib/c/include/ipc/services.h
r863d45e r1ffa73b 49 49 SERVICE_FHC, 50 50 SERVICE_OBIO, 51 SERVICE_APIC, 52 SERVICE_I8259, 51 53 SERVICE_CLIPBOARD, 52 54 SERVICE_NETWORKING, -
uspace/lib/c/include/mem.h
r863d45e r1ffa73b 44 44 extern void *memmove(void *, const void *, size_t); 45 45 46 extern int bcmp(const char *, const char*, size_t);46 extern int bcmp(const void *, const void *, size_t); 47 47 48 48 #endif -
uspace/lib/c/include/net/in.h
r863d45e r1ffa73b 43 43 44 44 /** INET string address maximum length. */ 45 #define INET_ADDRSTRLEN 45 #define INET_ADDRSTRLEN (4 * 3 + 3 + 1) 46 46 47 47 /** Type definition of the INET address. 48 48 * @see in_addr 49 49 */ 50 typedef struct in_addr 50 typedef struct in_addr in_addr_t; 51 51 52 52 /** Type definition of the INET socket address. -
uspace/lib/c/include/net/modules.h
r863d45e r1ffa73b 51 51 /** Connect to the needed module function type definition. 52 52 * 53 * @param[in] need The needed module service. 54 * @return The phone of the needed service. 53 * @param[in] need The needed module service. 54 * 55 * @return The phone of the needed service. 56 * 55 57 */ 56 58 typedef int connect_module_t(services_t need); 57 59 58 extern void answer_call(ipc_callid_t, int, ipc_call_t *, int);60 extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t); 59 61 extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t, 60 62 async_client_conn_t); … … 64 66 extern int connect_to_service_timeout(services_t, suseconds_t); 65 67 extern int data_reply(void *, size_t); 66 extern void refresh_answer(ipc_call_t *, int *);68 extern void refresh_answer(ipc_call_t *, size_t *); 67 69 68 70 #endif -
uspace/lib/c/include/stdlib.h
r863d45e r1ffa73b 46 46 } while (0) 47 47 48 #define core() \ 49 *((int *) 0) = 0xbadbad; 50 48 51 #define exit(status) _exit((status)) 49 52 -
uspace/lib/drv/Makefile
r863d45e r1ffa73b 35 35 generic/driver.c \ 36 36 generic/dev_iface.c \ 37 generic/remote_res.c \ 37 generic/remote_char_dev.c \ 38 generic/remote_hw_res.c \ 38 39 generic/remote_usb.c \ 39 generic/remote_usbhc.c \ 40 generic/remote_char.c 40 generic/remote_usbhc.c 41 41 42 42 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
r863d45e r1ffa73b 36 36 */ 37 37 38 #include <assert.h> 39 38 40 #include "dev_iface.h" 39 #include "remote_ res.h"40 #include "remote_char .h"41 #include "remote_hw_res.h" 42 #include "remote_char_dev.h" 41 43 #include "remote_usb.h" 42 44 #include "remote_usbhc.h" … … 44 46 static iface_dipatch_table_t remote_ifaces = { 45 47 .ifaces = { 46 &remote_ res_iface,47 &remote_char_ iface,48 &remote_hw_res_iface, 49 &remote_char_dev_iface, 48 50 &remote_usb_iface, 49 51 &remote_usbhc_iface … … 51 53 }; 52 54 53 remote_iface_t *get_remote_iface(int idx)54 { 55 remote_iface_t *get_remote_iface(int idx) 56 { 55 57 assert(is_valid_iface_idx(idx)); 56 58 return remote_ifaces.ifaces[idx]; … … 63 65 return NULL; 64 66 } 67 65 68 return rem_iface->methods[iface_method_idx]; 69 } 70 71 bool is_valid_iface_idx(int idx) 72 { 73 return (0 <= idx) && (idx < DEV_IFACE_MAX); 66 74 } 67 75 -
uspace/lib/drv/generic/driver.c
r863d45e r1ffa73b 52 52 #include <ipc/driver.h> 53 53 54 #include "dev_iface.h" 54 55 #include "driver.h" 55 56 56 /* driver structure */ 57 57 /** Driver structure */ 58 58 static driver_t *driver; 59 59 60 /* devices */ 61 60 /** Devices */ 62 61 LIST_INITIALIZE(devices); 63 62 FIBRIL_MUTEX_INITIALIZE(devices_mutex); 64 63 65 /* interrupts */ 66 64 /** Interrupts */ 67 65 static interrupt_context_list_t interrupt_contexts; 68 66 … … 85 83 86 84 ctx = find_interrupt_context_by_id(&interrupt_contexts, id); 87 if ( NULL != ctx && NULL != ctx->handler)85 if (ctx != NULL && ctx->handler != NULL) 88 86 (*ctx->handler)(ctx->dev, iid, icall); 89 87 } 88 89 interrupt_context_t *create_interrupt_context(void) 90 { 91 interrupt_context_t *ctx; 92 93 ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t)); 94 if (ctx != NULL) 95 memset(ctx, 0, sizeof(interrupt_context_t)); 96 97 return ctx; 98 } 99 100 void delete_interrupt_context(interrupt_context_t *ctx) 101 { 102 if (ctx != NULL) 103 free(ctx); 104 } 105 106 void init_interrupt_context_list(interrupt_context_list_t *list) 107 { 108 memset(list, 0, sizeof(interrupt_context_list_t)); 109 fibril_mutex_initialize(&list->mutex); 110 list_initialize(&list->contexts); 111 } 112 113 void 114 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx) 115 { 116 fibril_mutex_lock(&list->mutex); 117 ctx->id = list->curr_id++; 118 list_append(&ctx->link, &list->contexts); 119 fibril_mutex_unlock(&list->mutex); 120 } 121 122 void remove_interrupt_context(interrupt_context_list_t *list, 123 interrupt_context_t *ctx) 124 { 125 fibril_mutex_lock(&list->mutex); 126 list_remove(&ctx->link); 127 fibril_mutex_unlock(&list->mutex); 128 } 129 130 interrupt_context_t * 131 find_interrupt_context_by_id(interrupt_context_list_t *list, int id) 132 { 133 fibril_mutex_lock(&list->mutex); 134 135 link_t *link = list->contexts.next; 136 interrupt_context_t *ctx; 137 138 while (link != &list->contexts) { 139 ctx = list_get_instance(link, interrupt_context_t, link); 140 if (ctx->id == id) { 141 fibril_mutex_unlock(&list->mutex); 142 return ctx; 143 } 144 link = link->next; 145 } 146 147 fibril_mutex_unlock(&list->mutex); 148 return NULL; 149 } 150 151 interrupt_context_t * 152 find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq) 153 { 154 fibril_mutex_lock(&list->mutex); 155 156 link_t *link = list->contexts.next; 157 interrupt_context_t *ctx; 158 159 while (link != &list->contexts) { 160 ctx = list_get_instance(link, interrupt_context_t, link); 161 if (ctx->irq == irq && ctx->dev == dev) { 162 fibril_mutex_unlock(&list->mutex); 163 return ctx; 164 } 165 link = link->next; 166 } 167 168 fibril_mutex_unlock(&list->mutex); 169 return NULL; 170 } 171 90 172 91 173 int … … 101 183 add_interrupt_context(&interrupt_contexts, ctx); 102 184 103 if ( NULL == pseudocode)185 if (pseudocode == NULL) 104 186 pseudocode = &default_pseudocode; 105 187 106 188 int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode); 107 if ( 0 != res) {189 if (res != EOK) { 108 190 remove_interrupt_context(&interrupt_contexts, ctx); 109 191 delete_interrupt_context(ctx); … … 118 200 dev, irq); 119 201 int res = ipc_unregister_irq(irq, dev->handle); 120 121 if ( NULL != ctx) {202 203 if (ctx != NULL) { 122 204 remove_interrupt_context(&interrupt_contexts, ctx); 123 205 delete_interrupt_context(ctx); 124 206 } 207 125 208 return res; 126 209 } … … 140 223 } 141 224 142 static device_t * 225 static device_t *driver_get_device(link_t *devices, devman_handle_t handle) 143 226 { 144 227 device_t *dev = NULL; … … 146 229 fibril_mutex_lock(&devices_mutex); 147 230 link_t *link = devices->next; 231 148 232 while (link != devices) { 149 233 dev = list_get_instance(link, device_t, link); 150 if ( handle == dev->handle) {234 if (dev->handle == handle) { 151 235 fibril_mutex_unlock(&devices_mutex); 152 236 return dev; … … 154 238 link = link->next; 155 239 } 240 156 241 fibril_mutex_unlock(&devices_mutex); 157 242 158 243 return NULL; 159 244 } … … 162 247 { 163 248 char *dev_name = NULL; 164 int res = EOK;165 166 devman_handle_t dev_handle = 249 int res; 250 251 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 167 252 devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall); 168 253 169 254 device_t *dev = create_device(); 170 255 dev->handle = dev_handle; … … 177 262 178 263 res = driver->driver_ops->add_device(dev); 179 if ( 0 == res) {264 if (res == EOK) { 180 265 printf("%s: new device with handle=%" PRIun " was added.\n", 181 266 driver->name, dev_handle); … … 194 279 /* Accept connection */ 195 280 ipc_answer_0(iid, EOK); 196 281 197 282 bool cont = true; 198 283 while (cont) { 199 284 ipc_call_t call; 200 285 ipc_callid_t callid = async_get_call(&call); 201 286 202 287 switch (IPC_GET_IMETHOD(call)) { 203 288 case IPC_M_PHONE_HUNGUP: … … 240 325 * use the device. 241 326 */ 242 327 243 328 int ret = EOK; 244 329 /* open the device */ 245 if ( NULL != dev->ops && NULL != dev->ops->open)330 if (dev->ops != NULL && dev->ops->open != NULL) 246 331 ret = (*dev->ops->open)(dev); 247 332 248 ipc_answer_0(iid, ret); 249 if ( EOK != ret)333 ipc_answer_0(iid, ret); 334 if (ret != EOK) 250 335 return; 251 336 252 337 while (1) { 253 338 ipc_callid_t callid; … … 258 343 259 344 switch (method) { 260 case IPC_M_PHONE_HUNGUP: 345 case IPC_M_PHONE_HUNGUP: 261 346 /* close the device */ 262 if ( NULL != dev->ops && NULL != dev->ops->close)347 if (dev->ops != NULL && dev->ops->close != NULL) 263 348 (*dev->ops->close)(dev); 264 349 ipc_answer_0(callid, EOK); 265 350 return; 266 default: 351 default: 267 352 /* convert ipc interface id to interface index */ 268 353 … … 272 357 remote_handler_t *default_handler = 273 358 device_get_default_handler(dev); 274 if ( NULL != default_handler) {359 if (default_handler != NULL) { 275 360 (*default_handler)(dev, callid, &call); 276 361 break; … … 286 371 break; 287 372 } 288 373 289 374 /* calling one of the device's interfaces */ 290 375 291 /* get the device interface structure*/292 void * iface = device_get_iface(dev, iface_idx);293 if ( NULL == iface) {376 /* Get the interface ops structure. */ 377 void *ops = device_get_ops(dev, iface_idx); 378 if (ops == NULL) { 294 379 printf("%s: driver_connection_gen error - ", 295 380 driver->name); … … 299 384 break; 300 385 } 301 386 302 387 /* 303 388 * Get the corresponding interface for remote request 304 389 * handling ("remote interface"). 305 390 */ 306 remote_iface_t *rem_iface = get_remote_iface(iface_idx);307 assert( NULL != rem_iface);308 391 remote_iface_t *rem_iface = get_remote_iface(iface_idx); 392 assert(rem_iface != NULL); 393 309 394 /* get the method of the remote interface */ 310 395 sysarg_t iface_method_idx = IPC_GET_ARG1(call); 311 396 remote_iface_func_ptr_t iface_method_ptr = 312 397 get_remote_method(rem_iface, iface_method_idx); 313 if ( NULL == iface_method_ptr) {398 if (iface_method_ptr == NULL) { 314 399 // the interface has not such method 315 400 printf("%s: driver_connection_gen error - " … … 325 410 * associated with the device by its driver. 326 411 */ 327 (*iface_method_ptr)(dev, iface, callid, &call);412 (*iface_method_ptr)(dev, ops, callid, &call); 328 413 break; 329 414 } … … 348 433 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { 349 434 case DRIVER_DEVMAN: 350 /* handle PnP eventsfrom device manager */435 /* Handle request from device manager */ 351 436 driver_connection_devman(iid, icall); 352 437 break; 353 438 case DRIVER_DRIVER: 354 /* handle request from drivers of child devices */439 /* Handle request from drivers of child devices */ 355 440 driver_connection_driver(iid, icall); 356 441 break; 357 442 case DRIVER_CLIENT: 358 /* handle requestsfrom client applications */443 /* Handle request from client applications */ 359 444 driver_connection_client(iid, icall); 360 445 break; 361 362 446 default: 363 447 /* No such interface */ … … 366 450 } 367 451 452 /** Create new device structure. 453 * 454 * @return The device structure. 455 */ 456 device_t *create_device(void) 457 { 458 device_t *dev = malloc(sizeof(device_t)); 459 460 if (dev != NULL) { 461 memset(dev, 0, sizeof(device_t)); 462 init_match_ids(&dev->match_ids); 463 } 464 465 return dev; 466 } 467 468 /** Delete device structure. 469 * 470 * @param dev The device structure. 471 */ 472 void delete_device(device_t *dev) 473 { 474 clean_match_ids(&dev->match_ids); 475 if (dev->name != NULL) 476 free(dev->name); 477 free(dev); 478 } 479 480 void *device_get_ops(device_t *dev, dev_inferface_idx_t idx) 481 { 482 assert(is_valid_iface_idx(idx)); 483 if (dev->ops == NULL) 484 return NULL; 485 return dev->ops->interfaces[idx]; 486 } 487 368 488 int child_device_register(device_t *child, device_t *parent) 369 489 { 370 assert( NULL != child->name);371 490 assert(child->name != NULL); 491 372 492 int res; 373 493 … … 375 495 res = devman_child_device_register(child->name, &child->match_ids, 376 496 parent->handle, &child->handle); 377 if (EOK == res) 497 if (res != EOK) { 498 remove_from_devices_list(child); 378 499 return res; 379 remove_from_devices_list(child); 500 } 501 380 502 return res; 381 503 } … … 396 518 match_id_t *match_id = NULL; 397 519 int rc; 398 520 399 521 child = create_device(); 400 522 if (child == NULL) { … … 402 524 goto failure; 403 525 } 404 526 405 527 child->name = child_name; 406 528 407 529 match_id = create_match_id(); 408 530 if (match_id == NULL) { … … 410 532 goto failure; 411 533 } 412 534 413 535 match_id->id = child_match_id; 414 536 match_id->score = child_match_score; 415 537 add_match_id(&child->match_ids, match_id); 416 538 417 539 rc = child_device_register(child, parent); 418 if ( EOK != rc)540 if (rc != EOK) 419 541 goto failure; 420 542 … … 422 544 *child_handle = child->handle; 423 545 } 546 424 547 return EOK; 425 548 426 549 failure: 427 550 if (match_id != NULL) { … … 429 552 delete_match_id(match_id); 430 553 } 431 554 432 555 if (child != NULL) { 433 556 child->name = NULL; 434 557 delete_device(child); 435 558 } 436 559 437 560 return rc; 561 } 562 563 /** Get default handler for client requests */ 564 remote_handler_t *device_get_default_handler(device_t *dev) 565 { 566 if (dev->ops == NULL) 567 return NULL; 568 return dev->ops->default_handler; 569 } 570 571 int add_device_to_class(device_t *dev, const char *class_name) 572 { 573 return devman_add_device_to_class(dev->handle, class_name); 438 574 } 439 575 … … 445 581 */ 446 582 driver = drv; 447 583 448 584 /* Initialize the list of interrupt contexts. */ 449 585 init_interrupt_context_list(&interrupt_contexts); … … 457 593 */ 458 594 devman_driver_register(driver->name, driver_connection); 459 595 460 596 async_manager(); 461 597 462 598 /* Never reached. */ 463 599 return 0; -
uspace/lib/drv/generic/remote_char_dev.c
r863d45e r1ffa73b 37 37 #include <errno.h> 38 38 39 #include " char.h"39 #include "ops/char_dev.h" 40 40 #include "driver.h" 41 41 … … 46 46 47 47 /** Remote character interface operations. */ 48 static remote_iface_func_ptr_t remote_char_ iface_ops[] = {48 static remote_iface_func_ptr_t remote_char_dev_iface_ops[] = { 49 49 &remote_char_read, 50 50 &remote_char_write … … 56 56 * character interface. 57 57 */ 58 remote_iface_t remote_char_ iface = {59 .method_count = sizeof(remote_char_ iface_ops) /58 remote_iface_t remote_char_dev_iface = { 59 .method_count = sizeof(remote_char_dev_iface_ops) / 60 60 sizeof(remote_iface_func_ptr_t), 61 .methods = remote_char_ iface_ops61 .methods = remote_char_dev_iface_ops 62 62 }; 63 63 … … 69 69 * 70 70 * @param dev The device from which the data are read. 71 * @param iface The local interfacestructure.71 * @param ops The local ops structure. 72 72 */ 73 73 static void 74 remote_char_read(device_t *dev, void * iface, ipc_callid_t callid,74 remote_char_read(device_t *dev, void *ops, ipc_callid_t callid, 75 75 ipc_call_t *call) 76 { 77 char_ iface_t *char_iface = (char_iface_t *) iface;76 { 77 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 78 78 ipc_callid_t cid; 79 79 … … 85 85 } 86 86 87 if (!char_ iface->read) {87 if (!char_dev_ops->read) { 88 88 async_data_read_finalize(cid, NULL, 0); 89 89 ipc_answer_0(callid, ENOTSUP); … … 95 95 96 96 char buf[MAX_CHAR_RW_COUNT]; 97 int ret = (*char_ iface->read)(dev, buf, len);97 int ret = (*char_dev_ops->read)(dev, buf, len); 98 98 99 99 if (ret < 0) { … … 116 116 * 117 117 * @param dev The device to which the data are written. 118 * @param iface The local interfacestructure.118 * @param ops The local ops structure. 119 119 */ 120 120 static void 121 remote_char_write(device_t *dev, void * iface, ipc_callid_t callid,121 remote_char_write(device_t *dev, void *ops, ipc_callid_t callid, 122 122 ipc_call_t *call) 123 123 { 124 char_ iface_t *char_iface = (char_iface_t *) iface;124 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 125 125 ipc_callid_t cid; 126 126 size_t len; … … 132 132 } 133 133 134 if (!char_ iface->write) {134 if (!char_dev_ops->write) { 135 135 async_data_write_finalize(cid, NULL, 0); 136 136 ipc_answer_0(callid, ENOTSUP); 137 137 return; 138 } 138 } 139 139 140 140 if (len > MAX_CHAR_RW_COUNT) … … 145 145 async_data_write_finalize(cid, buf, len); 146 146 147 int ret = (*char_ iface->write)(dev, buf, len);147 int ret = (*char_dev_ops->write)(dev, buf, len); 148 148 if (ret < 0) { 149 149 /* Some error occured. */ -
uspace/lib/drv/generic/remote_hw_res.c
r863d45e r1ffa73b 37 37 #include <errno.h> 38 38 39 #include "ops/hw_res.h" 39 40 #include "driver.h" 40 #include "resource.h"41 41 42 static void remote_ res_get_resources(device_t *, void *, ipc_callid_t,42 static void remote_hw_res_get_resource_list(device_t *, void *, ipc_callid_t, 43 43 ipc_call_t *); 44 static void remote_ res_enable_interrupt(device_t *, void *, ipc_callid_t,44 static void remote_hw_res_enable_interrupt(device_t *, void *, ipc_callid_t, 45 45 ipc_call_t *); 46 46 47 static remote_iface_func_ptr_t remote_ res_iface_ops [] = {48 &remote_ res_get_resources,49 &remote_ res_enable_interrupt47 static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = { 48 &remote_hw_res_get_resource_list, 49 &remote_hw_res_enable_interrupt 50 50 }; 51 51 52 remote_iface_t remote_ res_iface = {53 .method_count = sizeof(remote_ res_iface_ops) /52 remote_iface_t remote_hw_res_iface = { 53 .method_count = sizeof(remote_hw_res_iface_ops) / 54 54 sizeof(remote_iface_func_ptr_t), 55 .methods = remote_ res_iface_ops55 .methods = remote_hw_res_iface_ops 56 56 }; 57 57 58 static void remote_ res_enable_interrupt(device_t *dev, void *iface,58 static void remote_hw_res_enable_interrupt(device_t *dev, void *ops, 59 59 ipc_callid_t callid, ipc_call_t *call) 60 60 { 61 resource_iface_t *ires = (resource_iface_t *) iface;61 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 62 62 63 if ( NULL == ires->enable_interrupt)63 if (hw_res_ops->enable_interrupt == NULL) 64 64 ipc_answer_0(callid, ENOTSUP); 65 else if ( ires->enable_interrupt(dev))65 else if (hw_res_ops->enable_interrupt(dev)) 66 66 ipc_answer_0(callid, EOK); 67 67 else … … 69 69 } 70 70 71 static void remote_ res_get_resources(device_t *dev, void *iface,71 static void remote_hw_res_get_resource_list(device_t *dev, void *ops, 72 72 ipc_callid_t callid, ipc_call_t *call) 73 73 { 74 resource_iface_t *ires = (resource_iface_t *) iface; 75 if (NULL == ires->get_resources) { 74 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 75 76 if (hw_res_ops->get_resource_list == NULL) { 76 77 ipc_answer_0(callid, ENOTSUP); 77 78 return; 78 79 } 79 80 80 hw_resource_list_t *hw_resources = ires->get_resources(dev);81 if ( NULL == hw_resources){81 hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev); 82 if (hw_resources == NULL){ 82 83 ipc_answer_0(callid, ENOENT); 83 84 return; 84 } 85 } 85 86 86 ipc_answer_1(callid, EOK, hw_resources->count); 87 ipc_answer_1(callid, EOK, hw_resources->count); 87 88 88 89 size_t len; 89 90 if (!async_data_read_receive(&callid, &len)) { 90 /* protocol error - the recipient is not accepting data */91 /* Protocol error - the recipient is not accepting data */ 91 92 return; 92 93 } -
uspace/lib/drv/include/dev_iface.h
r863d45e r1ffa73b 36 36 #define LIBDRV_DEV_IFACE_H_ 37 37 38 #include "driver.h"38 #include <ipc/dev_iface.h> 39 39 40 /* TODO declare device interface structures here */ 40 /* 41 * Device interface 42 */ 43 44 struct device; 45 46 /* 47 * First two parameters: device and interface structure registered by the 48 * devices driver. 49 */ 50 typedef void remote_iface_func_t(struct device *, void *, ipc_callid_t, 51 ipc_call_t *); 52 typedef remote_iface_func_t *remote_iface_func_ptr_t; 53 typedef void remote_handler_t(struct device *, ipc_callid_t, ipc_call_t *); 54 55 typedef struct { 56 size_t method_count; 57 remote_iface_func_ptr_t *methods; 58 } remote_iface_t; 59 60 typedef struct { 61 remote_iface_t *ifaces[DEV_IFACE_COUNT]; 62 } iface_dipatch_table_t; 63 64 extern remote_iface_t *get_remote_iface(int); 65 extern remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t); 66 67 68 extern bool is_valid_iface_idx(int); 41 69 42 70 #endif -
uspace/lib/drv/include/driver.h
r863d45e r1ffa73b 41 41 #include <ipc/devman.h> 42 42 #include <ipc/dev_iface.h> 43 #include <device/hw_res.h>44 #include <device/char.h>45 43 #include <assert.h> 46 44 #include <ddi.h> … … 49 47 #include <malloc.h> 50 48 49 #include "dev_iface.h" 50 51 51 struct device; 52 52 typedef struct device device_t; 53 53 54 /* device interface */ 54 /* 55 * Device class 56 */ 55 57 56 /* 57 * First two parameters: device and interface structure registered by the 58 * devices driver. 59 */ 60 typedef void remote_iface_func_t(device_t *, void *, ipc_callid_t, 61 ipc_call_t *); 62 typedef remote_iface_func_t *remote_iface_func_ptr_t; 63 typedef void remote_handler_t(device_t *, ipc_callid_t, ipc_call_t *); 64 65 typedef struct { 66 size_t method_count; 67 remote_iface_func_ptr_t *methods; 68 } remote_iface_t; 69 70 typedef struct { 71 remote_iface_t *ifaces[DEV_IFACE_COUNT]; 72 } iface_dipatch_table_t; 73 74 75 static inline bool is_valid_iface_idx(int idx) 76 { 77 return 0 <= idx && idx < DEV_IFACE_MAX; 78 } 79 80 remote_iface_t *get_remote_iface(int); 81 remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t); 82 83 84 /* device class */ 85 86 /** Devices operations. */ 58 /** Devices operations */ 87 59 typedef struct device_ops { 88 60 /** … … 110 82 111 83 112 /* device */ 84 /* 85 * Device 86 */ 113 87 114 /** The device.*/88 /** Device structure */ 115 89 struct device { 116 90 /** … … 121 95 122 96 /** 123 * The phone to the parent device driver (if it is different from this124 * driver) .97 * Phone to the parent device driver (if it is different from this 98 * driver) 125 99 */ 126 100 int parent_phone; 127 101 128 /** Parent device if handled by this driver, NULL otherwise .*/102 /** Parent device if handled by this driver, NULL otherwise */ 129 103 device_t *parent; 130 /** The device's name.*/104 /** Device name */ 131 105 const char *name; 132 /** The list of device ids for device-to-driver matching.*/106 /** List of device ids for device-to-driver matching */ 133 107 match_id_list_t match_ids; 134 /** The device driver's data associated with this device.*/108 /** Driver-specific data associated with this device */ 135 109 void *driver_data; 136 /** The implementation of operations provided by this device .*/110 /** The implementation of operations provided by this device */ 137 111 device_ops_t *ops; 138 112 139 /** 140 * Pointer to the previous and next device in the list of devices 141 * handled by the driver. 142 */ 113 /** Link in the list of devices handled by the driver */ 143 114 link_t link; 144 115 }; 145 116 117 /* 118 * Driver 119 */ 146 120 147 /* driver */ 148 149 /** Generic device driver operations. */ 121 /** Generic device driver operations */ 150 122 typedef struct driver_ops { 151 /** Callback method for passing a new device to the device driver .*/123 /** Callback method for passing a new device to the device driver */ 152 124 int (*add_device)(device_t *dev); 153 /* TODO add other generic driver operations */125 /* TODO: add other generic driver operations */ 154 126 } driver_ops_t; 155 127 156 /** The driver structure.*/128 /** Driver structure */ 157 129 typedef struct driver { 158 /** The name of the device driver.*/130 /** Name of the device driver */ 159 131 const char *name; 160 /** Generic device driver operations .*/132 /** Generic device driver operations */ 161 133 driver_ops_t *driver_ops; 162 134 } driver_t; … … 168 140 * @return The device structure. 169 141 */ 170 static inline device_t *create_device(void) 171 { 172 device_t *dev = malloc(sizeof(device_t)); 173 if (NULL != dev) { 174 memset(dev, 0, sizeof(device_t)); 175 init_match_ids(&dev->match_ids); 176 } 177 return dev; 178 } 142 extern device_t *create_device(void); 143 extern void delete_device(device_t *); 144 extern void *device_get_ops(device_t *, dev_inferface_idx_t); 179 145 180 /** Delete device structure. 181 * 182 * @param dev The device structure. 146 extern int child_device_register(device_t *, device_t *); 147 extern int child_device_register_wrapper(device_t *, const char *, const char *, 148 int, devman_handle_t *); 149 150 /* 151 * Interrupts 183 152 */ 184 static inline void delete_device(device_t *dev)185 {186 clean_match_ids(&dev->match_ids);187 if (NULL != dev->name)188 free(dev->name);189 free(dev);190 }191 192 static inline void *device_get_iface(device_t *dev, dev_inferface_idx_t idx)193 {194 assert(is_valid_iface_idx(idx));195 if (NULL == dev->ops)196 return NULL;197 return dev->ops->interfaces[idx];198 }199 200 int child_device_register(device_t *, device_t *);201 int child_device_register_wrapper(device_t *, const char *, const char *, int,202 devman_handle_t *);203 204 205 /* interrupts */206 153 207 154 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *); … … 221 168 } interrupt_context_list_t; 222 169 223 static inline interrupt_context_t *create_interrupt_context(void) 224 { 225 interrupt_context_t *ctx; 226 227 ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t)); 228 if (NULL != ctx) 229 memset(ctx, 0, sizeof(interrupt_context_t)); 230 231 return ctx; 232 } 170 extern interrupt_context_t *create_interrupt_context(void); 171 extern void delete_interrupt_context(interrupt_context_t *); 172 extern void init_interrupt_context_list(interrupt_context_list_t *); 173 extern void add_interrupt_context(interrupt_context_list_t *, 174 interrupt_context_t *); 175 extern void remove_interrupt_context(interrupt_context_list_t *, 176 interrupt_context_t *); 177 extern interrupt_context_t *find_interrupt_context_by_id( 178 interrupt_context_list_t *, int); 179 extern interrupt_context_t *find_interrupt_context( 180 interrupt_context_list_t *, device_t *, int); 233 181 234 static inline void delete_interrupt_context(interrupt_context_t *ctx) 235 { 236 if (NULL != ctx) 237 free(ctx); 238 } 182 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *, 183 irq_code_t *); 184 extern int unregister_interrupt_handler(device_t *, int); 239 185 240 static inline void init_interrupt_context_list(interrupt_context_list_t *list) 241 { 242 memset(list, 0, sizeof(interrupt_context_list_t)); 243 fibril_mutex_initialize(&list->mutex); 244 list_initialize(&list->contexts); 245 } 246 247 static inline void 248 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx) 249 { 250 fibril_mutex_lock(&list->mutex); 251 ctx->id = list->curr_id++; 252 list_append(&ctx->link, &list->contexts); 253 fibril_mutex_unlock(&list->mutex); 254 } 255 256 static inline void 257 remove_interrupt_context(interrupt_context_list_t *list, 258 interrupt_context_t *ctx) 259 { 260 fibril_mutex_lock(&list->mutex); 261 list_remove(&ctx->link); 262 fibril_mutex_unlock(&list->mutex); 263 } 264 265 static inline interrupt_context_t * 266 find_interrupt_context_by_id(interrupt_context_list_t *list, int id) 267 { 268 fibril_mutex_lock(&list->mutex); 269 270 link_t *link = list->contexts.next; 271 interrupt_context_t *ctx; 272 273 while (link != &list->contexts) { 274 ctx = list_get_instance(link, interrupt_context_t, link); 275 if (id == ctx->id) { 276 fibril_mutex_unlock(&list->mutex); 277 return ctx; 278 } 279 link = link->next; 280 } 281 282 fibril_mutex_unlock(&list->mutex); 283 return NULL; 284 } 285 286 static inline interrupt_context_t * 287 find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq) 288 { 289 fibril_mutex_lock(&list->mutex); 290 291 link_t *link = list->contexts.next; 292 interrupt_context_t *ctx; 293 294 while (link != &list->contexts) { 295 ctx = list_get_instance(link, interrupt_context_t, link); 296 if (irq == ctx->irq && dev == ctx->dev) { 297 fibril_mutex_unlock(&list->mutex); 298 return ctx; 299 } 300 link = link->next; 301 } 302 303 fibril_mutex_unlock(&list->mutex); 304 return NULL; 305 } 306 307 int register_interrupt_handler(device_t *, int, interrupt_handler_t *, 308 irq_code_t *); 309 int unregister_interrupt_handler(device_t *, int); 310 311 312 /* default handler for client requests */ 313 314 static inline remote_handler_t *device_get_default_handler(device_t *dev) 315 { 316 if (NULL == dev->ops) 317 return NULL; 318 return dev->ops->default_handler; 319 } 320 321 static inline int add_device_to_class(device_t *dev, const char *class_name) 322 { 323 return devman_add_device_to_class(dev->handle, class_name); 324 } 186 extern remote_handler_t *device_get_default_handler(device_t *); 187 extern int add_device_to_class(device_t *, const char *); 325 188 326 189 #endif -
uspace/lib/drv/include/ops/char_dev.h
r863d45e r1ffa73b 33 33 */ 34 34 35 #ifndef LIBDRV_ CHAR_H_36 #define LIBDRV_ CHAR_H_35 #ifndef LIBDRV_OPS_CHAR_DEV_H_ 36 #define LIBDRV_OPS_CHAR_DEV_H_ 37 37 38 #include " driver.h"38 #include "../driver.h" 39 39 40 typedef struct char_iface{40 typedef struct { 41 41 int (*read)(device_t *, char *, size_t); 42 42 int (*write)(device_t *, char *, size_t); 43 } char_ iface_t;43 } char_dev_ops_t; 44 44 45 45 #endif -
uspace/lib/drv/include/ops/hw_res.h
r863d45e r1ffa73b 33 33 */ 34 34 35 #ifndef LIBDRV_ RESOURCE_H_36 #define LIBDRV_ RESOURCE_H_35 #ifndef LIBDRV_OPS_HW_RES_H_ 36 #define LIBDRV_OPS_HW_RES_H_ 37 37 38 #include "driver.h" 38 #include <device/hw_res.h> 39 #include <sys/types.h> 39 40 40 typedef struct resource_iface { 41 hw_resource_list_t *(* get_resources)(device_t *); 41 #include "../driver.h" 42 43 typedef struct { 44 hw_resource_list_t *(*get_resource_list)(device_t *); 42 45 bool (*enable_interrupt)(device_t *); 43 } resource_iface_t; 44 46 } hw_res_ops_t; 45 47 46 48 #endif -
uspace/lib/drv/include/remote_char_dev.h
r863d45e r1ffa73b 33 33 */ 34 34 35 #ifndef LIBDRV_REMOTE_ RES_H_36 #define LIBDRV_REMOTE_ RES_H_35 #ifndef LIBDRV_REMOTE_CHAR_DEV_H_ 36 #define LIBDRV_REMOTE_CHAR_DEV_H_ 37 37 38 remote_iface_t remote_res_iface;38 extern remote_iface_t remote_char_dev_iface; 39 39 40 40 #endif -
uspace/lib/drv/include/remote_hw_res.h
r863d45e r1ffa73b 33 33 */ 34 34 35 #ifndef LIBDRV_REMOTE_ CHAR_H_36 #define LIBDRV_REMOTE_ CHAR_H_35 #ifndef LIBDRV_REMOTE_HW_RES_H_ 36 #define LIBDRV_REMOTE_HW_RES_H_ 37 37 38 remote_iface_t remote_char_iface;38 extern remote_iface_t remote_hw_res_iface; 39 39 40 40 #endif -
uspace/lib/net/Makefile
r863d45e r1ffa73b 40 40 generic/protocol_map.c \ 41 41 adt/module_map.c \ 42 netif/netif_local.c \43 42 netif/netif_remote.c \ 43 netif/netif_skel.c \ 44 44 nil/nil_remote.c \ 45 45 il/il_interface.c \ -
uspace/lib/net/adt/module_map.c
r863d45e r1ffa73b 63 63 */ 64 64 int 65 add_module(module_t **module, modules_t *modules, const char*name,66 const char*filename, services_t service, task_id_t task_id,65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 66 const uint8_t *filename, services_t service, task_id_t task_id, 67 67 connect_module_t connect_module) 68 68 { … … 104 104 * @return NULL if there is no such module. 105 105 */ 106 module_t *get_running_module(modules_t *modules, char*name)106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 108 module_t *module; … … 113 113 114 114 if (!module->task_id) { 115 module->task_id = spawn(module->filename);115 module->task_id = net_spawn(module->filename); 116 116 if (!module->task_id) 117 117 return NULL; … … 123 123 } 124 124 125 /** Start sthe given module.125 /** Start the given module. 126 126 * 127 * @param[in] fname The module full or relative path filename. 128 * @return The new module task identifier on success. 129 * @return Zero if there is no such module. 127 * @param[in] fname The module full or relative path filename. 128 * 129 * @return The new module task identifier on success. 130 * @return Zero if there is no such module. 131 * 130 132 */ 131 task_id_t spawn(const char*fname)133 task_id_t net_spawn(const uint8_t *fname) 132 134 { 133 135 task_id_t id; 134 136 int rc; 135 137 136 rc = task_spawnl(&id, fname,fname, NULL);138 rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL); 137 139 if (rc != EOK) 138 140 return 0; -
uspace/lib/net/generic/generic.c
r863d45e r1ffa73b 100 100 int 101 101 generic_get_addr_req(int phone, int message, device_id_t device_id, 102 measured_string_t **address, char **data)102 measured_string_t **address, uint8_t **data) 103 103 { 104 104 aid_t message_id; … … 234 234 generic_translate_req(int phone, int message, device_id_t device_id, 235 235 services_t service, measured_string_t *configuration, size_t count, 236 measured_string_t **translation, char**data)236 measured_string_t **translation, uint8_t **data) 237 237 { 238 238 aid_t message_id; -
uspace/lib/net/generic/net_remote.c
r863d45e r1ffa73b 63 63 * @see net_get_conf_req() 64 64 */ 65 void net_free_settings(measured_string_t *settings, char*data)65 void net_free_settings(measured_string_t *settings, uint8_t *data) 66 66 { 67 67 if (settings) … … 91 91 int 92 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 93 size_t count, char**data)93 size_t count, uint8_t **data) 94 94 { 95 95 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, … … 118 118 int 119 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 120 measured_string_t **configuration, size_t count, char**data)120 measured_string_t **configuration, size_t count, uint8_t **data) 121 121 { 122 122 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, -
uspace/lib/net/il/arp_remote.c
r863d45e r1ffa73b 165 165 int 166 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, char**data)167 measured_string_t *address, measured_string_t **translation, uint8_t **data) 168 168 { 169 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, -
uspace/lib/net/il/ip_remote.c
r863d45e r1ffa73b 170 170 free(*header); 171 171 else 172 *device_id = IPC_GET_DEVICE( &answer);172 *device_id = IPC_GET_DEVICE(answer); 173 173 174 174 return (int) result; -
uspace/lib/net/include/adt/module_map.h
r863d45e r1ffa73b 65 65 int usage; 66 66 /** Module name. */ 67 const char*name;67 const uint8_t *name; 68 68 /** Module full path filename. */ 69 const char*filename;69 const uint8_t *filename; 70 70 /** Connecting function. */ 71 71 connect_module_t *connect_module; 72 72 }; 73 73 74 extern int add_module(module_t **, modules_t *, const char *, const char*,75 services_t, task_id_t, connect_module_t *);76 extern module_t *get_running_module(modules_t *, char*);77 extern task_id_t spawn(const char*);74 extern int add_module(module_t **, modules_t *, const uint8_t *, 75 const uint8_t *, services_t, task_id_t, connect_module_t *); 76 extern module_t *get_running_module(modules_t *, uint8_t *); 77 extern task_id_t net_spawn(const uint8_t *); 78 78 79 79 #endif -
uspace/lib/net/include/arp_interface.h
r863d45e r1ffa73b 50 50 measured_string_t *); 51 51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *, 52 measured_string_t **, char**);52 measured_string_t **, uint8_t **); 53 53 extern int arp_clear_device_req(int, device_id_t); 54 54 extern int arp_clear_address_req(int, device_id_t, services_t, -
uspace/lib/net/include/generic.h
r863d45e r1ffa73b 50 50 extern int generic_device_req_remote(int, int, device_id_t, int, services_t); 51 51 extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **, 52 char**);52 uint8_t **); 53 53 extern int generic_packet_size_req_remote(int, int, device_id_t, 54 54 packet_dimension_t *); … … 58 58 services_t, services_t); 59 59 extern int generic_translate_req(int, int, device_id_t, services_t, 60 measured_string_t *, size_t, measured_string_t **, char**);60 measured_string_t *, size_t, measured_string_t **, uint8_t **); 61 61 62 62 #endif -
uspace/lib/net/include/il_local.h
r863d45e r1ffa73b 49 49 */ 50 50 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 51 ipc_call_t *answer, int *answer_count);51 ipc_call_t *answer, size_t *answer_count); 52 52 53 53 /** Starts the Internet layer module. -
uspace/lib/net/include/net_interface.h
r863d45e r1ffa73b 45 45 46 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **, 47 size_t, char**);48 extern int net_get_conf_req(int, measured_string_t **, size_t, char**);49 extern void net_free_settings(measured_string_t *, char*);47 size_t, uint8_t **); 48 extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **); 49 extern void net_free_settings(measured_string_t *, uint8_t *); 50 50 extern int net_connect_module(void); 51 51 -
uspace/lib/net/include/netif_remote.h
r863d45e r1ffa73b 41 41 #include <net/packet.h> 42 42 43 extern int netif_get_addr_req _remote(int, device_id_t, measured_string_t **,44 char**);45 extern int netif_probe_req _remote(int, device_id_t, int, int);46 extern int netif_send_msg _remote(int, device_id_t, packet_t *, services_t);47 extern int netif_start_req _remote(int, device_id_t);48 extern int netif_stop_req _remote(int, device_id_t);49 extern int netif_stats_req _remote(int, device_id_t, device_stats_t *);50 extern int netif_bind_service _remote(services_t, device_id_t, services_t,43 extern int netif_get_addr_req(int, device_id_t, measured_string_t **, 44 uint8_t **); 45 extern int netif_probe_req(int, device_id_t, int, void *); 46 extern int netif_send_msg(int, device_id_t, packet_t *, services_t); 47 extern int netif_start_req(int, device_id_t); 48 extern int netif_stop_req(int, device_id_t); 49 extern int netif_stats_req(int, device_id_t, device_stats_t *); 50 extern int netif_bind_service(services_t, device_id_t, services_t, 51 51 async_client_conn_t); 52 52 -
uspace/lib/net/include/netif_skel.h
r863d45e r1ffa73b 36 36 */ 37 37 38 #ifndef NET_NETIF_ LOCAL_H_39 #define NET_NETIF_ LOCAL_H_38 #ifndef NET_NETIF_SKEL_H_ 39 #define NET_NETIF_SKEL_H_ 40 40 41 41 #include <async.h> … … 76 76 * 77 77 * This function has to be implemented in user code. 78 * 78 79 */ 79 80 extern int netif_initialize(void); … … 83 84 * This has to be implemented in user code. 84 85 * 85 * @param[in] device_id The device identifier. 86 * @param[in] irq The device interrupt number. 87 * @param[in] io The device input/output address. 88 * 89 * @return EOK on success. 90 * @return Other error codes as defined for the find_device() 91 * function. 92 * @return Other error codes as defined for the specific module 93 * message implementation. 94 */ 95 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io); 86 * @param[in] device_id Device identifier. 87 * @param[in] irq Device interrupt number. 88 * @param[in] io Device input/output address. 89 * 90 * @return EOK on success. 91 * @return Other error codes as defined for the find_device() 92 * function. 93 * @return Other error codes as defined for the specific module 94 * message implementation. 95 * 96 */ 97 extern int netif_probe_message(device_id_t device_id, int irq, void *io); 96 98 97 99 /** Send the packet queue. … … 99 101 * This has to be implemented in user code. 100 102 * 101 * @param[in] device_id The device identifier. 102 * @param[in] packet The packet queue. 103 * @param[in] sender The sending module service. 104 * 105 * @return EOK on success. 106 * @return EFORWARD if the device is not active (in the 107 * NETIF_ACTIVE state). 108 * @return Other error codes as defined for the find_device() 109 * function. 110 * @return Other error codes as defined for the specific module 111 * message implementation. 103 * @param[in] device_id Device identifier. 104 * @param[in] packet Packet queue. 105 * @param[in] sender Sending module service. 106 * 107 * @return EOK on success. 108 * @return EFORWARD if the device is not active (in the 109 * NETIF_ACTIVE state). 110 * @return Other error codes as defined for the find_device() 111 * function. 112 * @return Other error codes as defined for the specific module 113 * message implementation. 114 * 112 115 */ 113 116 extern int netif_send_message(device_id_t device_id, packet_t *packet, … … 118 121 * This has to be implemented in user code. 119 122 * 120 * @param[in] device The device structure. 121 * 122 * @return EOK on success. 123 * @return Other error codes as defined for the find_device() 124 * function. 125 * @return Other error codes as defined for the specific module 126 * message implementation. 123 * @param[in] device Device structure. 124 * 125 * @return New network interface state (non-negative values). 126 * @return Other error codes as defined for the find_device() 127 * function. 128 * @return Other error codes as defined for the specific module 129 * message implementation. 130 131 * 127 132 */ 128 133 extern int netif_start_message(netif_device_t *device); … … 132 137 * This has to be implemented in user code. 133 138 * 134 * @param[in] device The device structure. 135 * 136 * @return EOK on success. 137 * @return Other error codes as defined for the find_device() 138 * function. 139 * @return Other error codes as defined for the specific module 140 * message implementation. 139 * @param[in] device Device structure. 140 * 141 * @return EOK on success. 142 * @return Other error codes as defined for the find_device() 143 * function. 144 * @return Other error codes as defined for the specific module 145 * message implementation. 146 * 141 147 */ 142 148 extern int netif_stop_message(netif_device_t *device); … … 146 152 * This has to be implemented in user code. 147 153 * 148 * @param[in] device_id The device identifier. 149 * @param[out] address The device local hardware address. 150 * 151 * @return EOK on success. 152 * @return EBADMEM if the address parameter is NULL. 153 * @return ENOENT if there no such device. 154 * @return Other error codes as defined for the find_device() 155 * function. 156 * @return Other error codes as defined for the specific module 157 * message implementation. 154 * @param[in] device_id Device identifier. 155 * @param[out] address Device local hardware address. 156 * 157 * @return EOK on success. 158 * @return EBADMEM if the address parameter is NULL. 159 * @return ENOENT if there no such device. 160 * @return Other error codes as defined for the find_device() 161 * function. 162 * @return Other error codes as defined for the specific module 163 * message implementation. 164 * 158 165 */ 159 166 extern int netif_get_addr_message(device_id_t device_id, … … 165 172 * skeleton. This has to be implemented in user code. 166 173 * 167 * @param[in] callid The message identifier.168 * @param[in] call The message parameters.169 * @param[out] answer The message answer parameters.170 * @param[out] answer_count The last parameter for the actual answer in171 * the answer parameter.172 * 173 * @return EOK on success.174 * @return ENOTSUP if the message is not known.175 * @return Other error codes as defined for the specific module176 * message implementation.174 * @param[in] callid Message identifier. 175 * @param[in] call Message. 176 * @param[out] answer Answer. 177 * @param[out] count Number of answer arguments. 178 * 179 * @return EOK on success. 180 * @return ENOTSUP if the message is not known. 181 * @return Other error codes as defined for the specific module 182 * message implementation. 183 * 177 184 */ 178 185 extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call, 179 ipc_call_t *answer, int *answer_count);186 ipc_call_t *answer, size_t *count); 180 187 181 188 /** Return the device usage statistics. … … 183 190 * This has to be implemented in user code. 184 191 * 185 * @param[in] device_id The device identifier. 186 * @param[out] stats The device usage statistics. 187 * 188 * @return EOK on success. 189 * @return Other error codes as defined for the find_device() 190 * function. 191 * @return Other error codes as defined for the specific module 192 * message implementation. 192 * @param[in] device_id Device identifier. 193 * @param[out] stats Device usage statistics. 194 * 195 * @return EOK on success. 196 * @return Other error codes as defined for the find_device() 197 * function. 198 * @return Other error codes as defined for the specific module 199 * message implementation. 200 * 193 201 */ 194 202 extern int netif_get_device_stats(device_id_t device_id, 195 203 device_stats_t *stats); 196 197 extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,198 char **);199 extern int netif_probe_req_local(int, device_id_t, int, int);200 extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);201 extern int netif_start_req_local(int, device_id_t);202 extern int netif_stop_req_local(int, device_id_t);203 extern int netif_stats_req_local(int, device_id_t, device_stats_t *);204 extern int netif_bind_service_local(services_t, device_id_t, services_t,205 async_client_conn_t);206 204 207 205 extern int find_device(device_id_t, netif_device_t **); … … 209 207 extern void netif_pq_release(packet_id_t); 210 208 extern packet_t *netif_packet_get_1(size_t); 211 extern int netif_init_module(async_client_conn_t); 212 213 extern int netif_module_message_standalone(const char *, ipc_callid_t, 214 ipc_call_t *, ipc_call_t *, int *); 215 extern int netif_module_start_standalone(async_client_conn_t); 209 210 extern int netif_module_start(void); 216 211 217 212 #endif -
uspace/lib/net/include/nil_local.h
r863d45e r1ffa73b 96 96 */ 97 97 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, 98 ipc_call_t *, int *);98 ipc_call_t *, size_t *); 99 99 100 100 /** Pass the parameters to the module specific nil_message() function. … … 112 112 */ 113 113 extern int nil_module_message_standalone(const char *, ipc_callid_t, 114 ipc_call_t *, ipc_call_t *, int *);114 ipc_call_t *, ipc_call_t *, size_t *); 115 115 116 116 /** Start the standalone nil layer module. -
uspace/lib/net/include/socket_core.h
r863d45e r1ffa73b 86 86 void *specific_data; 87 87 /** Socket ports map key. */ 88 const char*key;88 const uint8_t *key; 89 89 /** Length of the Socket ports map key. */ 90 90 size_t key_length; … … 118 118 void (*)(socket_core_t *)); 119 119 extern int socket_reply_packets(packet_t *, size_t *); 120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char*,120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, 121 121 size_t); 122 122 extern void socket_port_release(socket_ports_t *, socket_core_t *); 123 123 extern int socket_port_add(socket_ports_t *, int, socket_core_t *, 124 const char*, size_t);124 const uint8_t *, size_t); 125 125 126 126 #endif -
uspace/lib/net/include/tl_local.h
r863d45e r1ffa73b 52 52 */ 53 53 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *, 54 ipc_call_t *, int *); 55 54 ipc_call_t *, size_t *); 56 55 57 56 /** Processes the TL module message. -
uspace/lib/net/netif/netif_remote.c
r863d45e r1ffa73b 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 49 49 /** Return the device local hardware address. 50 50 * 51 * @param[in] netif_phone The network interface phone. 52 * @param[in] device_id The device identifier. 53 * @param[out] address The device local hardware address. 54 * @param[out] data The address data. 55 * @return EOK on success. 56 * @return EBADMEM if the address parameter is NULL. 57 * @return ENOENT if there no such device. 58 * @return Other error codes as defined for the 59 * netif_get_addr_message() function. 51 * @param[in] netif_phone Network interface phone. 52 * @param[in] device_id Device identifier. 53 * @param[out] address Device local hardware address. 54 * @param[out] data Address data. 55 * 56 * @return EOK on success. 57 * @return EBADMEM if the address parameter is NULL. 58 * @return ENOENT if there no such device. 59 * @return Other error codes as defined for the 60 * netif_get_addr_message() function. 61 * 60 62 */ 61 int netif_get_addr_req _remote(int netif_phone, device_id_t device_id,62 measured_string_t **address, char**data)63 int netif_get_addr_req(int netif_phone, device_id_t device_id, 64 measured_string_t **address, uint8_t **data) 63 65 { 64 66 return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, … … 68 70 /** Probe the existence of the device. 69 71 * 70 * @param[in] netif_phone The network interface phone. 71 * @param[in] device_id The device identifier. 72 * @param[in] irq The device interrupt number. 73 * @param[in] io The device input/output address. 74 * @return EOK on success. 75 * @return Other error codes as defined for the 76 * netif_probe_message(). 72 * @param[in] netif_phone Network interface phone. 73 * @param[in] device_id Device identifier. 74 * @param[in] irq Device interrupt number. 75 * @param[in] io Device input/output address. 76 * 77 * @return EOK on success. 78 * @return Other error codes as defined for the 79 * netif_probe_message(). 80 * 77 81 */ 78 int 79 netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io) 82 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io) 80 83 { 81 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io); 84 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, 85 (sysarg_t) io); 82 86 } 83 87 84 88 /** Send the packet queue. 85 89 * 86 * @param[in] netif_phone The network interface phone. 87 * @param[in] device_id The device identifier. 88 * @param[in] packet The packet queue. 89 * @param[in] sender The sending module service. 90 * @return EOK on success. 91 * @return Other error codes as defined for the generic_send_msg() 92 * function. 90 * @param[in] netif_phone Network interface phone. 91 * @param[in] device_id Device identifier. 92 * @param[in] packet Packet queue. 93 * @param[in] sender Sending module service. 94 * 95 * @return EOK on success. 96 * @return Other error codes as defined for the generic_send_msg() 97 * function. 98 * 93 99 */ 94 int 95 netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet, 100 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet, 96 101 services_t sender) 97 102 { … … 102 107 /** Start the device. 103 108 * 104 * @param[in] netif_phone The network interface phone. 105 * @param[in] device_id The device identifier. 106 * @return EOK on success. 107 * @return Other error codes as defined for the find_device() 108 * function. 109 * @return Other error codes as defined for the 110 * netif_start_message() function. 109 * @param[in] netif_phone Network interface phone. 110 * @param[in] device_id Device identifier. 111 * 112 * @return EOK on success. 113 * @return Other error codes as defined for the find_device() 114 * function. 115 * @return Other error codes as defined for the 116 * netif_start_message() function. 117 * 111 118 */ 112 int netif_start_req _remote(int netif_phone, device_id_t device_id)119 int netif_start_req(int netif_phone, device_id_t device_id) 113 120 { 114 121 return async_req_1_0(netif_phone, NET_NETIF_START, device_id); … … 117 124 /** Stop the device. 118 125 * 119 * @param[in] netif_phone The network interface phone. 120 * @param[in] device_id The device identifier. 121 * @return EOK on success. 122 * @return Other error codes as defined for the find_device() 123 * function. 124 * @return Other error codes as defined for the 125 * netif_stop_message() function. 126 * @param[in] netif_phone Network interface phone. 127 * @param[in] device_id Device identifier. 128 * 129 * @return EOK on success. 130 * @return Other error codes as defined for the find_device() 131 * function. 132 * @return Other error codes as defined for the 133 * netif_stop_message() function. 134 * 126 135 */ 127 int netif_stop_req _remote(int netif_phone, device_id_t device_id)136 int netif_stop_req(int netif_phone, device_id_t device_id) 128 137 { 129 138 return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id); … … 132 141 /** Return the device usage statistics. 133 142 * 134 * @param[in] netif_phone The network interface phone. 135 * @param[in] device_id The device identifier. 136 * @param[out] stats The device usage statistics. 143 * @param[in] netif_phone Network interface phone. 144 * @param[in] device_id Device identifier. 145 * @param[out] stats Device usage statistics. 146 * 137 147 * @return EOK on success. 148 * 138 149 */ 139 int netif_stats_req _remote(int netif_phone, device_id_t device_id,150 int netif_stats_req(int netif_phone, device_id_t device_id, 140 151 device_stats_t *stats) 141 152 { … … 153 164 } 154 165 155 /** Create bidirectional connection with the network interface module and 156 * registers the message receiver. 166 /** Create bidirectional connection with the network interface module 167 * 168 * Create bidirectional connection with the network interface module and 169 * register the message receiver. 157 170 * 158 171 * @param[in] service The network interface module service. … … 161 174 * @param[in] receiver The message receiver. 162 175 * 163 * @return The phone of the needed service. 164 * @return EOK on success. 165 * @return Other error codes as defined for the bind_service() 166 * function. 176 * @return The phone of the needed service. 177 * @return EOK on success. 178 * @return Other error codes as defined for the bind_service() 179 * function. 180 * 167 181 */ 168 int 169 netif_bind_service_remote(services_t service, device_id_t device_id, 182 int netif_bind_service(services_t service, device_id_t device_id, 170 183 services_t me, async_client_conn_t receiver) 171 184 { -
uspace/lib/net/netif/netif_skel.c
r863d45e r1ffa73b 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 53 53 #include <net/device.h> 54 54 #include <nil_interface.h> 55 #include <netif_local.h> 56 #include <netif_interface.h> 55 #include <netif_skel.h> 57 56 58 57 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); … … 63 62 /** Probe the existence of the device. 64 63 * 65 * @param[in] netif_phone The network interface phone. 66 * @param[in] device_id The device identifier. 67 * @param[in] irq The device interrupt number. 68 * @param[in] io The device input/output address. 69 * @return EOK on success. 70 * @return Other error codes as defined for the 71 * netif_probe_message(). 72 */ 73 int 74 netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io) 64 * @param[in] netif_phone Network interface phone. 65 * @param[in] device_id Device identifier. 66 * @param[in] irq Device interrupt number. 67 * @param[in] io Device input/output address. 68 * 69 * @return EOK on success. 70 * @return Other error codes as defined for the 71 * netif_probe_message(). 72 * 73 */ 74 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 75 int irq, void *io) 75 76 { 76 77 fibril_rwlock_write_lock(&netif_globals.lock); … … 83 84 /** Send the packet queue. 84 85 * 85 * @param[in] netif_phone The network interface phone. 86 * @param[in] device_id The device identifier. 87 * @param[in] packet The packet queue. 88 * @param[in] sender The sending module service. 89 * @return EOK on success. 90 * @return Other error codes as defined for the generic_send_msg() 91 * function. 92 */ 93 int netif_send_msg_local(int netif_phone, device_id_t device_id, 86 * @param[in] netif_phone Network interface phone. 87 * @param[in] device_id Device identifier. 88 * @param[in] packet Packet queue. 89 * @param[in] sender Sending module service. 90 * 91 * @return EOK on success. 92 * @return Other error codes as defined for the generic_send_msg() 93 * function. 94 * 95 */ 96 static int netif_send_msg_local(int netif_phone, device_id_t device_id, 94 97 packet_t *packet, services_t sender) 95 98 { … … 103 106 /** Start the device. 104 107 * 105 * @param[in] netif_phone The network interface phone.106 * @param[in] device_id The device identifier.107 * @return EOK on success.108 * @return Other error codes as defined for the find_device()109 * function.110 * @return Other error codes as defined for the111 * netif_start_message() function.112 * /113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 { 115 int rc; 116 108 * @param[in] netif_phone Network interface phone. 109 * @param[in] device_id Device identifier. 110 * 111 * @return EOK on success. 112 * @return Other error codes as defined for the find_device() 113 * function. 114 * @return Other error codes as defined for the 115 * netif_start_message() function. 116 * 117 */ 118 static int netif_start_req_local(int netif_phone, device_id_t device_id) 119 { 117 120 fibril_rwlock_write_lock(&netif_globals.lock); 118 121 119 122 netif_device_t *device; 120 rc = find_device(device_id, &device);123 int rc = find_device(device_id, &device); 121 124 if (rc != EOK) { 122 125 fibril_rwlock_write_unlock(&netif_globals.lock); … … 139 142 /** Stop the device. 140 143 * 141 * @param[in] netif_phone The network interface phone.142 * @param[in] device_id The device identifier.143 * @return EOK on success.144 * @return Other error codes as defined for the find_device()145 * function.146 * @return Other error codes as defined for the147 * netif_stop_message() function.148 * /149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 150 { 151 int rc; 152 144 * @param[in] netif_phone Network interface phone. 145 * @param[in] device_id Device identifier. 146 * 147 * @return EOK on success. 148 * @return Other error codes as defined for the find_device() 149 * function. 150 * @return Other error codes as defined for the 151 * netif_stop_message() function. 152 * 153 */ 154 static int netif_stop_req_local(int netif_phone, device_id_t device_id) 155 { 153 156 fibril_rwlock_write_lock(&netif_globals.lock); 154 157 155 158 netif_device_t *device; 156 rc = find_device(device_id, &device);159 int rc = find_device(device_id, &device); 157 160 if (rc != EOK) { 158 161 fibril_rwlock_write_unlock(&netif_globals.lock); … … 173 176 } 174 177 175 /** Return the device usage statistics.176 *177 * @param[in] netif_phone The network interface phone.178 * @param[in] device_id The device identifier.179 * @param[out] stats The device usage statistics.180 * @return EOK on success.181 */182 int netif_stats_req_local(int netif_phone, device_id_t device_id,183 device_stats_t *stats)184 {185 fibril_rwlock_read_lock(&netif_globals.lock);186 int res = netif_get_device_stats(device_id, stats);187 fibril_rwlock_read_unlock(&netif_globals.lock);188 189 return res;190 }191 192 /** Return the device local hardware address.193 *194 * @param[in] netif_phone The network interface phone.195 * @param[in] device_id The device identifier.196 * @param[out] address The device local hardware address.197 * @param[out] data The address data.198 * @return EOK on success.199 * @return EBADMEM if the address parameter is NULL.200 * @return ENOENT if there no such device.201 * @return Other error codes as defined for the202 * netif_get_addr_message() function.203 */204 int netif_get_addr_req_local(int netif_phone, device_id_t device_id,205 measured_string_t **address, char **data)206 {207 int rc;208 209 if (!address || !data)210 return EBADMEM;211 212 fibril_rwlock_read_lock(&netif_globals.lock);213 214 measured_string_t translation;215 rc = netif_get_addr_message(device_id, &translation);216 if (rc == EOK) {217 *address = measured_string_copy(&translation);218 rc = (*address) ? EOK : ENOMEM;219 }220 221 fibril_rwlock_read_unlock(&netif_globals.lock);222 223 *data = (**address).value;224 225 return rc;226 }227 228 178 /** Find the device specific data. 229 179 * 230 * @param[in] device_id The device identifier. 231 * @param[out] device The device specific data. 232 * @return EOK on success. 233 * @return ENOENT if device is not found. 234 * @return EPERM if the device is not initialized. 180 * @param[in] device_id Device identifier. 181 * @param[out] device Device specific data. 182 * 183 * @return EOK on success. 184 * @return ENOENT if device is not found. 185 * @return EPERM if the device is not initialized. 186 * 235 187 */ 236 188 int find_device(device_id_t device_id, netif_device_t **device) … … 251 203 /** Clear the usage statistics. 252 204 * 253 * @param[in] stats The usage statistics. 205 * @param[in] stats The usage statistics. 206 * 254 207 */ 255 208 void null_device_stats(device_stats_t *stats) … … 258 211 } 259 212 260 /** Initialize the netif module. 261 * 262 * @param[in] client_connection The client connection functio to be registered. 263 * @return EOK on success. 264 * @return Other error codes as defined for each specific module 265 * message function. 266 */ 267 int netif_init_module(async_client_conn_t client_connection) 268 { 269 int rc; 270 271 async_set_client_connection(client_connection); 272 273 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 274 netif_device_map_initialize(&netif_globals.device_map); 275 276 rc = pm_init(); 213 /** Release the given packet. 214 * 215 * Prepared for future optimization. 216 * 217 * @param[in] packet_id The packet identifier. 218 * 219 */ 220 void netif_pq_release(packet_id_t packet_id) 221 { 222 pq_release_remote(netif_globals.net_phone, packet_id); 223 } 224 225 /** Allocate new packet to handle the given content size. 226 * 227 * @param[in] content Minimum content size. 228 * 229 * @return The allocated packet. 230 * @return NULL on error. 231 * 232 */ 233 packet_t *netif_packet_get_1(size_t content) 234 { 235 return packet_get_1_remote(netif_globals.net_phone, content); 236 } 237 238 /** Register the device notification receiver, 239 * 240 * Register a network interface layer module as the device 241 * notification receiver. 242 * 243 * @param[in] device_id Device identifier. 244 * @param[in] phone Network interface layer module phone. 245 * 246 * @return EOK on success. 247 * @return ENOENT if there is no such device. 248 * @return ELIMIT if there is another module registered. 249 * 250 */ 251 static int register_message(device_id_t device_id, int phone) 252 { 253 netif_device_t *device; 254 int rc = find_device(device_id, &device); 277 255 if (rc != EOK) 278 256 return rc; 279 257 280 fibril_rwlock_initialize(&netif_globals.lock); 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 284 pm_destroy(); 285 return rc; 286 } 287 258 if (device->nil_phone >= 0) 259 return ELIMIT; 260 261 device->nil_phone = phone; 288 262 return EOK; 289 263 } 290 264 291 /** Release the given packet.292 *293 * Prepared for future optimization.294 *295 * @param[in] packet_id The packet identifier.296 */297 void netif_pq_release(packet_id_t packet_id)298 {299 pq_release_remote(netif_globals.net_phone, packet_id);300 }301 302 /** Allocate new packet to handle the given content size.303 *304 * @param[in] content The minimum content size.305 * @return The allocated packet.306 * @return NULL if there is an error.307 *308 */309 packet_t *netif_packet_get_1(size_t content)310 {311 return packet_get_1_remote(netif_globals.net_phone, content);312 }313 314 /** Register the device notification receiver, the network interface layer315 * module.316 *317 * @param[in] name Module name.318 * @param[in] device_id The device identifier.319 * @param[in] phone The network interface layer module phone.320 * @return EOK on success.321 * @return ENOENT if there is no such device.322 * @return ELIMIT if there is another module registered.323 */324 static int register_message(const char *name, device_id_t device_id, int phone)325 {326 netif_device_t *device;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)334 return ELIMIT;335 336 device->nil_phone = phone;337 printf("%s: Receiver of device %d registered (phone: %d)\n",338 name, device->device_id, device->nil_phone);339 return EOK;340 }341 342 265 /** Process the netif module messages. 343 266 * 344 * @param[in] name Module name. 345 * @param[in] callid The message identifier. 346 * @param[in] call The message parameters. 347 * @param[out] answer The message answer parameters. 348 * @param[out] answer_count The last parameter for the actual answer in the 349 * answer parameter. 350 * @return EOK on success. 351 * @return ENOTSUP if the message is not known. 352 * @return Other error codes as defined for each specific module 353 * message function. 267 * @param[in] callid Mmessage identifier. 268 * @param[in] call Message. 269 * @param[out] answer Answer. 270 * @param[out] count Number of arguments of the answer. 271 * 272 * @return EOK on success. 273 * @return ENOTSUP if the message is unknown. 274 * @return Other error codes as defined for each specific module 275 * message function. 354 276 * 355 277 * @see IS_NET_NETIF_MESSAGE() 356 278 * 357 279 */ 358 int netif_module_message_standalone(const char *name, ipc_callid_t callid,359 ipc_call_t * call, ipc_call_t *answer, int *answer_count)280 static int netif_module_message(ipc_callid_t callid, ipc_call_t *call, 281 ipc_call_t *answer, size_t *count) 360 282 { 361 283 size_t length; … … 365 287 int rc; 366 288 367 *answer_count = 0; 289 *count = 0; 290 368 291 switch (IPC_GET_IMETHOD(*call)) { 369 292 case IPC_M_PHONE_HUNGUP: … … 371 294 372 295 case NET_NETIF_PROBE: 373 return netif_probe_req_local(0, IPC_GET_DEVICE( call),374 NETIF_GET_IRQ( call), NETIF_GET_IO(call));375 296 return netif_probe_req_local(0, IPC_GET_DEVICE(*call), 297 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 298 376 299 case IPC_M_CONNECT_TO_ME: 377 300 fibril_rwlock_write_lock(&netif_globals.lock); 378 rc = register_message(name, IPC_GET_DEVICE(call), 379 IPC_GET_PHONE(call)); 301 302 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call)); 303 380 304 fibril_rwlock_write_unlock(&netif_globals.lock); 381 305 return rc; 382 306 383 307 case NET_NETIF_SEND: 384 308 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET( call));309 IPC_GET_PACKET(*call)); 386 310 if (rc != EOK) 387 311 return rc; 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 389 IPC_GET_SENDER(call)); 390 312 313 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 314 IPC_GET_SENDER(*call)); 315 391 316 case NET_NETIF_START: 392 return netif_start_req_local(0, IPC_GET_DEVICE( call));393 317 return netif_start_req_local(0, IPC_GET_DEVICE(*call)); 318 394 319 case NET_NETIF_STATS: 395 320 fibril_rwlock_read_lock(&netif_globals.lock); 396 321 397 322 rc = async_data_read_receive(&callid, &length); 398 323 if (rc != EOK) { … … 400 325 return rc; 401 326 } 327 402 328 if (length < sizeof(device_stats_t)) { 403 329 fibril_rwlock_read_unlock(&netif_globals.lock); 404 330 return EOVERFLOW; 405 331 } 406 407 rc = netif_get_device_stats(IPC_GET_DEVICE( call), &stats);332 333 rc = netif_get_device_stats(IPC_GET_DEVICE(*call), &stats); 408 334 if (rc == EOK) { 409 335 rc = async_data_read_finalize(callid, &stats, 410 336 sizeof(device_stats_t)); 411 337 } 412 338 413 339 fibril_rwlock_read_unlock(&netif_globals.lock); 414 340 return rc; 415 341 416 342 case NET_NETIF_STOP: 417 return netif_stop_req_local(0, IPC_GET_DEVICE( call));418 343 return netif_stop_req_local(0, IPC_GET_DEVICE(*call)); 344 419 345 case NET_NETIF_GET_ADDR: 420 346 fibril_rwlock_read_lock(&netif_globals.lock); 421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 347 348 rc = netif_get_addr_message(IPC_GET_DEVICE(*call), &address); 422 349 if (rc == EOK) 423 350 rc = measured_strings_reply(&address, 1); 351 424 352 fibril_rwlock_read_unlock(&netif_globals.lock); 425 353 return rc; 426 354 } 427 355 428 return netif_specific_message(callid, call, answer, answer_count); 356 return netif_specific_message(callid, call, answer, count); 357 } 358 359 /** Default fibril for new module connections. 360 * 361 * @param[in] iid Initial message identifier. 362 * @param[in] icall Initial message call structure. 363 * 364 */ 365 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall) 366 { 367 /* 368 * Accept the connection by answering 369 * the initial IPC_M_CONNECT_ME_TO call. 370 */ 371 ipc_answer_0(iid, EOK); 372 373 while (true) { 374 ipc_call_t answer; 375 size_t count; 376 377 /* Clear the answer structure */ 378 refresh_answer(&answer, &count); 379 380 /* Fetch the next message */ 381 ipc_call_t call; 382 ipc_callid_t callid = async_get_call(&call); 383 384 /* Process the message */ 385 int res = netif_module_message(callid, &call, &answer, &count); 386 387 /* End if said to either by the message or the processing result */ 388 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 389 (res == EHANGUP)) 390 return; 391 392 /* Answer the message */ 393 answer_call(callid, res, &answer, count); 394 } 429 395 } 430 396 … … 435 401 * messages in an infinite loop. 436 402 * 437 * @param[in] client_connection The client connection processing function. 438 * The module skeleton propagates its own one. 439 * @return EOK on success. 440 * @return Other error codes as defined for each specific module 441 * message function. 442 */ 443 int netif_module_start_standalone(async_client_conn_t client_connection) 444 { 445 int rc; 446 447 rc = netif_init_module(client_connection); 403 * @return EOK on success. 404 * @return Other error codes as defined for each specific module 405 * message function. 406 * 407 */ 408 int netif_module_start(void) 409 { 410 async_set_client_connection(netif_client_connection); 411 412 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 413 netif_device_map_initialize(&netif_globals.device_map); 414 415 int rc = pm_init(); 448 416 if (rc != EOK) 449 417 return rc; 418 419 fibril_rwlock_initialize(&netif_globals.lock); 420 421 rc = netif_initialize(); 422 if (rc != EOK) { 423 pm_destroy(); 424 return rc; 425 } 450 426 451 427 async_manager(); -
uspace/lib/net/tl/socket_core.c
r863d45e r1ffa73b 161 161 static int 162 162 socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket, 163 const char*key, size_t key_length)163 const uint8_t *key, size_t key_length) 164 164 { 165 165 socket_core_t **socket_ref; … … 216 216 goto fail; 217 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,219 0);218 rc = socket_port_add_core(socket_port, socket, 219 (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 220 220 if (rc != EOK) 221 221 goto fail; … … 602 602 */ 603 603 socket_core_t * 604 socket_port_find(socket_ports_t *global_sockets, int port, const char*key,604 socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key, 605 605 size_t key_length) 606 606 { … … 680 680 int 681 681 socket_port_add(socket_ports_t *global_sockets, int port, 682 socket_core_t *socket, const char*key, size_t key_length)682 socket_core_t *socket, const uint8_t *key, size_t key_length) 683 683 { 684 684 socket_port_t *socket_port; -
uspace/lib/packet/generic/packet_server.c
r863d45e r1ffa73b 322 322 int 323 323 packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 324 int *answer_count)324 size_t *answer_count) 325 325 { 326 326 packet_t *packet; … … 333 333 case NET_PACKET_CREATE_1: 334 334 packet = packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX, 335 IPC_GET_CONTENT( call), DEFAULT_SUFFIX);335 IPC_GET_CONTENT(*call), DEFAULT_SUFFIX); 336 336 if (!packet) 337 337 return ENOMEM; … … 343 343 case NET_PACKET_CREATE_4: 344 344 packet = packet_get_local( 345 ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN( call)) ?346 IPC_GET_ADDR_LEN( call) : DEFAULT_ADDR_LEN),347 DEFAULT_PREFIX + IPC_GET_PREFIX( call),348 IPC_GET_CONTENT( call),349 DEFAULT_SUFFIX + IPC_GET_SUFFIX( call));345 ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(*call)) ? 346 IPC_GET_ADDR_LEN(*call) : DEFAULT_ADDR_LEN), 347 DEFAULT_PREFIX + IPC_GET_PREFIX(*call), 348 IPC_GET_CONTENT(*call), 349 DEFAULT_SUFFIX + IPC_GET_SUFFIX(*call)); 350 350 if (!packet) 351 351 return ENOMEM; … … 356 356 357 357 case NET_PACKET_GET: 358 packet = pm_find(IPC_GET_ID( call));358 packet = pm_find(IPC_GET_ID(*call)); 359 359 if (!packet_is_valid(packet)) 360 360 return ENOENT; … … 362 362 363 363 case NET_PACKET_GET_SIZE: 364 packet = pm_find(IPC_GET_ID( call));364 packet = pm_find(IPC_GET_ID(*call)); 365 365 if (!packet_is_valid(packet)) 366 366 return ENOENT; … … 370 370 371 371 case NET_PACKET_RELEASE: 372 return packet_release_wrapper(IPC_GET_ID( call));372 return packet_release_wrapper(IPC_GET_ID(*call)); 373 373 } 374 374 -
uspace/lib/packet/include/packet_server.h
r863d45e r1ffa73b 48 48 49 49 extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, 50 int *);50 size_t *); 51 51 52 52 #endif
Note:
See TracChangeset
for help on using the changeset viewer.