Skip to content

Commit b2fed5a

Browse files
update limine from 10.1.1 to 11.4.1
1 parent 1691610 commit b2fed5a

10 files changed

Lines changed: 1573 additions & 1286 deletions

build-usb.php

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
const VOL_LABEL = 'RETROROCKET';
1616
const HEADROOM_MB = 64;
1717

18-
19-
2018
if (!is_file(LIMINE_BIN) || !is_executable(LIMINE_BIN)) {
2119
chdir(LIMINE_DIR);
2220
run('env -u MAKEFLAGS -u MFLAGS -u MAKELEVEL make -j1 CC="/usr/bin/gcc -B/usr/bin/" >/dev/null');
@@ -25,6 +23,7 @@
2523
throw new RuntimeException("limine build failed: missing or non-executable '" . LIMINE_BIN . "'");
2624
}
2725
}
26+
2827
function run(string $cmd, array $env = []): void {
2928
$proc = proc_open($cmd, [1=>['pipe','w'], 2=>['pipe','w']], $pipes, null, $env + $_ENV);
3029
if (!is_resource($proc)) {
@@ -70,37 +69,50 @@ function align_up(int $x, int $a): int {
7069
$sector_size = 512;
7170
$start_lba = 2048;
7271
$offset_bytes = $start_lba * $sector_size;
73-
$total_sectors = intdiv($img_bytes, $sector_size);
74-
$part_sectors = $total_sectors - $start_lba;
7572

7673
if (is_file(OUT_IMG)) {
7774
unlink(OUT_IMG);
7875
}
79-
run(sprintf("truncate -s %d %s", $img_bytes, escapeshellarg(OUT_IMG)));
8076

81-
$sfdisk_spec = <<<EOT
82-
label: dos
83-
unit: sectors
77+
run(sprintf("truncate -s %d %s", $img_bytes, escapeshellarg(OUT_IMG)));
8478

85-
${start_lba} ${part_sectors} ef *
86-
EOT;
79+
run(sprintf("sgdisk -o -a 1 -n 1:34:2047 -t 1:ef02 -n 2:%d:0 -t 2:ef00 %s", $start_lba, escapeshellarg(OUT_IMG)));
80+
run(sprintf("sgdisk --hybrid 2:EE %s", escapeshellarg(OUT_IMG)));
81+
run(sprintf("printf 'a\n1\nw\n' | fdisk %s", escapeshellarg(OUT_IMG)));
8782

88-
$spec_tmp = tempnam(sys_get_temp_dir(), 'sfdisk_');
89-
file_put_contents($spec_tmp, $sfdisk_spec);
90-
run(sprintf("sfdisk %s < %s", escapeshellarg(OUT_IMG), escapeshellarg($spec_tmp)));
91-
@unlink($spec_tmp);
9283
$env = ['MTOOLS_SKIP_CHECK' => '1'];
84+
9385
run(sprintf("mformat -i %s@@%d -F -v %s ::", escapeshellarg(OUT_IMG), $offset_bytes, escapeshellarg(VOL_LABEL)), $env);
86+
9487
$img_spec = escapeshellarg(OUT_IMG . '@@' . (string)$offset_bytes);
88+
9589
run("mmd -i $img_spec ::/EFI", $env);
9690
run("mmd -i $img_spec ::/EFI/BOOT", $env);
91+
9792
run(sprintf("mcopy -i %s %s ::/EFI/BOOT/BOOTX64.EFI", $img_spec, escapeshellarg(LIMINE_DIR . '/BOOTX64.EFI')), $env);
9893
run(sprintf("mcopy -i %s %s ::/limine-bios.sys", $img_spec, escapeshellarg(LIMINE_DIR . '/limine-bios.sys')), $env);
99-
run(sprintf("mcopy -i %s %s ::/kernel.bin", $img_spec, escapeshellarg(KERNEL_BIN)), $env);
100-
run(sprintf("mcopy -i %s %s ::/kernel.sym", $img_spec, escapeshellarg(KERNEL_SYM)), $env);
101-
run(sprintf("mcopy -i %s %s ::/root.iso.gz", $img_spec, escapeshellarg($root_gz)), $env);
94+
run(sprintf("mcopy -i %s %s ::/kernel.bin", $img_spec, escapeshellarg(KERNEL_BIN)), $env);
95+
run(sprintf("mcopy -i %s %s ::/kernel.sym", $img_spec, escapeshellarg(KERNEL_SYM)), $env);
96+
run(sprintf("mcopy -i %s %s ::/root.iso.gz", $img_spec, escapeshellarg($root_gz)), $env);
10297
run(sprintf("mcopy -i %s %s ::/limine.conf", $img_spec, escapeshellarg(LIMINE_CONF)), $env);
103-
run(sprintf("%s bios-install %s", escapeshellarg(LIMINE_BIN), escapeshellarg(OUT_IMG)));
98+
99+
// Install BIOS bootloader
100+
//run(sprintf("%s bios-install %s", escapeshellarg(LIMINE_BIN), escapeshellarg(OUT_IMG)));
101+
run(sprintf("%s bios-install %s 1", escapeshellarg(LIMINE_BIN), escapeshellarg(OUT_IMG)));
102+
103+
$fp = fopen(OUT_IMG, 'r+b');
104+
if ($fp === false) {
105+
throw new RuntimeException("failed to open image for MBR boot flag update");
106+
}
107+
if (fseek($fp, 446) !== 0) {
108+
fclose($fp);
109+
throw new RuntimeException("failed to seek to MBR partition entry");
110+
}
111+
if (fwrite($fp, "\x80") !== 1) {
112+
fclose($fp);
113+
throw new RuntimeException("failed to write MBR boot flag");
114+
}
115+
fclose($fp);
104116

105117
$mb = (int) round($img_bytes / (1024 * 1024));
106-
echo "USB image created: " . OUT_IMG . " (" . $mb . " MB)\n";
118+
echo "USB image created: " . OUT_IMG . " (" . $mb . " MB)\n";

limine/BOOTX64.EFI

64 KB
Binary file not shown.

limine/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2019-2025 Mintsuki and contributors.
1+
Copyright (C) 2019-2026 Mintsuki and contributors.
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

limine/Makefile

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,18 @@
22

33
SHELL=/bin/sh
44

5-
CC=/usr/bin/gcc
5+
CC=cc
66
CFLAGS=-g -O2 -pipe
77
CPPFLAGS=
88
LDFLAGS=
99
LIBS=
10-
LD=$(CC)
11-
12-
STRIP=strip
13-
INSTALL=./install-sh
14-
15-
PREFIX=/usr/local
1610

1711
.PHONY: all
1812
all: limine
1913

20-
.PHONY: install
21-
install: all
22-
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/share'
23-
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/share/limine'
24-
$(INSTALL) -m 644 limine-bios.sys '$(DESTDIR)$(PREFIX)/share/limine/'
25-
$(INSTALL) -m 644 limine-bios-cd.bin '$(DESTDIR)$(PREFIX)/share/limine/'
26-
$(INSTALL) -m 644 limine-uefi-cd.bin '$(DESTDIR)$(PREFIX)/share/limine/'
27-
$(INSTALL) -m 644 limine-bios-pxe.bin '$(DESTDIR)$(PREFIX)/share/limine/'
28-
$(INSTALL) -m 644 BOOTX64.EFI '$(DESTDIR)$(PREFIX)/share/limine/'
29-
$(INSTALL) -m 644 BOOTIA32.EFI '$(DESTDIR)$(PREFIX)/share/limine/'
30-
$(INSTALL) -m 644 BOOTAA64.EFI '$(DESTDIR)$(PREFIX)/share/limine/'
31-
$(INSTALL) -m 644 BOOTRISCV64.EFI '$(DESTDIR)$(PREFIX)/share/limine/'
32-
$(INSTALL) -m 644 BOOTLOONGARCH64.EFI '$(DESTDIR)$(PREFIX)/share/limine/'
33-
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/include'
34-
$(INSTALL) -m 644 limine.h '$(DESTDIR)$(PREFIX)/include/'
35-
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/bin'
36-
$(INSTALL) limine '$(DESTDIR)$(PREFIX)/bin/'
37-
38-
.PHONY: install-strip
39-
install-strip: install
40-
$(STRIP) '$(DESTDIR)$(PREFIX)/bin/limine'
41-
4214
.PHONY: clean
4315
clean:
4416
rm -f limine limine.exe
4517

4618
limine: limine.c
4719
$(CC) $(CFLAGS) -std=c99 $(CPPFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
48-

limine/limine-bios-cd.bin

2 KB
Binary file not shown.

0 commit comments

Comments
 (0)