Commit Graph

2833 Commits

Author SHA1 Message Date
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
vivek.j
322ff67050 [lib][miniheap] fix: modify the assert condition in miniheap
For LK_DEBUGLEVEL > 1
> alloc_struct_begin_size: 24
> free_heap_chunk_size: 24

size: max(alloc_struct_begin_size, free_heap_chunk_size)

But when freeing the chunk, allocated size is expected to be
greater than size of free_heap_chunk struct.
It contradicts its own code.
So add >= instead of > to maintain the integrity between
allocation and freeing of memory chunk.

Signed-off-by: vivek.j <vivek.j@samsung.com>
2025-04-05 00:25:54 -07:00
Travis Geiselbrecht
8fdadd9b33 [arch][x86] implement basic spinlocks
-This fixes the instability, seems stable on x86-64.
2025-04-01 20:10:18 -07:00
Travis Geiselbrecht
5a520eca3e [arch][x86] start getting inter-processor-interrupts working
-Move the local apic driver to arch/x86
-Add routines to send IPIs between cpus

Something is unstable at the moment and the system crashes after a while
with random corruptions when using SMP.
2025-04-01 00:40:50 -07:00
Travis Geiselbrecht
21ce533327 [platform][pc] make sure lapic is initialized per cpu
Actually boots secondaries to the point where it actually panics because
of missing IPI support.
2025-03-31 01:05:13 -07:00
Travis Geiselbrecht
d05bed3a25 [platform][pc] add local apic timer support
Supports deadline TSC and regular timer support.
Calibrated from the PIT if regular timer support is used.
2025-03-31 00:01:45 -07:00
Travis Geiselbrecht
2987f73d08 [platform][pc] add support for TSC based clock
-Detect if under KVM hypervisor and read tick rate or
-calibrate tick against PIT
2025-03-30 21:59:39 -07:00
Travis Geiselbrecht
09412c194f [platform][pc] refactor existing PIT code into separate file
Extend the PIT driver to allow for one shot timers even though it
monotonically runs a 1kHz tick. This allows it to keep time and provide
one shot events, though only at 1ms resolution.
2025-03-30 14:54:01 -07:00
Arve Hjønnevåg
4ff60704a5 kernel: mutex: Don't allow mutex_acquire with interrupts disabled
Calling mutex_acquire with interrupts disabled is usually unsafe. Add a
debug assert to catch this. Only check this after threading is enabled
on the primary CPU though, as the thread that runs the initial init
hooks run with interrupts disabled and in this case no other thread can
own the mutex anyway. Also allow 0 timeout since
vmm_get_address_description uses this to allow exception handlers to
dump additional information when the vmm_lock is available.

Bug: 304850822
Change-Id: I22c91c48b7853c0b8e0eb8da61cdfc9cd1650ae8
2025-03-29 16:18:55 -07:00