Commit Graph

82 Commits

Author SHA1 Message Date
Travis Geiselbrecht
c79960a48c [docs] start building more comprehensive documentation
About half and half AI generated stuff and manually curated, but it's a
pretty good start.

Add a helpful markdown addon to the workspace.
2025-07-29 01:22:11 -07:00
Alex Richardson
0fd355ea4b dlmalloc: fix -Wstrict-prototypes warning 2025-01-07 22:28:07 -08:00
Kelvin Zhang
7d77e28430 [app][uefi] Enable mspace feature on dlmalloc
This allows us to use an identitiy mapped piece of memory as the heap
for UEFI app. UEFI app's allocation would go from this heap.
2024-11-06 10:12:17 -08:00
Travis Geiselbrecht
6ed6f36fa0 [warnings] remove some redundant declarations
Discovered with -Wredundant-decls
2024-04-19 00:07:49 -07:00
Travis Geiselbrecht
0255d80bd0 [external][libfdt] rename a top level function that collides with the name of a structure
Fixes an issue when the header is compiled with C++.
2024-04-16 23:01:31 -07:00
Travis Geiselbrecht
414c1e2665 [external][libfdt] update libfdt to newest version
Update libfdt from https://github.com/dgibson/dtc at revision
855c934e26aeadb5bab878d1b148090af2480c90

Source is verbatim except moving headers into an include directory added
to the path.

Using 2-clause BSD option.
2024-04-16 23:01:26 -07:00
Travis Geiselbrecht
c892c958f4 [external] update raspberry pi pico SDK
Bump to version 1.5.1 from
https://github.com/raspberrypi/pico-sdk
6a7db34ff63345a7badec79ebea3aaef1712f374

All code verbatim with the exception of the removal of CmakeList.txt
files and a tweak to platform.h.
2024-02-27 00:12:23 -08:00
Travis Geiselbrecht
25ff64d4fd [libc] move sys/cdefs.h out of libm and into the main include path
More code is using it, so try to build a more standardized version of
it. For now, since most of the defines that are needed are similar to
lk/compiler.h, mostly reimplement in terms of those.
2024-02-27 00:12:15 -08:00
Alex Richardson
496e2f4b8c [riscv][clang] Use a CSR name instead of a numeric expression
Clang's assembler rejects expressions containing e.g. (1u << N) in the
assembler. Instead using numeric expressions for per-privilege level
CSRs, we can prepend `m` or `s`. This also lets the compiler assign the
CSR encoding instead of having to hardcode it in the source code.
2023-06-08 07:08:49 -07:00
Alex Richardson
231f58903b [make][clang] Do not add unsupported warning flags
Currently, clang does not support the -Wno-nonnull-compare and
-Wmaybe-uninitialized warning flags so this adds lots of unknown warning
flag output for each compile job when not using GCC.
This commit adds a makefile macro to check for supported warning flags
and only adds them if the compiler actually supports them.
2023-06-01 17:50:50 -07:00
Akansh
28c615456c Fix CVE-2004-0230
Applied patch for CVE-2004-0230 in tcp_in.c which prevents RST Spoofing Attack (Denial of Service).
2023-06-01 12:43:56 -07:00
Alex Richardson
7b12b201fd [dlmalloc] Fix -Wnull-pointer-arithmetic
Arithmetic on a NULL pointer is undefined behaviour and could be used by
the compiler to optimize out the arithmetic. Use the integer expansion of
chunk2mem(0) instead to silence this warning:
`arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic]`
2023-04-23 17:23:31 -07:00
Travis Geiselbrecht
415096a2bf [external][lib][fdt] update libfdt to newest version
Update libfdt from https://github.com/dgibson/dtc at revision
73590342fc85ca207ca1e6cbc110179873a96962

Source is verbatim except moving headers into an include directory added
to the path.

Using 2-clause BSD option.
2023-01-15 19:02:30 -08:00
Travis Geiselbrecht
2985728864 [stm32f4xx][stdperiph driver] remove +x from file modes in imported files 2022-08-14 19:00:16 -07:00
Travis Geiselbrecht
627e0a5cc0 [stm32f4xx][stdperiph driver] fix a typo in a wait loop 2022-08-14 18:59:50 -07:00
luka177
52ca5d32c9 [External-platform-stm32f4xx]: stm32f4xx.h remove redefenitions 2022-07-24 09:13:02 +03:00
luka177
f2459fe0ab Fix line ending 2022-07-24 08:52:42 +03:00
luka177
6abb5b3db7 [STM32F4xx_StdPeriph_Driver] Define assert_param 2022-07-21 19:22:19 +03:00
luka177
126abea100 Update to latest STM32F4xx_StdPeriph_Driver 2022-07-21 19:13:37 +03:00
Travis Geiselbrecht
6462cbf51c [arch][fpu] add ability to specify per file or module if code needs fpu
Have the arch define additional compiler flags to explicit support or
not support a floating point unit.

Add ability for modules to per file or for the whole module mark code
as needing floating point support.

Add default flags for arm64, riscv, and x86 toolchains.

Needed because gcc 12 is getting much more aggressive about using vector
instructions for non float code, so getting away with avoiding it was
no longer working.

Still not perfect: printf code is being compiled with float, so it's
possible to use floating point instructions inside core kernel or
interrupt handling code if a printf is used.

Possibly will have problems on architectures where mixing float and non
float code at the linker generates issues, but so far seems to be okay.
2022-07-17 16:32:24 -07:00
Travis Geiselbrecht
3ba03f7def [external][libm] add -Wno-maybe-uninitialized
Some older code triggers this warning on gcc 12.1.
2022-05-12 20:04:42 -07:00
Travis Geiselbrecht
0257ac8c1f [dev][pcnet32] get the pcnet32 driver building and working again
Not enabled by default since it uses the experimental driver api and
depends on lwip. But, builds and works if selected.
2021-11-09 00:44:55 -08:00
Travis Geiselbrecht
fcb65c9a88 [dev/lib][warnings] fix -Wmissing-declarations warnings in dev/ and lib/ 2021-10-21 23:16:20 -07:00
Travis Geiselbrecht
392dd18cfc [external][ARM][CMSIS] save a copy of the CMSIS patch
Save a formatted patch of the last commit to help reapplying in the
future.
2021-10-07 00:00:22 -07:00
Travis Geiselbrecht
4e25fdd11b [external][ARM][CMSIS] reapply the systick patch to cmsis
SysTick_Config() tries to set the systick priority to max. Comment out
this line since arch/arm/arm-m/arch.c sets the priority to medium to
compete with the rest of the exceptions in the system.

Also include lk/compiler.h to avoid redundant cmsis macros.
2021-10-07 00:00:22 -07:00
Travis Geiselbrecht
a0b27a955a [external][ARM][CMSIS] update to cmsis 5.3.2
Taken from https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/Core/Include

End of line changed in this patch from DOS to unix so the change looks
larger than it is. View without whitespace diffs to get a cleaner look.
2021-10-07 00:00:22 -07:00
Travis Geiselbrecht
5a3d51e3e7 [assert] fix up a few places broken at DEBUG=0 after recent assert changes
Forgot to test at DEBUG=0. Both of these are basically cases where
the new DEBUG_ASSERT_COND should be used, since the default DEBUG_ASSERT
will now always emit code that gets cleaned up in the optimizer.
2021-04-02 20:16:53 -07:00
Brian Swetland
e65436dca9 [external][pico] import source from rpi pico sdk
Origin: https://github.com/raspberrypi/pico-sdk
Branch: develop
Change: ebb228bfeaec81dce3b8ebdbf6c7f5fd580e2e2f

This is the contents of src/boads, src/common,
src/rp2040, and src/rp2_common, excluding cmake
goop.

I suspect we'll trim it back closer to just the
register definitions, but for now leave it mostly
as-is to simplify updating as the pico sdk updates
and we figure out how deeply (or not) to integrate
it with lk.
2021-02-15 21:06:05 -08: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
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
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
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
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
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
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
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
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
Martin Foo
b66bd3e420 Add STM32F429I-DISCO1 support(default serial:USART1). 2019-06-19 18:18:52 -07:00
Travis Geiselbrecht
8dca2206d2 [external][arm][cmsis] save the patch we just applied as a patch file 2019-06-12 14:26:48 -07:00
Travis Geiselbrecht
37918306f8 [external][arm][cmsis] reapply the systick patch to cmsis
SysTick_Config() tries to set the systick priority to max. Comment out
this line since arch/arm/arm-m/arch.c sets the priority to medium to
compete with the rest of the exceptions in the system.
2019-06-12 14:26:48 -07:00
Travis Geiselbrecht
0d58a1a108 [external][arm][cmsis] update to new pristine copy of CMSIS for cortex-m
CMSIS 5.1.0 from the CMSIS 5.5.1 pack

Pristine copy, build broken until next commit.
2019-06-12 14:26:36 -07:00
Travis Geiselbrecht
f98cef7992 [warnings] fix warnings across the entire code base
Fix or squelch all warnings in all code covered by buildall.
2018-12-16 17:33:22 -08:00
Eric Holland
31b8d1d217 [nrf] Support for NRF52840 DK 2018-05-02 14:50:41 -07:00
Todd Eisenberger
e007acc4dc [stm32f0xx] Add support for stm32f070xb
This cleans up handling of a lot of optional components
across f0xx models.
2018-04-17 10:52:14 -07:00