diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0d8a8fb38..682fba3ea 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -14,19 +14,25 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
- submodules: trues
+ submodules: true
- name: Install build dependencies
run: |
sudo apt-get update
- sudo apt-get install -y build-essential qemu-system-x86 mtools iasl
-
- - name: Setup PatchworkOS
- run: make setup DEBUG=1 TESTING=1 QEMU_EXIT_ON_PANIC=1
+ sudo apt-get install -y clang llvm build-essential qemu-system-x86 mtools iasl
- name: Build PatchworkOS
run: make all DEBUG=1 TESTING=1 QEMU_EXIT_ON_PANIC=1
+ - name: Inspect kernel ELF
+ run: |
+ echo "=== Kernel ELF Program Headers ==="
+ readelf -l bin/kernel/kernel || true
+ echo "=== Kernel ELF Section Headers ==="
+ readelf -S bin/kernel/kernel || true
+ echo "=== Kernel file size ==="
+ ls -la bin/kernel/kernel
+
- name: Verify PatchworkOS.img exists
run: |
if [ ! -f bin/PatchworkOS.img ]; then
@@ -34,10 +40,10 @@ jobs:
exit 1
fi
- - name: Run PatchworkOS with QEMU (test launch and graceful timeout)
+ - name: Run PatchworkOS with QEMU
id: qemu_test
- run: | # We use this cheap trick to check if qemu runs properly, the idea is that we start qemu, and let it run for one minute and it does not crash thats considered a success, if it crashes, well thats bad. If it doesent we shut it down and call it a success, a bit simple but gets the job done.
- setsid make run DEBUG=1 TESTING=1 QEMU_EXIT_ON_PANIC=1 &
+ run: |
+ setsid make run DEBUG=1 TESTING=1 QEMU_EXIT_ON_PANIC=1 QEMU_NOGRAPHIC=1 &
QEMU_PID=$!
echo "QEMU process started with PID=$QEMU_PID"
echo "QEMU_PID=$QEMU_PID" >> $GITHUB_OUTPUT
diff --git a/.gitignore b/.gitignore
index df06ef7c9..0962e232a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,5 +69,6 @@ include/kernel/version.h
lib/acpica
lib/acpica_tests
lib/argon2
+lib/gnu-efi
include/argon2
temp.md
diff --git a/Make.defaults b/Make.defaults
index 9d7b9c80b..d778115b1 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -3,14 +3,16 @@ MKCWD = @mkdir -p $(@D)
CC = gcc
AS = gcc
LD = gcc
-AR = gcc-ar
+AR = ar
OBJCOPY = objcopy
-
CFLAGS := \
-std=gnu11 \
-ffreestanding \
-fno-builtin \
+ -march=x86-64 \
-fno-pie \
+ -fno-stack-protector \
+ -fcf-protection=none \
-mno-red-zone \
-nostdinc \
-Wall \
@@ -36,7 +38,8 @@ CFLAGS_DISABLE_SIMD := \
-mno-mmx -mno-3dnow \
-mno-80387 -mno-sse \
-mno-sse2 -mno-sse3 \
- -mno-ssse3 -mno-sse4
+ -mno-ssse3 -mno-sse4 \
+ -mno-avx -mno-avx2
ASFLAGS := \
-nostdinc \
@@ -51,7 +54,9 @@ LDFLAGS := \
-nostdlib \
-Lbin/libstd \
-Lbin/libpatchwork \
- -no-pie
+ -z noexecstack \
+ -Wno-unused-command-line-argument \
+ -no-pie
ifeq ($(TESTING),1)
CFLAGS += -D_TESTING_
@@ -61,10 +66,8 @@ endif
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g3 -ggdb -fno-omit-frame-pointer -fno-inline
LDFLAGS += -g
- DEBUG_LDFLAGS = -g
else
CFLAGS += -O2 -DNDEBUG
- DEBUG_LDFLAGS =
endif
ifeq ($(NOSTDLIB),1)
diff --git a/Make.rules b/Make.rules
index 9a5e3c4ea..d27ee065d 100644
--- a/Make.rules
+++ b/Make.rules
@@ -16,40 +16,4 @@ $(BINDIR)/%.a: $(OBJ)
$(BINDIR)/%: $(OBJ)
$(MKCWD)
@echo " LD $@"
- @$(LD) -o $@ $^ $(LDFLAGS) $(LDSTDLIB)
-
-$(BINDIR)/%.efi: $(OBJ)
- $(MKCWD)
- @echo " LD $@ (EFI)"
- @gcc -shared -nostdlib -nostartfiles -fPIC -fno-stack-protector \
- $(DEBUG_LDFLAGS) \
- -Wl,-shared,-Bsymbolic \
- -Wl,-T,lib/gnu-efi/gnuefi/elf_x86_64_efi.lds \
- -Llib/gnu-efi/x86_64/lib \
- -Llib/gnu-efi/x86_64/gnuefi \
- lib/gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o $^ \
- -o $(BINDIR)/temp.so \
- -lgnuefi -lefi
-
-ifeq ($(DEBUG),1)
- @echo " OBJCOPY $@ (with debug symbols)"
- @$(OBJCOPY) --only-keep-debug $(BINDIR)/temp.so $(BINDIR)/$*.debug
- @$(OBJCOPY) \
- -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
- -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .eh_frame \
- --target efi-app-x86_64 \
- --subsystem=10 \
- --add-gnu-debuglink=$(BINDIR)/$*.debug \
- $(BINDIR)/temp.so $@
- @$(OBJCOPY) --strip-debug $@
-else
- @echo " OBJCOPY $@"
- @$(OBJCOPY) \
- -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
- -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .eh_frame \
- --target efi-app-x86_64 \
- --subsystem=10 \
- $(BINDIR)/temp.so $@
-endif
-
- @rm -f $(BINDIR)/temp.so
\ No newline at end of file
+ @$(LD) -o $@ $^ $(LDFLAGS) $(LDSTDLIB)
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 6852ad4f7..563da555f 100644
--- a/Makefile
+++ b/Makefile
@@ -90,7 +90,11 @@ $(VERSION_HEADER): .FORCE | include/kernel
include/kernel:
@mkdir -p $@
-lib/gnu-efi/.built: | lib/gnu-efi
+lib/gnu-efi/.built:
+ @if [ ! -d "lib/gnu-efi" ]; then \
+ echo "CLONE gnu-efi"; \
+ git clone https://github.com/ncroxon/gnu-efi.git lib/gnu-efi >/dev/null 2>&1; \
+ fi
@echo "BUILD gnu-efi"
@$(MAKE) -C lib/gnu-efi >/dev/null 2>&1
@touch $@
@@ -248,9 +252,7 @@ clean_programs:
nuke: clean
@echo "NUKE all"
- @$(MAKE) -C lib/gnu-efi clean 2>/dev/null || true
- @rm -rf lib/doomgeneric-patchworkos lib/lua-5.4.7 lib/acpica lib/acpica_tests lib/argon2 include/argon2 meta/docs
- @rm -rf lib/gnu-efi/.built lib/argon2/.built lib/acpica_tests/.built
+ @rm -rf lib/doomgeneric lib/lua lib/acpica lib/acpica_tests lib/argon2 include/argon2 meta/docs lib/gnu-efi
QEMU_MEMORY ?= 2G
QEMU_CPUS ?= $(shell nproc 2>/dev/null || echo 8)
@@ -259,8 +261,6 @@ QEMU_ARGS ?=
QEMU_FLAGS = \
-M $(QEMU_MACHINE) \
- -display sdl \
- -serial stdio \
-drive format=raw,file=$(IMAGE) \
-m $(QEMU_MEMORY) \
-smp $(QEMU_CPUS) \
@@ -268,6 +268,12 @@ QEMU_FLAGS = \
-drive if=pflash,format=raw,unit=0,file=lib/OVMFbin/OVMF_CODE-pure-efi.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=lib/OVMFbin/OVMF_VARS-pure-efi.fd
+ifeq ($(QEMU_NOGRAPHIC),1)
+QEMU_FLAGS += -nographic
+else
+QEMU_FLAGS += -display sdl -serial stdio
+endif
+
ifeq ($(DEBUG),1)
else
QEMU_FLAGS += -no-shutdown -no-reboot
diff --git a/README.md b/README.md
index cdf90a860..c53f961eb 100644
--- a/README.md
+++ b/README.md
@@ -24,9 +24,9 @@
-**PatchworkOS** is a modular non-POSIX operating system for the x86_64 architecture that rigorously follows an "everything is a file" philosophy, in the style of Plan9. Built from scratch in C and assembly, it's intended to be an educational and experimental operating system.
+**PatchworkOS** is a modular non-POSIX operating system for the x86_64 architecture that rigorously follows an "everything is a file" philosophy. Built from scratch in C and assembly.
-While primarily a project made for fun, the goal is still to make a "real" operating system, one that runs on real hardware and has the performance one would expect from a modern operating system without jumping ahead to user space features or drivers, a floppy disk driver and a round-robin scheduler are not enough.
+While primarily a project made for fun, the goal is still to make a "real" operating system, one that runs on real hardware and has the performance one would expect from a modern operating system without jumping ahead to user space features or drivers, a floppy disk driver with a round-robin scheduler is not enough.
PatchworkOS is not a UNIX clone, it's intended to be a (hopefully) interesting experiment in operating system design by attempting to use unique algorithms and designs over tried and tested ones. Sometimes this leads to bad results, and sometimes, with a bit of luck, good ones.
@@ -55,7 +55,7 @@ Will this project ever reach its goals? Probably not, but that's not the point.
- Preemptive and tickless [EEVDF scheduler](https://kainorberg.github.io/PatchworkOS/html/d7/d85/group__kernel__sched.html) based upon the [original paper](https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=805acf7726282721504c8f00575d91ebfd750564) and implemented using an [Augmented Red-Black tree](https://kainorberg.github.io/PatchworkOS/html/da/d90/group__kernel__utils__rbtree.html) to achieve `O(log n)` worst case complexity. EEVDF is the same algorithm used in the modern Linux kernel, but ours is obviously **a lot** less mature.
- Multithreading and Symmetric Multi Processing with fine-grained locking.
-- Physical and virtual memory management is `O(1)` per page and `O(n)` where `n` is the number of pages per allocation/mapping operation, see [benchmarks](#benchmarks) for more info.
+- Optimized memory management, featuring object caching and `O(1)` per page physical and virtual memory managers. See [benchmarks](#benchmarks) for more info.
- File based IPC including [pipes](https://kainorberg.github.io/PatchworkOS/html/d7/d64/group__modules__ipc__pipe.html), [shared memory](https://kainorberg.github.io/PatchworkOS/html/df/d3f/group__modules__ipc__shmem.html), [sockets](https://kainorberg.github.io/PatchworkOS/html/d4/db0/group__kernel__fs__netfs.html) and Plan9 inspired "signals" called [notes](https://kainorberg.github.io/PatchworkOS/html/d8/db1/group__kernel__ipc__note.html).
- File based device API [abstractions](https://kainorberg.github.io/PatchworkOS/html/de/d7b/group__kernel__drivers__abstract.html), including framebuffers, input devices, etc.
- [Synchronization primitives](https://kainorberg.github.io/PatchworkOS/html/dd/d6b/group__kernel__sync.html) including Read-Copy-Update, mutexes, R/W locks, sequential locks, futexes and others.
@@ -92,6 +92,24 @@ Will this project ever reach its goals? Probably not, but that's not the point.
- Fully Asynchronous I/O and syscalls (io_uring?).
- USB support.
+## Setup
+
+```bash
+# Install dependencies
+sudo dnf install gcc make mtools qemu-system-x86 # For Fedora
+sudo apt install build-essential mtools qemu-system-x86 # For Debian/Ubuntu
+
+# Clone this repository, you can also use the green Code button at the top of the Github.
+git clone https://github.com/KaiNorberg/PatchworkOS
+cd PatchworkOS
+
+# Build (creates PatchworkOS.img in bin/)
+make all
+
+# Run using QEMU
+make run
+```
+
---
## Doxygen Documentation
@@ -635,7 +653,9 @@ The scheduler has not yet been properly benchmarked. However, testing using the
## Shell Utilities
-PatchworkOS includes its own shell utilities designed around its [file flags](#file-flags) system, when file flags are used we also demonstrate the short form. Included is a brief overview with some usage examples. For convenience the shell utilities are named after their POSIX counterparts, however they are not drop-in replacements.
+PatchworkOS includes its own shell utilities designed around its [file flags](#file-flags) system, allowing all shell utilities to be "dumb" and rely on the virtual file system to provide more complex behavior.
+
+Included is a brief overview with some usage examples. For convenience the shell utilities are named after their POSIX counterparts, however they are not drop-in replacements. When file flags are used we also demonstrate the short form.
### touch
@@ -734,28 +754,7 @@ There are other utils available that work as expected, for example `symlink` and
---
-## Setup
-
-### Requirements
-
-| Requirement | Details |
-|:------------|:--------|
-| **OS** | Linux (WSL might work, but I make no guarantees) |
-| **Tools** | GCC, make, mtools, QEMU (optional) |
-
-### Build and Run
-
-```bash
-# Clone this repository, you can also use the green Code button at the top of the Github.
-git clone https://github.com/KaiNorberg/PatchworkOS
-cd PatchworkOS
-
-# Build (creates PatchworkOS.img in bin/)
-make all
-
-# Run using QEMU
-make run
-```
+## Development
### Additional commands
@@ -855,6 +854,10 @@ If you are unsure where to start, check the [Todo List](https://kainorberg.githu
Check out the [contribution guidelines](CONTRIBUTING.md) to get started.
+## License
+
+Distributed under the MIT License. See [LICENSE](https://github.com/KaiNorberg/PatchworkOS/blob/main/LICENSE) for more information.
+
## Nostalgia
[The first Reddit post and image of PatchworkOS](https://www.reddit.com/r/osdev/comments/18gbsng/a_little_over_2_years_ago_i_posted_a_screenshot/) from back when getting to user space was a massive milestone and the kernel was supposed to be a UNIX-like microkernel.
diff --git a/include/boot/boot_info.h b/include/boot/boot_info.h
index 170af37c7..c441495cf 100644
--- a/include/boot/boot_info.h
+++ b/include/boot/boot_info.h
@@ -3,11 +3,11 @@
#include
#include
-#include
+#include <_internal/MAX_NAME.h>
#include
+#include
#include
-#include
#include
/**
@@ -21,7 +21,7 @@
* @{
*/
-static bool boot_is_mem_ram(EFI_MEMORY_TYPE type)
+static UNUSED_FUNC bool boot_is_mem_ram(EFI_MEMORY_TYPE type)
{
switch (type)
{
diff --git a/include/kernel/cpu/cli.h b/include/kernel/cpu/cli.h
index 7fd29cbbb..ecc567a05 100644
--- a/include/kernel/cpu/cli.h
+++ b/include/kernel/cpu/cli.h
@@ -24,7 +24,7 @@
static inline void cli_push(void)
{
uint64_t rflags = rflags_read();
- asm volatile("cli" ::: "memory");
+ ASM("cli" :: : "memory");
if (SELF->cli == 0)
{
@@ -46,7 +46,7 @@ static inline void cli_pop(void)
SELF->cli--;
if (SELF->cli == 0 && (SELF->oldRflags & RFLAGS_INTERRUPT_ENABLE))
{
- asm volatile("sti" ::: "memory");
+ ASM("sti" :: : "memory");
}
}
diff --git a/include/kernel/cpu/cpu.h b/include/kernel/cpu/cpu.h
index c177053ae..857904c6a 100644
--- a/include/kernel/cpu/cpu.h
+++ b/include/kernel/cpu/cpu.h
@@ -2,7 +2,6 @@
#ifndef __ASSEMBLER__
#include
-#include
#include
#include
@@ -38,6 +37,33 @@ typedef struct cpu cpu_t;
#ifndef __ASSEMBLER__
+/**
+ * @brief The offset of the `id` member in the `cpu_t` structure.
+ *
+ * Needed to access the CPU ID from assembly code.
+ */
+#define CPU_OFFSET_ID 0x8
+
+/**
+ * @brief Maximum number of CPUs supported.
+ */
+#define CPU_MAX UINT8_MAX
+
+/**
+ * @brief ID of the bootstrap CPU.
+ */
+#define CPU_ID_BOOTSTRAP 0
+
+/**
+ * @brief Invalid CPU ID.
+ */
+#define CPU_ID_INVALID UINT16_MAX
+
+/**
+ * @brief Type used to identify a CPU.
+ */
+typedef uint16_t cpu_id_t;
+
/**
* @brief CPU stack canary value.
*
@@ -72,7 +98,7 @@ typedef struct cpu
uint8_t doubleFaultStackBuffer[CONFIG_INTERRUPT_STACK_PAGES * PAGE_SIZE] ALIGNED(PAGE_SIZE);
uint8_t nmiStackBuffer[CONFIG_INTERRUPT_STACK_PAGES * PAGE_SIZE] ALIGNED(PAGE_SIZE);
uint8_t interruptStackBuffer[CONFIG_INTERRUPT_STACK_PAGES * PAGE_SIZE] ALIGNED(PAGE_SIZE);
- uint8_t percpu[CONFIG_PERCPU_SIZE] ALIGNED(PAGE_SIZE);
+ uint8_t percpu[CONFIG_PERCPU_SIZE] ALIGNED(PAGE_SIZE); ///< Buffer used for per-CPU data.
} cpu_t;
static_assert(offsetof(cpu_t, self) == CPU_OFFSET_SELF,
diff --git a/include/kernel/cpu/cpu_id.h b/include/kernel/cpu/cpu_id.h
deleted file mode 100644
index af6ec0f98..000000000
--- a/include/kernel/cpu/cpu_id.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-
-#include
-
-#include
-#include
-
-/**
- * @addtogroup kernel_cpu
- *
- * @{
- */
-
-/**
- * @brief The offset of the `id` member in the `cpu_t` structure.
- *
- * Needed to access the CPU ID from assembly code.
- */
-#define CPU_OFFSET_ID 0x8
-
-/**
- * @brief Maximum number of CPUs supported.
- */
-#define CPU_MAX UINT8_MAX
-
-/**
- * @brief ID of the bootstrap CPU.
- */
-#define CPU_ID_BOOTSTRAP 0
-
-/**
- * @brief Invalid CPU ID.
- */
-#define CPU_ID_INVALID UINT16_MAX
-
-/**
- * @brief Type used to identify a CPU.
- */
-typedef uint16_t cpu_id_t;
-
-/** @} */
diff --git a/include/kernel/cpu/io.h b/include/kernel/cpu/io.h
index 2e9e22726..e1e97cb39 100644
--- a/include/kernel/cpu/io.h
+++ b/include/kernel/cpu/io.h
@@ -1,6 +1,7 @@
#pragma once
#include
+#include
/**
* @brief I/O port operations and reservations
@@ -70,7 +71,7 @@ void io_release(port_t base, uint64_t length);
*/
static inline void io_out8(port_t port, uint8_t val)
{
- asm volatile("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
+ ASM("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
}
/**
@@ -82,7 +83,7 @@ static inline void io_out8(port_t port, uint8_t val)
static inline uint8_t io_in8(port_t port)
{
uint8_t ret;
- asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
+ ASM("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
return ret;
}
@@ -94,7 +95,7 @@ static inline uint8_t io_in8(port_t port)
*/
static inline void io_out16(port_t port, uint16_t val)
{
- asm volatile("outw %0, %1" : : "a"(val), "Nd"(port) : "memory");
+ ASM("outw %0, %1" : : "a"(val), "Nd"(port) : "memory");
}
/**
@@ -106,7 +107,7 @@ static inline void io_out16(port_t port, uint16_t val)
static inline uint16_t io_in16(port_t port)
{
uint16_t ret;
- asm volatile("inw %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
+ ASM("inw %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
return ret;
}
@@ -119,7 +120,7 @@ static inline uint16_t io_in16(port_t port)
static inline uint32_t io_in32(port_t port)
{
uint32_t ret;
- asm volatile("inl %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
+ ASM("inl %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
return ret;
}
@@ -131,7 +132,7 @@ static inline uint32_t io_in32(port_t port)
*/
static inline void io_out32(port_t port, uint32_t val)
{
- asm volatile("outl %0, %1" : : "a"(val), "Nd"(port) : "memory");
+ ASM("outl %0, %1" : : "a"(val), "Nd"(port) : "memory");
}
/** @} */
diff --git a/include/kernel/cpu/irq.h b/include/kernel/cpu/irq.h
index 2632d99a4..6166d1f21 100644
--- a/include/kernel/cpu/irq.h
+++ b/include/kernel/cpu/irq.h
@@ -285,6 +285,6 @@ void irq_handler_unregister(irq_func_t func, irq_virt_t virt);
*
* @param virt The virtual IRQ to invoke.
*/
-#define IRQ_INVOKE(virt) asm volatile("int %0" : : "i"(virt));
+#define IRQ_INVOKE(virt) ASM("int %0" : : "i"(virt));
/** @} */
diff --git a/include/kernel/cpu/percpu.h b/include/kernel/cpu/percpu.h
index 2b7e0f883..3b9983b57 100644
--- a/include/kernel/cpu/percpu.h
+++ b/include/kernel/cpu/percpu.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
#include
@@ -9,27 +9,37 @@
* @defgroup kernel_cpu_percpu Per-CPU Data
* @ingroup kernel_cpu
*
- * Per-CPU data is stored using the `gs` segment register and the `MSR_GS_BASE` model specific register (MSR). Such that
- * the `MSR_GS_BASE` msr stores the address of the currently running CPU and the `gs` register can used to access
- * data within the current CPU structure.
+ * In the x86 architecture the `gs` and `fs` segment registers can be used to access data relative to the address stored
+ * in the `MSR_GS_BASE` or `MSR_FS_BASE` MSRs. In AT&T assembly this would look like this:
*
- * @note All percpu variables should use the `pcpu_` prefix for clarity.
+ * ```
+ * mov %gs:0x10, %rax ; Load the value at address in `MSR_GS_BASE` + 0x10 into rax
+ * ```
+ *
+ * This means that, since each cpu has its own `MSR_GS_BASE`, we can store the address of each CPU's structure in its
+ * own `MSR_GS_BASE` and then access data within that structure using offsets.
+ *
+ * Allocating a percpu variable then becomes as simple as allocating an offset within the `percpu` buffer in the CPU
+ * structure, and accessing it using the `gs` segment register.
+ *
+ * @note Its important to be aware of the distinction that the `gs` register does not store an address directly, rather
+ * it allows us to access memory relative to the address stored in the `MSR_GS_BASE` MSR. This is why we define Per-CPU
+ * variables as offsets within the CPU structure rather than absolute addresses.
*
* ## Defining Per-CPU Variables
*
- * To define a Per-CPU variable use the `PERCPU_DEFINE()` macro. This creates a variable that acts like a pointer, but
- * in reality its a `percpu_t` (64-bit integer) storing an offset into the CPU structure.
+ * To define a Per-CPU variable use the `PERCPU_DEFINE()` macro. This will add a `percpu_def_t` entry to the `._percpu`
+ * section. The PERCPU_INIT()` macro can be used to allocate and initialize all Per-CPU variables defined in the
+ * module's `._percpu` section, potentially invoking any needed constructors.
*
- * As such, even though there appears to be only one instance of the variable, each CPU will have its own instance of
- * the variable stored at the offset within its CPU structure.
+ * @note All percpu variables should use the `pcpu_` prefix for clarity.
*
* ## Constructors and Destructors
*
* All Per-CPU variables can optionally have constructors (ctor) and destructors (dtor) defined. These will be called on
- * each CPU when the Per-CPU section containing the variable is initialized and deinitialized respectively.
+ * each CPU either during boot, when the CPU is initialized, or via a call to `percpu_update()`.
*
- * By default, all variables are zero-initialized when allocated, but if a constructor is defined, it will be called
- * after zero-initialization.
+ * By default, all variables are zero-initialized when allocated.
*
* @{
*/
@@ -136,6 +146,15 @@ typedef struct
PERCPU_DEFINE(type, name, .ctor = NULL, .dtor = name##_dtor); \
static void name##_dtor(void)
+/**
+ * @brief Initialize the percpu system.
+ *
+ * This will setup the `gs` segment register to point to the CPU structure.
+ *
+ * @param cpu The CPU to initialize percpu for, should be the current CPU.
+ */
+void percpu_init(cpu_t* cpu);
+
/**
* @brief Allocates a percpu variable.
*
@@ -162,37 +181,33 @@ void percpu_update(void);
/**
* @brief Register a percpu section and run constructors.
*/
-void percpu_init_section(percpu_def_t* start, percpu_def_t* end);
+void percpu_section_init(percpu_def_t* start, percpu_def_t* end);
/**
* @brief Unregister a percpu section and run destructors.
*/
-void percpu_finit_section(percpu_def_t* start, percpu_def_t* end);
+void percpu_section_deinit(percpu_def_t* start, percpu_def_t* end);
/**
* @brief Initialize all percpu variables within the current modules `.percpu` section.
- *
- * @note Generally, it is prefered to call `INIT_CALL()` to initialize percpu variables.
*/
#define PERCPU_INIT() \
do \
{ \
- extern percpu_def_t _percpuStart; \
- extern percpu_def_t _percpuEnd; \
- percpu_init_section(&_percpuStart, &_percpuEnd); \
+ extern percpu_def_t _percpu_start; \
+ extern percpu_def_t _percpu_end; \
+ percpu_section_init(&_percpu_start, &_percpu_end); \
} while (0)
/**
* @brief Deinitialize all percpu variables within the current modules `.percpu` section.
- *
- * @note Generally, it is prefered to call `FINIT_CALL()` to deinitialize percpu variables.
*/
-#define PERCPU_FINIT() \
+#define PERCPU_DEINIT() \
do \
{ \
- extern percpu_def_t _percpuStart; \
- extern percpu_def_t _percpuEnd; \
- percpu_finit_section(&_percpuStart, &_percpuEnd); \
+ extern percpu_def_t _percpu_start; \
+ extern percpu_def_t _percpu_end; \
+ percpu_section_deinit(&_percpu_start, &_percpu_end); \
} while (0)
/** @} */
diff --git a/include/kernel/cpu/regs.h b/include/kernel/cpu/regs.h
index 567e0262c..25f96a0ca 100644
--- a/include/kernel/cpu/regs.h
+++ b/include/kernel/cpu/regs.h
@@ -1,6 +1,7 @@
#pragma once
#include
+#include
#define XCR0_XSAVE_SAVE_X87 (1 << 0)
#define XCR0_XSAVE_SAVE_SSE (1 << 1)
@@ -58,14 +59,14 @@ static inline void xcr0_write(uint32_t xcr, uint64_t value)
{
uint32_t eax = (uint32_t)value;
uint32_t edx = value >> 32;
- asm volatile("xsetbv" : : "a"(eax), "d"(edx), "c"(xcr) : "memory");
+ ASM("xsetbv" : : "a"(eax), "d"(edx), "c"(xcr) : "memory");
}
static inline uint64_t msr_read(uint32_t msr)
{
uint32_t low;
uint32_t high;
- asm volatile("rdmsr" : "=a"(low), "=d"(high) : "c"(msr));
+ ASM("rdmsr" : "=a"(low), "=d"(high) : "c"(msr));
return ((uint64_t)high << 32) | (uint64_t)low;
}
@@ -73,89 +74,89 @@ static inline void msr_write(uint32_t msr, uint64_t value)
{
uint32_t low = (uint32_t)(value & 0xFFFFFFFF);
uint32_t high = (uint32_t)(value >> 32);
- asm volatile("wrmsr" : : "c"(msr), "a"(low), "d"(high));
+ ASM("wrmsr" : : "c"(msr), "a"(low), "d"(high));
}
-static inline uint64_t rflags_read()
+static inline uint64_t rflags_read(void)
{
uint64_t rflags;
- asm volatile("pushfq; pop %0" : "=r"(rflags));
+ ASM("pushfq; pop %0" : "=r"(rflags));
return rflags;
}
static inline void rflags_write(uint64_t value)
{
- asm volatile("push %0; popfq" : : "r"(value));
+ ASM("push %0; popfq" : : "r"(value));
}
-static inline uint64_t cr4_read()
+static inline uint64_t cr4_read(void)
{
uint64_t cr4;
- asm volatile("mov %%cr4, %0" : "=r"(cr4));
+ ASM("mov %%cr4, %0" : "=r"(cr4));
return cr4;
}
static inline void cr4_write(uint64_t value)
{
- asm volatile("mov %0, %%cr4" : : "r"(value));
+ ASM("mov %0, %%cr4" : : "r"(value));
}
-static inline uint64_t cr3_read()
+static inline uint64_t cr3_read(void)
{
uint64_t cr3;
- asm volatile("mov %%cr3, %0" : "=r"(cr3));
+ ASM("mov %%cr3, %0" : "=r"(cr3));
return cr3;
}
static inline void cr3_write(uint64_t value)
{
- asm volatile("mov %0, %%cr3" : : "r"(value));
+ ASM("mov %0, %%cr3" : : "r"(value));
}
-static inline uint64_t cr2_read()
+static inline uint64_t cr2_read(void)
{
uint64_t cr2;
- asm volatile("mov %%cr2, %0" : "=r"(cr2));
+ ASM("mov %%cr2, %0" : "=r"(cr2));
return cr2;
}
static inline void cr2_write(uint64_t value)
{
- asm volatile("mov %0, %%cr2" : : "r"(value));
+ ASM("mov %0, %%cr2" : : "r"(value));
}
-static inline uint64_t cr0_read()
+static inline uint64_t cr0_read(void)
{
uint64_t cr0;
- asm volatile("mov %%cr0, %0" : "=r"(cr0));
+ ASM("mov %%cr0, %0" : "=r"(cr0));
return cr0;
}
static inline void cr0_write(uint64_t value)
{
- asm volatile("mov %0, %%cr0" : : "r"(value));
+ ASM("mov %0, %%cr0" : : "r"(value));
}
-static inline uint64_t rsp_read()
+static inline uint64_t rsp_read(void)
{
uint64_t rsp;
- asm volatile("mov %%rsp, %0" : "=r"(rsp));
+ ASM("mov %%rsp, %0" : "=r"(rsp));
return rsp;
}
static inline void rsp_write(uint64_t value)
{
- asm volatile("mov %0, %%rsp" : : "r"(value));
+ ASM("mov %0, %%rsp" : : "r"(value));
}
-static inline uint64_t rbp_read()
+static inline uint64_t rbp_read(void)
{
uint64_t rbp;
- asm volatile("mov %%rbp, %0" : "=r"(rbp));
+ ASM("mov %%rbp, %0" : "=r"(rbp));
return rbp;
}
static inline void rbp_write(uint64_t value)
{
- asm volatile("mov %0, %%rbp" : : "r"(value));
+ ASM("mov %0, %%rbp" : : "r"(value));
}
diff --git a/include/kernel/cpu/syscall.h b/include/kernel/cpu/syscall.h
index aeaeaa9c0..b1c87e3c3 100644
--- a/include/kernel/cpu/syscall.h
+++ b/include/kernel/cpu/syscall.h
@@ -148,12 +148,12 @@ typedef struct
/**
* @brief Linker defined start of the syscall table.
*/
-extern syscall_descriptor_t _syscallTableStart[];
+extern syscall_descriptor_t _syscall_table_start[];
/**
* @brief Linker defined end of the syscall table.
*/
-extern syscall_descriptor_t _syscallTableEnd[];
+extern syscall_descriptor_t _syscall_table_end[];
/**
* @brief Macro to define a syscall.
diff --git a/include/kernel/init/init.h b/include/kernel/init/init.h
index f55ae7480..f39710714 100644
--- a/include/kernel/init/init.h
+++ b/include/kernel/init/init.h
@@ -32,36 +32,4 @@ _NORETURN void init_early(void);
*/
_NORETURN void kmain(void);
-/**
- * @brief Calls all functions in the `.init_array` section and initializes percpu variables for the current module.
- */
-#define INIT_CALL() \
- do \
- { \
- extern void* _initArrayStart; \
- extern void* _initArrayEnd; \
- for (void** func = &_initArrayStart; func < &_initArrayEnd; func++) \
- { \
- void (*initFunc)(void) = (void (*)(void)) * func; \
- initFunc(); \
- } \
- PERCPU_INIT(); \
- } while (0)
-
-/**
- * @brief Calls all functions in the `.finit_array` section and deinitializes percpu variables for the current module.
- */
-#define FINIT_CALL() \
- do \
- { \
- PERCPU_FINIT(); \
- extern void* _finitArrayStart; \
- extern void* _finitArrayEnd; \
- for (void** func = &_finitArrayStart; func < &_finitArrayEnd; func++) \
- { \
- void (*finitFunc)(void) = (void (*)(void)) * func; \
- finitFunc(); \
- } \
- } while (0)
-
/** @} */
diff --git a/include/kernel/mem/paging.h b/include/kernel/mem/paging.h
index d0beabf00..c1922c3ae 100644
--- a/include/kernel/mem/paging.h
+++ b/include/kernel/mem/paging.h
@@ -3,16 +3,11 @@
#include
#include
+#include <_internal/PAGE_SIZE.h>
#include
#include
#include
#include
-#include
-
-#ifdef _BOOT_
-#include
-#include
-#endif
/**
* @addtogroup kernel_mem_paging
@@ -43,7 +38,7 @@ static inline void tlb_invalidate(void* virtAddr, uint64_t pageCount)
{
for (uint64_t i = 0; i < pageCount; i++)
{
- asm volatile("invlpg (%0)" ::"r"(virtAddr + i * PAGE_SIZE) : "memory");
+ ASM("invlpg (%0)" ::"r"(virtAddr + i * PAGE_SIZE) : "memory");
}
}
}
@@ -101,11 +96,7 @@ static inline uint64_t pml_new(page_table_t* table, pml_t** outPml)
{
return ERR;
}
-#ifdef _BOOT_
- SetMem(pml, PAGE_SIZE, 0);
-#else
memset(pml, 0, PAGE_SIZE);
-#endif
*outPml = pml;
return 0;
}
@@ -213,7 +204,8 @@ static inline uint64_t page_table_get_pml(page_table_t* table, pml_t* currentPml
*outPml = (pml_t*)pml_accessible_addr(*entry);
return 0;
}
- else if (flags & PML_PRESENT)
+
+ if (flags & PML_PRESENT)
{
pml_t* nextPml;
if (pml_new(table, &nextPml) == ERR)
diff --git a/include/kernel/mem/paging_types.h b/include/kernel/mem/paging_types.h
index 6ccae0a05..74205f767 100644
--- a/include/kernel/mem/paging_types.h
+++ b/include/kernel/mem/paging_types.h
@@ -1,7 +1,7 @@
#pragma once
+#include <_internal/size_t.h>
#include
-#include
#include
#include
diff --git a/include/kernel/sched/wait.h b/include/kernel/sched/wait.h
index 73150fc83..75afdb51d 100644
--- a/include/kernel/sched/wait.h
+++ b/include/kernel/sched/wait.h
@@ -31,7 +31,7 @@ typedef struct wait wait_t;
*
* @note Generally its preferred to use the `WAIT_BLOCK*` macros instead of directly calling the functions provided by
* this subsystem.
- *
+ *
* @todo Replace with `epoll()` style system?
*
* @{
diff --git a/include/kernel/sync/lock.h b/include/kernel/sync/lock.h
index 3f9218e43..dd0279c9f 100644
--- a/include/kernel/sync/lock.h
+++ b/include/kernel/sync/lock.h
@@ -66,17 +66,9 @@ typedef struct
* @return A `lock_t` initializer.
*/
#ifndef NDEBUG
-#define LOCK_CREATE() \
- (lock_t) \
- { \
- .nextTicket = ATOMIC_VAR_INIT(0), .nowServing = ATOMIC_VAR_INIT(0), .canary = LOCK_CANARY \
- }
+#define LOCK_CREATE() {.nextTicket = ATOMIC_VAR_INIT(0), .nowServing = ATOMIC_VAR_INIT(0), .canary = LOCK_CANARY}
#else
-#define LOCK_CREATE() \
- (lock_t) \
- { \
- .nextTicket = ATOMIC_VAR_INIT(0), .nowServing = ATOMIC_VAR_INIT(0) \
- }
+#define LOCK_CREATE() {.nextTicket = ATOMIC_VAR_INIT(0), .nowServing = ATOMIC_VAR_INIT(0)}
#endif
/**
@@ -118,7 +110,7 @@ static inline void lock_acquire(lock_t* lock)
uint16_t ticket = atomic_fetch_add_explicit(&lock->nextTicket, 1, memory_order_relaxed);
while (atomic_load_explicit(&lock->nowServing, memory_order_relaxed) != ticket)
{
- asm volatile("pause");
+ ASM("pause");
#ifndef NDEBUG
if (lock->canary != LOCK_CANARY)
diff --git a/include/kernel/sync/mutex.h b/include/kernel/sync/mutex.h
index 27e923f07..65942409d 100644
--- a/include/kernel/sync/mutex.h
+++ b/include/kernel/sync/mutex.h
@@ -31,7 +31,12 @@ typedef struct thread thread_t;
* @return A mutex initializer.
*/
#define MUTEX_CREATE(name) \
- {.waitQueue = WAIT_QUEUE_CREATE(name.waitQueue), .owner = NULL, .depth = 0, .lock = LOCK_CREATE()}
+ { \
+ .waitQueue = WAIT_QUEUE_CREATE(name.waitQueue), \
+ .owner = NULL, \
+ .depth = 0, \
+ .lock = LOCK_CREATE(), \
+ }
/**
* @brief Mutex structure.
diff --git a/include/kernel/sync/rwlock.h b/include/kernel/sync/rwlock.h
index f7a1f9958..07753e4df 100644
--- a/include/kernel/sync/rwlock.h
+++ b/include/kernel/sync/rwlock.h
@@ -1,10 +1,10 @@
#pragma once
-#include
#include
+#include
-#include
#include
+#include
#ifndef NDEBUG
#include
@@ -102,7 +102,7 @@ static inline void rwlock_read_acquire(rwlock_t* lock)
while (atomic_load_explicit(&lock->readServe, memory_order_acquire) != ticket)
{
- asm volatile("pause");
+ ASM("pause");
#ifndef NDEBUG
if (++iterations >= RWLOCK_DEADLOCK_ITERATIONS)
{
@@ -132,7 +132,7 @@ static inline void rwlock_read_acquire(rwlock_t* lock)
panic(NULL, "Deadlock in rwlock_read_acquire detected");
}
#endif
- asm volatile("pause");
+ ASM("pause");
}
}
atomic_fetch_add_explicit(&lock->readServe, 1, memory_order_release);
@@ -173,7 +173,7 @@ static inline void rwlock_write_acquire(rwlock_t* lock)
panic(NULL, "Deadlock in rwlock_write_acquire detected");
}
#endif
- asm volatile("pause");
+ ASM("pause");
}
while (atomic_load_explicit(&lock->activeReaders, memory_order_acquire) > 0)
@@ -184,7 +184,7 @@ static inline void rwlock_write_acquire(rwlock_t* lock)
panic(NULL, "Deadlock in rwlock_write_acquire detected");
}
#endif
- asm volatile("pause");
+ ASM("pause");
}
}
diff --git a/include/kernel/sync/rwmutex.h b/include/kernel/sync/rwmutex.h
index 9b31f63fd..22e201426 100644
--- a/include/kernel/sync/rwmutex.h
+++ b/include/kernel/sync/rwmutex.h
@@ -56,10 +56,13 @@ typedef struct rwmutex
* @return A `rwmutex_t` initializer.
*/
#define RWMUTEX_CREATE(name) \
- (rwmutex_t) \
{ \
- .activeReaders = 0, .waitingWriters = 0, .readerQueue = WAIT_QUEUE_CREATE(name.readerQueue), \
- .writerQueue = WAIT_QUEUE_CREATE(name.writerQueue), .hasWriter = false, .lock = LOCK_CREATE() \
+ .activeReaders = 0, \
+ .waitingWriters = 0, \
+ .readerQueue = WAIT_QUEUE_CREATE(name.readerQueue), \
+ .writerQueue = WAIT_QUEUE_CREATE(name.writerQueue), \
+ .hasWriter = false, \
+ .lock = LOCK_CREATE(), \
}
/**
diff --git a/include/kernel/sync/seqlock.h b/include/kernel/sync/seqlock.h
index e93929ea0..e1bb5779c 100644
--- a/include/kernel/sync/seqlock.h
+++ b/include/kernel/sync/seqlock.h
@@ -37,7 +37,11 @@ typedef struct
*
* @return A `seqlock_t` initializer.
*/
-#define SEQLOCK_CREATE() {.sequence = ATOMIC_VAR_INIT(0), .writeLock = LOCK_CREATE()}
+#define SEQLOCK_CREATE() \
+ { \
+ .sequence = ATOMIC_VAR_INIT(0), \
+ .writeLock = LOCK_CREATE(), \
+ }
/**
* @brief Initializes a sequence lock.
diff --git a/include/kernel/utils/ref.h b/include/kernel/utils/ref.h
index 6739779ab..886ade719 100644
--- a/include/kernel/utils/ref.h
+++ b/include/kernel/utils/ref.h
@@ -301,7 +301,7 @@ static inline void weak_ptr_clear(weak_ptr_t* wp)
}
lock_release(&wp->lock);
- asm volatile("pause");
+ ASM("pause");
}
}
diff --git a/include/kernel/utils/test.h b/include/kernel/utils/test.h
index f02abf5b3..9666f74b6 100644
--- a/include/kernel/utils/test.h
+++ b/include/kernel/utils/test.h
@@ -37,10 +37,10 @@ typedef struct test
#define TEST_ALL() \
do \
{ \
- extern test_t _testsStart; \
- extern test_t _testsEnd; \
- const test_t* test = &_testsStart; \
- while (test < &_testsEnd) \
+ extern test_t _tests_start; \
+ extern test_t _tests_end; \
+ const test_t* test = &_tests_start; \
+ while (test < &_tests_end) \
{ \
LOG_INFO("running test '%s'\n", test->name); \
clock_t start = clock_uptime(); \
diff --git a/include/libstd/_internal/NULL.h b/include/libstd/_internal/NULL.h
index 37ca3b7e1..3f3907501 100644
--- a/include/libstd/_internal/NULL.h
+++ b/include/libstd/_internal/NULL.h
@@ -1,6 +1,8 @@
#ifndef _INTERNAL_NULL_H
#define _INTERNAL_NULL_H 1
+#ifndef NULL
+
#ifdef __cplusplus
#if __cplusplus >= 201103L
#define _NULL nullptr
@@ -23,3 +25,5 @@
#define NULL _NULL
#endif
+
+#endif
diff --git a/include/libstd/_internal/PAGE_SIZE.h b/include/libstd/_internal/PAGE_SIZE.h
new file mode 100644
index 000000000..df96b80f9
--- /dev/null
+++ b/include/libstd/_internal/PAGE_SIZE.h
@@ -0,0 +1,10 @@
+#ifndef _INTERNAL_PAGE_SIZE_H
+#define _INTERNAL_PAGE_SIZE_H 1
+
+/**
+ * @brief The size of a memory page in bytes.
+ * @ingroup libstd
+ */
+#define PAGE_SIZE 0x1000
+
+#endif
diff --git a/include/libstd/stdarg.h b/include/libstd/stdarg.h
index cbadbc48c..f5356c3c0 100644
--- a/include/libstd/stdarg.h
+++ b/include/libstd/stdarg.h
@@ -6,6 +6,8 @@ extern "C"
{
#endif
+#ifndef va_arg
+
typedef __builtin_va_list va_list;
#define va_arg(ap, type) __builtin_va_arg(ap, type)
@@ -13,6 +15,8 @@ typedef __builtin_va_list va_list;
#define va_end(ap) __builtin_va_end(ap)
#define va_start(ap, parmN) __builtin_va_start(ap, parmN)
+#endif
+
#if defined(__cplusplus)
}
#endif
diff --git a/include/libstd/sys/cpuid.h b/include/libstd/sys/cpuid.h
index b2517b71c..01e9d213f 100644
--- a/include/libstd/sys/cpuid.h
+++ b/include/libstd/sys/cpuid.h
@@ -3,6 +3,7 @@
#include
#include
+#include
/**
* @brief CPU feature detection
@@ -181,7 +182,7 @@ typedef struct
*/
static inline void cpuid(cpuid_input_eax_t eax, cpuid_input_ecx_t ecx, cpuid_output_t* out)
{
- asm volatile("cpuid" : "=a"(out->eax), "=b"(out->ebx), "=c"(out->ecx), "=d"(out->edx) : "a"(eax), "c"(ecx));
+ ASM("cpuid" : "=a"(out->eax), "=b"(out->ebx), "=c"(out->ecx), "=d"(out->edx) : "a"(eax), "c"(ecx));
}
/**
diff --git a/include/libstd/sys/defs.h b/include/libstd/sys/defs.h
index ebd673cd8..7f41a45ab 100644
--- a/include/libstd/sys/defs.h
+++ b/include/libstd/sys/defs.h
@@ -99,6 +99,13 @@
*/
#define UNUSED(x) (void)(x)
+/**
+ * @brief GCC unused function attribute.
+ *
+ * Tells the compiler that the function with said attribute might be unused, preventing warnings.
+ */
+#define UNUSED_FUNC __attribute__((unused))
+
/**
* @brief Get the number of elements in a static array.
*
@@ -149,6 +156,13 @@
*/
#define DESTRUCTOR(priority) __attribute__((used, destructor(priority)))
+/**
+ * @brief Inline assembly macro.
+ *
+ * @param ... The assembly code to embed.
+ */
+#define ASM(...) __asm__ volatile(__VA_ARGS__)
+
/** @} */
#endif
\ No newline at end of file
diff --git a/include/libstd/sys/list.h b/include/libstd/sys/list.h
index dfee36a2a..7b8e26923 100644
--- a/include/libstd/sys/list.h
+++ b/include/libstd/sys/list.h
@@ -7,7 +7,6 @@
#include
#include
#include
-#include
/**
* @brief Doubly linked list header.
@@ -160,7 +159,6 @@ typedef struct list
* @return A `list_t` initializer for the specified list variable.
*/
#define LIST_CREATE(name) \
- (list_t) \
{ \
.head = {.prev = &(name).head, .next = &(name).head } \
}
diff --git a/include/libstd/sys/proc.h b/include/libstd/sys/proc.h
index 9dc17f16c..5c5276829 100644
--- a/include/libstd/sys/proc.h
+++ b/include/libstd/sys/proc.h
@@ -12,6 +12,7 @@ extern "C"
#include "_internal/ERR.h"
#include "_internal/NULL.h"
+#include "_internal/PAGE_SIZE.h"
#include "_internal/clock_t.h"
#include "_internal/config.h"
#include "_internal/fd_t.h"
@@ -97,11 +98,6 @@ pid_t getpid(void);
*/
tid_t gettid(void);
-/**
- * @brief The size of a memory page in bytes.
- */
-#define PAGE_SIZE 0x1000
-
/**
* @brief Convert a size in bytes to pages.
*
@@ -333,7 +329,7 @@ uint64_t atnotify(atnotify_func_t handler, atnotify_t action);
* @param frame The interrupt frame of the current interrupt.
* @return On success, `true` if a note was handled, `false` otherwise.
*/
-_NORETURN void _exit(const char* status);
+_NORETURN void proc_exit(const char* status);
/**
* @brief Helper for sending the "kill" command to a process.
diff --git a/include/modules/drivers/apic/apic_timer.h b/include/modules/drivers/apic/apic_timer.h
index cd1f62050..7531e3f2f 100644
--- a/include/modules/drivers/apic/apic_timer.h
+++ b/include/modules/drivers/apic/apic_timer.h
@@ -39,4 +39,11 @@ typedef enum
APIC_TIMER_DIV_DEFAULT = APIC_TIMER_DIV_16
} apic_timer_divider_t;
+/**
+ * @brief Initialize the APIC timer.
+ *
+ * @return On success, `0`. On failure, `ERR` and `errno` is set.
+ */
+uint64_t apic_timer_init(void);
+
/** @} */
\ No newline at end of file
diff --git a/include/modules/drivers/apic/ioapic.h b/include/modules/drivers/apic/ioapic.h
index f8dc1b185..c5c267bce 100644
--- a/include/modules/drivers/apic/ioapic.h
+++ b/include/modules/drivers/apic/ioapic.h
@@ -150,4 +150,11 @@ typedef union {
} raw;
} ioapic_redirect_entry_t;
+/**
+ * @brief Initialize all IO APICs found in the system.
+ *
+ * @return On success, `0`. On failure, `ERR` and `errno` is set.
+ */
+uint64_t ioapic_all_init(void);
+
/** @} */
\ No newline at end of file
diff --git a/include/modules/drivers/apic/lapic.h b/include/modules/drivers/apic/lapic.h
index cf664a559..4d1fd2b85 100644
--- a/include/modules/drivers/apic/lapic.h
+++ b/include/modules/drivers/apic/lapic.h
@@ -174,4 +174,11 @@ void lapic_send_init(lapic_id_t id);
*/
void lapic_send_sipi(lapic_id_t id, void* entryPoint);
+/**
+ * @brief Global initialization for the local APICs.
+ *
+ * @return On success, `0`. On failure, `ERR` and `errno` is set.
+ */
+uint64_t lapic_global_init(void);
+
/** @} */
\ No newline at end of file
diff --git a/include/modules/linker.lds b/include/modules/linker.lds
index 76d40e2d1..307a3542d 100644
--- a/include/modules/linker.lds
+++ b/include/modules/linker.lds
@@ -1,65 +1,83 @@
OUTPUT_FORMAT(elf64-x86-64)
+OUTPUT_ARCH(i386:x86-64)
ENTRY(_module_procedure)
PHDRS
{
text PT_LOAD FLAGS(5);
data PT_LOAD FLAGS(6);
+ dynamic PT_DYNAMIC FLAGS(6);
}
SECTIONS
{
.text : ALIGN(4K)
{
- *(.text)
+ *(.text .text.*)
} :text
.rodata : ALIGN(4K)
{
- *(.rodata)
+ *(.rodata .rodata.*)
+ *(.eh_frame .eh_frame.*)
+ *(.eh_frame_hdr)
+ *(.note.gnu.build-id)
} :text
+ .gnu.hash : { *(.gnu.hash) } :text
+ .dynsym : { *(.dynsym) } :text
+ .dynstr : { *(.dynstr) } :text
+ .rela.dyn : { *(.rela.dyn) } :text
+ .rela.plt : { *(.rela.plt) } :text
+ .plt : { *(.plt .plt.*) } :text
+
+ . = ALIGN(4K);
+
+ .dynamic : { *(.dynamic) } :data :dynamic
+
+ .got : { *(.got) } :data
+ .got.plt : { *(.got.plt) } :data
+
.data : ALIGN(4K)
{
- *(.data)
+ *(.data .data.*)
+ *(.data.rel.ro .data.rel.ro.*)
+ *(.init_array .init_array.*)
+ *(.fini_array .fini_array.*)
} :data
.bss : ALIGN(4K)
{
*(COMMON)
- *(.bss)
- } :data
-
- .init_array :
- {
- _initArrayStart = .;
- KEEP(*(.init_array .init_array.*))
- _initArrayEnd = .;
+ *(.bss .bss.*)
} :data
- .fini_array :
+ . = ALIGN(4K);
+ ._percpu :
{
- _finiArrayStart = .;
- KEEP(*(.fini_array .fini_array.*))
- _finiArrayEnd = .;
- } :data
-
- ._percpu :
- {
- _percpuStart = .;
+ _percpu_start = .;
KEEP(*(._percpu))
- _percpuEnd = .;
+ _percpu_end = .;
} :data
- ._tests :
+ . = ALIGN(4K);
+ ._tests :
{
- _testsStart = .;
+ _tests_start = .;
KEEP(*(._tests))
- _testsEnd = .;
+ _tests_end = .;
} :data
-
- ._module_info :
+
+ . = ALIGN(4K);
+ ._module_info :
{
KEEP(*(._module_info))
} :data
-}
+
+ /DISCARD/ :
+ {
+ *(.note.GNU-stack)
+ *(.comment)
+ *(.interp)
+ }
+}
\ No newline at end of file
diff --git a/lib/OVMFbin/OVMF_VARS-pure-efi.fd b/lib/OVMFbin/OVMF_VARS-pure-efi.fd
index 83109e2e9..92201fe8b 100644
Binary files a/lib/OVMFbin/OVMF_VARS-pure-efi.fd and b/lib/OVMFbin/OVMF_VARS-pure-efi.fd differ
diff --git a/lib/gnu-efi/.gitignore b/lib/gnu-efi/.gitignore
deleted file mode 100644
index 970b638e0..000000000
--- a/lib/gnu-efi/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*.efi
-*.efi.debug
-*.o
-*.a
-*.tar.*
-*.tar
diff --git a/lib/gnu-efi/ChangeLog b/lib/gnu-efi/ChangeLog
deleted file mode 100644
index b1ea047fe..000000000
--- a/lib/gnu-efi/ChangeLog
+++ /dev/null
@@ -1,1324 +0,0 @@
- Updated Changelog
-
- Signed-off-by: Nigel Croxon
-
-commit 37d7bee82a627999563069b090866076e055a871
-Author: Nigel Croxon
-Date: Thu May 14 12:38:39 2015 -0400
-
- Added some missing error code descriptions
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit dae0b4b0b0d522caecf09123db2cf0250c37a169
-Author: Nigel Croxon
-Date: Thu May 14 12:20:51 2015 -0400
-
- Turns out we actually need setjmp in one of gnu-efi's prominent
- users, and it seems to make more sense to put it here than in
- the application.
-
- All of these are derived from the Tiano code, but I re-wrote the
- x86_64 one because we use the ELF psABI calling conventions instead
- of the MS ABI calling conventions. Which is to say you probably
- shouldn't setjmp()/longjmp() between functions with EFIAPI (aka
- __attribute__((ms_abi))) and those without.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit b5a8e93cec396381a6d2beee022abbf50100f2fd
-Author: Nigel Croxon
-Date: Fri Apr 10 08:49:50 2015 -0400
-
- Bump version to 3.0.2
-
- Signed-off-by: Nigel Croxon
-
-commit 01c9f11ed5ad55661e8fc8a3eee35c578564754b
-Author: Nigel Croxon
-Date: Fri Apr 10 08:46:40 2015 -0400
-
- Fix ARM32 and AARCH64 builds
- Without these added into SUBDIRS the initplat.c compilation will fail.
-
- Signed-off-by: Koen Kooi
- Acked-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit dada63fd3de148c6f8551d253355c113547cd5a0
-Author: Nigel Croxon
-Date: Mon Mar 23 10:41:43 2015 -0400
-
- [PATCH] _SPrint: fix NULL termination
-
- maxlen is the maximum string length not the buffer size.
-
- Signed-off-by: Jeremy Compostella
- Signed-off-by: Nigel Croxon
-
-commit ce7098fb52e5fd4d16038964d029eb759f28eaaf
-Author: Nigel Croxon
-Date: Thu Feb 19 11:22:45 2015 -0500
-
- Enable out-of-tree building
-
- This patch enables building gnu-efi outside of the source tree.
- That in turn enables building for multiple architectures in parallel.
-
- The build directory is controlled by the OBJDIR make variable. It
- defaults to the value of ARCH, and can be overridden from the command
- line.
-
- This patch also cleans up some doubled slashes between INSTALLROOT
- and PREFIX.
-
- Signed-off-by: Jonathan Boeing
- Signed-off-by: Nigel Croxon
-
-commit f64cef26270bfbe04f038da33f95ae3f14c071bc
-Author: Nigel Croxon
-Date: Tue Jan 6 15:49:50 2015 -0500
-
- Since we're keeping this in git, it'd be nice not to see a bunch
- of make targets in 'status'
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit 322efb6b21ed0a5e42e8f124fd22bf0f8dbf01ae
-Author: Nigel Croxon
-Date: Mon Jan 5 13:20:43 2015 -0500
-
- version number changed from VERSION = 3.0u to VERSION = 3.0.1
-
- Signed-off-by: Nigel Croxon
-
-commit 09027207f7c18af6caa45a744fc15c90b2a829db
-Author: Nigel Croxon
-Date: Mon Jan 5 13:13:22 2015 -0500
-
- From: Pete Batard
- Date: Wed, 10 Dec 2014 21:08:34 +0000
- Subject: [PATCH] fixes for MSVC compilation
-
- These fixes are needed to address the following error and warnings when compiling the library part
- using Visual Studio 2013 Community Edition (as in https://github.com/pbatard/uefi-simple):
- * "lib\x86_64\math.c(49): error C4235: nonstandard extension used : '_asm' keyword not supported
- on this architecture"
- * "lib\print.c(98): error C2059: syntax error : '('" due to placement of EFIAPI macro
- * "lib\cmdline.c(94): warning C4090: 'function' : different 'const' qualifiers"
- * "lib\smbios.c(25): warning C4068: unknown pragma"
- * Also update macro definitions in "inc\\efibind.h" for MSVC
-
- Signed-off-by: Pete Batard
- Signed-off-by: Nigel Croxon
-
-commit 15805ff38b83a72c2c7c96a24bd642ee1176d819
-Author: Nigel Croxon
-Date: Tue Nov 25 14:23:21 2014 -0500
-
- Add README.git file. Instructions on how to archive.
-
- Signed-off-by: Nigel Croxon
-
-commit b868aa75669723b7e32f46524822e17e388fe2ba
-Author: Nigel Croxon
-Date: Tue Nov 25 13:26:45 2014 -0500
-
- This patch makes generating releases from git a very simple process; you
- simply edit the makefile's "VERSION" line to the new version, commit
- that as its own commit, and do: "make test-archive". That'll make a
- file in the current directory gnu-efi-$VERSION.tar.bz2 , with its top
- level directory gnu-efi-$VERSION/ and the source tree under that.
-
- Once you've tested that and you're sure it's what you want to release,
- you do "make archive", which will tag a release in git and generate a
- final tarball from it. You then push to the archive, being sure to
- include the tag:
-
- git push origin master:master --tags
-
- And upload the archive wherever it's supposed to go.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit 530d68ba191850edafc6da22cb2df55bec0c5fa5
-Author: Nigel Croxon
-Date: Tue Nov 25 10:09:50 2014 -0500
-
- The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit 00bd66ef46b59a1623a293491a8b2c65a6d61975
-Author: Nigel Croxon
-Date: Mon Nov 24 14:33:09 2014 -0500
-
- FreeBSD's binutils doesn't have "-j " support, so we need to
- include non-globbed versions of .rel/.rela individually.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Bill Paul
- Signed-off-by: Nigel Croxon
-
-commit 56eb64d3c06854b9b68d61e3c2d3bdf6ff2a9853
-Author: Nigel Croxon
-Date: Mon Nov 24 14:27:14 2014 -0500
-
- Right now we wind up trying to build gnuefi/.o from a source file that's
- an empty string. This is caused by the macros trying to generate
- install rules, but there's no real reason to have all that anyway. So
- just have some static install rules that are simpler and don't generate
- stuff on the fly.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit 65e28a90a7be9e990b360286cea31e63319217fb
-Author: Nigel Croxon
-Date: Mon Nov 24 12:17:45 2014 -0500
-
- Add current OsIndications values.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-Date: Mon Nov 24 12:15:34 2014 -0500
-
- Add the QueryVariableInfo() API.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit 60efb7a2939b65a01e95aa8b535f1b756d984fba
-Author: Nigel Croxon
-Date: Mon Nov 24 12:13:23 2014 -0500
-
- Add the capsule API.
-
- Signed-off-by: Peter Jones
- Signed-off-by: Nigel Croxon
-
-commit ef08b655d1f8dfbd9a0f3a86d5685b24695ef12f
-Author: Nigel Croxon
-Date: Mon Nov 17 16:05:42 2014 -0500
-
- Fix Table Header misspelling. Change from EFI_TABLE_HEARDER to
- EFI_TABLE_HEADER.
-
- Signed-Off-By: Nigel Croxon
-
-commit 370cce41da3fff41ba38feb1262002aff2d85ffd
-Author: Nigel Croxon
-Date: Thu Nov 6 14:41:40 2014 -0500
-
- If CROSS_COMPILE is set, ignore the ARCH value supplied on the
- command line and use the target machine of the cross compiler.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit d32fb845433ff6fb38e81ae0d9273454e7d18197
-Author: Nigel Croxon
-Date: Thu Nov 6 14:30:03 2014 -0500
-
- Allow reuse of this file beyond GPL compatible software,
- update the license of crt0-efi-aarch64.S to dual 2-clause BSD/GPLv2+.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit aa1df67f48f3c035fa8891e1bb311ec21500d6d9
-Author: Nigel Croxon
-Date: Tue Oct 21 11:08:47 2014 -0400
-
- Add the missing Variable attributes
-
- From: Jeremy Compostella
- Date: Mon, 13 Oct 2014 17:50:50 +0200
- Subject: [PATCH] Add the missing Variable attributes
-
- Signed-off-by: Jeremy Compostella
- Signed-off-by: Nigel Croxon
-
-commit 5706dff09364cbbec37f47e2fe1350747f631d74
-Author: Nigel Croxon
-Date: Tue Aug 26 10:54:22 2014 -0400
-
- From: David Decotigny
- Date: Mon, 25 Aug 2014 13:28:49 -0700
- Subject: [PATCH] document that binutils >= 2.24 needed.
-
- commit ac983081 "Add support for non-PE/COFF capable objcopy" depends
- on objcopy accepting wildcards for the section names. This feature is
- available only with binutils >= 2.24 (binutils 2e62b7218 "PR
- binutils/15033").
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 6c10e225bc759d69af520a551b9d7b37f3ae0a82
-Author: Nigel Croxon
-Date: Mon Aug 25 08:51:23 2014 -0400
-
- From: David Decotigny
- Date: Thu, 31 Jul 2014 18:19:16 -0700
- Subject: [PATCH 5/5] allow to use external stdarg.h
-
- in cases we use gnu-efi together with other libs that define stdarg.h,
- break the tie by telling gnu-efi to use that stdarg.h .
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 16d65c0669258c8044e3549b2d9eb0cf0eb08f5a
-Author: Nigel Croxon
-Date: Tue Aug 19 12:07:00 2014 -0400
-
- From: Ard Biesheuvel
- Date: Mon, 11 Aug 2014 15:39:16 +0200
- Subject: [PATCH] Add support for 32-bit ARM
-
- This adds support for 32-bit ARM using an approach similar to the one used for
- 64-bit ARM (AArch64), i.e., it does not rely on an objcopy that is aware of EFI
- or PE/COFF, but lays out the entire PE/COFF header using the assembler.
-
- In the 32-bit ARM case (which does not have a division instruction), some code
- has been imported from the Linux kernel to perform the division operations in
- software.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit b28143d4fb4f6969dc0c87c853d3527d889951d7
-Author: Nigel Croxon
-Date: Fri Aug 8 15:54:19 2014 -0400
-
- Updated Changelog
-
- Signed-off-by: Nigel Croxon
-
-commit 1525190354f5faac33015e17c9ba7ea2bb2be35b
-Author: Nigel Croxon
-Date: Fri Aug 8 15:35:09 2014 -0400
-
- From: Ard Biesheuvel
- Date: Fri, 8 Aug 2014 18:16:59 +0200
- Subject: [PATCH 4/4] Add support for 64-bit ARM (AArch64)
-
- This adds support for 64-bit ARM (AArch64) environments. Since there is no
- EFI-capable objcopy for this platform, this contains a manually laid out
- PE/COFF header using the assembler.
-
- In addition, it includes the relocation bits, some string functions that GCC
- assumes are available and other glue to hold it all together.
-
- This can be cross built using
-
- make CROSS_COMPILE=aarch64-linux-gnu-
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit ac983081525f9483941517dfb53cf8d0163d49c0
-Author: Nigel Croxon
-Date: Fri Aug 8 15:32:26 2014 -0400
-
- From: Ard Biesheuvel
- Date: Fri, 8 Aug 2014 17:53:42 +0200
- Subject: [PATCH 3/4] Add support for non-PE/COFF capable objcopy
-
- Introduce HAVE_EFI_OBJCOPY and set it if objcopy for $ARCH support PE/COOF and
- EFI, i.e., it supports --target efi-[app|bsdrv|rtdrv] options. Use it to decide
- whether to invoke objcopy with those options or use the linker to populate the
- PE/COFF header.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit fb063f0f65543b3e2bf55a39d5aa70b17a98c65e
-Author: Nigel Croxon
-Date: Fri Aug 8 15:26:38 2014 -0400
-
- From: Ard Biesheuvel
- Date: Fri, 8 Aug 2014 17:37:36 +0200
- Subject: [PATCH 2/4] Add support for cross compilation
-
- This changes the logic that defines ARCH (and HOSTARCH) to take CROSS_COMPILE
- into account. Also, $prefix is not assigned, so that the default will be what
- is on the path rather than hardcoded in /usr/bin.
-
- This results in the build doing the right thing if CROSS_COMPILE is set in the
- environment and no ARCH or prefix options are passed to make, aligning it with
- most other CROSS_COMPILE compatible projects.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit 7a98d83fc32de6cf0b1ce5e12dfe80690f29fb3f
-Author: Nigel Croxon
-Date: Fri Aug 8 15:25:03 2014 -0400
-
- From: Ard Biesheuvel
- Date: Fri, 8 Aug 2014 16:50:45 +0200
- Subject: [PATCH 1/4] Restrict GNU_EFI_USE_MS_ABI GCC version test to x86_64
-
- The version test only applies to x86_64 builds, so no need to do it
- for other archs.
-
- Signed-off-by: Ard Biesheuvel
- Signed-off-by: Nigel Croxon
-
-commit f42974dd9a7d0ea690d293f88396abd289f0014c
-Author: Nigel Croxon
-Date: Fri Aug 8 15:21:16 2014 -0400
-
- From: David Decotigny
- Date: Thu, 31 Jul 2014 13:42:23 -0700
- Subject: [PATCH 4/4] Use Shell protocols to retrieve argc/argv, when
- available.
-
- New header files efishellintf.h efishellparm.h are coming from EDK
- II, initial location and license at top of files. Only modifications:
- - efishellintf.h: s/EFI_FILE_PROTOCOL/EFI_FILE/ + expand BITx macros (1<
- Signed-off-by: Nigel Croxon
-
-commit a61fa058e9a87f966de3342b8c95fdbdcb007827
-Author: Nigel Croxon
-Date: Fri Aug 8 15:17:32 2014 -0400
-
- From: David Decotigny
- Date: Thu, 31 Jul 2014 13:41:52 -0700
- Subject: [PATCH 3/4] document format of LoadedImage::LoadOptions data
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 2f440200c855154f929d28971b2fd702ea7a207a
-Author: Nigel Croxon
-Date: Fri Aug 8 15:15:59 2014 -0400
-
- From: David Decotigny
- Date: Thu, 31 Jul 2014 13:39:37 -0700
- Subject: [PATCH 2/4] Use OpenProtocol instead of HandleProtocol
-
- UEFI 2.x recommends OpenProtocol instead of HandleProtocol.
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 7f173da1e54f8cfe4c7c7c091ab6585af07b25ce
-Author: Nigel Croxon
-Date: Fri Aug 8 15:14:26 2014 -0400
-
- From: David Decotigny
- Date: Thu, 31 Jul 2014 13:30:07 -0700
- Subject: [PATCH 1/4] move cmdline parser to its own file
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 0ad8fb87cbc59f58675b18253ad802ba51f1d132
-Author: Nigel Croxon
-Date: Wed Jul 30 15:06:36 2014 -0400
-
- From: David Decotigny
- Date: Mon, 28 Jul 2014 21:28:50 -0700
- Subject: [PATCH 3/3] make cmdline parsing a 1st class citizen
-
- Refactor ParseCmdline and apps/Alloc+FreePages to factorize
- boilerplate and move the new parser to the main API.
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit ff7ec964f2c0de0cfc4b52cfdd356003450f28bf
-Author: Nigel Croxon
-Date: Wed Jul 30 15:05:28 2014 -0400
-
- From: David Decotigny
- Date: Mon, 28 Jul 2014 21:00:52 -0700
- Subject: [PATCH 2/3] Avoid buffer overflow while parsing the cmdline args
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 8d86ee202a9bb553375f56ae1d2944818112b68b
-Author: Nigel Croxon
-Date: Wed Jul 30 15:04:44 2014 -0400
-
- From: David Decotigny
- Date: Mon, 28 Jul 2014 21:01:35 -0700
- Subject: [PATCH 1/3] Fix cmdline parser
-
- The cmdline parser would not return the correct number of args, would
- allocate one too many. Also make it clear from the declaration that we
- expect a suitably lare argv.
-
- Signed-off-by: David Decotigny
- Signed-off-by: Nigel Croxon
-
-commit 1ec094bfaf46a610a740dadc0150bf457dd72345
-Author: Nigel Croxon
-Date: Wed Jul 23 09:54:25 2014 -0400
-
- From: Julian Klode
- Date: Mon, 21 Jul 2014 14:26:23 -0400
- Subject: [PATCH] inc/efistdarg.h: Use gcc builtins instead of stdarg.h or broken stubs
-
- We cannot use stdarg.h, as this breaks applications compiling
- with -nostdinc because those will not find the header.
- We also cannot use the stubs, as they just produce broken code,
- as seen in the gummiboot 45-1 Debian release.
-
- Signed-off-by: Julian Klode
- Signed-off-by: Nigel Croxon
-
-commit 6caab22f23434f41f42cfe7591d9a7ae66de9f0a
-Author: Nigel Croxon
-Date: Thu Jun 19 10:39:23 2014 -0400
-
- From: Laszlo Ersek
- Date: Mon, 2 Jun 2014 23:26:48 +0200
- Subject: [PATCH] always observe EFIAPI calling convention when calling
- STO.SetAttribute
-
- We have to consider the following cases wrt. the PRINT_STATE.Output and
- PRINT_STATE.SetAttr EFIAPI function pointers, especially when building for
- x86_64 with gcc:
-
- (1) The compiler is new enough, and EFIAPI actually ensures the Microsoft
- calling convention. In this case everything happens to work fine even
- if we forget uefi_call_wrapper(), because the wrapper would expand to
- a normal C function call anyway.
-
- (2) Otherwise (ie. gcc is old), EFIAPI expands to nothing, and we must
- take into account the called function's origin:
-
- (2a) If the callee that is declared EFIAPI is *defined* inside gnu-efi,
- then EFIAPI means nothing for the callee too, so caller and callee
- only understand each other if the caller intentionally omits
- uefi_call_wrapper().
-
- (2b) If the callee that is declared EFIAPI is defined by the platform
- UEFI implementation, then the caller *must* use
- uefi_call_wrapper().
-
- The PRINT_STATE.Output EFIAPI function pointer is dereferenced correctly:
- the PFLUSH() distinguishes cases (2a) from (2b) by using IsLocalPrint().
-
- However use of the PRINT_STATE.SetAttr EFIAPI function pointer is not
- always correct:
-
- - The PSETATTR() helper function always relies on the wrapper (case (2b)).
- This is correct, because PRINT_STATE.SetAttr always points to a
- platform-provided function.
-
- - The DbgPrint() function contains two incorrect calls: they mistakenly
- assume case (2a) (or case (1)), even though the pointer always points to
- a platform function, implying (2b). (The error is masked in case (1).)
- Fix them.
-
- Signed-off-by: Laszlo Ersek
- Signed-off-by: Nigel Croxon
-
-commit ecfd1ded9a799c3a572d4eb7fbb52582fe4d3390
-Author: Nigel Croxon
-Date: Tue Jun 10 12:59:09 2014 -0400
-
- Add VPoolPrint Function
-
- Equivalent to PoolPrint but using a va_list parameter
-
- Signed-off-by: Sylvain Chouleur
- Signed-off-by: Nigel Croxon
-
-commit f16d93f3b9e314336a387a3885c7fd2f176c41d3
-Author: Nigel Croxon
-Date: Fri May 16 11:33:51 2014 -0400
-
- Revert "The prototype of DbgPrint() is incorrect, at the end of "inc/efidebug.h"."
- A problem was found compiling on GCC 4.8.
-
- This reverts commit 644898eabc06c8efaa3aa54f84cdd468960a2f6c.
-
-commit 644898eabc06c8efaa3aa54f84cdd468960a2f6c
-Author: Nigel Croxon
-Date: Wed May 14 09:09:47 2014 -0400
-
- The prototype of DbgPrint() is incorrect, at the end of "inc/efidebug.h".
- Consequently, when your program calls DbgPrint() via the DEBUG() macro,
- it fails to set up the stack correctly (it does not pass the arguments
- through the ellipsis (...) according to the EFIAPI calling convention).
- However, va_start() inside DbgPrint() *assumes* that stack.
-
- Signed-off-by: Laszlo Ersek
- Signed-off-by: Nigel Croxon
-
-commit 8921ba2fc5f6163bdad3b5902c5d9d638415dde0
-Author: Nigel Croxon
-Date: Mon Apr 14 18:49:23 2014 -0400
-
- Cleaned up compile warnings.
-
- Signed-off-by: Nigel Croxon
-
-commit 42cca551dbf1c0be9e02e8d3d3c417ce35749638
-Author: Nigel Croxon
-Date: Mon Apr 14 14:04:11 2014 -0400
-
- Module lib/ParseCmdLine.c has errors, it incorrectly mixes "char" and "CHAR16"
- and uses a pointer to argv[] like it's argv[]. The compiler only issues
- warnings though. Here is a patch to remove compiler warnings and make the
- code behave.
-
- Signed-off-by: Bernard Burette
- Signed-off-by: Nigel Croxon
-
-commit 4e8460f1aedd2724de876be5b154eb5752bfada5
-Author: Nigel Croxon
-Date: Mon Apr 14 13:53:03 2014 -0400
-
- Here is a very small patch to remove a compiler warning when processing lib/smbios.c.
-
- Signed-off-by: Bernard Burette
- Signed-off-by: Nigel Croxon
-
-commit 6a0875ca2fcb67e7d1a1e2d15f3bcc645329dc75
-Author: Nigel Croxon
-Date: Mon Apr 14 13:45:16 2014 -0400
-
- Here is a very small patch to remove compiler warning in function
- "LibLocateHandleByDiskSignature()" because the "Start" variable is
- give a value which is not used.
-
- Signed-off-by: Bernard Burette
- Signed-off-by: Nigel Croxon
-
-commit d5f35dfb8008ba65bcc641559accd9bc13386ef9
-Author: Nigel Croxon
-Date: Mon Apr 14 13:40:29 2014 -0400
-
- Here is a very small patch to remove *~ files in include diretory.
-
- Signed-off-by: Bernard Burette
- Signed-off-by: Nigel Croxon
-
-commit 1a04669a7bb022984c9b54a0f73d7d67a2540fb7
-Author: Nigel Croxon
-Date: Mon Apr 14 12:45:57 2014 -0400
-
- Here is a patch for "DevicePathToStr()" to display device path according to UEFI 2 specification.
- The path is in the two files inc/efidevp.h and lib/dpath.c.
-
- It also add the Sata device path and removes the "/?" path for unknown device paths.
-
- Signed-off-by: Bernard Burette
- Signed-off-by: Nigel Croxon
-
-commit 3c62e78556aea01e9798380cd46794c6ca09d4bd
-Author: Nigel Croxon
-Date: Tue Apr 1 10:26:44 2014 -0400
-
- Removed GPL code setjmp_ia32.S, setjmp_ia64.S, setjmp_x86_64.S
- Not used anymore.
-
- Signed-off-by: Nigel Croxon
-
-commit f9baa4f622cf34576d73e00d4a774a31f0f81fd7
-Author: Nigel Croxon
-Date: Mon Mar 31 08:37:56 2014 -0400
-
- Remove incumbent GPL 'debian' subdiretory.
- Update ChangeLog
-
- Signed-off-by: Nigel Croxon
-
-
-Changelog format change from here and above to 'git log' style.
-
-2014-04-01 Nigel Croxon
-
- Removed GPL code setjmp_ia32.S, setjmp_ia64.S, setjmp_x86_64.S
- Not used anymore.
-
- Signed-off-by: Nigel Croxon
-
-2014-03-17 Nigel Croxon
-
- Add support for the simple pointer and absolute pointer protocols
-
- Signed-off-by: John Cronin
- Signed-off-by: Nigel Croxon
-
-2014-03-14 Nigel Croxon
-
- Trying to recurse into subdirectories of object files may lead
- to an error if the directory doesn't exist. Even when cleaning.
-
- Signed-off-by: Sylvain Gault
- Signed-off-by: Nigel Croxon
-
-2014-03-14 Nigel Croxon
-
- Make install used to copy files unconditionnally to their
- destination. However, if the destination is used by another
- Makefile, it will always see modified files. "install" target
- now only updates the files when they need to.
-
- Signed-off-by: Sylvain Gault
- Signed-off-by: Nigel Croxon
-
-2014-02-13 Nigel Croxon
-
- Patch GNU-EFI to remove the ELILO code
-
- Signed-off-by: Jerry Hoemann
- Signed-off-by: Nigel Croxon
-
-2014-02-13 Nigel Croxon
-
- Initialize Status before calling GrowBuffer()
- Status must be initialized before calling GrowBuffer() as it may
- otherwise be uninitialized or set to EFI_BUFFER_TOO_SMALL by
- other functions.
-
- Signed-off-by: Gene Cumm
- Signed-off-by: Nigel Croxon
-
-2014-01-23 Nigel Croxon
-
- These changes allow manually overridden SRCDIR (current source
- directory) and TOPDIR (top of source tree) to separate the
- build directory from the source tree.
-
- Signed-off-by: Gene Cumm
- Signed-off-by: Nigel Croxon
-
-2014-01-16 Nigel Croxon
- compilation: fix uninitialized variables warning
-
- Signed-off-by: Jeremy Compostella
- Signed-off-by: Nigel Croxon
-
-2014-01-13 Nigel Croxon
- Implement VSPrint function, prints a formatted unicode string to a buffer.
-
- Signed-off-by: Jeremy Compostella
- Signed-off-by: Nigel Croxon
-
-2014-01-10 Nigel Croxon
- Created lib/argify.c and inc/argify.h containing the function argify.
- It contains verbatim copy of the comment at beginning of file from
- elilo.
- There was no COPYING file in the elilo source that the comment refers to.
-
- Signed-off-by: Jerry Hoemann
- Signed-off-by: Nigel Croxon
-
-2014-01-08 Nigel Croxon
- The information needed is not really the host architecture as given by
- the kernel arch. The information actually needed is the default target
- of gcc.
-
- Signed-off-by: Sylvain Gault
- Signed-off-by: Nigel Croxon
-
-2013-10-11 Nigel Croxon
- Added support for SetVariable to store volatile variable,
- and SetNVVariable to store non volatile variable.
-
- Signed-off-by: Sylvain Chouleur
- Signed-off-by: Nigel Croxon
-
-2013-10-07 Nigel Croxon
-
- Atoi needs to have consistent declaration/definition.
-
- Signed-off-by: Nigel Croxon
-
-2013-10-07 Nigel Croxon
- if you have a function that takes const arguments and then
- e.g. tries to copy StrCmp, gcc will give you warnings about those
- calls, and the warnings are right. These clutter up other things
- you might miss that you should be more concered about.
-
- You could work around it through vigorous typecasting
- to non-const types, but why should you have to? All of these
- functions are regorously defined as not changing their input
- - it is const, and should be marked as such.
-
- Signed-off-by: Peter Jones
-
-2013-10-02 Nigel Croxon
-
- Added two simple applications to allocate/free memory at EFI.
- Used to test/find memory fragmentation issues linux.
-
- Signed-off-by: Jerry Hoemann
- Signed-off-by: Nigel Croxon
-
-2013-06-25 Nigel Croxon
- Sample boot service driver.
-
- Signed-off-by: David Decotigny
-
-2013-06-25 Nigel Croxon
-Date: Tue Jun 25 08:47:03 2013 -0400
-
- Be more pedantic when linking, don't allow duplicate symbols,
- abort upon first error. Also make sure linker script comes
- last for apps.
-
- Signed-off-by: David Decotigny