Changeset 2568c94 in mainline for uspace/lib


Ignore:
Timestamp:
2012-08-17T17:15:19Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1789023
Parents:
4f351432 (diff), 01e397ac (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

Location:
uspace/lib
Files:
4 added
20 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r4f351432 r2568c94  
    9696        generic/inetping.c \
    9797        generic/io/asprintf.c \
     98        generic/io/input.c \
    9899        generic/io/io.c \
    99100        generic/io/chargrid.c \
  • uspace/lib/c/generic/str.c

    r4f351432 r2568c94  
    134134       
    135135        return ch;
     136}
     137
     138/** Decode a single character from a string to the left.
     139 *
     140 * Decode a single character from a string of size @a size. Decoding starts
     141 * at @a offset and this offset is moved to the beginning of the previous
     142 * character. In case of decoding error, offset generally decreases at least
     143 * by one. However, offset is never moved before 0.
     144 *
     145 * @param str    String (not necessarily NULL-terminated).
     146 * @param offset Byte offset in string where to start decoding.
     147 * @param size   Size of the string (in bytes).
     148 *
     149 * @return Value of decoded character, U_SPECIAL on decoding error or
     150 *         NULL if attempt to decode beyond @a start of str.
     151 *
     152 */
     153wchar_t str_decode_reverse(const char *str, size_t *offset, size_t size)
     154{
     155        if (*offset == 0)
     156                return 0;
     157       
     158        size_t processed = 0;
     159        /* Continue while continuation bytes found */
     160        while (*offset > 0 && processed < 4) {
     161                uint8_t b = (uint8_t) str[--(*offset)];
     162               
     163                if (processed == 0 && (b & 0x80) == 0) {
     164                        /* 0xxxxxxx (Plain ASCII) */
     165                        return b & 0x7f;
     166                }
     167                else if ((b & 0xe0) == 0xc0 || (b & 0xf0) == 0xe0 ||
     168                    (b & 0xf8) == 0xf0) {
     169                        /* Start byte */
     170                        size_t start_offset = *offset;
     171                        return str_decode(str, &start_offset, size);
     172                }
     173                else if ((b & 0xc0) != 0x80) {
     174                        /* Not a continuation byte */
     175                        return U_SPECIAL;
     176                }
     177                processed++;
     178        }
     179        /* Too many continuation bytes */
     180        return U_SPECIAL;
    136181}
    137182
  • uspace/lib/c/include/io/console.h

    r4f351432 r2568c94  
    3737
    3838#include <sys/time.h>
     39#include <io/kbd_event.h>
    3940#include <io/keycode.h>
    4041#include <async.h>
     
    7071} console_ctrl_t;
    7172
    72 typedef enum {
    73         KEY_PRESS,
    74         KEY_RELEASE
    75 } kbd_event_type_t;
    76 
    77 /** Console event structure. */
    78 typedef struct {
    79         /** List handle */
    80         link_t link;
    81        
    82         /** Press or release event. */
    83         kbd_event_type_t type;
    84        
    85         /** Keycode of the key that was pressed or released. */
    86         keycode_t key;
    87        
    88         /** Bitmask of modifiers held. */
    89         keymod_t mods;
    90        
    91         /** The character that was generated or '\0' for none. */
    92         wchar_t c;
    93 } kbd_event_t;
    94 
    9573extern console_ctrl_t *console_init(FILE *, FILE *);
    9674extern void console_done(console_ctrl_t *);
  • uspace/lib/c/include/str.h

    r4f351432 r2568c94  
    5656
    5757extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
     58extern wchar_t str_decode_reverse(const char *str, size_t *offset, size_t sz);
    5859extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
    5960
  • uspace/lib/drv/generic/driver.c

    r4f351432 r2568c94  
    3636/** @file
    3737 */
     38
     39#define _DDF_DATA_IMPLANT
    3840
    3941#include <assert.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

    r4f351432 r2568c94  
    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/remote_graph_dev.c

    r4f351432 r2568c94  
    5656        graph_dev_ops_t *graph_dev_ops = (graph_dev_ops_t *) ops;
    5757
    58         if (!graph_dev_ops->connect || !fun->driver_data) {
     58        if (!graph_dev_ops->connect || !ddf_fun_data_get(fun)) {
    5959                async_answer_0(callid, ENOTSUP);
    6060                return;
    6161        }
    6262
    63         (*graph_dev_ops->connect)(fun->driver_data, callid, call, NULL);
     63        (*graph_dev_ops->connect)(ddf_fun_data_get(fun), callid, call, NULL);
    6464}
    6565
  • uspace/lib/drv/include/ddf/driver.h

    r4f351432 r2568c94  
    4242#include "../dev_iface.h"
    4343
    44 typedef struct ddf_dev ddf_dev_t;
    45 typedef struct ddf_fun ddf_fun_t;
    4644
    4745/*
    4846 * Device
    4947 */
     48
     49typedef struct ddf_dev ddf_dev_t;
     50typedef struct ddf_fun ddf_fun_t;
    5051
    5152/** Devices operations */
     
    7576
    7677/** Device structure */
    77 struct ddf_dev {
    78         /**
    79          * Globally unique device identifier (assigned to the device by the
    80          * device manager).
    81          */
    82         devman_handle_t handle;
    83        
    84         /** Reference count */
    85         atomic_t refcnt;
    86        
    87         /**
    88          * Session to the parent device driver (if it is different from this
    89          * driver)
    90          */
    91         async_sess_t *parent_sess;
    92        
    93         /** Device name */
    94         const char *name;
    95        
    96         /** Driver-specific data associated with this device */
    97         void *driver_data;
    98        
    99         /** Link in the list of devices handled by the driver */
    100         link_t link;
    101 };
     78struct ddf_dev;
    10279
    10380/** Function structure */
    104 struct ddf_fun {
    105         /** True if bound to the device manager */
    106         bool bound;
    107        
    108         /** Function indentifier (asigned by device manager) */
    109         devman_handle_t handle;
    110        
    111         /** Reference count */
    112         atomic_t refcnt;
    113        
    114         /** Device which this function belogs to */
    115         ddf_dev_t *dev;
    116        
    117         /** Function type */
    118         fun_type_t ftype;
    119        
    120         /** Function name */
    121         const char *name;
    122        
    123         /** List of device ids for driver matching */
    124         match_id_list_t match_ids;
    125        
    126         /** Driver-specific data associated with this function */
    127         void *driver_data;
    128        
    129         /** Implementation of operations provided by this function */
    130         ddf_dev_ops_t *ops;
    131        
    132         /** Connection handler or @c NULL to use the DDF default handler. */
    133         async_client_conn_t conn_handler;
    134        
    135         /** Link in the list of functions handled by the driver */
    136         link_t link;
    137 };
     81struct ddf_fun;
    13882
    13983/*
     
    167111} driver_t;
    168112
     113/** XXX Only to transition USB */
     114#ifdef _DDF_DATA_IMPLANT
     115extern void ddf_fun_data_implant(ddf_fun_t *, void *);
     116#endif
     117
    169118extern int ddf_driver_main(driver_t *);
    170119
    171120extern void *ddf_dev_data_alloc(ddf_dev_t *, size_t);
     121extern void *ddf_dev_data_get(ddf_dev_t *);
     122extern devman_handle_t ddf_dev_get_handle(ddf_dev_t *);
     123extern const char *ddf_dev_get_name(ddf_dev_t *);
     124extern async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *, exch_mgmt_t);
     125extern async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *);
    172126extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
     127extern devman_handle_t ddf_fun_get_handle(ddf_fun_t *);
    173128extern void ddf_fun_destroy(ddf_fun_t *);
    174129extern void *ddf_fun_data_alloc(ddf_fun_t *, size_t);
     130extern void *ddf_fun_data_get(ddf_fun_t *);
     131extern const char *ddf_fun_get_name(ddf_fun_t *);
     132extern int ddf_fun_set_name(ddf_fun_t *, const char *);
     133extern ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *);
    175134extern int ddf_fun_bind(ddf_fun_t *);
    176135extern int ddf_fun_unbind(ddf_fun_t *);
     
    178137extern int ddf_fun_offline(ddf_fun_t *);
    179138extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
    180 
     139extern void ddf_fun_set_ops(ddf_fun_t *, ddf_dev_ops_t *);
     140extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_client_conn_t);
    181141extern int ddf_fun_add_to_category(ddf_fun_t *, const char *);
    182142
  • uspace/lib/nic/src/nic_driver.c

    r4f351432 r2568c94  
    4747#include <sysinfo.h>
    4848#include <as.h>
    49 #include <devman.h>
    5049#include <ddf/interrupt.h>
    5150#include <ops/nic.h>
     
    250249{
    251250        ddf_dev_t *dev = nic_data->dev;
     251        async_sess_t *parent_sess;
    252252       
    253253        /* Connect to the parent's driver. */
    254         dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
    255                 dev->handle, IPC_FLAG_BLOCKING);
    256         if (dev->parent_sess == NULL)
     254        parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
     255        if (parent_sess == NULL)
    257256                return EPARTY;
    258257       
    259         return hw_res_get_list_parsed(nic_data->dev->parent_sess, resources, 0);
     258        return hw_res_get_list_parsed(parent_sess, resources, 0);
    260259}
    261260
     
    650649 *
    651650 */
    652 static nic_t *nic_create(void)
    653 {
    654         nic_t *nic_data = malloc(sizeof(nic_t));
     651static nic_t *nic_create(ddf_dev_t *dev)
     652{
     653        nic_t *nic_data = ddf_dev_data_alloc(dev, sizeof(nic_t));
    655654        if (nic_data == NULL)
    656655                return NULL;
    657656       
    658657        /* Force zero to all uninitialized fields (e.g. added in future) */
    659         bzero(nic_data, sizeof(nic_t));
    660658        if (nic_rxc_init(&nic_data->rx_control) != EOK) {
    661                 free(nic_data);
    662659                return NULL;
    663660        }
    664661       
    665662        if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) {
    666                 free(nic_data);
    667663                return NULL;
    668664        }
     
    705701nic_t *nic_create_and_bind(ddf_dev_t *device)
    706702{
    707         assert(device);
    708         assert(!device->driver_data);
    709        
    710         nic_t *nic_data = nic_create();
     703        nic_t *nic_data = nic_create(device);
    711704        if (!nic_data)
    712705                return NULL;
    713706       
    714707        nic_data->dev = device;
    715         device->driver_data = nic_data;
    716708       
    717709        return nic_data;
     
    724716 * @param data
    725717 */
    726 static void nic_destroy(nic_t *nic_data) {
    727         if (nic_data->client_session != NULL) {
    728                 async_hangup(nic_data->client_session);
    729         }
    730 
     718static void nic_destroy(nic_t *nic_data)
     719{
    731720        free(nic_data->specific);
    732         free(nic_data);
    733721}
    734722
     
    740728 * @param device The NIC device structure
    741729 */
    742 void nic_unbind_and_destroy(ddf_dev_t *device){
    743         if (!device)
    744                 return;
    745         if (!device->driver_data)
    746                 return;
    747 
    748         nic_destroy((nic_t *) device->driver_data);
    749         device->driver_data = NULL;
     730void nic_unbind_and_destroy(ddf_dev_t *device)
     731{
     732        nic_destroy(nic_get_from_ddf_dev(device));
    750733        return;
    751734}
     
    983966nic_t *nic_get_from_ddf_dev(ddf_dev_t *dev)
    984967{
    985         return (nic_t *) dev->driver_data;
    986 };
     968        return (nic_t *) ddf_dev_data_get(dev);
     969}
    987970
    988971/**
     
    992975nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun)
    993976{
    994         return (nic_t *) fun->driver_data;
    995 };
     977        return (nic_t *) ddf_fun_data_get(fun);
     978}
    996979
    997980/**
  • uspace/lib/nic/src/nic_impl.c

    r4f351432 r2568c94  
    5454int nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state)
    5555{
    56         nic_t *nic_data = (nic_t *) fun->driver_data;
     56        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    5757        fibril_rwlock_read_lock(&nic_data->main_lock);
    5858        *state = nic_data->state;
     
    7878        }
    7979
    80         nic_t *nic_data = (nic_t *) fun->driver_data;
     80        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    8181
    8282        fibril_rwlock_write_lock(&nic_data->main_lock);
     
    170170int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size)
    171171{
    172         nic_t *nic_data = (nic_t *) fun->driver_data;
     172        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    173173
    174174        fibril_rwlock_read_lock(&nic_data->main_lock);
     
    192192int nic_callback_create_impl(ddf_fun_t *fun)
    193193{
    194         nic_t *nic = (nic_t *) fun->driver_data;
     194        nic_t *nic = nic_get_from_ddf_fun(fun);
    195195        fibril_rwlock_write_lock(&nic->main_lock);
    196196       
     
    218218{
    219219        assert(address);
    220         nic_t *nic_data = (nic_t *) fun->driver_data;
     220        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    221221        fibril_rwlock_read_lock(&nic_data->main_lock);
    222222        memcpy(address, &nic_data->mac, sizeof (nic_address_t));
     
    236236int nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats)
    237237{
    238         nic_t *nic_data = (nic_t *) fun->driver_data;
     238        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    239239        assert (stats != NULL);
    240240        fibril_rwlock_read_lock(&nic_data->stats_lock);
     
    259259        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    260260{
    261         nic_t *nic_data = (nic_t *) fun->driver_data;
     261        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    262262        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    263263        nic_rxc_unicast_get_mode(&nic_data->rx_control, mode, max_count,
     
    291291        }
    292292
    293         nic_t *nic_data = (nic_t *) fun->driver_data;
     293        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    294294        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    295295        int rc = ENOTSUP;
     
    326326        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    327327{
    328         nic_t *nic_data = (nic_t *) fun->driver_data;
     328        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    329329        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    330330        nic_rxc_multicast_get_mode(&nic_data->rx_control, mode, max_count,
     
    358358        }
    359359
    360         nic_t *nic_data = (nic_t *) fun->dev->driver_data;
     360        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    361361        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    362362        int rc = ENOTSUP;
     
    382382int nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode)
    383383{
    384         nic_t *nic_data = (nic_t *) fun->driver_data;
     384        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    385385        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    386386        nic_rxc_broadcast_get_mode(&nic_data->rx_control, mode);
     
    402402int nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode)
    403403{
    404         nic_t *nic_data = (nic_t *) fun->driver_data;
     404        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    405405        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    406406        int rc = ENOTSUP;
     
    429429        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    430430{
    431         nic_t *nic_data = (nic_t *) fun->driver_data;
     431        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    432432        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    433433        nic_rxc_blocked_sources_get(&nic_data->rx_control,
     
    452452        const nic_address_t *addr_list, size_t addr_count)
    453453{
    454         nic_t *nic_data = (nic_t *) fun->driver_data;
     454        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    455455        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    456456        if (nic_data->on_blocked_sources_change) {
     
    474474int nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask)
    475475{
    476         nic_t *nic_data = (nic_t *) fun->driver_data;
     476        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    477477        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    478478        int rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask);
     
    492492int nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask)
    493493{
    494         nic_t *nic_data = (nic_t *) fun->driver_data;
     494        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    495495        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    496496        int rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask);
     
    520520        const void *data, size_t length, nic_wv_id_t *new_id)
    521521{
    522         nic_t *nic_data = (nic_t *) fun->driver_data;
     522        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    523523        if (nic_data->on_wol_virtue_add == NULL
    524524                || nic_data->on_wol_virtue_remove == NULL) {
     
    594594int nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id)
    595595{
    596         nic_t *nic_data = (nic_t *) fun->driver_data;
     596        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    597597        if (nic_data->on_wol_virtue_add == NULL
    598598                || nic_data->on_wol_virtue_remove == NULL) {
     
    631631        nic_wv_type_t *type, size_t max_length, void *data, size_t *length)
    632632{
    633         nic_t *nic_data = (nic_t *) fun->driver_data;
     633        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    634634        fibril_rwlock_read_lock(&nic_data->wv_lock);
    635635        const nic_wol_virtue_t *virtue =
     
    669669        size_t max_count, nic_wv_id_t *id_list, size_t *id_count)
    670670{
    671         nic_t *nic_data = (nic_t *) fun->driver_data;
     671        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    672672        fibril_rwlock_read_lock(&nic_data->wv_lock);
    673673        int rc = nic_wol_virtues_list(&nic_data->wol_virtues, type,
     
    689689int nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count)
    690690{
    691         nic_t *nic_data = (nic_t *) fun->driver_data;
     691        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    692692        fibril_rwlock_read_lock(&nic_data->wv_lock);
    693693        *count = nic_data->wol_virtues.caps_max[type]
     
    712712        nic_poll_mode_t *mode, struct timeval *period)
    713713{
    714         nic_t *nic_data = (nic_t *) fun->driver_data;
     714        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    715715        fibril_rwlock_read_lock(&nic_data->main_lock);
    716716        *mode = nic_data->poll_mode;
     
    735735        nic_poll_mode_t mode, const struct timeval *period)
    736736{
    737         nic_t *nic_data = (nic_t *) fun->driver_data;
     737        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    738738        /* If the driver does not implement the poll mode change handler it cannot
    739739         * switch off interrupts and this is not supported. */
     
    783783 */
    784784int nic_poll_now_impl(ddf_fun_t *fun) {
    785         nic_t *nic_data = (nic_t *) fun->driver_data;
     785        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    786786        fibril_rwlock_read_lock(&nic_data->main_lock);
    787787        if (nic_data->poll_mode != NIC_POLL_ON_DEMAND) {
  • uspace/lib/softfloat/generic/softfloat.c

    r4f351432 r2568c94  
    12671267}
    12681268
     1269double __aeabi_i2d(int i)
     1270{
     1271        return __floatsidf(i);
     1272}
     1273
     1274double __aeabi_ui2d(unsigned int i)
     1275{
     1276        return __floatunsidf(i);
     1277}
     1278
     1279int __aeabi_d2iz(double a)
     1280{
     1281        return __fixdfsi(a);
     1282}
     1283
     1284unsigned int __aeabi_d2uiz(double a)
     1285{
     1286        return __fixunsdfsi(a);
     1287}
     1288
     1289int __aeabi_dcmpge(double a, double b)
     1290{
     1291        return __gedf2(a, b);
     1292}
     1293
     1294int __aeabi_dcmpgt(double a, double b)
     1295{
     1296        return __gtdf2(a, b);
     1297}
     1298
     1299int __aeabi_dcmplt(double a, double b)
     1300{
     1301        return __ltdf2(a, b);
     1302}
     1303
     1304double __aeabi_dadd(double a, double b)
     1305{
     1306        return __adddf3(a, b);
     1307}
     1308
     1309double __aeabi_dsub(double a, double b)
     1310{
     1311        return __subdf3(a, b);
     1312}
     1313
     1314double __aeabi_dmul(double a, double b)
     1315{
     1316        return __muldf3(a, b);
     1317}
     1318
     1319double __aeabi_ddiv(double a, double b)
     1320{
     1321        return __divdf3(a, b);
     1322}
     1323
    12691324/** @}
    12701325 */
  • uspace/lib/softfloat/include/softfloat.h

    r4f351432 r2568c94  
    173173
    174174/* SPARC quadruple-precision wrappers */
    175 
    176175extern void _Qp_add(long double *, long double *, long double *);
    177176extern void _Qp_sub(long double *, long double *, long double *);
     
    204203extern int _Qp_fne(long double *, long double *);
    205204
     205/* ARM EABI */
     206extern double __aeabi_i2d(int);
     207extern double __aeabi_ui2d(unsigned int);
     208extern unsigned int __aeabi_d2uiz(double);
     209extern int __aeabi_d2iz(double);
     210
     211extern int __aeabi_dcmpge(double, double);
     212extern int __aeabi_dcmpgt(double, double);
     213extern int __aeabi_dcmplt(double, double);
     214
     215extern double __aeabi_dadd(double, double);
     216extern double __aeabi_dsub(double, double);
     217extern double __aeabi_dmul(double, double);
     218extern double __aeabi_ddiv(double, double);
     219
    206220/* Not implemented yet */
    207221extern void _Qp_sqrt(long double *, long double *);
  • uspace/lib/usb/include/usb/hc.h

    r4f351432 r2568c94  
    7777}
    7878
    79 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
    80     const ddf_dev_t *);
     79int usb_hc_connection_initialize_from_device(usb_hc_connection_t *, ddf_dev_t *);
    8180
    8281void usb_hc_connection_deinitialize(usb_hc_connection_t *);
  • uspace/lib/usb/src/ddfiface.c

    r4f351432 r2568c94  
    6868{
    6969        assert(fun);
    70         return usb_get_hc_by_handle(fun->handle, handle);
     70        return usb_get_hc_by_handle(ddf_fun_get_handle(fun), handle);
    7171}
    7272
     
    8282
    8383        if (handle != NULL) {
    84                 *handle = fun->handle;
     84                *handle = ddf_fun_get_handle(fun);
    8585        }
    8686
     
    9999{
    100100        assert(fun);
    101         return usb_get_address_by_handle(fun->handle, address);
     101        return usb_get_address_by_handle(ddf_fun_get_handle(fun), address);
    102102}
    103103
     
    116116    usb_address_t *address)
    117117{
    118         assert(fun);
    119         assert(fun->driver_data);
    120         const usb_hub_attached_device_t *device = fun->driver_data;
     118        const usb_hub_attached_device_t *device = ddf_fun_data_get(fun);
    121119        assert(device->fun == fun);
    122120        if (address)
  • uspace/lib/usb/src/hc.c

    r4f351432 r2568c94  
    115115 */
    116116int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
    117     const ddf_dev_t *device)
    118 {
    119         assert(connection);
    120 
    121         if (device == NULL) {
     117    ddf_dev_t *device)
     118{
     119        if (device == NULL)
    122120                return EBADMEM;
    123         }
    124121
    125122        devman_handle_t hc_handle;
    126         const int rc = usb_get_hc_by_handle(device->handle, &hc_handle);
     123        const int rc = usb_get_hc_by_handle(ddf_dev_get_handle(device), &hc_handle);
    127124        if (rc == EOK) {
    128125                usb_hc_connection_initialize(connection, hc_handle);
  • uspace/lib/usbdev/src/devdrv.c

    r4f351432 r2568c94  
    105105        if (dev == NULL) {
    106106                usb_log_error("USB device `%s' structure allocation failed.\n",
    107                     gen_dev->name);
     107                    ddf_dev_get_name(gen_dev));
    108108                return ENOMEM;
    109109        }
     
    114114        if (rc != EOK) {
    115115                usb_log_error("USB device `%s' init failed (%s): %s.\n",
    116                     gen_dev->name, err_msg, str_error(rc));
     116                    ddf_dev_get_name(gen_dev), err_msg, str_error(rc));
    117117                return rc;
    118118        }
     
    139139                return ENOTSUP;
    140140        /* Just tell the driver to stop whatever it is doing */
    141         usb_device_t *usb_dev = gen_dev->driver_data;
     141        usb_device_t *usb_dev = ddf_dev_data_get(gen_dev);
    142142        const int ret = driver->ops->device_rem(usb_dev);
    143143        if (ret != EOK)
     
    160160        if (driver->ops->device_gone == NULL)
    161161                return ENOTSUP;
    162         usb_device_t *usb_dev = gen_dev->driver_data;
     162        usb_device_t *usb_dev = ddf_dev_data_get(gen_dev);
    163163        const int ret = driver->ops->device_gone(usb_dev);
    164164        if (ret == EOK)
     
    415415        usb_address_t address;
    416416
    417         int rc = usb_get_info_by_handle(ddf_dev->handle,
     417        int rc = usb_get_info_by_handle(ddf_dev_get_handle(ddf_dev),
    418418            &hc_handle, &address, &usb_dev->interface_no);
    419419        if (rc != EOK) {
  • uspace/lib/usbdev/src/devpoll.c

    r4f351432 r2568c94  
    8080                usb_log_debug("Poll%p: started polling of `%s' - " \
    8181                    "interface %d (%s,%d,%d), %zuB/%zu.\n",
    82                     data, data->dev->ddf_dev->name,
     82                    data, ddf_dev_get_name(data->dev->ddf_dev),
    8383                    (int) mapping->interface->interface_number,
    8484                    usb_str_class(mapping->interface->interface_class),
     
    159159                if (failed) {
    160160                        usb_log_error("Polling of device `%s' terminated: "
    161                             "recurring failures.\n", data->dev->ddf_dev->name);
     161                            "recurring failures.\n", ddf_dev_get_name(
     162                            data->dev->ddf_dev));
    162163                } else {
    163164                        usb_log_debug("Polling of device `%s' terminated: "
    164                             "driver request.\n", data->dev->ddf_dev->name);
     165                            "driver request.\n", ddf_dev_get_name(
     166                            data->dev->ddf_dev));
    165167                }
    166168        }
  • uspace/lib/usbdev/src/hub.c

    r4f351432 r2568c94  
    6363                return EBADMEM;
    6464        return usb_hc_bind_address(connection,
    65             attached_device->address, attached_device->fun->handle);
     65            attached_device->address, ddf_fun_get_handle(attached_device->fun));
    6666}
    6767
     
    287287        rc = usb_hub_register_device(hc_conn, &new_device);
    288288        if (rc != EOK) {
    289                 /* We know nothing about that data. */
    290                 if (new_dev_data)
    291                         child_fun->driver_data = NULL;
    292289                /* The child function is already created. */
    293290                ddf_fun_destroy(child_fun);
  • uspace/lib/usbdev/src/recognise.c

    r4f351432 r2568c94  
    3333 * Functions for recognition of attached devices.
    3434 */
     35
     36/** XXX Fix this */
     37#define _DDF_DATA_IMPLANT
    3538
    3639#include <sys/types.h>
     
    352355       
    353356        if (dev_ops != NULL)
    354                 child->ops = dev_ops;
     357                ddf_fun_set_ops(child, dev_ops);
    355358        else
    356                 child->ops = &child_ops;
    357        
    358         child->driver_data = dev_data;
     359                ddf_fun_set_ops(child, &child_ops);
     360       
     361        ddf_fun_data_implant(child, dev_data);
     362       
    359363        /*
    360364         * Store the attached device in fun
     
    373377        }
    374378       
    375         rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
     379        match_id_list_t match_ids;
     380        init_match_ids(&match_ids);
     381        rc = usb_device_create_match_ids(ctrl_pipe, &match_ids);
    376382        if (rc != EOK)
    377383                goto failure;
     384       
     385        list_foreach(match_ids.ids, id_link) {
     386                match_id_t *match_id = list_get_instance(id_link, match_id_t, link);
     387                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
     388                if (rc != EOK) {
     389                        clean_match_ids(&match_ids);
     390                        goto failure;
     391                }
     392        }
     393       
     394        clean_match_ids(&match_ids);
    378395       
    379396        rc = ddf_fun_bind(child);
     
    386403failure:
    387404        if (child != NULL) {
    388                 /* We know nothing about the data if it came from outside. */
    389                 if (dev_data)
    390                         child->driver_data = NULL;
    391                
    392405                /* This takes care of match_id deallocation as well. */
    393406                ddf_fun_destroy(child);
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r4f351432 r2568c94  
    9898 * @return pointer cast to hcd_t*.
    9999 */
    100 static inline hcd_t * fun_to_hcd(const ddf_fun_t *fun)
     100static inline hcd_t *fun_to_hcd(ddf_fun_t *fun)
    101101{
    102         assert(fun);
    103         return fun->driver_data;
     102        return ddf_fun_data_get(fun);
    104103}
    105104
Note: See TracChangeset for help on using the changeset viewer.