vaseboot/include/VasEBoot/dma.h

45 lines
1.7 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_DMA_H
#define VAS_EBOOT_DMA_H 1
struct VasEBoot_pci_dma_chunk;
struct VasEBoot_pci_dma_chunk *EXPORT_FUNC(VasEBoot_memalign_dma32) (VasEBoot_size_t align,
VasEBoot_size_t size);
void EXPORT_FUNC(VasEBoot_dma_free) (struct VasEBoot_pci_dma_chunk *ch);
volatile void *EXPORT_FUNC(VasEBoot_dma_get_virt) (struct VasEBoot_pci_dma_chunk *ch);
VasEBoot_uint32_t EXPORT_FUNC(VasEBoot_dma_get_phys) (struct VasEBoot_pci_dma_chunk *ch);
static inline void *
VasEBoot_dma_phys2virt (VasEBoot_uint32_t phys, struct VasEBoot_pci_dma_chunk *chunk)
{
return ((VasEBoot_uint8_t *) VasEBoot_dma_get_virt (chunk)
+ (phys - VasEBoot_dma_get_phys (chunk)));
}
static inline VasEBoot_uint32_t
VasEBoot_dma_virt2phys (volatile void *virt, struct VasEBoot_pci_dma_chunk *chunk)
{
return (((VasEBoot_uint8_t *) virt - (VasEBoot_uint8_t *) VasEBoot_dma_get_virt (chunk))
+ VasEBoot_dma_get_phys (chunk));
}
#endif