Changeset 8d6c1f1 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-06-07T21:31:35Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75608143
Parents:
ff4f073 (diff), eb522e8 (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 USB support.

Changes from bzr://helenos-usb.bzr.sourceforge.net/bzrroot/helenos-usb/mainline:

  • replaced '-' with '_' in new driver names
  • USB libs are built for each architecture
  • devman starts early
  • sys_thread_udelay() uses generic delay()
  • sys_as_create_area() now creates cacheable areas by default
Location:
uspace/lib/c
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rff4f073 r8d6c1f1  
    7676        generic/str.c \
    7777        generic/str_error.c \
     78        generic/l18n/langs.c \
    7879        generic/fibril.c \
    7980        generic/fibril_synch.c \
  • uspace/lib/c/generic/adt/hash_table.c

    rff4f073 r8d6c1f1  
    5454 *
    5555 */
    56 int hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,
     56bool hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,
    5757    hash_table_operations_t *op)
    5858{
  • uspace/lib/c/generic/as.c

    rff4f073 r8d6c1f1  
    3535#include <as.h>
    3636#include <libc.h>
     37#include <errno.h>
    3738#include <unistd.h>
    3839#include <align.h>
     
    114115}
    115116
     117/** Find mapping to physical address.
     118 *
     119 * @param address Virtual address in question (virtual).
     120 * @param[out] frame Frame address (physical).
     121 * @return Error code.
     122 * @retval EOK No error, @p frame holds the translation.
     123 * @retval ENOENT Mapping not found.
     124 */
     125int as_get_physical_mapping(void *address, uintptr_t *frame)
     126{
     127        uintptr_t tmp_frame;
     128        uintptr_t virt = (uintptr_t) address;
     129       
     130        int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING,
     131            (sysarg_t) virt, (sysarg_t) &tmp_frame);
     132        if (rc != EOK) {
     133                return rc;
     134        }
     135       
     136        if (frame != NULL) {
     137                *frame = tmp_frame;
     138        }
     139       
     140        return EOK;
     141}
     142
    116143/** @}
    117144 */
  • uspace/lib/c/generic/async.c

    rff4f073 r8d6c1f1  
    15691569}
    15701570
     1571/** Start IPC_M_DATA_READ using the async framework.
     1572 *
     1573 * @param phoneid Phone that will be used to contact the receiving side.
     1574 * @param dst Address of the beginning of the destination buffer.
     1575 * @param size Size of the destination buffer (in bytes).
     1576 * @param dataptr Storage of call data (arg 2 holds actual data size).
     1577 * @return Hash of the sent message or 0 on error.
     1578 */
     1579aid_t async_data_read(int phoneid, void *dst, size_t size, ipc_call_t *dataptr)
     1580{
     1581        return async_send_2(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
     1582            (sysarg_t) size, dataptr);
     1583}
     1584
    15711585/** Wrapper for IPC_M_DATA_READ calls using the async framework.
    15721586 *
  • uspace/lib/c/generic/devman.c

    rff4f073 r8d6c1f1  
    374374}
    375375
     376int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size)
     377{
     378        int phone = devman_get_phone(DEVMAN_CLIENT, 0);
     379
     380        if (phone < 0)
     381                return phone;
     382
     383        async_serialize_start();
     384
     385        ipc_call_t answer;
     386        aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_DEVICE_PATH,
     387            handle, &answer);
     388
     389        ipc_call_t data_request_call;
     390        aid_t data_request = async_data_read(phone, path, path_size,
     391            &data_request_call);
     392        if (data_request == 0) {
     393                async_wait_for(req, NULL);
     394                async_serialize_end();
     395                return ENOMEM;
     396        }
     397
     398        sysarg_t data_request_rc;
     399        sysarg_t opening_request_rc;
     400        async_wait_for(data_request, &data_request_rc);
     401        async_wait_for(req, &opening_request_rc);
     402
     403        async_serialize_end();
     404
     405        if (data_request_rc != EOK) {
     406                /* Prefer the return code of the opening request. */
     407                if (opening_request_rc != EOK) {
     408                        return (int) opening_request_rc;
     409                } else {
     410                        return (int) data_request_rc;
     411                }
     412        }
     413        if (opening_request_rc != EOK) {
     414                return (int) opening_request_rc;
     415        }
     416
     417        /* To be on the safe-side. */
     418        path[path_size - 1] = 0;
     419
     420        size_t transferred_size = IPC_GET_ARG2(data_request_call);
     421
     422        if (transferred_size >= path_size) {
     423                return ELIMIT;
     424        }
     425
     426        /* Terminate the string (trailing 0 not send over IPC). */
     427        path[transferred_size] = 0;
     428
     429        return EOK;
     430}
     431
    376432
    377433/** @}
  • uspace/lib/c/generic/str_error.c

    rff4f073 r8d6c1f1  
    3333 */
    3434
     35#include <errno.h>
    3536#include <str_error.h>
    3637#include <stdio.h>
     
    6364static fibril_local char noerr[NOERR_LEN];
    6465
    65 const char *str_error(const int errno)
     66const char *str_error(const int e)
    6667{
    67         if ((errno <= 0) && (errno >= MIN_ERRNO))
    68                 return err_desc[-errno];
     68        if ((e <= 0) && (e >= MIN_ERRNO))
     69                return err_desc[-e];
    6970       
    70         snprintf(noerr, NOERR_LEN, "Unkown error code %d", errno);
     71        /* Ad hoc descriptions of error codes interesting for USB. */
     72        switch (e) {
     73                case EBADCHECKSUM:
     74                        return "Bad checksum";
     75                case ESTALL:
     76                        return "Operation stalled";
     77                case EAGAIN:
     78                        return "Resource temporarily unavailable";
     79                case EEMPTY:
     80                        return "Resource is empty";
     81                default:
     82                        break;
     83        }
     84
     85        snprintf(noerr, NOERR_LEN, "Unkown error code %d", e);
    7186        return noerr;
    7287}
  • uspace/lib/c/generic/time.c

    rff4f073 r8d6c1f1  
    207207}
    208208
     209void udelay(useconds_t time)
     210{
     211        (void) __SYSCALL1(SYS_THREAD_UDELAY, (sysarg_t) time);
     212}
     213
     214
    209215/** Wait unconditionally for specified number of seconds
    210216 *
  • uspace/lib/c/include/adt/hash_table.h

    rff4f073 r8d6c1f1  
    3838#include <adt/list.h>
    3939#include <unistd.h>
     40#include <bool.h>
    4041
    4142typedef unsigned long hash_count_t;
     
    8384    list_get_instance((item), type, member)
    8485
    85 extern int hash_table_create(hash_table_t *, hash_count_t, hash_count_t,
     86extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t,
    8687    hash_table_operations_t *);
    8788extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *);
  • uspace/lib/c/include/as.h

    rff4f073 r8d6c1f1  
    6060extern void *set_maxheapsize(size_t);
    6161extern void *as_get_mappable_page(size_t);
     62extern int as_get_physical_mapping(void *, uintptr_t *);
    6263
    6364#endif
  • uspace/lib/c/include/async.h

    rff4f073 r8d6c1f1  
    340340            (arg4), (answer))
    341341
     342extern aid_t async_data_read(int, void *, size_t, ipc_call_t *);
    342343#define async_data_read_start(p, buf, len) \
    343344        async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE)
  • uspace/lib/c/include/devman.h

    rff4f073 r8d6c1f1  
    5555extern int devman_device_get_handle_by_class(const char *, const char *,
    5656    devman_handle_t *, unsigned int);
     57extern int devman_get_device_path(devman_handle_t, char *, size_t);
    5758
    5859extern int devman_add_device_to_class(devman_handle_t, const char *);
  • uspace/lib/c/include/errno.h

    rff4f073 r8d6c1f1  
    5656#define EMLINK        (-266)
    5757
     58/** Bad checksum. */
     59#define EBADCHECKSUM  (-300)
     60
     61/** USB: stalled operation. */
     62#define ESTALL (-301)
     63
     64/** Empty resource (no data). */
     65#define EEMPTY (-302)
     66
     67/** Negative acknowledgment. */
     68#define ENAK (-303)
     69
    5870/** An API function is called while another blocking function is in progress. */
    5971#define EINPROGRESS  (-10036)
  • uspace/lib/c/include/ipc/dev_iface.h

    rff4f073 r8d6c1f1  
    3737        HW_RES_DEV_IFACE = 0,
    3838        CHAR_DEV_IFACE,
     39
     40        /** Interface provided by any PCI device. */
     41        PCI_DEV_IFACE,
     42
     43        /** Interface provided by any USB device. */
     44        USB_DEV_IFACE,
     45        /** Interface provided by USB host controller. */
     46        USBHC_DEV_IFACE,
     47        /** Interface provided by USB HID devices. */
     48        USBHID_DEV_IFACE,
     49
    3950        DEV_IFACE_MAX
    4051} dev_inferface_idx_t;
     
    4859        DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX)
    4960
     61/*
     62 * The first argument is actually method (as the "real" method is used
     63 * for indexing into interfaces.
     64 */
     65
     66#define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call))
     67#define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call))
     68#define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call))
     69#define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call))
     70
    5071
    5172#endif
  • uspace/lib/c/include/ipc/devman.h

    rff4f073 r8d6c1f1  
    149149typedef enum {
    150150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
    151         DEVMAN_DEVICE_GET_HANDLE_BY_CLASS
     151        DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
     152        DEVMAN_DEVICE_GET_DEVICE_PATH
    152153} client_to_devman_t;
    153154
  • uspace/lib/c/include/ipc/kbd.h

    rff4f073 r8d6c1f1  
    3939
    4040#include <ipc/common.h>
     41#include <ipc/dev_iface.h>
    4142
    4243typedef enum {
    43         KBD_YIELD = IPC_FIRST_USER_METHOD,
     44        KBD_YIELD = DEV_FIRST_CUSTOM_METHOD,
    4445        KBD_RECLAIM
    4546} kbd_request_t;
  • uspace/lib/c/include/sys/time.h

    rff4f073 r8d6c1f1  
    6262extern int gettimeofday(struct timeval *tv, struct timezone *tz);
    6363
     64extern void udelay(useconds_t);
     65
    6466#endif
    6567
Note: See TracChangeset for help on using the changeset viewer.