Commit Graph

2789 Commits

Author SHA1 Message Date
Travis Geiselbrecht
b433d4582d [arch][m68k] careful of PC relative addressing on 68000 and 68010
These cpus only support a simple 16 bit offset from PC, so cannot use it
in start.S to compute a large offset. This is okay, because the code
that needs it is only for cpus with an MMU, which these dont have.
2025-09-22 21:52:48 -07:00
Travis Geiselbrecht
bb5db64b4c [arch][m68k] add arch_mmu_query so the kernel boots completely
Side effect of editing: reformat all of the code in
platform/qemu-virt-m68k
2025-09-22 21:52:48 -07:00
Travis Geiselbrecht
6c7e6a1796 [arch][m68k] start to enable the VM on m68k
-Wire up the make plumbing for setting the kernel vm bits
-Implement stubbed out arch_mmu routines.
-Set up a high mapping in start.S that should be compatible with the mmu
code.
2025-09-22 21:52:48 -07:00
Travis Geiselbrecht
5926fb1cc8 [arch][m68k] Initial support for 68040 mmu
Currently just sets up most of an identity map and some test mappings.
Not fully wired up to the VM yet.
2025-09-07 16:23:16 -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
Ying-Chun Liu (PaulLiu)
cfeef533d1 lib: uefi: debug_support.cpp: fix code-style of teardown_debug_support()
This commit refactors teardown_debug_support() to make the code
looks simpler.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-11 14:19:55 -04:00
Kelvin Zhang
22b808b6ec [lib][uefi] Fix LTRACEF logging
LTRACEF already outputs function name, no need to do it again
2025-08-08 16:13:30 -04:00
Kelvin Zhang
0f15dc23bc [lib][uefi] Move several memory APIs to uefi_platform.cpp
This allows OEMs to customize exactly how their memories are allocated.
For examples, OEMs might want to allocate certain parts of the UEFI
from high address kernel space, for ease of access in LK world.
Since UEFI spec requires everything to be identity mapped, the default
implementation of memory allocation is identity mapped.
2025-08-08 03:06:05 -04:00
Ying-Chun Liu (PaulLiu)
c5612330cc lib: uefi: add EfiDebugImageInfo for debug
This commit adds the functionality of generate EfiDebugImageInfo
while loading the image.

This feature is described in UEFI Spec 2.10. Section 18.4.3.
The implementation ensures support for hardware-assisted debugging and
provides a standardized mechanism for debuggers to discover the load
address of an EFI application.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-06 03:19:47 -04:00
Ying-Chun Liu (PaulLiu)
1ffb54dace lib: uefi: add EfiDebugImageInfoTable for debug
EfiDebugImageInfoTable is used to store EfiLoadedImage for
debug purpose. This commit adds the table to the EfiConfigurationTable.

This feature is described in UEFI Spec version 2.10. Section 18.4.
The implementation ensures support for hardware-assisted debugging and
provides a standardized mechanism for debuggers to discover and interact
with system-level debug resources.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-06 03:19:47 -04:00
Ying-Chun Liu (PaulLiu)
ea327d7242 lib: uefi: add EfiSystemTablePointer for debug
Add EfiSystemTablePointer structure for remote debugger to locate
the address of EfiSystemTable.

This feature is described in UEFI SPEC version 2.10. Section 18.4.2.
The implementation ensures support for hardware-assisted debugging and
provides a standardized mechanism for debuggers to discover the EFI
system table.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-06 03:19:47 -04:00
Ying-Chun Liu (PaulLiu)
777297f156 lib: uefi: uefi.cpp: set vendor string of SystemTable
Setting the vendor string makes us easier for testing the
SystemTablePointer. When we discover SystemTable we can check
if the vendor string is set with proper value.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-06 03:19:47 -04:00
Ying-Chun Liu (PaulLiu)
7c23aac677 lib: uefi: boot_service_provider.cpp: implement Stall call
We implement a Stall call for easier testing with Rust UEFI application.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
Link: https://rust-osdev.github.io/uefi-rs/tutorial/app.html
2025-08-06 03:19:47 -04:00
Kelvin Zhang
07f5cdf370 [lib][uefi] Make UEFI API signal_event usable in interrupt context
This is to prepare events API for interrupt based async block I/O,
in which case UEFI events will be signaled from block driver callback(in
in interrupt context).
2025-08-05 14:21:57 -04:00
Kelvin Zhang
9bbfeabb9d [lib][uefi] Free memory used by UEFI app after app returns 2025-08-05 14:21:57 -04:00
Kelvin Zhang
ed656a3993 [ci][github] Disable buffering on subprocess output
Testing script works by reading output of subprocess and checking if
output matches expectation. To ensure that we can see output in timely
fashion, disable buffering.
2025-08-05 03:52:06 -04:00
Yi-Yo Chiang
6ae7086222 [lib][uefi] Add GBL protocol definitions
GBL HEAD: aosp/I28a1926447e54401d9678c40a98957d558125ced
2025-08-05 03:51:19 -04:00
Yi-Yo Chiang
3460cd6c2d [lib][uefi] Implement EFI_TIMESTAMP_PROTOCOL
Reads the ARM64-specific counter registers.
This only works on ARM64 platform obviously, which is the only platform
we support for UEFI at the moment.
2025-07-30 00:11:49 -04:00
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
Travis Geiselbrecht
5cd783b831 [github][action] skip building if docs/ or only .md files are touched
[skip ci]
2025-07-29 00:30:28 -07:00
Travis Geiselbrecht
17cef2e44d [github][gcc] bump the gcc version to 15.1.0 2025-07-29 00:08:55 -07:00
Travis Geiselbrecht
bab69228bd [lib][libc] clear errno in the thread TLS
When creating new thread, the TLS entries are copied from the parent
thread, but zero out errno so it defaults to 0.
2025-07-28 23:54:07 -07:00
Matt Schulte
00b6ca080e Reset errno values where read
According to `man 3 errno`:

```
The value of errno is never set to zero by any system
call or library function.
```

So we must set it to 0 ourselves before each `read` and `write` call to
ensure we don't get stuck in an error loop.
2025-07-28 12:48:11 -07:00
Travis Geiselbrecht
4dd3bbd2f1 [lib][uefi] Merge pull request #452 from zhangxp1998/master
Support os_loading protocol and async io protocol
2025-07-28 12:39:52 -07:00
Kelvin Zhang
f356261b67 [lib][uefi] Allow identity mapped pages to be free'ed
Since UEFI requires app to be run in physical address space,
we allocate memory that are identity mapped. Previous identity
mapping works as follows:

1. call vmm_alloc_contigious to obtain a VA1(virtual address) mapping to
   PA1(physical address)
2. Use arch_mmu_query to obtain PA1 from VA1
3. arch_mmu_unmap VA1 <-> PA1
4. arch_mmu_map PA1 <-> PA1

Now we can return PA1 as a valid virtual address pointer, which is
mapped to physical memory. However, this has problems. LK allocates a
vmm_region_t struct for each call to vmm_alloc_* . This struct can
never be free'ed, as the associated virtual address VA1 is forever
lost. We can't even free PA1, as PA1 is not a valid argument to
vmm_free(PA1 does not have associated vmm_region_t struct).

The new approach uses pmm_alloc and vmm_reserve_space, allowing
vmm_free_region to be called.
2025-07-23 10:46:42 -07:00
Kelvin Zhang
f7d8f58cdc [lib][uefi] Support async blockio 2025-07-23 10:46:42 -07:00
Travis Geiselbrecht
3581b14b06 [github-action] try to build by architecture instead of project list
This should cut down on the number of github builders, but having only
one per arch per toolchain per debug per ubsan. Still a lot, but working
on it.

Also means it automatically builds every project in the tree, instead of
just the curated list.
2025-07-18 22:22:17 -07:00
Travis Geiselbrecht
be52909f49 [make][buildall] add ability to filter buildall by architecture
Clean up make targets list-arch and list-toolchain to be much faster and
work without needing to invoke the archtecture's arch rules.mk. This
should make it work on machines that do not have that particular
toolchain in the path.

This is setting up for using it in the github action script.
2025-07-18 21:51:50 -07:00
Travis Geiselbrecht
50dc95b85e [scripts][buildall] print if building with WERROR or not
General cleanup of script based on vscode suggestions.
2025-07-18 20:57:07 -07:00
Travis Geiselbrecht
731ea62c38 [includes] remove lk/utils.h which seem to be unused on anything in mainline
Was a bit of a hodgepodge of defines. If any of these are needed we can
add them back somewhere a bit more appropriate.

ARRAY_SIZE can use countof() defined in compiler.h

KB/MB/GB are generally duplicately defined in architecture specific
files, but not generically. I couldn't think off the top of my head of a
better place to generically put these, especially since they're used in
asm files, so just deleted it for now.

The other stuff seemed to be just unused anywhere.
2025-07-18 20:25:02 -07:00
Travis Geiselbrecht
28ae26f7be [init] pack the lk init structures a little tighter by making the levels uint16_t
Should save 4 bytes per init level on 32bit architectures, though for
64bit it'll almost certainly just pad it out to the same size as before.
2025-07-18 20:16:38 -07:00
Kelvin Zhang
76ce54625a [lib][uefi] Support 5 arguments for switch stack call
Some functions have >4 arguments, bump support to 5 arguments
2025-07-16 14:00:00 -07:00