Commit Graph

2056 Commits

Author SHA1 Message Date
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
Travis Geiselbrecht
a44bc7863d [dev][bus][pci] move the pci driver out of platform/pc into generic space
No functional change.
2020-03-07 18:17:36 -08:00
Travis Geiselbrecht
5969063a52 [arch][x86][64] Get the 64bit build working again
Set -fno-builtin to keep the compiler from generating load/stores using
sse outside of floating point code. Not ideal for a lot of reasons but
it's difficult to segregate kernel code and user code such that it only
generates SSE instructions there.

Will probably need to do some work to let certain flags be set per
module, and then have only some of the modules be marked as user vs
kernel.
2020-03-07 18:06:01 -08:00
Travis Geiselbrecht
f0449cc59c [platform][riscv] move the supervisor mode switch to -S which makes more sense 2020-01-26 12:11:14 -08:00
Travis Geiselbrecht
8fbac4302c [arch][riscv] add proper barriers 2020-01-19 16:58:46 -08:00
Travis Geiselbrecht
7648ca09d9 [platform][qemu-riscv] add virtio to bring it up to par with arm virt machine 2020-01-19 16:17:34 -08:00
Travis Geiselbrecht
96359bd05e [arch][riscv] stub out cache and memory barrier ops
Need to implement the barrier ops, but for the moment they're only used
in virtual machines.
2020-01-19 16:16:59 -08:00
Travis Geiselbrecht
0ec24d0b29 [dev][virtio] add no kernel VM workaround
Also add stride to the mmio detect routine. Not all virtio apertures are
tightly packed as they are on arm.
2020-01-19 16:15:58 -08:00
Travis Geiselbrecht
dfcc7c3970 [arch][riscv] move some of the riscv specific headers another level deeper 2020-01-19 15:15:59 -08:00
Travis Geiselbrecht
e75de97e38 [travis-ci] add supervisor mode qemu-riscv to the build 2020-01-19 14:51:04 -08:00
Travis Geiselbrecht
9c71a0ec57 [platform][qemu-riscv] Fixup qemu-riscv target
-Fix plic driver to handle machine vs supervisor mode
-Add switch to scripts/do-qemuriscv to run in supervisor mode (with OpenSBI)
-Use the FDT to detect the number of cpus and size of memory
2020-01-19 14:48:25 -08:00
Travis Geiselbrecht
4d080aaef9 [arch][riscv] fix up the smp reschedule ipi delivery 2020-01-19 14:48:25 -08:00
Travis Geiselbrecht
6dbe2b04a7 [arch][riscv] tweak the SMP start code
-Fix a race in start.S depending on which secondary cpus start first
-Add routine to let a platform/target set the cpu count dynamically
2020-01-19 14:47:07 -08:00
Travis Geiselbrecht
90dc9e50ef [platform][sifive-e] get the hifive1 hardware working again
Had rotted a bit. Had to reimplement a few tweaks.
Also generally #if out a lot of the SMP code when unused on riscv.
2020-01-18 18:39:07 -08:00
Travis Geiselbrecht
1b36390a39 [heap][miniheap] fix assert when miniheap is initialized with a non 8 byte aligned ptr on 64bit cpu 2020-01-16 23:38:38 -08:00
Travis Geiselbrecht
36afd4e095 [arch][riscv] code formatting
using ./scripts/codestyle which is an astyle wrapper
2020-01-16 23:17:34 -08:00
Travis Geiselbrecht
ccf46eefba [arch][riscv] add timer hack back
For one of the riscv embedded targets, the clock ticks at such a slow
rate that the compiler will warn of a div by zero. Add a compile time
hack for this.
2020-01-16 23:10:35 -08:00
Elliot Berman
e50d7db612 [arch][riscv] Add support for running in supervisor mode
Add support for running LK in supervisor mode or machine mode.
- Macro-ify CSR access to use correct CSR # or use SBI call as req'd
- Add support to make SBI calls
- Split CLINT and lk timer abstraction so that RISC-V timer can use SBI
  as required.
- Add support for booting other harts as primary since hart0 on U540
  does not support S-mode. A map is used to get LK cpu number from
  hartid.
2020-01-16 23:06:28 -08:00
Elliot Berman
e137d70ccd [target][riscv] Add support for qemu-sifive-u virt machine
A copy/paste from sifive-unleashed but without PWM/LED.
2020-01-16 23:06:28 -08:00
Elliot Berman
acfe991c7f [arch][riscv] Expose RISC-V mp kernel start
Support mp lk start on RISC-V. Several changes throughout were required:
- Add signal in asm start to force secondary harts to wait for bss to be
  cleared.
- Use mhartid in arch_curr_cpu_num, PLIC, and CLINT
- Use tp register as thread pointer instead of global variable.
- Support sending IPIs between harts using CLINT
- Add spinlock implementation
2020-01-16 23:06:28 -08:00
Elliot Berman
d239adf839 [arch][riscv] Add basic support for SiFive HiFive Unleashed
Most of changes were moving around where macros were defined, plus the
following:
- Remove requirement for floating point on RV64 to support booting
  monitor core on U54 SoC.
- Add support for Debug LEDs on HiFive Unleashed Board
2020-01-16 23:06:28 -08:00
Venkatesh Srinivas
128890f8a8 [platform][tms570-launchpad] Skeleton of port to TI LaunchXL2-TMS57012
* Adds target tms570-launchpad, for TI TMS570 Launchpad Dev Kit
(https://www.ti.com/store/ti/en/p/product/?p=LAUNCHXL2-TMS57012)

* Adds CPU definitions for Cortex R4F (BE) CPU, implementing
  ARMv7-R ISA. Does not yet add definitions for ARMv7 arch entry
  functions.

* Board does not yet build - platform.c/uart.c are empty, no GIC
  entry points provided.
2019-11-18 15:36:28 -08:00
Travis Geiselbrecht
bff17f7e99 [platform][riscv] add code to read the size of memory from the FDT
Tweak the novm allocator to let us more easily add a variable sized
arena at boot.

Also added code to trap secondary cpus and reenable the use of WFI
instruction.
2019-11-02 18:13:02 -07:00
Travis Geiselbrecht
5928d88a0e [travis-ci] add the riscv64 qemu target to the build 2019-11-02 17:23:24 -07:00
Travis Geiselbrecht
fdc08a8446 [arch][riscv] port to riscv64
Very little needed to port except to conditionalize some assembly in the
context switch and exception code. Mostly needed to move build system
stuff around and add a new project.
2019-11-02 17:21:13 -07:00
Travis Geiselbrecht
ae5200595c [platform][riscv-virt] added support for QEMU's riscv 'virt' machine
The virt machine is a generic target, much like the arm virt machine.
Intended to be simple to use and a good target to run large systems like
linux on. At the moment simply support booting and simple uart and timer
support.
2019-11-02 14:19:36 -07:00
Travis Geiselbrecht
dbe86c89be [scripts][do-qemu] minor restructure of how args are passed to qemu
No functional change, just a tiny tweak that had been floating around.
2019-10-23 07:14:45 -07:00
Patrick Shickel
9a6081399c [stm32f0cube][bugfix] Fix race which leads to 0-length SETUP transfers
Fixes a race in the STM USB driver which can lead to the device seeing
only 0-length SETUP transfers. The bug ultimately leads to a failed
USB enumeration. The race condition is described in further detail
below.

The current behavior of the IRQ handler for received OUT transfers is
as such:

- Clear RX_CTR bit (at this point, HW sees that SW has acknowledged
previous SETUP/OUT transfer, and the HW will now accept new STATUS
transfers)
- Call out to the client OutStageCallback (nothing significant here)
- Set EP_RX_CNT back to size of max_packet (was previously set to 0 as
we expect to receive 0-length OUT transfer from host. HW uses this
value to limit the amount of data it can receive)
- Set RX_STAT back to VALID (the HW can now receive new STATUS/OUT
transfers)

The important thing to note here is that even before RX_STAT is set to
VALID in the last step, the HW can still receive and process a new
SETUP transfer as long as RX_CTR is cleared (the spec has some detail
about this under section "Control Transfers" on page 867:
https://www.st.com/resource/en/reference_manual/dm00031936.pdf). The
race will occur if we receive a SETUP transfer after clearing RX_CTR
but before adjusting EP_RX_CNT back to max_packet. In this case, the
IRQ handler will run for the newly received SETUP transfer, but the
transfer will have no data associated with it (the driver ends up
using the previous transfer data which was cached).

We can eliminate the race window by waiting to clear RX_CTR only after
we've reset EP_RX_CNT. In this case the HW will ignore any new SETUP
transfers until after the EP_RX_CNT is reset back to the desired
value.
2019-08-07 16:45:25 -07:00
Erik Gilling
4cf2997a04 [stm32f0] Update to STM32Cube v1.10.1. 2019-08-07 11:01:19 -07:00
Travis Geiselbrecht
ad246760ff [c++] remove WITH_CPP_SUPPORT flag
Just always build with it enabled.
2019-07-13 17:41:25 -07:00
Travis Geiselbrecht
d607a93b86 [project][arm] remove the project switches to disable linker gc 2019-07-13 17:37:25 -07:00
Travis Geiselbrecht
df32504748 [kernel] test run sorting some includes
No functional change.
2019-07-13 17:21:00 -07:00
Travis Geiselbrecht
4aa556b837 [project][qemu-virt-arm32-minimal] add a new project that doesnt' enable as much
Useful for testing when the console is off.
2019-07-13 17:11:48 -07:00
Travis Geiselbrecht
f880ff3615 [libc][c++] move __cxa_atexit into the eabi.c file to always be built
Even if C++ isn't active we still need it.
2019-07-13 17:10:06 -07:00
Travis Geiselbrecht
6cb02526b7 [include][console] split lib/console.h into two
TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
2019-07-13 16:56:33 -07:00
Travis Geiselbrecht
35a8d555a3 [include] move almost all of the remainder of top level includes into a subdir
Examples are include/platform.h -> platform/include/platform.h
include/target.h -> target/include/target.h

The old model generally considered these to be Always There includes,
but they're starting to stick out more and more so may as well actually
follow the model that most of the rest of the system follows.
2019-07-13 16:09:27 -07:00
Travis Geiselbrecht
a634b338c5 [make] tweak the way top level modules are included and add a few comments
No functional change.
2019-07-13 15:56:08 -07:00
Travis Geiselbrecht
3aecdda231 [includes] replace header guards with #pragma once 2019-07-13 15:46:16 -07:00
Travis Geiselbrecht
d10eb9a8f6 [libc] remove a few unused header files
strings.h and alloca.h are unused and a little funny anyway. Probably
were once used in an external library that's no longer in the tree.
2019-07-13 15:46:01 -07:00
Travis Geiselbrecht
cba9e47987 [license] replace the longer full MIT license with a shorter one
Used scripts/replacelic. Everything seems to build fine.
2019-07-05 17:22:23 -07:00
Travis Geiselbrecht
ca648bcd01 [scripts][replacelic] Add a script to replace full MIT licenses with shortened versions 2019-07-05 17:19:13 -07:00