Changeset 70922c2 in mainline for uspace


Ignore:
Timestamp:
2012-02-01T00:09:22Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
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.
Message:

Mainline changes.

Location:
uspace
Files:
1 added
30 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/isa.c

    rcb3dbb63 r70922c2  
    401401
    402402        val = skip_spaces(val);
    403         irq = (int)strtol(val, &end, 10);
     403        irq = (int) strtol(val, &end, 10);
    404404
    405405        if (val != end)
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    rcb3dbb63 r70922c2  
    170170        return result;
    171171}
    172 /*----------------------------------------------------------------------------*/
     172
    173173static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev,
    174174    usb_mouse_t *mouse_dev)
     
    297297        return EOK;
    298298}
    299 /*----------------------------------------------------------------------------*/
     299
    300300/** Get highest index of a button mentioned in given report.
    301301 *
  • uspace/drv/char/i8042/i8042.c

    rcb3dbb63 r70922c2  
    307307       
    308308        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);
    312311                        pio_write_8(&controller->regs->status,
    313312                            i8042_CMD_WRITE_AUX);
     313                }
    314314               
     315                wait_ready(controller);
    315316                pio_write_8(&controller->regs->data, buffer[i]);
    316317        }
  • uspace/drv/nic/e1k/e1k.c

    rcb3dbb63 r70922c2  
    14021402        fibril_mutex_unlock(&e1000->rx_lock);
    14031403        return EOK;
     1404       
    14041405error:
    14051406        for (i = 0; i < E1000_RX_FRAME_COUNT; i++) {
     
    14101411                }
    14111412        }
     1413       
    14121414        if (e1000->rx_frame_phys != NULL) {
    14131415                free(e1000->rx_frame_phys);
    14141416                e1000->rx_frame_phys = NULL;
    14151417        }
     1418       
    14161419        if (e1000->rx_frame_virt != NULL) {
    14171420                free(e1000->rx_frame_virt);
    14181421                e1000->rx_frame_phys = NULL;
    14191422        }
     1423       
    14201424        return rc;
    14211425}
     
    16421646                e1000->tx_frame_phys = NULL;
    16431647        }
     1648       
    16441649        dmamem_unmap_anonymous(e1000->tx_ring_virt);
    16451650}
     
    20522057        case E1000_82545:
    20532058        case E1000_82546:
    2054         case E1000_82572:
    20552059                e1000->info.eerd_start = 0x01;
    20562060                e1000->info.eerd_done = 0x10;
     
    20592063                break;
    20602064        case E1000_82547:
     2065        case E1000_82572:
    20612066        case E1000_80003ES2:
    20622067                e1000->info.eerd_start = 0x01;
  • uspace/drv/nic/lo/lo.c

    rcb3dbb63 r70922c2  
    127127        printf("%s: Adding loopback device '%s'\n", NAME, dev->name);
    128128        return EOK;
     129       
    129130error:
    130131        if (bound)
    131132                ddf_fun_unbind(fun);
     133       
    132134        if (fun != NULL)
    133135                ddf_fun_destroy(fun);
  • uspace/drv/nic/rtl8139/defs.h

    rcb3dbb63 r70922c2  
    2929/** @file rtl8139_defs.h
    3030 *
    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
    3738#include <sys/types.h>
    3839#include <libarch/ddi.h>
    3940
    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
    4952
    5053/** HW version
    5154 *
    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 */
     59typedef enum {
    5660        RTL8139 = 0,          /**< RTL8139 */
    5761        RTL8139A,             /**< RTL8139A */
     
    6670        RTL8101,              /**< RTL8101 */
    6771        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;
    7173
    7274/** Registers of RTL8139 family card offsets from the memory address base */
     
    7577        MAC0  = IDR0,    /**< Alias for IDR0 */
    7678
    77         // 0x6 - 0x7 reserved
     79        // 0x06 - 0x07 reserved
    7880
    7981        MAR0    = 0x08,  /**< Multicast mask registers 8 1b registers sequence */
     
    213215        pio_write_8(io_base + CR9346, RTL8139_REGS_LOCKED);
    214216}
     217
    215218/** Allow to change Config0-4 and BMCR register  */
    216219static inline void rtl8139_regs_unlock(void *io_base)
     
    417420
    418421/** Maximal runt frame size + 1 */
    419 #define RTL8139_RUNT_MAX_SIZE 64
     422#define RTL8139_RUNT_MAX_SIZE  64
    420423
    421424/** Bits in frame header */
     
    470473
    471474/** 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_id ver_id;  /**< appropriate version id */
     475struct rtl8139_hwver_map {
     476        uint32_t hwverid;             /**< HW version value in the register */
     477        rtl8139_version_id_t ver_id;  /**< appropriate version id */
    475478};
    476479
    477480/** Mapping of HW version -> version ID */
    478481extern const struct rtl8139_hwver_map rtl8139_versions[RTL8139_VER_COUNT + 1];
     482extern const char* model_names[RTL8139_VER_COUNT];
    479483
    480484/** 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
    482487/** The only supported pause frame time value */
    483 #define RTL8139_PAUSE_VAL UINT16_C(0xFFFF)
     488#define RTL8139_PAUSE_VAL  UINT16_C(0xFFFF)
    484489
    485490/** Size of the frame header in front of the received frame */
    486 #define RTL_FRAME_HEADER_SIZE 4
     491#define RTL_FRAME_HEADER_SIZE  4
    487492
    488493/** 8k buffer */
  • uspace/drv/nic/rtl8139/driver.c

    rcb3dbb63 r70922c2  
    5555/** Global mutex for work with shared irq structure */
    5656FIBRIL_MUTEX_INITIALIZE(irq_reg_lock);
     57
    5758/** 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
    5962/** 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)
    6165
    6266/** PCI clock frequency in kHz */
    63 #define RTL8139_PCI_FREQ_KHZ 33000
    64 
    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)
    6872
    6973/** 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 *
    7481 */
    7582inline static void rtl8139_lock_all(rtl8139_t *rtl8139)
     
    8289/** Unlock transmitter and receiver data
    8390 *
    84  *  @param rtl8139  RTL8139 private data
     91 * @param rtl8139 RTL8139 private data
     92 *
    8593 */
    8694inline static void rtl8139_unlock_all(rtl8139_t *rtl8139)
     
    457465        pio_write_32(tsd, tsd_value);
    458466        return;
    459 
     467       
    460468err_busy_no_inc:
    461469err_size:
     
    513521 *
    514522 * @return The frame list node (not connected)
     523 *
    515524 */
    516525static nic_frame_t *rtl8139_read_frame(nic_t *nic_data,
     
    12151224        ddf_msg(LVL_DEBUG, "The device is initialized");
    12161225        return ret;
    1217 
     1226       
    12181227failed:
    12191228        ddf_msg(LVL_ERROR, "The device initialization failed");
     
    13421351
    13431352        return EOK;
    1344 
     1353       
    13451354err_fun_bind:
    13461355        ddf_fun_unbind(fun);
  • uspace/drv/nic/rtl8139/driver.h

    rcb3dbb63 r70922c2  
    3030#define RTL8139_DRIVER_H_
    3131
     32#include <sys/types.h>
     33#include <stdint.h>
    3234#include "defs.h"
    3335#include "general.h"
    34 #include <sys/types.h>
    35 #include <stdint.h>
    3636
    3737/** The driver name */
    38 #define NAME "rtl8139"
     38#define NAME  "rtl8139"
     39
    3940/** Transmittion buffers count */
    40 #define TX_BUFF_COUNT 4
    41 /** Size of buffer for one frame
    42  *  - 2kB
    43  */
    44 #define TX_BUFF_SIZE (2 * 1024)
    45 /** Count of pages to allocate for TxBuffers */
    46 #define TX_PAGES 2
     41#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
    4748
    4849/** Size of the CRC after the received frame in the receiver buffer */
    49 #define RTL8139_CRC_SIZE 4
     50#define RTL8139_CRC_SIZE  4
    5051
    5152/** 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
    5355/** The default mode of accepting multicast frames */
    54 #define RTL8139_RCR_MCAST_DEFAULT 0
     56#define RTL8139_RCR_MCAST_DEFAULT  0
     57
    5558/** 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
    5761/** The default mode of accepting defect frames */
    58 #define RTL8139_RCR_DEFECT_DEFAULT 0
     62#define RTL8139_RCR_DEFECT_DEFAULT  0
    5963
    6064/** Mask for accepting all multicast */
    61 #define RTL8139_MCAST_MASK_PROMISC UINT64_MAX
    62 
    63 /** Data  */
     65#define RTL8139_MCAST_MASK_PROMISC  UINT64_MAX
     66
     67/** Data */
    6468struct rtl8139_rcr_data {
    6569        /** Configuration part of RCR */
     
    134138
    135139        /** Version of RT8139 controller */
    136         enum rtl8139_version_id hw_version;
     140        rtl8139_version_id_t hw_version;
    137141} rtl8139_t;
    138 
    139142
    140143/* ***** Pointers casting - for both amd64 and ia32 ***** */
     
    160163 */
    161164#define IOADDR_TO_PTR(ioaddr) ((void*)((size_t)(ioaddr)))
    162 
    163 
    164165
    165166/* ***** Bit operation macros ***** */
     
    177178 * @return New value
    178179 */
    179 #define bit_set_part_g( src, value, mask, type ) \
     180#define bit_set_part_g(src, value, mask, type) \
    180181        ((type)(((src) & ~((type)(mask))) | ((value) & (type)(mask))))
    181182
     
    237238        bit_set_part_32(tsd_value, (size) << TSD_SIZE_SHIFT, TSD_SIZE_MASK << TSD_SIZE_SHIFT)
    238239
    239 
    240240#endif
  • uspace/drv/nic/rtl8139/general.h

    rcb3dbb63 r70922c2  
    2929/** @file
    3030 *
    31  *  General functions and structures used in rtl8139 driver
     31 * General functions and structures used in rtl8139 driver
    3232 */
    3333
     
    3737#include <unistd.h>
    3838
    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
    4241
    4342/** Structure for HW timer control */
    44 typedef struct rtl8139_timer_act {
     43typedef struct {
    4544        /** Register value set in the last timer period */
    4645        uint32_t last_val;
     46       
    4747        /** Register value set in the common timer period */
    4848        uint32_t full_val;
    49 
     49       
    5050        /** Amount of full register periods in timer period */
    5151        size_t full_skips;
     52       
    5253        /** Remaining full register periods to the next period end */
    5354        size_t full_skips_remains;
     55       
    5456        /** Mark if there is a last run */
    5557        int last_run;
    5658} rtl8139_timer_act_t;
    5759
    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 
     60extern void *rtl8139_memcpy_wrapped(void *, const void *, size_t, size_t,
     61    size_t);
     62extern int rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t,
     63    const struct timeval *);
     64extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *);
    6565
    6666#endif
  • uspace/lib/c/generic/device/nic.c

    rcb3dbb63 r70922c2  
    8181 *
    8282 */
    83 int nic_callback_create(async_sess_t *dev_sess, nic_device_id_t device_id,
    84     async_client_conn_t cfun, void *carg)
     83int nic_callback_create(async_sess_t *dev_sess, async_client_conn_t cfun,
     84    void *carg)
    8585{
    8686        ipc_call_t answer;
     
    8989       
    9090        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);
    9393       
    9494        rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
  • uspace/lib/c/include/device/nic.h

    rcb3dbb63 r70922c2  
    9191
    9292extern 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 *);
     93extern int nic_callback_create(async_sess_t *, async_client_conn_t, void *);
    9594extern int nic_get_state(async_sess_t *, nic_device_state_t *);
    9695extern int nic_set_state(async_sess_t *, nic_device_state_t);
  • uspace/lib/c/include/net/device.h

    rcb3dbb63 r70922c2  
    4747#define DEVICE_MAP_IMPLEMENT  INT_MAP_IMPLEMENT
    4848
     49/** Device identifier type. */
     50typedef int nic_device_id_t;
     51
     52/** Invalid device identifier. */
     53#define NIC_DEVICE_INVALID_ID  (-1)
     54
    4955#endif
    5056
  • uspace/lib/c/include/nic/nic.h

    rcb3dbb63 r70922c2  
    6363#define NIC_MAX_ADDRESS_LENGTH  16
    6464
    65 /** Invalid device identifier. */
    66 #define NIC_DEVICE_INVALID_ID  (-1)
    67 
    6865#define NIC_VENDOR_MAX_LENGTH         64
    6966#define NIC_MODEL_MAX_LENGTH          64
     
    8683
    8784#define NIC_DEVICE_PRINT_FMT  "%x"
    88 
    89 /** Device identifier type. */
    90 typedef int nic_device_id_t;
    9185
    9286/**
  • uspace/lib/drv/Makefile

    rcb3dbb63 r70922c2  
    3535        generic/driver.c \
    3636        generic/dev_iface.c \
     37        generic/interrupt.c \
    3738        generic/log.c \
    3839        generic/logbuf.c \
  • uspace/lib/drv/generic/driver.c

    rcb3dbb63 r70922c2  
    7070FIBRIL_MUTEX_INITIALIZE(functions_mutex);
    7171
    72 /** Interrupts */
    73 static interrupt_context_list_t interrupt_contexts;
    74 
    75 static irq_cmd_t default_cmds[] = {
    76         {
    77                 .cmd = CMD_ACCEPT
    78         }
    79 };
    80 
    81 static irq_code_t default_pseudocode = {
    82         sizeof(default_cmds) / sizeof(irq_cmd_t),
    83         default_cmds
    84 };
    85 
    8672static ddf_dev_t *create_device(void);
    8773static void delete_device(ddf_dev_t *);
     
    9278static remote_handler_t *function_get_default_handler(ddf_fun_t *);
    9379static 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 void
    130 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 int
    186 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 }
    22280
    22381static void add_to_functions_list(ddf_fun_t *fun)
     
    737595
    738596/** Allocate driver-specific device data. */
    739 extern void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size)
     597void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size)
    740598{
    741599        void *data;
     
    799657
    800658/** Allocate driver-specific function data. */
    801 extern void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size)
     659void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size)
    802660{
    803661        void *data;
     
    992850        driver = drv;
    993851       
    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();
    999854       
    1000855        /*
  • uspace/lib/drv/generic/remote_nic.c

    rcb3dbb63 r70922c2  
    6969        assert(nic_iface->callback_create);
    7070       
    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);
    7472        async_answer_0(callid, rc);
    7573}
  • uspace/lib/drv/include/ddf/interrupt.h

    rcb3dbb63 r70922c2  
    6464} interrupt_context_list_t;
    6565
    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 
     66extern void interrupt_init(void);
    7867extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
    7968    irq_code_t *);
  • uspace/lib/drv/include/ops/nic.h

    rcb3dbb63 r70922c2  
    4646        /** Mandatory methods */
    4747        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 *);
    4949        int (*get_state)(ddf_fun_t *, nic_device_state_t *);
    5050        int (*set_state)(ddf_fun_t *, nic_device_state_t);
  • uspace/lib/drv/include/usbhc_iface.h

    rcb3dbb63 r70922c2  
    2727 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828 */
     29
    2930/** @addtogroup libdrv
    3031 * @addtogroup usb
    3132 * @{
    3233 */
     34
    3335/** @file
    3436 * @brief USB host controller interface definition.
  • uspace/lib/nic/include/nic_driver.h

    rcb3dbb63 r70922c2  
    7070         */
    7171        ddf_fun_t *fun;
    72         /** Identifier for higher network stack layers */
    73         nic_device_id_t device_id;
    7472        /** Current state of the device */
    7573        nic_device_state_t state;
  • uspace/lib/nic/include/nic_ev.h

    rcb3dbb63 r70922c2  
    4343#include <sys/types.h>
    4444
    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);
     45extern int nic_ev_addr_changed(async_sess_t *, const nic_address_t *);
     46extern int nic_ev_device_state(async_sess_t *, sysarg_t);
     47extern int nic_ev_received(async_sess_t *, void *, size_t);
    4948
    5049#endif
  • uspace/lib/nic/include/nic_impl.h

    rcb3dbb63 r70922c2  
    4848extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address);
    4949extern 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);
     50extern int nic_callback_create_impl(ddf_fun_t *dev_fun);
    5151extern int nic_get_state_impl(ddf_fun_t *dev_fun, nic_device_state_t *state);
    5252extern int nic_set_state_impl(ddf_fun_t *dev_fun, nic_device_state_t state);
  • uspace/lib/nic/src/nic_driver.c

    rcb3dbb63 r70922c2  
    497497        if (nic_data->client_session != NULL) {
    498498                int rc = nic_ev_addr_changed(nic_data->client_session,
    499                     nic_data->device_id, address);
     499                    address);
    500500                if (rc != EOK) {
    501501                        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    604604                }
    605605                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);
    608608        } else {
    609609                switch (frame_type) {
     
    639639        fibril_rwlock_write_unlock(&nic_data->stats_lock);
    640640       
    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);
    643642}
    644643
     
    691690        nic_data->dev = NULL;
    692691        nic_data->fun = NULL;
    693         nic_data->device_id = NIC_DEVICE_INVALID_ID;
    694692        nic_data->state = NIC_STATE_STOPPED;
    695693        nic_data->client_session = NULL;
  • uspace/lib/nic/src/nic_ev.c

    rcb3dbb63 r70922c2  
    4242
    4343/** 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)
     44int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr)
    4645{
    4746        async_exch_t *exch = async_exchange_begin(sess);
    4847
    4948        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);
    5250        sysarg_t retval = async_data_write_start(exch, addr,
    5351            sizeof(nic_address_t));
     
    6563
    6664/** Device state changed. */
    67 extern int nic_ev_device_state(async_sess_t *sess, nic_device_id_t dev_id,
    68     sysarg_t state)
     65int nic_ev_device_state(async_sess_t *sess, sysarg_t state)
    6966{
    7067        int rc;
    7168
    7269        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);
    7471        async_exchange_end(exch);
    7572
     
    7875
    7976/** Frame received. */
    80 int nic_ev_received(async_sess_t *sess, nic_device_id_t dev_id, void *data,
    81     size_t size)
     77int nic_ev_received(async_sess_t *sess, void *data, size_t size)
    8278{
    8379        async_exch_t *exch = async_exchange_begin(sess);
    8480
    8581        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);
    8883        sysarg_t retval = async_data_write_start(exch, data, size);
    8984
  • uspace/lib/nic/src/nic_impl.c

    rcb3dbb63 r70922c2  
    8787        }
    8888        if (state == NIC_STATE_ACTIVE) {
    89                 if (nic_data->client_session == NULL || nic_data->device_id < 0) {
     89                if (nic_data->client_session == NULL) {
    9090                        fibril_rwlock_write_unlock(&nic_data->main_lock);
    9191                        return EINVAL;
     
    118118                /* Notify upper layers that we are reseting the MAC */
    119119                int rc = nic_ev_addr_changed(nic_data->client_session,
    120                         nic_data->device_id, &nic_data->default_mac);
     120                        &nic_data->default_mac);
    121121                nic_data->poll_mode = nic_data->default_poll_mode;
    122122                memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
     
    150150        nic_data->state = state;
    151151
    152         nic_ev_device_state(nic_data->client_session, nic_data->device_id, state);
     152        nic_ev_device_state(nic_data->client_session, state);
    153153
    154154        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    187187 *
    188188 * @param       fun
    189  * @param       device_id       ID of the device as used in higher layers
    190189 *
    191190 * @return EOK          On success, or negative error code.
    192191 */
    193 int nic_callback_create_impl(ddf_fun_t *fun, nic_device_id_t device_id)
     192int nic_callback_create_impl(ddf_fun_t *fun)
    194193{
    195194        nic_t *nic = (nic_t *) fun->driver_data;
    196195        fibril_rwlock_write_lock(&nic->main_lock);
    197        
    198         nic->device_id = device_id;
    199196       
    200197        nic->client_session = async_callback_receive(EXCHANGE_SERIALIZE);
  • uspace/lib/posix/ctype.c

    rcb3dbb63 r70922c2  
    112112 * @return Non-zero if character match the definition, zero otherwise.
    113113 */
    114 extern int posix_isascii(int c)
     114int posix_isascii(int c)
    115115{
    116116        return c >= 0 && c < 128;
     
    123123 * @return Coverted character.
    124124 */
    125 extern int posix_toascii(int c)
     125int posix_toascii(int c)
    126126{
    127127        return c & 0x7F;
  • uspace/srv/loc/loc.c

    rcb3dbb63 r70922c2  
    813813 * On success, answer will contain EOK int retval.
    814814 * On failure, error code will be sent in retval.
     815 *
    815816 */
    816817static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall)
    817818{
    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));
    821820        if (cb_sess == NULL) {
    822821                async_answer_0(iid, ENOMEM);
  • uspace/srv/net/net/net.h

    rcb3dbb63 r70922c2  
    9696       
    9797        /** 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. */
    100100       
    101101        module_t *nil;  /**< Serving link layer module index. */
  • uspace/srv/net/nil/eth/eth.c

    rcb3dbb63 r70922c2  
    173173    void *arg);
    174174
    175 static int eth_device_state(nic_device_id_t device_id, sysarg_t state)
     175static int eth_device_state(eth_device_t *device, sysarg_t state)
    176176{
    177177        int index;
     
    183183                proto = eth_protos_get_index(&eth_globals.protos, index);
    184184                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);
    187187                }
    188188        }
     
    347347        }
    348348       
    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);
    351350        if (rc != EOK) {
    352351                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
     
    825824}
    826825
    827 static int eth_received(nic_device_id_t device_id)
     826static int eth_received(eth_device_t *device)
    828827{
    829828        void *data;
     
    845844        free(data);
    846845       
    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
     849static int eth_addr_changed(eth_device_t *device)
    851850{
    852851        nic_address_t address;
     
    866865
    867866        fibril_rwlock_write_lock(&eth_globals.devices_lock);
    868         /* An existing device? */
    869         eth_device_t *device = eth_devices_find(&eth_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(&eth_globals.devices_lock);
    875 
    876                 /* Notify all upper layer modules */
    877                 fibril_rwlock_read_lock(&eth_globals.protos_lock);
    878                 int index;
    879                 for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
    880                         eth_proto_t *proto = eth_protos_get_index(&eth_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(&eth_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(&eth_globals.devices_lock);
     873
     874        /* Notify all upper layer modules */
     875        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     876        int index;
     877        for (index = 0; index < eth_protos_count(&eth_globals.protos); index++) {
     878                eth_proto_t *proto = eth_protos_get_index(&eth_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(&eth_globals.protos_lock);
     886        return EOK;
    892887}
    893888
     
    962957static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    963958{
     959        eth_device_t *device = (eth_device_t *)arg;
    964960        int rc;
    965961       
     
    975971                switch (IPC_GET_IMETHOD(call)) {
    976972                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));
    979974                        async_answer_0(callid, (sysarg_t) rc);
    980975                        break;
    981976                case NIC_EV_RECEIVED:
    982                         rc = eth_received(IPC_GET_ARG1(call));
     977                        rc = eth_received(device);
    983978                        async_answer_0(callid, (sysarg_t) rc);
    984979                        break;
    985980                case NIC_EV_ADDR_CHANGED:
    986                         rc = eth_addr_changed(IPC_GET_ARG1(call));
     981                        rc = eth_addr_changed(device);
    987982                        async_answer_0(callid, (sysarg_t) rc);
    988983                        break;
  • uspace/srv/net/nil/nildummy/nildummy.c

    rcb3dbb63 r70922c2  
    7373    void *arg);
    7474
    75 static int nildummy_device_state(nic_device_id_t device_id, sysarg_t state)
     75static int nildummy_device_state(nildummy_device_t *device, sysarg_t state)
    7676{
    7777        fibril_rwlock_read_lock(&nildummy_globals.protos_lock);
    7878        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);
    8181        fibril_rwlock_read_unlock(&nildummy_globals.protos_lock);
    8282       
     
    8484}
    8585
    86 static int nildummy_addr_changed(nic_device_id_t device_id)
     86static int nildummy_addr_changed(nildummy_device_t *device)
    8787{
    8888        return ENOTSUP;
     
    182182        }
    183183       
    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);
    186186        if (rc != EOK) {
    187187                async_hangup(device->sess);
     
    360360    services_t sender)
    361361{
    362         packet_t *p;
    363        
    364362        fibril_rwlock_read_lock(&nildummy_globals.devices_lock);
    365363       
     
    371369        }
    372370       
    373         p = packet;
     371        packet_t *p = packet;
    374372        do {
    375373                nic_send_frame(device->sess, packet_get_data(p),
     
    385383}
    386384
    387 static int nildummy_received(nic_device_id_t device_id)
     385static int nildummy_received(nildummy_device_t *device)
    388386{
    389387        void *data;
     
    403401        free(pdata);
    404402
    405         return nil_received_msg_local(device_id, packet);
     403        return nil_received_msg_local(device->device_id, packet);
    406404}
    407405
     
    467465static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    468466{
     467        nildummy_device_t *device = (nildummy_device_t *)arg;
    469468        int rc;
    470469       
     
    480479                switch (IPC_GET_IMETHOD(call)) {
    481480                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));
    484482                        async_answer_0(callid, (sysarg_t) rc);
    485483                        break;
    486484                case NIC_EV_RECEIVED:
    487                         rc = nildummy_received(IPC_GET_ARG1(call));
     485                        rc = nildummy_received(device);
    488486                        async_answer_0(callid, (sysarg_t) rc);
    489487                        break;
    490488                case NIC_EV_ADDR_CHANGED:
    491                         rc = nildummy_addr_changed(IPC_GET_ARG1(call));
     489                        rc = nildummy_addr_changed(device);
    492490                        async_answer_0(callid, (sysarg_t) rc);
    493491                        break;
Note: See TracChangeset for help on using the changeset viewer.