Commit Graph

753 Commits

Author SHA1 Message Date
Travis Geiselbrecht
7102838b49 [arch] have each arch define ARCH_HAS_MMU
This lets some code decide whether or not there's any mmu
present to use. Also kernel VM will complain if it isn't set
as an extra safety.
2021-03-30 02:48:59 -07:00
Travis Geiselbrecht
c8e4a56f00 [target][pico] switch the uart config to target driven
Uses the target/debugconfig.h file pattern laid down before,
which is a bit long in the tooth but for the moment still helps
us separate target from platform.
2021-02-15 21:06:05 -08:00
Travis Geiselbrecht
c2574c46c6 [arch][arm-m] add logic to conditionally set VTOR if present
VTOR is optional on cortex-m0+, so let the platform or target set
a define to do it.

Move the RP20xx platform to this switch.
2021-02-15 21:06:05 -08:00
Brian Swetland
7d3f648e88 [rp20xx] quick and dirty early init using pico-sdk driver code
- pull in headers for essential modules
- init clocks, gpios, uart0 out of platform_early_init
- wire up debug getc/putc to uart0
- comment out "native" uart impl
2021-02-15 21:06:05 -08:00
Brian Swetland
9c769f6931 [rp20xx][pico-sdk] add some missing / generated headers
- sys/cdefs is wanted for __CONCAT()
- version.h and config_autogen.h are generated by the pico sdk
- config_autogen expects to include board file
- instead define PICO_xyz in target rules.mk
2021-02-15 21:06:05 -08:00
Brian Swetland
5434847c51 [libc] C style static_assert takes two arguments
Fix this up and fix up the one existening dependency on the
existing incorrect behaviour.
2021-02-06 20:30:34 -08:00
Travis Geiselbrecht
7c43f66169 [platform][pi20xx] Add a tool to convert the final .bin file to a UF2 file
Tool is MIT licensed, taken from
https://github.com/microsoft/uf2
2021-02-06 16:29:02 -08:00
Brian Swetland
b142c6bdcd [rp20xx][pico] platform and target for rp20xx and pico board
- just a skeleton to get us started
- cpu feature config and irq names / vectab2 setup done
- pulled in the second stage for pico as a blob for now
- seems to be hard faulting out of systick setup in platform_init()
2021-02-05 19:25:19 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
3aecdda231 [includes] replace header guards with #pragma once 2019-07-13 15:46:16 -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