CRpi
A library for rpi with intefaces to: gpio, pwm, dma
Functions
cacheCoherentMemoryProvider.cpp File Reference

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

#include <stdint.h>
#include <stdlib.h>
#include "../notMine/mailbox.h"
#include <CCRCodingUtils/include/errorManagement.h>
#include <memoryManagement/physMemoryManagement.h>
#include <memoryManagement/addressing.h>
#include <memoryManagement/cacheCoherentMemoryProvider.h>

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.

See cacheCoherentMemoryProvider.h

This file uses the "mailbox property interface". I didn't find a complete and clear documentation but only vague and sparse informations. So I'll use the files mailbox.c and mailbox.h taken from https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/hello_pi/hello_fft/ And some information taken from the sources of servoblaster and piblaster. Thanks to servoblaster, piblaster, the raspberry foundation and broadcom.

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