Commit graph

229 commits

Author SHA1 Message Date
Andrew Boie e2ff2fdd91 nios2: add base exception handling code
Change-Id: I56b0ec1a3576a77ca7bd6f2c0217de8053406927
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 16:42:20 +00:00
Andrew Boie 1487c6d66e nios2: implement _Swap() and _new_thread()
With this code we can successfully boot and context switch into
the main thread. Nanokernel hello_world has the expected
"Hello World!" string in the RAM console.

Change-Id: I56335d992f5a7cbb12d9e4c02d1cc23ea28ae6ef
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 16:42:18 +00:00
Andrew Boie 3574aec5e1 nios2: don't enable XIP by default
If XIP is turned on, only hardware breakpoints may be used, and
code cannot be loaded onto the device with nios2-download
or GDB 'load' command. RAM-constrained applications are free to
enable this if they need to.

Change-Id: Iee2d41f71f7ca2bc599801cf3cf0fac680273e51
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:13 +00:00
Andrew Boie 5846018d0d nios2: crt0: fix GDB debugging
When an image is sent over the wire with the GDB 'load' command,
it tries to start execution from the __start symbol, which needs to
be in RAM. Since the reset vector is in ROM, name it something else.

Change-Id: Id0bbfa76db9a8a81bd7ff20be3f2baec81eae15e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:12 +00:00
Andrew Boie 0d9b755bb1 nios2: ensure stack pointer is properly aligned
Kconfig doesn't enforce any kind of alignment when specifying the
ISR stack size. Perform the assembly equivalent of STACK_ROUND_DOWN.

Change-Id: Ib7fb72ff7db8a3aa20ec6d0c59a03aa8227f6671
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:11 +00:00
Andrew Boie b5177d7d2d nios2: Makefile: optionally include SOC Makefile
It may not necessarily exist.

Change-Id: I5c79d7538edef78e38f7e05b004e69e0259dd079
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:10 +00:00
Andrew Boie 464676510b nios2: crt0: init interrupt stack as well
CONFIG_INIT_STACKS should initialize all stack regions
with 0xaa. Make sure the initial interrupt stack gets this
as well. Take care not to exceed the bounds of the array
if it is not 4-byte aligned.

Change-Id: Ib23329ac84a5a8515272be2944f948e8faba65b3
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:10 +00:00
Andrew Boie 6524bae242 nios2-qemu: experimental QEMU target for Nios II
Change-Id: I4c2413000166b4a8c221fab81f3d8da98a88806b
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:09 +00:00
Andrew Boie 4fabf216fd nios2f-zephyr: add Nios II/f core
This core has extra debugging features useful for this bring-up
exercise.

Change-Id: I619bc8768acb1d9be8699a6e238168f47e605f3d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-22 01:31:09 +00:00
Kumar Gala b757c1ccba nios2: remove empty files from nios2e-zephyr
Use a kbuild trick to force built-in.o to get built even if there isn't
any code so we can link properly.  This is cleaner than keeping around
empty files that don't do anything.

Change-Id: I4214d21104fe5f49613fa5697c8116b0e8c8aa50
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-06-17 17:28:31 +00:00
Andrew Boie 00365c188c nios2: Kconfig: remove some unused config options
We get these out of system.h instead. A clause in libc-hooks.c
for newlib added since we don't get RAM size from
CONFIG_SRAM_BASE_ADDRESS.

Change-Id: Ic35113395b951f625e8e29658afe19c525037964
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:42 +00:00
Andrew Boie 3b9302158c nios2: set up common linker script for XIP and non-XIP
We will require 6 variables to be defined by SOC-specific
linker script; these values in turn can be pulled from
defines in layout.h.

To help position code correctly we define two new ELF sections
for this arch, 'reset' and 'exceptions'.

Change-Id: Idffbd53895945b7d0ec0aac281e5bf7c85b4b2c2
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:41 +00:00
Andrew Boie dca76617f0 nios2: implement irq_enable() and irq_disable()
Change-Id: I98fee2df9cb8a7aa9769863238980d043903d436
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:41 +00:00
Andrew Boie 45cff183a2 nios2: implement nano_cpu_idle and nano_cpu_atomic_idle
Nios II does not have a power saving instruction, so there is nothing
to really do here other than ensure that interrupts are in the correct
state when leaving nano_cpu_atomic_idle().

Change-Id: I664c7542dc2fc1795a453d35e183a737dcb20c38
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:41 +00:00
Andrew Boie 9280e71ea4 nios2: add flashing/debug scripts
For the moment, NIOS2_CPU_SOF must be set with the path to the
CPU configuration. We are checking with Altera on whether we
can directly check in the binary to the source tree.

These scripts depend on tools provided by the Altera Quartus
Prime Lite Edition. This is available for free but requires
registration on Altera's website to obtain.

Change-Id: Ia6cb6c9e43c3e141807a887cb25c47b370a7d8e9
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:40 +00:00
Andrew Boie fe6f178a3b nios2: generate kernel image in Intel HEX format
Altera tools for creating .pof files for flashing onto their
FPGAs require UFM data to be in this special format. Extend
the current 'all' and 'zephyr' targets to additionally create
this .hex file using objcopy, with the same exclusions as the
existing rule for .bin files.

Change-Id: I75293fba47536545359f817a1f2c1ae905b9d25c
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:40 +00:00
Andrew Boie 31e8030c05 nios2: set initial stack pointer to the interrupt stack
Change-Id: I5a71215dde9e7fdc7d5d9de5297f5f493de40ca8
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:39 +00:00
Andrew Boie 191f1df574 nios2: crt0: split into __start and __text_start
__start is the CPU's reset vector. In a typical Nios II configuration,
the exception vector is 0x20 bytes after the reset vector, severely
constraining the amount of code that can go in here.

Split this into __start and __text_start. The only thing that __start
really need to do is init the instruction cache and jump into
__text_start.

JIRA IDs placed in comments for missing items.

Change-Id: I3c6b8ed65e8fcf6b6a735b80cf007d0180599230
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:39 +00:00
Andrew Boie e57f3446ac nios2: add arch/nios2/soc/<soc>/include to linker include path
Linker scripts for Nios II will also need these headers as it
specifies the device's physical layout and various important
vector addresses.

Change-Id: Ie9efaf19e53d2493eed7b9783052393d7ea9dd0f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-06-10 15:22:39 +00:00
Kumar Gala 6102427e5d build: Introduce concept of SoC specific build flags
Introduce a soc-cflags, soc-cxxflags, and soc-aflags as a means for
SoC specific compiler flags to be set without manipulating Kbuild
options directly.

Change-Id: I2c8f5019fb237429e59717ef96bd4251a61dc1a5
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-05-27 10:04:29 -05:00
Andrew Boie e91f7101c6 nios2: update _new_thread prototype to latest changes
Now matches kernel/nanokernel/include/nano_internal.h.

Change-Id: I4dbbf50aa05c55de42100a6896fe0fa3b26955ec
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-09 18:09:28 +00:00
Andrew Boie 8564875a98 nios2: provide and include soc-specific headers
BSP builds for Nios II generate a linker.h and system.h which reflects
the configuration for that CPU. This can vary depending on how the CPU
is wired up in QSYS, so it needs to be at the SOC level--we essentially
treat any given CPU configuration as a SOC in Zephyr build terms.

Include these files from <arch/cpu.h>.

Change-Id: I12f76600107fec1a14a2f9cb82b0f55915ec03a6
Origin: Altera Quartus tools, machine generated
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-09 18:09:28 +00:00
Andrew Boie 7f7337a0fe nios2: fatal: add _SysFatalErrorHandler and _Fault stub
ZEP-252 will handle implementation of the code here.

Change-Id: I3e9a6c7cdf2d5a3b0240317b772628fead528095
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-09 18:09:27 +00:00
Andrew Boie 2d5645e57a 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 <andrew.p.boie@intel.com>
2016-05-09 18:09:26 +00:00
Andrew Boie ff872dc349 build: rename non-generated linker scripts to .ld extension
Avoids confusion with .gitignore rules, which were inadequate to
cover all the places where these files are found. At least in
VIM, these files are now syntax highlighted correctly.

Change-Id: I23810b0ed34129320cc2760e19ed1a610afe039e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-09 18:09:26 +00:00
Andrew Boie f6cf65d57c nios2: add prep_c to zero BSS and copy XIP data
Copied verbatim from arch/arc/core

Change-Id: I00c920064f75455010806951ad052289d0290654
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-03 23:18:46 +00:00
Andrew Boie d380e555c6 nios2: turn on function and data sections
Change-Id: I5bd841873207d1106a82b3e05187ee401b6c5478
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-03 23:18:46 +00:00
Andrew Boie f00671ab16 nios2: move cflags hacks to main Nios2 Makefile
These are for any Nios II at this stage of bring-up.

Change-Id: Ie4d0c80df164f81f6615ac35d3f42235b04870f1
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-03 23:18:46 +00:00
Andrew Boie 9433895954 nios2: basic build, non-functional
Basic build framework for Nios2. Everything is stubbed out,
we just want to have a build going so that we can start to
parallelize implementation tasks.

This patch is not intended to be functional, but should be
able to produce a binary for all the nanokernel-based
sanity checks.

Change-Id: I12dd8ca4a2273f7662bee46175822c9bbd99202a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-03 23:18:45 +00:00