Ignore:
File:
1 edited

Legend:

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

    r9cd8165 r6d8455d  
    3636 */
    3737
    38 #include <errno.h>
    3938#include <str_error.h>
    4039#include <ipc/services.h>
    4140#include <ns.h>
    4241#include "nic_driver.h"
    43 #include "nic_ev.h"
    4442#include "nic_impl.h"
    4543
     
    8785        }
    8886        if (state == NIC_STATE_ACTIVE) {
    89                 if (nic_data->client_session == NULL) {
     87                if (nic_data->nil_session == NULL || nic_data->net_session == NULL
     88                    || nic_data->device_id < 0) {
    9089                        fibril_rwlock_write_unlock(&nic_data->main_lock);
    9190                        return EINVAL;
     
    117116        if (state == NIC_STATE_STOPPED) {
    118117                /* Notify upper layers that we are reseting the MAC */
    119                 int rc = nic_ev_addr_changed(nic_data->client_session,
    120                         &nic_data->default_mac);
     118                int rc = nil_addr_changed_msg(nic_data->nil_session,
     119                        nic_data->device_id, &nic_data->default_mac);
    121120                nic_data->poll_mode = nic_data->default_poll_mode;
    122121                memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
     
    150149        nic_data->state = state;
    151150
    152         nic_ev_device_state(nic_data->client_session, state);
     151        nil_device_state_msg(nic_data->nil_session, nic_data->device_id, state);
    153152
    154153        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    183182
    184183/**
    185  * Default implementation of the connect_client method.
    186  * Creates callback connection to the client.
     184 * Default implementation of the connect_to_nil method.
     185 * Connects the driver to the NIL service.
    187186 *
    188187 * @param       fun
    189  *
    190  * @return EOK          On success, or negative error code.
    191  */
    192 int 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);
     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 */
     194int 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);
    196199       
    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         }
     200        nic_data->device_id = device_id;
    202201       
    203         fibril_rwlock_write_unlock(&nic->main_lock);
    204         return EOK;
     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;
    205211}
    206212
     
    799805}
    800806
     807/** Default implementation of the device_added method
     808 *
     809 * Just calls nic_ready.
     810 *
     811 * @param dev
     812 *
     813 */
     814void nic_device_added_impl(ddf_dev_t *dev)
     815{
     816        nic_ready((nic_t *) dev->driver_data);
     817}
     818
    801819/**
    802820 * Default handler for unknown methods (outside of the NIC interface).
Note: See TracChangeset for help on using the changeset viewer.