From 2d5645e57a73928e03feea84e29ec27dfb352b91 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 3 May 2016 11:47:01 -0700 Subject: [PATCH] nios2: add minimal crt0.S At the moment this just jumps into prep_c, with comments left on other things that need to be done. Having this here ensures that the early boot code isn't discarded by gc-sections. vector_table.c removed, it isn't the right approach for this CPU. Proper method for initializing reset and exception vectors still being investigated. Change-Id: Id7965c671f1a55c42ecfb65119497405a646bec4 Signed-off-by: Andrew Boie --- arch/nios2/core/Makefile | 4 +- arch/nios2/core/crt0.S | 45 +++++++++++++++++++ .../arch/nios2/asm.h | 30 +++---------- 3 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 arch/nios2/core/crt0.S rename arch/nios2/core/vector_table.c => include/arch/nios2/asm.h (53%) diff --git a/arch/nios2/core/Makefile b/arch/nios2/core/Makefile index 7526d9871d5..12a41278b26 100644 --- a/arch/nios2/core/Makefile +++ b/arch/nios2/core/Makefile @@ -2,8 +2,8 @@ ccflags-y += -I$(srctree)/kernel/nanokernel/include ccflags-y +=-I$(srctree)/arch/$(ARCH)/include ccflags-y += -I$(srctree)/kernel/microkernel/include -obj-y += reset.o irq_manage.o fatal.o vector_table.o swap.o thread.o \ - cpu_idle.o irq_offload.o prep_c.o +obj-y += reset.o irq_manage.o fatal.o swap.o thread.o \ + cpu_idle.o irq_offload.o prep_c.o crt0.o obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o diff --git a/arch/nios2/core/crt0.S b/arch/nios2/core/crt0.S new file mode 100644 index 00000000000..98a2304fe9c --- /dev/null +++ b/arch/nios2/core/crt0.S @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define _ASMLANGUAGE +#include + +/* exports */ +GTEXT(__start) + +/* imports */ +GTEXT(_PrepC) + + +SECTION_FUNC(TEXT_START, __start) + + /* TODO initialize instruction cache, if present */ + + /* TODO if shadow register sets enabled, ensure we are in set 0 */ + + /* TODO initialize data cache, if present */ + + /* TODO setup stack pointer */ + + /* TODO setup global pointer, if used */ + + /* TODO if shadow register sets enabled, interate through them to set + * up. Need to clear r0, write gp, set the execption stack pointer */ + + /* Jump into C domain. _PrepC zeroes BSS, copies rw data into RAM, + * and then enters nanokernel _Cstart */ + call _PrepC + diff --git a/arch/nios2/core/vector_table.c b/include/arch/nios2/asm.h similarity index 53% rename from arch/nios2/core/vector_table.c rename to include/arch/nios2/asm.h index a8745b65f8a..cf30d79d856 100644 --- a/arch/nios2/core/vector_table.c +++ b/include/arch/nios2/asm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel Corporation + * Copyright (c) 2015 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,13 @@ * limitations under the License. */ -#include +#ifndef _NIOS2_ASM_H +#define _NIOS2_ASM_H -void __reset_handler(void) -{ - /* stub */ -} - -void __exception_handler(void) -{ - /* stub */ -} +#include +#include -struct vector_table { - uint32_t reset; - uint32_t exception; -}; -/* FIXME not using CONFIG_RESET_VECTOR or CONFIG_EXCEPTION_VECTOR like we - * should - */ -struct vector_table _vector_table _GENERIC_SECTION(.exc_vector_table) = { - (uint32_t)__reset_handler, - (uint32_t)__exception_handler -}; - -extern struct vector_table __start _ALIAS_OF(_vector_table); +#endif