RTEMS 6.1-rc6
Loading...
Searching...
No Matches
drvmgr_internal.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/* Private driver manager declarations
4 *
5 * COPYRIGHT (c) 2009 Cobham Gaisler AB.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31/* Structure hold all information the driver manager needs to know of. Used
32 * internally by Driver Manager routines.
33 */
34struct drvmgr {
35 int level;
36 int initializing_objs;
37
38 /* Device tree Lock */
40
41 /* The first device - The root device and it's driver */
42 struct drvmgr_drv *root_drv;
44
46 struct drvmgr_list drivers;
47
48 /* Buses that reached a certain initialization level.
49 * Lists by Level:
50 * N=0 - Not intialized, just registered
51 * N=1..MAX-1 - Reached init level N
52 * N=MAX - Successfully initialized bus
53 */
54 struct drvmgr_list buses[DRVMGR_LEVEL_MAX+1];
55 /* Buses failed to initialize or has been removed by not freed */
56 struct drvmgr_list buses_inactive;
57
58 /* Devices that reached a certain initialization level.
59 * Lists by Level:
60 * N=0 - Not intialized, just registered
61 * N=1..MAX-1 - Reached init level N
62 * N=MAX - Successfully initialized device
63 */
64 struct drvmgr_list devices[DRVMGR_LEVEL_MAX+1];
66 struct drvmgr_list devices_inactive;
67};
68
69extern struct drvmgr drvmgr;
70
71extern void _DRV_Manager_Lock(void);
72extern void _DRV_Manager_Unlock(void);
73
74/* The best solution is to implement the locking with a RW lock, however there
75 * is no such API available. Care must be taken so that dead-lock isn't created
76 * for example in recursive functions.
77 */
78#if defined(DRVMGR_USE_LOCKS) && (DRVMGR_USE_LOCKS == 1)
79 #define DRVMGR_LOCK_WRITE() _DRV_Manager_Lock()
80 #define DRVMGR_LOCK_READ() _DRV_Manager_Lock()
81 #define DRVMGR_UNLOCK() _DRV_Manager_Unlock()
82#else
83 /* no locking */
84 #define DRVMGR_LOCK_WRITE()
85 #define DRVMGR_LOCK_READ()
86 #define DRVMGR_UNLOCK()
87#endif
This header file provides the interfaces of the API Mutex Handler.
Control block used to manage each API mutex.
Definition: apimutex.h:65
Definition: drvmgr.h:297
Definition: drvmgr.h:327
Definition: drvmgr_list.h:48
Definition: drvmgr_internal.h:34
struct drvmgr_list devices[DRVMGR_LEVEL_MAX+1]
Definition: drvmgr_internal.h:64
struct drvmgr_dev root_dev
Definition: drvmgr_internal.h:43