Commit Graph

2155 Commits

Author SHA1 Message Date
Brian Swetland
16ba667296 [app][mdebug] makefile.fw and linkscript to regenerate fw
The original tooling is lost to the mists of time and long-discarded
workstations, but this generates identical results and will enable
updating the code on the m0 sub-processor going forward.  Yay.
2021-01-30 02:51:41 -08:00
Brian Swetland
98cf1e5067 [app][mdebug] normalize whitespace in fw-m0sub.h
The xxd tool generates two spaces of indent, not four.

Fix this existing file to match the tool output to make it easier
to detect changes to the resulting image header when rebuilt.
2021-01-30 02:48:34 -08:00
Piotr Tworek
a969cc9c99 [libc] Fix UINT16_MAX, INT16_MIN and INT16_MAX definitions.
The defines from limits.h have SHRT, not SHORT in their names.
2021-01-25 18:49:35 -08:00
Travis Geiselbrecht
c55ab00668 [platform][sifive] add a GPIO driver and switch the target setup to it 2021-01-20 01:11:29 -08:00
Travis Geiselbrecht
7033559d38 [inc][c++] add some additional __BEGIN_CDECL/__END_CDECLS to various global headers
Just a few that were missed, and picked up with some additional C++ code.
2021-01-20 01:02:48 -08:00
Travis Geiselbrecht
3083f63253 [arch][riscv] fix accidental file rename in last commit
Have been fiddling with using some C++ in the riscv code, but didn't
intend to check this file rename in yet.
2021-01-14 20:21:22 -08:00
Travis Geiselbrecht
649ca7dd54 [make] encode the source file extension into the .o file
Instead of compiling each .c or .cpp or .S file into an equivalent .o file,
map it to a file with .c.o or .cpp.o extension.

IE,
    foo.c -> foo.c.o
    bar.cpp -> bar.cpp.o

Reason for this being that if you change the suffix of a file it'll
automatically pick it up and recompile.
2021-01-14 18:43:18 -08:00
Travis Geiselbrecht
b655fea02f [platform][qemu-virt-riscv] switch to dlmalloc as default heap
miniheap is really not set up for large memory machines.
2021-01-14 18:27:37 -08:00
Travis Geiselbrecht
6f5fe1efca [arch][riscv] add proper SBI extension support
-Add support for probing SBI extensions
-Switch to newer versions if present
-Add HBM extension which allows proper secondary cpu bootstrap
-Add support for secondary bootup via HBM.
2020-12-30 03:43:54 -08:00
Travis Geiselbrecht
d1c04827e9 [arch][riscv] make sure zero sized bsses work
-Skip looping if the bss size is actually zero

Issue #288
2020-12-30 02:15:26 -08:00
Travis Geiselbrecht
6bd5e9e857 [arch][riscv] tweak some of the start.S code that was recently modified
-Add a comment as to why a2 is used to hold the assigned cpu id
-Add a memory fence after releasing the secondary cpus
2020-12-30 02:02:50 -08:00
Travis Geiselbrecht
a21bc34022 [arch][riscv] restructure the qemu starter script to share the embedded and non embedded logic 2020-12-30 02:02:42 -08:00
Travis Geiselbrecht
6ea6256d89 [platform][sifive] add switch to scripts/do-riscvqemu to run sifive unleashed
Also fix up some broken bits on the previously unused qemu-sifive-u target.
2020-12-30 01:40:05 -08:00
Travis Geiselbrecht
1e50428091 [arch][riscv] remove the last of the RISCV_BOOT_HART mechanism
Now the harts are dynamically numbered, so don't need
this mechanism anymore.
2020-12-30 01:09:24 -08:00
Travis Geiselbrecht
c2d77234c3 [arch][riscv] switch to using a boot lottery to dynamically assign cpu number
Turns out that in some cases we can't really rely on a particular boot cpu id
so go ahead and simply dynamically assign cpu numbers by having each cpu
increment an atomic number in the very top of start.S. The first one in gets
the worm.
2020-12-30 00:52:41 -08:00
Travis Geiselbrecht
431543a9bf [platform][qemu-virt-arm] spiff up the PSCI call to boot the secondary cpus
Add a few comments and print something in case of error.
2020-12-17 01:40:40 -08:00
Travis Geiselbrecht
3194e45807 [arch][riscv][sbi] add probe for new SRST extension 2020-12-09 02:15:29 -08:00
Travis Geiselbrecht
8869020ae2 [arch][riscv] fix bug with gcc 10.2 & binutils 2.35 with section padding
In a two segment binary was previously trying to use MAXPAGESIZE set to 4
to cram the sections in very tight for embedded. This seemed to with this
toolchain cause the linker to get confused and sometimes appear to stuff in
an extra 4 bytes in the output file, thus misaligning the data segment.

It's possible it's still a bug on my side in the linker, but setting
max_page_size to 8 seems to work around it for now. Possible there's some
implicit 64bit aligning slipped in a stage somewhere in binutils thats
causing it to get confused. Either way, 8 byte alignment is no large loss
here.
2020-12-09 01:59:16 -08:00
Travis Geiselbrecht
11ca56717e [scripts][do-sifive-e] point the script at the current versions of the sifive-e sdk
Not ideal to have these hard coded but it beats building them from scratch.
2020-11-30 23:22:59 -08:00
Travis Geiselbrecht
54955fb7f7 [platform][qemu-riscv] add simple hard coded support for poweroff and reset
Writing to a particular address will tell qemu to poweroff or reset.
2020-11-12 03:05:41 -08:00
Travis Geiselbrecht
f893499029 [github][irc] try to use notice instead of privmsg 2020-10-21 02:43:17 -07:00
Travis Geiselbrecht
01f9a97dc1 [arch][openrisc] fix up and get the OpenRISC port working again
Previous to now it had always relied on a custom patched gcc
and a custom sim. In the interim since the initial port went in
some time in 2015 GCC and QEMU have both officially picked up support
for the architecture and the machine that was emulated in the previous
emultor.

Using gcc 10.2 fix up the build and get it basically working. Timers
seem to not be working right but it's probably fairly easy to fix.
2020-10-21 02:34:50 -07:00
Travis Geiselbrecht
917906e4a4 [libc] add abort() implementation
Does nothing but call panic(). The compiler has been seen emitting
this which is highly suspicious.
2020-10-21 02:34:50 -07:00
Travis Geiselbrecht
9366b4ae37 [platform][include] move current_time and friends to its own header
Just an itch that has bothered me for a while. Current time is not
strictly speaking platform specific though it's usually associated
with platform code. Move it into its own header and add some text
to explain a bit whats going on.

Add some more comments for other headers while in there.
2020-10-21 02:34:50 -07:00
Eric Holland
fbac7e3f8f [nrf52][tick] improve RTC use for LK tick
Using the RTC1 module for the LK tick (instead of arm systick)
Use the nrf_hal library for peripheral manipulation instead of
direct register access.  Fixed race condition in current_time_hires
which would result in non monotonic readings.

Tested with clock_tests on:
  nrf52-pca10040-test  (nrf52832)
  nrf52-pca10056-test  (nrf52840)
2020-10-14 16:12:07 -04:00
vannapurve
945cd5ecdb [ARCH][ARM64] Dump more information during aborts
1) Decode FSC and dump more human readable status
2) Add support of stack unwinding as referred from
arm64 procedure call standard and frame pointer usage.
3) Compiler options for not omitting frame pointer
are enabled to ensure usage of frame pointers even
with higher optimization levels enabled.

Signed-off-by: vannapurve <vannapurve@google.com>
2020-10-13 16:16:15 -07:00
Travis Geiselbrecht
60972b36c1 [arch][arm][cortex-m] select the simplified arch interrupt save/restore for armv6m too
Previously had only selected armv7m for the simplified version.
Forgot that cortex-m0s are armv6m and could use this version.
2020-10-11 03:27:27 -07:00
Eric Holland
94675a7780 [nrf52][i2c] move i2c_init to target
Since the i2c driver is optional (not required for platform) the
i2c_init should be done during target initialization.  The flags
used to include the i2c driver should be in either target or project
files so it makes sense that the i2c_init should also be called from
target files.
2020-10-10 16:48:49 -04:00
Eric Holland
38dd509b27 [nrf][pca10040] fix platform incompatibilities
When the nrf52xxx platform was changed to use the Nordic nrfx
libraries the pca10040 target was broken due to differences in
how the platform handled initialization.
2020-10-10 16:12:07 -04:00
Travis Geiselbrecht
e0487f9b48 [github][action][irc] tweak the bot name 2020-10-10 01:50:34 -07:00
Travis Geiselbrecht
bf6de611f2 [github][actions][irc] add a irc notify action
This should hypothetically send a message to the #lk channel on freenode
on push and other git events.

We shall see.
2020-10-10 01:47:45 -07:00
Travis Geiselbrecht
bf24db407e [endian] update the endian.h file to use builtins and tighten up a macro
Use compiler builtins for these and make the *E32SWAP routines a bit safer.
2020-10-10 01:08:02 -07:00
Michael Bishop
71687b4cbf [arch][arm] fix booting when in HYP mode 2020-10-10 00:58:38 -07:00
Travis Geiselbrecht
ed7e3571c2 [kernel][thread] gcc 10.2 warning fix
In a previous patch, on architectures where SMP is disabled,
thread_pinned_cpu() will always return a negative number. GCC 10.2
is somewhat more aggressive about negative shift values so it wasn't
detecting that the second path of an if statement is never taken.

Solution is to cache the pinned cpu value and use it for both the
test and the operation.
2020-10-09 01:25:03 -07:00
vannapurve
961ef679cf [kernel][thread] Wake up only needed cores
This change ensures that during thread scheduling
only needed cores are woken up as per the thread's
CPU affinity rather than all cores. This would avoid
un-necessary wakup for other cores from lower power
states without having to execute anything.

Signed-off-by: vannapurve <vannapurve@google.com>
2020-10-09 01:10:35 -07:00
Venkatesh Srinivas
c4cdc17865 [platform][tms570-launchpad] Do not try to save d16-d31 on ARMv7-R
All shipping ARMv7-R processors include VFPv3-D16, a subset of VFPv3
with only 16 double-precision registers. The first -R profile CPU
with a complete VFP or NEON implementation is the Cortex-R52,
implementing ARMv8-R.

LK's context switch code had a dynamic check and would only save
d16-d31 if present, but gcc/gas will not assemble code that includes
references to d16-d31 when mcpu=cortex-r4f or other v7-R CPUs.

Ideally we'd key the #if off of __TARGET_FPU_VFPV3_D16, but that
only appears to be defined by the ARM compilers, not gcc. Use
V7-R as the key instead.
2020-10-09 00:58:32 -07:00
Eric Holland
d1bad2e683 [nrf][clock] use nrfx lib clock driver
Using Nordic's nrfx driver for the clock control peripheral since
it address a handful of errata and abstracts some differences
in the nrf52 family of parts.
2020-10-06 17:50:51 -04:00
Eric Holland
7068fb63cb [nrf52][gpio] use nrfx gpio library
Platform gpio driver now uses the nrfx library for gpio manipulation.
This allows utilization of second gpio bank present on some parts
and handling of errata.
2020-10-03 15:05:34 -04:00
Eric Holland
c45337488c [nrf][i2c] Fix second i2c module instance
Second TWIM module did not have correct instance number.
Removed leftover dprintf.
2020-09-30 18:56:21 -04:00
Eric Holland
668be9d9fa [nrf52][i2c] Add nrfx i2c driver
Use twim(i2c) driver from nrfx library.  See comments and patterns in
target/nrf-pca10056 for info on how to properly utilize driver as it
requires some GLOBAL_DEFINES and gpio defines.
2020-09-28 09:07:27 -04:00
Eric Holland
80f464b7cb [nrfx] Cleanup glue for nrfx library
Errors were introduced when some drivers were compiled due to
nested macros and some conditionals used in LK macros.
2020-09-28 08:50:43 -04:00
Eric Holland
29b49dff83 [nordic][nrfx] Cleanup of nrfx integration 2020-09-21 13:26:07 -04:00
Eric Holland
b720536fe6 Nordic nrfx usb driver integration 2020-09-09 20:24:10 -04:00
Eric Holland
0f36150464 [nordic] use nrfx platform libs 2020-08-31 11:52:37 -04:00
Travis Geiselbrecht
8a8debbe3d [warning] fix a few warnings that pop up with gcc 10.2 2020-07-26 23:42:02 -07:00
Travis Geiselbrecht
7707ab3897 [arch][riscv] specify the target binary format on links, expand exception code
This allows the use of the riscv64-elf toolchain to link riscv32 binaries
and vice versa.

Also add some helpful printfs to the exception code.
2020-07-26 23:41:27 -07:00
Travis Geiselbrecht
1272d037aa [dev][virtio] remove some extraneous __PACKED attributes
From working with -Wpacked its clear that some of the virtio
structures are overly packed and result in bad codegen on particular
architectures such as riscv. Roll back from using packed but
statically assert that the sizes are correct for some future arch
where things naturally pack differently.
2020-07-25 20:04:21 -07:00
Travis Geiselbrecht
ba530722f5 [warning] add -Wdouble-promotion
Mostly just a few warnings where things are promoted via passing floats to
printf. Those we should generally remove anyway because they're just
benchmarking code. Most things LK runs on either doesn't have float or
doesn't have double sized floats.
2020-07-25 17:16:22 -07:00
Travis Geiselbrecht
f7d8e2300c [warnings] add -Wshadow which helps detect local variables that override globals
Nothing particularly bad showed up but cleaned up a bit of code.
2020-07-25 16:49:25 -07:00
Travis Geiselbrecht
82b4d6ffdb [lib][version] rename the global variable version to lk_version
Avoids colliding with some things.
2020-07-25 16:26:12 -07:00