Compare commits
45 Commits
v2.2.1-bin
...
v2.33-bina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5cfd6710d | ||
|
|
a4be378fad | ||
|
|
f024767359 | ||
|
|
7deacc5dc4 | ||
|
|
df3429aeb4 | ||
|
|
f3df8c34ca | ||
|
|
4a250dd367 | ||
|
|
239a9cad62 | ||
|
|
97be83460a | ||
|
|
2862a26145 | ||
|
|
57f875ff80 | ||
|
|
00bbd375d9 | ||
|
|
9249b5058e | ||
|
|
8aeca4502a | ||
|
|
3ac3c7acba | ||
|
|
e076a3a94f | ||
|
|
9f837d47f2 | ||
|
|
ef6e9305fb | ||
|
|
e9312ed0d6 | ||
|
|
463c2658dd | ||
|
|
33c5b0d1fc | ||
|
|
2d5b927e9e | ||
|
|
fe885fdf97 | ||
|
|
7efd20e4db | ||
|
|
d0c389d185 | ||
|
|
22afa3656b | ||
|
|
fb56f9d681 | ||
|
|
ab4119ce7d | ||
|
|
9357e39c0e | ||
|
|
436ab302d8 | ||
|
|
278a5be490 | ||
|
|
3b3198b5d5 | ||
|
|
9702acab01 | ||
|
|
50a6c0228e | ||
|
|
d7e1cccd49 | ||
|
|
38a17c5653 | ||
|
|
1648873a11 | ||
|
|
6a5c7fb13a | ||
|
|
c934aa50bb | ||
|
|
e1c6ab55e6 | ||
|
|
ed690885b9 | ||
|
|
11414ed6e3 | ||
|
|
8423a5007f | ||
|
|
0c98d680e8 | ||
|
|
d8ba22b093 |
BIN
BOOTX64.EFI
BIN
BOOTX64.EFI
Binary file not shown.
29
Makefile
29
Makefile
@@ -4,7 +4,6 @@ OBJCOPY = objcopy
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
|
||||
OBJCOPY_ARCH = default
|
||||
LIMINE_HDD_BIN = limine-hdd.bin
|
||||
BUILD_DIR = $(shell realpath .)
|
||||
|
||||
@@ -15,22 +14,18 @@ CFLAGS = -O2 -pipe -Wall -Wextra
|
||||
all: limine-install
|
||||
|
||||
install: all
|
||||
install -d $(DESTDIR)$(PREFIX)/bin
|
||||
install -s limine-install $(DESTDIR)$(PREFIX)/bin/
|
||||
install -d $(DESTDIR)$(PREFIX)/share
|
||||
install -d $(DESTDIR)$(PREFIX)/share/limine
|
||||
install -m 644 limine.sys $(DESTDIR)$(PREFIX)/share/limine/
|
||||
install -m 644 limine-cd.bin $(DESTDIR)$(PREFIX)/share/limine/
|
||||
install -m 644 limine-eltorito-efi.bin $(DESTDIR)$(PREFIX)/share/limine/
|
||||
install -m 644 limine-pxe.bin $(DESTDIR)$(PREFIX)/share/limine/
|
||||
install -m 644 BOOTX64.EFI $(DESTDIR)$(PREFIX)/share/limine/
|
||||
install -d "$(DESTDIR)$(PREFIX)/bin"
|
||||
install -s limine-install "$(DESTDIR)$(PREFIX)/bin/"
|
||||
install -d "$(DESTDIR)$(PREFIX)/share"
|
||||
install -d "$(DESTDIR)$(PREFIX)/share/limine"
|
||||
install -m 644 limine.sys "$(DESTDIR)$(PREFIX)/share/limine/"
|
||||
install -m 644 limine-cd.bin "$(DESTDIR)$(PREFIX)/share/limine/"
|
||||
install -m 644 limine-eltorito-efi.bin "$(DESTDIR)$(PREFIX)/share/limine/" || true
|
||||
install -m 644 limine-pxe.bin "$(DESTDIR)$(PREFIX)/share/limine/"
|
||||
install -m 644 BOOTX64.EFI "$(DESTDIR)$(PREFIX)/share/limine/"
|
||||
|
||||
clean:
|
||||
rm -f limine-hdd.o limine-install limine-install.exe
|
||||
rm -f limine-install limine-install.exe
|
||||
|
||||
limine-install: limine-install.c limine-hdd.o
|
||||
$(CC) $(CFLAGS) -std=c11 $^ -o $@
|
||||
|
||||
limine-hdd.o: $(LIMINE_HDD_BIN)
|
||||
cd `dirname $^` && \
|
||||
$(OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) `basename $^` $(BUILD_DIR)/$@
|
||||
limine-install: limine-install.c inc.S $(LIMINE_HDD_BIN)
|
||||
$(CC) $(CFLAGS) -std=c11 -DLIMINE_HDD_BIN='"$(LIMINE_HDD_BIN)"' limine-install.c inc.S -o $@
|
||||
|
||||
33
inc.S
Normal file
33
inc.S
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#if defined (__APPLE__)
|
||||
|
||||
.data
|
||||
.global __binary_limine_hdd_bin_start
|
||||
__binary_limine_hdd_bin_start:
|
||||
.incbin LIMINE_HDD_BIN
|
||||
.global __binary_limine_hdd_bin_end
|
||||
__binary_limine_hdd_bin_end:
|
||||
|
||||
#elif defined (__MINGW32__)
|
||||
|
||||
.section .data
|
||||
.global __binary_limine_hdd_bin_start
|
||||
__binary_limine_hdd_bin_start:
|
||||
.incbin LIMINE_HDD_BIN
|
||||
.global __binary_limine_hdd_bin_end
|
||||
__binary_limine_hdd_bin_end:
|
||||
|
||||
#elif defined (__linux__) || defined (__unix__)
|
||||
|
||||
#if defined (__ELF__)
|
||||
.section .note.GNU-stack, "", %progbits
|
||||
#endif
|
||||
|
||||
.section .data
|
||||
.global _binary_limine_hdd_bin_start
|
||||
_binary_limine_hdd_bin_start:
|
||||
.incbin LIMINE_HDD_BIN
|
||||
.global _binary_limine_hdd_bin_end
|
||||
_binary_limine_hdd_bin_end:
|
||||
|
||||
#endif
|
||||
BIN
limine-cd.bin
BIN
limine-cd.bin
Binary file not shown.
Binary file not shown.
BIN
limine-hdd.bin
BIN
limine-hdd.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
139
limine-install.c
139
limine-install.c
@@ -261,23 +261,14 @@ static bool _device_write(const void *buffer, uint64_t loc, size_t count) {
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#ifdef __MINGW32__
|
||||
extern uint8_t binary_limine_hdd_bin_start[], binary_limine_hdd_bin_end[];
|
||||
#else
|
||||
extern uint8_t _binary_limine_hdd_bin_start[], _binary_limine_hdd_bin_end[];
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ok = 1;
|
||||
#ifdef __MINGW32__
|
||||
uint8_t *bootloader_img = binary_limine_hdd_bin_start;
|
||||
size_t bootloader_file_size =
|
||||
(size_t)binary_limine_hdd_bin_end - (size_t)binary_limine_hdd_bin_start;
|
||||
#else
|
||||
int force_mbr = 0;
|
||||
uint8_t *bootloader_img = _binary_limine_hdd_bin_start;
|
||||
size_t bootloader_file_size =
|
||||
(size_t)_binary_limine_hdd_bin_end - (size_t)_binary_limine_hdd_bin_start;
|
||||
#endif
|
||||
uint8_t orig_mbr[70], timestamp[6];
|
||||
|
||||
if (sizeof(off_t) != 8) {
|
||||
@@ -290,6 +281,12 @@ int main(int argc, char *argv[]) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
if (strcmp(argv[2], "--force-mbr") == 0) {
|
||||
force_mbr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
device = open(argv[1], O_RDWR);
|
||||
if (device == -1) {
|
||||
perror("ERROR");
|
||||
@@ -307,10 +304,15 @@ int main(int argc, char *argv[]) {
|
||||
for (size_t i = 0; i < sizeof(lb_guesses) / sizeof(uint64_t); i++) {
|
||||
device_read(&gpt_header, lb_guesses[i], sizeof(struct gpt_table_header));
|
||||
if (!strncmp(gpt_header.signature, "EFI PART", 8)) {
|
||||
gpt = 1;
|
||||
lb_size = lb_guesses[i];
|
||||
fprintf(stderr, "Installing to GPT. Logical block size of %" PRIu64 " bytes.\n",
|
||||
lb_guesses[i]);
|
||||
if (!force_mbr) {
|
||||
gpt = 1;
|
||||
fprintf(stderr, "Installing to GPT. Logical block size of %" PRIu64 " bytes.\n",
|
||||
lb_guesses[i]);
|
||||
} else {
|
||||
memset(&gpt_header, 0, sizeof(struct gpt_table_header));
|
||||
device_write(&gpt_header, lb_guesses[i], sizeof(struct gpt_table_header));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -336,45 +338,108 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
uint16_t hint = 0;
|
||||
device_read(&hint, 218, sizeof(uint16_t));
|
||||
if (hint != 0)
|
||||
mbr = 0;
|
||||
if (hint != 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = 0;
|
||||
device_write(&hint, 218, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
device_read(&hint, 444, sizeof(uint16_t));
|
||||
if (hint != 0 && hint != 0x5a5a)
|
||||
mbr = 0;
|
||||
if (hint != 0 && hint != 0x5a5a) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = 0;
|
||||
device_write(&hint, 444, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
device_read(&hint, 510, sizeof(uint16_t));
|
||||
if (hint != 0xaa55)
|
||||
mbr = 0;
|
||||
if (hint != 0xaa55) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = 0xaa55;
|
||||
device_write(&hint, 510, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
device_read(&hint, 446, sizeof(uint8_t));
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80)
|
||||
mbr = 0;
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = (uint8_t)hint & 0x80 ? 0x80 : 0x00;
|
||||
device_write(&hint, 446, sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
device_read(&hint, 462, sizeof(uint8_t));
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80)
|
||||
mbr = 0;
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = (uint8_t)hint & 0x80 ? 0x80 : 0x00;
|
||||
device_write(&hint, 462, sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
device_read(&hint, 478, sizeof(uint8_t));
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80)
|
||||
mbr = 0;
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = (uint8_t)hint & 0x80 ? 0x80 : 0x00;
|
||||
device_write(&hint, 478, sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
device_read(&hint, 494, sizeof(uint8_t));
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80)
|
||||
mbr = 0;
|
||||
if ((uint8_t)hint != 0x00 && (uint8_t)hint != 0x80) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = (uint8_t)hint & 0x80 ? 0x80 : 0x00;
|
||||
device_write(&hint, 494, sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
|
||||
char hintc[64];
|
||||
device_read(hintc, 4, 8);
|
||||
if (memcmp(hintc, "_ECH_FS_", 8) == 0)
|
||||
mbr = 0;
|
||||
if (memcmp(hintc, "_ECH_FS_", 8) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 8);
|
||||
device_write(hintc, 4, 8);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 54, 3);
|
||||
if (memcmp(hintc, "FAT", 3) == 0)
|
||||
mbr = 0;
|
||||
if (memcmp(hintc, "FAT", 3) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 5);
|
||||
device_write(hintc, 54, 5);
|
||||
}
|
||||
}
|
||||
device_read(&hint, 1080, sizeof(uint16_t));
|
||||
if (hint == 0xef53)
|
||||
mbr = 0;
|
||||
if (hint == 0xef53) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
hint = 0;
|
||||
device_write(&hint, 1080, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gpt == 0 && mbr == 0) {
|
||||
fprintf(stderr, "ERROR: Could not determine if the device has a valid partition table.\n");
|
||||
fprintf(stderr, " Please ensure the device has a valid MBR or GPT.\n");
|
||||
fprintf(stderr, " Alternatively, pass `--force-mbr` at the end of the command to\n");
|
||||
fprintf(stderr, " override these checks. ONLY DO THIS AT YOUR OWN RISK, DATA LOSS\n");
|
||||
fprintf(stderr, " MAY OCCUR!\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -421,7 +486,7 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "GPT partition NOT specified. Attempting GPT embedding.\n");
|
||||
|
||||
ssize_t max_partition_entry_used = -1;
|
||||
for (ssize_t i = 0; i < gpt_header.number_of_partition_entries; i++) {
|
||||
for (ssize_t i = 0; i < (ssize_t)gpt_header.number_of_partition_entries; i++) {
|
||||
struct gpt_entry gpt_entry;
|
||||
device_read(&gpt_entry,
|
||||
(gpt_header.partition_entry_lba * lb_size)
|
||||
@@ -541,9 +606,9 @@ int main(int argc, char *argv[]) {
|
||||
if (!device_flush_cache())
|
||||
goto cleanup;
|
||||
|
||||
fprintf(stderr, "WARNING: Remember to copy the limine.sys file in either\n"
|
||||
" the root or /boot directories of one of the partitions\n"
|
||||
" on the device, or boot will fail!\n");
|
||||
fprintf(stderr, "Reminder: Remember to copy the limine.sys file in either\n"
|
||||
" the root or /boot directories of one of the partitions\n"
|
||||
" on the device, or boot will fail!\n");
|
||||
|
||||
fprintf(stderr, "Limine installed successfully!\n");
|
||||
|
||||
|
||||
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.sys
BIN
limine.sys
Binary file not shown.
Reference in New Issue
Block a user