RTEMS 6.3
Loading...
Searching...
No Matches
drvmgr.h File Reference

Driver Manager Interface. More...

#include <rtems.h>
#include <drvmgr/drvmgr_list.h>
#include <stdint.h>
#include <rtems/score/basedefs.h>
#include <rtems/score/smpimpl.h>

Go to the source code of this file.

Data Structures

struct  drvmgr_bus_params
struct  drvmgr_bus_ops
struct  drvmgr_func
union  drvmgr_key_value
struct  drvmgr_key
struct  drvmgr_drv_res
struct  drvmgr_bus_res
struct  drvmgr_map_entry
struct  drvmgr_bus
struct  drvmgr_dev
struct  drvmgr_drv_ops
struct  drvmgr_drv
struct  drvmgr_rw_arg

Macros

#define DRVMGR_LEVEL_MAX   4
#define DRVMGR_USE_LOCKS   1
#define BUS_LIST_HEAD(list)
#define BUS_LIST_TAIL(list)
#define DEV_LIST_HEAD(list)
#define DEV_LIST_TAIL(list)
#define DRV_LIST_HEAD(list)
#define DRV_LIST_TAIL(list)
#define DRVMGR_BUS_TYPE_NONE   0
#define DRVMGR_BUS_TYPE_ROOT   1
#define DRVMGR_BUS_TYPE_PCI   2
#define DRVMGR_BUS_TYPE_AMBAPP   3
#define DRVMGR_BUS_TYPE_LEON2_AMBA   4
#define DRVMGR_BUS_TYPE_AMBAPP_DIST   5
#define DRVMGR_BUS_TYPE_SPW_RMAP   6
#define DRVMGR_BUS_TYPE_AMBAPP_RMAP   7
#define DRIVER_ID_BUS_MASK   0x00000000000000FFULL
#define DRIVER_ID_RSV_MASK   0xFF00000000000000ULL
#define DRIVER_ID_DEV_MASK   0x00FFFFFFFFFFFF00ULL
#define DRIVER_ID(busid, devid)
#define DRIVER_BUSID_GET(id)
#define DRIVER_DEVID_GET(id)
#define DRIVER_ROOTBUS_ID(bus_type)
#define DRIVER_ROOT_ID   DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_ROOT)
#define DRIVER_PCIBUS_ID   DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_PCI)
#define DRIVER_GRLIB_AMBAPP_ID   DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP)
#define DRIVER_LEON2_AMBA_ID   DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_LEON2_AMBA)
#define DRIVER_AMBAPP_DIST_ID   DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP_DIST)
#define BUS_OPS_NUM   (sizeof(struct drvmgr_bus_ops)/sizeof(void (*)(void)))
#define DRVMGR_FUNC(_ID_, _FUNC_)
#define DRVMGR_FUNC_END   {0, NULL}
#define DRVMGR_KEY_EMPTY   {NULL, DRVMGR_KT_NONE, {0}}
#define DRVMGR_RES_EMPTY   {0, 0, NULL}
#define MMAP_EMPTY   {0, 0, 0}
#define DRVMGR_TRANSLATE_ONE2ONE   NULL
#define DRVMGR_TRANSLATE_NO_BRIDGE   ((void *)1)
#define BUS_STATE_INIT_FAILED   0x00000001
#define BUS_STATE_LIST_INACTIVE   0x00001000
#define BUS_STATE_DEPEND_FAILED   0x00000004
#define DEV_STATE_INIT_FAILED   0x00000001
#define DEV_STATE_INIT_DONE   0x00000002
#define DEV_STATE_DEPEND_FAILED   0x00000004
#define DEV_STATE_UNITED   0x00000100
#define DEV_STATE_REMOVED   0x00000200
#define DEV_STATE_IGNORED   0x00000400
#define DEV_STATE_LIST_INACTIVE   0x00001000
#define DRVMGR_OPS_NUM(x)
#define DRVMGR_FED_BF   1
#define DRVMGR_FED_DF   0
#define DRVMGR_TR_REVERSE   0x1
#define DRVMGR_TR_PATH   0x2
#define DRVMGR_FUNCID(major, minor)
#define DRVMGR_FUNCID_NONE   0
#define DRVMGR_FUNCID_END   DRVMGR_FUNCID(DRVMGR_FUNCID_NONE, 0)
#define RW_SIZE_1   0x00001
#define RW_SIZE_2   0x00002
#define RW_SIZE_4   0x00004
#define RW_SIZE_8   0x00008
#define RW_SIZE_ANY   0x00000
#define RW_SIZE(id)
#define RW_DIR_ANY   0x00000
#define RW_READ   0x00000
#define RW_WRITE   0x00010
#define RW_SET   0x00020
#define RW_DIR(id)
#define RW_RAW   0x00000
#define RW_LITTLE   0x00040
#define RW_BIG   0x00080
#define RW_ENDIAN(id)
#define RW_TYPE_ANY   0x00000
#define RW_REG   0x00100
#define RW_MEM   0x00200
#define RW_MEMREG   0x00300
#define RW_CFG   0x00400
#define RW_TYPE(id)
#define RW_ARG   0x01000
#define RW_ERR   0x02000
#define DRVMGR_RWFUNC(minor)
#define PRINT_DEVS_FAILED   0x01
#define PRINT_DEVS_ASSIGNED   0x02
#define PRINT_DEVS_UNASSIGNED   0x04
#define PRINT_DEVS_IGNORED   0x08
#define PRINT_DEVS_ALL
#define OPTION_DEV_GENINFO   0x00000001
#define OPTION_DEV_BUSINFO   0x00000002
#define OPTION_DEV_DRVINFO   0x00000004
#define OPTION_DRV_DEVS   0x00000100
#define OPTION_BUS_DEVS   0x00010000
#define OPTION_RECURSIVE   0x01000000
#define OPTION_INFO_ALL   0xffffffff

Typedefs

typedef void(*) drvmgr_isr(void *arg)
typedef void(*) drvmgr_drv_reg_func(void)
typedef uint8_t(*) drvmgr_r8(uint8_t *srcadr)
typedef uint16_t(*) drvmgr_r16(uint16_t *srcadr)
typedef uint32_t(*) drvmgr_r32(uint32_t *srcadr)
typedef uint64_t(*) drvmgr_r64(uint64_t *srcadr)
typedef void(*) drvmgr_w8(uint8_t *dstadr, uint8_t data)
typedef void(*) drvmgr_w16(uint16_t *dstadr, uint16_t data)
typedef void(*) drvmgr_w32(uint32_t *dstadr, uint32_t data)
typedef void(*) drvmgr_w64(uint64_t *dstadr, uint64_t data)
typedef int(*) drvmgr_rmem(void *dest, const void *src, int n)
typedef int(*) drvmgr_wmem(void *dest, const void *src, int n)
typedef int(*) drvmgr_memset(void *dstadr, int c, size_t n)
typedef uint8_t(*) drvmgr_r8_arg(uint8_t *srcadr, void *a)
typedef uint16_t(*) drvmgr_r16_arg(uint16_t *srcadr, void *a)
typedef uint32_t(*) drvmgr_r32_arg(uint32_t *srcadr, void *a)
typedef uint64_t(*) drvmgr_r64_arg(uint64_t *srcadr, void *a)
typedef void(*) drvmgr_w8_arg(uint8_t *dstadr, uint8_t data, void *a)
typedef void(*) drvmgr_w16_arg(uint16_t *dstadr, uint16_t data, void *a)
typedef void(*) drvmgr_w32_arg(uint32_t *dstadr, uint32_t data, void *a)
typedef void(*) drvmgr_w64_arg(uint64_t *dstadr, uint64_t data, void *a)
typedef int(*) drvmgr_rmem_arg(void *dest, const void *src, int n, void *a)
typedef int(*) drvmgr_wmem_arg(void *dest, const void *src, int n, void *a)
typedef int(*) drvmgr_memset_arg(void *dstadr, int c, size_t n, void *a)
typedef void(*) drvmgr_rw_err(struct drvmgr_rw_arg *a, struct drvmgr_bus *bus, int funcid, void *adr)

Enumerations

enum  { DRVMGR_OBJ_NONE = 0 , DRVMGR_OBJ_DRV = 1 , DRVMGR_OBJ_BUS = 2 , DRVMGR_OBJ_DEV = 3 }
enum  drvmgr_kt {
  DRVMGR_KT_ANY = -1 , DRVMGR_KT_NONE = 0 , DRVMGR_KT_INT = 1 , DRVMGR_KT_STRING = 2 ,
  DRVMGR_KT_POINTER = 3
}
enum  {
  DRVMGR_OK = 0 , DRVMGR_NOMEM = 1 , DRVMGR_EIO = 2 , DRVMGR_EINVAL = 3 ,
  DRVMGR_ENOSYS = 4 , DRVMGR_TIMEDOUT = 5 , DRVMGR_EBUSY = 6 , DRVMGR_ENORES = 7 ,
  DRVMGR_FAIL = -1
}
enum  drvmgr_tr_opts { CPUMEM_TO_DMA = 0x0 , CPUMEM_FROM_DMA = 0x1 , DMAMEM_TO_CPU = 0x2 , DMAMEM_FROM_CPU = 0x3 }
enum  { FUNCID_NONE = 0x000 , FUNCID_RW = 0x001 }

Functions

void _DRV_Manager_initialization (void)
void _DRV_Manager_init_level (int level)
int drvmgr_init (void)
void drvmgr_init_update (void)
int drvmgr_root_drv_register (struct drvmgr_drv *drv)
int drvmgr_drv_register (struct drvmgr_drv *drv)
int drvmgr_dev_register (struct drvmgr_dev *dev)
int drvmgr_dev_unregister (struct drvmgr_dev *dev)
int drvmgr_bus_register (struct drvmgr_bus *bus)
int drvmgr_bus_unregister (struct drvmgr_bus *bus)
int drvmgr_children_unregister (struct drvmgr_bus *bus)
int drvmgr_dev_drv_separate (struct drvmgr_dev *dev)
int drvmgr_alloc_dev (struct drvmgr_dev **pdev, int extra)
int drvmgr_alloc_bus (struct drvmgr_bus **pbus, int extra)
void drvmgr_bus_res_add (struct drvmgr_bus *bus, struct drvmgr_bus_res *bres)
int drvmgr_keys_get (struct drvmgr_dev *dev, struct drvmgr_key **keys)
struct drvmgr_key * drvmgr_key_get (struct drvmgr_key *keys, char *key_name)
union drvmgr_key_value * drvmgr_key_val_get (struct drvmgr_key *keys, char *key_name, enum drvmgr_kt key_type)
union drvmgr_key_value * drvmgr_dev_key_get (struct drvmgr_dev *dev, char *key_name, enum drvmgr_kt key_type)
intptr_t drvmgr_for_each_dev (intptr_t(*func)(struct drvmgr_dev *dev, void *arg), void *arg, int options)
int drvmgr_get_dev (struct drvmgr_drv *drv, int minor, struct drvmgr_dev **pdev)
int drvmgr_freq_get (struct drvmgr_dev *dev, int options, unsigned int *freq_hz)
int drvmgr_on_rootbus (struct drvmgr_dev *dev)
int drvmgr_get_dev_prefix (struct drvmgr_dev *dev, char *dev_prefix)
int drvmgr_interrupt_register (struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg)
int drvmgr_interrupt_unregister (struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg)
int drvmgr_interrupt_clear (struct drvmgr_dev *dev, int index)
int drvmgr_interrupt_unmask (struct drvmgr_dev *dev, int index)
int drvmgr_interrupt_mask (struct drvmgr_dev *dev, int index)
unsigned int drvmgr_translate (struct drvmgr_dev *dev, unsigned int options, void *src_address, void **dst_address)
unsigned int drvmgr_translate_bus (struct drvmgr_bus *from, struct drvmgr_bus *to, int reverse, void *src_address, void **dst_address)
int drvmgr_translate_check (struct drvmgr_dev *dev, unsigned int options, void *src_address, void **dst_address, unsigned int size)
int drvmgr_func_get (void *obj, int funcid, void **func)
int drvmgr_func_call (void *obj, int funcid, void *a, void *b, void *c, void *d)
void drvmgr_rw_memset (void *dstadr, int c, size_t n, void *a, drvmgr_wmem_arg wmem)
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)
void drvmgr_summary (void)
void drvmgr_print_devs (unsigned int options)
void drvmgr_print_topo (void)
void drvmgr_print_mem (void)
void drvmgr_info (void *id, unsigned int options)
void drvmgr_info_dev (struct drvmgr_dev *dev, unsigned int options)
void drvmgr_info_bus (struct drvmgr_bus *bus, unsigned int options)
void drvmgr_info_drv (struct drvmgr_drv *drv, unsigned int options)
void drvmgr_info_devs_on_bus (struct drvmgr_bus *bus, unsigned int options)
void drvmgr_info_devs (unsigned int options)
void drvmgr_info_drvs (unsigned int options)
void drvmgr_info_buses (unsigned int options)
struct drvmgr_drv * drvmgr_drv_by_id (uint64_t id)
struct drvmgr_drv * drvmgr_drv_by_name (const char *name)
struct drvmgr_dev * drvmgr_dev_by_name (const char *name)

Detailed Description

Driver Manager Interface.

Macro Definition Documentation

◆ BUS_LIST_HEAD

#define BUS_LIST_HEAD ( list)
Value:
LIST_HEAD(list, struct drvmgr_bus)
Definition drvmgr.h:261

◆ BUS_LIST_TAIL

#define BUS_LIST_TAIL ( list)
Value:
LIST_TAIL(list, struct drvmgr_bus)

◆ DEV_LIST_HEAD

#define DEV_LIST_HEAD ( list)
Value:
LIST_HEAD(list, struct drvmgr_dev)
Definition drvmgr.h:299

◆ DEV_LIST_TAIL

#define DEV_LIST_TAIL ( list)
Value:
LIST_TAIL(list, struct drvmgr_dev)

◆ DRIVER_BUSID_GET

#define DRIVER_BUSID_GET ( id)
Value:
((unsigned long long)(id) & DRIVER_ID_BUS_MASK)

◆ DRIVER_DEVID_GET

#define DRIVER_DEVID_GET ( id)
Value:
(((unsigned long long)(id) & DRIVER_ID_DEV_MASK) >> 8)

◆ DRIVER_ID

#define DRIVER_ID ( busid,
devid )
Value:
((unsigned long long) \
((((unsigned long long)(devid) << 8) & DRIVER_ID_DEV_MASK) | \
((unsigned long long)(busid) & DRIVER_ID_BUS_MASK)))

◆ DRIVER_ROOTBUS_ID

#define DRIVER_ROOTBUS_ID ( bus_type)
Value:
DRIVER_ID(bus_type, 0)

◆ DRV_LIST_HEAD

#define DRV_LIST_HEAD ( list)
Value:
LIST_HEAD(list, struct drvmgr_drv)
Definition drvmgr.h:329

◆ DRV_LIST_TAIL

#define DRV_LIST_TAIL ( list)
Value:
LIST_TAIL(list, struct drvmgr_drv)

◆ DRVMGR_FED_BF

#define DRVMGR_FED_BF   1

Calls func() for every device found in the device tree, regardless of device state or if a driver is assigned. With the options argument the user can decide to do either a depth-first or a breadth-first search.

If the function func() returns a non-zero value then for_each_dev will return imediatly with the same return value as func() returned.

Parameters
funcFunction called on each device
argCustom function argument
optionsSearch Options, see DRVMGR_FED_*

◆ DRVMGR_FUNC

#define DRVMGR_FUNC ( _ID_,
_FUNC_ )
Value:
{(int)(_ID_), (void *)(_FUNC_)}

◆ DRVMGR_FUNCID

#define DRVMGR_FUNCID ( major,
minor )
Value:
((((major) & 0xfff) << 20) | ((minor) & 0xfffff))

◆ DRVMGR_OPS_NUM

#define DRVMGR_OPS_NUM ( x)
Value:
(sizeof(x)/sizeof(void (*)(void)))

◆ DRVMGR_RWFUNC

#define DRVMGR_RWFUNC ( minor)
Value:
DRVMGR_FUNCID(FUNCID_RW, minor)

◆ PRINT_DEVS_ALL

#define PRINT_DEVS_ALL
Value:
(PRINT_DEVS_FAILED | \
PRINT_DEVS_ASSIGNED | \
PRINT_DEVS_UNASSIGNED |\
PRINT_DEVS_IGNORED)

◆ RW_DIR

#define RW_DIR ( id)
Value:
(((unsigned int)(id) >> 4) & 0x3)

◆ RW_ENDIAN

#define RW_ENDIAN ( id)
Value:
(((unsigned int)(id) >> 6) & 0x3)

◆ RW_SIZE

#define RW_SIZE ( id)
Value:
((unsigned int)(id) & 0xf)

◆ RW_TYPE

#define RW_TYPE ( id)
Value:
(((unsigned int)(id) >> 8) & 0xf)

Typedef Documentation

◆ drvmgr_drv_reg_func

typedef void(*) drvmgr_drv_reg_func(void)

Structure defines a function pointer called when driver manager is ready for drivers to register themselfs. Used to select drivers available to the driver manager.

Enumeration Type Documentation

◆ drvmgr_tr_opts

Force masking/disable an interrupt on the interrupt controller, this is not normally performed since this will stop all other (shared) ISRs to be disabled until _unmask() is called.

Parameters
devDevice to mask interrupt for.
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.

drvmgr_translate() translation options

Function Documentation

◆ _DRV_Manager_init_level()

void _DRV_Manager_init_level ( int level)
extern

Take all devices into init level 'level', all devices registered later will directly be taken into this level as well, ensuring that all registerd devices has been taken into the level.

◆ _DRV_Manager_initialization()

void _DRV_Manager_initialization ( void )
extern

Initialize data structures of the driver management system. Calls predefined register driver functions so that drivers can register themselves.

◆ drvmgr_alloc_bus()

int drvmgr_alloc_bus ( struct drvmgr_bus ** pbus,
int extra )
extern

Allocate a bus structure, if no memory available rtems_error_fatal_occurred is called. The 'extra' argment tells how many bytes extra space is to be allocated after the device structure, this is typically used for "businfo" structures. The extra space is always aligned to a 4-byte boundary.

◆ drvmgr_alloc_dev()

int drvmgr_alloc_dev ( struct drvmgr_dev ** pdev,
int extra )
extern

Allocate a device structure, if no memory available rtems_error_fatal_occurred is called. The 'extra' argment tells how many bytes extra space is to be allocated after the device structure, this is typically used for "businfo" structures. The extra space is always aligned to a 4-byte boundary.

◆ drvmgr_bus_register()

int drvmgr_bus_register ( struct drvmgr_bus * bus)
extern

Register a bus

◆ drvmgr_bus_res_add()

void drvmgr_bus_res_add ( struct drvmgr_bus * bus,
struct drvmgr_bus_res * bres )
extern

Add resources to a bus, typically used by a bus driver.

Parameters
busThe Bus to add the resources to.
resAn array with Driver resources, all together are called bus resources.

◆ drvmgr_bus_unregister()

int drvmgr_bus_unregister ( struct drvmgr_bus * bus)
extern

Unregister a bus

◆ drvmgr_children_unregister()

int drvmgr_children_unregister ( struct drvmgr_bus * bus)
extern

Unregister all child devices of a bus.

This function is called from the bus driver, from a "safe" state where devices will not be added or removed on this particular bus at this time

◆ drvmgr_dev_by_name()

struct drvmgr_dev * drvmgr_dev_by_name ( const char * name)
extern

Get Device by Device Name

◆ drvmgr_dev_key_get()

union drvmgr_key_value * drvmgr_dev_key_get ( struct drvmgr_dev * dev,
char * key_name,
enum drvmgr_kt key_type )
extern

Get key value from the bus resources matching [device, key name, key type] if no matching key is found NULL is returned.

This is typically used by device drivers to find a particular device resource.

Parameters
devThe device to search resource for.
key_nameThe key name to search for
key_typeThe key type expected.
Returns
Returns NULL if no value found matching Key Name and Key Type was found for device.

◆ drvmgr_dev_register()

int drvmgr_dev_register ( struct drvmgr_dev * dev)
extern

Register a device

◆ drvmgr_dev_unregister()

int drvmgr_dev_unregister ( struct drvmgr_dev * dev)
extern

Remove a device, and all its children devices if device is a bus device. The device driver will be requested to remove the device and once gone from bus, device and driver list the device is put into a inactive list for debugging (this is optional by using remove argument).

Removing the Root Bus Device is not supported.

Parameters
removeIf non-zero the device will be deallocated, and not put into the inacitve list.

◆ drvmgr_drv_by_id()

struct drvmgr_drv * drvmgr_drv_by_id ( uint64_t id)
extern

Get Driver by Driver ID

◆ drvmgr_drv_by_name()

struct drvmgr_drv * drvmgr_drv_by_name ( const char * name)
extern

Get Driver by Driver Name

◆ drvmgr_drv_register()

int drvmgr_drv_register ( struct drvmgr_drv * drv)
extern

Register a driver

◆ drvmgr_for_each_listdev()

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 )
extern

Calls func() for every device found matching the search requirements of set_mask and clr_mask. Each bit set in set_mask must be set in the device state bit mask (dev->state), and Each bit in the clr_mask must be cleared in the device state bit mask (dev->state). There are three special cases:

  1. If state_set_mask and state_clr_mask are zero the state bits are ignored and all cores are treated as a match.
  2. If state_set_mask is zero the function func will not be called due to a bit being set in the state mask.
  3. If state_clr_mask is zero the function func will not be called due to a bit being cleared in the state mask.

If the function func() returns a non-zero value then for_each_dev will return imediatly with the same return value as func() returned.

Parameters
devlistThe list to iterate though searching for devices.
state_set_maskDefines the bits that must be set in dev->state
state_clr_maskDefines the bits that must be cleared in dev->state
funcFunction called on each

◆ drvmgr_freq_get()

int drvmgr_freq_get ( struct drvmgr_dev * dev,
int options,
unsigned int * freq_hz )
extern

Get Bus frequency in Hertz. Frequency is stored into address of freq_hz.

Parameters
devThe Device to get Bus frequency for.
optionsBus-type specific options
freq_hzLocation where Bus Frequency will be stored.

◆ drvmgr_func_call()

int drvmgr_func_call ( void * obj,
int funcid,
void * a,
void * b,
void * c,
void * d )
extern

Lookup function and call it directly with the four optional arguments

◆ drvmgr_func_get()

int drvmgr_func_get ( void * obj,
int funcid,
void ** func )
extern

Get function pointer from Device Driver or Bus Driver.

Returns 0 if function is available

◆ drvmgr_get_dev()

int drvmgr_get_dev ( struct drvmgr_drv * drv,
int minor,
struct drvmgr_dev ** pdev )
extern

Get Device pointer from Driver and Driver minor number

Parameters
drvDriver the device is united with.
minorDriver minor number assigned to device.
pdevLocation where the Device point will be stored.
Returns
Zero on success. -1 on failure, when device was not found in driver device list.

◆ drvmgr_get_dev_prefix()

int drvmgr_get_dev_prefix ( struct drvmgr_dev * dev,
char * dev_prefix )
extern

Get device name prefix, this name can be used to register a unique name in the bus->error filesystem or to get an idea where the device is located.

Parameters
devThe Device to get the device Prefix for.
dev_prefixLocation where the prefix will be stored.

◆ drvmgr_info()

void drvmgr_info ( void * id,
unsigned int options )
extern

Print information about a driver manager object (device, driver, bus)

◆ drvmgr_info_bus()

void drvmgr_info_bus ( struct drvmgr_bus * bus,
unsigned int options )
extern

Get information about a bus

◆ drvmgr_info_buses()

void drvmgr_info_buses ( unsigned int options)
extern

Get information about all buses in the system

◆ drvmgr_info_dev()

void drvmgr_info_dev ( struct drvmgr_dev * dev,
unsigned int options )
extern

Get information about a device

◆ drvmgr_info_devs()

void drvmgr_info_devs ( unsigned int options)
extern

Get information about all devices in the system (on all buses)

◆ drvmgr_info_devs_on_bus()

void drvmgr_info_devs_on_bus ( struct drvmgr_bus * bus,
unsigned int options )
extern

Get information about all devices on a bus

◆ drvmgr_info_drv()

void drvmgr_info_drv ( struct drvmgr_drv * drv,
unsigned int options )
extern

Get information about a driver

◆ drvmgr_info_drvs()

void drvmgr_info_drvs ( unsigned int options)
extern

Get information about all drivers in the system

◆ drvmgr_init()

int drvmgr_init ( void )
extern

Init driver manager all in one go, will call _DRV_Manager_initialization(), then _DRV_Manager_init_level([1..DRVMGR_LEVEL_MAX]). Typically called from Init task when user wants to initilize driver manager after startup, otherwise not used.

◆ drvmgr_interrupt_clear()

int drvmgr_interrupt_clear ( struct drvmgr_dev * dev,
int index )
extern

Clear (ACK) pending interrupt

Parameters
devDevice to clear interrupt for.
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.
isrInterrupt Service Routine, previously registered.
argOptional ISR argument, previously registered.

◆ drvmgr_interrupt_mask()

int drvmgr_interrupt_mask ( struct drvmgr_dev * dev,
int index )
extern

Force masking/disable an interrupt on the interrupt controller, this is not normally performed since this will stop all other (shared) ISRs to be disabled until _unmask() is called.

Parameters
devDevice to mask interrupt for.
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.

◆ drvmgr_interrupt_register()

int drvmgr_interrupt_register ( struct drvmgr_dev * dev,
int index,
const char * info,
drvmgr_isr isr,
void * arg )
extern

Register a shared interrupt handler. Since this service is shared among interrupt drivers/handlers the handler[arg] must be installed before the interrupt can be cleared or disabled. The handler is by default disabled after registration.

Parameters
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.
isrInterrupt Service Routine.
argOptional ISR argument.

◆ drvmgr_interrupt_unmask()

int drvmgr_interrupt_unmask ( struct drvmgr_dev * dev,
int index )
extern

Force unmasking/enableing an interrupt on the interrupt controller, this is not normally used, if used the caller has masked/disabled the interrupt just before.

Parameters
devDevice to clear interrupt for.
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.
isrInterrupt Service Routine, previously registered.
argOptional ISR argument, previously registered.

◆ drvmgr_interrupt_unregister()

int drvmgr_interrupt_unregister ( struct drvmgr_dev * dev,
int index,
drvmgr_isr isr,
void * arg )
extern

Unregister an interrupt handler. This also disables the interrupt before unregistering the interrupt handler.

Parameters
indexIndex is used to identify the IRQ number if hardware has multiple IRQ sources. Normally Index is set to 0 to indicated the first and only IRQ source. A negative index is interpreted as a absolute bus IRQ number.
isrInterrupt Service Routine, previously registered.
argOptional ISR argument, previously registered.

◆ drvmgr_key_get()

struct drvmgr_key * drvmgr_key_get ( struct drvmgr_key * keys,
char * key_name )
extern

Return the one key that matches key name from a driver keys array. The keys can be obtained using drvmgr_keys_get().

Parameters
keysAn array of keys ended with DRVMGR_KEY_EMPTY to search among.
key_nameName of key to search for among the keys.

◆ drvmgr_key_val_get()

union drvmgr_key_value * drvmgr_key_val_get ( struct drvmgr_key * keys,
char * key_name,
enum drvmgr_kt key_type )
extern

Extract key value from the key in the keys array matching name and type.

This function calls drvmgr_keys_get to get the key requested (from key name), then determines if the type is correct. A pointer to the key value is returned.

Parameters
keysAn array of keys ended with DRVMGR_KEY_EMPTY to search among.
key_nameName of key to search for among the keys.
key_typeData Type of value. INTEGER, ADDRESS, STRING.
Returns
Returns NULL if no value found matching Key Name and Key Type.

◆ drvmgr_keys_get()

int drvmgr_keys_get ( struct drvmgr_dev * dev,
struct drvmgr_key ** keys )
extern

Find all the resource keys for a device among all driver resources on a bus. Typically used by a device driver to get configuration options.

Parameters
devDevice to find resources for
keyLocation where the pointer to the driver resource array (drvmgr_drv_res->keys) is stored.

◆ drvmgr_on_rootbus()

int drvmgr_on_rootbus ( struct drvmgr_dev * dev)
extern

Return 0 if dev is not located on the root bus, 1 if on root bus

◆ drvmgr_print_devs()

void drvmgr_print_devs ( unsigned int options)
extern

Print devices with certain condictions met according to 'options'

◆ drvmgr_print_mem()

void drvmgr_print_mem ( void )
extern

Print the memory usage Only accounts for data structures. Not for the text size.

◆ drvmgr_print_topo()

void drvmgr_print_topo ( void )
extern

Print device/bus topology

◆ drvmgr_root_drv_register()

int drvmgr_root_drv_register ( struct drvmgr_drv * drv)
extern

Register Root Bus device driver

◆ drvmgr_summary()

void drvmgr_summary ( void )
extern

Print number of devices, buses and drivers

◆ drvmgr_translate()

unsigned int drvmgr_translate ( struct drvmgr_dev * dev,
unsigned int options,
void * src_address,
void ** dst_address )
extern

Translate an address on one bus to an address on another bus.

The device determines source or destination bus, the root bus is always the other bus. It is assumed that the CPU is located on the root bus or that it can access it without address translation (mapped 1:1). The CPU is thus assumed to be located on level 0 top most in the bus hierarchy.

If no map is present in the bus driver src_address is translated 1:1 (just copied).

Addresses are typically converted up-streams from the DMA unit towards the CPU (DMAMEM_TO_CPU) or down-streams towards DMA hardware from the CPU (CPUMEM_TO_DMA) over one or multiple bridges depending on bus architecture. See 'enum drvmgr_tr_opts' for other translation direction options. For example: Two common operations is to translate a CPU accessible RAM address to an address that DMA units can access (dev=DMA-unit, CPUMEM_TO_DMA, src_address=CPU-RAM-ADR) and to translate an address of a PCI resource for example RAM mapped into a PCI BAR to an CPU accessible address (dev=PCI-device, DMAMEM_TO_CPU, src_address=PCI-BAR-ADR).

Source address is translated and the result is put into *dst_address, if the address is not accessible on the other bus -1 is returned.

Parameters
devDevice to translate addresses for
optionsTanslation direction options, see enum drvmgr_tr_opts
src_addressAddress to translate
dst_addressLocation where translated address is stored

Returns 0 if unable to translate. The remaining length from the given address of the map is returned on success, for example if a map starts at 0x40000000 of size 0x100000 the result will be 0x40000 if the address was translated into 0x400C0000. If dev is on root-bus no translation is performed 0xffffffff is returned and src_address is stored in *dst_address.