fwcfg: Drop support

This commit is contained in:
mintsuki 2022-07-13 06:23:20 +02:00
parent 447de819c8
commit 0af37b7cf0
7 changed files with 1 additions and 184 deletions

View File

@ -6,12 +6,6 @@ Limine scans for a config file on *the boot drive*. Every partition on the boot
is scanned sequentially (first partition first, last partition last) for the presence
of either a `/limine.cfg`, `/boot/limine.cfg`, or a `/EFI/BOOT/limine.cfg` file, in that order.
If no config file is found in the aforementioned locations, Limine looks for the file on the fw_cfg
interface called `opt/org.limine-bootloader.config`. If that is not present and the kernel is found at
`opt/org.limine-bootloader.kernel`, Limine enters the so-called "simple mode", where the kernel is loaded from
`opt/org.limine-bootloader.kernel`, and, (if present), the background is loaded from
`opt/org.limine-bootloader.background`.
Once the file is located, Limine will use it as its config file. Other possible
candidates in subsequent partitions or directories are ignored.
@ -168,7 +162,6 @@ A resource can be one of the following:
* `uuid` - Alias of `guid`.
* `fslabel` - The `root` is the name of the filesystem label of a partition.
* `tftp` - The `root` is the IP address of the tftp server to load the file from. If the root is left empty (`tftp:///...`) the file will be loaded from the server Limine booted from. This resource is only available when booting off PXE.
* `fwcfg` - The `root` must be empty. The `path` refers to a fw_cfg filename to be loaded. The canonical place to put fw_cfg files is in the `opt/fqdn.<name>` namespace.
A URI can optionally be prefixed by a `$` character to indicate that the file
pointed to be the URI is a gzip-compressed payload to be uncompressed on the

View File

@ -271,30 +271,6 @@ mbrtest.hdd:
dd if=/dev/zero bs=1M count=0 seek=64 of=mbrtest.hdd
echo -e "o\nn\np\n1\n2048\n\nt\n6\na\nw\n" | fdisk mbrtest.hdd -H 16 -S 63
.PHONY: fwcfg-common fwcfg-test fwcfg-simple-test
fwcfg-common:
$(MAKE) test-clean
$(MAKE) limine-bios
$(MAKE) limine-deploy
$(MAKE) -C test
rm -rf test_image/
mkdir -p test_image/boot
cp -rv $(BINDIR)/* test_image/boot/
xorriso -as mkisofs -b boot/limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table test_image/ -o test.iso
fwcfg-simple-test:
$(MAKE) fwcfg-common
qemu-system-x86_64 -net none -smp 4 -cdrom test.iso -debugcon stdio \
-fw_cfg opt/org.limine-bootloader.background,file=test/bg.bmp \
-fw_cfg opt/org.limine-bootloader.kernel,file=test/test.elf
fwcfg-test:
$(MAKE) fwcfg-common
qemu-system-x86_64 -net none -smp 4 -cdrom test.iso -debugcon stdio \
-fw_cfg opt/org.limine-bootloader.config,file=test/limine-fwcfg.cfg \
-fw_cfg opt/org.limine-bootloader.background,file=test/bg.bmp \
-fw_cfg opt/org.limine-bootloader.kernel,file=test/test.elf
.PHONY: ext2-test
ext2-test:
$(MAKE) test-clean

View File

@ -1,10 +0,0 @@
#ifndef __DRIVERS__FWCFG_H__
#define __DRIVERS__FWCFG_H__
#include <stdint.h>
#include <lib/blib.h>
#include <lib/libc.h>
bool fwcfg_open(struct file_handle *handle, const char *name);
#endif

View File

@ -1,100 +0,0 @@
#include <stdint.h>
#include <lib/libc.h>
#include <lib/print.h>
#include <mm/pmm.h>
#include <lib/blib.h>
#include <sys/cpu.h>
struct dma_descr {
uint32_t control;
uint32_t length;
uint64_t address;
};
struct fw_cfg_file {
uint32_t size;
uint16_t select;
uint16_t reserved;
char name[56];
};
struct fw_cfg_files {
uint32_t count;
struct fw_cfg_file f[];
};
static uint16_t bswap16(uint16_t value) {
uint8_t* value_ptr = (uint8_t*)&value;
return value_ptr[0]<<8|value_ptr[1];
}
static uint32_t bswap32(uint32_t value) {
uint8_t* value_ptr = (uint8_t*)&value;
return value_ptr[0]<<24|value_ptr[1]<<16|value_ptr[2]<<8|value_ptr[3];
}
static void fwcfg_disp_read(uint16_t sel, uint32_t outsz, uint8_t* outbuf) {
outw(0x510, sel);
for (uint32_t i = 0;i < outsz;i++) outbuf[i] = inb(0x511);
}
static struct fw_cfg_files* filebuf = NULL;
static const char* simple_mode_config =
"TIMEOUT=0\n"
":simple mode config\n"
"KERNEL_PATH=fwcfg:///opt/org.limine-bootloader.kernel";
static const char* simple_mode_bg_config =
"TIMEOUT=0\n"
"GRAPHICS=yes\n"
"THEME_BACKGROUND=50000000\n"
"BACKGROUND_PATH=fwcfg:///opt/org.limine-bootloader.background\n"
"BACKGROUND_STYLE=stretched\n"
":simple mode config\n"
"KERNEL_PATH=fwcfg:///opt/org.limine-bootloader.kernel";
static bool simple_mode = false;
bool fwcfg_open(struct file_handle *handle, const char *name) {
char sig[5] = { 0 };
fwcfg_disp_read(/* signature */ 0x0000, 4, (uint8_t*)sig);
if (strcmp(sig, "QEMU")) return false;
uint32_t count;
fwcfg_disp_read(0x0019, 4, (uint8_t*)&count);
count = bswap32(count);
if (!filebuf) {
filebuf = (struct fw_cfg_files*)ext_mem_alloc(count * 64 + 4);
fwcfg_disp_read(0x0019, count * 64 + 4, (uint8_t*)filebuf);
}
bool has_kernel = false, has_background = false;
for (uint32_t i = 0;i < count;i++) {
if (!strncmp(filebuf->f[i].name, name, 56)) {
uint16_t sel = bswap16(filebuf->f[i].select);
handle->size = bswap32(filebuf->f[i].size);
handle->is_memfile = true;
uint8_t* buf = (uint8_t*)(handle->fd = ext_mem_alloc(handle->size));
fwcfg_disp_read(sel, handle->size, buf);
return true;
}
if (!strncmp(filebuf->f[i].name, "opt/org.limine-bootloader.background", 56)) {
has_background = true;
}
if (!strncmp(filebuf->f[i].name, "opt/org.limine-bootloader.kernel", 56)) {
has_kernel = true;
}
}
if (has_kernel && !strcmp(name, "opt/org.limine-bootloader.config")) {
const char* conf = has_background ? simple_mode_bg_config : simple_mode_config;
handle->size = strlen(conf);
handle->is_memfile = true;
char* buf = (char*)(handle->fd = ext_mem_alloc(handle->size + 1));
strcpy(buf, conf);
simple_mode = true;
return true;
}
return false;
}

View File

@ -23,8 +23,7 @@ int init_config_disk(struct volume *part) {
if ((f = fopen(part, "/limine.cfg")) == NULL
&& (f = fopen(part, "/boot/limine.cfg")) == NULL
&& (f = fopen(part, "/EFI/BOOT/limine.cfg")) == NULL
&& (f = uri_open("fwcfg:///opt/org.limine-bootloader.config")) == NULL) {
&& (f = fopen(part, "/EFI/BOOT/limine.cfg")) == NULL) {
return -1;
}

View File

@ -8,7 +8,6 @@
#include <mm/pmm.h>
#include <lib/print.h>
#include <pxe/tftp.h>
#include <drivers/fwcfg.h>
#include <tinf.h>
// A URI takes the form of: resource://root/path
@ -142,15 +141,6 @@ static struct file_handle *uri_fslabel_dispatch(char *fslabel, char *path) {
return fopen(volume, path);
}
static struct file_handle *uri_fwcfg_dispatch(char *path) {
struct file_handle *ret = ext_mem_alloc(sizeof(struct file_handle));
if (!fwcfg_open(ret, path)) {
return NULL;
}
return ret;
}
#if bios == 1
static struct file_handle *uri_tftp_dispatch(char *root, char *path) {
uint32_t ip;
@ -231,12 +221,6 @@ struct file_handle *uri_open(char *uri) {
} else if (!strcmp(resource, "tftp")) {
ret = uri_tftp_dispatch(root, path);
#endif
// note: fwcfg MUST be the last on the list due to fwcfg simple mode.
} else if (!strcmp(resource, "fwcfg")) {
if (*root != 0) {
panic(true, "No root supported in an fwcfg:// uri!");
}
ret = uri_fwcfg_dispatch(path);
} else {
panic(true, "Resource `%s` not valid.", resource);
}

View File

@ -1,25 +0,0 @@
DEFAULT_ENTRY=1
TIMEOUT=3
GRAPHICS=yes
VERBOSE=yes
THEME_BACKGROUND=50000000
BACKGROUND_PATH=fwcfg:///opt/org.limine-bootloader.background
BACKGROUND_STYLE=stretched
BACKDROP_COLOUR=008080
:fwcfg:// test
# Let's use autodetection
RESOLUTION=800x600
KERNEL_PATH=fwcfg:///opt/org.limine-bootloader.kernel
KERNEL_CMDLINE=Woah! Another example!
MODULE_PATH=fwcfg:///opt/org.limine-bootloader.background
MODULE_STRING=yooooo
# Test that the module string provided to the kernel will be
# the module path since a module string is not specified.
# (cc CONFIG.md limine.`MODULE_STRING` section)
MODULE_PATH=fwcfg:///opt/org.limine-bootloader.background