Changeset 03362fbd in mainline for uspace/lib/drv/generic


Ignore:
Timestamp:
2013-02-09T23:14:45Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
22dfd38
Parents:
b5d2e57 (diff), 005b765 (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.

Conflict resulting from bool.h → stdbool.h move and ddf structs turning opaque.
Fails to boot to shell console.

Location:
uspace/lib/drv/generic
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/dev_iface.c

    rb5d2e57 r03362fbd  
    4141#include "remote_hw_res.h"
    4242#include "remote_char_dev.h"
     43#include "remote_clock_dev.h"
     44#include "remote_battery_dev.h"
     45#include "remote_graph_dev.h"
    4346#include "remote_nic.h"
    4447#include "remote_usb.h"
     
    5659                [HW_RES_DEV_IFACE] = &remote_hw_res_iface,
    5760                [CHAR_DEV_IFACE] = &remote_char_dev_iface,
     61                [GRAPH_DEV_IFACE] = &remote_graph_dev_iface,
    5862                [NIC_DEV_IFACE] = &remote_nic_iface,
    5963                [PCI_DEV_IFACE] = &remote_pci_iface,
     
    6165                [USBHC_DEV_IFACE] = &remote_usbhc_iface,
    6266                [USBHID_DEV_IFACE] = &remote_usbhid_iface,
     67                [CLOCK_DEV_IFACE] = &remote_clock_dev_iface,
     68                [BATTERY_DEV_IFACE] = &remote_battery_dev_iface,
    6369                [AHCI_DEV_IFACE] = &remote_ahci_iface,
    6470        }
  • uspace/lib/drv/generic/driver.c

    rb5d2e57 r03362fbd  
    3737 */
    3838
     39#define _DDF_DATA_IMPLANT
     40
    3941#include <assert.h>
    4042#include <ipc/services.h>
     
    4345#include <stdio.h>
    4446#include <errno.h>
    45 #include <bool.h>
     47#include <stdbool.h>
    4648#include <fibril_synch.h>
    4749#include <stdlib.h>
     
    5860#include "ddf/driver.h"
    5961#include "ddf/interrupt.h"
     62#include "private/driver.h"
    6063
    6164/** Driver structure */
     
    523526static void delete_device(ddf_dev_t *dev)
    524527{
     528        if (dev->parent_sess)
     529                async_hangup(dev->parent_sess);
    525530        if (dev->driver_data != NULL)
    526531                free(dev->driver_data);
     
    597602}
    598603
     604/** Implant foreign driver-specific device data.
     605 *
     606 * XXX This is used to transition USB to new interface. Do not use
     607 * in new code. Use of this function must be removed.
     608 */
     609void ddf_fun_data_implant(ddf_fun_t *fun, void *data)
     610{
     611        assert(fun->driver_data == NULL);
     612        fun->driver_data = data;
     613}
     614
     615/** Return driver-specific device data. */
     616void *ddf_dev_data_get(ddf_dev_t *dev)
     617{
     618        return dev->driver_data;
     619}
     620
     621/** Get device handle. */
     622devman_handle_t ddf_dev_get_handle(ddf_dev_t *dev)
     623{
     624        return dev->handle;
     625}
     626
     627/** Return device name.
     628 *
     629 * @param dev   Device
     630 * @return      Device name. Valid as long as @a dev is valid.
     631 */
     632const char *ddf_dev_get_name(ddf_dev_t *dev)
     633{
     634        return dev->name;
     635}
     636
     637/** Create session with the parent function.
     638 *
     639 * The session will be automatically closed when @a dev is destroyed.
     640 *
     641 * @param dev   Device
     642 * @param mgmt  Exchange management style
     643 * @return      New session or NULL if session could not be created
     644 */
     645async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)
     646{
     647        assert(dev->parent_sess == NULL);
     648        dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,
     649            IPC_FLAG_BLOCKING);
     650
     651        return dev->parent_sess;
     652}
     653
     654/** Return existing session with the parent function.
     655 *
     656 * @param dev   Device
     657 * @return      Existing session or NULL if there is no session
     658 */
     659async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *dev)
     660{
     661        return dev->parent_sess;
     662}
     663
     664/** Set function name (if it was not specified when node was created.)
     665 *
     666 * @param dev   Device whose name has not been set yet
     667 * @param name  Name, will be copied
     668 * @return      EOK on success, ENOMEM if out of memory
     669 */
     670int ddf_fun_set_name(ddf_fun_t *dev, const char *name)
     671{
     672        assert(dev->name == NULL);
     673
     674        dev->name = str_dup(name);
     675        if (dev->name == NULL)
     676                return ENOENT;
     677
     678        return EOK;
     679}
     680
     681/** Get device to which function belongs. */
     682ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *fun)
     683{
     684        return fun->dev;
     685}
     686
     687/** Get function handle.
     688 *
     689 * XXX USB uses this, but its use should be eliminated.
     690 */
     691devman_handle_t ddf_fun_get_handle(ddf_fun_t *fun)
     692{
     693        return fun->handle;
     694}
     695
    599696/** Create a DDF function node.
    600697 *
     
    608705 * This function should only fail if there is not enough free memory.
    609706 * Specifically, this function succeeds even if @a dev already has
    610  * a (bound) function with the same name.
     707 * a (bound) function with the same name. @a name can be NULL in which
     708 * case the caller will set the name later using ddf_fun_set_name().
     709 * He must do this before binding the function.
    611710 *
    612711 * Type: A function of type fun_inner indicates that DDF should attempt
     
    616715 * @param dev           Device to which we are adding function
    617716 * @param ftype         Type of function (fun_inner or fun_exposed)
    618  * @param name          Name of function
     717 * @param name          Name of function or NULL
    619718 *
    620719 * @return              New function or @c NULL if memory is not available
     
    633732        fun->ftype = ftype;
    634733       
    635         fun->name = str_dup(name);
    636         if (fun->name == NULL) {
    637                 delete_function(fun);
    638                 return NULL;
     734        if (name != NULL) {
     735                fun->name = str_dup(name);
     736                if (fun->name == NULL) {
     737                        delete_function(fun);
     738                        return NULL;
     739                }
    639740        }
    640741       
     
    654755        fun->driver_data = data;
    655756        return data;
     757}
     758
     759/** Return driver-specific function data. */
     760void *ddf_fun_data_get(ddf_fun_t *fun)
     761{
     762        return fun->driver_data;
     763}
     764
     765/** Return function name.
     766 *
     767 * @param fun   Function
     768 * @return      Function name. Valid as long as @a fun is valid.
     769 */
     770const char *ddf_fun_get_name(ddf_fun_t *fun)
     771{
     772        return fun->name;
    656773}
    657774
     
    805922        add_match_id(&fun->match_ids, match_id);
    806923        return EOK;
     924}
     925
     926/** Set function ops. */
     927void ddf_fun_set_ops(ddf_fun_t *fun, ddf_dev_ops_t *dev_ops)
     928{
     929        assert(fun->conn_handler == NULL);
     930        fun->ops = dev_ops;
     931}
     932
     933/** Set user-defined connection handler.
     934 *
     935 * This allows handling connections the non-devman way.
     936 */
     937void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn)
     938{
     939        assert(fun->ops == NULL);
     940        fun->conn_handler = conn;
    807941}
    808942
  • uspace/lib/drv/generic/interrupt.c

    rb5d2e57 r03362fbd  
    4141
    4242#include "ddf/interrupt.h"
     43#include "private/driver.h"
    4344
    4445static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall);
  • uspace/lib/drv/generic/log.c

    rb5d2e57 r03362fbd  
    3838 *
    3939 * @param drv_name Driver name, will be printed as part of message
    40  * @param level    Minimum message level to print
    4140 *
    4241 */
    43 int ddf_log_init(const char *drv_name, log_level_t level)
     42int ddf_log_init(const char *drv_name)
    4443{
    45         return log_init(drv_name, level);
     44        return log_init(drv_name);
    4645}
    4746
     
    5958       
    6059        va_start(args, fmt);
    61         log_msgv(level, fmt, args);
     60        log_msgv(LOG_DEFAULT, level, fmt, args);
    6261        va_end(args);
    6362}
  • uspace/lib/drv/generic/remote_usb.c

    rb5d2e57 r03362fbd  
    5656{
    5757        if (!exch)
    58                 return EINVAL;
     58                return EBADMEM;
    5959        sysarg_t addr;
    6060        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    6565        return ret;
    6666}
    67 /*----------------------------------------------------------------------------*/
     67
    6868/** Tell interface number given device can use.
    6969 * @param[in] exch IPC communication exchange
     
    7575{
    7676        if (!exch)
    77                 return EINVAL;
     77                return EBADMEM;
    7878        sysarg_t iface_no;
    7979        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    8383        return ret;
    8484}
    85 /*----------------------------------------------------------------------------*/
     85
    8686/** Tell devman handle of device host controller.
    8787 * @param[in] exch IPC communication exchange
     
    9292{
    9393        if (!exch)
    94                 return EINVAL;
     94                return EBADMEM;
    9595        devman_handle_t h;
    9696        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    121121};
    122122
    123 /*----------------------------------------------------------------------------*/
     123
    124124void remote_usb_get_my_address(ddf_fun_t *fun, void *iface,
    125125    ipc_callid_t callid, ipc_call_t *call)
     
    140140        }
    141141}
    142 /*----------------------------------------------------------------------------*/
     142
    143143void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface,
    144144    ipc_callid_t callid, ipc_call_t *call)
     
    159159        }
    160160}
    161 /*----------------------------------------------------------------------------*/
     161
    162162void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,
    163163    ipc_callid_t callid, ipc_call_t *call)
  • uspace/lib/drv/generic/remote_usbhc.c

    rb5d2e57 r03362fbd  
    165165{
    166166        if (!exch || !address)
    167                 return EINVAL;
     167                return EBADMEM;
    168168        sysarg_t new_address;
    169169        const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    173173        return ret;
    174174}
    175 /*----------------------------------------------------------------------------*/
     175
    176176int usbhc_bind_address(async_exch_t *exch, usb_address_t address,
    177177    devman_handle_t handle)
    178178{
    179179        if (!exch)
    180                 return EINVAL;
     180                return EBADMEM;
    181181        return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    182182            IPC_M_USBHC_BIND_ADDRESS, address, handle);
    183183}
    184 /*----------------------------------------------------------------------------*/
     184
    185185int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
    186186    devman_handle_t *handle)
    187187{
    188188        if (!exch)
    189                 return EINVAL;
     189                return EBADMEM;
    190190        sysarg_t h;
    191191        const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    195195        return ret;
    196196}
    197 /*----------------------------------------------------------------------------*/
     197
    198198int usbhc_release_address(async_exch_t *exch, usb_address_t address)
    199199{
    200200        if (!exch)
    201                 return EINVAL;
     201                return EBADMEM;
    202202        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    203203            IPC_M_USBHC_RELEASE_ADDRESS, address);
    204204}
    205 /*----------------------------------------------------------------------------*/
     205
    206206int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    207207    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    209209{
    210210        if (!exch)
    211                 return EINVAL;
     211                return EBADMEM;
    212212        const usb_target_t target =
    213213            {{ .address = address, .endpoint = endpoint }};
     
    220220#undef _PACK2
    221221}
    222 /*----------------------------------------------------------------------------*/
     222
    223223int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address,
    224224    usb_endpoint_t endpoint, usb_direction_t direction)
    225225{
    226226        if (!exch)
    227                 return EINVAL;
     227                return EBADMEM;
    228228        return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    229229            IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction);
    230230}
    231 /*----------------------------------------------------------------------------*/
     231
    232232int usbhc_read(async_exch_t *exch, usb_address_t address,
    233233    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
    234234    size_t *rec_size)
    235235{
     236        if (!exch)
     237                return EBADMEM;
     238
    236239        if (size == 0 && setup == 0)
    237240                return EOK;
    238241
    239         if (!exch)
    240                 return EINVAL;
    241242        const usb_target_t target =
    242243            {{ .address = address, .endpoint = endpoint }};
     
    284285        return EOK;
    285286}
    286 /*----------------------------------------------------------------------------*/
     287
    287288int usbhc_write(async_exch_t *exch, usb_address_t address,
    288289    usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
    289290{
     291        if (!exch)
     292                return EBADMEM;
     293
    290294        if (size == 0 && setup == 0)
    291295                return EOK;
    292296
    293         if (!exch)
    294                 return EINVAL;
    295297        const usb_target_t target =
    296298            {{ .address = address, .endpoint = endpoint }};
     
    319321        return (int) opening_request_rc;
    320322}
    321 /*----------------------------------------------------------------------------*/
     323
    322324
    323325static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    384386        return trans;
    385387}
    386 /*----------------------------------------------------------------------------*/
     388
    387389void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    388390    ipc_callid_t callid, ipc_call_t *call)
     
    406408        }
    407409}
    408 /*----------------------------------------------------------------------------*/
     410
    409411void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    410412    ipc_callid_t callid, ipc_call_t *call)
     
    423425        async_answer_0(callid, ret);
    424426}
    425 /*----------------------------------------------------------------------------*/
     427
    426428void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    427429    ipc_callid_t callid, ipc_call_t *call)
     
    444446        }
    445447}
    446 /*----------------------------------------------------------------------------*/
     448
    447449void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    448450    ipc_callid_t callid, ipc_call_t *call)
     
    460462        async_answer_0(callid, ret);
    461463}
    462 /*----------------------------------------------------------------------------*/
     464
    463465static void callback_out(ddf_fun_t *fun,
    464466    int outcome, void *arg)
     
    470472        async_transaction_destroy(trans);
    471473}
    472 /*----------------------------------------------------------------------------*/
     474
    473475static void callback_in(ddf_fun_t *fun,
    474476    int outcome, size_t actual_size, void *arg)
     
    494496        async_transaction_destroy(trans);
    495497}
    496 /*----------------------------------------------------------------------------*/
     498
    497499void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
    498500    ipc_callid_t callid, ipc_call_t *call)
     
    594596        }
    595597}
    596 /*----------------------------------------------------------------------------*/
     598
    597599void remote_usbhc_write(
    598600    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
Note: See TracChangeset for help on using the changeset viewer.