Changeset 8d7ec69d in mainline for uspace/lib/c


Ignore:
Timestamp:
2012-01-22T10:40:07Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c38e417, cf9cb36
Parents:
e98fe28c
Message:

NIC should talk to its client via a callback connection with NIC-defined
protocol (was using nil, was connecting via NS).

Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/nic.c

    re98fe28c r8d7ec69d  
    7373}
    7474
    75 /** Connect the driver to the NET and NIL services
    76  *
    77  * @param[in] dev_sess
    78  * @param[in] nil_service Service identifier for the NIL service
     75/** Create callback connection from NIC service
     76 *
     77 * @param[in] dev_sess
    7978 * @param[in] device_id
    8079 *
     
    8281 *
    8382 */
    84 int nic_connect_to_nil(async_sess_t *dev_sess, services_t nil_service,
    85     nic_device_id_t device_id)
    86 {
    87         async_exch_t *exch = async_exchange_begin(dev_sess);
    88         int rc = async_req_3_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    89             NIC_CONNECT_TO_NIL, nil_service, device_id);
    90         async_exchange_end(exch);
    91        
    92         return rc;
     83int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id,
     84    async_client_conn_t cfun, void *carg)
     85{
     86        ipc_call_t answer;
     87        int rc;
     88        sysarg_t retval;
     89       
     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);
     93       
     94        rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
     95        if (rc != EOK) {
     96                async_wait_for(req, NULL);
     97                return rc;
     98        }
     99        async_exchange_end(exch);
     100       
     101        async_wait_for(req, &retval);
     102        return (int) retval;
    93103}
    94104
  • uspace/lib/c/include/device/nic.h

    re98fe28c r8d7ec69d  
    3939#include <net/device.h>
    4040#include <net/packet.h>
     41#include <ipc/common.h>
    4142#include <ipc/services.h>
    4243
    4344typedef enum {
    4445        NIC_SEND_MESSAGE = 0,
    45         NIC_CONNECT_TO_NIL,
     46        NIC_CALLBACK_CREATE,
    4647        NIC_GET_STATE,
    4748        NIC_SET_STATE,
     
    8586} nic_funcs_t;
    8687
     88typedef enum {
     89        NIC_EV_ADDR_CHANGED = IPC_FIRST_USER_METHOD,
     90        NIC_EV_RECEIVED,
     91        NIC_EV_DEVICE_STATE
     92} nic_event_t;
     93
    8794extern int nic_send_frame(async_sess_t *, void *, size_t);
    88 extern int nic_connect_to_nil(async_sess_t *, services_t, nic_device_id_t);
     95extern int nic_callback_create(async_sess_t *, nic_device_id_t,
     96    async_client_conn_t, void *);
    8997extern int nic_get_state(async_sess_t *, nic_device_state_t *);
    9098extern int nic_set_state(async_sess_t *, nic_device_state_t);
  • uspace/lib/c/include/ipc/nil.h

    re98fe28c r8d7ec69d  
    4646         */
    4747        NET_NIL_DEVICE = NET_NIL_FIRST,
    48         /** New device state message.
    49          * @see nil_device_state_msg()
    50          */
    51         NET_NIL_DEVICE_STATE,
    52         /** Received packet queue message.
    53          * @see nil_received_msg()
    54          */
    55         NET_NIL_RECEIVED,
    5648        /** Send packet queue message.
    5749         * @see nil_send_msg()
     
    6961         * @see nil_get_broadcast_addr()
    7062         */
    71         NET_NIL_BROADCAST_ADDR,
    72         /** Device has changed address
    73          * @see nil_addr_changed_msg()
    74          */
    75         NET_NIL_ADDR_CHANGED
     63        NET_NIL_BROADCAST_ADDR
    7664} nil_messages;
    7765
Note: See TracChangeset for help on using the changeset viewer.