Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7707954 in mainline


Ignore:
Timestamp:
2010-03-18T21:20:17Z (12 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
bda60d9
Parents:
084ff99
Message:

child device registration - parts of code

Location:
uspace/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/devman.c

    r084ff99 r7707954  
    106106}
    107107
     108int devman_child_device_register(const char *name, long parent_handle, long *handle)
     109{       
     110        int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
     111       
     112        if (phone < 0)
     113                return phone;
     114       
     115        async_serialize_start();
     116       
     117        ipc_call_t answer;
     118        aid_t req = async_send_1(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, &answer);
     119
     120        ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
     121        if (retval != EOK) {
     122                async_wait_for(req, NULL);
     123                async_serialize_end();
     124                return retval;
     125        }
     126       
     127        async_wait_for(req, &retval);
     128       
     129        async_serialize_end();
     130       
     131        if (retval != EOK) {
     132                if (handle != NULL) {
     133                        *handle = -1;
     134                }
     135                return retval;
     136        }       
     137       
     138        if (handle != NULL)
     139                *handle = (int) IPC_GET_ARG1(answer);   
     140}
     141
    108142void devman_hangup_phone(devman_interface_t iface)
    109143{
  • uspace/lib/libc/include/devman.h

    r084ff99 r7707954  
    4141#include <bool.h>
    4242
    43 extern int devman_get_phone(devman_interface_t, unsigned int);
    44 extern void devman_hangup_phone(devman_interface_t iface);
    4543
    46 extern int devman_driver_register(const char *, async_client_conn_t);
     44int devman_get_phone(devman_interface_t, unsigned int);
     45void devman_hangup_phone(devman_interface_t iface);
     46
     47int devman_driver_register(const char *, async_client_conn_t);
     48int devman_child_device_register(const char *name, long parent_handle, long *handle);
    4749
    4850
  • uspace/lib/libdrv/generic/driver.c

    r084ff99 r7707954  
    129129static void driver_connection(ipc_callid_t iid, ipc_call_t *icall)
    130130{
    131         ipc_callid_t callid;
    132131        /* Select interface */
    133132        switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
     
    151150}
    152151
     152bool child_device_register(device_t *child, const char *child_name, device_t *parent)
     153{
     154        if (devman_child_device_register(child_name, parent->handle, &child->handle)) {
     155                // TODO initialize child device
     156                return true;
     157        }
     158        return false;
     159}
     160
    153161int driver_main(driver_t *drv)
    154162{
  • uspace/lib/libdrv/include/driver.h

    r084ff99 r7707954  
    3838#include <adt/list.h>
    3939
    40 
    41 
    4240typedef struct device {
    4341        long handle;
     
    6159int driver_main(driver_t *drv);
    6260
     61static inline device_t * create_device()
     62{
     63        device_t *dev = malloc(sizeof(device_t));
     64        if (NULL != dev) {
     65                memset(dev, 0, sizeof(device_t));
     66        }
     67       
     68        return dev;
     69}
     70
     71bool child_device_register(device_t *child, const char *child_name, device_t *parent);
     72
     73
     74
    6375#endif
    6476
Note: See TracChangeset for help on using the changeset viewer.