CRpi
A library for rpi with intefaces to: gpio, pwm, dma
Data Structures | Typedefs | Functions
cacheCoherentMemoryProvider.h File Reference

Provides a way to easily allocate memory areas that are coherent between CPU and DMA. More...

#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  ccmb_desc_struct
 Describes a Cache Coherent Memory Block allocated by ccmp_malloc() More...
 

Typedefs

typedef struct ccmb_desc_struct Ccmb_desc
 Describes a Cache Coherent Memory Block allocated by ccmp_malloc()
 

Functions

int ccmp_malloc (size_t reqSize, Ccmb_desc *allocatedAreaDesc, unsigned int byteAlignment)
 Provides a way to easily allocate memory areas that are coherent between CPU and DMA. More...
 
int ccmp_free (Ccmb_desc *allocatedAreaDesc)
 Frees a block allocated with ccmp_malloc() More...
 
uintptr_t ccmp_virtAddrToBusAddr (Ccmb_desc *desc, void *virtAddr)
 Converts a virtual address inside the block described by desc to it's bus address. More...
 

Detailed Description

Provides a way to easily allocate memory areas that are coherent between CPU and DMA.

This files provides functions to get blocks of memory with known associated physical address that are cache coherent. This is useful when interfacing with peripherals that access memory directly, bypassing the L1 or L2 caches, like the DMA.

Function Documentation

int ccmp_free ( Ccmb_desc allocatedAreaDesc)

Frees a block allocated with ccmp_malloc()

Returns
negative in case of error
int ccmp_malloc ( size_t  reqSize,
Ccmb_desc allocatedAreaDesc,
unsigned int  byteAlignment 
)

Provides a way to easily allocate memory areas that are coherent between CPU and DMA.

Parameters
reqSizeThe size of the block to be allocated.
allocatedAreaDescHere will be returned the descriptor for the allocated block
byteAlignmentThe allocated block will be aligned to this value
Returns
negative in case of error
uintptr_t ccmp_virtAddrToBusAddr ( Ccmb_desc desc,
void *  virtAddr 
)

Converts a virtual address inside the block described by desc to it's bus address.

Returns
the bus address