Changeset cfb79747 in mainline for uspace/lib/nic/src/nic_impl.c


Ignore:
Timestamp:
2012-02-14T22:06:15Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a31aad1
Parents:
199112e4 (diff), e10d41a (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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r199112e4 rcfb79747  
    3636 */
    3737
     38#include <errno.h>
    3839#include <str_error.h>
    3940#include <ipc/services.h>
    4041#include <ns.h>
    4142#include "nic_driver.h"
     43#include "nic_ev.h"
    4244#include "nic_impl.h"
    4345
     
    8587        }
    8688        if (state == NIC_STATE_ACTIVE) {
    87                 if (nic_data->nil_session == NULL || nic_data->net_session == NULL
    88                     || nic_data->device_id < 0) {
     89                if (nic_data->client_session == NULL) {
    8990                        fibril_rwlock_write_unlock(&nic_data->main_lock);
    9091                        return EINVAL;
     
    116117        if (state == NIC_STATE_STOPPED) {
    117118                /* Notify upper layers that we are reseting the MAC */
    118                 int rc = nil_addr_changed_msg(nic_data->nil_session,
    119                         nic_data->device_id, &nic_data->default_mac);
     119                int rc = nic_ev_addr_changed(nic_data->client_session,
     120                        &nic_data->default_mac);
    120121                nic_data->poll_mode = nic_data->default_poll_mode;
    121122                memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
     
    149150        nic_data->state = state;
    150151
    151         nil_device_state_msg(nic_data->nil_session, nic_data->device_id, state);
     152        nic_ev_device_state(nic_data->client_session, state);
    152153
    153154        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    182183
    183184/**
    184  * Default implementation of the connect_to_nil method.
    185  * Connects the driver to the NIL service.
     185 * Default implementation of the connect_client method.
     186 * Creates callback connection to the client.
    186187 *
    187188 * @param       fun
    188  * @param       nil_service     ID of the server implementing the NIL service
    189  * @param       device_id       ID of the device as used in higher layers
    190  *
    191  * @return EOK          If the services were bound
    192  * @return                      Negative error code from service_connect_blocking
    193  */
    194 int nic_connect_to_nil_impl(ddf_fun_t *fun, services_t nil_service,
    195     nic_device_id_t device_id)
    196 {
    197         nic_t *nic_data = (nic_t *) fun->driver_data;
    198         fibril_rwlock_write_lock(&nic_data->main_lock);
     189 *
     190 * @return EOK          On success, or negative error code.
     191 */
     192int nic_callback_create_impl(ddf_fun_t *fun)
     193{
     194        nic_t *nic = (nic_t *) fun->driver_data;
     195        fibril_rwlock_write_lock(&nic->main_lock);
    199196       
    200         nic_data->device_id = device_id;
     197        nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE);
     198        if (nic->client_session == NULL) {
     199                fibril_rwlock_write_unlock(&nic->main_lock);
     200                return ENOMEM;
     201        }
    201202       
    202         nic_data->nil_session = service_connect_blocking(EXCHANGE_SERIALIZE,
    203             nil_service, 0, 0);
    204         if (nic_data->nil_session != NULL) {
    205                 fibril_rwlock_write_unlock(&nic_data->main_lock);
    206                 return EOK;
    207         }
    208        
    209         fibril_rwlock_write_unlock(&nic_data->main_lock);
    210         return EHANGUP;
     203        fibril_rwlock_write_unlock(&nic->main_lock);
     204        return EOK;
    211205}
    212206
     
    805799}
    806800
    807 /** Default implementation of the device_added method
    808  *
    809  * Just calls nic_ready.
    810  *
    811  * @param dev
    812  *
    813  */
    814 void nic_device_added_impl(ddf_dev_t *dev)
    815 {
    816         nic_ready((nic_t *) dev->driver_data);
    817 }
    818 
    819801/**
    820802 * Default handler for unknown methods (outside of the NIC interface).
Note: See TracChangeset for help on using the changeset viewer.