forked from jnode/jnode
-
Notifications
You must be signed in to change notification settings - Fork 0
Boot Sequence
opencode-agent[bot] edited this page May 11, 2026
·
2 revisions
JNode boots from GRUB via Multiboot, transitions through x86 assembly setup to Java's
Main.vmMain(), which initializes the VM and starts plugins.
The boot sequence has three major phases:
-
Native bootstrap — GRUB →
kernel.asm→ CPU/memory setup -
VM initialization —
VmSystem.initialize()brings up the Java runtime -
Plugin startup —
Main.vmMain()loads and starts system plugins
The boot image is a Multiboot-compliant ELF binary built by BootImageBuilder. GRUB loads it and jumps to sys_start in kernel.asm with:
-
EAX = 0x2BADB002(Multiboot magic) -
EBX= pointer to Multiboot info structure
| File | core/src/native/x86/kernel.asm |
|---|
sys_start → real_start:
1. Set up kernel stack (Lkernel_esp)
2. Clear screen
3. Verify Multiboot magic (0x2BADB002)
4. Copy Multiboot info block
5. Detect CPU features (CPUID)
6. Set up GDT, IDT
7. Enable paging (mm32.asm / mm64.asm)
8. Jump to VM entry point
| File | Role |
|---|---|
kernel.asm |
Main entry, Multiboot header, CPU init |
mm32.asm |
32-bit memory management, page tables |
mm64.asm |
64-bit memory management, page tables |
cpu.asm / cpu32.asm
|
CPU detection, feature flags |
ints.asm / ints32.asm / ints64.asm
|
Interrupt descriptor table, IRQ handlers |
console.asm |
Early VGA text console output |
ap-boot.asm |
Application processor bootstrap (SMP) |
| File | core/src/core/org/jnode/vm/VmSystem.java |
|---|
Called from Main.vmMain(). Sets up:
-
Boot logging —
BootLogInstancefor early console output -
System classloader —
VmSystemClassLoaderwith pre-loaded boot classes -
System properties —
java.home,os.name, etc. - Memory manager — Heap initialization, GC setup
-
Scheduler —
VmSchedulerstarts the idle thread and timer -
I/O system — Console streams (
System.out,System.err) -
Log4j — Sets up logging via
ConsoleAppender
| File | core/src/core/org/jnode/boot/Main.java |
|---|
After VmSystem.initialize():
-
Load initjar —
InitJarProcessorextracts plugin JARs and descriptors from the embedded init-jar -
Create PluginManager —
DefaultPluginManagermanages the plugin lifecycle -
Start system plugins —
piMgr.startSystemPlugins(descriptors)activates all plugins in dependency order -
Launch main class — Reads
Main-Classfrom the plugin list manifest (typicallyorg.jnode.shell.CommandShell) and invokes itsmain()method
Plugins are started in dependency order. The default plugin list (all/conf/default-plugin-list.xml) specifies:
- Core classpath extensions (
org.classpath.ext.*) - Driver framework (
org.jnode.driver) - Block devices and partitions
- Filesystem service
- Console and input drivers
- Shell and commands
- Network stack (if included)
- GUI (if included)
| Annotation | Effect |
|---|---|
@Uninterruptible |
Method must not be interrupted (no GC safepoints) |
@LoadStatics |
Static fields are initialized at boot time, not build time |
@SharedStatics |
Static fields are shared across all isolates |
@KernelSpace |
Method runs in kernel context |
Main.vmMain() is annotated with both @LoadStatics and @Uninterruptible because it runs before the scheduler and GC are fully operational.
-
Build time vs. boot time —
BootImageBuilderpre-compiles classes and serializes static fields into the image.@LoadStaticsmarks fields that should be re-initialized at actual boot rather than using build-time values. -
pluginRegistry —
Main.pluginRegistryis set byBootImageBuilder.initMain()during image creation, not at runtime. -
No exceptions before VmSystem.initialize() — The exception handling machinery isn't ready until the VM is initialized. Early boot code uses
Unsafe.debug()for output. -
The initjar — This is a nested archive inside the boot image containing all plugin JARs. It's created by the build process and accessed via
VmSystem.getInitJar().
- Architecture — Where boot fits in the system layers
-
Assembly-Files — Detailed role of each
.asmfile - Plugin-System — How plugins are loaded and started
- Build-System — How the boot image is created
- VM-Magic — Boot-critical annotations
- NoCloseInputStream — InputStream decorator for shared streams