arm_coreboot: Support DMA.
This is needed to support USB and some other busses.
This commit is contained in:
parent
656c3b0d7f
commit
265292f2b0
8 changed files with 155 additions and 25 deletions
|
@ -248,6 +248,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dma.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h
|
||||
endif
|
||||
|
|
|
@ -163,6 +163,7 @@ kernel = {
|
|||
arm_coreboot = term/ps2.c;
|
||||
arm_coreboot = term/arm/pl050.c;
|
||||
arm_coreboot = commands/keylayouts.c;
|
||||
arm_coreboot = kern/arm/coreboot/dma.c;
|
||||
|
||||
terminfoinkernel = term/terminfo.c;
|
||||
terminfoinkernel = term/tparm.c;
|
||||
|
|
|
@ -29,6 +29,8 @@ void grub_arm_clean_dcache_range_armv6 (grub_addr_t start, grub_addr_t end,
|
|||
grub_addr_t dlinesz);
|
||||
void grub_arm_clean_dcache_range_armv7 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_clean_dcache_range_poc_armv7 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_invalidate_icache_range_armv6 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_invalidate_icache_range_armv7 (grub_addr_t start, grub_addr_t end,
|
||||
|
@ -252,6 +254,38 @@ grub_arch_sync_caches (void *address, grub_size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_arch_sync_dma_caches (volatile void *address, grub_size_t len)
|
||||
{
|
||||
grub_addr_t start = (grub_addr_t) address;
|
||||
grub_addr_t end = start + len;
|
||||
|
||||
if (type == ARCH_UNKNOWN)
|
||||
probe_caches ();
|
||||
start = ALIGN_DOWN (start, grub_arch_cache_max_linesz);
|
||||
end = ALIGN_UP (end, grub_arch_cache_max_linesz);
|
||||
switch (type)
|
||||
{
|
||||
case ARCH_ARMV6:
|
||||
grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz);
|
||||
grub_arm_invalidate_icache_range_armv6 (start, end,
|
||||
grub_arch_cache_ilinesz);
|
||||
break;
|
||||
case ARCH_ARMV5_WRITE_THROUGH:
|
||||
case ARCH_ARMV6_UNIFIED:
|
||||
grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz);
|
||||
break;
|
||||
case ARCH_ARMV7:
|
||||
grub_arm_clean_dcache_range_poc_armv7 (start, end, grub_arch_cache_dlinesz);
|
||||
grub_arm_invalidate_icache_range_armv7 (start, end,
|
||||
grub_arch_cache_ilinesz);
|
||||
break;
|
||||
/* Pacify GCC. */
|
||||
case ARCH_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm_disable_caches_mmu (void)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
# define ISB isb
|
||||
#define ARMV7 1
|
||||
|
||||
FUNCTION(grub_arm_clean_dcache_range_poc_armv7)
|
||||
DSB
|
||||
@ Clean data cache for range to point-of-coherence
|
||||
1: cmp r0, r1
|
||||
bge 2f
|
||||
mcr p15, 0, r0, c7, c14, 1 @ DCCMVAC
|
||||
add r0, r0, r2 @ Next line
|
||||
b 1b
|
||||
2: DSB
|
||||
bx lr
|
||||
|
||||
|
||||
@ r0 - CLIDR
|
||||
@ r1 - LoC
|
||||
@ r2 - current level
|
||||
|
|
59
grub-core/kern/arm/coreboot/dma.c
Normal file
59
grub-core/kern/arm/coreboot/dma.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/dma.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm_private.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
struct grub_pci_dma_chunk *
|
||||
grub_memalign_dma32 (grub_size_t align, grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
if (align < 64)
|
||||
align = 64;
|
||||
size = ALIGN_UP (size, align);
|
||||
ret = grub_memalign (align, size);
|
||||
if (!ret)
|
||||
return 0;
|
||||
grub_arch_sync_dma_caches (ret, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
grub_dma_free (struct grub_pci_dma_chunk *ch)
|
||||
{
|
||||
grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN;
|
||||
grub_arch_sync_dma_caches (ch, size);
|
||||
grub_free (ch);
|
||||
}
|
||||
|
||||
volatile void *
|
||||
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
||||
{
|
||||
return (void *) ch;
|
||||
}
|
||||
|
||||
grub_uint32_t
|
||||
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
|
||||
{
|
||||
return (grub_uint32_t) (grub_addr_t) ch;
|
||||
}
|
||||
|
|
@ -34,15 +34,14 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
|
|||
#endif
|
||||
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
#ifdef _mips
|
||||
void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address,
|
||||
grub_size_t len);
|
||||
#else
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
static inline void
|
||||
grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
#else
|
||||
void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, grub_size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
44
include/grub/dma.h
Normal file
44
include/grub/dma.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_DMA_H
|
||||
#define GRUB_DMA_H 1
|
||||
|
||||
struct grub_pci_dma_chunk;
|
||||
|
||||
struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align,
|
||||
grub_size_t size);
|
||||
void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch);
|
||||
volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch);
|
||||
grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch);
|
||||
|
||||
static inline void *
|
||||
grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk)
|
||||
{
|
||||
return ((grub_uint8_t *) grub_dma_get_virt (chunk)
|
||||
+ (phys - grub_dma_get_phys (chunk)));
|
||||
}
|
||||
|
||||
static inline grub_uint32_t
|
||||
grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk)
|
||||
{
|
||||
return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk))
|
||||
+ grub_dma_get_phys (chunk));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -142,27 +142,7 @@ grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
|
|||
void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook,
|
||||
void *hook_data);
|
||||
|
||||
struct grub_pci_dma_chunk;
|
||||
|
||||
struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align,
|
||||
grub_size_t size);
|
||||
void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch);
|
||||
volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch);
|
||||
grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch);
|
||||
|
||||
static inline void *
|
||||
grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk)
|
||||
{
|
||||
return ((grub_uint8_t *) grub_dma_get_virt (chunk)
|
||||
+ (phys - grub_dma_get_phys (chunk)));
|
||||
}
|
||||
|
||||
static inline grub_uint32_t
|
||||
grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk)
|
||||
{
|
||||
return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk))
|
||||
+ grub_dma_get_phys (chunk));
|
||||
}
|
||||
#include <grub/dma.h>
|
||||
|
||||
grub_uint8_t
|
||||
EXPORT_FUNC (grub_pci_find_capability) (grub_pci_device_t dev, grub_uint8_t cap);
|
||||
|
|
Loading…
Reference in a new issue