Commit Graph

2820 Commits

Author SHA1 Message Date
Travis Geiselbrecht
c9d2f80e43 [dev][interrupt][gicv2] test that this is a GICv2
Add some boot time informational message and read the maximum number of
interrupts supported by this hardware.
2025-10-05 13:57:21 -07:00
Travis Geiselbrecht
34310ae0ca [make] remove line numbers from the non-debug .lst file
Turns out it's just a little too noisy for me for normal bringup. That's
what .debug.lst is for.
2025-10-05 13:57:13 -07:00
Travis Geiselbrecht
e0b5008641 [riscv][toolchain] fix clang test of -misa switch which is not present
The test inside riscv/rules.mk was assuming gcc and that the CC variable
isn't passed in from the user. This is not a very clean solution and
acts like a bandaid over the problem. Added some todos for a potential
solution.
2025-10-05 13:57:04 -07:00
Travis Geiselbrecht
48d331f144 [clang] fix a few warnings
Mostly dealing with comparing a pointer variable that is declared
nonnull, which I find to be a dubious warning but is pretty safe in this
case since the compiler will be more aggressive about the nullness of
the arguments.
2025-10-05 13:56:55 -07:00
Travis Geiselbrecht
64e1ccfe78 [scripts] add do-qemu-boot-tests.py
This will boot a list of qemu emulated devices with the option to run
all of the unittests at boot.

Will be automatically enabled on the build servers soon which will fail
any pending CLs if it breaks.
2025-10-02 00:01:41 -07:00
Travis Geiselbrecht
976cd70f4f [unittests] add RUN_UNITTESTS_AT_BOOT build option
This will cause the system to automatically run all of the unit tests
after a short pause on boot. Will be used by an automatic test script.

At the moment there aren't a lot of unit tests in the list, but this
should greatly increase the utility of them since they'll be
automatically run.
2025-10-01 23:54:54 -07:00
Travis Geiselbrecht
be07027fe1 [project][pc] add minip and all of the fses to all of the PC projects
Leave minip out of legacy PC right now since the registration scheme is
a bit broken and assumes e1000 is present.
2025-10-01 23:41:11 -07:00
Travis Geiselbrecht
5720b2a32f [fs][fat][tests] be a bit more forgiving if the test device isn't present
Have the unit tests for the FAT driver fail a bit more gracefully if the
test device is not present, to make it somewhat easier to live with this
driver present with systems a way to mount a test volume.
2025-10-01 23:35:48 -07:00
Travis Geiselbrecht
e3ffad684f [scripts] make sure all the do-qemu* scripts exec qemu as the last line
This helps a wrapper script test for proper exit.
2025-10-01 23:33:25 -07:00
Travis Geiselbrecht
ad6ef65a5a [arch][ops.h] force all of the fast routines to be inline
Also make sure each arch_ops.h always includes arch/ops.h at the top, to
make sure the declaration always appears in front of the definition.
2025-10-01 20:56:07 -07:00
Travis Geiselbrecht
04b88750b3 [debug] remove lib/debug and move to the top/ module
Most of the functions for this was declared in a top level lk/ include
space, so go ahead and move it there.

A few exceptions:
- Moved spin() over to platform/time.h and platform/time.c since the
function more logically belongs to platform/time.h.  Any users of
spin() will need to update their headers to include platform/time.h
instead.

- Renamed spin_cycles() to arm_cm_spin_cycles() and moved over into
arm/cm.h since it is currently defined in arch/arm-m and only used for
targets that implicitly are for arm-m.
2025-10-01 20:56:06 -07:00
Travis Geiselbrecht
163e296e70 [docs] tweak a few errors in the blocking primitives doc 2025-10-01 20:56:06 -07:00
Travis Geiselbrecht
022b050925 [vscode] add a few more recommended extensions to the list 2025-10-01 20:56:06 -07:00
Travis Geiselbrecht
e739abc490 [kernel] tweak a few thread apis to to take a const pointer
A bit of reformatting on some ARM code while was touching it.
2025-10-01 20:56:06 -07:00
Travis Geiselbrecht
f5999d5a40 Merge branch 'port_race_test' of github.com:redpig/lk
edit: add a few quickie warning fixes
2025-09-29 23:15:57 -07:00
Mahavir Jain
68c6ae154c [wait-queue] fix wake all to remove threads from tail
While waking up all threads from wait-queue, order should
start from tail to maintain correct scheduling sequence.

Signed-off-by: Mahavir Jain <mahavirpj@gmail.com>
2025-09-29 23:03:59 -07:00
luka177
014de968e1 [target-stm32f429i-disco]: Initial lcd support 2025-09-29 22:44:53 -07:00
Lei Wen
145e9a0d27 [arch] fix link script not include global array init
Using wild match init_array* to include global array init ctor

Before:

 10 .ctors             00000040 ffff0000001e6b80 00000000401e6b80 DATA
 11 .dtors             00000000 ffff0000001e6bc0 00000000401e6bc0 DATA
 12 .got               00000060 ffff0000001e6bc0 00000000401e6bc0 DATA
 13 .init_array.1      00000470 ffff0000001e6c20 00000000401e6c20
 14 .fini_array.1      00000470 ffff0000001e7090 00000000401e7090
 15 .dummy_post_data   00000000 ffff0000001e7500 00000000401e7500 DATA
 16 .bss               00009460 ffff0000001e8000 00000000401e8000 BSS

After:

 10 .ctors             000004b0 ffff0000001e6b80 00000000401e6b80 DATA
 11 .dtors             00000470 ffff0000001e7030 00000000401e7030
 12 .got               00000060 ffff0000001e74a0 00000000401e74a0 DATA
 13 .dummy_post_data   00000000 ffff0000001e7500 00000000401e7500 DATA
 14 .bss               00009460 ffff0000001e8000 00000000401e8000 BSS

Signed-off-by: Lei Wen <leiwen@asrmicro.com>
2025-09-29 22:40:41 -07:00
Travis Geiselbrecht
63e4bdcd92 [build] add line numbers to the disassembly .lst files 2025-09-29 22:28:00 -07:00
Travis Geiselbrecht
1f54072295 [platform][pc] when building with SMP, don't even attempt to bring up the local apic
Not exactly what we want but avoids the lapic code needing the per cpu
structures which aren't set up without SMP support.

Consider leaving the percpu structure in, just only support for cpu 0.

This fixes trying to boot the X86_LEGACY build on a machine with a local
apic.
2025-09-29 22:20:30 -07:00
Travis Geiselbrecht
936ee8ac81 [arch][x86] start of an ioapic driver
Doesn't do much but provided the detection path for it and ability to
hold initialized state. The higher level platform code is going to need
to use it directly so will mostly just provide an api for access to it.

Moved ACPI sniffing back to just after the VM is initialized instead of
all the way into platform_init(). This should try to ensure that all
drivers that come up afterwards will have ioapics discovered in case
future development tries to enable and use them, kicking the machine out
of virtual-wire-mode.
2025-09-24 01:18:52 -07:00
Travis Geiselbrecht
72112c0676 [pci] little bit of code cleanup in the pci bus driver
Mostly just suggestions by clang-tidy. No functional change.
2025-09-23 23:16:55 -07:00
Travis Geiselbrecht
5a17519e54 [arch][riscv] fix rounding issue with PAGE_SIZE on riscv64
Inadvertently added this bug where PAGE_SIZE type is 32bit which causes
truncating when using it to round a kernel address.
2025-09-23 23:05:15 -07:00
Travis Geiselbrecht
b7d69d8804 [arch][x86] handle the local apic of the boot cpu not being 0
I have a bulldozer machine here that curiously starts the APIC IDs for
the cpus at 16 and counts up.

This is a problem since the current code assumes that the boot cpu is 0,
and would try to start itself (apic id 16) later because it thought it
was the first secondary. Fix this by re-reading the APIC id on the boot
cpu and patching the percpu structure a bit into boot. Kinda a hack but
avoids having to detect the APIC, find the type of ID to read, etc.

Also means that practically speaking the system is using the full 32bit
APIC IDs if that feature is present, since now the local apic id is
entirely read from the local apic as it should be (if present).

Fixes #475
2025-09-22 20:57:30 -07:00
Travis Geiselbrecht
bdf2203fdc [arch][x86][lapic] a little bit of restructuring of some recent lapic code
Functionally equivalent, but refactor two copies of local apic
initialization code into a shared routine.
2025-09-21 21:53:35 -07:00
little fairy
d0eb5c464e [arch][x86] Read full 32bit apic id from x2apic msr if available (#465) 2025-09-21 21:04:00 -07:00
Kelvin Zhang
a1be045514 [lib][uefi] Migrate to boot memory protocol
Image loading protocol is deprecated, migrate
2025-09-18 22:13:33 -07:00
Kelvin Zhang
848fbfefe7 [lib][uefi] Mark bio functions as WEAK
OEMs may want to override certain bio functions, hence mark
`open_block_device` and `open_async_block_device`  as WEAK. This allows
OEMs to customize any of the bio functions
2025-09-18 22:13:33 -07:00
Kelvin Zhang
72c92b5d81 [lib][uefi] Update protocol headers from upstream
Copied from https://cs.android.com/android/kernel/superproject/+/common-android-mainline:bootable/libbootloader/gbl/libefi_types/defs/protocols/
2025-09-17 10:27:49 -07:00
Travis Geiselbrecht
5c1bc61e11 [scripts][do-qemuarm] general cleanup of script style and fix potential bugs
Mostly suggestions from shellcheck
2025-09-16 13:36:20 -07:00
Travis Geiselbrecht
457355fa3c [scripts][do-qemuarm] accept 4k/16k/64k as page size aliases 2025-09-16 13:15:15 -07:00
Yi-Yo Chiang
fb9c37cbd6 [lib][uefi] Implement EFI_ERASE_BLOCK protocol 2025-09-05 13:49:28 -07:00
Yi-Yo Chiang
91a76a9a03 [lib][uefi] Fix -Wc++20-compat compiler warning 2025-09-04 23:27:02 -07:00
Yi-Yo Chiang
b1e26e90cd [lib][uefi] Update UEFI protocol definitions
GBL HEAD: 878653395d
2025-09-04 09:59:22 -07:00
Travis Geiselbrecht
2377c3d440 [make] fix three misuses of TOBOOL
Forgot to expand the variable in the call to the TOBOOL function which
would cause the result to always be true. In this case always resulted
in the test code for these three modules to be included.
2025-09-03 15:14:18 -07:00
Travis Geiselbrecht
9325c18b27 [docs] update the getting started doc to be a bit more clear
Issue: 437
2025-08-31 22:20:05 -07:00
Travis Geiselbrecht
c48cfcb5d0 [arch][arm64] add support for 64k pages
Already worked, just needed to set up the address space size and create
a new project.
2025-08-31 21:48:09 -07:00
Travis Geiselbrecht
fff0f2a740 [arch][arm64] add support for 16k pages 2025-08-31 21:47:32 -07:00
Travis Geiselbrecht
cc9c3a053c [arch][mmu] clean up page size definitions in each arch's defines.h
No real functional change except how the smaller ARCH_DEFAULT_PAGE_SIZE
is now computed and set in defines.h instead of rules.mk for arch/arm to
be consistent with the other arch that has a large/small build (riscv).
2025-08-31 19:16:58 -07:00
Travis Geiselbrecht
0a8a4354a9 [clang-format] first stab at a .clang-format file that matches the existing style
Not enabled by default, but if you want to use this one for now while
things are stabilized feel free. Going to move off astyle since this
seems to be superior now (wasn't always).

Also switched scripts/codestyle to use clang-format
2025-08-31 13:13:21 -07:00
Travis Geiselbrecht
c3a754cf03 [github][ci] bump gcc to 15.2.0 2025-08-31 12:44:36 -07:00
Travis Geiselbrecht
e50948bf06 [dev][virtio-block] fix a printf formatting warning on 32bit
ssize_t is annoying with formatting, since %zd doesn't really know how
to match it, so the usual strategy is to use %ld, since ssize_t is
always defined as a signed long on LK.
2025-08-31 12:41:30 -07:00
Ying-Chun Liu (PaulLiu)
426294d656 [docs] add debug support for GBL doc
Adding a document for how to debug GBL with UEFI debug support protocol.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-28 15:07:12 -07:00
Yi-Yo Chiang
e38bf65034 [lib][uefi] Default implementation of BootService.SetWatchdogTimer()
The platform_watchdog_ methods are optional features that the target
platform can choose to implement.
If they are implemented, then BootService.SetWatchdogTimer() would call
them to setup the hardware watchdog.
If they are not implemented (for example presubmit targets), then
BootService.SetWatchdogTimer() would test the WEAK symbol against a NULL
pointer and error out.

To use BootService.SetWatchdogTimer(), platforms can choose to either
implement platform_watchdog_init and platform_watchdog_set_enabled, or
override the entire BootService.SetWatchdogTimer() method.
2025-08-22 09:21:56 -07:00
Yi-Yo Chiang
7b26b7cf3a [lib][uefi] Stub implementation of BootService.RaiseTpl .RestoreTpl 2025-08-22 09:21:56 -07:00
Kelvin Zhang
2be24ed6e6 [lib][uefi] Fix os loading protocol setup
get_buffer was actually unused, fix
2025-08-15 01:02:55 -04:00
Ying-Chun Liu (PaulLiu)
17dc5cd0aa lib: uefi: runtime_service_provider.cpp: implement Get/SetVariable
GBL debug target will use GetVariable to get a variable called
gbl_debug. If the variable exists, it waits for the gdb to be started.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-14 12:25:36 -04:00
Ying-Chun Liu (PaulLiu)
45d7da5640 lib: uefi: add volatile UEFI variable support
GBL needs to read an UEFI variable called "gbl_debug".
We add 2 commands. "uefi_set_var" to set an UEFI variable. And
"uefi_list_var" to list the UEFI variables.

For GBL, we can use "uefi_set_var gbl_debug 1" to enable its
debug mode.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-14 12:25:36 -04:00
Ying-Chun Liu (PaulLiu)
de3e831eae lib: uefi: add charset converting helper functions.
The UEFI variable names are in UTF-16. We add several helper
functions to convert US-ASCII to UTF-16.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-14 12:25:36 -04:00
Kelvin Zhang
af1f19a2cc [lib][uefi] Add interrupt based async IO support
Add a new API to bio layer(read_async) where function will
return immediately, and a callback function will be called from
interrupt context, when block driver completes the IO request.
2025-08-13 16:13:38 -04:00