Changeset c16cf62 in mainline for uspace/srv/drivers/root/root.c
- Timestamp:
- 2010-02-26T14:22:33Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67ba309
- Parents:
- 92413de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/drivers/root/root.c
r92413de rc16cf62 28 28 29 29 /** 30 * @defgroup root device driver.30 * @defgroup root Root device driver. 31 31 * @brief HelenOS root device driver. 32 32 * @{ … … 37 37 38 38 #include <assert.h> 39 #include <ipc/services.h>40 #include <ipc/ns.h>41 #include <async.h>42 39 #include <stdio.h> 43 40 #include <errno.h> … … 48 45 #include <ctype.h> 49 46 47 #include <driver.h> 50 48 #include <devman.h> 51 49 #include <ipc/devman.h> 52 50 53 54 ////////////////////////////////////////55 // rudiments of generic driver support56 // TODO - create library(ies) for this functionality57 ////////////////////////////////////////58 59 typedef enum {60 DRIVER_DEVMAN = 1,61 DRIVER_CLIENT,62 DRIVER_DRIVER63 } driver_interface_t;64 65 typedef struct device {66 int parent_handle;67 ipcarg_t parent_phone;68 // TODO add more items - parent bus type etc.69 int handle;70 } device_t;71 72 typedef struct driver_ops {73 bool (*add_device)(device_t *dev);74 // TODO add other generic driver operations75 } driver_ops_t;76 77 typedef struct driver {78 const char *name;79 driver_ops_t *driver_ops;80 } driver_t;81 82 83 static driver_t *driver;84 85 86 static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)87 {88 /* Accept connection */89 ipc_answer_0(iid, EOK);90 91 bool cont = true;92 while (cont) {93 ipc_call_t call;94 ipc_callid_t callid = async_get_call(&call);95 96 switch (IPC_GET_METHOD(call)) {97 case IPC_M_PHONE_HUNGUP:98 cont = false;99 continue;100 case DRIVER_ADD_DEVICE:101 // TODO102 break;103 default:104 if (!(callid & IPC_CALLID_NOTIFICATION))105 ipc_answer_0(callid, ENOENT);106 }107 }108 109 }110 111 static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)112 {113 // TODO later114 }115 116 static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)117 {118 // TODO later119 }120 121 122 123 124 /** Function for handling connections to device driver.125 *126 */127 static void driver_connection(ipc_callid_t iid, ipc_call_t *icall)128 {129 ipc_callid_t callid;130 /* Select interface */131 switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {132 case DRIVER_DEVMAN:133 // handle PnP events from device manager134 driver_connection_devman(iid, icall);135 break;136 case DRIVER_DRIVER:137 // handle request from drivers of child devices138 driver_connection_driver(iid, icall);139 break;140 case DRIVER_CLIENT:141 // handle requests from client applications142 driver_connection_client(iid, icall);143 break;144 145 default:146 /* No such interface */147 ipc_answer_0(iid, ENOENT);148 }149 }150 151 152 153 int driver_main(driver_t *drv)154 {155 // remember driver structure - driver_ops will be called by generic handler for incoming connections156 driver = drv;157 158 // register driver by device manager with generic handler for incoming connections159 printf("%s: sending registration request to devman.\n", driver->name);160 devman_driver_register(driver->name, driver_connection);161 162 async_manager();163 164 // Never reached165 return 0;166 167 }168 169 ////////////////////////////////////////170 // ROOT driver171 ////////////////////////////////////////172 173 51 #define NAME "root" 174 52 175 176 177 bool root_add_device(device_t *dev) 178 { 179 // TODO add root device and register its children 180 return true; 181 } 53 static bool root_add_device(device_t *dev); 54 static bool root_init(); 182 55 183 56 static driver_ops_t root_ops = { … … 190 63 }; 191 64 192 bool root_init() 65 static bool root_add_device(device_t *dev) 66 { 67 // TODO add root device and register its children 68 return true; 69 } 70 71 static bool root_init() 193 72 { 194 73 // TODO driver initialization … … 206 85 return driver_main(&root_driver); 207 86 } 87 88 /** 89 * @} 90 */
Note:
See TracChangeset
for help on using the changeset viewer.