- Add a percpu structure for each cpu, akin to x86-64 and riscv. Pointed
to by x18, which is now reserved for this in the kernel. Tweaked
exception and context switch routines to leave x18 alone.
- Remove the cpu-trapping spinlock logic that is unused in mainline,
probably. (Can add a new version of it back if it's necessary).
- Switch fdtwalk helper to using the newer, cleaner way of initializing
secondaries using the PSCI CPU_ON argument that should be pretty
standard on modern implementations. (Possibly an issue with old
firmware).
- Remove the notion of computing the cpu ID from the Affinity levels,
which doesn't really work properly on modern ARM CPUs which more or
less abandoned the logical meaning of AFFn.
- General cleanup of the driver a bit
- Aadd a boot time message that prints the version
- Add the argument field to CPU_ON
- Pass the cpu number through from fdtwalk library
The default printf and family will now not implement FPU support, a
second copy of the routines will be generated with the _float suffix.
ie, printf() has no %f support, but printf_float() does.
This is to avoid the default printf from emitting any floating point
instructions when used within core kernel code which has been an off and
on problem for years, especially on architectures that are eager to use
fpu/vector instructions for regular non-fpu code.
If FPU is not implemented on the arch, the *_float routines will alias
to the integer only one.
Perhaps a much more proper solution is to invert this and require every
caller of printf that cannot tolerate fpu codegen (which in mainline is
most of it) use a _nofloat implementation, but this would touch
pratically all printfs in mainline.
This solution acknowledges that for the most part most of the code in
mainline is in-kernel support code, and doesn't need floating point,
except for perhaps some app/* code, which already can opt in.
This solution also can potentially bloat the size of the binary by
having two complete implementations, though I think in practice the
architectures where the extra few KB of code will matter generally dont
have FPU support, or aren't using it. In the latter case the
link-time-gc should remove unused _float routines.
- X86 cpuid feature list dump was using the wrong array and walking off
the end of one.
- GICv2 code had a left shift by up to 31 of an integer. Needs to be
unsigned.
- PLIC same as GIC code.
- fdtwalker code should be using a bytewise accessor based helper
function for reading large integers out of an unaliged FDT.
- PCI BIOS32 search code could do a 32bit unaligned read of a string,
switch to using memcmp.
Mostly from the use of ssize_t which does not play well with printf and
32bit arches on LK for underlying type reasons that haven't really ever
been sorted out properly.
Mostly dealing with comparing a pointer variable that is declared
nonnull, which I find to be a dubious warning but is pretty safe in this
case since the compiler will be more aggressive about the nullness of
the arguments.
This will cause the system to automatically run all of the unit tests
after a short pause on boot. Will be used by an automatic test script.
At the moment there aren't a lot of unit tests in the list, but this
should greatly increase the utility of them since they'll be
automatically run.
Have the unit tests for the FAT driver fail a bit more gracefully if the
test device is not present, to make it somewhat easier to live with this
driver present with systems a way to mount a test volume.
Most of the functions for this was declared in a top level lk/ include
space, so go ahead and move it there.
A few exceptions:
- Moved spin() over to platform/time.h and platform/time.c since the
function more logically belongs to platform/time.h. Any users of
spin() will need to update their headers to include platform/time.h
instead.
- Renamed spin_cycles() to arm_cm_spin_cycles() and moved over into
arm/cm.h since it is currently defined in arch/arm-m and only used for
targets that implicitly are for arm-m.
OEMs may want to override certain bio functions, hence mark
`open_block_device` and `open_async_block_device` as WEAK. This allows
OEMs to customize any of the bio functions
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.
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.
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>
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>
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>
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.
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.
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>
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>
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>
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>
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).
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.
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
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
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.
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.