source: rtems/cpukit/libdrvmgr/drvmgr_internal.h @ bc5b56a

5
Last change on this file since bc5b56a was 98b52e3, checked in by Sebastian Huber <sebastian.huber@…>, on 12/04/17 at 07:48:10

drvmgr: Use API mutex

  • Property mode set to 100644
File size: 2.0 KB
Line 
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 */
15struct 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;
24        struct drvmgr_dev       root_dev;
25
26        /*!< Linked list of all registered drivers */
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];
46        /*!< Devices failed to initialize, removed, ignored, no driver */
47        struct drvmgr_list      devices_inactive;
48};
49
50extern struct drvmgr drvmgr;
51
52extern void _DRV_Manager_Lock(void);
53extern 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
Note: See TracBrowser for help on using the repository browser.