2841 Commits

Author SHA1 Message Date
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
Kelvin Zhang
27696ee6c2 [lib][uefi] Make exit_boot_service weak link
This allows different platforms to provide their own implementation
of exit_boot_service
2025-04-28 17:48:52 -07:00
Travis Geiselbrecht
0ac0911404 [arch][x86] save the translated kernel pgdir physical address
This keeps from needing to recompute it on every context switch back to
the kernel aspace.
2025-04-13 22:43:28 -07:00
Travis Geiselbrecht
a04776ba78 [arch][x86] add a few more feature bits
There's always more feature bits showing up on these things.
Rename a few to match the intel manual closer.
2025-04-11 01:21:12 -07:00
Travis Geiselbrecht
e970a6ea4b [arch][x86-64] remove extra segment register set in start.S 2025-04-10 22:25:38 -07:00
Travis Geiselbrecht
9d66069183 Merge from x86-smp: implement SMP for both 32 and 64bit x86
A large pile of changes to the PC platform and x86 architecture that
facilitate SMP support. Tested in both 64 and 32bit on qemu and real
hardware all the way back through i486.
2025-04-10 22:17:02 -07:00
Heiko Behrens
dd8210d957 atol handles overflow and accepts leading whitespace and '+' 2025-04-10 21:41:06 -07:00
Travis Geiselbrecht
c80efdc4ce [arch][x86] add missing pv.h file added a few commits back 2025-04-10 21:37:35 -07:00
Travis Geiselbrecht
c054ee89c2 [x86][mmu] only write to CR4 if necessary
In legacy builds it's possible to boot on a cpu that doesn't appear to
have CR4 implemented (Am586 to be precise), but there's no features
needed to set, so it seems that this was architecturally okay.
2025-04-10 00:45:41 -07:00
Travis Geiselbrecht
f52ef453fe [tests][mmu] update the file a bit for C++, add another test
Make sure a page appears to be unmapped after it is told to.
2025-04-08 23:49:47 -07:00
Travis Geiselbrecht
bdf62a7e41 [clang-tidy] turn off readability-math-missing-parenthesis
This one is just too annoying for me.
2025-04-08 23:49:47 -07:00
Travis Geiselbrecht
bc01491bc9 [arch][x86][mmu] disable SMAP, add PGE feature
32 and 64 bit:
- For now SMAP causes the mmu unit tests to fail, so disable.
- Make sure CR4.PGE is set if present.
- Make sure the rest of the system knows that user aspaces are available
  on 32bit.
2025-04-08 23:49:47 -07:00
Travis Geiselbrecht
80a08c177d [platform][pc] add a few comments to the top of timer.c 2025-04-08 23:49:37 -07:00
Travis Geiselbrecht
699ec6344e [arch][x86][smp] few misc tweaks
- Skip cpus in the MADT table that are not enabled
- Bump count to 16 cpus
- Move the spurious interrupt vector to 0xff since it needs to end in
  0xf on <=P6.
2025-04-06 22:22:20 -07:00
Travis Geiselbrecht
a8bc048648 [arch][x86] tighten up x86 cpu bootstrap code
- Fix an assert in local apic code when not using x2apic and starting
  secondaries.
- Follow the spec a bit closer and wait up till a second for each
  secondary core to start.
2025-04-06 21:13:06 -07:00
Travis Geiselbrecht
3013662345 [arch][x86] move the KVM clock stuff to arch from platform
One can argue it more logically fits there, and eventually more KVM
features will arrive in this file that have nothing to do with timers.
2025-04-06 19:28:08 -07:00
Travis Geiselbrecht
71e795de19 [arch][x86] get SMP working on x86-32
- Added very basic user page table support (needed to bootstrap the
  secondary cpus)
- Added MP bootup code for 32bit.
2025-04-06 19:09:32 -07:00