host: Condense various host utilities into a single executable

This commit is contained in:
mintsuki 2023-04-11 22:04:05 +02:00
parent eba0183b6e
commit 7ad444936e
15 changed files with 340 additions and 450 deletions

View File

@ -41,26 +41,14 @@ jobs:
- name: Build the bootloader
run: make -C build
- name: Clean limine-version
run: rm build/bin/limine-version
- name: Clean limine
run: rm build/bin/limine
- name: Clean limine-enroll-config
run: rm build/bin/limine-enroll-config
- name: Build limine for Windows
run: make -C build/bin CC="i686-w64-mingw32-gcc" CFLAGS="-O2 -pipe" CPPFLAGS="-D__USE_MINGW_ANSI_STDIO" limine
- name: Build limine-enroll-config-win32
run: make -C build/bin CC="i686-w64-mingw32-gcc" CFLAGS="-O2 -pipe" CPPFLAGS="-D__USE_MINGW_ANSI_STDIO" limine-enroll-config
- name: Strip limine-enroll-config-win32
run: i686-w64-mingw32-strip build/bin/limine-enroll-config.exe
- name: Clean limine-deploy
run: rm build/bin/limine-deploy
- name: Build limine-deploy-win32
run: make -C build/bin CC="i686-w64-mingw32-gcc" CFLAGS="-O2 -pipe" CPPFLAGS="-D__USE_MINGW_ANSI_STDIO" limine-deploy
- name: Strip limine-deploy-win32
run: i686-w64-mingw32-strip build/bin/limine-deploy.exe
- name: Strip limine for Windows
run: i686-w64-mingw32-strip build/bin/limine.exe
- name: Copy LICENSE to bin
run: cp LICENSE build/bin/

4
.gitignore vendored
View File

@ -33,9 +33,7 @@
/config.status
/config.log
/autom4te.cache
/man/man1/limine-version.1
/man/man1/limine-deploy.1
/man/man1/limine-enroll-config.1
/man/man1/limine.1
/GNUmakefile
/config.h
/common-bios

View File

@ -41,7 +41,6 @@ override BUILD_UEFI_AARCH64 := @BUILD_UEFI_AARCH64@
override BUILD_CD_EFI := @BUILD_CD_EFI@
override BUILD_PXE := @BUILD_PXE@
override BUILD_CD := @BUILD_CD@
override BUILD_LIMINE_DEPLOY := @BUILD_LIMINE_DEPLOY@
$(eval $(call DEFAULT_VAR,CC,@CC@))
export CC
@ -95,40 +94,31 @@ all: $(call MKESCAPE,$(BINDIR))/Makefile
$(MAKE) all1
.PHONY: all1
all1: limine-version limine-enroll-config $(BUILD_UEFI_X86_64) $(BUILD_UEFI_IA32) $(BUILD_UEFI_AARCH64) $(BUILD_BIOS)
all1: $(BUILD_UEFI_X86_64) $(BUILD_UEFI_IA32) $(BUILD_UEFI_AARCH64) $(BUILD_BIOS)
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine'
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin'
$(call MKESCAPE,$(BINDIR))/limine-hdd.h: $(call MKESCAPE,$(BINDIR))/limine-hdd.bin
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cd '$(call SHESCAPE,$(BINDIR))' && '$(call SHESCAPE,$(SRCDIR))/host/hgen.sh' >limine-hdd.h
$(call MKESCAPE,$(BINDIR))/limine-deploy: $(call MKESCAPE,$(BINDIR))/Makefile $(call MKESCAPE,$(SRCDIR))/host/limine-deploy.c $(call MKESCAPE,$(BINDIR))/limine-hdd.h
cp '$(call SHESCAPE,$(SRCDIR))/host/limine-deploy.c' '$(call SHESCAPE,$(BINDIR))/'
$(MAKE) -C '$(call SHESCAPE,$(BINDIR))' limine-deploy
ifeq ($(BUILD_BIOS),limine-bios)
$(call MKESCAPE,$(BINDIR))/limine: $(call MKESCAPE,$(BINDIR))/Makefile $(call MKESCAPE,$(SRCDIR))/host/limine.c $(call MKESCAPE,$(BINDIR))/limine-hdd.h
else
override LIMINE_NO_BIOS := -DLIMINE_NO_BIOS
$(call MKESCAPE,$(BINDIR))/limine-version: $(call MKESCAPE,$(BINDIR))/Makefile $(call MKESCAPE,$(SRCDIR))/host/limine-version.c
$(SED) 's/@LIMINE_VERSION@/@PACKAGE_VERSION@/g' <'$(call SHESCAPE,$(SRCDIR))/host/limine-version.c' >'$(call SHESCAPE,$(BINDIR))/limine-version.c'
$(MAKE) -C '$(call SHESCAPE,$(BINDIR))' limine-version
$(call MKESCAPE,$(BINDIR))/limine-enroll-config: $(call MKESCAPE,$(BINDIR))/Makefile $(call MKESCAPE,$(SRCDIR))/host/limine-enroll-config.c
cp '$(call SHESCAPE,$(SRCDIR))/host/limine-enroll-config.c' '$(call SHESCAPE,$(BINDIR))/'
$(MAKE) -C '$(call SHESCAPE,$(BINDIR))' limine-enroll-config
$(call MKESCAPE,$(BINDIR))/limine: $(call MKESCAPE,$(BINDIR))/Makefile $(call MKESCAPE,$(SRCDIR))/host/limine.c
endif
$(SED) 's/@LIMINE_VERSION@/@PACKAGE_VERSION@/g' <'$(call SHESCAPE,$(SRCDIR))/host/limine.c' >'$(call SHESCAPE,$(BINDIR))/limine.c'
CPPFLAGS="$(CPPFLAGS) $(LIMINE_NO_BIOS)" $(MAKE) -C '$(call SHESCAPE,$(BINDIR))' limine
$(call MKESCAPE,$(BINDIR))/Makefile: $(call MKESCAPE,$(SRCDIR))/host/Makefile $(call MKESCAPE,$(SRCDIR))/host/.gitignore
mkdir -p '$(call SHESCAPE,$(BINDIR))'
cp '$(call SHESCAPE,$(SRCDIR))/host/Makefile' '$(call SHESCAPE,$(SRCDIR))/host/.gitignore' '$(call SHESCAPE,$(BINDIR))/'
.PHONY: limine-deploy
limine-deploy:
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-deploy'
.PHONY: limine-version
limine-version:
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-version'
.PHONY: limine-enroll-config
limine-enroll-config:
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-enroll-config'
.PHONY: limine
limine:
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine'
.PHONY: clean
clean: limine-bios-clean limine-uefi-ia32-clean limine-uefi-x86-64-clean limine-uefi-aarch64-clean
@ -143,11 +133,7 @@ install: all
$(INSTALL_DATA) '$(call SHESCAPE,$(SRCDIR))/PHILOSOPHY.md' '$(call SHESCAPE,$(DESTDIR)$(docdir))/'
$(INSTALL_DATA) '$(call SHESCAPE,$(SRCDIR))/README.md' '$(call SHESCAPE,$(DESTDIR)$(docdir))/'
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1'
$(INSTALL_DATA) '$(call SHESCAPE,$(BUILDDIR))/man/man1/limine-version.1' '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/'
ifneq ($(BUILD_LIMINE_DEPLOY),no)
$(INSTALL_DATA) '$(call SHESCAPE,$(BUILDDIR))/man/man1/limine-deploy.1' '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/'
endif
$(INSTALL_DATA) '$(call SHESCAPE,$(BUILDDIR))/man/man1/limine-enroll-config.1' '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/'
$(INSTALL_DATA) '$(call SHESCAPE,$(BUILDDIR))/man/man1/limine.1' '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/'
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(datarootdir))'
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/limine'
ifeq ($(BUILD_BIOS),limine-bios)
@ -174,19 +160,11 @@ endif
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(includedir))'
$(INSTALL_DATA) '$(call SHESCAPE,$(SRCDIR))/limine.h' '$(call SHESCAPE,$(DESTDIR)$(includedir))/'
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(bindir))'
$(INSTALL_PROGRAM) '$(call SHESCAPE,$(BINDIR))/limine-version' '$(call SHESCAPE,$(DESTDIR)$(bindir))/'
$(INSTALL_PROGRAM) '$(call SHESCAPE,$(BINDIR))/limine-enroll-config' '$(call SHESCAPE,$(DESTDIR)$(bindir))/'
ifneq ($(BUILD_LIMINE_DEPLOY),no)
$(INSTALL_PROGRAM) '$(call SHESCAPE,$(BINDIR))/limine-deploy' '$(call SHESCAPE,$(DESTDIR)$(bindir))/'
endif
$(INSTALL_PROGRAM) '$(call SHESCAPE,$(BINDIR))/limine' '$(call SHESCAPE,$(DESTDIR)$(bindir))/'
.PHONY: install-strip
install-strip: install
@NATIVE_STRIP@ '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-version'
@NATIVE_STRIP@ '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-enroll-config'
ifneq ($(BUILD_LIMINE_DEPLOY),no)
@NATIVE_STRIP@ '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-deploy'
endif
@NATIVE_STRIP@ '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine'
.PHONY: uninstall
uninstall:
@ -195,12 +173,8 @@ uninstall:
rm -f '$(call SHESCAPE,$(DESTDIR)$(docdir))/PROTOCOL.md'
rm -f '$(call SHESCAPE,$(DESTDIR)$(docdir))/PHILOSOPHY.md'
rm -f '$(call SHESCAPE,$(DESTDIR)$(docdir))/README.md'
rm -f '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/limine-version.1'
rm -f '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/limine-deploy.1'
rm -f '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/limine-enroll-config.1'
rm -f '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-version'
rm -f '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-enroll-config'
rm -f '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine-deploy'
rm -f '$(call SHESCAPE,$(DESTDIR)$(mandir))/man1/limine.1'
rm -f '$(call SHESCAPE,$(DESTDIR)$(bindir))/limine'
rm -rf '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/limine'
rm -f '$(call SHESCAPE,$(DESTDIR)$(includedir))/limine.h'
@ -219,9 +193,6 @@ endif
.PHONY: limine-bios
limine-bios: common-bios decompressor
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp'
ifneq ($(BUILD_LIMINE_DEPLOY),no)
$(MAKE) limine-deploy
endif
$(call MKESCAPE,$(BINDIR))/limine-cd-efi.bin: $(if $(BUILD_UEFI_IA32),$(call MKESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI) $(if $(BUILD_UEFI_X86_64),$(call MKESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI) $(if $(BUILD_UEFI_AARCH64),$(call MKESCAPE,$(BUILDDIR))/common-uefi-aarch64/BOOTAA64.EFI)
ifneq ($(BUILD_CD_EFI),no)
@ -321,7 +292,7 @@ dist:
.PHONY: distclean
distclean: clean
rm -rf ovmf* config.log config.status GNUmakefile config.h toolchain-files man/man1/limine-version.1 man/man1/limine-deploy.1 man/man1/limine-enroll-config.1
rm -rf ovmf* config.log config.status GNUmakefile config.h toolchain-files man/man1/limine.1
.PHONY: maintainer-clean
maintainer-clean: distclean

View File

@ -62,7 +62,7 @@ or, to clone a specific binary point release (for example `v4.20230120.0`)
git clone https://github.com/limine-bootloader/limine.git --branch=v4.20230120.0-binary --depth=1
```
In order to rebuild host utilities like `limine-deploy`, simply run `make` in the binary
In order to rebuild host utilities like `limine`, simply run `make` in the binary
release directory.
Host utility binaries are provided for Windows.
@ -136,14 +136,14 @@ partitions, formatted with a supported file system (the ESP partition is recomme
Limine can be booted with secure boot using shim. This will also allow one to enroll
the BLAKE2B hash of the Limine config file into the Limine EFI executable image itself for
verification purposes.
For more information see the `limine-enroll-config` program and [the philosophy](/PHILOSOPHY.md).
For more information see the `limine enroll-config` program and [the philosophy](/PHILOSOPHY.md).
### BIOS/MBR
In order to install Limine on a MBR device (which can just be a raw image file),
run `limine-deploy` as such:
run `limine bios-install` as such:
```bash
limine-deploy <path to device/image>
limine bios-install <path to device/image>
```
The boot device must contain the `limine.sys` and `limine.cfg` files in
@ -154,18 +154,18 @@ partitions, formatted with a supported file system.
If using a GPT formatted device, there are 2 options one can follow for
installation:
* Specifying a dedicated stage 2 partition.
* Letting `limine-deploy` attempt to embed stage 2 within GPT structures.
* Letting `limine bios-install` attempt to embed stage 2 within GPT structures.
In case one wants to specify a stage 2 partition, create a partition on the GPT
device of at least 32KiB in size, and pass the 1-based number of the partition
to `limine-deploy` as a second argument; such as:
to `limine bios-install` as a second argument; such as:
```bash
limine-deploy <path to device/image> <1-based stage 2 partition number>
limine bios-install <path to device/image> <1-based stage 2 partition number>
```
In case one wants to let `limine-deploy` embed stage 2 within GPT's structures,
simply omit the partition number, and invoke `limine-deploy` the same as one
In case one wants to let `limine bios-install` embed stage 2 within GPT's structures,
simply omit the partition number, and invoke `limine bios-install` the same as one
would do for an MBR partitioned device.
The boot device must contain the `limine.sys` and `limine.cfg` files in
@ -192,9 +192,9 @@ xorriso -as mkisofs -b <relative path of limine-cd.bin> \
*Note: `xorriso` is required.*
And do not forget to also run `limine-deploy` on the generated image:
And do not forget to also run `limine bios-install` on the generated image:
```
limine-deploy image.iso
limine bios-install image.iso
```
`<relative path of limine-cd.bin>` is the relative path of

View File

@ -91,8 +91,6 @@ AC_ARG_ENABLE([bios],
[AS_HELP_STRING([--enable-bios], [enable building the x86 BIOS port])],
[BUILD_BIOS="$enableval"])
BUILD_LIMINE_DEPLOY="$BUILD_BIOS"
if test "x$BUILD_BIOS" = "xno"; then
if test "x$BUILD_CD" = "xyes"; then
BUILD_BIOS="yes"
@ -127,7 +125,6 @@ else
fi
AC_SUBST([BUILD_BIOS])
AC_SUBST([BUILD_LIMINE_DEPLOY])
BUILD_UEFI_IA32="$BUILD_ALL"
@ -276,5 +273,5 @@ if ! test "$SRCDIR" = "$BUILDDIR"; then
cp "$SRCDIR/limine.h" "$BUILDDIR/"
fi
AC_CONFIG_FILES([man/man1/limine-version.1 man/man1/limine-deploy.1 man/man1/limine-enroll-config.1 GNUmakefile config.h])
AC_CONFIG_FILES([man/man1/limine.1 GNUmakefile config.h])
AC_OUTPUT

8
host/.gitignore vendored
View File

@ -1,6 +1,2 @@
limine-deploy
limine-deploy.exe
limine-version
limine-version.exe
limine-enroll-config
limine-enroll-config.exe
limine
limine.exe

View File

@ -7,7 +7,7 @@ PREFIX ?= /usr/local
CFLAGS ?= -g -O2 -pipe
.PHONY: all
all: limine-deploy limine-version limine-enroll-config
all: limine
.PHONY: install
install: all
@ -22,27 +22,15 @@ install: all
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/include'
$(INSTALL) -m 644 limine.h '$(DESTDIR)$(PREFIX)/include/'
$(INSTALL) -d '$(DESTDIR)$(PREFIX)/bin'
$(INSTALL) limine-deploy '$(DESTDIR)$(PREFIX)/bin/'
$(INSTALL) limine-version '$(DESTDIR)$(PREFIX)/bin/'
$(INSTALL) limine-enroll-config '$(DESTDIR)$(PREFIX)/bin/'
$(INSTALL) limine '$(DESTDIR)$(PREFIX)/bin/'
.PHONY: install-strip
install-strip: install
$(STRIP) '$(DESTDIR)$(PREFIX)/bin/limine-deploy'
$(STRIP) '$(DESTDIR)$(PREFIX)/bin/limine-version'
$(STRIP) '$(DESTDIR)$(PREFIX)/bin/limine-enroll-config'
$(STRIP) '$(DESTDIR)$(PREFIX)/bin/limine'
.PHONY: clean
clean:
rm -f limine-deploy limine-deploy.exe
rm -f limine-version limine-version.exe
rm -f limine-enroll-config limine-enroll-config.exe
rm -f limine limine.exe
limine-deploy: limine-deploy.c limine-hdd.h
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-deploy.c $(LIBS) -o $@
limine-version: limine-version.c
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-version.c $(LIBS) -o $@
limine-enroll-config: limine-enroll-config.c
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-enroll-config.c $(LIBS) -o $@
limine: limine.c
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine.c $(LIBS) -o $@

View File

@ -1,143 +0,0 @@
#undef IS_WINDOWS
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define IS_WINDOWS 1
#endif
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CONFIG_B2SUM_SIGNATURE "++CONFIG_B2SUM_SIGNATURE++"
static void usage(const char *name) {
printf("Usage: %s <Limine executable> <BLAKE2B of config file>\n", name);
printf("\n");
printf(" --reset Remove enrolled BLAKE2B, will not check config intergrity\n");
printf("\n");
printf(" --quiet Do not print verbose diagnostic messages\n");
printf("\n");
printf(" --help | -h Display this help message\n");
printf("\n");
}
static void remove_arg(int *argc, char *argv[], int index) {
for (int i = index; i < *argc - 1; i++) {
argv[i] = argv[i + 1];
}
(*argc)--;
argv[*argc] = NULL;
}
int main(int argc, char *argv[]) {
int ret = EXIT_FAILURE;
char *bootloader = NULL;
FILE *bootloader_file = NULL;
bool quiet = false;
bool reset = false;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
usage(argv[0]);
return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--quiet") == 0) {
remove_arg(&argc, argv, i);
quiet = true;
} else if (strcmp(argv[i], "--reset") == 0) {
remove_arg(&argc, argv, i);
reset = true;
}
}
if (argc <= (reset ? 1 : 2)) {
usage(argv[0]);
#ifdef IS_WINDOWS
system("pause");
#endif
return EXIT_FAILURE;
}
if (!reset && strlen(argv[2]) != 128) {
fprintf(stderr, "ERROR: BLAKE2B specified is not 128 characters long\n");
goto cleanup;
}
bootloader_file = fopen(argv[1], "r+b");
if (bootloader_file == NULL) {
perror("ERROR");
goto cleanup;;
}
if (fseek(bootloader_file, 0, SEEK_END) != 0) {
perror("ERROR");
goto cleanup;
}
size_t bootloader_size = ftell(bootloader_file);
rewind(bootloader_file);
bootloader = malloc(bootloader_size);
if (bootloader == NULL) {
perror("ERROR");
goto cleanup;
}
if (fread(bootloader, bootloader_size, 1, bootloader_file) != 1) {
perror("ERROR");
goto cleanup;
}
char *checksum_loc = NULL;
size_t checked_count = 0;
const char *config_b2sum_sign = CONFIG_B2SUM_SIGNATURE;
for (size_t i = 0; i < bootloader_size - ((sizeof(CONFIG_B2SUM_SIGNATURE) - 1) + 128) + 1; i++) {
if (bootloader[i] != config_b2sum_sign[checked_count]) {
checked_count = 0;
continue;
}
checked_count++;
if (checked_count == sizeof(CONFIG_B2SUM_SIGNATURE) - 1) {
checksum_loc = &bootloader[i + 1];
break;
}
}
if (checksum_loc == NULL) {
fprintf(stderr, "ERROR: Checksum location not found in provided executable\n");
goto cleanup;
}
if (!reset) {
memcpy(checksum_loc, argv[2], 128);
} else {
memset(checksum_loc, '0', 128);
}
if (fseek(bootloader_file, 0, SEEK_SET) != 0) {
perror("ERROR");
goto cleanup;
}
if (fwrite(bootloader, bootloader_size, 1, bootloader_file) != 1) {
perror("ERROR");
goto cleanup;
}
if (!quiet) {
fprintf(stderr, "Config file BLAKE2B successfully %s!\n", reset ? "reset" : "enrolled");
}
ret = EXIT_SUCCESS;
cleanup:
if (bootloader != NULL) {
free(bootloader);
}
if (bootloader_file != NULL) {
fclose(bootloader_file);
}
return ret;
}

View File

@ -1,7 +0,0 @@
#include <stdio.h>
#define LIMINE_VERSION "@LIMINE_VERSION@"
int main(void) {
puts(LIMINE_VERSION);
}

View File

@ -12,7 +12,21 @@
#include <inttypes.h>
#include <limits.h>
#ifndef LIMINE_NO_BIOS
#include "limine-hdd.h"
#endif
static void remove_arg(int *argc, char *argv[], int index) {
for (int i = index; i < *argc - 1; i++) {
argv[i] = argv[i + 1];
}
(*argc)--;
argv[*argc] = NULL;
}
#ifndef LIMINE_NO_BIOS
static bool quiet = false;
@ -265,37 +279,37 @@ static bool device_cache_block(uint64_t block) {
return true;
}
struct undeploy_data {
struct uninstall_data {
void *data;
uint64_t loc;
uint64_t count;
};
#define UNDEPLOY_DATA_MAX 256
#define UNINSTALL_DATA_MAX 256
static bool undeploying = false;
static struct undeploy_data undeploy_data[UNDEPLOY_DATA_MAX];
static struct undeploy_data undeploy_data_rev[UNDEPLOY_DATA_MAX];
static uint64_t undeploy_data_i = 0;
static const char *undeploy_file = NULL;
static bool uninstalling = false;
static struct uninstall_data uninstall_data[UNINSTALL_DATA_MAX];
static struct uninstall_data uninstall_data_rev[UNINSTALL_DATA_MAX];
static uint64_t uninstall_data_i = 0;
static const char *uninstall_file = NULL;
static void reverse_undeploy_data(void) {
for (size_t i = 0, j = undeploy_data_i - 1; i < undeploy_data_i; i++, j--) {
undeploy_data_rev[j] = undeploy_data[i];
static void reverse_uninstall_data(void) {
for (size_t i = 0, j = uninstall_data_i - 1; i < uninstall_data_i; i++, j--) {
uninstall_data_rev[j] = uninstall_data[i];
}
memcpy(undeploy_data, undeploy_data_rev, undeploy_data_i * sizeof(struct undeploy_data));
memcpy(uninstall_data, uninstall_data_rev, uninstall_data_i * sizeof(struct uninstall_data));
}
static void free_undeploy_data(void) {
for (size_t i = 0; i < undeploy_data_i; i++) {
free(undeploy_data[i].data);
static void free_uninstall_data(void) {
for (size_t i = 0; i < uninstall_data_i; i++) {
free(uninstall_data[i].data);
}
}
static bool store_undeploy_data(const char *filename) {
static bool store_uninstall_data(const char *filename) {
if (!quiet) {
fprintf(stderr, "Storing undeploy data to file: `%s`...\n", filename);
fprintf(stderr, "Storing uninstall data to file: `%s`...\n", filename);
}
FILE *udfile = fopen(filename, "wb");
@ -303,18 +317,18 @@ static bool store_undeploy_data(const char *filename) {
goto error;
}
if (fwrite(&undeploy_data_i, sizeof(uint64_t), 1, udfile) != 1) {
if (fwrite(&uninstall_data_i, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
for (size_t i = 0; i < undeploy_data_i; i++) {
if (fwrite(&undeploy_data[i].loc, sizeof(uint64_t), 1, udfile) != 1) {
for (size_t i = 0; i < uninstall_data_i; i++) {
if (fwrite(&uninstall_data[i].loc, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
if (fwrite(&undeploy_data[i].count, sizeof(uint64_t), 1, udfile) != 1) {
if (fwrite(&uninstall_data[i].count, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
if (fwrite(undeploy_data[i].data, undeploy_data[i].count, 1, udfile) != 1) {
if (fwrite(uninstall_data[i].data, uninstall_data[i].count, 1, udfile) != 1) {
goto error;
}
}
@ -330,9 +344,9 @@ error:
return false;
}
static bool load_undeploy_data(const char *filename) {
static bool load_uninstall_data(const char *filename) {
if (!quiet) {
fprintf(stderr, "Loading undeploy data from file: `%s`...\n", filename);
fprintf(stderr, "Loading uninstall data from file: `%s`...\n", filename);
}
FILE *udfile = fopen(filename, "rb");
@ -340,22 +354,22 @@ static bool load_undeploy_data(const char *filename) {
goto error;
}
if (fread(&undeploy_data_i, sizeof(uint64_t), 1, udfile) != 1) {
if (fread(&uninstall_data_i, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
for (size_t i = 0; i < undeploy_data_i; i++) {
if (fread(&undeploy_data[i].loc, sizeof(uint64_t), 1, udfile) != 1) {
for (size_t i = 0; i < uninstall_data_i; i++) {
if (fread(&uninstall_data[i].loc, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
if (fread(&undeploy_data[i].count, sizeof(uint64_t), 1, udfile) != 1) {
if (fread(&uninstall_data[i].count, sizeof(uint64_t), 1, udfile) != 1) {
goto error;
}
undeploy_data[i].data = malloc(undeploy_data[i].count);
if (undeploy_data[i].data == NULL) {
uninstall_data[i].data = malloc(uninstall_data[i].count);
if (uninstall_data[i].data == NULL) {
goto error;
}
if (fread(undeploy_data[i].data, undeploy_data[i].count, 1, udfile) != 1) {
if (fread(uninstall_data[i].data, uninstall_data[i].count, 1, udfile) != 1) {
goto error;
}
}
@ -395,16 +409,16 @@ static bool _device_read(void *_buffer, uint64_t loc, size_t count) {
}
static bool _device_write(const void *_buffer, uint64_t loc, size_t count) {
if (undeploying) {
if (uninstalling) {
goto skip_save;
}
if (undeploy_data_i >= UNDEPLOY_DATA_MAX) {
fprintf(stderr, "Internal error: Too many undeploy data entries!\n");
if (uninstall_data_i >= UNINSTALL_DATA_MAX) {
fprintf(stderr, "Internal error: Too many uninstall data entries!\n");
return false;
}
struct undeploy_data *ud = &undeploy_data[undeploy_data_i];
struct uninstall_data *ud = &uninstall_data[uninstall_data_i];
ud->data = malloc(count);
if (ud->data == NULL) {
@ -441,31 +455,31 @@ skip_save:;
progress += chunk;
}
if (!undeploying) {
undeploy_data_i++;
if (!uninstalling) {
uninstall_data_i++;
}
return true;
}
static void undeploy(void) {
undeploying = true;
static void uninstall(void) {
uninstalling = true;
cache_state = CACHE_CLEAN;
cached_block = (uint64_t)-1;
for (size_t i = 0; i < undeploy_data_i; i++) {
struct undeploy_data *ud = &undeploy_data[i];
for (size_t i = 0; i < uninstall_data_i; i++) {
struct uninstall_data *ud = &uninstall_data[i];
bool retry = false;
while (!_device_write(ud->data, ud->loc, ud->count)) {
if (retry) {
fprintf(stderr, "ERROR: Undeploy data index %zu failed to write. Undeploy may be incomplete!\n", i);
fprintf(stderr, "ERROR: Uninstall data index %zu failed to write. Uninstall may be incomplete!\n", i);
break;
}
if (!quiet) {
fprintf(stderr, "Warning: Undeploy data index %zu failed to write, retrying...\n", i);
fprintf(stderr, "Warning: Uninstall data index %zu failed to write, retrying...\n", i);
}
if (!device_flush_cache()) {
fprintf(stderr, "ERROR: Device cache flush failure. Undeploy may be incomplete!\n");
fprintf(stderr, "ERROR: Device cache flush failure. Uninstall may be incomplete!\n");
}
cache_state = CACHE_CLEAN;
cached_block = (uint64_t)-1;
@ -474,11 +488,11 @@ static void undeploy(void) {
}
if (!device_flush_cache()) {
fprintf(stderr, "ERROR: Device cache flush failure. Undeploy may be incomplete!\n");
fprintf(stderr, "ERROR: Device cache flush failure. Uninstall may be incomplete!\n");
}
if (!quiet) {
fprintf(stderr, "Undeploy data restored successfully. Limine undeployed!\n");
fprintf(stderr, "Uninstall data restored successfully. Limine uninstalled!\n");
}
}
@ -494,17 +508,17 @@ static void undeploy(void) {
goto cleanup; \
} while (0)
static void usage(const char *name) {
printf("Usage: %s <device> [GPT partition index]\n", name);
static void bios_install_usage(const char *name) {
printf("Usage: %s bios-install <device> [GPT partition index]\n", name);
printf("\n");
printf(" --force-mbr Force MBR detection to work even if the\n");
printf(" safety checks fail (DANGEROUS!)\n");
printf("\n");
printf(" --undeploy Reverse the entire deployment procedure\n");
printf(" --uninstall Reverse the entire install procedure\n");
printf("\n");
printf(" --undeploy-data-file=<filename>\n");
printf(" Set the input (for --undeploy) or output file\n");
printf(" name of the file which contains undeploy data\n");
printf(" --uninstall-data-file=<filename>\n");
printf(" Set the input (for --uninstall) or output file\n");
printf(" name of the file which contains uninstall data\n");
printf("\n");
printf(" --quiet Do not print verbose diagnostic messages\n");
printf("\n");
@ -512,10 +526,10 @@ static void usage(const char *name) {
printf("\n");
}
int main(int argc, char *argv[]) {
static int bios_install(int argc, char *argv[]) {
int ok = EXIT_FAILURE;
int force_mbr = 0;
bool undeploy_mode = false;
bool uninstall_mode = false;
const uint8_t *bootloader_img = binary_limine_hdd_bin_data;
size_t bootloader_file_size = sizeof(binary_limine_hdd_bin_data);
uint8_t orig_mbr[70], timestamp[6];
@ -526,7 +540,7 @@ int main(int argc, char *argv[]) {
bigendian = endbyte == 0x12;
if (argc < 2) {
usage(argv[0]);
bios_install_usage(argv[-1]);
#ifdef IS_WINDOWS
system("pause");
#endif
@ -535,7 +549,7 @@ int main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
usage(argv[0]);
bios_install_usage(argv[-1]);
return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--quiet") == 0) {
quiet = true;
@ -544,18 +558,18 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Warning: --force-mbr already set.\n");
}
force_mbr = 1;
} else if (strcmp(argv[i], "--undeploy") == 0) {
if (undeploy_mode && !quiet) {
fprintf(stderr, "Warning: --undeploy already set.\n");
} else if (strcmp(argv[i], "--uninstall") == 0) {
if (uninstall_mode && !quiet) {
fprintf(stderr, "Warning: --uninstall already set.\n");
}
undeploy_mode = true;
} else if (memcmp(argv[i], "--undeploy-data-file=", 21) == 0) {
if (undeploy_file != NULL && !quiet) {
fprintf(stderr, "Warning: --undeploy-data-file already set. Overriding...\n");
uninstall_mode = true;
} else if (memcmp(argv[i], "--uninstall-data-file=", 21) == 0) {
if (uninstall_file != NULL && !quiet) {
fprintf(stderr, "Warning: --uninstall-data-file already set. Overriding...\n");
}
undeploy_file = argv[i] + 21;
if (strlen(undeploy_file) == 0) {
fprintf(stderr, "ERROR: Undeploy data file has a zero-length name!\n");
uninstall_file = argv[i] + 21;
if (strlen(uninstall_file) == 0) {
fprintf(stderr, "ERROR: Uninstall data file has a zero-length name!\n");
return EXIT_FAILURE;
}
} else {
@ -570,28 +584,28 @@ int main(int argc, char *argv[]) {
if (device == NULL) {
fprintf(stderr, "ERROR: No device specified\n");
usage(argv[0]);
bios_install_usage(argv[-1]);
return EXIT_FAILURE;
}
if (!device_init()) {
goto undeploy_mode_cleanup;
goto uninstall_mode_cleanup;
}
if (undeploy_mode) {
if (undeploy_file == NULL) {
fprintf(stderr, "ERROR: Undeploy mode set but no --undeploy-data-file=... passed.\n");
goto undeploy_mode_cleanup;
if (uninstall_mode) {
if (uninstall_file == NULL) {
fprintf(stderr, "ERROR: Uninstall mode set but no --uninstall-data-file=... passed.\n");
goto uninstall_mode_cleanup;
}
if (!load_undeploy_data(undeploy_file)) {
goto undeploy_mode_cleanup;
if (!load_uninstall_data(uninstall_file)) {
goto uninstall_mode_cleanup;
}
undeploy();
uninstall();
ok = EXIT_SUCCESS;
goto undeploy_mode_cleanup;
goto uninstall_mode_cleanup;
}
// Probe for GPT and logical block size
@ -606,7 +620,7 @@ int main(int argc, char *argv[]) {
if (!force_mbr) {
gpt = 1;
if (!quiet) {
fprintf(stderr, "Deploying to GPT. Logical block size of %" PRIu64 " bytes.\n",
fprintf(stderr, "Installing to GPT. Logical block size of %" PRIu64 " bytes.\n",
lb_guesses[i]);
}
} else {
@ -796,7 +810,7 @@ int main(int argc, char *argv[]) {
}
if (!quiet) {
fprintf(stderr, "GPT partition specified. Deploying there instead of embedding.\n");
fprintf(stderr, "GPT partition specified. Installing there instead of embedding.\n");
}
stage2_loc_a = ENDSWAP(gpt_entry.starting_lba) * lb_size;
@ -898,7 +912,7 @@ int main(int argc, char *argv[]) {
}
} else {
if (!quiet) {
fprintf(stderr, "Deploying to MBR.\n");
fprintf(stderr, "Installing to MBR.\n");
}
}
@ -945,21 +959,21 @@ int main(int argc, char *argv[]) {
" the root, /boot, /limine, or /boot/limine directories of\n"
" one of the partitions on the device, or boot will fail!\n");
fprintf(stderr, "Limine deployed successfully!\n");
fprintf(stderr, "Limine BIOS stages installed successfully!\n");
}
ok = EXIT_SUCCESS;
cleanup:
reverse_undeploy_data();
reverse_uninstall_data();
if (ok != EXIT_SUCCESS) {
// If we failed, attempt to reverse deploy process
undeploy();
} else if (undeploy_file != NULL) {
store_undeploy_data(undeploy_file);
// If we failed, attempt to reverse install process
uninstall();
} else if (uninstall_file != NULL) {
store_uninstall_data(uninstall_file);
}
undeploy_mode_cleanup:
free_undeploy_data();
uninstall_mode_cleanup:
free_uninstall_data();
if (cache)
free(cache);
if (device != NULL)
@ -967,3 +981,168 @@ undeploy_mode_cleanup:
return ok;
}
#endif
#define CONFIG_B2SUM_SIGNATURE "++CONFIG_B2SUM_SIGNATURE++"
static void enroll_config_usage(const char *name) {
printf("Usage: %s enroll-config <Limine executable> <BLAKE2B of config file>\n", name);
printf("\n");
printf(" --reset Remove enrolled BLAKE2B, will not check config intergrity\n");
printf("\n");
printf(" --quiet Do not print verbose diagnostic messages\n");
printf("\n");
printf(" --help | -h Display this help message\n");
printf("\n");
}
static int enroll_config(int argc, char *argv[]) {
int ret = EXIT_FAILURE;
char *bootloader = NULL;
FILE *bootloader_file = NULL;
bool quiet = false;
bool reset = false;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
enroll_config_usage(argv[-1]);
return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--quiet") == 0) {
remove_arg(&argc, argv, i);
quiet = true;
} else if (strcmp(argv[i], "--reset") == 0) {
remove_arg(&argc, argv, i);
reset = true;
}
}
if (argc <= (reset ? 1 : 2)) {
enroll_config_usage(argv[-1]);
#ifdef IS_WINDOWS
system("pause");
#endif
return EXIT_FAILURE;
}
if (!reset && strlen(argv[2]) != 128) {
fprintf(stderr, "ERROR: BLAKE2B specified is not 128 characters long\n");
goto cleanup;
}
bootloader_file = fopen(argv[1], "r+b");
if (bootloader_file == NULL) {
perror("ERROR");
goto cleanup;;
}
if (fseek(bootloader_file, 0, SEEK_END) != 0) {
perror("ERROR");
goto cleanup;
}
size_t bootloader_size = ftell(bootloader_file);
rewind(bootloader_file);
bootloader = malloc(bootloader_size);
if (bootloader == NULL) {
perror("ERROR");
goto cleanup;
}
if (fread(bootloader, bootloader_size, 1, bootloader_file) != 1) {
perror("ERROR");
goto cleanup;
}
char *checksum_loc = NULL;
size_t checked_count = 0;
const char *config_b2sum_sign = CONFIG_B2SUM_SIGNATURE;
for (size_t i = 0; i < bootloader_size - ((sizeof(CONFIG_B2SUM_SIGNATURE) - 1) + 128) + 1; i++) {
if (bootloader[i] != config_b2sum_sign[checked_count]) {
checked_count = 0;
continue;
}
checked_count++;
if (checked_count == sizeof(CONFIG_B2SUM_SIGNATURE) - 1) {
checksum_loc = &bootloader[i + 1];
break;
}
}
if (checksum_loc == NULL) {
fprintf(stderr, "ERROR: Checksum location not found in provided executable\n");
goto cleanup;
}
if (!reset) {
memcpy(checksum_loc, argv[2], 128);
} else {
memset(checksum_loc, '0', 128);
}
if (fseek(bootloader_file, 0, SEEK_SET) != 0) {
perror("ERROR");
goto cleanup;
}
if (fwrite(bootloader, bootloader_size, 1, bootloader_file) != 1) {
perror("ERROR");
goto cleanup;
}
if (!quiet) {
fprintf(stderr, "Config file BLAKE2B successfully %s!\n", reset ? "reset" : "enrolled");
}
ret = EXIT_SUCCESS;
cleanup:
if (bootloader != NULL) {
free(bootloader);
}
if (bootloader_file != NULL) {
fclose(bootloader_file);
}
return ret;
}
#define LIMINE_VERSION "@LIMINE_VERSION@"
static int version(void) {
puts(LIMINE_VERSION);
return EXIT_SUCCESS;
}
static void general_usage(const char *name) {
printf("Usage: %s <command> <args...>\n", name);
printf("\n");
printf("Valid commands: help, version, bios-install, enroll-config\n");
}
int main(int argc, char *argv[]) {
if (argc <= 1) {
general_usage(argv[0]);
return EXIT_FAILURE;
}
if (strcmp(argv[1], "help") == 0
|| strcmp(argv[1], "--help") == 0
|| strcmp(argv[1], "-h") == 0) {
general_usage(argv[0]);
return EXIT_SUCCESS;
} else if (strcmp(argv[1], "bios-install") == 0) {
#ifndef LIMINE_NO_BIOS
return bios_install(argc - 1, &argv[1]);
#else
fprintf(stderr, "ERROR: Limine has been compiled without BIOS support.\n");
return EXIT_FAILURE;
#endif
} else if (strcmp(argv[1], "enroll-config") == 0) {
return enroll_config(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "version") == 0) {
return version();
}
general_usage(argv[0]);
return EXIT_FAILURE;
}

View File

@ -1,39 +0,0 @@
.TH LIMINE-DEPLOY 1 "version @PACKAGE_VERSION@" "@REGEN_DATE@"
.SH NAME
limine-deploy \- install BIOS port's early stages to device
.SH SYNOPSIS
.B limine-deploy
.RI "<device> [ GPT partition index ]"
.SH DESCRIPTION
\fBlimine-deploy\fR installs the BIOS port's early stages to the specified device.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Show the available command-line options and exit
.TP
.BR \-\-force-mbr
Force MBR detection to work even if the safety checks fail (\fIDANGEROUS\fR!)
.TP
.BR \-\-undeploy
Reverse the entire deployment procedure
.TP
.BR \-\-undeploy-data-file= \fIfilename
Set the input (for --undeploy) or output file name of the file which contains undeploy data
.TP
.BR \-\-quiet
Do not print verbose diagnostic messages
.SH BUGS
Please report bugs via
.IR @PACKAGE_BUGREPORT@ .
.SH HOMEPAGE
.I @PACKAGE_URL@
.SH SEE ALSO
.BR limine-version (1)
.BR limine-enroll-config (1)

View File

@ -1,34 +0,0 @@
.TH LIMINE-ENROLL-CONFIG 1 "version @PACKAGE_VERSION@" "@REGEN_DATE@"
.SH NAME
limine-enroll-config \- embed config hash into Limine executable
.SH SYNOPSIS
.B limine-enroll-config
.RI "<Limine executable> <BLAKE2B of config file>"
.SH DESCRIPTION
\fBlimine-enroll-config\fR embeds the config file's BLAKE2B hash into a valid Limine bootloader
executable, such as its EFI executable or limine.sys, for tampering prevention purposes.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Show the available command-line options and exit
.TP
.BR \-\-reset
Remove enrolled BLAKE2B, will not check config intergrity
.TP
.BR \-\-quiet
Do not print verbose diagnostic messages
.SH BUGS
Please report bugs via
.IR @PACKAGE_BUGREPORT@ .
.SH HOMEPAGE
.I @PACKAGE_URL@
.SH SEE ALSO
.BR limine-version (1)
.BR limine-deploy (1)

View File

@ -1,22 +0,0 @@
.TH LIMINE-VERSION 1 "version @PACKAGE_VERSION@" "@REGEN_DATE@"
.SH NAME
limine-version \- print Limine version
.SH SYNOPSIS
.B limine-version
.SH DESCRIPTION
\fBlimine-version\fR prints the version number of the installed copy of Limine
to standard output.
.SH BUGS
Please report bugs via
.IR @PACKAGE_BUGREPORT@ .
.SH HOMEPAGE
.I https://limine-bootloader.org/
.SH SEE ALSO
.BR limine-deploy (1)
.BR limine-enroll-config (1)

18
man/man1/limine.1.in Normal file
View File

@ -0,0 +1,18 @@
.TH LIMINE 1 "version @PACKAGE_VERSION@" "@REGEN_DATE@"
.SH NAME
limine \- Multiplexer to several Limine-related utilities.
.SH SYNOPSIS
.B limine
.RI "<command> <args...>"
.SH DESCRIPTION
\fBlimine\fR provides a series of Limine-related utilities condensed in a single executable.
.SH BUGS
Please report bugs via
.IR @PACKAGE_BUGREPORT@ .
.SH HOMEPAGE
.I @PACKAGE_URL@

22
test.mk
View File

@ -33,7 +33,7 @@ ext2-test:
$(MAKE) test-clean
$(MAKE) test.hdd
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) limine
$(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/
mkdir test_image
@ -48,7 +48,7 @@ ext2-test:
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
$(BINDIR)/limine-deploy test.hdd
$(BINDIR)/limine bios-install test.hdd
qemu-system-x86_64 -net none -smp 4 -hda test.hdd -debugcon stdio
.PHONY: fat12-test
@ -56,7 +56,7 @@ fat12-test:
$(MAKE) test-clean
$(MAKE) test.hdd
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) limine
$(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/
mkdir test_image
@ -71,7 +71,7 @@ fat12-test:
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
$(BINDIR)/limine-deploy test.hdd
$(BINDIR)/limine bios-install test.hdd
qemu-system-x86_64 -net none -smp 4 -hda test.hdd -debugcon stdio
.PHONY: fat16-test
@ -79,7 +79,7 @@ fat16-test:
$(MAKE) test-clean
$(MAKE) test.hdd
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) limine
$(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/
mkdir test_image
@ -94,7 +94,7 @@ fat16-test:
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
$(BINDIR)/limine-deploy test.hdd
$(BINDIR)/limine bios-install test.hdd
qemu-system-x86_64 -net none -smp 4 -hda test.hdd -debugcon stdio
.PHONY: legacy-fat16-test
@ -103,7 +103,7 @@ legacy-fat16-test:
$(MAKE) mbrtest.hdd
fdisk -l mbrtest.hdd
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) limine
$(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/
mkdir test_image
@ -118,7 +118,7 @@ legacy-fat16-test:
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
$(BINDIR)/limine-deploy mbrtest.hdd
$(BINDIR)/limine bios-install mbrtest.hdd
qemu-system-i386 -cpu pentium2 -m 16M -M isapc -net none -hda mbrtest.hdd -debugcon stdio
.PHONY: fat32-test
@ -126,7 +126,7 @@ fat32-test:
$(MAKE) test-clean
$(MAKE) test.hdd
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) limine
$(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/
mkdir test_image
@ -141,7 +141,7 @@ fat32-test:
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
$(BINDIR)/limine-deploy test.hdd
$(BINDIR)/limine bios-install test.hdd
qemu-system-x86_64 -net none -smp 4 -hda test.hdd -debugcon stdio
.PHONY: iso9660-test
@ -169,7 +169,7 @@ full-hybrid-test:
sudo cp -rv $(BINDIR)/* test_image/boot/
sudo cp -rv test/* test_image/boot/
xorriso -as mkisofs -b boot/limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot boot/limine-cd-efi.bin -efi-boot-part --efi-boot-image --protective-msdos-label test_image/ -o test.iso
$(BINDIR)/limine-deploy test.iso
$(BINDIR)/limine bios-install test.iso
qemu-system-x86_64 -m 512M -M q35 -bios ovmf-x64/OVMF.fd -net none -smp 4 -cdrom test.iso -debugcon stdio
qemu-system-x86_64 -m 512M -M q35 -bios ovmf-x64/OVMF.fd -net none -smp 4 -hda test.iso -debugcon stdio
qemu-system-x86_64 -m 512M -M q35 -bios ovmf-ia32/OVMF.fd -net none -smp 4 -cdrom test.iso -debugcon stdio