XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
dma.c File Reference
#include <Mm/dma.h>
#include <Mm/kmalloc.h>
#include <_null.h>
#include <string.h>
#include <Drivers/uart.h>
Include dependency graph for dma.c:

Macros

#define DMA_DEFAULT_PAGE_BOUNDARY   PAGE_SIZE
 

Functions

AuDMAPoolAuDMAPoolCreate (const char *name, size_t alloc_sz, size_t align, size_t boundary)
 AuDMAPoolCreate – create a new pool.
 
void * AuDMAPoolAlloc (AuDMAPool *pool, uint64_t *phys_out)
 AuDMAPoolAlloc – allocate a slot from desired pool.
 
void AuDMAPoolFree (AuDMAPool *pool, void *virt, uint64_t phys)
 AuDMAPoolFree – free up a slot within the pool.
 
void AuDMAPoolDestroy (AuDMAPool *pool)
 AuDMAPoolDestroy – completely destroy a pool.
 
void AuDMAGlobalClassInitialize (AuDMAGlobalClass *gclass, char *name)
 AuDMAGlobalClassInitialize – initialize and populate global class structure.
 
void * AuDMAGClassAlloc (AuDMAGlobalClass *gClass, size_t sz, uint64_t *physOut)
 AuDMAGClassAlloc – allocate memory from DMA Global Class.
 
void AuDMAGClassFree (AuDMAGlobalClass *gClass, void *virt, uint64_t physOut, size_t sz)
 AuDMAGClassFree – free a memory and put it to gclass pool.
 
void AuDMAGClassDestroy (AuDMAGlobalClass *gClass)
 AuDMAGClassDestroy – destroy entire dma global class.
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2026, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ DMA_DEFAULT_PAGE_BOUNDARY

#define DMA_DEFAULT_PAGE_BOUNDARY   PAGE_SIZE

Function Documentation

◆ AuDMAGClassAlloc()

void * AuDMAGClassAlloc ( AuDMAGlobalClass gClass,
size_t  sz,
uint64_t physOut 
)

AuDMAGClassAlloc – allocate memory from DMA Global Class.

Parameters
gClass– pointer to gClass
sz– size to allocate
physOut– where to put the physical output

return a full 4KiB page for larger than MAX_POOL_SZ

or allocate it using pool allocator

◆ AuDMAGClassDestroy()

void AuDMAGClassDestroy ( AuDMAGlobalClass gClass)

AuDMAGClassDestroy – destroy entire dma global class.

Parameters
gClass– pointer to gClass

◆ AuDMAGClassFree()

void AuDMAGClassFree ( AuDMAGlobalClass gClass,
void *  virt,
uint64_t  physOut,
size_t  sz 
)

AuDMAGClassFree – free a memory and put it to gclass pool.

Parameters
gClass– pointer to global class
virt– virtual address
physOut– physical address to put
sz– size of the allocated memory

◆ AuDMAGlobalClassInitialize()

void AuDMAGlobalClassInitialize ( AuDMAGlobalClass gclass,
char *  name 
)

AuDMAGlobalClassInitialize – initialize and populate global class structure.

Parameters
gclass– Pointer to allocated gclass
name– suitable gclass name

◆ AuDMAPoolAlloc()

void * AuDMAPoolAlloc ( AuDMAPool pool,
uint64_t phys_out 
)

AuDMAPoolAlloc – allocate a slot from desired pool.

Parameters
pool– pointer to pool memory
phys_out– where to store the physical address

◆ AuDMAPoolCreate()

AuDMAPool * AuDMAPoolCreate ( const char *  name,
size_t  alloc_sz,
size_t  align,
size_t  boundary 
)

AuDMAPoolCreate – create a new pool.

Parameters
name– name of the pool
alloc_sz– allocation unit size
align– alignment to check
boundary– ofcourse page boundary

◆ AuDMAPoolDestroy()

void AuDMAPoolDestroy ( AuDMAPool pool)

AuDMAPoolDestroy – completely destroy a pool.

Parameters
pool– pointer to pool

◆ AuDMAPoolFree()

void AuDMAPoolFree ( AuDMAPool pool,
void *  virt,
uint64_t  phys 
)

AuDMAPoolFree – free up a slot within the pool.

Parameters
pool– pointer to dma pool
virt– virtual address to free
phys– physical address to free