13#include "modules/drivers/common/dma/IsaDma.h"
14#include "pedigree/kernel/Log.h"
15#include "pedigree/kernel/processor/MemoryRegion.h"
16#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
17#include "pedigree/kernel/processor/VirtualAddressSpace.h"
18#include "pedigree/kernel/processor/types.h"
19#include "pedigree/kernel/utilities/utility.h"
22#warning ISA DMA not supported on non-x86 architectures. TODO: FIXME
30int cdi_dma_open(
struct cdi_dma_handle* handle, uint8_t channel, uint8_t mode,
size_t length,
void* buffer)
34 handle->channel = channel;
36 handle->length = length;
37 handle->buffer = handle->meta.realbuffer = buffer;
44 (length + page_size - 1) / page_size,
49 WARNING(
"cdi: Couldn't allocate physical memory for DMA!");
55 handle->meta.region =
reinterpret_cast<void*
>(region);
57 ByteSet(handle->buffer, 0, handle->length);
60 if(IsaDma::instance().initTransfer(handle->channel, handle->mode, handle->length, region->
physicalAddress()))
77int cdi_dma_read(
struct cdi_dma_handle* handle)
81 MemoryCopy(handle->meta.realbuffer, handle->buffer, handle->length);
93int cdi_dma_write(
struct cdi_dma_handle* handle)
97 MemoryCopy(handle->buffer, handle->meta.realbuffer, handle->length);
109int cdi_dma_close(
struct cdi_dma_handle* handle)
Special memory entity in the kernel's virtual address space.
void * virtualAddress() const
physical_uintptr_t physicalAddress() const
static const size_t continuous
static PhysicalMemoryManager & instance()
static constexpr size_t getPageSize() PURE
static const size_t below16MB
static const size_t Write