Changeset 08d9525a in mainline


Ignore:
Timestamp:
2010-05-12T10:22:22Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4ef3c2
Parents:
f031713
Message:

add default handler for client requests which do not use any of the standard interfaces

Location:
uspace/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/ipc/dev_iface.h

    rf031713 r08d9525a  
    4646
    4747#define DEV_IFACE_COUNT DEV_IFACE_MAX
     48#define DEV_FIRST_CUSTOM_METHOD DEV_IFACE_MAX
    4849
    4950
  • uspace/lib/libdrv/generic/driver.c

    rf031713 r08d9525a  
    253253                       
    254254                        if (!is_valid_iface_idx(iface_idx)) {
    255                                 // this is not device's interface
     255                                remote_handler_t *default_handler;
     256                                if (NULL != (default_handler = device_get_default_handler(dev))) {
     257                                        (*default_handler)(dev, callid, &call);
     258                                        break;
     259                                }
     260                                // this is not device's interface and the default handler is not provided
    256261                                printf("%s: driver_connection_gen error - invalid interface id %d.", driver->name, iface_idx);
    257262                                ipc_answer_0(callid, ENOTSUP);
  • uspace/lib/libdrv/include/driver.h

    rf031713 r08d9525a  
    5656typedef void remote_iface_func_t(device_t*, void *, ipc_callid_t, ipc_call_t *);
    5757typedef remote_iface_func_t *remote_iface_func_ptr_t;
     58typedef void remote_handler_t(device_t*, ipc_callid_t, ipc_call_t *);
    5859
    5960typedef struct {
     
    8687        /** Optional callback function called when a client is disconnecting from the device. */
    8788        void (*close)(device_t *dev);
    88         /** The table of interfaces implemented by the device. */
     89        /** The table of standard interfaces implemented by the device. */
    8990        void *interfaces[DEV_IFACE_COUNT];     
     91        /** The default handler of remote client requests. If the client's remote request cannot be handled
     92         * by any of the standard interfaces, the default handler is used.*/
     93        remote_handler_t *default_handler;
    9094} device_class_t;
    9195
     
    270274int unregister_interrupt_handler(device_t *dev, int irq);
    271275
     276
     277// default handler for client requests
     278
     279static inline remote_handler_t * device_get_default_handler(device_t *dev)
     280{
     281        if (NULL == dev->class) {
     282                return NULL;
     283        }
     284       
     285        return dev->class->default_handler;     
     286}
     287
    272288#endif
    273289
Note: See TracChangeset for help on using the changeset viewer.