From 397bf5192a44ea95a82a9792cb7a8a23b112bb3e Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 3 Feb 2013 15:29:05 -0500 Subject: Add some forgotten DMA files. --- source/nds/dma_adj.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 source/nds/dma_adj.c (limited to 'source/nds/dma_adj.c') diff --git a/source/nds/dma_adj.c b/source/nds/dma_adj.c new file mode 100644 index 0000000..8b6f9ad --- /dev/null +++ b/source/nds/dma_adj.c @@ -0,0 +1,26 @@ +#include "ds2_malloc.h" +#include "dma_adj.h" + +#ifdef DS2_DMA + +struct SPointerAdjustments PtrAdj; + +void* AlignedMalloc (unsigned int Size, unsigned int Alignment, unsigned int* Adjustment) +{ + if (Alignment == 0) Alignment = 1; + + unsigned char* result = (unsigned char*) malloc(Size + Alignment); + if (!result) { + return result; + } else { + *Adjustment = Alignment - ((unsigned int) result & (Alignment - 1)); + return (void*) (result + *Adjustment); + } +} + +void AlignedFree (void* Memory, unsigned int Adjustment) +{ + free((void*) ((unsigned char*) Memory - Adjustment)); +} + +#endif // DS2_DMA -- cgit v1.2.3