RTEMS CPU Kit with SuperCore
4.11.3
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <drvmgr/drvmgr.h>
#include "drvmgr_internal.h"
Functions | |
unsigned int | drvmgr_translate_bus (struct drvmgr_bus *from, struct drvmgr_bus *to, int reverse, void *src_address, void **dst_address) |
unsigned int | drvmgr_translate (struct drvmgr_dev *dev, unsigned int options, void *src_address, void **dst_address) |
Translate an address on one bus to an address on another bus. More... | |
unsigned int drvmgr_translate | ( | struct drvmgr_dev * | dev, |
unsigned int | options, | ||
void * | src_address, | ||
void ** | dst_address | ||
) |
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.
dev | Device to translate addresses for |
options | Tanslation direction options, see enum drvmgr_tr_opts |
src_address | Address to translate |
dst_address | Location 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.