Changeset 8989f2a7 in mainline for uspace/lib
- Timestamp:
- 2012-01-15T10:38:46Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 121e7adf
- Parents:
- 9957a97 (diff), f302586 (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:
-
- 15 edited
-
c/generic/async.c (modified) (3 diffs)
-
c/generic/device/nic.c (modified) (1 diff)
-
c/generic/devman.c (modified) (2 diffs)
-
c/generic/loc.c (modified) (2 diffs)
-
c/include/device/nic.h (modified) (1 diff)
-
c/include/devman.h (modified) (1 diff)
-
c/include/loc.h (modified) (1 diff)
-
drv/generic/driver.c (modified) (1 diff)
-
drv/generic/remote_nic.c (modified) (2 diffs)
-
drv/include/ops/nic.h (modified) (2 diffs)
-
nic/include/nic.h (modified) (2 diffs)
-
nic/include/nic_driver.h (modified) (1 diff)
-
nic/include/nic_impl.h (modified) (1 diff)
-
nic/src/nic_driver.c (modified) (3 diffs)
-
nic/src/nic_impl.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r9957a97 r8989f2a7 257 257 void async_set_client_data_constructor(async_client_data_ctor_t ctor) 258 258 { 259 assert(async_client_data_create == default_client_data_constructor); 259 260 async_client_data_create = ctor; 260 261 } … … 262 263 void async_set_client_data_destructor(async_client_data_dtor_t dtor) 263 264 { 265 assert(async_client_data_destroy == default_client_data_destructor); 264 266 async_client_data_destroy = dtor; 265 267 } … … 303 305 void async_set_client_connection(async_client_conn_t conn) 304 306 { 307 assert(client_connection == default_client_connection); 305 308 client_connection = conn; 306 309 } -
uspace/lib/c/generic/device/nic.c
r9957a97 r8989f2a7 44 44 #include <ipc/services.h> 45 45 46 /** Send a packet through the device 47 * 48 * @param[in] dev_sess 49 * @param[in] packet_id Id of the sent packet 50 * 51 * @return EOK If the operation was successfully completed 52 * 53 */ 54 int nic_send_message(async_sess_t *dev_sess, packet_id_t packet_id) 55 { 56 async_exch_t *exch = async_exchange_begin(dev_sess); 57 int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 58 NIC_SEND_MESSAGE, packet_id); 59 async_exchange_end(exch); 60 61 return rc; 46 /** Send frame from NIC 47 * 48 * @param[in] dev_sess 49 * @param[in] data Frame data 50 * @param[in] size Frame size in bytes 51 * 52 * @return EOK If the operation was successfully completed 53 * 54 */ 55 int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size) 56 { 57 async_exch_t *exch = async_exchange_begin(dev_sess); 58 59 ipc_call_t answer; 60 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 61 NIC_SEND_MESSAGE, &answer); 62 sysarg_t retval = async_data_write_start(exch, data, size); 63 64 async_exchange_end(exch); 65 66 if (retval != EOK) { 67 async_wait_for(req, NULL); 68 return retval; 69 } 70 71 async_wait_for(req, &retval); 72 return retval; 62 73 } 63 74 -
uspace/lib/c/generic/devman.c
r9957a97 r8989f2a7 177 177 178 178 /** Register running driver with device manager. */ 179 int devman_driver_register(const char *name , async_client_conn_t conn)179 int devman_driver_register(const char *name) 180 180 { 181 181 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER); … … 192 192 } 193 193 194 async_set_client_connection(conn);195 196 194 exch = devman_exchange_begin(DEVMAN_DRIVER); 197 async_connect_to_me(exch, 0, 0, 0, conn, NULL);195 async_connect_to_me(exch, 0, 0, 0, NULL, NULL); 198 196 devman_exchange_end(exch); 199 197 -
uspace/lib/c/generic/loc.c
r9957a97 r8989f2a7 242 242 243 243 /** Register new driver with loc. */ 244 int loc_server_register(const char *name , async_client_conn_t conn)244 int loc_server_register(const char *name) 245 245 { 246 246 async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER); … … 256 256 return retval; 257 257 } 258 259 async_set_client_connection(conn);260 258 261 259 exch = loc_exchange_begin(LOC_PORT_SUPPLIER); -
uspace/lib/c/include/device/nic.h
r9957a97 r8989f2a7 85 85 } nic_funcs_t; 86 86 87 extern int nic_send_ message(async_sess_t *, packet_id_t);87 extern int nic_send_frame(async_sess_t *, void *, size_t); 88 88 extern int nic_connect_to_nil(async_sess_t *, services_t, nic_device_id_t); 89 89 extern int nic_get_state(async_sess_t *, nic_device_state_t *); -
uspace/lib/c/include/devman.h
r9957a97 r8989f2a7 46 46 extern void devman_exchange_end(async_exch_t *); 47 47 48 extern int devman_driver_register(const char * , async_client_conn_t);48 extern int devman_driver_register(const char *); 49 49 extern int devman_add_function(const char *, fun_type_t, match_id_list_t *, 50 50 devman_handle_t, devman_handle_t *); -
uspace/lib/c/include/loc.h
r9957a97 r8989f2a7 46 46 extern void loc_exchange_end(async_exch_t *); 47 47 48 extern int loc_server_register(const char * , async_client_conn_t);48 extern int loc_server_register(const char *); 49 49 extern int loc_service_register(const char *, service_id_t *); 50 50 extern int loc_service_register_with_iface(const char *, service_id_t *, -
uspace/lib/drv/generic/driver.c
r9957a97 r8989f2a7 1016 1016 * incoming connections. 1017 1017 */ 1018 rc = devman_driver_register(driver->name, driver_connection); 1018 async_set_client_connection(driver_connection); 1019 rc = devman_driver_register(driver->name); 1019 1020 if (rc != EOK) { 1020 1021 printf("Error: Failed to register driver with device manager " -
uspace/lib/drv/generic/remote_nic.c
r9957a97 r8989f2a7 39 39 #include <errno.h> 40 40 #include <ipc/services.h> 41 #include <adt/measured_strings.h>42 41 #include <sys/time.h> 43 42 #include "ops/nic.h" 44 43 45 static void remote_nic_send_message(ddf_fun_t *dev, void *iface, 46 ipc_callid_t callid, ipc_call_t *call) 47 { 48 nic_iface_t *nic_iface = (nic_iface_t *) iface; 49 assert(nic_iface->send_message); 50 51 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); 52 53 int rc = nic_iface->send_message(dev, packet_id); 54 async_answer_0(callid, rc); 44 static void remote_nic_send_frame(ddf_fun_t *dev, void *iface, 45 ipc_callid_t callid, ipc_call_t *call) 46 { 47 nic_iface_t *nic_iface = (nic_iface_t *) iface; 48 assert(nic_iface->send_frame); 49 50 void *data; 51 size_t size; 52 int rc; 53 54 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 55 if (rc != EOK) { 56 async_answer_0(callid, EINVAL); 57 return; 58 } 59 60 rc = nic_iface->send_frame(dev, data, size); 61 async_answer_0(callid, rc); 62 free(data); 55 63 } 56 64 … … 1194 1202 */ 1195 1203 static remote_iface_func_ptr_t remote_nic_iface_ops[] = { 1196 &remote_nic_send_ message,1204 &remote_nic_send_frame, 1197 1205 &remote_nic_connect_to_nil, 1198 1206 &remote_nic_get_state, -
uspace/lib/drv/include/ops/nic.h
r9957a97 r8989f2a7 37 37 #define LIBDRV_OPS_NIC_H_ 38 38 39 #include <net/packet.h>40 39 #include <ipc/services.h> 41 40 #include <net/device.h> … … 46 45 typedef struct nic_iface { 47 46 /** Mandatory methods */ 48 int (*send_ message)(ddf_fun_t *, packet_id_t);47 int (*send_frame)(ddf_fun_t *, void *, size_t); 49 48 int (*connect_to_nil)(ddf_fun_t *, services_t, nic_device_id_t); 50 49 int (*get_state)(ddf_fun_t *, nic_device_state_t *); -
uspace/lib/nic/include/nic.h
r9957a97 r8989f2a7 77 77 * 78 78 * @param nic_data 79 * @param packet Pointer to the packet to be sent 80 */ 81 typedef void (*write_packet_handler)(nic_t *, packet_t *); 79 * @param data Pointer to frame data 80 * @param size Size of frame data in bytes 81 */ 82 typedef void (*send_frame_handler)(nic_t *, void *, size_t); 82 83 /** 83 84 * The handler for transitions between driver states. … … 206 207 extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *); 207 208 extern void nic_set_specific(nic_t *, void *); 208 extern void nic_set_ write_packet_handler(nic_t *, write_packet_handler);209 extern void nic_set_send_frame_handler(nic_t *, send_frame_handler); 209 210 extern void nic_set_state_change_handlers(nic_t *, 210 211 state_change_handler, state_change_handler, state_change_handler); -
uspace/lib/nic/include/nic_driver.h
r9957a97 r8989f2a7 134 134 * Called with the main_lock locked for reading. 135 135 */ 136 write_packet_handler write_packet;136 send_frame_handler send_frame; 137 137 /** 138 138 * Event handler called when device goes to the ACTIVE state. -
uspace/lib/nic/include/nic_impl.h
r9957a97 r8989f2a7 48 48 49 49 extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address); 50 extern int nic_send_ message_impl(ddf_fun_t *dev_fun, packet_id_t packet_id);50 extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size); 51 51 extern int nic_connect_to_nil_impl(ddf_fun_t *dev_fun, services_t nil_service, 52 52 int device_id); -
uspace/lib/nic/src/nic_driver.c
r9957a97 r8989f2a7 114 114 if (!iface->set_state) 115 115 iface->set_state = nic_set_state_impl; 116 if (!iface->send_ message)117 iface->send_ message = nic_send_message_impl;116 if (!iface->send_frame) 117 iface->send_frame = nic_send_frame_impl; 118 118 if (!iface->connect_to_nil) 119 119 iface->connect_to_nil = nic_connect_to_nil_impl; … … 168 168 * 169 169 * @param nic_data 170 * @param wpfunc Function handling the write_packetrequest171 */ 172 void nic_set_ write_packet_handler(nic_t *nic_data, write_packet_handler wpfunc)173 { 174 nic_data-> write_packet = wpfunc;170 * @param sffunc Function handling the send_frame request 171 */ 172 void nic_set_send_frame_handler(nic_t *nic_data, send_frame_handler sffunc) 173 { 174 nic_data->send_frame = sffunc; 175 175 } 176 176 … … 765 765 nic_data->poll_mode = NIC_POLL_IMMEDIATE; 766 766 nic_data->default_poll_mode = NIC_POLL_IMMEDIATE; 767 nic_data-> write_packet= NULL;767 nic_data->send_frame = NULL; 768 768 nic_data->on_activating = NULL; 769 769 nic_data->on_going_down = NULL; -
uspace/lib/nic/src/nic_impl.c
r9957a97 r8989f2a7 39 39 #include <ipc/services.h> 40 40 #include <ns.h> 41 #include <packet_client.h>42 #include <packet_remote.h>43 41 #include "nic_driver.h" 44 42 #include "nic_impl.h" … … 159 157 160 158 /** 161 * Default implementation of the send_ message method.159 * Default implementation of the send_frame method. 162 160 * Send messages to the network. 163 161 * 164 162 * @param fun 165 * @param packet_id ID of the first packet in a queue of sent packets 163 * @param data Frame data 164 * @param size Frame size in bytes 166 165 * 167 166 * @return EOK If the message was sent 168 * @return EBUSY If the device is not in state when the packet can be set. 169 * @return EINVAL If the packet ID is invalid 170 */ 171 int nic_send_message_impl(ddf_fun_t *fun, packet_id_t packet_id) 172 { 173 nic_t *nic_data = (nic_t *) fun->driver_data; 174 packet_t *packet, *next; 167 * @return EBUSY If the device is not in state when the frame can be sent. 168 */ 169 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size) 170 { 171 nic_t *nic_data = (nic_t *) fun->driver_data; 175 172 176 173 fibril_rwlock_read_lock(&nic_data->main_lock); 177 174 if (nic_data->state != NIC_STATE_ACTIVE || nic_data->tx_busy) { 178 175 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 pq_release_remote(nic_data->net_session, packet_id);180 176 return EBUSY; 181 177 } 182 178 183 int rc = packet_translate_remote(nic_data->net_session, &packet, packet_id); 184 185 if (rc != EOK) { 186 fibril_rwlock_read_unlock(&nic_data->main_lock); 187 return EINVAL; 188 } 189 190 /* 191 * Process the packet queue. Each sent packet must be detached from the 192 * queue and destroyed. This is why the cycle differs from loopback's 193 * cycle, where the packets are immediately used in upper layers and 194 * therefore they must not be destroyed (released). 195 */ 196 assert(nic_data->write_packet != NULL); 197 do { 198 next = pq_detach(packet); 199 nic_data->write_packet(nic_data, packet); 200 packet = next; 201 } while (packet); 202 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 nic_data->send_frame(nic_data, data, size); 203 180 return EOK; 204 181 }
Note:
See TracChangeset
for help on using the changeset viewer.
