Changeset f658458 in mainline for uspace/lib


Ignore:
Timestamp:
2010-05-02T20:49:09Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb864a0
Parents:
25a7e11d
Message:

parts of generic char interface, fixed some bugs

Location:
uspace/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/device/char.c

    r25a7e11d rf658458  
    3838#include <async.h>
    3939#include <malloc.h>
     40#include <stdio.h>
    4041
    4142
     
    4647        async_serialize_start();
    4748       
     49        printf("calling interface %d\n", DEV_IFACE_ID(CHAR_DEV_IFACE));
    4850        aid_t req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_READ_DEV, &answer);
    4951       
  • uspace/lib/libc/generic/devman.c

    r25a7e11d rf658458  
    230230}
    231231
     232int devman_device_get_handle(const char *pathname, device_handle_t *handle, unsigned int flags)
     233{
     234        int phone = devman_get_phone(DEVMAN_CLIENT, flags);
     235       
     236        if (phone < 0)
     237                return phone;
     238       
     239        async_serialize_start();
     240       
     241        ipc_call_t answer;
     242        aid_t req = async_send_2(phone, DEVMAN_DEVICE_GET_HANDLE, flags, 0,
     243            &answer);
     244       
     245        ipcarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
     246        if (retval != EOK) {
     247                async_wait_for(req, NULL);
     248                async_serialize_end();
     249                return retval;
     250        }
     251       
     252        async_wait_for(req, &retval);
     253       
     254        async_serialize_end();
     255       
     256        if (retval != EOK) {
     257                if (handle != NULL)
     258                        *handle = (device_handle_t) -1;
     259                return retval;
     260        }
     261       
     262        if (handle != NULL)
     263                *handle = (device_handle_t) IPC_GET_ARG1(answer);
     264       
     265        return retval;
     266}
     267
     268
    232269/** @}
    233270 */
  • uspace/lib/libc/include/devman.h

    r25a7e11d rf658458  
    5151int devman_parent_device_connect(device_handle_t handle, unsigned int flags);
    5252
     53int devman_device_get_handle(const char *pathname, device_handle_t *handle, unsigned int flags);
     54
    5355
    5456#endif
  • uspace/lib/libc/include/ipc/devman.h

    r25a7e11d rf658458  
    138138} devman_to_driver_t;
    139139
     140typedef enum {
     141        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD
     142} client_to_devman_t;
     143
    140144#endif
    141145
  • uspace/lib/libdrv/generic/driver.c

    r25a7e11d rf658458  
    254254                        if (!is_valid_iface_idx(iface_idx)) {
    255255                                // this is not device's interface
    256                                 printf("%s: driver_connection_gen error - invalid interface id %x.", driver->name, method);
     256                                printf("%s: driver_connection_gen error - invalid interface id %d.", driver->name, iface_idx);
    257257                                ipc_answer_0(callid, ENOTSUP);
    258258                                break;
     
    265265                        if (NULL == iface) {
    266266                                printf("%s: driver_connection_gen error - ", driver->name);
    267                                 printf("device with handle %x has no interface with id %x.\n", handle, method);
     267                                printf("device with handle %d has no interface with id %d.\n", handle, iface_idx);
    268268                                ipc_answer_0(callid, ENOTSUP);
    269269                                break;
  • uspace/lib/libdrv/generic/remote_char.c

    r25a7e11d rf658458  
    5656
    5757static void remote_char_read(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
    58 {
     58{       
    5959        char_iface_t *char_iface = (char_iface_t *)iface;
    60         if (!char_iface->read) {
    61                 ipc_answer_0(callid, ENOTSUP);
    62                 return;
    63         }
    6460       
    6561        size_t len;
    6662        if (!async_data_read_receive(&callid, &len)) {
    6763                // TODO handle protocol error
     64                ipc_answer_0(callid, EINVAL);
     65                return;
     66        }
     67       
     68        if (!char_iface->read) {
     69                async_data_read_finalize(callid, NULL, 0);
     70                ipc_answer_0(callid, ENOTSUP);
    6871                return;
    6972        }
  • uspace/lib/libdrv/include/driver.h

    r25a7e11d rf658458  
    163163{
    164164        assert(is_valid_iface_idx(idx));       
    165 
     165        if (NULL == dev->class) {
     166                return NULL;
     167        }
    166168        return dev->class->interfaces[idx];     
    167169}
Note: See TracChangeset for help on using the changeset viewer.