source: rtems/cpukit/libdrvmgr/drvmgr_internal.h @ 30594a9

4.115
Last change on this file since 30594a9 was e7fade3, checked in by Daniel Hellstrom <daniel@…>, on 11/28/11 at 08:52:03

DRVMGR: added driver manager to cpukit/libdrvmgr

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/* Private driver manager declarations
2 *
3 * COPYRIGHT (c) 2009.
4 * Cobham Gaisler AB.
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rtems.com/license/LICENSE.
9 */
10
11/*  Structure hold all information the driver manager needs to know of. Used
12 *  internally by Driver Manager routines.
13 */
14struct rtems_driver_manager {
15        int     level;
16        int     initializing_objs;
17
18        /* Device tree Lock */
19        rtems_id                lock;
20
21        /* The first device - The root device and it's driver */
22        struct drvmgr_drv       *root_drv;
23        struct drvmgr_dev       root_dev;
24
25        /*!< Linked list of all registered drivers */
26        struct drvmgr_list      drivers;
27
28        /* Buses that reached a certain initialization level.
29         * Lists by Level:
30         *  N=0         - Not intialized, just registered
31         *  N=1..MAX-1  - Reached init level N
32         *  N=MAX       - Successfully initialized bus
33         */
34        struct drvmgr_list      buses[DRVMGR_LEVEL_MAX+1];
35        /* Buses failed to initialize or has been removed by not freed */
36        struct drvmgr_list      buses_inactive;
37
38        /* Devices that reached a certain initialization level.
39         * Lists by Level:
40         *  N=0         - Not intialized, just registered
41         *  N=1..MAX-1  - Reached init level N
42         *  N=MAX       - Successfully initialized device
43         */
44        struct drvmgr_list      devices[DRVMGR_LEVEL_MAX+1];
45        /*!< Devices failed to initialize, removed, ignored, no driver */
46        struct drvmgr_list      devices_inactive;
47};
48
49extern struct rtems_driver_manager drv_mgr;
50
51extern void _DRV_Manager_Lock(void);
52extern void _DRV_Manager_Unlock(void);
53extern int _DRV_Manager_Init_Lock(void);
54
55/* The best solution is to implement the locking with a RW lock, however there
56 * is no such API available. Care must be taken so that dead-lock isn't created
57 * for example in recursive functions.
58 */
59#if defined(DRVMGR_USE_LOCKS) && (DRVMGR_USE_LOCKS == 1)
60 #define DRVMGR_LOCK_INIT() _DRV_Manager_Init_Lock()
61 #define DRVMGR_LOCK_WRITE() _DRV_Manager_Lock()
62 #define DRVMGR_LOCK_READ() _DRV_Manager_Lock()
63 #define DRVMGR_UNLOCK() _DRV_Manager_Unlock()
64#else
65 /* no locking */
66 #define DRVMGR_LOCK_INIT()
67 #define DRVMGR_LOCK_WRITE()
68 #define DRVMGR_LOCK_READ()
69 #define DRVMGR_UNLOCK()
70#endif
Note: See TracBrowser for help on using the repository browser.