Skip to content

Assembly Files

Levente Santha edited this page May 9, 2026 · 1 revision

Assembly Files

While JNode is primarily written in Java, low-level bootstrapping, CPU initialization, and core OS primitives require native x86 assembly. These files are assembled by JNasm during the build process.

Location

All assembly files are located in core/src/native/x86/.

The Boot Sequence

These files are executed before the Java Virtual Machine is fully operational.

FileRole
kernel.asmThe absolute entry point. Contains the Multiboot header recognized by GRUB. Sets up the initial kernel stack, parses multiboot parameters, and transitions into the VM.
ap-boot.asmApplication Processor bootstrap. Used for initializing secondary CPU cores in an SMP (Symmetric Multiprocessing) system.
console.asmEarly VGA text-mode console. Used for raw debug output (Unsafe.debug()) before the Java-level System.out and GUI console are ready.

Memory Management (Paging)

These files handle the raw hardware-level memory initialization.

FileRole
mm32.asm32-bit memory management. Sets up the Global Descriptor Table (GDT), Task State Segment (TSS), and initial 32-bit page tables (4KB and 4MB pages). Enables paging.
mm64.asm64-bit memory management. Sets up the Page Map Level 4 (PML4) tables and transitions the CPU from 32-bit protected mode into 64-bit long mode.

Interrupts & Traps

Hardware interrupts and CPU exceptions (like page faults) are caught here before being routed to Java.

FileRole
ints.asmCore interrupt handling setup. Constructs the Interrupt Descriptor Table (IDT).
ints32.asm / ints64.asm32-bit / 64-bit specific interrupt service routines (ISRs) and trap handlers.
vm-ints.asmBridges the gap between raw hardware interrupts (caught in ints.asm) and the Java-level org.jnode.vm.scheduler.IRQManager. Handles context saving before jumping to Java.

CPU & System Details

FileRole
cpu.asm / cpu32.asmDetects CPU features using the CPUID instruction and handles basic CPU control register manipulation.
syscall.asmFast system call entry point (SYSENTER / SYSCALL). Currently experimental or reserved for future use.
kdb.asmVery low-level kernel debugger stubs.
jnode.asm / version.asmMacros and version strings baked into the binary.

VM Support & Unsafe Operations

These files provide native implementations for operations that cannot be expressed in pure Java or require direct processor access.

FileRole
vm.asmCore VM native methods. Includes the vm_invoke routine used for dynamically invoking Java methods from native code.
unsafe.asmNative implementations for org.jnode.vm.Unsafe. Includes atomic operations (CAS), raw memory reads/writes, and I/O port instructions (IN, OUT).
unsafe-binop.asmNative binary operations (like atomic adds).
unsafe-setmulti.asmNative block memory operations (like memset or memcpy).
unsafex86.asmx86-specific unsafe operations.
unsafex86-cpuid.asmCPUID instruction wrapper for Java.
unsafex86-mm.asmNative memory management operations (flushing TLB, reading CR2 for page faults).

Headers (.h files)

JNasm supports basic C-style macros and includes.

FileRole
i386.h / i386_bits.hDefinitions for x86 control registers (CR0, CR4), EFLAGS bits, and page fault error codes.
console.hMacros for printing strings and hex values in early boot.
rmconfig.hConfiguration constants.

Related Pages

  • Boot-Sequence — How kernel.asm and mm32.asm orchestrate the boot process.
  • Memory-Management — How the hardware paging interacts with Java heaps.
  • VM-Magic — How Unsafe operations in Java translate to unsafe.asm routines.

Clone this wiki locally