Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e7459fd
* Ke, Ldr, Mm: A bunch of cleanups in preparation of adding ARM code.
iProgramMC Dec 25, 2025
02e18fb
* Add armv6 toolchain and base stuff.
iProgramMC Dec 25, 2025
668695f
* Mm: Fix PFN construction for write faults.
iProgramMC Dec 25, 2025
7514dfc
* Mm: Implement MmAllocatePhysicalContiguousRegion.
iProgramMC Dec 26, 2025
32ac31e
* Now compiles for ARM, but doesn't link!
iProgramMC Dec 26, 2025
48d2ac8
* Armv6: Add beginning of hardware-specific Ke parts
iProgramMC Dec 26, 2025
2b24b2f
* Some more work on armv6 support.
iProgramMC Dec 27, 2025
978b156
* Mm: Map exception handlers to 0xFFFF0000
iProgramMC Dec 28, 2025
9e9851a
* Significantly more armv6 port, still doesn't link, still need to se…
iProgramMC Dec 30, 2025
06b9b08
* Implement interrupt handling properly.
iProgramMC Dec 30, 2025
a9bb805
* Slight rearchitecture, we're supposed to preserve these values acro…
iProgramMC Dec 30, 2025
9409fd9
* Implement debug-related stubs, SWI stub, HAL interrupt interface
iProgramMC Dec 30, 2025
21dfceb
* First successful link of the kernel! (Not tested)
iProgramMC Dec 30, 2025
bc7aa59
* Mm: Update PFN DB mapping code to be a bit more crossplatform.
iProgramMC Dec 30, 2025
3e5fa2e
* A bunch more ARM fixes
iProgramMC Dec 30, 2025
63d5a64
* More armv6 memory fixes. Turns out I was in armv5 backwards compat …
iProgramMC Dec 30, 2025
372c46c
* Mm(armv6): Fix pool headers not being mapped properly.
iProgramMC Dec 30, 2025
39e24e2
* Ke: Remove accidentally uncovered debug print for page faults
iProgramMC Dec 30, 2025
f6a78b0
* Armv6: Switch to raspi1ap board
iProgramMC Dec 30, 2025
c709a5f
* Make a fat disk image instead of an ISO
iProgramMC Dec 31, 2025
5fed099
* Add raspi1ap hal (currently built into kernel for testing)
iProgramMC Dec 31, 2025
5f43adb
* Provide placeholders for functions inside the hal
iProgramMC Dec 31, 2025
8011920
* Mm: Use MM_PTE_ISPRESENT macro instead of AND-ing with MM_PTE_PRESENT
iProgramMC Dec 31, 2025
648df06
* Switch back to versatilepb.
iProgramMC Dec 31, 2025
c15f5b6
* Some uncommitted changes for the new year.
iProgramMC Jan 4, 2026
f5a6e5c
* Rename armv6 to arm, prepare for armv5 support too.
iProgramMC Jan 30, 2026
f2c9050
* One more thing to update
iProgramMC Jan 30, 2026
5ae7b09
* Implement armv5 replacements for unsupported operations.
iProgramMC Jan 31, 2026
4a3e016
* Small fixes to some functions.
iProgramMC Jan 31, 2026
f93ab2b
* Add versatilepb HAL, CLCD framebuffer init, and more.
iProgramMC Jan 31, 2026
d5f4404
* Mm: Rename MM_PTE_CDISABLE to MM_PTE_NOCACHE.
iProgramMC Jan 31, 2026
2aa511c
* Fix now that we merged with master
iProgramMC Jan 31, 2026
0d822fa
Merge branch 'master' of github.com:iProgramMC/Boron into arm-port-new
iProgramMC Feb 1, 2026
4c9cda3
* HalVersatilepb: Add terminal support
iProgramMC Feb 1, 2026
d366981
* Correct memory amount.
iProgramMC Feb 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ USER_DIR = user
ISO_DIR = $(BUILD_DIR)/iso_root

# The ISO target.
IMAGE_TARGET = $(BUILD_DIR)/../image.$(TARGETL).iso
IMAGE_TARGET ?= $(BUILD_DIR)/../image.$(TARGETL).iso

# The init ramdisk directory.
INITRD_DIR = $(BUILD_DIR)/initrd_root
Expand Down
26 changes: 22 additions & 4 deletions boron/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ LINKER_FILE = linker.$(TARGETL).ld
ISO_DIR=$(BUILD_DIR)/iso_root
IMAGE_TARGET=$(BUILD_DIR)/image.iso

ifeq ($(TARGET),AMD64)
GENERATE_SYMBOLS = 1
else ifeq ($(TARGET),I386)
GENERATE_SYMBOLS = 1
else
GENERATE_SYMBOLS = 0
endif

# This is the name that our final kernel executable will have.
# Change as needed.
override KERNEL := $(BUILD_DIR)/kernel.$(TARGETL).elf
Expand Down Expand Up @@ -150,10 +158,10 @@ NASMFLAGS += $(ARCH_ASFLAGS)

# Use find to glob all *.c, *.S, and *.asm files in the directory and extract the object names.
EXCLUDE_WRONG_ARCH = '(' '(' -path 'source/ke/$(TARGETL)/*' ')' -o '(' -path 'source/mm/$(TARGETL)/*' ')' -o '(' -not -path 'source/ke/*/*' -not -path 'source/mm/*/*' ')' ')'
override CFILES := $(shell find $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.c')
override CXXFILES := $(shell find $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.cpp')
override ASFILES := $(shell find $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.S')
override NASMFILES := $(shell find $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.asm')
override CFILES := $(shell find -L $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.c')
override CXXFILES := $(shell find -L $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.cpp')
override ASFILES := $(shell find -L $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.S')
override NASMFILES := $(shell find -L $(SRC_DIR) -not -path '*/.*' $(EXCLUDE_WRONG_ARCH) -type f -name '*.asm')
override OBJ := $(patsubst %.o,%.$(TARGETL).o,$(patsubst $(SRC_DIR)/%,$(BUILD_DIR)/%,$(CFILES:.c=.o) $(CXXFILES:.cpp=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o)))
override HEADER_DEPS := $(patsubst %.o,%.d,$(OBJ))

Expand All @@ -175,6 +183,8 @@ VER_BUILD = $(shell cat $(BUILD_NUMBER_FILE))
CFLAGS += -D__BORON_MAJOR=$(VER_MAJOR) -D__BORON_MINOR=$(VER_MINOR) -D__BORON_BUILD=$(VER_BUILD)

# Link rules for the final kernel executable.
ifeq ($(GENERATE_SYMBOLS),1)

$(KERNEL): $(SYMBOLS)
@echo "[LD]\tBuilding $(KERNEL)"
@$(BLD) $(OBJ) $(SYMBOLS) $(LDFLAGS) -o $@
Expand All @@ -193,6 +203,14 @@ $(KERNEL_PARTIAL): $(OBJ) $(LINKER_FILE)
@echo "[LD]\tPartially linking kernel"
@$(BLD) -m $(LINK_ARCH) -r $(OBJ) $(LDFLAGSBASE) -o $@

else

$(KERNEL): $(OBJ) $(LINKER_FILE)
@echo "[LD]\tLinking kernel"
@$(BLD) $(OBJ) $(LDFLAGS) -o $@

endif

$(BUILD_DIR)/ke/version.$(TARGETL).o: $(filter-out $(BUILD_DIR)/ke/version.$(TARGETL).o, $(OBJ)) $(SRC_DIR)/ke/version.c
@echo "[CC]\tCompiling $(SRC_DIR)/ke/version.c"
@mkdir -p $(dir $@)
Expand Down
62 changes: 62 additions & 0 deletions boron/address_space_arm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
BORON Operating System Address Space (i386)

** Kernel Mode **

+------------------------------+ - 0xFFFFFFFF
| virtually linear page tables |
+------------------------------+ - 0xFF800000
| unused |
+------------------------------+ - 0xF0000000
| more dynamic pool space |
+------------------------------+ - 0xE0000000
| unused |
+------------------------------+ - 0xD8000000
| page frame data base |
+------------------------------+ - 0xD4000000
| system module DLLs |
+------------------------------+ - 0xD2000000
| unused |
+------------------------------+ - 0xD1900000
| map of UART MMIO |
+------------------------------+ - 0xD1800000
| pool header slab magazines |
+------------------------------+ - 0xD1000000
| fast mapping in 16MB windows |
+------------------------------+ - 0xD0000000
| map of first 256 MB of phys |
| kernel code & data |
+------------------------------+ - 0xC0000000
| dynamic pool space |
+------------------------------+ - 0x80000000
| higher half direct map |
+------------------------------+ - 0x00000000

Notes:
- if we use the multiboot boot protocol, then "kernel code & data" really means "first 8MB of physical memory"

** User Mode **

Currently this is nothing more than a plan.
Now, a user process has complete control over its own
address space. (They will even be able to unmap the
PEB/TEBs if they want as well!)

However, this is the plan for normal user processes.

+-----------------------------+ - 0x80000000
| process environment block |
+-----------------------------+ - 0x7ffe0000
| thread environment blocks |
+-----------------------------+ - 0x7fe00000
| operating system DLLs |
+-----------------------------+ - 0x78000000
| thread stacks |
+-----------------------------+ - 0x70000000
| user DLLs |
+-----------------------------+ - 0x60000000
| user heap + mappings |
+-----------------------------+ - 0x10000000
| program executable |
+-----------------------------+ - 0x00001000
| |
+-----------------------------+ - 0x00000000
29 changes: 4 additions & 25 deletions boron/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,20 @@
#include <arch/amd64.h>
#elif defined TARGET_I386
#include <arch/i386.h>
#elif defined TARGET_ARM
#include <arch/arm.h>
#else
#error Define your architecture here!
#endif

// ==== Forward declarations. Depending on the platform, we'll include platform specific definitions. ====
typedef struct KREGISTERS_tag KREGISTERS, *PKREGISTERS; // List of registers.

// Functions that do different things based on architecture,
// but exist everywhere
#if defined TARGET_AMD64 || defined TARGET_I386

FORCE_INLINE
void KeWaitForNextInterrupt(void)
{
ASM("hlt":::"memory");
}

FORCE_INLINE
void KeSpinningHint(void)
{
ASM("pause":::"memory");
}

FORCE_INLINE
void KeInvalidatePage(void* Address)
{
ASM("invlpg (%0)"::"r"((uintptr_t)Address):"memory");
}

#else

void KeWaitForNextInterrupt(void);
void KeSpinningHint(void);
void KeInvalidatePage(void* Page);

#endif

void KeSetCPUPointer(void* CpuPointer);
void* KeGetCPUPointer(void);
uintptr_t KeGetCurrentPageTable(void);
Expand Down
28 changes: 25 additions & 3 deletions boron/include/arch/amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,28 @@ MMADDRESS_CONVERT;
#define MM_PTE_READWRITE (1ULL << 1)
#define MM_PTE_USERACCESS (1ULL << 2)
#define MM_PTE_WRITETHRU (1ULL << 3)
#define MM_PTE_CDISABLE (1ULL << 4)
#define MM_PTE_NOCACHE (1ULL << 4)
#define MM_PTE_ACCESSED (1ULL << 5)
#define MM_PTE_DIRTY (1ULL << 6)
#define MM_PTE_PAT (1ULL << 7)
#define MM_PTE_PAGESIZE (1ULL << 7) // in terms of PML3/PML2 entries, for 1GB/2MB pages respectively. Not Used by the kernel
#define MM_PTE_GLOBAL (1ULL << 8) // doesn't invalidate the pages from the TLB when CR3 is changed
#define MM_PTE_ISFROMPMM (1ULL << 9) // if the allocated memory is managed by the PFN database
#define MM_PTE_COW (1ULL << 10) // if this page is to be copied after a write -- TODO: We are supposed to be phasing this one out.
#define MM_PTE_COW (1ULL << 10) // if this page is to be copied after a write (UNUSED)
#define MM_PTE_TRANSITION (1ULL << 11) // if this page is in transition (3) (UNUSED)
#define MM_PTE_NOEXEC (1ULL << 63) // aka eXecute Disable
#define MM_PTE_PKMASK (15ULL<< 59) // protection key mask. We will not use it.
#define MM_PTE_ISPOOLHDR (1ULL << 58) // if the PTE actually contains the address of a pool entry (subtracted MM_KERNEL_SPACE_BASE from it) (NOTE: This is supposed to be MM_DPTE_ISPOOLHDR)

#define MM_PTE_ADDRESSMASK (0x000FFFFFFFFFF000) // description of the other bits that aren't 1 in the mask:
// 63 - execute disable
// 62..59 - protection key (unused)
// 58..52 - more available bits

#define MM_PTE_PFN(Pte) (((Pte) & MM_PTE_ADDRESSMASK) / PAGE_SIZE)
#define MM_PTE_NEWPFN(Pfn) (((Pfn) * PAGE_SIZE) & MM_PTE_ADDRESSMASK)

#define MM_PTE_CHECKFROMPMM(Pte) ((Pte) & MM_PTE_ISFROMPMM)
#define MM_PTE_ISPRESENT(Pte) (((Pte) & MM_PTE_PRESENT) != 0)

// Disabled PTE (present bit is zero):
// bits 0..2 and 63 - Permission bits as usual
Expand All @@ -112,6 +115,7 @@ MMADDRESS_CONVERT;
#define MM_DPTE_COMMITTED (1ULL << 8)
#define MM_DPTE_BACKEDBYFILE (1ULL << 9)
#define MM_DPTE_SWAPPED (1ULL << 10)
#define MM_DPTE_ISPOOLHDR (1ULL << 58) // if the PTE actually contains the address of a pool entry (subtracted MM_KERNEL_SPACE_BASE from it)
#define MM_DPTE_WASPRESENT (1ULL << 62)

// Page fault reasons
Expand Down Expand Up @@ -294,4 +298,22 @@ KARCH_DATA, *PKARCH_DATA;
#include <arch/x86cpuid.h>
#include <arch/x86cr.h>

FORCE_INLINE
void KeWaitForNextInterrupt(void)
{
ASM("hlt":::"memory");
}

FORCE_INLINE
void KeSpinningHint(void)
{
ASM("pause":::"memory");
}

FORCE_INLINE
void KeInvalidatePage(void* Address)
{
ASM("invlpg (%0)"::"r"((uintptr_t)Address):"memory");
}

#endif//NS64_ARCH_AMD64_H
Loading