Commit Graph

2814 Commits

Author SHA1 Message Date
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
Dmitrii Merkurev
5fa9649ad9 [lib][uefi] initialize uefi system table with zeroes 2025-03-17 17:50:31 -07:00
SP-Melokc
a74f9ebbd8 Update thread.c
Changed kmain to lk_main
2025-02-25 01:08:59 -08:00
Kelvin Zhang
3fb0e31374 [app][uefi] Split memory and block io code into separate files 2025-02-25 01:05:22 -08:00
Kelvin Zhang
c7576472f2 [app][uefi] refactor relocation logic to a separate file 2025-02-25 01:05:22 -08:00
Travis Geiselbrecht
3543217461 [lib][uefi] fix a few warnings and a little code tidying
GCC 14 is quite picky about warnings, probably more so than clang.

-Fix a bunch of printf warnings. Pointers should be printed with %p.
-Move some stuff into an anonymous namespace.
-Worked around GCC really not liking reinterpret_casting from one
function pointer type to another. Fiddled with it a bit and eventually
settled on casting the function pointer to const void * and passing it
through.
2025-01-20 01:46:21 -08:00
Travis Geiselbrecht
7fff3510a3 [scripts][buildall] hard set WERROR=0 if -e not passed
This allows it to override the WERROR setting if, say, someone put
WERROR?=1 in their local.mk. (It's a good idea)

Note: I can't really leave WERROR enabled in the default build because
of all of the variants of compilers folks use in the wild, but I do
highly suggest folks use it locally.
2025-01-11 17:24:51 -08:00
Travis Geiselbrecht
6747010a5c [arch][arm64] restructure some start.S to allow KERNEL_VM and WITH_SMP
Currently only supports both set at the same time, but rearrange their
order such that theoretically both are pretty independent.

Somewhat untested in that there's no configuration for !KERNEL_VM and
WITH_SMP, but at least allows that config to be tested.
2025-01-11 17:12:16 -08:00
Travis Geiselbrecht
538f32e09d [arch][arm64] make sure SPSel is set to SP_ELx at boot
Just a safety check, has not been a problem in general, but pulled from
a similar trusty change.
2025-01-11 17:11:27 -08:00
Travis Geiselbrecht
0ac7a2d7cb [kernel][mp] use proper types when computing idle and active cpus
Also return a proper bool instead of an int. No functional change.
2025-01-11 16:59:42 -08:00
Travis Geiselbrecht
6d9a0b5c35 [libc][printf] Handle case where snprintf underflows for len = 0
The code would write a null pointer always, even if len = 0, or if the
buffer pointer is null.

Test for this condition and add a unit test.

fixes #407
2025-01-09 23:32:56 -08:00
Alexander Richardson
e7b71623c4 Document how to use clang in README
Fixes: https://github.com/littlekernel/lk/issues/426
2025-01-09 19:52:18 -08:00
Travis Geiselbrecht
f9a5a16db5 Merge pull request #429 from zhangxp1998/gbl
Add block IO protocol to UEFI loader
2025-01-09 19:49:49 -08:00
Kelvin Zhang
5c066ae52c [app][uefi] Implement GLB fdt fixiup protocol 2025-01-08 09:54:00 -08:00
Kelvin Zhang
0c1cb6bf03 [app][uefi] Add block device protocol 2025-01-08 09:54:00 -08:00
Kelvin Zhang
1103fd5575 [app][uefi] Pass DTB to linux kernel 2025-01-08 09:53:59 -08:00
Alex Richardson
0fd355ea4b dlmalloc: fix -Wstrict-prototypes warning 2025-01-07 22:28:07 -08:00
Alex Richardson
d22534704d pci: remove write-only variable
This is not used anywhere so just drop it.
2025-01-07 22:28:07 -08:00
Alex Richardson
d673d211eb riscv: add missing stdint.h include
While this is currently pulled in transitively, uint32_t is defined there
and we should explicitly include the appropriate header.
2025-01-07 22:28:07 -08:00
Alex Richardson
22ae6b6cea riscv: ensure arguments to __ASM_STR() are expanded first
Right now this does not cause any issues, but I had a local change where
missing expansion resulted in compilation errors when reading CSRs.
2025-01-07 22:28:07 -08:00