Commit Graph

2096 Commits

Author SHA1 Message Date
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
Travis Geiselbrecht
89cdb26d5b [platform][arm/riscv][virt] update both arm-virt and riscv-virt to use libfdtwalk
No real change except moving fdt walking code into the fdtwalk library.

Also update some constants for ARM virt and bump the load address to
make sure the FDT works. Turns out it had been missing for a while so it
was actually not finding it because the kernel was loaded too close to
the start of memory.
2020-04-25 18:46:57 -07:00
Travis Geiselbrecht
f1dcdfd7a8 [lib][fdtwalk] move some of the duplicate code to parse flattened device trees into a shared lib
Uses a callback structure that various platforms can use to automate
walking through the trees for common nodes.
2020-04-25 18:37:57 -07:00
Travis Geiselbrecht
36fd4c3244 [external][libfdt] refresh copy of libfdt from upstream
Snapshot as of revision 62cb4ad286ff82648232f769f78401bf6b00deda
from https://github.com/dgibson/dtc
2020-04-05 19:16:46 -07:00
Travis Geiselbrecht
4a04e4634b [travis-ci] add sifive-unleashed board to the build matrix 2020-03-28 20:33:04 -07:00
Travis Geiselbrecht
dc1cfc0b33 [target][sifive-unleashed] get working on a physical sifive unleashed
Only tested with SBI and supervisor mode, but that's all I have now.

Add checked in copies of the device tree needed for a uboot uimage
needed to start it.
2020-03-28 20:33:04 -07:00
Travis Geiselbrecht
17037d258d [riscv] add a max HART define to deal with offset hart numbering
Add a define that sets the maximum allowed hart number, potentially
higher than the maximum number of allowed cpus.

This lets us more cleanly deal with having a higher HART number than the
logical cpu numbering. Only really works where it's still fairly packed
around 0, but in the case of the Sifive Unleased board it's just offset
by 1 so it's not a huge loss.

Generally clean up RISCV SMP boot code by rearranging things a bit as
well.
2020-03-28 20:33:04 -07:00
Travis Geiselbrecht
e0cdfbae17 [python] fix a few of the python tools to be python 2 and 3 compatible 2020-03-08 16:39:15 -07:00
Travis Geiselbrecht
b54f5f2b0f [dev][bus][pci] add simple type 1 (IO port based) access mode 2020-03-07 19:40:41 -08:00
Travis Geiselbrecht
389965328f [dev][bus][pci] split the bios32 routines out into a separate file
Disable bios32 mechanism based on architecture (x86-32 only) for now.
2020-03-07 18:39:35 -08:00