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 | /* Structure hold all information the driver manager needs to know of. Used |
---|
11 | * internally by Driver Manager routines. |
---|
12 | */ |
---|
13 | struct drvmgr { |
---|
14 | int level; |
---|
15 | int initializing_objs; |
---|
16 | |
---|
17 | /* Device tree Lock */ |
---|
18 | rtems_id lock; |
---|
19 | |
---|
20 | /* The first device - The root device and it's driver */ |
---|
21 | struct drvmgr_drv *root_drv; |
---|
22 | struct drvmgr_dev root_dev; |
---|
23 | |
---|
24 | /*!< Linked list of all registered drivers */ |
---|
25 | struct drvmgr_list drivers; |
---|
26 | |
---|
27 | /* Buses that reached a certain initialization level. |
---|
28 | * Lists by Level: |
---|
29 | * N=0 - Not intialized, just registered |
---|
30 | * N=1..MAX-1 - Reached init level N |
---|
31 | * N=MAX - Successfully initialized bus |
---|
32 | */ |
---|
33 | struct drvmgr_list buses[DRVMGR_LEVEL_MAX+1]; |
---|
34 | /* Buses failed to initialize or has been removed by not freed */ |
---|
35 | struct drvmgr_list buses_inactive; |
---|
36 | |
---|
37 | /* Devices that reached a certain initialization level. |
---|
38 | * Lists by Level: |
---|
39 | * N=0 - Not intialized, just registered |
---|
40 | * N=1..MAX-1 - Reached init level N |
---|
41 | * N=MAX - Successfully initialized device |
---|
42 | */ |
---|
43 | struct drvmgr_list devices[DRVMGR_LEVEL_MAX+1]; |
---|
44 | /*!< Devices failed to initialize, removed, ignored, no driver */ |
---|
45 | struct drvmgr_list devices_inactive; |
---|
46 | }; |
---|
47 | |
---|
48 | extern struct drvmgr drvmgr; |
---|
49 | |
---|
50 | extern void _DRV_Manager_Lock(void); |
---|
51 | extern void _DRV_Manager_Unlock(void); |
---|
52 | extern int _DRV_Manager_Init_Lock(void); |
---|
53 | |
---|
54 | /* The best solution is to implement the locking with a RW lock, however there |
---|
55 | * is no such API available. Care must be taken so that dead-lock isn't created |
---|
56 | * for example in recursive functions. |
---|
57 | */ |
---|
58 | #if defined(DRVMGR_USE_LOCKS) && (DRVMGR_USE_LOCKS == 1) |
---|
59 | #define DRVMGR_LOCK_INIT() _DRV_Manager_Init_Lock() |
---|
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_INIT() |
---|
66 | #define DRVMGR_LOCK_WRITE() |
---|
67 | #define DRVMGR_LOCK_READ() |
---|
68 | #define DRVMGR_UNLOCK() |
---|
69 | #endif |
---|