mirror of
https://github.com/limine-bootloader/limine
synced 2024-11-27 11:00:28 +03:00
limine: PXE and HHDM work
This commit is contained in:
parent
ee5e776c2c
commit
fb54571b34
@ -22,6 +22,9 @@ struct file_handle {
|
||||
#if uefi == 1
|
||||
EFI_HANDLE efi_part_handle;
|
||||
#endif
|
||||
bool pxe;
|
||||
uint32_t pxe_ip;
|
||||
uint16_t pxe_port;
|
||||
};
|
||||
|
||||
struct file_handle *fopen(struct volume *part, const char *filename);
|
||||
|
@ -22,6 +22,8 @@ struct limine_uuid {
|
||||
|
||||
struct limine_file_location {
|
||||
uint64_t partition_index;
|
||||
uint32_t pxe_ip;
|
||||
uint32_t pxe_port;
|
||||
uint32_t mbr_disk_id;
|
||||
struct limine_uuid gpt_disk_uuid;
|
||||
struct limine_uuid gpt_part_uuid;
|
||||
@ -35,6 +37,7 @@ struct limine_file_location {
|
||||
struct limine_boot_info_response {
|
||||
uint64_t flags;
|
||||
LIMINE_PTR(char *) loader;
|
||||
LIMINE_PTR(void *) hhdm;
|
||||
};
|
||||
|
||||
struct limine_boot_info_request {
|
||||
|
@ -39,9 +39,17 @@ static uint64_t physical_base, virtual_base, slide, direct_map_offset;
|
||||
static size_t requests_count;
|
||||
static void *requests[MAX_REQUESTS];
|
||||
|
||||
static struct limine_file_location get_file_loc(struct volume *vol) {
|
||||
static struct limine_file_location get_file_loc(struct file_handle *file) {
|
||||
struct limine_file_location ret = {0};
|
||||
|
||||
if (file->pxe) {
|
||||
ret.pxe_ip = file->pxe_ip;
|
||||
ret.pxe_port = file->pxe_port;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct volume *vol = file->vol;
|
||||
|
||||
ret.partition_index = vol->partition;
|
||||
|
||||
ret.mbr_disk_id = mbr_get_id(vol);
|
||||
@ -111,7 +119,8 @@ bool limine_load(char *config, char *cmdline) {
|
||||
|
||||
size_t kernel_file_size = kernel_file->size;
|
||||
|
||||
struct volume *kernel_volume = kernel_file->vol;
|
||||
struct limine_file_location *kl = ext_mem_alloc(sizeof(struct limine_file_location));
|
||||
*kl = get_file_loc(kernel_file);
|
||||
|
||||
fclose(kernel_file);
|
||||
|
||||
@ -234,6 +243,7 @@ FEAT_START
|
||||
ext_mem_alloc(sizeof(struct limine_boot_info_response));
|
||||
|
||||
boot_info_response->loader = reported_addr("Limine " LIMINE_VERSION);
|
||||
boot_info_response->hhdm = direct_map_offset;
|
||||
|
||||
boot_info_request->response = reported_addr(boot_info_response);
|
||||
FEAT_END
|
||||
@ -306,9 +316,6 @@ FEAT_START
|
||||
modules[0].path = reported_addr(kernel_path);
|
||||
modules[0].cmdline = reported_addr(cmdline);
|
||||
|
||||
struct limine_file_location *kl = ext_mem_alloc(sizeof(struct limine_file_location));
|
||||
*kl = get_file_loc(kernel_volume);
|
||||
|
||||
modules[0].file_location = reported_addr(kl);
|
||||
|
||||
for (size_t i = 1; i < module_count; i++) {
|
||||
@ -337,7 +344,7 @@ FEAT_START
|
||||
m->cmdline = reported_addr(module_cmdline);
|
||||
|
||||
struct limine_file_location *l = ext_mem_alloc(sizeof(struct limine_file_location));
|
||||
*l = get_file_loc(f->vol);
|
||||
*l = get_file_loc(f);
|
||||
|
||||
m->file_location = reported_addr(l);
|
||||
|
||||
|
@ -45,6 +45,10 @@ bool tftp_open(struct file_handle *handle, uint32_t server_ip, uint16_t server_p
|
||||
handle->size = fsize.file_size;
|
||||
handle->is_memfile = true;
|
||||
|
||||
handle->pxe = true;
|
||||
handle->pxe_ip = server_ip;
|
||||
handle->pxe_port = server_port;
|
||||
|
||||
struct pxenv_open open = {
|
||||
.status = 0,
|
||||
.sip = server_ip,
|
||||
|
@ -67,6 +67,12 @@ static char *get_memmap_type(uint64_t type) {
|
||||
|
||||
static void print_file_loc(struct limine_file_location *file_location) {
|
||||
e9_printf("Loc->PartIndex: %d", file_location->partition_index);
|
||||
e9_printf("Loc->PXEIP: %d.%d.%d.%d",
|
||||
(file_location->pxe_ip & (0xff << 0)) >> 0,
|
||||
(file_location->pxe_ip & (0xff << 8)) >> 8,
|
||||
(file_location->pxe_ip & (0xff << 16)) >> 16,
|
||||
(file_location->pxe_ip & (0xff << 24)) >> 24);
|
||||
e9_printf("Loc->PXEPort: %d", file_location->pxe_port);
|
||||
e9_printf("Loc->MBRDiskId: %x", file_location->mbr_disk_id);
|
||||
e9_printf("Loc->GPTDiskUUID: %x-%x-%x-%x",
|
||||
file_location->gpt_disk_uuid.a,
|
||||
@ -88,8 +94,14 @@ static void print_file_loc(struct limine_file_location *file_location) {
|
||||
#define FEAT_START do {
|
||||
#define FEAT_END } while (0);
|
||||
|
||||
extern char kernel_start[];
|
||||
|
||||
static void limine_main(void) {
|
||||
e9_printf("We're alive");
|
||||
e9_printf("\nWe're alive");
|
||||
|
||||
uint64_t kernel_slide = (uint64_t)kernel_start - 0xffffffff80000000;
|
||||
|
||||
e9_printf("Kernel slide: %x", kernel_slide);
|
||||
|
||||
FEAT_START
|
||||
if (boot_info_request.response == NULL) {
|
||||
@ -99,6 +111,7 @@ FEAT_START
|
||||
struct limine_boot_info_response *boot_info_response = boot_info_request.response;
|
||||
e9_printf("Boot info response:");
|
||||
e9_printf("Bootloader name: %s", boot_info_response->loader);
|
||||
e9_printf("Higher half direct map: %x", boot_info_response->hhdm);
|
||||
FEAT_END
|
||||
|
||||
FEAT_START
|
||||
|
@ -12,6 +12,7 @@ PHDRS
|
||||
SECTIONS
|
||||
{
|
||||
. = 0xffffffff80000000;
|
||||
kernel_start = .;
|
||||
|
||||
.text : {
|
||||
*(.text*)
|
||||
|
Loading…
Reference in New Issue
Block a user