summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/altera-cyclone-v
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-25 08:40:20 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-27 10:33:30 +0100
commitcbc433c7a25dbe19414f70edc64f9de1f630a117 (patch)
tree8d53c70658b82b052f0c5c81e7a025548a147aea /c/src/lib/libbsp/arm/altera-cyclone-v
parentrtems: Add rtems_cache_coherent_allocate() (diff)
downloadrtems-cbc433c7a25dbe19414f70edc64f9de1f630a117.tar.bz2
bsps/arm: Add .nocache section
This section can be use to provide a cache coherent memory area via rtems_cache_coherent_add_area().
Diffstat (limited to 'c/src/lib/libbsp/arm/altera-cyclone-v')
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/include/nocache-heap.h55
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/network/network.c14
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am4
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspstart.c7
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv2
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv_devkit11
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/startup/mmu-config.c9
-rw-r--r--c/src/lib/libbsp/arm/altera-cyclone-v/startup/nocache-heap.c89
9 files changed, 11 insertions, 182 deletions
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/Makefile.am b/c/src/lib/libbsp/arm/altera-cyclone-v/Makefile.am
index 3e02200470..6afe6814aa 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/Makefile.am
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/Makefile.am
@@ -47,7 +47,6 @@ include_bsp_HEADERS += ../shared/include/arm-gic-regs.h
include_bsp_HEADERS += ../shared/include/arm-gic-tm27.h
include_bsp_HEADERS += ../shared/include/arm-release-id.h
include_bsp_HEADERS += include/irq.h
-include_bsp_HEADERS += include/nocache-heap.h
# Altera hwlib
include_bsp_HEADERS += hwlib/include/alt_16550_uart.h
@@ -171,7 +170,6 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
libbsp_a_SOURCES += startup/bspreset.c
libbsp_a_SOURCES += startup/bspstart.c
libbsp_a_SOURCES += startup/bspstarthooks.c
-libbsp_a_SOURCES += startup/nocache-heap.c
libbsp_a_SOURCES += startup/mmu-config.c
if HAS_SMP
libbsp_a_SOURCES += ../shared/arm-a9mpcore-smp.c
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/include/nocache-heap.h b/c/src/lib/libbsp/arm/altera-cyclone-v/include/nocache-heap.h
deleted file mode 100644
index 73f56f3e65..0000000000
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/include/nocache-heap.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * @file
- *
- * @brief Heap handling for uncached RAM
- */
-
-/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifndef NOCACHE_HEAP_H_
-#define NOCACHE_HEAP_H_
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/** @brief Initialize nocache heap.
- *
- * Initializes a heap for uncached RAM
- */
-void altera_cyclone_v_nocache_init_heap( void );
-
-/** @brief Nocache alloc.
- *
- * Allocate memory from uncached heap.
- * @param size Number of bytes to be allocated.
- * @returns Pointer to the allocated memory.
- */
-void *altera_cyclone_v_nocache_malloc( const size_t size );
-
-/** @brief Nocache free.
- *
- * Release memory from uncached heap.
- * @param ptr Address of the memory to be released.
- */
-void altera_cyclone_v_nocache_free( void *ptr );
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* NOCACHE_HEAP_H_ */
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/network/network.c b/c/src/lib/libbsp/arm/altera-cyclone-v/network/network.c
index 43c95cd723..28596cf116 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/network/network.c
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/network/network.c
@@ -38,7 +38,6 @@
#include <bsp/hwlib.h>
#include <bsp/alt_clock_manager.h>
#include <bsp/alt_generalpurpose_io.h>
-#include <bsp/nocache-heap.h>
#include "socal/alt_rstmgr.h"
#include "socal/alt_sysmgr.h"
#include "socal/hps.h"
@@ -1032,7 +1031,7 @@ static int network_if_mem_alloc_nocache(
assert( memory != NULL );
if ( memory != NULL ) {
- *memory = altera_cyclone_v_nocache_malloc( size );
+ *memory = rtems_cache_coherent_allocate( size, 0, 0 );
if ( *memory != NULL ) {
eno = 0;
@@ -1057,18 +1056,11 @@ static int network_if_mem_free_nocache(
void *arg,
void *memory )
{
- int eno = EINVAL;
-
(void) arg;
- assert( memory != NULL );
+ free( memory );
- if ( memory != NULL ) {
- altera_cyclone_v_nocache_free( memory );
- eno = 0;
- }
-
- return eno;
+ return 0;
}
/**
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am b/c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am
index 8fe547e6fc..8ed1b5e47d 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am
@@ -135,10 +135,6 @@ $(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
-$(PROJECT_INCLUDE)/bsp/nocache-heap.h: include/nocache-heap.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/nocache-heap.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/nocache-heap.h
-
$(PROJECT_INCLUDE)/bsp/alt_16550_uart.h: hwlib/include/alt_16550_uart.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/alt_16550_uart.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/alt_16550_uart.h
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspstart.c b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspstart.c
index 85eadbf628..52e535c21c 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspstart.c
@@ -15,11 +15,14 @@
#include <bsp/bootcard.h>
#include <bsp/arm-a9mpcore-clock.h>
#include <bsp/irq-generic.h>
-#include <bsp/nocache-heap.h>
+#include <bsp/linker-symbols.h>
void bsp_start( void )
{
a9mpcore_clock_initialize_early();
bsp_interrupt_initialize();
- altera_cyclone_v_nocache_init_heap();
+ rtems_cache_coherent_add_area(
+ bsp_nocache_heap_begin,
+ (uintptr_t) bsp_nocache_heap_size
+ );
}
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv
index da4275ff63..bea6df1659 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv
@@ -13,6 +13,8 @@ REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_BSS", RAM);
REGION_ALIAS ("REGION_WORK", RAM);
REGION_ALIAS ("REGION_STACK", RAM);
+REGION_ALIAS ("REGION_NOCACHE", NOCACHE);
+REGION_ALIAS ("REGION_NOCACHE_LOAD", NOCACHE);
bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv_devkit b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv_devkit
index 0e0c38ea24..c36b3ce323 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv_devkit
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/linkcmds.altcycv_devkit
@@ -4,15 +4,4 @@ MEMORY {
RAM : ORIGIN = 0x00300000, LENGTH = 1024M - 1M - 1M - 1M
}
-SECTIONS {
- .nocache (NOLOAD) : {
- bsp_section_nocache_begin = .;
- *(SORT(.bsp_nocache*))
- bsp_section_nocache_end = .;
- } > NOCACHE AT > NOCACHE
- bsp_section_nocache_size = bsp_section_nocache_end - bsp_section_nocache_begin;
- bsp_section_nocache_load_begin = LOADADDR (.nocache);
- bsp_section_nocache_load_end = bsp_section_nocache_load_begin + bsp_section_nocache_size;
-}
-
INCLUDE linkcmds.altcycv
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/mmu-config.c b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/mmu-config.c
index 98b4ac833b..9d56e5c8f5 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/mmu-config.c
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/mmu-config.c
@@ -14,16 +14,9 @@
#include <bsp/arm-cp15-start.h>
-LINKER_SYMBOL(bsp_section_nocache_end);
-LINKER_SYMBOL(bsp_section_nocache_begin);
-
const arm_cp15_start_section_config arm_cp15_start_mmu_config_table[] = {
ARMV7_CP15_START_DEFAULT_SECTIONS,
- {
- .begin = (uint32_t) bsp_section_nocache_begin,
- .end = (uint32_t) bsp_section_nocache_end,
- .flags = ARMV7_MMU_DATA_READ_WRITE
- }, { /* Periphery area */
+ { /* Periphery area */
.begin = 0xFC000000U,
.end = 0x00000000U,
.flags = ARMV7_MMU_DEVICE
diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/nocache-heap.c b/c/src/lib/libbsp/arm/altera-cyclone-v/startup/nocache-heap.c
deleted file mode 100644
index ae2faef3fc..0000000000
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/startup/nocache-heap.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * @file
- *
- * @brief Heap handling for uncached RAM
- */
-
-/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <assert.h>
-#include <bsp/linker-symbols.h>
-#include <bsp/nocache-heap.h>
-#include <rtems/score/heapimpl.h>
-#include <rtems/score/apimutex.h>
-
-/** @brief Uncached RAM pool
- *
- * Allocate the whole bsp_nocache for the nocache heap */
-static char nocache_pool[1024 * 1024]
- __attribute__( ( section( ".bsp_nocache" ) ) );
-
-/** @brief Nocache heap
- *
- * Heap control for the uncached RAM heap */
-static Heap_Control nocache_heap;
-
-/** @brief Init nocache heap
- *
- * Constructor for the uncached RAM heap
- * @returns 0 on succuss, error code from errno.h on failure
- */
-void altera_cyclone_v_nocache_init_heap( void )
-{
- uintptr_t heap_status = 0;
-
- heap_status = _Heap_Initialize(
- &nocache_heap,
- &nocache_pool[0],
- sizeof( nocache_pool ),
- 0
- );
- assert( heap_status != 0 );
-}
-
-/** @brief Allocate uncached RAM
- *
- * Allocates RAM from the uncached heap
- * @param size Number of bytes to be allocated
- * @returns Pointer to the allocated RAM
- */
-void *altera_cyclone_v_nocache_malloc( const size_t size )
-{
- void* ret = NULL;
-
- _RTEMS_Lock_allocator();
- ret = _Heap_Allocate( &nocache_heap, size );
- _RTEMS_Unlock_allocator();
-
- return ret;
-}
-
-/** @brief Free uncached RAM
- *
- * Releases RAM from the uncached heap
- * @param ptr Address of the RAM to be released
- */
-void altera_cyclone_v_nocache_free( void *ptr )
-{
- if ( ptr != NULL ) {
- bool ok;
-
- _RTEMS_Lock_allocator();
- ok = _Heap_Free( &nocache_heap, ptr );
- _RTEMS_Unlock_allocator();
-
- assert( ok );
- }
-}