Changeset 8d7ec69d in mainline for uspace/lib/nic/src/nic_impl.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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_impl.c

    re98fe28c r8d7ec69d  
    4040#include <ns.h>
    4141#include "nic_driver.h"
     42#include "nic_ev.h"
    4243#include "nic_impl.h"
    4344
     
    8586        }
    8687        if (state == NIC_STATE_ACTIVE) {
    87                 if (nic_data->nil_session == NULL || nic_data->device_id < 0) {
     88                if (nic_data->client_session == NULL || nic_data->device_id < 0) {
    8889                        fibril_rwlock_write_unlock(&nic_data->main_lock);
    8990                        return EINVAL;
     
    115116        if (state == NIC_STATE_STOPPED) {
    116117                /* Notify upper layers that we are reseting the MAC */
    117                 int rc = nil_addr_changed_msg(nic_data->nil_session,
     118                int rc = nic_ev_addr_changed(nic_data->client_session,
    118119                        nic_data->device_id, &nic_data->default_mac);
    119120                nic_data->poll_mode = nic_data->default_poll_mode;
     
    148149        nic_data->state = state;
    149150
    150         nil_device_state_msg(nic_data->nil_session, nic_data->device_id, state);
     151        nic_ev_device_state(nic_data->client_session, nic_data->device_id, state);
    151152
    152153        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    181182
    182183/**
    183  * Default implementation of the connect_to_nil method.
    184  * Connects the driver to the NIL service.
     184 * Default implementation of the connect_client method.
     185 * Creates callback connection to the client.
    185186 *
    186187 * @param       fun
    187  * @param       nil_service     ID of the server implementing the NIL service
    188188 * @param       device_id       ID of the device as used in higher layers
    189189 *
    190  * @return EOK          If the services were bound
    191  * @return                      Negative error code from service_connect_blocking
    192  */
    193 int nic_connect_to_nil_impl(ddf_fun_t *fun, services_t nil_service,
    194     nic_device_id_t device_id)
    195 {
    196         nic_t *nic_data = (nic_t *) fun->driver_data;
    197         fibril_rwlock_write_lock(&nic_data->main_lock);
     190 * @return EOK          On success, or negative error code.
     191 */
     192int nic_callback_create_impl(ddf_fun_t *fun, nic_device_id_t device_id)
     193{
     194        nic_t *nic = (nic_t *) fun->driver_data;
     195        fibril_rwlock_write_lock(&nic->main_lock);
    198196       
    199         nic_data->device_id = device_id;
     197        nic->device_id = device_id;
    200198       
    201         nic_data->nil_session = service_connect_blocking(EXCHANGE_SERIALIZE,
    202             nil_service, 0, 0);
    203         if (nic_data->nil_session != NULL) {
    204                 fibril_rwlock_write_unlock(&nic_data->main_lock);
    205                 return EOK;
     199        nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE);
     200        if (nic->client_session == NULL) {
     201                fibril_rwlock_write_unlock(&nic->main_lock);
     202                return ENOMEM;
    206203        }
    207204       
    208         fibril_rwlock_write_unlock(&nic_data->main_lock);
    209         return EHANGUP;
     205        fibril_rwlock_write_unlock(&nic->main_lock);
     206        return EOK;
    210207}
    211208
Note: See TracChangeset for help on using the changeset viewer.