Commit Graph

2134 Commits

Author SHA1 Message Date
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
Travis Geiselbrecht
4edb93adde [lib][console] rename some console command types to be prefixed with console_
Some of the structures, notably 'cmd', in the lib console stuff are a
little too generically named and have collided with some other code
so prefix the names a bit more cleanly with console_

The change is largely mechanical, and folks with out of tree code can
easily switch by renaming:
cmd -> console_cmd
cmd_args -> console_cmd_args
cmd_block -> console_cmd_block
console_cmd -> console_cmd_func

Apologies if this breaks you but it should be pretty easy to fix.
2020-07-25 15:59:58 -07:00
Onath Claridge
c629d762a3 [stm32f0xx] Fix prescaler value.
As specified in ST reference manual RM0091, the prescaling factor
applied by timers is 1 plus the value in the corresponding prescaler
register. (See section 17.4.11 for TIM1, and analogous sections for
other timers.)

This change causes stm32_timer_capture_setup to take the prescaling
factor as input rather than the register value.
2020-07-21 00:33:29 -07:00
Travis Geiselbrecht
9d07949891 [lib][unittest] spiff up the underutilized unittest library
-Stop using 512 bytes of bss and use a proper printf output
routine if the user wants to override it.
-Add a test case for unittest itself to see what the failure printfs
look like and make sure the test registration is working.
2020-07-12 15:37:49 -07:00
Travis Geiselbrecht
5690a8bb58 [arch] make sure the arch rules file sets TOOLCHAIN_PREFIX, make sure riscv picks up the alt selector
ARCH_riscv*_TOOLCHAIN_PREFIX should override TOOLCHAIN_PREFIX like it does on some other arches.
While was at it clean up the rules.mk file a bit.
2020-07-12 13:41:11 -07:00
Travis Geiselbrecht
dac96bea90 [asm] add END_FUNCTION and END_DATA macros and mark up some riscv assembly
Doesn't really do much but at least sets the symbol size properly in a
symbol dump.
2020-07-12 13:41:11 -07:00
Travis Geiselbrecht
cf7de9eaa7 [app][tests] fix a function definition to make the prototype
Only shows up when trying to link with LTO.
2020-07-12 13:11:28 -07:00
Travis Geiselbrecht
4ca59c9237 [arch][riscv] tweak the linker scripts to better place .sdata and .sbss
Refactor the two linker scripts to put .sdata at the end of the data segment
and .sbss at the start of the bss segment to try to maximize the reach of
the global pointer.

Also generally tries to clean up and align the two linker scripts as a new
golden standard for other architectures.
2020-07-11 15:33:14 -07:00
Travis Geiselbrecht
213895c69a [libc] build libc with -fno-builtin
Can't remember precisely what this fixes to be honest, but I
remember there was some sort of recursion on one of the targets on
one of the versions of the compiler.
2020-07-11 14:55:09 -07:00
Travis Geiselbrecht
0105cd8eab [travis-ci] switch main toolchain version to 7.5.0
There were a few 7.3.0 and 7.4.0s in there, bump to 7.5.0.
2020-05-22 14:03:36 -07:00
Travis Geiselbrecht
ca800ac932 [console] move the history buffer into static memory, remove console_init
No need to malloc this memory if it's always going to be initialized
anyway. Add history disabling switch to a few targets to make sure both
builds are tested.
2020-05-17 16:13:45 -07:00
Travis Geiselbrecht
0175e27ac5 [console] move the command blocks into ro memory
Nothing was using console_register_commands so just move the command
block into a read only section. Remove the linked list stuff but add a
block name to print in its place.
2020-05-17 15:59:04 -07:00
Travis Geiselbrecht
30a334288f [lib][console] move the command block private stuff into lib/console
Pull some of the machinery of the lib/console stuff into a private
header that is only pulled in when lib/console is built.
2020-05-17 15:43:00 -07:00
Logan Gorence
77f5dac525 Fix incompatibility with Make 4.3.
+= does not prepend a space if the variable was empty.
Source: https://lwn.net/Articles/810071/
2020-05-17 14:19:25 -07:00
Travis Geiselbrecht
4c39a19583 [travisci] fix a few warnings in the travisci tool 2020-05-17 13:55:16 -07:00
Travis Geiselbrecht
2d29b94c84 [travisci] use parallel builds 2020-05-17 13:55:16 -07:00
Travis Geiselbrecht
61fce09db0 [travisci] have travisci just join the channel when doing a notification 2020-05-17 13:54:52 -07:00
Travis Geiselbrecht
52862d04c7 [arch][riscv] Add a space in some linker script logic
For some reason on older binutils the lack of space around the divide
seems to be a problem.
2020-05-17 13:54:52 -07:00
Travis Geiselbrecht
1ae28c2b5b [arch][x86] big cleanup of the x86.h header
Mostly deduplicating x86-32 and x86-64 code since virtually all of it
can be shared.

Fixed up some cpuid usage which was not properly marking registers as
clobber.
2020-05-16 20:28:17 -07:00
Travis Geiselbrecht
3e5319ff14 [lib][cmpctmalloc] add some missing statics to inline 2020-05-16 19:05:28 -07:00
Travis Geiselbrecht
7d9f80974d [make][flags] remove -finline, which apparently does nothing
Been carrying this flag around for years but from sleuthing around in
the compiler it seems to only exist as the opposite to -fno-inline which
has an actual effect. Only reason -finline would do anything would be to
cancel a previous -fno-inline switch.
2020-05-16 18:54:44 -07:00
Travis Geiselbrecht
aaafac5903 [arch][arm-m] optimize the arch_interrupt_save routine a bit for cortex-m
From looking at the dissassembly the compiler wasn't doing a good job
with the overly complicated version shared with the larger arm cores.
Simplify it by recognizing that you can save the state directly from
PRIMASK and restore it more simply.
2020-05-16 18:54:00 -07:00