diff --git a/common/fs/file.h b/common/fs/file.h index 50a61e86..f17b5b27 100644 --- a/common/fs/file.h +++ b/common/fs/file.h @@ -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); diff --git a/common/limine.h b/common/limine.h index 3be01c45..37114129 100644 --- a/common/limine.h +++ b/common/limine.h @@ -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 { diff --git a/common/protos/limine.c b/common/protos/limine.c index 560ea1cd..ddaf1f68 100644 --- a/common/protos/limine.c +++ b/common/protos/limine.c @@ -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); diff --git a/common/pxe/tftp.s2.c b/common/pxe/tftp.s2.c index 24f24584..d4f61aaf 100644 --- a/common/pxe/tftp.s2.c +++ b/common/pxe/tftp.s2.c @@ -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, diff --git a/test/limine.c b/test/limine.c index dd8024c4..ede5619e 100644 --- a/test/limine.c +++ b/test/limine.c @@ -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 diff --git a/test/linker.ld b/test/linker.ld index 69aa865a..4ee8dc40 100644 --- a/test/linker.ld +++ b/test/linker.ld @@ -12,6 +12,7 @@ PHDRS SECTIONS { . = 0xffffffff80000000; + kernel_start = .; .text : { *(.text*)