- Timestamp:
- 2012-02-01T00:09:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ffcc5776
- Parents:
- cb3dbb63 (diff), 3d4750f (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. - Location:
- uspace
- Files:
-
- 1 added
- 30 edited
-
drv/bus/isa/isa.c (modified) (1 diff)
-
drv/bus/usb/usbhid/mouse/mousedev.c (modified) (2 diffs)
-
drv/char/i8042/i8042.c (modified) (1 diff)
-
drv/nic/e1k/e1k.c (modified) (5 diffs)
-
drv/nic/lo/lo.c (modified) (1 diff)
-
drv/nic/rtl8139/defs.h (modified) (6 diffs)
-
drv/nic/rtl8139/driver.c (modified) (6 diffs)
-
drv/nic/rtl8139/driver.h (modified) (5 diffs)
-
drv/nic/rtl8139/general.h (modified) (2 diffs)
-
lib/c/generic/device/nic.c (modified) (2 diffs)
-
lib/c/include/device/nic.h (modified) (1 diff)
-
lib/c/include/net/device.h (modified) (1 diff)
-
lib/c/include/nic/nic.h (modified) (2 diffs)
-
lib/drv/Makefile (modified) (1 diff)
-
lib/drv/generic/driver.c (modified) (5 diffs)
-
lib/drv/generic/interrupt.c (added)
-
lib/drv/generic/remote_nic.c (modified) (1 diff)
-
lib/drv/include/ddf/interrupt.h (modified) (1 diff)
-
lib/drv/include/ops/nic.h (modified) (1 diff)
-
lib/drv/include/usbhc_iface.h (modified) (1 diff)
-
lib/nic/include/nic_driver.h (modified) (1 diff)
-
lib/nic/include/nic_ev.h (modified) (1 diff)
-
lib/nic/include/nic_impl.h (modified) (1 diff)
-
lib/nic/src/nic_driver.c (modified) (4 diffs)
-
lib/nic/src/nic_ev.c (modified) (3 diffs)
-
lib/nic/src/nic_impl.c (modified) (4 diffs)
-
lib/posix/ctype.c (modified) (2 diffs)
-
srv/loc/loc.c (modified) (1 diff)
-
srv/net/net/net.h (modified) (1 diff)
-
srv/net/nil/eth/eth.c (modified) (8 diffs)
-
srv/net/nil/nildummy/nildummy.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
rcb3dbb63 r70922c2 401 401 402 402 val = skip_spaces(val); 403 irq = (int) strtol(val, &end, 10);403 irq = (int) strtol(val, &end, 10); 404 404 405 405 if (val != end) -
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
rcb3dbb63 r70922c2 170 170 return result; 171 171 } 172 /*----------------------------------------------------------------------------*/ 172 173 173 static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, 174 174 usb_mouse_t *mouse_dev) … … 297 297 return EOK; 298 298 } 299 /*----------------------------------------------------------------------------*/ 299 300 300 /** Get highest index of a button mentioned in given report. 301 301 * -
uspace/drv/char/i8042/i8042.c
rcb3dbb63 r70922c2 307 307 308 308 for (size_t i = 0; i < size; ++i) { 309 wait_ready(controller); 310 311 if (controller->aux_fun == fun) 309 if (controller->aux_fun == fun) { 310 wait_ready(controller); 312 311 pio_write_8(&controller->regs->status, 313 312 i8042_CMD_WRITE_AUX); 313 } 314 314 315 wait_ready(controller); 315 316 pio_write_8(&controller->regs->data, buffer[i]); 316 317 } -
uspace/drv/nic/e1k/e1k.c
rcb3dbb63 r70922c2 1402 1402 fibril_mutex_unlock(&e1000->rx_lock); 1403 1403 return EOK; 1404 1404 1405 error: 1405 1406 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { … … 1410 1411 } 1411 1412 } 1413 1412 1414 if (e1000->rx_frame_phys != NULL) { 1413 1415 free(e1000->rx_frame_phys); 1414 1416 e1000->rx_frame_phys = NULL; 1415 1417 } 1418 1416 1419 if (e1000->rx_frame_virt != NULL) { 1417 1420 free(e1000->rx_frame_virt); 1418 1421 e1000->rx_frame_phys = NULL; 1419 1422 } 1423 1420 1424 return rc; 1421 1425 } … … 1642 1646 e1000->tx_frame_phys = NULL; 1643 1647 } 1648 1644 1649 dmamem_unmap_anonymous(e1000->tx_ring_virt); 1645 1650 } … … 2052 2057 case E1000_82545: 2053 2058 case E1000_82546: 2054 case E1000_82572:2055 2059 e1000->info.eerd_start = 0x01; 2056 2060 e1000->info.eerd_done = 0x10; … … 2059 2063 break; 2060 2064 case E1000_82547: 2065 case E1000_82572: 2061 2066 case E1000_80003ES2: 2062 2067 e1000->info.eerd_start = 0x01; -
uspace/drv/nic/lo/lo.c
rcb3dbb63 r70922c2 127 127 printf("%s: Adding loopback device '%s'\n", NAME, dev->name); 128 128 return EOK; 129 129 130 error: 130 131 if (bound) 131 132 ddf_fun_unbind(fun); 133 132 134 if (fun != NULL) 133 135 ddf_fun_destroy(fun); -
uspace/drv/nic/rtl8139/defs.h
rcb3dbb63 r70922c2 29 29 /** @file rtl8139_defs.h 30 30 * 31 * Registers, bit positions and masks definition of the RTL8139 network family 32 * cards 33 */ 34 35 #ifndef RTL8139_DEFS_H_INCLUDED_ 36 #define RTL8139_DEFS_H_INCLUDED_ 31 * Registers, bit positions and masks definition 32 * of the RTL8139 network family cards 33 */ 34 35 #ifndef RTL8139_DEFS_H_ 36 #define RTL8139_DEFS_H_ 37 37 38 #include <sys/types.h> 38 39 #include <libarch/ddi.h> 39 40 40 41 /** The size of RTL8139 registers address space */ 42 #define RTL8139_IO_SIZE 256 43 44 /** The maximal transmitted frame length in bytes allowed according to RTL8139 45 * documentation (see SIZE part of TSD documentation) 46 */ 47 #define RTL8139_FRAME_MAX_LENGTH 1792 48 41 /** Size of RTL8139 registers address space */ 42 #define RTL8139_IO_SIZE 256 43 44 /** Maximal transmitted frame length 45 * 46 * Maximal transmitted frame length in bytes 47 * allowed according to the RTL8139 documentation 48 * (see SIZE part of TSD documentation). 49 * 50 */ 51 #define RTL8139_FRAME_MAX_LENGTH 1792 49 52 50 53 /** HW version 51 54 * 52 * as can be detected from HWVERID part of TCR 53 * (Transmit Configuration Register) 54 */ 55 enum rtl8139_version_id { 55 * As can be detected from HWVERID part of TCR 56 * (Transmit Configuration Register). 57 * 58 */ 59 typedef enum { 56 60 RTL8139 = 0, /**< RTL8139 */ 57 61 RTL8139A, /**< RTL8139A */ … … 66 70 RTL8101, /**< RTL8101 */ 67 71 RTL8139_VER_COUNT /**< Count of known RTL versions, the last value */ 68 }; 69 70 extern const char* model_names[RTL8139_VER_COUNT]; 72 } rtl8139_version_id_t; 71 73 72 74 /** Registers of RTL8139 family card offsets from the memory address base */ … … 75 77 MAC0 = IDR0, /**< Alias for IDR0 */ 76 78 77 // 0x 6 - 0x7 reserved79 // 0x06 - 0x07 reserved 78 80 79 81 MAR0 = 0x08, /**< Multicast mask registers 8 1b registers sequence */ … … 213 215 pio_write_8(io_base + CR9346, RTL8139_REGS_LOCKED); 214 216 } 217 215 218 /** Allow to change Config0-4 and BMCR register */ 216 219 static inline void rtl8139_regs_unlock(void *io_base) … … 417 420 418 421 /** Maximal runt frame size + 1 */ 419 #define RTL8139_RUNT_MAX_SIZE 64422 #define RTL8139_RUNT_MAX_SIZE 64 420 423 421 424 /** Bits in frame header */ … … 470 473 471 474 /** Mapping of HW version -> version ID */ 472 struct rtl8139_hwver_map { 473 uint32_t hwverid; /**< HW version value in the register */474 enum rtl8139_version_idver_id; /**< appropriate version id */475 struct rtl8139_hwver_map { 476 uint32_t hwverid; /**< HW version value in the register */ 477 rtl8139_version_id_t ver_id; /**< appropriate version id */ 475 478 }; 476 479 477 480 /** Mapping of HW version -> version ID */ 478 481 extern const struct rtl8139_hwver_map rtl8139_versions[RTL8139_VER_COUNT + 1]; 482 extern const char* model_names[RTL8139_VER_COUNT]; 479 483 480 484 /** Size in the frame header while copying from RxFIFO to Rx buffer */ 481 #define RTL8139_EARLY_SIZE UINT16_C(0xfff0) 485 #define RTL8139_EARLY_SIZE UINT16_C(0xfff0) 486 482 487 /** The only supported pause frame time value */ 483 #define RTL8139_PAUSE_VAL UINT16_C(0xFFFF)488 #define RTL8139_PAUSE_VAL UINT16_C(0xFFFF) 484 489 485 490 /** Size of the frame header in front of the received frame */ 486 #define RTL_FRAME_HEADER_SIZE 4491 #define RTL_FRAME_HEADER_SIZE 4 487 492 488 493 /** 8k buffer */ -
uspace/drv/nic/rtl8139/driver.c
rcb3dbb63 r70922c2 55 55 /** Global mutex for work with shared irq structure */ 56 56 FIBRIL_MUTEX_INITIALIZE(irq_reg_lock); 57 57 58 /** Lock interrupt structure mutex */ 58 #define RTL8139_IRQ_STRUCT_LOCK() fibril_mutex_lock(&irq_reg_lock) 59 #define RTL8139_IRQ_STRUCT_LOCK() \ 60 fibril_mutex_lock(&irq_reg_lock) 61 59 62 /** Unlock interrupt structure mutex */ 60 #define RTL8139_IRQ_STRUCT_UNLOCK() fibril_mutex_unlock(&irq_reg_lock) 63 #define RTL8139_IRQ_STRUCT_UNLOCK() \ 64 fibril_mutex_unlock(&irq_reg_lock) 61 65 62 66 /** PCI clock frequency in kHz */ 63 #define RTL8139_PCI_FREQ_KHZ 3300064 65 #define RTL8139_AUTONEG_CAPS (ETH_AUTONEG_10BASE_T_HALF \66 | ETH_AUTONEG_10BASE_T_FULL | ETH_AUTONEG_100BASE_TX_HALF\67 |ETH_AUTONEG_100BASE_TX_FULL | ETH_AUTONEG_PAUSE_SYMETRIC)67 #define RTL8139_PCI_FREQ_KHZ 33000 68 69 #define RTL8139_AUTONEG_CAPS (ETH_AUTONEG_10BASE_T_HALF | \ 70 ETH_AUTONEG_10BASE_T_FULL | ETH_AUTONEG_100BASE_TX_HALF | \ 71 ETH_AUTONEG_100BASE_TX_FULL | ETH_AUTONEG_PAUSE_SYMETRIC) 68 72 69 73 /** Lock transmitter and receiver data 70 * This function shall be called whenever both transmitter and receiver locking 71 * to force safe lock ordering (deadlock prevention) 72 * 73 * @param rtl8139 RTL8139 private data 74 * 75 * This function shall be called whenever 76 * both transmitter and receiver locking 77 * to force safe lock ordering (deadlock prevention) 78 * 79 * @param rtl8139 RTL8139 private data 80 * 74 81 */ 75 82 inline static void rtl8139_lock_all(rtl8139_t *rtl8139) … … 82 89 /** Unlock transmitter and receiver data 83 90 * 84 * @param rtl8139 RTL8139 private data 91 * @param rtl8139 RTL8139 private data 92 * 85 93 */ 86 94 inline static void rtl8139_unlock_all(rtl8139_t *rtl8139) … … 457 465 pio_write_32(tsd, tsd_value); 458 466 return; 459 467 460 468 err_busy_no_inc: 461 469 err_size: … … 513 521 * 514 522 * @return The frame list node (not connected) 523 * 515 524 */ 516 525 static nic_frame_t *rtl8139_read_frame(nic_t *nic_data, … … 1215 1224 ddf_msg(LVL_DEBUG, "The device is initialized"); 1216 1225 return ret; 1217 1226 1218 1227 failed: 1219 1228 ddf_msg(LVL_ERROR, "The device initialization failed"); … … 1342 1351 1343 1352 return EOK; 1344 1353 1345 1354 err_fun_bind: 1346 1355 ddf_fun_unbind(fun); -
uspace/drv/nic/rtl8139/driver.h
rcb3dbb63 r70922c2 30 30 #define RTL8139_DRIVER_H_ 31 31 32 #include <sys/types.h> 33 #include <stdint.h> 32 34 #include "defs.h" 33 35 #include "general.h" 34 #include <sys/types.h>35 #include <stdint.h>36 36 37 37 /** The driver name */ 38 #define NAME "rtl8139" 38 #define NAME "rtl8139" 39 39 40 /** Transmittion buffers count */ 40 #define TX_BUFF_COUNT 441 /** Size of buffer for one frame 42 * - 2kB 43 */ 44 #define TX_BUFF_SIZE (2 * 1024) 45 /** Countof pages to allocate for TxBuffers */46 #define TX_PAGES 241 #define TX_BUFF_COUNT 4 42 43 /** Size of buffer for one frame (2kB) */ 44 #define TX_BUFF_SIZE (2 * 1024) 45 46 /** Number of pages to allocate for TxBuffers */ 47 #define TX_PAGES 2 47 48 48 49 /** Size of the CRC after the received frame in the receiver buffer */ 49 #define RTL8139_CRC_SIZE 450 #define RTL8139_CRC_SIZE 4 50 51 51 52 /** The default mode of accepting unicast frames */ 52 #define RTL8139_RCR_UCAST_DEFAULT RCR_ACCEPT_PHYS_MATCH 53 #define RTL8139_RCR_UCAST_DEFAULT RCR_ACCEPT_PHYS_MATCH 54 53 55 /** The default mode of accepting multicast frames */ 54 #define RTL8139_RCR_MCAST_DEFAULT 0 56 #define RTL8139_RCR_MCAST_DEFAULT 0 57 55 58 /** The default mode of accepting broadcast frames */ 56 #define RTL8139_RCR_BCAST_DEFAULT RCR_ACCEPT_BROADCAST 59 #define RTL8139_RCR_BCAST_DEFAULT RCR_ACCEPT_BROADCAST 60 57 61 /** The default mode of accepting defect frames */ 58 #define RTL8139_RCR_DEFECT_DEFAULT 062 #define RTL8139_RCR_DEFECT_DEFAULT 0 59 63 60 64 /** Mask for accepting all multicast */ 61 #define RTL8139_MCAST_MASK_PROMISC UINT64_MAX62 63 /** Data */65 #define RTL8139_MCAST_MASK_PROMISC UINT64_MAX 66 67 /** Data */ 64 68 struct rtl8139_rcr_data { 65 69 /** Configuration part of RCR */ … … 134 138 135 139 /** Version of RT8139 controller */ 136 enum rtl8139_version_idhw_version;140 rtl8139_version_id_t hw_version; 137 141 } rtl8139_t; 138 139 142 140 143 /* ***** Pointers casting - for both amd64 and ia32 ***** */ … … 160 163 */ 161 164 #define IOADDR_TO_PTR(ioaddr) ((void*)((size_t)(ioaddr))) 162 163 164 165 165 166 /* ***** Bit operation macros ***** */ … … 177 178 * @return New value 178 179 */ 179 #define bit_set_part_g( src, value, mask, type) \180 #define bit_set_part_g(src, value, mask, type) \ 180 181 ((type)(((src) & ~((type)(mask))) | ((value) & (type)(mask)))) 181 182 … … 237 238 bit_set_part_32(tsd_value, (size) << TSD_SIZE_SHIFT, TSD_SIZE_MASK << TSD_SIZE_SHIFT) 238 239 239 240 240 #endif -
uspace/drv/nic/rtl8139/general.h
rcb3dbb63 r70922c2 29 29 /** @file 30 30 * 31 * General functions and structures used in rtl8139 driver31 * General functions and structures used in rtl8139 driver 32 32 */ 33 33 … … 37 37 #include <unistd.h> 38 38 39 extern void* rtl8139_memcpy_wrapped(void *dest, const void *src_buf, 40 size_t src_offset, size_t src_size, size_t data_size); 41 39 /** Number of microseconds in second */ 40 #define RTL8139_USEC_IN_SEC 1000000 42 41 43 42 /** Structure for HW timer control */ 44 typedef struct rtl8139_timer_act{43 typedef struct { 45 44 /** Register value set in the last timer period */ 46 45 uint32_t last_val; 46 47 47 /** Register value set in the common timer period */ 48 48 uint32_t full_val; 49 49 50 50 /** Amount of full register periods in timer period */ 51 51 size_t full_skips; 52 52 53 /** Remaining full register periods to the next period end */ 53 54 size_t full_skips_remains; 55 54 56 /** Mark if there is a last run */ 55 57 int last_run; 56 58 } rtl8139_timer_act_t; 57 59 58 /** Count of microseconds in second */ 59 #define RTL8139_USEC_IN_SEC 1000000 60 61 extern int rtl8139_timer_act_init(rtl8139_timer_act_t *ta, uint32_t timer_freq, 62 const struct timeval *time); 63 extern int rtl8139_timer_act_step(rtl8139_timer_act_t *ta, uint32_t *new_reg); 64 60 extern void *rtl8139_memcpy_wrapped(void *, const void *, size_t, size_t, 61 size_t); 62 extern int rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t, 63 const struct timeval *); 64 extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *); 65 65 66 66 #endif -
uspace/lib/c/generic/device/nic.c
rcb3dbb63 r70922c2 81 81 * 82 82 */ 83 int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id,84 async_client_conn_t cfun,void *carg)83 int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun, 84 void *carg) 85 85 { 86 86 ipc_call_t answer; … … 89 89 90 90 async_exch_t *exch = async_exchange_begin(dev_sess); 91 aid_t req = async_send_ 2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),92 NIC_CALLBACK_CREATE, device_id,&answer);91 aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE), 92 NIC_CALLBACK_CREATE, &answer); 93 93 94 94 rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg); -
uspace/lib/c/include/device/nic.h
rcb3dbb63 r70922c2 91 91 92 92 extern int nic_send_frame(async_sess_t *, void *, size_t); 93 extern int nic_callback_create(async_sess_t *, nic_device_id_t, 94 async_client_conn_t, void *); 93 extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *); 95 94 extern int nic_get_state(async_sess_t *, nic_device_state_t *); 96 95 extern int nic_set_state(async_sess_t *, nic_device_state_t); -
uspace/lib/c/include/net/device.h
rcb3dbb63 r70922c2 47 47 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 48 48 49 /** Device identifier type. */ 50 typedef int nic_device_id_t; 51 52 /** Invalid device identifier. */ 53 #define NIC_DEVICE_INVALID_ID (-1) 54 49 55 #endif 50 56 -
uspace/lib/c/include/nic/nic.h
rcb3dbb63 r70922c2 63 63 #define NIC_MAX_ADDRESS_LENGTH 16 64 64 65 /** Invalid device identifier. */66 #define NIC_DEVICE_INVALID_ID (-1)67 68 65 #define NIC_VENDOR_MAX_LENGTH 64 69 66 #define NIC_MODEL_MAX_LENGTH 64 … … 86 83 87 84 #define NIC_DEVICE_PRINT_FMT "%x" 88 89 /** Device identifier type. */90 typedef int nic_device_id_t;91 85 92 86 /** -
uspace/lib/drv/Makefile
rcb3dbb63 r70922c2 35 35 generic/driver.c \ 36 36 generic/dev_iface.c \ 37 generic/interrupt.c \ 37 38 generic/log.c \ 38 39 generic/logbuf.c \ -
uspace/lib/drv/generic/driver.c
rcb3dbb63 r70922c2 70 70 FIBRIL_MUTEX_INITIALIZE(functions_mutex); 71 71 72 /** Interrupts */73 static interrupt_context_list_t interrupt_contexts;74 75 static irq_cmd_t default_cmds[] = {76 {77 .cmd = CMD_ACCEPT78 }79 };80 81 static irq_code_t default_pseudocode = {82 sizeof(default_cmds) / sizeof(irq_cmd_t),83 default_cmds84 };85 86 72 static ddf_dev_t *create_device(void); 87 73 static void delete_device(ddf_dev_t *); … … 92 78 static remote_handler_t *function_get_default_handler(ddf_fun_t *); 93 79 static void *function_get_ops(ddf_fun_t *, dev_inferface_idx_t); 94 95 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)96 {97 int id = (int)IPC_GET_IMETHOD(*icall);98 interrupt_context_t *ctx;99 100 ctx = find_interrupt_context_by_id(&interrupt_contexts, id);101 if (ctx != NULL && ctx->handler != NULL)102 (*ctx->handler)(ctx->dev, iid, icall);103 }104 105 interrupt_context_t *create_interrupt_context(void)106 {107 interrupt_context_t *ctx;108 109 ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));110 if (ctx != NULL)111 memset(ctx, 0, sizeof(interrupt_context_t));112 113 return ctx;114 }115 116 void delete_interrupt_context(interrupt_context_t *ctx)117 {118 if (ctx != NULL)119 free(ctx);120 }121 122 void init_interrupt_context_list(interrupt_context_list_t *list)123 {124 memset(list, 0, sizeof(interrupt_context_list_t));125 fibril_mutex_initialize(&list->mutex);126 list_initialize(&list->contexts);127 }128 129 void130 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)131 {132 fibril_mutex_lock(&list->mutex);133 ctx->id = list->curr_id++;134 list_append(&ctx->link, &list->contexts);135 fibril_mutex_unlock(&list->mutex);136 }137 138 void remove_interrupt_context(interrupt_context_list_t *list,139 interrupt_context_t *ctx)140 {141 fibril_mutex_lock(&list->mutex);142 list_remove(&ctx->link);143 fibril_mutex_unlock(&list->mutex);144 }145 146 interrupt_context_t *147 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)148 {149 interrupt_context_t *ctx;150 151 fibril_mutex_lock(&list->mutex);152 153 list_foreach(list->contexts, link) {154 ctx = list_get_instance(link, interrupt_context_t, link);155 if (ctx->id == id) {156 fibril_mutex_unlock(&list->mutex);157 return ctx;158 }159 }160 161 fibril_mutex_unlock(&list->mutex);162 return NULL;163 }164 165 interrupt_context_t *166 find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)167 {168 interrupt_context_t *ctx;169 170 fibril_mutex_lock(&list->mutex);171 172 list_foreach(list->contexts, link) {173 ctx = list_get_instance(link, interrupt_context_t, link);174 if (ctx->irq == irq && ctx->dev == dev) {175 fibril_mutex_unlock(&list->mutex);176 return ctx;177 }178 }179 180 fibril_mutex_unlock(&list->mutex);181 return NULL;182 }183 184 185 int186 register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler,187 irq_code_t *pseudocode)188 {189 interrupt_context_t *ctx = create_interrupt_context();190 191 ctx->dev = dev;192 ctx->irq = irq;193 ctx->handler = handler;194 195 add_interrupt_context(&interrupt_contexts, ctx);196 197 if (pseudocode == NULL)198 pseudocode = &default_pseudocode;199 200 int res = irq_register(irq, dev->handle, ctx->id, pseudocode);201 if (res != EOK) {202 remove_interrupt_context(&interrupt_contexts, ctx);203 delete_interrupt_context(ctx);204 }205 206 return res;207 }208 209 int unregister_interrupt_handler(ddf_dev_t *dev, int irq)210 {211 interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,212 dev, irq);213 int res = irq_unregister(irq, dev->handle);214 215 if (ctx != NULL) {216 remove_interrupt_context(&interrupt_contexts, ctx);217 delete_interrupt_context(ctx);218 }219 220 return res;221 }222 80 223 81 static void add_to_functions_list(ddf_fun_t *fun) … … 737 595 738 596 /** Allocate driver-specific device data. */ 739 externvoid *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size)597 void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size) 740 598 { 741 599 void *data; … … 799 657 800 658 /** Allocate driver-specific function data. */ 801 externvoid *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size)659 void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size) 802 660 { 803 661 void *data; … … 992 850 driver = drv; 993 851 994 /* Initialize the list of interrupt contexts. */ 995 init_interrupt_context_list(&interrupt_contexts); 996 997 /* Set generic interrupt handler. */ 998 async_set_interrupt_received(driver_irq_handler); 852 /* Initialize interrupt module */ 853 interrupt_init(); 999 854 1000 855 /* -
uspace/lib/drv/generic/remote_nic.c
rcb3dbb63 r70922c2 69 69 assert(nic_iface->callback_create); 70 70 71 nic_device_id_t device_id = (nic_device_id_t) IPC_GET_ARG2(*call); 72 73 int rc = nic_iface->callback_create(dev, device_id); 71 int rc = nic_iface->callback_create(dev); 74 72 async_answer_0(callid, rc); 75 73 } -
uspace/lib/drv/include/ddf/interrupt.h
rcb3dbb63 r70922c2 64 64 } interrupt_context_list_t; 65 65 66 extern interrupt_context_t *create_interrupt_context(void); 67 extern void delete_interrupt_context(interrupt_context_t *); 68 extern void init_interrupt_context_list(interrupt_context_list_t *); 69 extern void add_interrupt_context(interrupt_context_list_t *, 70 interrupt_context_t *); 71 extern void remove_interrupt_context(interrupt_context_list_t *, 72 interrupt_context_t *); 73 extern interrupt_context_t *find_interrupt_context_by_id( 74 interrupt_context_list_t *, int); 75 extern interrupt_context_t *find_interrupt_context( 76 interrupt_context_list_t *, ddf_dev_t *, int); 77 66 extern void interrupt_init(void); 78 67 extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *, 79 68 irq_code_t *); -
uspace/lib/drv/include/ops/nic.h
rcb3dbb63 r70922c2 46 46 /** Mandatory methods */ 47 47 int (*send_frame)(ddf_fun_t *, void *, size_t); 48 int (*callback_create)(ddf_fun_t * , nic_device_id_t);48 int (*callback_create)(ddf_fun_t *); 49 49 int (*get_state)(ddf_fun_t *, nic_device_state_t *); 50 50 int (*set_state)(ddf_fun_t *, nic_device_state_t); -
uspace/lib/drv/include/usbhc_iface.h
rcb3dbb63 r70922c2 27 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 */ 29 29 30 /** @addtogroup libdrv 30 31 * @addtogroup usb 31 32 * @{ 32 33 */ 34 33 35 /** @file 34 36 * @brief USB host controller interface definition. -
uspace/lib/nic/include/nic_driver.h
rcb3dbb63 r70922c2 70 70 */ 71 71 ddf_fun_t *fun; 72 /** Identifier for higher network stack layers */73 nic_device_id_t device_id;74 72 /** Current state of the device */ 75 73 nic_device_state_t state; -
uspace/lib/nic/include/nic_ev.h
rcb3dbb63 r70922c2 43 43 #include <sys/types.h> 44 44 45 extern int nic_ev_addr_changed(async_sess_t *, nic_device_id_t, 46 const nic_address_t *); 47 extern int nic_ev_device_state(async_sess_t *, nic_device_id_t, sysarg_t); 48 extern int nic_ev_received(async_sess_t *, nic_device_id_t, void *, size_t); 45 extern int nic_ev_addr_changed(async_sess_t *, const nic_address_t *); 46 extern int nic_ev_device_state(async_sess_t *, sysarg_t); 47 extern int nic_ev_received(async_sess_t *, void *, size_t); 49 48 50 49 #endif -
uspace/lib/nic/include/nic_impl.h
rcb3dbb63 r70922c2 48 48 extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address); 49 49 extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size); 50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun , int device_id);50 extern int nic_callback_create_impl(ddf_fun_t *dev_fun); 51 51 extern int nic_get_state_impl(ddf_fun_t *dev_fun, nic_device_state_t *state); 52 52 extern int nic_set_state_impl(ddf_fun_t *dev_fun, nic_device_state_t state); -
uspace/lib/nic/src/nic_driver.c
rcb3dbb63 r70922c2 497 497 if (nic_data->client_session != NULL) { 498 498 int rc = nic_ev_addr_changed(nic_data->client_session, 499 nic_data->device_id,address);499 address); 500 500 if (rc != EOK) { 501 501 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 604 604 } 605 605 fibril_rwlock_write_unlock(&nic_data->stats_lock); 606 nic_ev_received(nic_data->client_session, nic_data->device_id,607 frame-> data, frame->size);606 nic_ev_received(nic_data->client_session, frame->data, 607 frame->size); 608 608 } else { 609 609 switch (frame_type) { … … 639 639 fibril_rwlock_write_unlock(&nic_data->stats_lock); 640 640 641 nic_ev_received(nic_data->client_session, nic_data->device_id, 642 data, size); 641 nic_ev_received(nic_data->client_session, data, size); 643 642 } 644 643 … … 691 690 nic_data->dev = NULL; 692 691 nic_data->fun = NULL; 693 nic_data->device_id = NIC_DEVICE_INVALID_ID;694 692 nic_data->state = NIC_STATE_STOPPED; 695 693 nic_data->client_session = NULL; -
uspace/lib/nic/src/nic_ev.c
rcb3dbb63 r70922c2 42 42 43 43 /** Device address changed. */ 44 int nic_ev_addr_changed(async_sess_t *sess, nic_device_id_t dev_id, 45 const nic_address_t *addr) 44 int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr) 46 45 { 47 46 async_exch_t *exch = async_exchange_begin(sess); 48 47 49 48 ipc_call_t answer; 50 aid_t req = async_send_1(exch, NIC_EV_ADDR_CHANGED, (sysarg_t) dev_id, 51 &answer); 49 aid_t req = async_send_0(exch, NIC_EV_ADDR_CHANGED, &answer); 52 50 sysarg_t retval = async_data_write_start(exch, addr, 53 51 sizeof(nic_address_t)); … … 65 63 66 64 /** Device state changed. */ 67 extern int nic_ev_device_state(async_sess_t *sess, nic_device_id_t dev_id, 68 sysarg_t state) 65 int nic_ev_device_state(async_sess_t *sess, sysarg_t state) 69 66 { 70 67 int rc; 71 68 72 69 async_exch_t *exch = async_exchange_begin(sess); 73 rc = async_req_ 2_0(exch, NIC_EV_DEVICE_STATE, dev_id, state);70 rc = async_req_1_0(exch, NIC_EV_DEVICE_STATE, state); 74 71 async_exchange_end(exch); 75 72 … … 78 75 79 76 /** Frame received. */ 80 int nic_ev_received(async_sess_t *sess, nic_device_id_t dev_id, void *data, 81 size_t size) 77 int nic_ev_received(async_sess_t *sess, void *data, size_t size) 82 78 { 83 79 async_exch_t *exch = async_exchange_begin(sess); 84 80 85 81 ipc_call_t answer; 86 aid_t req = async_send_1(exch, NIC_EV_RECEIVED, (sysarg_t) dev_id, 87 &answer); 82 aid_t req = async_send_0(exch, NIC_EV_RECEIVED, &answer); 88 83 sysarg_t retval = async_data_write_start(exch, data, size); 89 84 -
uspace/lib/nic/src/nic_impl.c
rcb3dbb63 r70922c2 87 87 } 88 88 if (state == NIC_STATE_ACTIVE) { 89 if (nic_data->client_session == NULL || nic_data->device_id < 0) {89 if (nic_data->client_session == NULL) { 90 90 fibril_rwlock_write_unlock(&nic_data->main_lock); 91 91 return EINVAL; … … 118 118 /* Notify upper layers that we are reseting the MAC */ 119 119 int rc = nic_ev_addr_changed(nic_data->client_session, 120 nic_data->device_id,&nic_data->default_mac);120 &nic_data->default_mac); 121 121 nic_data->poll_mode = nic_data->default_poll_mode; 122 122 memcpy(&nic_data->poll_period, &nic_data->default_poll_period, … … 150 150 nic_data->state = state; 151 151 152 nic_ev_device_state(nic_data->client_session, nic_data->device_id,state);152 nic_ev_device_state(nic_data->client_session, state); 153 153 154 154 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 187 187 * 188 188 * @param fun 189 * @param device_id ID of the device as used in higher layers190 189 * 191 190 * @return EOK On success, or negative error code. 192 191 */ 193 int nic_callback_create_impl(ddf_fun_t *fun , nic_device_id_t device_id)192 int nic_callback_create_impl(ddf_fun_t *fun) 194 193 { 195 194 nic_t *nic = (nic_t *) fun->driver_data; 196 195 fibril_rwlock_write_lock(&nic->main_lock); 197 198 nic->device_id = device_id;199 196 200 197 nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE); -
uspace/lib/posix/ctype.c
rcb3dbb63 r70922c2 112 112 * @return Non-zero if character match the definition, zero otherwise. 113 113 */ 114 externint posix_isascii(int c)114 int posix_isascii(int c) 115 115 { 116 116 return c >= 0 && c < 128; … … 123 123 * @return Coverted character. 124 124 */ 125 externint posix_toascii(int c)125 int posix_toascii(int c) 126 126 { 127 127 return c & 0x7F; -
uspace/srv/loc/loc.c
rcb3dbb63 r70922c2 813 813 * On success, answer will contain EOK int retval. 814 814 * On failure, error code will be sent in retval. 815 * 815 816 */ 816 817 static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall) 817 818 { 818 cb_sess_t *cb_sess; 819 820 cb_sess = calloc(1, sizeof(cb_sess_t)); 819 cb_sess_t *cb_sess = calloc(1, sizeof(cb_sess_t)); 821 820 if (cb_sess == NULL) { 822 821 async_answer_0(iid, ENOMEM); -
uspace/srv/net/net/net.h
rcb3dbb63 r70922c2 96 96 97 97 /** Serving network interface driver module index. */ 98 service_id_t sid; /**< Service ID */99 async_sess_t *sess; /**< Driver session. */98 service_id_t sid; /**< Service ID */ 99 async_sess_t *sess; /**< Driver session. */ 100 100 101 101 module_t *nil; /**< Serving link layer module index. */ -
uspace/srv/net/nil/eth/eth.c
rcb3dbb63 r70922c2 173 173 void *arg); 174 174 175 static int eth_device_state( nic_device_id_t device_id, sysarg_t state)175 static int eth_device_state(eth_device_t *device, sysarg_t state) 176 176 { 177 177 int index; … … 183 183 proto = eth_protos_get_index(ð_globals.protos, index); 184 184 if ((proto) && (proto->sess)) { 185 il_device_state_msg(proto->sess, device _id, state,186 proto->service);185 il_device_state_msg(proto->sess, device->device_id, 186 state, proto->service); 187 187 } 188 188 } … … 347 347 } 348 348 349 rc = nic_callback_create(device->sess, device_id, 350 eth_nic_cb_connection, NULL); 349 rc = nic_callback_create(device->sess, eth_nic_cb_connection, device); 351 350 if (rc != EOK) { 352 351 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 825 824 } 826 825 827 static int eth_received( nic_device_id_t device_id)826 static int eth_received(eth_device_t *device) 828 827 { 829 828 void *data; … … 845 844 free(data); 846 845 847 return nil_received_msg_local(device _id, packet);848 } 849 850 static int eth_addr_changed( nic_device_id_t device_id)846 return nil_received_msg_local(device->device_id, packet); 847 } 848 849 static int eth_addr_changed(eth_device_t *device) 851 850 { 852 851 nic_address_t address; … … 866 865 867 866 fibril_rwlock_write_lock(ð_globals.devices_lock); 868 /* An existing device? */ 869 eth_device_t *device = eth_devices_find(ð_globals.devices, device_id); 870 if (device) { 871 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n", 872 device_id, ARGSMAC(device->addr.address), ARGSMAC(address.address)); 873 memcpy(&device->addr, &address, sizeof (nic_address_t)); 874 fibril_rwlock_write_unlock(ð_globals.devices_lock); 875 876 /* Notify all upper layer modules */ 877 fibril_rwlock_read_lock(ð_globals.protos_lock); 878 int index; 879 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 880 eth_proto_t *proto = eth_protos_get_index(ð_globals.protos, index); 881 if (proto->sess != NULL) { 882 il_addr_changed_msg(proto->sess, device->device_id, 883 ETH_ADDR, address.address); 884 } 885 } 886 887 fibril_rwlock_read_unlock(ð_globals.protos_lock); 888 return EOK; 889 } else { 890 return ENOENT; 891 } 867 868 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n", 869 device->device_id, ARGSMAC(device->addr.address), 870 ARGSMAC(address.address)); 871 memcpy(&device->addr, &address, sizeof (nic_address_t)); 872 fibril_rwlock_write_unlock(ð_globals.devices_lock); 873 874 /* Notify all upper layer modules */ 875 fibril_rwlock_read_lock(ð_globals.protos_lock); 876 int index; 877 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 878 eth_proto_t *proto = eth_protos_get_index(ð_globals.protos, index); 879 if (proto->sess != NULL) { 880 il_addr_changed_msg(proto->sess, device->device_id, 881 ETH_ADDR, address.address); 882 } 883 } 884 885 fibril_rwlock_read_unlock(ð_globals.protos_lock); 886 return EOK; 892 887 } 893 888 … … 962 957 static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 963 958 { 959 eth_device_t *device = (eth_device_t *)arg; 964 960 int rc; 965 961 … … 975 971 switch (IPC_GET_IMETHOD(call)) { 976 972 case NIC_EV_DEVICE_STATE: 977 rc = eth_device_state(IPC_GET_ARG1(call), 978 IPC_GET_ARG2(call)); 973 rc = eth_device_state(device, IPC_GET_ARG1(call)); 979 974 async_answer_0(callid, (sysarg_t) rc); 980 975 break; 981 976 case NIC_EV_RECEIVED: 982 rc = eth_received( IPC_GET_ARG1(call));977 rc = eth_received(device); 983 978 async_answer_0(callid, (sysarg_t) rc); 984 979 break; 985 980 case NIC_EV_ADDR_CHANGED: 986 rc = eth_addr_changed( IPC_GET_ARG1(call));981 rc = eth_addr_changed(device); 987 982 async_answer_0(callid, (sysarg_t) rc); 988 983 break; -
uspace/srv/net/nil/nildummy/nildummy.c
rcb3dbb63 r70922c2 73 73 void *arg); 74 74 75 static int nildummy_device_state(ni c_device_id_t device_id, sysarg_t state)75 static int nildummy_device_state(nildummy_device_t *device, sysarg_t state) 76 76 { 77 77 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 78 78 if (nildummy_globals.proto.sess) 79 il_device_state_msg(nildummy_globals.proto.sess, device_id,80 state, nildummy_globals.proto.service);79 il_device_state_msg(nildummy_globals.proto.sess, 80 device->device_id, state, nildummy_globals.proto.service); 81 81 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); 82 82 … … 84 84 } 85 85 86 static int nildummy_addr_changed(ni c_device_id_t device_id)86 static int nildummy_addr_changed(nildummy_device_t *device) 87 87 { 88 88 return ENOTSUP; … … 182 182 } 183 183 184 int rc = nic_callback_create(device->sess, device_id,185 nildummy_nic_cb_conn, NULL);184 int rc = nic_callback_create(device->sess, nildummy_nic_cb_conn, 185 device); 186 186 if (rc != EOK) { 187 187 async_hangup(device->sess); … … 360 360 services_t sender) 361 361 { 362 packet_t *p;363 364 362 fibril_rwlock_read_lock(&nildummy_globals.devices_lock); 365 363 … … 371 369 } 372 370 373 p = packet;371 packet_t *p = packet; 374 372 do { 375 373 nic_send_frame(device->sess, packet_get_data(p), … … 385 383 } 386 384 387 static int nildummy_received(ni c_device_id_t device_id)385 static int nildummy_received(nildummy_device_t *device) 388 386 { 389 387 void *data; … … 403 401 free(pdata); 404 402 405 return nil_received_msg_local(device _id, packet);403 return nil_received_msg_local(device->device_id, packet); 406 404 } 407 405 … … 467 465 static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 468 466 { 467 nildummy_device_t *device = (nildummy_device_t *)arg; 469 468 int rc; 470 469 … … 480 479 switch (IPC_GET_IMETHOD(call)) { 481 480 case NIC_EV_DEVICE_STATE: 482 rc = nildummy_device_state(IPC_GET_ARG1(call), 483 IPC_GET_ARG2(call)); 481 rc = nildummy_device_state(device, IPC_GET_ARG1(call)); 484 482 async_answer_0(callid, (sysarg_t) rc); 485 483 break; 486 484 case NIC_EV_RECEIVED: 487 rc = nildummy_received( IPC_GET_ARG1(call));485 rc = nildummy_received(device); 488 486 async_answer_0(callid, (sysarg_t) rc); 489 487 break; 490 488 case NIC_EV_ADDR_CHANGED: 491 rc = nildummy_addr_changed( IPC_GET_ARG1(call));489 rc = nildummy_addr_changed(device); 492 490 async_answer_0(callid, (sysarg_t) rc); 493 491 break;
Note:
See TracChangeset
for help on using the changeset viewer.
