[80099c19] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Martin Decky
|
---|
| 3 | * Copyright (c) 2011 Radim Vansa
|
---|
| 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * @addtogroup drv_ne2k
|
---|
| 32 | * @brief Novell NE2000 NIC driver
|
---|
| 33 | * @{
|
---|
| 34 | */
|
---|
| 35 | /**
|
---|
| 36 | * @file
|
---|
| 37 | * @brief Bridge between NICF, DDF and business logic for the NIC
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | #include <stdio.h>
|
---|
| 41 | #include <errno.h>
|
---|
[d51838f] | 42 | #include <device/hw_res.h>
|
---|
[80099c19] | 43 | #include <stdlib.h>
|
---|
| 44 | #include <str_error.h>
|
---|
| 45 | #include <async.h>
|
---|
| 46 | #include "dp8390.h"
|
---|
| 47 |
|
---|
| 48 | #define NAME "ne2k"
|
---|
| 49 |
|
---|
| 50 | /** Return the ISR from the interrupt call.
|
---|
| 51 | *
|
---|
| 52 | * @param[in] call The interrupt call.
|
---|
| 53 | *
|
---|
| 54 | */
|
---|
| 55 | #define IRQ_GET_ISR(call) ((int) IPC_GET_ARG2(call))
|
---|
| 56 |
|
---|
| 57 | /** Return the TSR from the interrupt call.
|
---|
| 58 | *
|
---|
| 59 | * @param[in] call The interrupt call.
|
---|
| 60 | *
|
---|
| 61 | */
|
---|
| 62 | #define IRQ_GET_TSR(call) ((int) IPC_GET_ARG3(call))
|
---|
| 63 |
|
---|
[56fd7cf] | 64 | #define DRIVER_DATA(dev) ((nic_t *) ddf_dev_data_get(dev))
|
---|
[80099c19] | 65 | #define NE2K(device) ((ne2k_t *) nic_get_specific(DRIVER_DATA(device)))
|
---|
| 66 |
|
---|
[9571230] | 67 | static irq_pio_range_t ne2k_ranges_prototype[] = {
|
---|
| 68 | {
|
---|
| 69 | .base = 0,
|
---|
| 70 | .size = NE2K_IO_SIZE,
|
---|
| 71 | }
|
---|
| 72 | };
|
---|
| 73 |
|
---|
[80099c19] | 74 | /** NE2000 kernel interrupt command sequence.
|
---|
| 75 | *
|
---|
| 76 | */
|
---|
| 77 | static irq_cmd_t ne2k_cmds_prototype[] = {
|
---|
| 78 | {
|
---|
| 79 | /* Read Interrupt Status Register */
|
---|
| 80 | .cmd = CMD_PIO_READ_8,
|
---|
| 81 | .addr = NULL,
|
---|
| 82 | .dstarg = 2
|
---|
| 83 | },
|
---|
| 84 | {
|
---|
| 85 | /* Mask supported interrupt causes */
|
---|
[8486c07] | 86 | .cmd = CMD_AND,
|
---|
[80099c19] | 87 | .value = (ISR_PRX | ISR_PTX | ISR_RXE | ISR_TXE | ISR_OVW |
|
---|
| 88 | ISR_CNT | ISR_RDC),
|
---|
| 89 | .srcarg = 2,
|
---|
| 90 | .dstarg = 3,
|
---|
| 91 | },
|
---|
| 92 | {
|
---|
| 93 | /* Predicate for accepting the interrupt */
|
---|
| 94 | .cmd = CMD_PREDICATE,
|
---|
| 95 | .value = 4,
|
---|
| 96 | .srcarg = 3
|
---|
| 97 | },
|
---|
| 98 | {
|
---|
| 99 | /*
|
---|
| 100 | * Mask future interrupts via
|
---|
| 101 | * Interrupt Mask Register
|
---|
| 102 | */
|
---|
| 103 | .cmd = CMD_PIO_WRITE_8,
|
---|
| 104 | .addr = NULL,
|
---|
| 105 | .value = 0
|
---|
| 106 | },
|
---|
| 107 | {
|
---|
| 108 | /* Acknowledge the current interrupt */
|
---|
| 109 | .cmd = CMD_PIO_WRITE_A_8,
|
---|
| 110 | .addr = NULL,
|
---|
| 111 | .srcarg = 3
|
---|
| 112 | },
|
---|
| 113 | {
|
---|
| 114 | /* Read Transmit Status Register */
|
---|
| 115 | .cmd = CMD_PIO_READ_8,
|
---|
| 116 | .addr = NULL,
|
---|
| 117 | .dstarg = 3
|
---|
| 118 | },
|
---|
| 119 | {
|
---|
| 120 | .cmd = CMD_ACCEPT
|
---|
| 121 | }
|
---|
| 122 | };
|
---|
| 123 |
|
---|
[01c3bb4] | 124 | static void ne2k_interrupt_handler(ipc_call_t *, ddf_dev_t *);
|
---|
[80099c19] | 125 |
|
---|
| 126 | static int ne2k_register_interrupt(nic_t *nic_data)
|
---|
| 127 | {
|
---|
| 128 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 129 |
|
---|
| 130 | if (ne2k->code.cmdcount == 0) {
|
---|
[9571230] | 131 | irq_pio_range_t *ne2k_ranges;
|
---|
| 132 | irq_cmd_t *ne2k_cmds;
|
---|
| 133 |
|
---|
| 134 | ne2k_ranges = malloc(sizeof(ne2k_ranges_prototype));
|
---|
| 135 | if (!ne2k_ranges)
|
---|
| 136 | return ENOMEM;
|
---|
| 137 | memcpy(ne2k_ranges, ne2k_ranges_prototype,
|
---|
| 138 | sizeof(ne2k_ranges_prototype));
|
---|
| 139 | ne2k_ranges[0].base = (uintptr_t) ne2k->base_port;
|
---|
| 140 |
|
---|
| 141 | ne2k_cmds = malloc(sizeof(ne2k_cmds_prototype));
|
---|
| 142 | if (!ne2k_cmds) {
|
---|
| 143 | free(ne2k_ranges);
|
---|
[80099c19] | 144 | return ENOMEM;
|
---|
| 145 | }
|
---|
[9571230] | 146 | memcpy(ne2k_cmds, ne2k_cmds_prototype,
|
---|
| 147 | sizeof(ne2k_cmds_prototype));
|
---|
| 148 | ne2k_cmds[0].addr = ne2k->base_port + DP_ISR;
|
---|
| 149 | ne2k_cmds[3].addr = ne2k->base_port + DP_IMR;
|
---|
[80099c19] | 150 | ne2k_cmds[4].addr = ne2k_cmds[0].addr;
|
---|
[9571230] | 151 | ne2k_cmds[5].addr = ne2k->base_port + DP_TSR;
|
---|
| 152 |
|
---|
| 153 | ne2k->code.rangecount = sizeof(ne2k_ranges_prototype) /
|
---|
| 154 | sizeof(irq_pio_range_t);
|
---|
| 155 | ne2k->code.ranges = ne2k_ranges;
|
---|
[80099c19] | 156 |
|
---|
[9571230] | 157 | ne2k->code.cmdcount = sizeof(ne2k_cmds_prototype) /
|
---|
| 158 | sizeof(irq_cmd_t);
|
---|
[80099c19] | 159 | ne2k->code.cmds = ne2k_cmds;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[e9d15d9] | 162 | int irq_cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
|
---|
[80099c19] | 163 | ne2k->irq, ne2k_interrupt_handler, &ne2k->code);
|
---|
[e9d15d9] | 164 | return irq_cap;
|
---|
[80099c19] | 165 | }
|
---|
| 166 |
|
---|
| 167 | static ddf_dev_ops_t ne2k_dev_ops;
|
---|
| 168 |
|
---|
| 169 | static void ne2k_dev_cleanup(ddf_dev_t *dev)
|
---|
| 170 | {
|
---|
[56fd7cf] | 171 | if (ddf_dev_data_get(dev) != NULL) {
|
---|
[80099c19] | 172 | ne2k_t *ne2k = NE2K(dev);
|
---|
| 173 | if (ne2k) {
|
---|
[9571230] | 174 | free(ne2k->code.ranges);
|
---|
[80099c19] | 175 | free(ne2k->code.cmds);
|
---|
| 176 | }
|
---|
| 177 | nic_unbind_and_destroy(dev);
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | static int ne2k_dev_init(nic_t *nic_data)
|
---|
| 182 | {
|
---|
| 183 | /* Get HW resources */
|
---|
| 184 | hw_res_list_parsed_t hw_res_parsed;
|
---|
| 185 | hw_res_list_parsed_init(&hw_res_parsed);
|
---|
| 186 |
|
---|
| 187 | int rc = nic_get_resources(nic_data, &hw_res_parsed);
|
---|
| 188 |
|
---|
| 189 | if (rc != EOK)
|
---|
| 190 | goto failed;
|
---|
| 191 |
|
---|
| 192 | if (hw_res_parsed.irqs.count == 0) {
|
---|
| 193 | rc = EINVAL;
|
---|
| 194 | goto failed;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | if (hw_res_parsed.io_ranges.count == 0) {
|
---|
| 198 | rc = EINVAL;
|
---|
| 199 | goto failed;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | if (hw_res_parsed.io_ranges.ranges[0].size < NE2K_IO_SIZE) {
|
---|
| 203 | rc = EINVAL;
|
---|
| 204 | goto failed;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 208 | ne2k->irq = hw_res_parsed.irqs.irqs[0];
|
---|
| 209 |
|
---|
[7de1988c] | 210 | addr_range_t regs = hw_res_parsed.io_ranges.ranges[0];
|
---|
| 211 | ne2k->base_port = RNGABSPTR(regs);
|
---|
[80099c19] | 212 |
|
---|
| 213 | hw_res_list_parsed_clean(&hw_res_parsed);
|
---|
| 214 |
|
---|
[7de1988c] | 215 | /* Enable programmed I/O */
|
---|
| 216 | if (pio_enable_range(®s, &ne2k->port) != EOK)
|
---|
[80099c19] | 217 | return EADDRNOTAVAIL;
|
---|
| 218 |
|
---|
| 219 | ne2k->data_port = ne2k->port + NE2K_DATA;
|
---|
| 220 | ne2k->receive_configuration = RCR_AB | RCR_AM;
|
---|
| 221 | ne2k->probed = false;
|
---|
| 222 | ne2k->up = false;
|
---|
| 223 |
|
---|
| 224 | /* Find out whether the device is present. */
|
---|
| 225 | if (ne2k_probe(ne2k) != EOK)
|
---|
| 226 | return ENOENT;
|
---|
| 227 |
|
---|
| 228 | ne2k->probed = true;
|
---|
| 229 |
|
---|
[e9d15d9] | 230 | int irq_cap = ne2k_register_interrupt(nic_data);
|
---|
| 231 | if (irq_cap < 0)
|
---|
[80099c19] | 232 | return EINVAL;
|
---|
| 233 |
|
---|
| 234 | return EOK;
|
---|
| 235 |
|
---|
| 236 | failed:
|
---|
| 237 | hw_res_list_parsed_clean(&hw_res_parsed);
|
---|
| 238 | return rc;
|
---|
| 239 | }
|
---|
| 240 |
|
---|
[01c3bb4] | 241 | void ne2k_interrupt_handler(ipc_call_t *call, ddf_dev_t *dev)
|
---|
[80099c19] | 242 | {
|
---|
| 243 | nic_t *nic_data = DRIVER_DATA(dev);
|
---|
| 244 | ne2k_interrupt(nic_data, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | static int ne2k_on_activating(nic_t *nic_data)
|
---|
| 248 | {
|
---|
| 249 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 250 |
|
---|
| 251 | if (!ne2k->up) {
|
---|
| 252 | int rc = ne2k_up(ne2k);
|
---|
[e5424e9] | 253 | if (rc != EOK)
|
---|
| 254 | return rc;
|
---|
| 255 |
|
---|
[d51838f] | 256 | rc = hw_res_enable_interrupt(ne2k->parent_sess, ne2k->irq);
|
---|
[80099c19] | 257 | if (rc != EOK) {
|
---|
[e5424e9] | 258 | ne2k_down(ne2k);
|
---|
[80099c19] | 259 | return rc;
|
---|
| 260 | }
|
---|
| 261 | }
|
---|
| 262 | return EOK;
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | static int ne2k_on_stopping(nic_t *nic_data)
|
---|
| 266 | {
|
---|
| 267 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 268 |
|
---|
[d51838f] | 269 | (void) hw_res_disable_interrupt(ne2k->parent_sess, ne2k->irq);
|
---|
[80099c19] | 270 | ne2k->receive_configuration = RCR_AB | RCR_AM;
|
---|
| 271 | ne2k_down(ne2k);
|
---|
| 272 | return EOK;
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | static int ne2k_set_address(ddf_fun_t *fun, const nic_address_t *address)
|
---|
| 276 | {
|
---|
[56fd7cf] | 277 | nic_t *nic_data = DRIVER_DATA(ddf_fun_get_dev(fun));
|
---|
[80099c19] | 278 | int rc = nic_report_address(nic_data, address);
|
---|
| 279 | if (rc != EOK) {
|
---|
| 280 | return EINVAL;
|
---|
| 281 | }
|
---|
| 282 | /* Note: some frame with previous physical address may slip to NIL here
|
---|
| 283 | * (for a moment the filtering is not exact), but ethernet should be OK with
|
---|
[1bc35b5] | 284 | * that. Some frames may also be lost, but this is not a problem.
|
---|
[80099c19] | 285 | */
|
---|
| 286 | ne2k_set_physical_address((ne2k_t *) nic_get_specific(nic_data), address);
|
---|
| 287 | return EOK;
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | static int ne2k_on_unicast_mode_change(nic_t *nic_data,
|
---|
| 291 | nic_unicast_mode_t new_mode,
|
---|
| 292 | const nic_address_t *address_list, size_t address_count)
|
---|
| 293 | {
|
---|
| 294 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 295 | switch (new_mode) {
|
---|
| 296 | case NIC_UNICAST_BLOCKED:
|
---|
| 297 | ne2k_set_promisc_phys(ne2k, false);
|
---|
| 298 | nic_report_hw_filtering(nic_data, 0, -1, -1);
|
---|
| 299 | return EOK;
|
---|
| 300 | case NIC_UNICAST_DEFAULT:
|
---|
| 301 | ne2k_set_promisc_phys(ne2k, false);
|
---|
| 302 | nic_report_hw_filtering(nic_data, 1, -1, -1);
|
---|
| 303 | return EOK;
|
---|
| 304 | case NIC_UNICAST_LIST:
|
---|
| 305 | ne2k_set_promisc_phys(ne2k, true);
|
---|
| 306 | nic_report_hw_filtering(nic_data, 0, -1, -1);
|
---|
| 307 | return EOK;
|
---|
| 308 | case NIC_UNICAST_PROMISC:
|
---|
| 309 | ne2k_set_promisc_phys(ne2k, true);
|
---|
| 310 | nic_report_hw_filtering(nic_data, 1, -1, -1);
|
---|
| 311 | return EOK;
|
---|
| 312 | default:
|
---|
| 313 | return ENOTSUP;
|
---|
| 314 | }
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | static int ne2k_on_multicast_mode_change(nic_t *nic_data,
|
---|
| 318 | nic_multicast_mode_t new_mode,
|
---|
| 319 | const nic_address_t *address_list, size_t address_count)
|
---|
| 320 | {
|
---|
| 321 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 322 | switch (new_mode) {
|
---|
| 323 | case NIC_MULTICAST_BLOCKED:
|
---|
| 324 | ne2k_set_accept_mcast(ne2k, false);
|
---|
| 325 | nic_report_hw_filtering(nic_data, -1, 1, -1);
|
---|
| 326 | return EOK;
|
---|
| 327 | case NIC_MULTICAST_LIST:
|
---|
| 328 | ne2k_set_accept_mcast(ne2k, true);
|
---|
| 329 | ne2k_set_mcast_hash(ne2k,
|
---|
| 330 | nic_mcast_hash(address_list, address_count));
|
---|
| 331 | nic_report_hw_filtering(nic_data, -1, 0, -1);
|
---|
| 332 | return EOK;
|
---|
| 333 | case NIC_MULTICAST_PROMISC:
|
---|
| 334 | ne2k_set_accept_mcast(ne2k, true);
|
---|
| 335 | ne2k_set_mcast_hash(ne2k, 0xFFFFFFFFFFFFFFFFllu);
|
---|
| 336 | nic_report_hw_filtering(nic_data, -1, 1, -1);
|
---|
| 337 | return EOK;
|
---|
| 338 | default:
|
---|
| 339 | return ENOTSUP;
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | static int ne2k_on_broadcast_mode_change(nic_t *nic_data,
|
---|
| 344 | nic_broadcast_mode_t new_mode)
|
---|
| 345 | {
|
---|
| 346 | ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
|
---|
| 347 | switch (new_mode) {
|
---|
| 348 | case NIC_BROADCAST_BLOCKED:
|
---|
| 349 | ne2k_set_accept_bcast(ne2k, false);
|
---|
| 350 | return EOK;
|
---|
| 351 | case NIC_BROADCAST_ACCEPTED:
|
---|
| 352 | ne2k_set_accept_bcast(ne2k, true);
|
---|
| 353 | return EOK;
|
---|
| 354 | default:
|
---|
| 355 | return ENOTSUP;
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[0c0f823b] | 359 | static int ne2k_dev_add(ddf_dev_t *dev)
|
---|
[80099c19] | 360 | {
|
---|
[e86b8f0] | 361 | ddf_fun_t *fun;
|
---|
| 362 |
|
---|
[80099c19] | 363 | /* Allocate driver data for the device. */
|
---|
| 364 | nic_t *nic_data = nic_create_and_bind(dev);
|
---|
| 365 | if (nic_data == NULL)
|
---|
| 366 | return ENOMEM;
|
---|
| 367 |
|
---|
[6d8455d] | 368 | nic_set_send_frame_handler(nic_data, ne2k_send);
|
---|
[80099c19] | 369 | nic_set_state_change_handlers(nic_data,
|
---|
| 370 | ne2k_on_activating, NULL, ne2k_on_stopping);
|
---|
| 371 | nic_set_filtering_change_handlers(nic_data,
|
---|
| 372 | ne2k_on_unicast_mode_change, ne2k_on_multicast_mode_change,
|
---|
| 373 | ne2k_on_broadcast_mode_change, NULL, NULL);
|
---|
| 374 |
|
---|
| 375 | ne2k_t *ne2k = malloc(sizeof(ne2k_t));
|
---|
| 376 | if (NULL != ne2k) {
|
---|
| 377 | memset(ne2k, 0, sizeof(ne2k_t));
|
---|
| 378 | nic_set_specific(nic_data, ne2k);
|
---|
| 379 | } else {
|
---|
| 380 | nic_unbind_and_destroy(dev);
|
---|
| 381 | return ENOMEM;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
[d51838f] | 384 | ne2k->dev = dev;
|
---|
| 385 | ne2k->parent_sess = ddf_dev_parent_sess_get(dev);
|
---|
| 386 | if (ne2k->parent_sess == NULL) {
|
---|
| 387 | ne2k_dev_cleanup(dev);
|
---|
| 388 | return ENOMEM;
|
---|
| 389 | }
|
---|
| 390 |
|
---|
[80099c19] | 391 | int rc = ne2k_dev_init(nic_data);
|
---|
| 392 | if (rc != EOK) {
|
---|
| 393 | ne2k_dev_cleanup(dev);
|
---|
| 394 | return rc;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | rc = nic_report_address(nic_data, &ne2k->mac);
|
---|
| 398 | if (rc != EOK) {
|
---|
| 399 | ne2k_dev_cleanup(dev);
|
---|
| 400 | return rc;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
[e86b8f0] | 403 | fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");
|
---|
| 404 | if (fun == NULL) {
|
---|
| 405 | ne2k_dev_cleanup(dev);
|
---|
| 406 | return ENOMEM;
|
---|
| 407 | }
|
---|
[54a1ca7] | 408 |
|
---|
[e86b8f0] | 409 | nic_set_ddf_fun(nic_data, fun);
|
---|
[56fd7cf] | 410 | ddf_fun_set_ops(fun, &ne2k_dev_ops);
|
---|
[e86b8f0] | 411 |
|
---|
| 412 | rc = ddf_fun_bind(fun);
|
---|
[80099c19] | 413 | if (rc != EOK) {
|
---|
[e86b8f0] | 414 | ddf_fun_destroy(fun);
|
---|
[80099c19] | 415 | ne2k_dev_cleanup(dev);
|
---|
| 416 | return rc;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[e86b8f0] | 419 | rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
|
---|
| 420 | if (rc != EOK) {
|
---|
| 421 | ddf_fun_unbind(fun);
|
---|
| 422 | ddf_fun_destroy(fun);
|
---|
| 423 | return rc;
|
---|
| 424 | }
|
---|
| 425 |
|
---|
[80099c19] | 426 | return EOK;
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | static nic_iface_t ne2k_nic_iface = {
|
---|
| 430 | .set_address = ne2k_set_address
|
---|
| 431 | };
|
---|
| 432 |
|
---|
| 433 | static driver_ops_t ne2k_driver_ops = {
|
---|
[0c0f823b] | 434 | .dev_add = ne2k_dev_add
|
---|
[80099c19] | 435 | };
|
---|
| 436 |
|
---|
| 437 | static driver_t ne2k_driver = {
|
---|
| 438 | .name = NAME,
|
---|
| 439 | .driver_ops = &ne2k_driver_ops
|
---|
| 440 | };
|
---|
| 441 |
|
---|
| 442 | int main(int argc, char *argv[])
|
---|
| 443 | {
|
---|
[869d936] | 444 | printf("%s: HelenOS NE 2000 network adapter driver\n", NAME);
|
---|
| 445 |
|
---|
[80099c19] | 446 | nic_driver_init(NAME);
|
---|
| 447 | nic_driver_implement(&ne2k_driver_ops, &ne2k_dev_ops, &ne2k_nic_iface);
|
---|
| 448 |
|
---|
| 449 | return ddf_driver_main(&ne2k_driver);
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 | /** @}
|
---|
| 453 | */
|
---|