Changeset 8e7c9fe in mainline for uspace/lib/drv


Ignore:
Timestamp:
2014-09-12T03:45:25Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c53b58e
Parents:
3eb0c85 (diff), 105d8d6 (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:

merge mainline changes

most usb changes were reverted. blink and usbmass were fixed
known problems:
ehci won't initialize
usbmast asserts on unmount (happens on mainline too)

Location:
uspace/lib/drv
Files:
10 edited
3 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/Makefile

    r3eb0c85 r8e7c9fe  
    4747        generic/remote_pio_window.c \
    4848        generic/remote_char_dev.c \
    49         generic/remote_graph_dev.c \
    5049        generic/remote_nic.c \
    5150        generic/remote_usb.c \
     
    5453        generic/remote_usbhid.c \
    5554        generic/remote_clock_dev.c \
     55        generic/remote_led_dev.c \
    5656        generic/remote_battery_dev.c \
    5757        generic/remote_ahci.c
  • uspace/lib/drv/generic/dev_iface.c

    r3eb0c85 r8e7c9fe  
    4343#include "remote_char_dev.h"
    4444#include "remote_clock_dev.h"
     45#include "remote_led_dev.h"
    4546#include "remote_battery_dev.h"
    46 #include "remote_graph_dev.h"
    4747#include "remote_nic.h"
    4848#include "remote_usb.h"
     
    6161                [PIO_WINDOW_DEV_IFACE] = &remote_pio_window_iface,
    6262                [CHAR_DEV_IFACE] = &remote_char_dev_iface,
    63                 [GRAPH_DEV_IFACE] = &remote_graph_dev_iface,
    6463                [NIC_DEV_IFACE] = &remote_nic_iface,
    6564                [PCI_DEV_IFACE] = &remote_pci_iface,
     
    6867                [USBHID_DEV_IFACE] = &remote_usbhid_iface,
    6968                [CLOCK_DEV_IFACE] = &remote_clock_dev_iface,
     69                [LED_DEV_IFACE] = &remote_led_dev_iface,
    7070                [BATTERY_DEV_IFACE] = &remote_battery_dev_iface,
    7171                [AHCI_DEV_IFACE] = &remote_ahci_iface,
  • uspace/lib/drv/generic/driver.c

    r3eb0c85 r8e7c9fe  
    3636/** @file
    3737 */
    38 
    39 #define _DDF_DATA_IMPLANT
    4038
    4139#include <assert.h>
     
    596594}
    597595
    598 /** Implant foreign driver-specific device data.
    599  *
    600  * XXX This is used to transition USB to new interface. Do not use
    601  * in new code. Use of this function must be removed.
    602  */
    603 void ddf_fun_data_implant(ddf_fun_t *fun, void *data)
    604 {
    605         assert(fun->driver_data == NULL);
    606         fun->driver_data = data;
    607 }
    608 
    609596/** Return driver-specific device data. */
    610597void *ddf_dev_data_get(ddf_dev_t *dev)
     
    964951         */
    965952        driver = drv;
    966        
    967         /* Initialize interrupt module */
    968         interrupt_init();
    969953       
    970954        /*
  • uspace/lib/drv/generic/interrupt.c

    r3eb0c85 r8e7c9fe  
    4444#include "private/driver.h"
    4545
    46 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall);
    47 static interrupt_context_t *create_interrupt_context(void);
    48 static void delete_interrupt_context(interrupt_context_t *ctx);
    49 static void init_interrupt_context_list(interrupt_context_list_t *list);
    50 static void add_interrupt_context(interrupt_context_list_t *list,
    51     interrupt_context_t *ctx);
    52 static void remove_interrupt_context(interrupt_context_list_t *list,
    53     interrupt_context_t *ctx);
    54 static interrupt_context_t *find_interrupt_context_by_id(
    55     interrupt_context_list_t *list, int id);
    56 static interrupt_context_t *find_interrupt_context(
    57     interrupt_context_list_t *list, ddf_dev_t *dev, int irq);
    58 
    59 /** Interrupts */
    60 static interrupt_context_list_t interrupt_contexts;
    61 
    6246static irq_cmd_t default_cmds[] = {
    6347        {
     
    7357};
    7458
    75 void interrupt_init(void)
    76 {
    77         /* Initialize the list of interrupt contexts. */
    78         init_interrupt_context_list(&interrupt_contexts);
    79        
    80         /* Set generic interrupt handler. */
    81         async_set_interrupt_received(driver_irq_handler);
    82 }
    83 
    84 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
    85 {
    86         int id = (int)IPC_GET_IMETHOD(*icall);
    87         interrupt_context_t *ctx;
    88        
    89         ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
    90         if (ctx != NULL && ctx->handler != NULL)
    91                 (*ctx->handler)(ctx->dev, iid, icall);
    92 }
    93 
    94 static interrupt_context_t *create_interrupt_context(void)
    95 {
    96         interrupt_context_t *ctx;
    97        
    98         ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
    99         if (ctx != NULL)
    100                 memset(ctx, 0, sizeof(interrupt_context_t));
    101        
    102         return ctx;
    103 }
    104 
    105 static void delete_interrupt_context(interrupt_context_t *ctx)
    106 {
    107         if (ctx != NULL)
    108                 free(ctx);
    109 }
    110 
    111 static void init_interrupt_context_list(interrupt_context_list_t *list)
    112 {
    113         memset(list, 0, sizeof(interrupt_context_list_t));
    114         fibril_mutex_initialize(&list->mutex);
    115         list_initialize(&list->contexts);
    116 }
    117 
    118 static void add_interrupt_context(interrupt_context_list_t *list,
    119     interrupt_context_t *ctx)
    120 {
    121         fibril_mutex_lock(&list->mutex);
    122         ctx->id = list->curr_id++;
    123         list_append(&ctx->link, &list->contexts);
    124         fibril_mutex_unlock(&list->mutex);
    125 }
    126 
    127 static void remove_interrupt_context(interrupt_context_list_t *list,
    128     interrupt_context_t *ctx)
    129 {
    130         fibril_mutex_lock(&list->mutex);
    131         list_remove(&ctx->link);
    132         fibril_mutex_unlock(&list->mutex);
    133 }
    134 
    135 static interrupt_context_t *find_interrupt_context_by_id(
    136     interrupt_context_list_t *list, int id)
    137 {
    138         fibril_mutex_lock(&list->mutex);
    139        
    140         list_foreach(list->contexts, link, interrupt_context_t, ctx) {
    141                 if (ctx->id == id) {
    142                         fibril_mutex_unlock(&list->mutex);
    143                         return ctx;
    144                 }
    145         }
    146        
    147         fibril_mutex_unlock(&list->mutex);
    148         return NULL;
    149 }
    150 
    151 static interrupt_context_t *find_interrupt_context(
    152     interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
    153 {
    154         fibril_mutex_lock(&list->mutex);
    155        
    156         list_foreach(list->contexts, link, interrupt_context_t, ctx) {
    157                 if (ctx->irq == irq && ctx->dev == dev) {
    158                         fibril_mutex_unlock(&list->mutex);
    159                         return ctx;
    160                 }
    161         }
    162        
    163         fibril_mutex_unlock(&list->mutex);
    164         return NULL;
    165 }
    166 
    167 
    16859int register_interrupt_handler(ddf_dev_t *dev, int irq,
    16960    interrupt_handler_t *handler, const irq_code_t *pseudocode)
    17061{
    171         interrupt_context_t *ctx = create_interrupt_context();
    172        
    173         ctx->dev = dev;
    174         ctx->irq = irq;
    175         ctx->handler = handler;
    176        
    177         add_interrupt_context(&interrupt_contexts, ctx);
    178        
    179         if (pseudocode == NULL)
    180                 pseudocode = &default_pseudocode;
    181        
    182         int res = irq_register(irq, dev->handle, ctx->id, pseudocode);
    183         if (res != EOK) {
    184                 remove_interrupt_context(&interrupt_contexts, ctx);
    185                 delete_interrupt_context(ctx);
    186         }
    187        
    188         return res;
     62        return async_irq_subscribe(irq, dev->handle,
     63            (async_notification_handler_t) handler, dev, pseudocode);
    18964}
    19065
    19166int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
    19267{
    193         interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
    194             dev, irq);
    195         int res = irq_unregister(irq, dev->handle);
    196        
    197         if (ctx != NULL) {
    198                 remove_interrupt_context(&interrupt_contexts, ctx);
    199                 delete_interrupt_context(ctx);
    200         }
    201        
    202         return res;
     68        return async_irq_unsubscribe(irq, dev->handle);
    20369}
    20470
  • uspace/lib/drv/generic/private/remote_led_dev.h

    r3eb0c85 r8e7c9fe  
    11/*
    2  * Copyright (c) 2011 Petr Koupy
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    3333 */
    3434
    35 #ifndef LIBDRV_REMOTE_GRAPH_DEV_H_
    36 #define LIBDRV_REMOTE_GRAPH_DEV_H_
     35#ifndef LIBDRV_REMOTE_LED_DEV_H_
     36#define LIBDRV_REMOTE_LED_DEV_H_
    3737
    38 extern remote_iface_t remote_graph_dev_iface;
     38extern remote_iface_t remote_led_dev_iface;
    3939
    4040#endif
     
    4343 * @}
    4444 */
     45
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r3eb0c85 r8e7c9fe  
    3838#include <macros.h>
    3939#include <str.h>
    40 #include <sys/mman.h>
     40#include <as.h>
    4141
    4242#include "audio_pcm_iface.h"
  • uspace/lib/drv/generic/remote_led_dev.c

    r3eb0c85 r8e7c9fe  
    11/*
    2  * Copyright (c) 2011 Petr Koupy
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    3333 */
    3434
     35#include <async.h>
    3536#include <errno.h>
    36 #include <async.h>
     37#include <io/pixel.h>
    3738#include <macros.h>
     39#include <device/led_dev.h>
     40#include <ops/led_dev.h>
     41#include <ddf/driver.h>
    3842
    39 #include "ops/graph_dev.h"
    40 #include "graph_iface.h"
    41 #include "ddf/driver.h"
     43static void remote_led_color_set(ddf_fun_t *, void *, ipc_callid_t,
     44    ipc_call_t *);
    4245
    43 typedef enum {
    44         GRAPH_DEV_CONNECT = 0
    45 } graph_dev_method_t;
    46 
    47 int graph_dev_connect(async_sess_t *sess)
    48 {
    49         async_exch_t *exch = async_exchange_begin(sess);
    50         int ret = async_req_1_0(exch, DEV_IFACE_ID(GRAPH_DEV_IFACE), GRAPH_DEV_CONNECT);
    51         async_exchange_end(exch);
    52 
    53         return ret;
    54 }
    55 
    56 static void remote_graph_connect(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    57 
    58 static const remote_iface_func_ptr_t remote_graph_dev_iface_ops[] = {
    59         [GRAPH_DEV_CONNECT] = remote_graph_connect
     46/** Remote LED interface operations */
     47static const remote_iface_func_ptr_t remote_led_dev_iface_ops[] = {
     48        [LED_DEV_COLOR_SET] = remote_led_color_set
    6049};
    6150
    62 const remote_iface_t remote_graph_dev_iface = {
    63         .method_count = ARRAY_SIZE(remote_graph_dev_iface_ops),
    64         .methods = remote_graph_dev_iface_ops
     51/** Remote LED interface structure
     52 *
     53 * Interface for processing requests from remote clients
     54 * addressed by the LED interface.
     55 *
     56 */
     57const remote_iface_t remote_led_dev_iface = {
     58        .method_count = ARRAY_SIZE(remote_led_dev_iface_ops),
     59        .methods = remote_led_dev_iface_ops
    6560};
    6661
    67 static void remote_graph_connect(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
     62/** Process the color_set() request from the remote client
     63 *
     64 * @param fun The function to which the data are written
     65 * @param ops The local ops structure
     66 *
     67 */
     68static void remote_led_color_set(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
    6869    ipc_call_t *call)
    6970{
    70         graph_dev_ops_t *graph_dev_ops = (graph_dev_ops_t *) ops;
    71 
    72         if (!graph_dev_ops->connect || !ddf_fun_data_get(fun)) {
     71        led_dev_ops_t *led_dev_ops = (led_dev_ops_t *) ops;
     72        pixel_t color = DEV_IPC_GET_ARG1(*call);
     73       
     74        if (!led_dev_ops->color_set) {
    7375                async_answer_0(callid, ENOTSUP);
    7476                return;
    7577        }
    76 
    77         (*graph_dev_ops->connect)(ddf_fun_data_get(fun), callid, call, NULL);
     78       
     79        int rc = (*led_dev_ops->color_set)(fun, color);
     80        async_answer_0(callid, rc);
    7881}
    7982
  • uspace/lib/drv/generic/remote_nic.c

    r3eb0c85 r8e7c9fe  
    288288        async_exch_t *exch = async_exchange_begin(dev_sess);
    289289       
    290         int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    291             NIC_GET_DEVICE_INFO);
    292         if (rc != EOK) {
    293                 async_exchange_end(exch);
     290        aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     291            NIC_GET_DEVICE_INFO, NULL);
     292        int rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
     293        async_exchange_end(exch);
     294
     295        sysarg_t res;
     296        async_wait_for(aid, &res);
     297       
     298        if (rc != EOK)
    294299                return rc;
    295         }
    296        
    297         rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
    298        
    299         async_exchange_end(exch);
    300        
    301         return rc;
     300       
     301        return (int) res;
    302302}
    303303
  • uspace/lib/drv/generic/remote_usbhc.c

    r3eb0c85 r8e7c9fe  
    212212static void async_transaction_destroy(async_transaction_t *trans)
    213213{
    214         if (trans == NULL) {
    215                 return;
    216         }
    217         if (trans->buffer != NULL) {
     214        if (trans == NULL)
     215                return;
     216       
     217        if (trans->buffer != NULL)
    218218                free(trans->buffer);
    219         }
    220 
     219       
    221220        free(trans);
    222221}
     
    304303                async_answer_0(callid, ENOMEM);
    305304                async_transaction_destroy(trans);
     305                return;
    306306        }
    307307
  • uspace/lib/drv/include/ddf/driver.h

    r3eb0c85 r8e7c9fe  
    111111} driver_t;
    112112
    113 /** XXX Only to transition network drivers */
    114 #ifdef _DDF_DATA_IMPLANT
    115 extern void ddf_fun_data_implant(ddf_fun_t *, void *);
    116 #endif
    117 
    118113extern int ddf_driver_main(const driver_t *);
    119114
  • uspace/lib/drv/include/ddf/interrupt.h

    r3eb0c85 r8e7c9fe  
    4949 */
    5050
    51 typedef void interrupt_handler_t(ddf_dev_t *, ipc_callid_t, ipc_call_t *);
     51typedef void interrupt_handler_t(ipc_callid_t, ipc_call_t *, ddf_dev_t *);
    5252
    53 typedef struct interrupt_context {
    54         int id;
    55         ddf_dev_t *dev;
    56         int irq;
    57         interrupt_handler_t *handler;
    58         link_t link;
    59 } interrupt_context_t;
    60 
    61 typedef struct interrupt_context_list {
    62         int curr_id;
    63         list_t contexts;
    64         fibril_mutex_t mutex;
    65 } interrupt_context_list_t;
    66 
    67 extern void interrupt_init(void);
    6853extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
    6954    const irq_code_t *);
  • uspace/lib/drv/include/ops/led_dev.h

    r3eb0c85 r8e7c9fe  
    11/*
    2  * Copyright (c) 2011 Petr Koupy
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    3333 */
    3434
    35 #ifndef LIBDRV_OPS_GRAPH_DEV_H_
    36 #define LIBDRV_OPS_GRAPH_DEV_H_
     35#ifndef LIBDRV_OPS_LED_DEV_H_
     36#define LIBDRV_OPS_LED_DEV_H_
    3737
    38 #include <async.h>
     38#include <io/pixel.h>
    3939#include "../ddf/driver.h"
    4040
    41 typedef void (*connect_func)(void *, ipc_callid_t , ipc_call_t *, void *);
    42 
    4341typedef struct {
    44         connect_func connect;
    45 } graph_dev_ops_t;
     42        int (*color_set)(ddf_fun_t *, pixel_t);
     43} led_dev_ops_t;
    4644
    4745#endif
  • uspace/lib/drv/include/pci_dev_iface.h

    r3eb0c85 r8e7c9fe  
    4040#include "ddf/driver.h"
    4141
     42#define PCI_VENDOR_ID  0x00
    4243#define PCI_DEVICE_ID  0x02
    4344
Note: See TracChangeset for help on using the changeset viewer.