34#ifndef _DRIVER_MANAGER_H_
35#define _DRIVER_MANAGER_H_
50#define DRVMGR_LEVEL_MAX 4
55#ifndef DRVMGR_USE_LOCKS
56#define DRVMGR_USE_LOCKS 1
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)
72#define DRVMGR_BUS_TYPE_NONE 0
73#define DRVMGR_BUS_TYPE_ROOT 1
74#define DRVMGR_BUS_TYPE_PCI 2
75#define DRVMGR_BUS_TYPE_AMBAPP 3
76#define DRVMGR_BUS_TYPE_LEON2_AMBA 4
77#define DRVMGR_BUS_TYPE_AMBAPP_DIST 5
78#define DRVMGR_BUS_TYPE_SPW_RMAP 6
79#define DRVMGR_BUS_TYPE_AMBAPP_RMAP 7
104#define DRIVER_ID_BUS_MASK 0x00000000000000FFULL
107#define DRIVER_ID_RSV_MASK 0xFF00000000000000ULL
110#define DRIVER_ID_DEV_MASK 0x00FFFFFFFFFFFF00ULL
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)))
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)
121#define DRIVER_ROOTBUS_ID(bus_type) DRIVER_ID(bus_type, 0)
126#define DRIVER_ROOT_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_ROOT)
129#define DRIVER_PCIBUS_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_PCI)
132#define DRIVER_GRLIB_AMBAPP_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP)
135#define DRIVER_LEON2_AMBA_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_LEON2_AMBA)
138#define DRIVER_AMBAPP_DIST_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP_DIST)
150typedef void (*drvmgr_isr)(
void *arg);
155 int (*init[DRVMGR_LEVEL_MAX])(
struct drvmgr_bus *);
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);
166 int (*int_set_affinity)(
struct drvmgr_dev *,
int index,
167 const Processor_mask *cpus);
173 int (*get_freq)(
struct drvmgr_dev*, int,
unsigned int*);
178 void (*print)(
void *
p,
char *str),
void *
p);
180#define BUS_OPS_NUM (sizeof(struct drvmgr_bus_ops)/sizeof(void (*)(void)))
186#define DRVMGR_FUNC(_ID_, _FUNC_) {(int)(_ID_), (void *)(_FUNC_)}
187#define DRVMGR_FUNC_END {0, NULL}
206 DRVMGR_KT_STRING = 2,
207 DRVMGR_KT_POINTER = 3,
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}
224 enum drvmgr_kt key_type;
257#define DRVMGR_TRANSLATE_ONE2ONE NULL
258#define DRVMGR_TRANSLATE_NO_BRIDGE ((void *)1)
283#define BUS_STATE_INIT_FAILED 0x00000001
284#define BUS_STATE_LIST_INACTIVE 0x00001000
285#define BUS_STATE_DEPEND_FAILED 0x00000004
288#define DEV_STATE_INIT_FAILED 0x00000001
289#define DEV_STATE_INIT_DONE 0x00000002
290#define DEV_STATE_DEPEND_FAILED 0x00000004
291#define DEV_STATE_UNITED 0x00000100
292#define DEV_STATE_REMOVED 0x00000200
293#define DEV_STATE_IGNORED 0x00000400
296#define DEV_STATE_LIST_INACTIVE 0x00001000
324 int (*
info)(
struct drvmgr_dev *, void (*print)(
void *
p,
char *str),
void *
p,
int,
char *argv[]);
326#define DRVMGR_OPS_NUM(x) (sizeof(x)/sizeof(void (*)(void)))
388extern void drvmgr_init_update(
void);
425extern int drvmgr_dev_drv_separate(
struct drvmgr_dev *dev);
485 enum drvmgr_kt key_type);
502 enum drvmgr_kt key_type);
507static inline struct drvmgr_bus *drvmgr_get_parent(
537#define DRVMGR_FED_BF 1
538#define DRVMGR_FED_DF 0
539extern intptr_t drvmgr_for_each_dev(
566 unsigned int *freq_hz);
663extern int drvmgr_interrupt_set_affinity(
666 const Processor_mask *cpus);
689 CPUMEM_FROM_DMA = 0x1,
705 DMAMEM_FROM_CPU = 0x3,
707#define DRVMGR_TR_REVERSE 0x1
708#define DRVMGR_TR_PATH 0x2
748 unsigned int options,
771extern unsigned int drvmgr_translate_bus(
786extern int drvmgr_translate_check(
788 unsigned int options,
800extern int drvmgr_func_call(
void *obj,
int funcid,
void *a,
void *b,
void *c,
void *d);
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)
817#define RW_SIZE_1 0x00001
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)
824#define RW_DIR_ANY 0x00000
825#define RW_READ 0x00000
826#define RW_WRITE 0x00010
827#define RW_SET 0x00020
828#define RW_DIR(id) (((unsigned int)(id) >> 4) & 0x3)
830#define RW_RAW 0x00000
831#define RW_LITTLE 0x00040
832#define RW_BIG 0x00080
833#define RW_ENDIAN(id) (((unsigned int)(id) >> 6) & 0x3)
835#define RW_TYPE_ANY 0x00000
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)
842#define RW_ARG 0x01000
843#define RW_ERR 0x02000
846#define DRVMGR_RWFUNC(minor) DRVMGR_FUNCID(FUNCID_RW, minor)
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);
868typedef int (*drvmgr_rmem)(
void *dest,
const void *src,
int n);
872typedef int (*drvmgr_wmem)(
void *dest,
const void *src,
int n);
876typedef int (*drvmgr_memset)(
void *dstadr,
int c,
size_t n);
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);
893 int funcid,
void *adr);
896extern void drvmgr_rw_memset(
932 unsigned int state_set_mask,
933 unsigned int state_clr_mask,
938#define PRINT_DEVS_FAILED 0x01
939#define PRINT_DEVS_ASSIGNED 0x02
940#define PRINT_DEVS_UNASSIGNED 0x04
941#define PRINT_DEVS_IGNORED 0x08
942#define PRINT_DEVS_ALL (PRINT_DEVS_FAILED | \
943 PRINT_DEVS_ASSIGNED | \
944 PRINT_DEVS_UNASSIGNED |\
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
970extern void drvmgr_info(
void *
id,
unsigned int options);
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.
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
This header file defines the RTEMS Classic API.
This header file provides interfaces of the SMP Support which are only used by the implementation.
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
char * dev_prefix
Definition: drvmgr.h:146
struct drvmgr_drv_res resource[]
Definition: drvmgr.h:240
struct drvmgr_bus_res * next
Definition: drvmgr.h:239
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
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
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
int minor_bus
Definition: drvmgr.h:233
struct drvmgr_key * keys
Definition: drvmgr.h:234
uint64_t drv_id
Definition: drvmgr.h:232
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_list.h:48
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
unsigned p
Definition: tte.h:17
unsigned int i
Definition: drvmgr.h:216
char * str
Definition: drvmgr.h:217
void * ptr
Definition: drvmgr.h:218