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.
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.
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.
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.
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.
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>
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.