Commit Graph

2105 Commits

Author SHA1 Message Date
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
Travis Geiselbrecht
80967e78a6 [arch] tweak arch_cycle_count prototype to return a ulong
This lets some arches return a 64bit counter.

As a result of fixing this, removed -Wno-format switch in the test app
which caused the need to fix a lot of printfs.
2020-05-16 17:55:50 -07:00
Travis Geiselbrecht
35c3742b6c [scripts][codestyle] add some comments on the codestyle script 2020-05-16 15:33:00 -07:00
Travis Geiselbrecht
6e0762fb53 [arch][arm] remove some old dead code for pre armv6 compiles
Haven't built for a pre-armv6 or v6 + thumb machine in a long time and
the effort needed to maintain that is not really worth it. Officially
remove the old support code.
2020-05-16 15:07:55 -07:00
Travis Geiselbrecht
f371fa246b [arch] move the atomic ops into a separate header
Now you need to include arch/atomic.h to get to the atomic routines.
This simplifies a recusion issue in the way arch/ops.h included
arch_ops. Also just generally makes things cleaner.
2020-05-16 15:05:34 -07:00
Travis Geiselbrecht
556c985b0c [arch][arm64] remove some extraneous copy-pasta in the ops header 2020-05-16 14:40:51 -07:00
Travis Geiselbrecht
f8effeba66 [arch][x86] switch x86 to the builtin atomics
Easy to do except for the legacy compile case for i386, in which case we
have to start defining fallthrough atomic routines that the compiler
will call.

At the moment only implement __atomic_fetch_add_4 since its the only one
in use.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
d0f1944038 [arch] define the atomic routines in arch-neutral headers and use builtins
Generally move most arches over to using the builtin atomics except for
the few that still require a little bit of work.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
de29964f7c [platform][zynq] tweak to build at lower optimization levels
For some reason this particular sequence isn't picked up as a warning
unless you're compiling with -O1 or below.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
c57b661c93 [kernel][thread] change the way get_current_thread is inlined
Previously, was relying on a regular definition with the arch_ops.h code
overriding it with a static inline. This has been annoying for some
years since it forces the declarations to be in order. Change it to
simple declare an inline wrapper around an arch_ routine that does
whatever it needs to do.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
3e66ea6361 [arch][riscv] simplify the exception decoding logic
Use the sign bit on the cause register to separate interrupts from
exceptions.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
a5e6261e48 [arch][riscv] optimize the bss fill and data copy in start.S
Use full width load/stores based on the bitness of the build. Previous
linker script changes made sure the start/stop symbols are always
aligned.
2020-05-15 02:06:47 -07:00
Travis Geiselbrecht
225bef5a4b [riscv][linker] general cleanup of the linker scripts
Start using PHDRS and MAXPAGESIZE, remove some extraneous stuff.

Possible we can combine a lot of these linker scripts for various arches
if we're careful.
2020-05-15 02:06:23 -07:00
Travis Geiselbrecht
7544ff39b5 [dev] move the device/driver class api to __start __stop style symbols 2020-05-15 00:11:14 -07:00
Travis Geiselbrecht
d3d22d68a5 [lib][console] switch the console commands to __start __stop style symbols 2020-05-15 00:03:14 -07:00
Travis Geiselbrecht
c6ee887e96 [init] switch the init hook system to __start __stop style symbols 2020-05-15 00:00:50 -07:00
Travis Geiselbrecht
243975bbce [apps] switch to the __start __stop section linker magic 2020-05-14 23:57:42 -07:00
Travis Geiselbrecht
f10d9baadb [lib][fs] switch the fs registration to __start __stop style registration
Use the linker's auto generation of a __start_* and __stop_* symbol to
define a run of global structures.
2020-05-14 23:53:46 -07:00
Travis Geiselbrecht
badbeb691a [lib][elf][riscv] add riscv machine defines to libelf 2020-05-10 21:27:35 -07:00
Travis Geiselbrecht
95cf798c83 [console][panic] slight tweak to where the panic shell define is set
Tweak the default platform_halt to idle the core if fully wedged.
2020-05-10 20:03:31 -07:00
Travis Geiselbrecht
445283fd8c [lib][unittest] slight tidying of the unittest library
Added unittest lib to the test virtual project. Currently nothing uses
it.
2020-05-10 19:50:08 -07:00
Travis Geiselbrecht
7c9906a5ff [arch][riscv] Initial implementation of MMU for RISC-V
Implements both SV39 and SV48. No 32bit support yet.

Currently implements basic setup of paging in start.S by mapping a large
chunk of memory into both an identity map and to the bottom of the
kernel address space. Run the kernel out of this physical mapping.

Added basic arch mmu support for querying existing paging structures and
mapping 4K pages. No unmap support as of yet.

System boots with mmu on when running supervisor test on qemu. Untested
on real hardware as of yet.
2020-05-10 17:09:48 -07:00
Travis Geiselbrecht
0b6866830d [arch][arm64][mmu] use slightly more efficient pmm_alloc_page routine
Only used when allocating page size aligned page tables, which is the
common case.
2020-05-10 16:51:58 -07:00
Travis Geiselbrecht
7cc7d79e74 [pmm] add a few more convenience routines
Add a routine to just allocate a single page and a fast page for
allocating a single kvaddr page.
2020-05-10 16:51:58 -07:00
Travis Geiselbrecht
d6bba37cec [arch][riscv] make sure the stack is 16 byte aligned for new threads
This is according to the RISC-V ABI, even in 32bit mode.
2020-05-03 19:34:32 -07:00
Travis Geiselbrecht
5fd7168ab9 [arch][riscv] use a simpler access method for current_thread 2020-05-03 18:50:12 -07:00
Travis Geiselbrecht
6dee5a1303 [arch][riscv] add a per cpu structure and point the scratch register at it
Generally spiff up and clean up the MP code and how the cpu to hart and
vice versa translation is handled.
2020-05-03 17:57:46 -07:00
Travis Geiselbrecht
811566f03d [lib][fdtwalk] spiff up the fdt walker to read #address-cells and #size-cells
Will now start to handle properly sized cells for future parsing
efforts.
2020-05-03 14:47:22 -07:00
Travis Geiselbrecht
f34164580e [libc][printf] remove wrapper #define macro that calls inner _printf
Wasn't really useful and caused the compiler to not be able to optimize
printf -> puts replacements which is slightly nicer.
2020-04-30 01:02:19 -07:00
Travis Geiselbrecht
83c2eb5b0e [debug][panic] remove the wrapper panic #define and read the caller inside panic itself
Was always this way for some reason, which would tend to print the
calling routine that called the routine that paniced, which was of
dubious use. Simplify the panic logic and just call it as a standard
varargs routine.
2020-04-30 01:00:45 -07:00