Changes in uspace/drv/nic/e1k/e1k.c [e882e3a:1ae74c6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
re882e3a r1ae74c6 33 33 */ 34 34 35 /* XXX Fix this */ 36 #define _DDF_DATA_IMPLANT 37 35 38 #include <assert.h> 36 39 #include <stdio.h> … … 42 45 #include <ipc/irc.h> 43 46 #include <ipc/ns.h> 44 #include < libarch/ddi.h>47 #include <ddi.h> 45 48 #include <as.h> 46 49 #include <ddf/log.h> … … 49 52 #include <device/pci.h> 50 53 #include <nic.h> 51 #include <nil_remote.h>52 54 #include <ops/nic.h> 53 55 #include "e1k.h" … … 72 74 ((e1000_t *) nic_get_specific(nic)) 73 75 74 /** device_t* -> nic_driver_data_t* cast */ 76 /** ddf_fun_t * -> nic_driver_data_t* cast */ 77 #define NIC_DATA_FUN(fun) \ 78 ((nic_t *) ddf_fun_data_get(fun)) 79 80 /** ddf_dev_t * -> nic_driver_data_t* cast */ 75 81 #define NIC_DATA_DEV(dev) \ 76 ((nic_t *) ((dev)->driver_data))77 78 /** d evice_t* -> e1000_t* cast */82 ((nic_t *) ddf_dev_data_get(dev)) 83 84 /** ddf_dev_t * -> e1000_t* cast */ 79 85 #define DRIVER_DATA_DEV(dev) \ 80 86 (DRIVER_DATA_NIC(NIC_DATA_DEV(dev))) 87 88 /** ddf_fun_t * -> e1000_t* cast */ 89 #define DRIVER_DATA_FUN(fun) \ 90 (DRIVER_DATA_NIC(NIC_DATA_FUN(fun))) 81 91 82 92 /** Cast pointer to uint64_t … … 306 316 * 307 317 */ 308 static int e1000_get_cable_state(ddf_fun_t *dev, nic_cable_state_t *state) 309 { 310 assert(dev); 311 assert(DRIVER_DATA_DEV(dev)); 312 assert(state); 313 314 e1000_t *e1000 = DRIVER_DATA_DEV(dev); 318 static int e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 319 { 320 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 315 321 if (E1000_REG_READ(e1000, E1000_STATUS) & (STATUS_LU)) 316 322 *state = NIC_CS_PLUGGED; … … 329 335 * 330 336 */ 331 static int e1000_get_operation_mode(ddf_fun_t * dev, int *speed,337 static int e1000_get_operation_mode(ddf_fun_t *fun, int *speed, 332 338 nic_channel_mode_t *duplex, nic_role_t *role) 333 339 { 334 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);340 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 335 341 uint32_t status = E1000_REG_READ(e1000, E1000_STATUS); 336 342 … … 377 383 * 378 384 */ 379 static int e1000_set_operation_mode(ddf_fun_t * dev, int speed,385 static int e1000_set_operation_mode(ddf_fun_t *fun, int speed, 380 386 nic_channel_mode_t duplex, nic_role_t role) 381 387 { … … 386 392 return EINVAL; 387 393 388 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);394 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 389 395 390 396 fibril_mutex_lock(&e1000->ctrl_lock); … … 425 431 * 426 432 */ 427 static int e1000_autoneg_enable(ddf_fun_t * dev, uint32_t advertisement)428 { 429 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);433 static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement) 434 { 435 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 430 436 431 437 fibril_mutex_lock(&e1000->ctrl_lock); … … 453 459 * 454 460 */ 455 static int e1000_autoneg_disable(ddf_fun_t * dev)456 { 457 e1000_t *e1000 = DRIVER_DATA_ DEV(dev);461 static int e1000_autoneg_disable(ddf_fun_t *fun) 462 { 463 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 458 464 459 465 fibril_mutex_lock(&e1000->ctrl_lock); … … 492 498 * 493 499 */ 494 static int e1000_defective_get_mode(ddf_fun_t * device, uint32_t *mode)495 { 496 e1000_t *e1000 = DRIVER_DATA_ DEV(device);500 static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode) 501 { 502 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 497 503 498 504 *mode = 0; … … 513 519 * 514 520 */ 515 static int e1000_defective_set_mode(ddf_fun_t * device, uint32_t mode)516 { 517 e1000_t *e1000 = DRIVER_DATA_ DEV(device);521 static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode) 522 { 523 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 518 524 int rc = EOK; 519 525 … … 1039 1045 * 1040 1046 */ 1041 static int e1000_vlan_set_tag(ddf_fun_t * device, uint16_t tag, bool add,1047 static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add, 1042 1048 bool strip) 1043 1049 { … … 1053 1059 return ENOTSUP; 1054 1060 1055 e1000_t *e1000 = DRIVER_DATA_ DEV(device);1061 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 1056 1062 1057 1063 e1000->vlan_tag = tag; … … 1856 1862 static e1000_t *e1000_create_dev_data(ddf_dev_t *dev) 1857 1863 { 1858 assert(dev);1859 assert(!dev->driver_data);1860 1861 1864 nic_t *nic = nic_create_and_bind(dev); 1862 1865 if (!nic) … … 1897 1900 assert(dev); 1898 1901 1899 if (d ev->driver_data!= NULL)1902 if (ddf_dev_data_get(dev) != NULL) 1900 1903 nic_unbind_and_destroy(dev); 1901 1904 } … … 1911 1914 1912 1915 e1000_delete_dev_data(dev); 1913 1914 if (dev->parent_sess != NULL) {1915 async_hangup(dev->parent_sess);1916 dev->parent_sess = NULL;1917 }1918 1916 } 1919 1917 … … 1932 1930 const hw_res_list_parsed_t *hw_resources) 1933 1931 { 1934 assert(dev != NULL);1935 assert(hw_resources != NULL);1936 assert(dev->driver_data != NULL);1937 1938 1932 e1000_t *e1000 = DRIVER_DATA_DEV(dev); 1939 1933 … … 2004 1998 2005 1999 uint16_t device_id; 2006 rc = pci_config_space_read_16(d ev->parent_sess, PCI_DEVICE_ID,2000 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), PCI_DEVICE_ID, 2007 2001 &device_id); 2008 2002 if (rc != EOK) { … … 2122 2116 2123 2117 /* Device initialization */ 2124 nic_t *nic = d ev->driver_data;2118 nic_t *nic = ddf_dev_data_get(dev); 2125 2119 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 2126 2120 … … 2148 2142 goto err_tx_structure; 2149 2143 nic_set_ddf_fun(nic, fun); 2150 fun->ops = &e1000_dev_ops;2151 fun->driver_data = nic;2144 ddf_fun_set_ops(fun, &e1000_dev_ops); 2145 ddf_fun_data_implant(fun, nic); 2152 2146 2153 2147 rc = e1000_register_int_handler(nic); … … 2279 2273 * @return Negative error code otherwise 2280 2274 */ 2281 static int e1000_set_addr(ddf_fun_t * dev, const nic_address_t *addr)2282 { 2283 nic_t *nic = NIC_DATA_ DEV(dev);2275 static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr) 2276 { 2277 nic_t *nic = NIC_DATA_FUN(fun); 2284 2278 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 2285 2279 … … 2387 2381 &e1000_nic_iface); 2388 2382 2389 ddf_log_init(NAME , LVL_ERROR);2383 ddf_log_init(NAME); 2390 2384 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started"); 2391 2385 return ddf_driver_main(&e1000_driver);
Note:
See TracChangeset
for help on using the changeset viewer.