RTEMS 6.1-rc5
Loading...
Searching...
No Matches
drvmgr.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
9/*
10 * COPYRIGHT (c) 2009 Cobham Gaisler AB.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _DRIVER_MANAGER_H_
35#define _DRIVER_MANAGER_H_
36
37#include <rtems.h>
38#include <drvmgr/drvmgr_list.h>
39#include <stdint.h>
41#include <rtems/score/smpimpl.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/*** Configure Driver manager ***/
48
49/* Define the number of initialization levels of device drivers */
50#define DRVMGR_LEVEL_MAX 4
51
52/* Default to use semahpores for protection. Initialization works without
53 * locks and after initialization too if devices are not removed.
54 */
55#ifndef DRVMGR_USE_LOCKS
56#define DRVMGR_USE_LOCKS 1
57#endif
58
59struct drvmgr_dev; /* Device */
60struct drvmgr_bus; /* Bus */
61struct drvmgr_drv; /* Driver */
62
63/*** List Interface shortcuts ***/
64#define BUS_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_bus)
65#define BUS_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_bus)
66#define DEV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_dev)
67#define DEV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_dev)
68#define DRV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_drv)
69#define DRV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_drv)
70
71/*** Bus indentification ***/
72#define DRVMGR_BUS_TYPE_NONE 0 /* Not a valid bus */
73#define DRVMGR_BUS_TYPE_ROOT 1 /* Hard coded bus */
74#define DRVMGR_BUS_TYPE_PCI 2 /* PCI bus */
75#define DRVMGR_BUS_TYPE_AMBAPP 3 /* AMBA Plug & Play bus */
76#define DRVMGR_BUS_TYPE_LEON2_AMBA 4 /* LEON2 hardcoded bus */
77#define DRVMGR_BUS_TYPE_AMBAPP_DIST 5 /* Distibuted AMBA Plug & Play bus accessed using a communication interface */
78#define DRVMGR_BUS_TYPE_SPW_RMAP 6 /* SpaceWire Network bus */
79#define DRVMGR_BUS_TYPE_AMBAPP_RMAP 7 /* SpaceWire RMAP accessed AMBA Plug & Play bus */
80
81enum {
82 DRVMGR_OBJ_NONE = 0,
83 DRVMGR_OBJ_DRV = 1,
84 DRVMGR_OBJ_BUS = 2,
85 DRVMGR_OBJ_DEV = 3,
86};
87
88/*** Driver indentification ***
89 *
90 * 64-bit identification integer definition
91 * * Bus ID 8-bit [7..0]
92 * * Reserved 8-bit field [63..56]
93 * * Device ID specific for bus type 48-bit [55..8] (Different buses have
94 * different unique identifications for hardware/driver.)
95 *
96 * ID Rules
97 * * A root bus driver must always have device ID set to 0. There can only by
98 * one root bus driver for a certain bus type.
99 * * A Driver ID must identify a unique hardware core
100 *
101 */
102
103/* Bus ID Mask */
104#define DRIVER_ID_BUS_MASK 0x00000000000000FFULL
105
106/* Reserved Mask for future use */
107#define DRIVER_ID_RSV_MASK 0xFF00000000000000ULL
108
109/* Reserved Mask for future use */
110#define DRIVER_ID_DEV_MASK 0x00FFFFFFFFFFFF00ULL
111
112/* Set Bus ID Mask. */
113#define DRIVER_ID(busid, devid) ((unsigned long long) \
114 ((((unsigned long long)(devid) << 8) & DRIVER_ID_DEV_MASK) | \
115 ((unsigned long long)(busid) & DRIVER_ID_BUS_MASK)))
116
117/* Get IDs */
118#define DRIVER_BUSID_GET(id) ((unsigned long long)(id) & DRIVER_ID_BUS_MASK)
119#define DRIVER_DEVID_GET(id) (((unsigned long long)(id) & DRIVER_ID_DEV_MASK) >> 8)
120
121#define DRIVER_ROOTBUS_ID(bus_type) DRIVER_ID(bus_type, 0)
122
123/*** Root Bus drivers ***/
124
125/* Generic Hard coded Root bus: Driver ID */
126#define DRIVER_ROOT_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_ROOT)
127
128/* PCI Plug & Play bus: Driver ID */
129#define DRIVER_PCIBUS_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_PCI)
130
131/* AMBA Plug & Play bus: Driver ID */
132#define DRIVER_GRLIB_AMBAPP_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP)
133
134/* AMBA Hard coded bus: Driver ID */
135#define DRIVER_LEON2_AMBA_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_LEON2_AMBA)
136
137/* Distributed AMBA Plug & Play bus: Driver ID */
138#define DRIVER_AMBAPP_DIST_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP_DIST)
139
147};
148
149/* Interrupt Service Routine (ISR) */
150typedef void (*drvmgr_isr)(void *arg);
151
154 /* Functions used internally within driver manager */
155 int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_bus *);
156 int (*remove)(struct drvmgr_bus *);
157 int (*unite)(struct drvmgr_drv *, struct drvmgr_dev *);
159 /* Functions called indirectly from drivers */
160 int (*int_register)(struct drvmgr_dev *, int index, const char *info, drvmgr_isr isr, void *arg);
161 int (*int_unregister)(struct drvmgr_dev *, int index, drvmgr_isr isr, void *arg);
162 int (*int_clear)(struct drvmgr_dev *, int index);
163 int (*int_mask)(struct drvmgr_dev *, int index);
164 int (*int_unmask)(struct drvmgr_dev *, int index);
165#ifdef RTEMS_SMP
166 int (*int_set_affinity)(struct drvmgr_dev *, int index,
167 const Processor_mask *cpus);
168#endif
169
170 /* Get Parameters */
171 int (*get_params)(struct drvmgr_dev *, struct drvmgr_bus_params *);
172 /* Get Frequency of Bus */
173 int (*get_freq)(struct drvmgr_dev*, int, unsigned int*);
177 void (*get_info_dev)(struct drvmgr_dev *,
178 void (*print)(void *p, char *str), void *p);
179};
180#define BUS_OPS_NUM (sizeof(struct drvmgr_bus_ops)/sizeof(void (*)(void)))
181
183 int funcid;
184 void *func;
185};
186#define DRVMGR_FUNC(_ID_, _FUNC_) {(int)(_ID_), (void *)(_FUNC_)}
187#define DRVMGR_FUNC_END {0, NULL}
188
189/*** Resource definitions ***
190 *
191 * Overview of structures:
192 * All bus resources entries (_bus_res) are linked together per bus
193 * (bus_info->reslist). One bus resource entry has a pointer to an array of
194 * driver resources (_drv_res). One driver resouces is made out of an array
195 * of keys (drvmgr_key). All keys belongs to the same driver and harwdare
196 * device. Each key has a Name, Type ID and Data interpreted differently
197 * depending on the Type ID (union drvmgr_key_value).
198 *
199 */
200
201/* Key Data Types */
202enum drvmgr_kt {
203 DRVMGR_KT_ANY = -1,
204 DRVMGR_KT_NONE = 0,
205 DRVMGR_KT_INT = 1,
206 DRVMGR_KT_STRING = 2,
207 DRVMGR_KT_POINTER = 3,
208};
209
210#define DRVMGR_KEY_EMPTY {NULL, DRVMGR_KT_NONE, {0}}
211#define DRVMGR_RES_EMPTY {0, 0, NULL}
212#define MMAP_EMPTY {0, 0, 0}
213
216 unsigned int i;
217 char *str;
218 void *ptr;
219};
220
221/* One key. One Value. Holding information relevant to the driver. */
223 char *key_name; /* Name of key */
224 enum drvmgr_kt key_type; /* How to interpret key_value */
225 union drvmgr_key_value key_value; /* The value or pointer to value */
226};
227
232 uint64_t drv_id;
234 struct drvmgr_key *keys;
235};
236
241};
242
250 char *name;
251 unsigned int size;
252 char *from_adr;
254 char *to_adr;
256};
257#define DRVMGR_TRANSLATE_ONE2ONE NULL
258#define DRVMGR_TRANSLATE_NO_BRIDGE ((void *)1) /* No bridge, error */
259
263 unsigned char bus_type;
264 unsigned char depth;
265 struct drvmgr_bus *next;
266 struct drvmgr_dev *dev;
267 void *priv;
276 /* Bus status */
277 int level;
278 int state;
279 int error;
280};
281
282/* States of a bus */
283#define BUS_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */
284#define BUS_STATE_LIST_INACTIVE 0x00001000 /* In inactive bus list */
285#define BUS_STATE_DEPEND_FAILED 0x00000004 /* Device init failed */
286
287/* States of a device */
288#define DEV_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */
289#define DEV_STATE_INIT_DONE 0x00000002 /* All init levels completed */
290#define DEV_STATE_DEPEND_FAILED 0x00000004 /* Parent Bus init failed */
291#define DEV_STATE_UNITED 0x00000100 /* Device United with Device Driver */
292#define DEV_STATE_REMOVED 0x00000200 /* Device has been removed (unregistered) */
293#define DEV_STATE_IGNORED 0x00000400 /* Device was ignored according to user's request, the device
294 * was never reported to it's driver (as expected).
295 */
296#define DEV_STATE_LIST_INACTIVE 0x00001000 /* In inactive device list */
301 struct drvmgr_dev *next;
302 struct drvmgr_dev *next_in_bus;
305 struct drvmgr_drv *drv;
307 short minor_drv;
308 short minor_bus;
309 char *name;
310 void *priv;
311 void *businfo;
312 struct drvmgr_bus *bus;
314 /* Device Status */
315 unsigned int state;
316 int level;
317 int error;
318};
322 int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_dev *);
323 int (*remove)(struct drvmgr_dev *);
324 int (*info)(struct drvmgr_dev *, void (*print)(void *p, char *str), void *p, int, char *argv[]);
325};
326#define DRVMGR_OPS_NUM(x) (sizeof(x)/sizeof(void (*)(void)))
331 struct drvmgr_drv *next;
332 struct drvmgr_dev *dev;
334 uint64_t drv_id;
335 char *name;
339 unsigned int dev_cnt;
340 unsigned int dev_priv_size;
341};
342
347typedef void (*drvmgr_drv_reg_func)(void);
348
349/*** DRIVER | DEVICE | BUS FUNCTIONS ***/
350
351/* Return Codes */
352enum {
353 DRVMGR_OK = 0, /* Sucess */
354 DRVMGR_NOMEM = 1, /* Memory allocation error */
355 DRVMGR_EIO = 2, /* I/O error */
356 DRVMGR_EINVAL = 3, /* Invalid parameter */
357 DRVMGR_ENOSYS = 4,
358 DRVMGR_TIMEDOUT = 5, /* Operation timeout error */
359 DRVMGR_EBUSY = 6,
360 DRVMGR_ENORES = 7, /* Not enough resources */
361 DRVMGR_FAIL = -1 /* Unspecified failure */
362};
363
368extern void _DRV_Manager_initialization(void);
369
375extern void _DRV_Manager_init_level(int level);
376
382extern int drvmgr_init(void);
383
384/* Take registered buses and devices into the correct init level,
385 * this function is called from _init_level() so normally
386 * we don't need to call it directly.
387 */
388extern void drvmgr_init_update(void);
389
391extern int drvmgr_root_drv_register(struct drvmgr_drv *drv);
392
394extern int drvmgr_drv_register(struct drvmgr_drv *drv);
395
397extern int drvmgr_dev_register(struct drvmgr_dev *dev);
398
409extern int drvmgr_dev_unregister(struct drvmgr_dev *dev);
410
412extern int drvmgr_bus_register(struct drvmgr_bus *bus);
413
415extern int drvmgr_bus_unregister(struct drvmgr_bus *bus);
416
422extern int drvmgr_children_unregister(struct drvmgr_bus *bus);
423
424/* Separate a device from the driver it has been united with */
425extern int drvmgr_dev_drv_separate(struct drvmgr_dev *dev);
426
433extern int drvmgr_alloc_dev(struct drvmgr_dev **pdev, int extra);
434
441extern int drvmgr_alloc_bus(struct drvmgr_bus **pbus, int extra);
442
443/*** DRIVER RESOURCE FUNCTIONS ***/
444
451extern void drvmgr_bus_res_add(struct drvmgr_bus *bus,
452 struct drvmgr_bus_res *bres);
453
460extern int drvmgr_keys_get(struct drvmgr_dev *dev, struct drvmgr_key **keys);
461
468extern struct drvmgr_key *drvmgr_key_get(struct drvmgr_key *keys, char *key_name);
469
483 struct drvmgr_key *keys,
484 char *key_name,
485 enum drvmgr_kt key_type);
486
500 struct drvmgr_dev *dev,
501 char *key_name,
502 enum drvmgr_kt key_type);
503
504/*** DRIVER INTERACE USED TO REQUEST INFORMATION/SERVICES FROM BUS DRIVER ***/
505
507static inline struct drvmgr_bus *drvmgr_get_parent(
508 struct drvmgr_dev *dev)
509{
510 if (dev)
511 return dev->parent;
512 else
513 return NULL;
514}
515
517static inline struct drvmgr_drv *drvmgr_get_drv(struct drvmgr_dev *dev)
518{
519 if (dev)
520 return dev->drv;
521 else
522 return NULL;
523}
524
537#define DRVMGR_FED_BF 1 /* Breadth-first search */
538#define DRVMGR_FED_DF 0 /* Depth first search */
539extern intptr_t drvmgr_for_each_dev(
540 intptr_t (*func)(struct drvmgr_dev *dev, void *arg),
541 void *arg,
542 int options);
543
552extern int drvmgr_get_dev(
553 struct drvmgr_drv *drv,
554 int minor,
555 struct drvmgr_dev **pdev);
556
563extern int drvmgr_freq_get(
564 struct drvmgr_dev *dev,
565 int options,
566 unsigned int *freq_hz);
567
569extern int drvmgr_on_rootbus(struct drvmgr_dev *dev);
570
577extern int drvmgr_get_dev_prefix(struct drvmgr_dev *dev, char *dev_prefix);
578
593 struct drvmgr_dev *dev,
594 int index,
595 const char *info,
596 drvmgr_isr isr,
597 void *arg);
598
610 struct drvmgr_dev *dev,
611 int index,
612 drvmgr_isr isr,
613 void *arg);
614
624extern int drvmgr_interrupt_clear(
625 struct drvmgr_dev *dev,
626 int index);
627
638extern int drvmgr_interrupt_unmask(
639 struct drvmgr_dev *dev,
640 int index);
641
650extern int drvmgr_interrupt_mask(
651 struct drvmgr_dev *dev,
652 int index);
653
662#ifdef RTEMS_SMP
663extern int drvmgr_interrupt_set_affinity(
664 struct drvmgr_dev *dev,
665 int index,
666 const Processor_mask *cpus);
667#endif
670enum drvmgr_tr_opts {
671 /* Translate CPU RAM Address (input) to DMA unit accessible address
672 * (output), this is an upstreams translation in reverse order.
673 *
674 * Typical Usage:
675 * It is common to translate a CPU accessible RAM address to an
676 * address that DMA units can access over bridges.
677 */
678 CPUMEM_TO_DMA = 0x0,
679
680 /* Translate DMA Unit Accessible address mapped to CPU RAM (input) to
681 * CPU accessible address (output). This is an upstreams translation.
682 *
683 * Typical Usage (not often used):
684 * The DMA unit descriptors contain pointers to DMA buffers located at
685 * CPU RAM addresses that the DMA unit can access, the CPU processes
686 * the descriptors and want to access the data but a translation back
687 * to CPU address is required.
688 */
689 CPUMEM_FROM_DMA = 0x1,
690
691 /* Translate DMA Memory Address (input) to CPU accessible address
692 * (output), this is a downstreams translation in reverse order.
693 *
694 * Typical Usage:
695 * A PCI network card puts packets into its memory not doing DMA over
696 * PCI, in order for the CPU to access them the PCI address must be
697 * translated.
698 */
699 DMAMEM_TO_CPU = 0x2,
700
701 /* Translate CPU accessible address (input) mapped to DMA Memory Address
702 * to DMA Unit accessible address (output). This is a downstreams
703 * translation.
704 */
705 DMAMEM_FROM_CPU = 0x3,
706};
707#define DRVMGR_TR_REVERSE 0x1 /* do reverse translation direction order */
708#define DRVMGR_TR_PATH 0x2 /* 0x0=down-stream 0x2=up-stream address path */
709
746extern unsigned int drvmgr_translate(
747 struct drvmgr_dev *dev,
748 unsigned int options,
749 void *src_address,
750 void **dst_address);
751
752/* Translate addresses between buses, used internally to implement
753 * drvmgr_translate. Function is not limited to translate from/to root bus
754 * where CPU is resident, however buses must be on a straight path relative
755 * to each other (parent of parent of parent and so on).
756 *
757 * \param from src_address is given for this bus
758 * \param to src_address is translated to this bus
759 * \param reverse Selects translation method, if map entries are used in
760 * the reverse order (map_up->to is used as map_up->from)
761 * \param src_address Address to be translated
762 * \param dst_address Translated address is stored here on success (return=0)
763 *
764 * Returns 0 if unable to translate. The remaining length from the given
765 * address of the map is returned on success and the result is stored into
766 * *dst_address. For example if a map starts at 0x40000000 of size 0x100000
767 * the result will be 0x40000 if the address was translated into 0x400C0000.
768 * If dev is on root-bus no translation is performed 0xffffffff is returned.
769 * and src_address is stored in *dst_address.
770 */
771extern unsigned int drvmgr_translate_bus(
772 struct drvmgr_bus *from,
773 struct drvmgr_bus *to,
774 int reverse,
775 void *src_address,
776 void **dst_address);
777
778/* Calls drvmgr_translate() to translate an address range and checks the result,
779 * a printout is generated if the check fails. All parameters are passed on to
780 * drvmgr_translate() except for size, see paramters of drvmgr_translate().
781 *
782 * If size=0 only the starting address is not checked.
783 *
784 * If mapping failes a non-zero result is returned.
785 */
786extern int drvmgr_translate_check(
787 struct drvmgr_dev *dev,
788 unsigned int options,
789 void *src_address,
790 void **dst_address,
791 unsigned int size);
792
797extern int drvmgr_func_get(void *obj, int funcid, void **func);
798
800extern int drvmgr_func_call(void *obj, int funcid, void *a, void *b, void *c, void *d);
801
802/* Builds a Function ID.
803 *
804 * Used to request optional functions by a bus or device driver
805 */
806#define DRVMGR_FUNCID(major, minor) ((((major) & 0xfff) << 20) | ((minor) & 0xfffff))
807#define DRVMGR_FUNCID_NONE 0
808#define DRVMGR_FUNCID_END DRVMGR_FUNCID(DRVMGR_FUNCID_NONE, 0)
809
810/* Major Function ID. Most significant 12-bits. */
811enum {
812 FUNCID_NONE = 0x000,
813 FUNCID_RW = 0x001, /* Read/Write functions */
814};
815
816/* Select Sub-Function Read/Write function by ID */
817#define RW_SIZE_1 0x00001 /* Access Size */
818#define RW_SIZE_2 0x00002
819#define RW_SIZE_4 0x00004
820#define RW_SIZE_8 0x00008
821#define RW_SIZE_ANY 0x00000
822#define RW_SIZE(id) ((unsigned int)(id) & 0xf)
823
824#define RW_DIR_ANY 0x00000 /* Access Direction */
825#define RW_READ 0x00000 /* Read */
826#define RW_WRITE 0x00010 /* Write */
827#define RW_SET 0x00020 /* Write with same value (memset) */
828#define RW_DIR(id) (((unsigned int)(id) >> 4) & 0x3)
829
830#define RW_RAW 0x00000 /* Raw access - no swapping (machine default) */
831#define RW_LITTLE 0x00040 /* Little Endian */
832#define RW_BIG 0x00080 /* Big Endian */
833#define RW_ENDIAN(id) (((unsigned int)(id) >> 6) & 0x3)
834
835#define RW_TYPE_ANY 0x00000 /* Access type */
836#define RW_REG 0x00100
837#define RW_MEM 0x00200
838#define RW_MEMREG 0x00300
839#define RW_CFG 0x00400
840#define RW_TYPE(id) (((unsigned int)(id) >> 8) & 0xf)
841
842#define RW_ARG 0x01000 /* Optional Argument */
843#define RW_ERR 0x02000 /* Optional Error Handler */
844
845/* Build a Read/Write function ID */
846#define DRVMGR_RWFUNC(minor) DRVMGR_FUNCID(FUNCID_RW, minor)
847
848/* Argument to Read/Write functions, the "void *arg" pointer is returned by
849 * RW_ARG. If NULL is returned no argument is needed.
850 */
851struct drvmgr_rw_arg {
852 void *arg;
853 struct drvmgr_dev *dev;
854};
855
856/* Standard Read/Write function types */
857typedef uint8_t (*drvmgr_r8)(uint8_t *srcadr);
858typedef uint16_t (*drvmgr_r16)(uint16_t *srcadr);
859typedef uint32_t (*drvmgr_r32)(uint32_t *srcadr);
860typedef uint64_t (*drvmgr_r64)(uint64_t *srcadr);
861typedef void (*drvmgr_w8)(uint8_t *dstadr, uint8_t data);
862typedef void (*drvmgr_w16)(uint16_t *dstadr, uint16_t data);
863typedef void (*drvmgr_w32)(uint32_t *dstadr, uint32_t data);
864typedef void (*drvmgr_w64)(uint64_t *dstadr, uint64_t data);
865/* READ/COPY a memory area located on bus into CPU memory.
866 * From 'src' (remote) to the destination 'dest' (local), n=number of bytes
867 */
868typedef int (*drvmgr_rmem)(void *dest, const void *src, int n);
869/* WRITE/COPY a user buffer located in CPU memory to a location on the bus.
870 * From 'src' (local) to the destination 'dest' (remote), n=number of bytes
871 */
872typedef int (*drvmgr_wmem)(void *dest, const void *src, int n);
873/* Set a memory area to the byte value given in c, see LIBC memset(). Memset is
874 * implemented by calling wmem() multiple times with a "large" buffer.
875 */
876typedef int (*drvmgr_memset)(void *dstadr, int c, size_t n);
877
878/* Read/Write function types with additional argument */
879typedef uint8_t (*drvmgr_r8_arg)(uint8_t *srcadr, void *a);
880typedef uint16_t (*drvmgr_r16_arg)(uint16_t *srcadr, void *a);
881typedef uint32_t (*drvmgr_r32_arg)(uint32_t *srcadr, void *a);
882typedef uint64_t (*drvmgr_r64_arg)(uint64_t *srcadr, void *a);
883typedef void (*drvmgr_w8_arg)(uint8_t *dstadr, uint8_t data, void *a);
884typedef void (*drvmgr_w16_arg)(uint16_t *dstadr, uint16_t data, void *a);
885typedef void (*drvmgr_w32_arg)(uint32_t *dstadr, uint32_t data, void *a);
886typedef void (*drvmgr_w64_arg)(uint64_t *dstadr, uint64_t data, void *a);
887typedef int (*drvmgr_rmem_arg)(void *dest, const void *src, int n, void *a);
888typedef int (*drvmgr_wmem_arg)(void *dest, const void *src, int n, void *a);
889typedef int (*drvmgr_memset_arg)(void *dstadr, int c, size_t n, void *a);
890
891/* Report an error to the parent bus of the device */
892typedef void (*drvmgr_rw_err)(struct drvmgr_rw_arg *a, struct drvmgr_bus *bus,
893 int funcid, void *adr);
894
895/* Helper function for buses that implement the memset() over wmem() */
896extern void drvmgr_rw_memset(
897 void *dstadr,
898 int c,
899 size_t n,
900 void *a,
901 drvmgr_wmem_arg wmem
902 );
903
904/*** PRINT INFORMATION ABOUT DRIVER MANAGER ***/
905
930extern int drvmgr_for_each_listdev(
931 struct drvmgr_list *devlist,
932 unsigned int state_set_mask,
933 unsigned int state_clr_mask,
934 int (*func)(struct drvmgr_dev *dev, void *arg),
935 void *arg);
936
937/* Print all devices */
938#define PRINT_DEVS_FAILED 0x01 /* Failed during initialization */
939#define PRINT_DEVS_ASSIGNED 0x02 /* Driver assigned */
940#define PRINT_DEVS_UNASSIGNED 0x04 /* Driver not assigned */
941#define PRINT_DEVS_IGNORED 0x08 /* Device ignored on user's request */
942#define PRINT_DEVS_ALL (PRINT_DEVS_FAILED | \
943 PRINT_DEVS_ASSIGNED | \
944 PRINT_DEVS_UNASSIGNED |\
945 PRINT_DEVS_IGNORED)
946
948extern void drvmgr_summary(void);
949
951extern void drvmgr_print_devs(unsigned int options);
952
954extern void drvmgr_print_topo(void);
955
959extern void drvmgr_print_mem(void);
960
961#define OPTION_DEV_GENINFO 0x00000001
962#define OPTION_DEV_BUSINFO 0x00000002
963#define OPTION_DEV_DRVINFO 0x00000004
964#define OPTION_DRV_DEVS 0x00000100
965#define OPTION_BUS_DEVS 0x00010000
966#define OPTION_RECURSIVE 0x01000000
967#define OPTION_INFO_ALL 0xffffffff
968
970extern void drvmgr_info(void *id, unsigned int options);
971
973extern void drvmgr_info_dev(struct drvmgr_dev *dev, unsigned int options);
974
976extern void drvmgr_info_bus(struct drvmgr_bus *bus, unsigned int options);
977
979extern void drvmgr_info_drv(struct drvmgr_drv *drv, unsigned int options);
980
982extern void drvmgr_info_devs_on_bus(struct drvmgr_bus *bus, unsigned int options);
983
985extern void drvmgr_info_devs(unsigned int options);
986
988extern void drvmgr_info_drvs(unsigned int options);
989
991extern void drvmgr_info_buses(unsigned int options);
992
994extern struct drvmgr_drv *drvmgr_drv_by_id(uint64_t id);
995
997extern struct drvmgr_drv *drvmgr_drv_by_name(const char *name);
998
1000extern struct drvmgr_dev *drvmgr_dev_by_name(const char *name);
1001
1002#ifdef __cplusplus
1003}
1004#endif
1005
1006#endif
This header file provides basic definitions used by the API and the implementation.
struct drvmgr_drv * drvmgr_drv_by_id(uint64_t id)
Definition: drvmgr_by_id.c:33
void drvmgr_print_topo(void)
Definition: drvmgr_print.c:116
int drvmgr_alloc_bus(struct drvmgr_bus **pbus, int extra)
Definition: drvmgr.c:631
int drvmgr_bus_register(struct drvmgr_bus *bus)
Definition: drvmgr.c:585
int drvmgr_for_each_listdev(struct drvmgr_list *devlist, unsigned int state_set_mask, unsigned int state_clr_mask, int(*func)(struct drvmgr_dev *dev, void *arg), void *arg)
Definition: drvmgr_for_each_list_dev.c:33
int drvmgr_keys_get(struct drvmgr_dev *dev, struct drvmgr_key **keys)
Definition: drvmgr_res.c:33
void drvmgr_info(void *id, unsigned int options)
Definition: drvmgr_print.c:394
int drvmgr_func_call(void *obj, int funcid, void *a, void *b, void *c, void *d)
Definition: drvmgr_func_call.c:32
int drvmgr_interrupt_register(struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg)
Definition: drvmgr_drvinf.c:98
union drvmgr_key_value * drvmgr_dev_key_get(struct drvmgr_dev *dev, char *key_name, enum drvmgr_kt key_type)
Definition: drvmgr_res.c:108
int drvmgr_drv_register(struct drvmgr_drv *drv)
Definition: drvmgr.c:363
int drvmgr_init(void)
Definition: drvmgr_init.c:34
int drvmgr_get_dev_prefix(struct drvmgr_dev *dev, char *dev_prefix)
Definition: drvmgr_drvinf.c:83
int drvmgr_root_drv_register(struct drvmgr_drv *drv)
Definition: drvmgr.c:334
void drvmgr_info_drvs(unsigned int options)
Definition: drvmgr_print.c:444
int drvmgr_dev_unregister(struct drvmgr_dev *dev)
Definition: drvmgr_unregister.c:169
int drvmgr_get_dev(struct drvmgr_drv *drv, int minor, struct drvmgr_dev **pdev)
Definition: drvmgr_drvinf.c:46
int drvmgr_interrupt_unmask(struct drvmgr_dev *dev, int index)
Definition: drvmgr_drvinf.c:140
void drvmgr_print_mem(void)
Definition: drvmgr_print.c:125
drvmgr_tr_opts
Definition: drvmgr.h:668
unsigned int drvmgr_translate(struct drvmgr_dev *dev, unsigned int options, void *src_address, void **dst_address)
Definition: drvmgr_translate.c:148
int drvmgr_interrupt_clear(struct drvmgr_dev *dev, int index)
Definition: drvmgr_drvinf.c:130
int drvmgr_freq_get(struct drvmgr_dev *dev, int options, unsigned int *freq_hz)
Definition: drvmgr_drvinf.c:71
void drvmgr_info_dev(struct drvmgr_dev *dev, unsigned int options)
Definition: drvmgr_print.c:257
void _DRV_Manager_init_level(int level)
Definition: drvmgr.c:88
int drvmgr_on_rootbus(struct drvmgr_dev *dev)
Definition: drvmgr_drvinf.c:173
struct drvmgr_key * drvmgr_key_get(struct drvmgr_key *keys, char *key_name)
Definition: drvmgr_res.c:73
int drvmgr_alloc_dev(struct drvmgr_dev **pdev, int extra)
Definition: drvmgr.c:612
int drvmgr_bus_unregister(struct drvmgr_bus *bus)
Definition: drvmgr_unregister.c:62
int drvmgr_dev_register(struct drvmgr_dev *dev)
Definition: drvmgr.c:490
void drvmgr_bus_res_add(struct drvmgr_bus *bus, struct drvmgr_bus_res *bres)
Definition: drvmgr.c:650
int drvmgr_children_unregister(struct drvmgr_bus *bus)
Definition: drvmgr_unregister.c:40
void drvmgr_info_devs(unsigned int options)
Definition: drvmgr_print.c:433
void _DRV_Manager_initialization(void)
Definition: drvmgr.c:105
struct drvmgr_drv * drvmgr_drv_by_name(const char *name)
Definition: drvmgr_by_name.c:34
void drvmgr_info_bus(struct drvmgr_bus *bus, unsigned int options)
Definition: drvmgr_print.c:320
int drvmgr_interrupt_unregister(struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg)
Definition: drvmgr_drvinf.c:115
struct drvmgr_dev * drvmgr_dev_by_name(const char *name)
Definition: drvmgr_dev_by_name.c:45
void drvmgr_summary(void)
Definition: drvmgr_print.c:201
int drvmgr_func_get(void *obj, int funcid, void **func)
Definition: drvmgr_func.c:32
void(* drvmgr_drv_reg_func)(void)
Definition: drvmgr.h:345
void drvmgr_info_buses(unsigned int options)
Definition: drvmgr_print.c:457
void drvmgr_print_devs(unsigned int options)
Definition: drvmgr_print.c:60
int drvmgr_interrupt_mask(struct drvmgr_dev *dev, int index)
Definition: drvmgr_drvinf.c:150
void drvmgr_info_drv(struct drvmgr_drv *drv, unsigned int options)
Definition: drvmgr_print.c:357
void drvmgr_info_devs_on_bus(struct drvmgr_bus *bus, unsigned int options)
Definition: drvmgr_print.c:408
union drvmgr_key_value * drvmgr_key_val_get(struct drvmgr_key *keys, char *key_name, enum drvmgr_kt key_type)
Definition: drvmgr_res.c:91
Linked list help functions used by driver manager.
This header file defines the RTEMS Classic API.
This header file provides interfaces of the SMP Support which are only used by the implementation.
Definition: drvmgr.h:153
void(* get_info_dev)(struct drvmgr_dev *, void(*print)(void *p, char *str), void *p)
Definition: drvmgr.h:177
int(* unite)(struct drvmgr_drv *, struct drvmgr_dev *)
Definition: drvmgr.h:157
Definition: drvmgr.h:145
char * dev_prefix
Definition: drvmgr.h:146
Definition: drvmgr.h:238
struct drvmgr_drv_res resource[]
Definition: drvmgr.h:240
struct drvmgr_bus_res * next
Definition: drvmgr.h:239
Definition: drvmgr.h:261
struct drvmgr_func * funcs
Definition: drvmgr.h:270
int error
Definition: drvmgr.h:279
int state
Definition: drvmgr.h:278
int obj_type
Definition: drvmgr.h:262
void * priv
Definition: drvmgr.h:267
struct drvmgr_map_entry * maps_down
Definition: drvmgr.h:274
struct drvmgr_dev * dev
Definition: drvmgr.h:266
struct drvmgr_bus_res * reslist
Definition: drvmgr.h:272
unsigned char depth
Definition: drvmgr.h:264
struct drvmgr_bus * next
Definition: drvmgr.h:265
int dev_cnt
Definition: drvmgr.h:271
struct drvmgr_bus_ops * ops
Definition: drvmgr.h:269
struct drvmgr_map_entry * maps_up
Definition: drvmgr.h:273
int level
Definition: drvmgr.h:277
unsigned char bus_type
Definition: drvmgr.h:263
struct drvmgr_dev * children
Definition: drvmgr.h:268
Definition: drvmgr.h:297
struct drvmgr_bus * bus
Definition: drvmgr.h:310
int level
Definition: drvmgr.h:314
struct drvmgr_dev * next
Definition: drvmgr.h:299
char * name
Definition: drvmgr.h:307
unsigned int state
Definition: drvmgr.h:313
struct drvmgr_dev * next_in_bus
Definition: drvmgr.h:300
struct drvmgr_drv * drv
Definition: drvmgr.h:303
void * priv
Definition: drvmgr.h:308
struct drvmgr_dev * next_in_drv
Definition: drvmgr.h:301
struct drvmgr_bus * parent
Definition: drvmgr.h:304
int obj_type
Definition: drvmgr.h:298
int error
Definition: drvmgr.h:315
short minor_drv
Definition: drvmgr.h:305
void * businfo
Definition: drvmgr.h:309
short minor_bus
Definition: drvmgr.h:306
Definition: drvmgr.h:319
int(* info)(struct drvmgr_dev *, void(*print)(void *p, char *str), void *p, int, char *argv[])
Definition: drvmgr.h:322
int(* remove)(struct drvmgr_dev *)
Definition: drvmgr.h:321
Definition: drvmgr.h:231
int minor_bus
Definition: drvmgr.h:233
struct drvmgr_key * keys
Definition: drvmgr.h:234
uint64_t drv_id
Definition: drvmgr.h:232
Definition: drvmgr.h:327
char * name
Definition: drvmgr.h:333
struct drvmgr_drv * next
Definition: drvmgr.h:329
unsigned int dev_cnt
Definition: drvmgr.h:337
struct drvmgr_drv_ops * ops
Definition: drvmgr.h:335
struct drvmgr_func * funcs
Definition: drvmgr.h:336
unsigned int dev_priv_size
Definition: drvmgr.h:338
struct drvmgr_dev * dev
Definition: drvmgr.h:330
int obj_type
Definition: drvmgr.h:328
uint64_t drv_id
Definition: drvmgr.h:332
int bus_type
Definition: drvmgr.h:334
Definition: drvmgr.h:182
Definition: drvmgr.h:222
Definition: drvmgr_list.h:48
Definition: drvmgr.h:249
unsigned int size
Definition: drvmgr.h:251
char * name
Definition: drvmgr.h:250
char * to_adr
Definition: drvmgr.h:254
char * from_adr
Definition: drvmgr.h:252
Definition: drvmgr.h:849
unsigned p
Definition: tte.h:17
Definition: drvmgr.h:215
unsigned int i
Definition: drvmgr.h:216
char * str
Definition: drvmgr.h:217
void * ptr
Definition: drvmgr.h:218