nanokernel: move dataCopy() and bssZero() to common code
Used by ARC, ARM, Nios II. x86 has alternate code done in assembly. Linker scripts had some alarming comments about data/BSS overlap, but the beginning of BSS is aligned so this can't happen even if the end of data isn't. The common code doesn't use fake pointer values for the number of words in these sections, don't compute or export them. Change-Id: I4291c2a6d0222d0a3e95c140deae7539ebab3cc3 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
b6fb004354
commit
5b9378ab7e
10 changed files with 81 additions and 193 deletions
|
@ -1,5 +1,6 @@
|
|||
ccflags-y +=-I$(srctree)/include/drivers
|
||||
ccflags-y +=-I$(srctree)/arch/arm/soc/$(SOC_PATH)
|
||||
ccflags-y +=-I$(srctree)/kernel/nanokernel/include
|
||||
|
||||
asflags-y = $(ccflags-y)
|
||||
|
||||
|
|
|
@ -30,53 +30,11 @@
|
|||
#include <stdint.h>
|
||||
#include <toolchain.h>
|
||||
#include <linker-defs.h>
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Clear BSS
|
||||
*
|
||||
* This routine clears the BSS region, so all bytes are 0.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
static void bssZero(void)
|
||||
{
|
||||
volatile uint32_t *pBSS = (uint32_t *)&__bss_start;
|
||||
unsigned int n;
|
||||
|
||||
for (n = 0; n < (unsigned int)&__bss_num_words; n++) {
|
||||
pBSS[n] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Copy the data section from ROM to RAM
|
||||
*
|
||||
* This routine copies the data section from ROM to RAM.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
#include <nano_internal.h>
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
static void dataCopy(void)
|
||||
{
|
||||
volatile uint32_t *pROM = (uint32_t *)&__data_rom_start;
|
||||
volatile uint32_t *pRAM = (uint32_t *)&__data_ram_start;
|
||||
unsigned int n;
|
||||
|
||||
for (n = 0; n < (unsigned int)&__data_num_words; n++) {
|
||||
pRAM[n] = pROM[n];
|
||||
}
|
||||
}
|
||||
|
||||
static inline void relocate_vector_table(void) { /* do nothing */ }
|
||||
#else
|
||||
static void dataCopy(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void relocate_vector_table(void)
|
||||
{
|
||||
/* vector table is already in SRAM, just point to it */
|
||||
|
@ -136,8 +94,8 @@ void _PrepC(void)
|
|||
{
|
||||
relocate_vector_table();
|
||||
enable_floating_point();
|
||||
bssZero();
|
||||
dataCopy();
|
||||
_bss_zero();
|
||||
_data_copy();
|
||||
_Cstart();
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue