Changeset c16cf62 in mainline
- Timestamp:
- 2010-02-26T14:22:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67ba309
- Parents:
- 92413de
- Location:
- uspace
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r92413de rc16cf62 97 97 lib/softint \ 98 98 lib/softfloat \ 99 lib/libdrv 99 100 100 101 ifeq ($(UARCH),amd64) -
uspace/lib/libc/include/devman.h
r92413de rc16cf62 1 1 /* 2 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2010 Lenka Trochtova *3 * Copyright (c) 2010 Lenka Trochtova 4 4 * All rights reserved. 5 5 * -
uspace/lib/libc/include/ipc/devman.h
r92413de rc16cf62 55 55 } devman_to_driver_t; 56 56 57 #endif 57 58 58 59 60 61 62 63 64 65 #endif 59 /** @} 60 */ -
uspace/srv/Makefile.common
r92413de rc16cf62 49 49 LIBPCI_PREFIX = $(USPACE_PREFIX)/lib/libpci 50 50 SOFTINT_PREFIX = $(USPACE_PREFIX)/lib/softint 51 LIBDRV_PREFIX = $(USPACE_PREFIX)/lib/libdrv 51 52 52 53 LINK_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld -
uspace/srv/devman/devman.c
r92413de rc16cf62 428 428 } 429 429 430 void set_driver_phone(driver_t *driver, ipcarg_t phone) 431 { 432 fibril_mutex_lock(&driver->driver_mutex); 433 assert(DRIVER_STARTING == driver->state); 434 driver->phone = phone; 435 fibril_mutex_unlock(&driver->driver_mutex); 436 } 437 438 /** 439 * Notify driver about the devices to which it was assigned. 440 * 441 * The driver's mutex must be locked. 442 * 443 * @param driver the driver to which the devices are passed. 444 */ 445 static void pass_devices_to_driver(driver_t *driver) 446 { 447 node_t *dev; 448 link_t *link; 449 450 link = driver->devices.next; 451 while (link != &driver->devices) { 452 dev = list_get_instance(link, node_t, driver_devices); 453 add_device(driver, dev); 454 link = link->next; 455 } 456 } 457 458 /** Finish the initialization of a driver after it has succesfully started and registered itself by the device manager. 459 * 460 * Pass devices formerly matched to the driver to the driver and remember the driver is running and fully functional now. 461 * 462 * @param driver the driver which registered itself as running by the device manager. 463 */ 464 void initialize_running_driver(driver_t *driver) 465 { 466 fibril_mutex_lock(&driver->driver_mutex); 467 468 // pass devices which have been already assigned to the driver to the driver 469 pass_devices_to_driver(driver); 470 471 // change driver's state to running 472 driver->state = DRIVER_RUNNING; 473 474 fibril_mutex_unlock(&driver->driver_mutex); 475 } 476 430 477 /** Pass a device to running driver. 431 478 * 432 479 * @param drv the driver's structure. 433 480 * @param node the device's node in the device tree. 434 * 435 * @return true on success, false otherwise. 436 */ 437 bool add_device(driver_t *drv, node_t *node) 481 */ 482 void add_device(driver_t *drv, node_t *node) 438 483 { 439 484 printf(NAME ": add_device\n"); … … 506 551 } 507 552 553 /** @} 554 */ -
uspace/srv/devman/devman.h
r92413de rc16cf62 191 191 void add_driver(driver_list_t *drivers_list, driver_t *drv); 192 192 void attach_driver(node_t *node, driver_t *drv); 193 booladd_device(driver_t *drv, node_t *node);193 void add_device(driver_t *drv, node_t *node); 194 194 bool start_driver(driver_t *drv); 195 195 196 196 driver_t * find_driver(driver_list_t *drv_list, const char *drv_name); 197 void set_driver_phone(driver_t *driver, ipcarg_t phone); 198 void initialize_running_driver(driver_t *driver); 197 199 198 200 … … 260 262 261 263 #endif 264 265 /** @} 266 */ -
uspace/srv/devman/main.c
r92413de rc16cf62 60 60 61 61 /** 62 *63 *64 * Driver's mutex must be locked.65 */66 static void pass_devices_to_driver(driver_t *driver)67 {68 69 70 71 72 }73 74 static void init_running_driver(driver_t *driver)75 {76 fibril_mutex_lock(&driver->driver_mutex);77 78 // pass devices which have been already assigned to the driver to the driver79 pass_devices_to_driver(driver);80 81 // change driver's state to running82 driver->state = DRIVER_RUNNING;83 84 fibril_mutex_unlock(&driver->driver_mutex);85 }86 87 /**88 62 * Register running driver. 89 63 */ … … 134 108 } 135 109 136 fibril_mutex_lock(&driver->driver_mutex); 137 assert(DRIVER_STARTING == driver->state); 138 driver->phone = IPC_GET_ARG5(call); 139 fibril_mutex_unlock(&driver->driver_mutex); 110 // remember driver's phone 111 set_driver_phone(driver, IPC_GET_ARG5(call)); 140 112 141 113 printf(NAME ": the %s driver was successfully registered as running.\n", driver->name); … … 160 132 return; 161 133 162 init _running_driver(driver);134 initialize_running_driver(driver); 163 135 164 136 ipc_callid_t callid; … … 251 223 return 0; 252 224 } 225 226 /** @} 227 */ -
uspace/srv/drivers/root/Makefile
r92413de rc16cf62 27 27 28 28 USPACE_PREFIX = ../../.. 29 LIBS = $(LIBC_PREFIX)/libc.a 29 LIBS = $(LIBC_PREFIX)/libc.a $(LIBDRV_PREFIX)/libdrv.a 30 30 31 31 OUTPUT = root … … 35 35 36 36 include ../../Makefile.common 37 38 EXTRA_CFLAGS = -I$(LIBDRV_PREFIX)/include -
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.