Commit Graph

2753 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
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
Kelvin Zhang
e8cea74e9b [lib][uefi] Implement events API in UEFI
LK already has events APIs. To support events protocols in UEFI spec,
I created a wrapper object for LK events. This wrapper object keeps
additional data that are necessary to support UEFI events spec:

* Notification function, or callbacks
* Argument for the notification function
* Type of this UEFI event (which specifies when the callback should be
  called)

The events API is essential for supporting async I/O in UEFI. Intended
use case looks like:

* UEFI app creates an event object, attatch callback to this event
* UEFI app calls LK for asynchronous read/write on a block device, with
  the newly created events object
* LK executes IO operation in background, after IO finishes, signal the
  specified event object
* UEFI's callback gets executed
2025-07-16 14:00:00 -07:00
Kelvin Zhang
2ff6ab3920 [lib][uefi] Implement os loading buffer protocol 2025-07-16 14:00:00 -07:00
Kelvin Zhang
953b519d69 [lib][uefi] Update os configuration protocol
Two breaking changes:

* fixup_kernel_commandline was removed by upstream
* GblEfiDeviceTreeMetadata's reserve field is removed, instead a `type`
  variable is inserted earlier in the struct.

Both changes come from upstream GBL, update LK accordingly
2025-07-16 13:59:59 -07:00
Kelvin Zhang
62409f55f6 [lib][uefi] Add error checking to certain functions 2025-07-16 13:59:59 -07:00
Matt Schulte
e51cf68c3c [lib][libc] Make errno thread safe using TLS APIs
Before this change, errno was "completely un-threadsafe" as the comment
states.

This changes errno to be threadsafe by making errno a thread local
variable.
2025-07-10 15:37:43 -07:00
Travis Geiselbrecht
2d567e437d [kernel][vm] remove default KERNEL_ASPACE_BASE definition
Require the platform or arch to provide it. The default was pretty
obsolete, assuming a 32bit arch with a split 50/50 mapping. May as well
make it a forced arch thing so that it's known to be correct.

Had to define it for OR1K, it was already defined for all the other
(known) architectures.
2025-07-09 23:55:13 -07:00
Travis Geiselbrecht
ac65ad8429 [github][actions] dont run actions for branches under wip/ path 2025-07-09 23:42:36 -07:00
Travis Geiselbrecht
07eb425744 [github][copilot] add an instructions.md file
Unclear if this is doing any good, but the copilot agent does seem to
read it in.
2025-07-09 23:42:26 -07:00
Chieh-Min Wang
816be268be [console] support background command execution
Launch a thread to execute commands when the last argument is ampersand

Signed-off-by: Chieh-Min Wang <cmwang@google.com>
2025-07-09 23:12:51 -07:00
Travis Geiselbrecht
f70a9031ac [vscode][workspace] remove build-* from the workspace
This might cause problems if trying to find config.h or whatnot, so may
end up rolling it back.
2025-07-09 22:09:45 -07:00
Travis Geiselbrecht
22fee46d6d [kernel][includes] clean up and add more commentary to the kernel API
-In a few places, rearrange some of the fields of some structures to
pack more nicely in 64bit environments.
-Convert C style comments to C++ style

No functional difference.
2025-07-09 22:09:32 -07:00
Travis Geiselbrecht
73d29b0860 [lib][libc] don't compile the floating point tests if there's no FPU 2025-06-10 23:57:05 -07:00
Travis Geiselbrecht
2865ab6813 [lib][libc][tests] switch floating point test vector to a constructor
This should avoid a problem with older compilers that do not support non
trivial designated initializers.
2025-06-10 23:37:51 -07:00
Travis Geiselbrecht
c1166cf534 [app][tests] add test vectors to the floating point test 2025-06-10 23:30:11 -07:00
Travis Geiselbrecht
37abbeb6db [arch][x86] remove lazy fpu save
For newer SMP and modern cpus, just doing a full fpu context switch
is simpler and cheaper than dealing with the complexity of lazy fpu
context switch logic.

Plus this old logic was broken in the recent SMP-ification of the x86
code base. A functional version of this would be far more complex.
2025-06-10 23:10:45 -07:00
Travis Geiselbrecht
03bc415b2b [lib][libc] a few little style tweaks in the printf code
No functional change.
2025-06-10 23:10:45 -07:00
Travis Geiselbrecht
c8f011a159 [lib][libc][tests] move the floating point printf test to libc unittests
Complete moving the rest of the previously manual printf tests out of
app/tests and into lib/libc/test as a proper unit test.
2025-06-10 23:10:45 -07:00
Travis Geiselbrecht
433b02ce10 [lib][libc] move all the printf routines into printf.c
Some of the wrapper routines (printf, fprintf, etc) were defined in
stdio.c which is not necessarily compiled with the same compiler flags
concerning floating point support.

On some architectures (arm64, x86-64) this caused the wrapper routines
to clobber the floating point registers prior to getting into the
printf_engine.
2025-06-10 23:10:45 -07:00
Travis Geiselbrecht
aafeda6b86 [github][ci][clang] add clang 19 to the list 2025-06-03 22:33:00 -07:00
Kelvin Zhang
97e2d701b7 [ci][github] Increase test timeout to 5s
It was found that QEMU process is often under D(Disk Sleep) state
after test fails due to timeout. This suggests that I/O is sometimes
extremely slow on github CI server. Hence increase test timeout to
5s for reliability.
2025-06-03 22:17:22 -07:00
Kelvin Zhang
a7addca7bc [ci][github] Check QEMU process state before exiting
This helps understand what the QEMU process is doing when test
fails due to timeout
2025-06-03 22:17:22 -07:00
Kelvin Zhang
32429c6c11 [lib][uefi] Allow complete platform customization for UEFI
Added platform_setup_system_table, where platform/vendor can
make arbitrary changes to UEFI's system table, overriding
any of the UEFI protocols with custom one.
2025-06-03 22:17:22 -07:00
Kelvin Zhang
b8a584b69a [lib][uefi] Move certain UEFI headers to public include dir
This allows other components to reference basic UEFI types. Now
different platforms can provide their own override for certain UEFI
protocols.

To keep good include structure, all public headers are put under
include/uefi.
2025-06-03 22:17:22 -07:00
Kelvin Zhang
b10701feaa [lib][uefi] Make load_pe_file extern linkage
This function was previously put in anon namespace, making it
unavailable for other source files to consume. Since we made this
function an API for consumption, move outside anon namespace so
that linkers can find it.
2025-05-28 16:04:10 -07:00
Kelvin Zhang
91a65fd20d [ci][github] Fix CI stability
* Sometimes apt-get install qemu fails with fetch error, run apt-get
update first to mitigate
* unittest.py often fails due to app shell not started in 0.5s, increase
  timeout
2025-05-28 16:04:10 -07:00
Travis Geiselbrecht
15e3cca123 Merge pull request #444 from toor1245/fvp-base
Add FVP Base support
2025-05-06 23:55:41 -07:00
Michael Bishop
d66ad44db3 bio: use shifts to divide 2025-05-06 23:40:25 -07:00
Travis Geiselbrecht
50e86cb141 Merge pull request #443
Implement 2 missing UEFI protocols
2025-05-06 23:36:48 -07:00
Travis Geiselbrecht
e31b1ee768 [arch][m68k] make sure move %sp, <reg> doesn't use the 'a' registers
This particular instruction format doesn't take plain a registers, but
takes d and the rest of the <ea> formats.
2025-05-06 23:26:10 -07:00
Mykola Hohsadze
ae64e6aa3c Fix typos 2025-05-05 02:45:08 +03:00
Mykola Hohsadze
a3660b8fb4 Add FVP Base platform 2025-05-04 20:58:02 +03:00
Mykola Hohsadze
cc940333d6 Add FVP Base docs 2025-05-04 20:57:23 +03:00
Kelvin Zhang
55e2d6f2aa [lib][uefi] Move platform dependent functions to a separate file 2025-04-29 14:17:10 -07:00
Kelvin Zhang
9b5a187952 Put functions in anon namespace if possible 2025-04-28 17:53:55 -07:00
Kelvin Zhang
5ee4e35921 [lib][uefi] Allow load_pe_file to be called from other apps/libs 2025-04-28 17:48:52 -07:00
Kelvin Zhang
fbc354e7e3 [lib][uefi] Implement ResetSystem protocol 2025-04-28 17:48:52 -07:00