RTEMS  5.1
drvmgr_internal.h
1 /* Private driver manager declarations
2  *
3  * COPYRIGHT (c) 2009 Cobham Gaisler AB.
4  *
5  * The license and distribution terms for this file may be
6  * found in the file LICENSE in this distribution or at
7  * http://www.rtems.org/license/LICENSE.
8  */
9 
10 #include <rtems/score/apimutex.h>
11 
12 /* Structure hold all information the driver manager needs to know of. Used
13  * internally by Driver Manager routines.
14  */
15 struct drvmgr {
16  int level;
17  int initializing_objs;
18 
19  /* Device tree Lock */
20  API_Mutex_Control lock;
21 
22  /* The first device - The root device and it's driver */
23  struct drvmgr_drv *root_drv;
25 
27  struct drvmgr_list drivers;
28 
29  /* Buses that reached a certain initialization level.
30  * Lists by Level:
31  * N=0 - Not intialized, just registered
32  * N=1..MAX-1 - Reached init level N
33  * N=MAX - Successfully initialized bus
34  */
35  struct drvmgr_list buses[DRVMGR_LEVEL_MAX+1];
36  /* Buses failed to initialize or has been removed by not freed */
37  struct drvmgr_list buses_inactive;
38 
39  /* Devices that reached a certain initialization level.
40  * Lists by Level:
41  * N=0 - Not intialized, just registered
42  * N=1..MAX-1 - Reached init level N
43  * N=MAX - Successfully initialized device
44  */
45  struct drvmgr_list devices[DRVMGR_LEVEL_MAX+1];
47  struct drvmgr_list devices_inactive;
48 };
49 
50 extern struct drvmgr drvmgr;
51 
52 extern void _DRV_Manager_Lock(void);
53 extern void _DRV_Manager_Unlock(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_WRITE() _DRV_Manager_Lock()
61  #define DRVMGR_LOCK_READ() _DRV_Manager_Lock()
62  #define DRVMGR_UNLOCK() _DRV_Manager_Unlock()
63 #else
64  /* no locking */
65  #define DRVMGR_LOCK_WRITE()
66  #define DRVMGR_LOCK_READ()
67  #define DRVMGR_UNLOCK()
68 #endif
struct drvmgr_dev root_dev
Definition: drvmgr_internal.h:24
struct drvmgr_list devices[DRVMGR_LEVEL_MAX+1]
Definition: drvmgr_internal.h:45
Definition: drvmgr.h:275
API Mutex Handler API.
Definition: drvmgr_internal.h:15
Control block used to manage each API mutex.
Definition: apimutex.h:42
Definition: drvmgr.h:305
Definition: drvmgr_list.h:24