vaseboot/VasEBoot-core/kern/arm/coreboot/dma.c

60 lines
1.7 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2007,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/>.
*/
#include <VasEBoot/dl.h>
#include <VasEBoot/dma.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm_private.h>
#include <VasEBoot/cache.h>
struct VasEBoot_pci_dma_chunk *
VasEBoot_memalign_dma32 (VasEBoot_size_t align, VasEBoot_size_t size)
{
void *ret;
if (align < 64)
align = 64;
size = ALIGN_UP (size, align);
ret = VasEBoot_memalign (align, size);
if (!ret)
return 0;
VasEBoot_arch_sync_dma_caches (ret, size);
return ret;
}
void
VasEBoot_dma_free (struct VasEBoot_pci_dma_chunk *ch)
{
VasEBoot_size_t size = (((struct VasEBoot_mm_header *) ch) - 1)->size * VAS_EBOOT_MM_ALIGN;
VasEBoot_arch_sync_dma_caches (ch, size);
VasEBoot_free (ch);
}
volatile void *
VasEBoot_dma_get_virt (struct VasEBoot_pci_dma_chunk *ch)
{
return (void *) ch;
}
VasEBoot_uint32_t
VasEBoot_dma_get_phys (struct VasEBoot_pci_dma_chunk *ch)
{
return (VasEBoot_uint32_t) (VasEBoot_addr_t) ch;
}