Changeset 8da2c60 in mainline for uspace/lib
- Timestamp:
- 2012-01-27T19:12:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fe56c08a
- Parents:
- ea75ceb (diff), d81eaf94 (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:
-
- 12 edited
-
c/generic/device/nic.c (modified) (2 diffs)
-
c/include/device/nic.h (modified) (1 diff)
-
c/include/net/device.h (modified) (1 diff)
-
c/include/nic/nic.h (modified) (2 diffs)
-
drv/generic/remote_nic.c (modified) (1 diff)
-
drv/include/ops/nic.h (modified) (1 diff)
-
nic/include/nic_driver.h (modified) (1 diff)
-
nic/include/nic_ev.h (modified) (1 diff)
-
nic/include/nic_impl.h (modified) (1 diff)
-
nic/src/nic_driver.c (modified) (4 diffs)
-
nic/src/nic_ev.c (modified) (3 diffs)
-
nic/src/nic_impl.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/device/nic.c
rea75ceb r8da2c60 81 81 * 82 82 */ 83 int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id,84 async_client_conn_t cfun,void *carg)83 int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun, 84 void *carg) 85 85 { 86 86 ipc_call_t answer; … … 89 89 90 90 async_exch_t *exch = async_exchange_begin(dev_sess); 91 aid_t req = async_send_ 2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),92 NIC_CALLBACK_CREATE, device_id,&answer);91 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 92 NIC_CALLBACK_CREATE, &answer); 93 93 94 94 rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg); -
uspace/lib/c/include/device/nic.h
rea75ceb r8da2c60 91 91 92 92 extern int nic_send_frame(async_sess_t *, void *, size_t); 93 extern int nic_callback_create(async_sess_t *, nic_device_id_t, 94 async_client_conn_t, void *); 93 extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *); 95 94 extern int nic_get_state(async_sess_t *, nic_device_state_t *); 96 95 extern int nic_set_state(async_sess_t *, nic_device_state_t); -
uspace/lib/c/include/net/device.h
rea75ceb r8da2c60 47 47 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 48 48 49 /** Device identifier type. */ 50 typedef int nic_device_id_t; 51 52 /** Invalid device identifier. */ 53 #define NIC_DEVICE_INVALID_ID (-1) 54 49 55 #endif 50 56 -
uspace/lib/c/include/nic/nic.h
rea75ceb r8da2c60 63 63 #define NIC_MAX_ADDRESS_LENGTH 16 64 64 65 /** Invalid device identifier. */66 #define NIC_DEVICE_INVALID_ID (-1)67 68 65 #define NIC_VENDOR_MAX_LENGTH 64 69 66 #define NIC_MODEL_MAX_LENGTH 64 … … 86 83 87 84 #define NIC_DEVICE_PRINT_FMT "%x" 88 89 /** Device identifier type. */90 typedef int nic_device_id_t;91 85 92 86 /** -
uspace/lib/drv/generic/remote_nic.c
rea75ceb r8da2c60 69 69 assert(nic_iface->callback_create); 70 70 71 nic_device_id_t device_id = (nic_device_id_t) IPC_GET_ARG2(*call); 72 73 int rc = nic_iface->callback_create(dev, device_id); 71 int rc = nic_iface->callback_create(dev); 74 72 async_answer_0(callid, rc); 75 73 } -
uspace/lib/drv/include/ops/nic.h
rea75ceb r8da2c60 46 46 /** Mandatory methods */ 47 47 int (*send_frame)(ddf_fun_t *, void *, size_t); 48 int (*callback_create)(ddf_fun_t * , nic_device_id_t);48 int (*callback_create)(ddf_fun_t *); 49 49 int (*get_state)(ddf_fun_t *, nic_device_state_t *); 50 50 int (*set_state)(ddf_fun_t *, nic_device_state_t); -
uspace/lib/nic/include/nic_driver.h
rea75ceb r8da2c60 70 70 */ 71 71 ddf_fun_t *fun; 72 /** Identifier for higher network stack layers */73 nic_device_id_t device_id;74 72 /** Current state of the device */ 75 73 nic_device_state_t state; -
uspace/lib/nic/include/nic_ev.h
rea75ceb r8da2c60 43 43 #include <sys/types.h> 44 44 45 extern int nic_ev_addr_changed(async_sess_t *, nic_device_id_t, 46 const nic_address_t *); 47 extern int nic_ev_device_state(async_sess_t *, nic_device_id_t, sysarg_t); 48 extern int nic_ev_received(async_sess_t *, nic_device_id_t, void *, size_t); 45 extern int nic_ev_addr_changed(async_sess_t *, const nic_address_t *); 46 extern int nic_ev_device_state(async_sess_t *, sysarg_t); 47 extern int nic_ev_received(async_sess_t *, void *, size_t); 49 48 50 49 #endif -
uspace/lib/nic/include/nic_impl.h
rea75ceb r8da2c60 48 48 extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address); 49 49 extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size); 50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun , int device_id);50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun); 51 51 extern int nic_get_state_impl(ddf_fun_t *dev_fun, nic_device_state_t *state); 52 52 extern int nic_set_state_impl(ddf_fun_t *dev_fun, nic_device_state_t state); -
uspace/lib/nic/src/nic_driver.c
rea75ceb r8da2c60 497 497 if (nic_data->client_session != NULL) { 498 498 int rc = nic_ev_addr_changed(nic_data->client_session, 499 nic_data->device_id,address);499 address); 500 500 if (rc != EOK) { 501 501 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 604 604 } 605 605 fibril_rwlock_write_unlock(&nic_data->stats_lock); 606 nic_ev_received(nic_data->client_session, nic_data->device_id,607 frame-> data, frame->size);606 nic_ev_received(nic_data->client_session, frame->data, 607 frame->size); 608 608 } else { 609 609 switch (frame_type) { … … 639 639 fibril_rwlock_write_unlock(&nic_data->stats_lock); 640 640 641 nic_ev_received(nic_data->client_session, nic_data->device_id, 642 data, size); 641 nic_ev_received(nic_data->client_session, data, size); 643 642 } 644 643 … … 691 690 nic_data->dev = NULL; 692 691 nic_data->fun = NULL; 693 nic_data->device_id = NIC_DEVICE_INVALID_ID;694 692 nic_data->state = NIC_STATE_STOPPED; 695 693 nic_data->client_session = NULL; -
uspace/lib/nic/src/nic_ev.c
rea75ceb r8da2c60 42 42 43 43 /** Device address changed. */ 44 int nic_ev_addr_changed(async_sess_t *sess, nic_device_id_t dev_id, 45 const nic_address_t *addr) 44 int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr) 46 45 { 47 46 async_exch_t *exch = async_exchange_begin(sess); 48 47 49 48 ipc_call_t answer; 50 aid_t req = async_send_1(exch, NIC_EV_ADDR_CHANGED, (sysarg_t) dev_id, 51 &answer); 49 aid_t req = async_send_0(exch, NIC_EV_ADDR_CHANGED, &answer); 52 50 sysarg_t retval = async_data_write_start(exch, addr, 53 51 sizeof(nic_address_t)); … … 65 63 66 64 /** Device state changed. */ 67 extern int nic_ev_device_state(async_sess_t *sess, nic_device_id_t dev_id, 68 sysarg_t state) 65 extern int nic_ev_device_state(async_sess_t *sess, sysarg_t state) 69 66 { 70 67 int rc; 71 68 72 69 async_exch_t *exch = async_exchange_begin(sess); 73 rc = async_req_ 2_0(exch, NIC_EV_DEVICE_STATE, dev_id, state);70 rc = async_req_1_0(exch, NIC_EV_DEVICE_STATE, state); 74 71 async_exchange_end(exch); 75 72 … … 78 75 79 76 /** Frame received. */ 80 int nic_ev_received(async_sess_t *sess, nic_device_id_t dev_id, void *data, 81 size_t size) 77 int nic_ev_received(async_sess_t *sess, void *data, size_t size) 82 78 { 83 79 async_exch_t *exch = async_exchange_begin(sess); 84 80 85 81 ipc_call_t answer; 86 aid_t req = async_send_1(exch, NIC_EV_RECEIVED, (sysarg_t) dev_id, 87 &answer); 82 aid_t req = async_send_0(exch, NIC_EV_RECEIVED, &answer); 88 83 sysarg_t retval = async_data_write_start(exch, data, size); 89 84 -
uspace/lib/nic/src/nic_impl.c
rea75ceb r8da2c60 87 87 } 88 88 if (state == NIC_STATE_ACTIVE) { 89 if (nic_data->client_session == NULL || nic_data->device_id < 0) {89 if (nic_data->client_session == NULL) { 90 90 fibril_rwlock_write_unlock(&nic_data->main_lock); 91 91 return EINVAL; … … 118 118 /* Notify upper layers that we are reseting the MAC */ 119 119 int rc = nic_ev_addr_changed(nic_data->client_session, 120 nic_data->device_id,&nic_data->default_mac);120 &nic_data->default_mac); 121 121 nic_data->poll_mode = nic_data->default_poll_mode; 122 122 memcpy(&nic_data->poll_period, &nic_data->default_poll_period, … … 150 150 nic_data->state = state; 151 151 152 nic_ev_device_state(nic_data->client_session, nic_data->device_id,state);152 nic_ev_device_state(nic_data->client_session, state); 153 153 154 154 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 187 187 * 188 188 * @param fun 189 * @param device_id ID of the device as used in higher layers190 189 * 191 190 * @return EOK On success, or negative error code. 192 191 */ 193 int nic_callback_create_impl(ddf_fun_t *fun , nic_device_id_t device_id)192 int nic_callback_create_impl(ddf_fun_t *fun) 194 193 { 195 194 nic_t *nic = (nic_t *) fun->driver_data; 196 195 fibril_rwlock_write_lock(&nic->main_lock); 197 198 nic->device_id = device_id;199 196 200 197 nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE);
Note:
See TracChangeset
for help on using the changeset viewer.
