From c4c8d3fd50e21a49b0e511e1dd19ab1d369c536c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 10 Jun 2021 13:25:26 +0200 Subject: grlib: Customizable allocation in ambapp_scan() Make the memory allocations in ambapp_scan() customizable via the new struct ambapp_context parameter which generalizes the memory copy handler. --- bsps/include/grlib/ambapp.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'bsps/include/grlib') diff --git a/bsps/include/grlib/ambapp.h b/bsps/include/grlib/ambapp.h index 3c3d3e9e3e..2091103551 100644 --- a/bsps/include/grlib/ambapp.h +++ b/bsps/include/grlib/ambapp.h @@ -15,6 +15,15 @@ #ifndef __AMBAPP_H__ #define __AMBAPP_H__ +#include + +/* Include VENDOR and DEVICE definitions */ +#include "ambapp_ids.h" + +#ifdef __cplusplus +extern "C" { +#endif + /** * @defgroup amba AMBA * @@ -25,13 +34,6 @@ * @{ */ -/* Include VENDOR and DEVICE definitions */ -#include "ambapp_ids.h" - -#ifdef __cplusplus -extern "C" { -#endif - /* Max supported AHB buses */ #define AHB_BUS_MAX 6 @@ -181,6 +183,11 @@ typedef void *(*ambapp_memcpy_t)( struct ambapp_bus *abus /* Optional AMBA Bus pointer */ ); +struct ambapp_context { + ambapp_memcpy_t copy_from_device; + void *(*alloc)(size_t); +}; + /* Scan a AMBA Plug & Play bus and create all device structures describing the * the devices. The devices will form a tree, where every node describes one * interface. The resulting tree is placed in the location pointed to by root. @@ -188,16 +195,16 @@ typedef void *(*ambapp_memcpy_t)( * Since it the tree is located in RAM it is easier to work with AMBA buses * that is located over PCI and SpaceWire etc. * + * \param abus Resulting device node tree root is stored here. * \param ioarea The IO-AREA where Plug & Play information can be found. - * \param parent Used internally when recursing down a bridge. Set to NULL. + * \param ctx The scan context. May be NULL. * \param mmaps Is used to perform address translation if needed. - * \param root Resulting device node tree root is stored here. * */ extern int ambapp_scan( struct ambapp_bus *abus, unsigned int ioarea, - ambapp_memcpy_t memfunc, + const struct ambapp_context *ctx, struct ambapp_mmap *mmaps ); -- cgit v1.2.3