:: commit 5c7578c54a8db2b4d83abf8c41b6dba5a0c9fe10

mintsuki <mintsuki@protonmail.com> — 2022-04-02 08:28

parents: 012e7b0b67

limine: Add media type to limine_file structure

diff --git a/PROTOCOL.md b/PROTOCOL.md
index 64b616a7..8251a30c 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -752,16 +752,21 @@ struct limine_uuid {
     uint8_t d[8];
 };
 
+#define LIMINE_MEDIA_TYPE_GENERIC 0
+#define LIMINE_MEDIA_TYPE_OPTICAL 1
+#define LIMINE_MEDIA_TYPE_TFTP 2
+
 struct limine_file {
     uint64_t revision;
     void *address;
     uint64_t size;
     char *path;
     char *cmdline;
-    uint64_t partition_index;
+    uint32_t media_type;
     uint32_t unused;
     uint32_t tftp_ip;
     uint32_t tftp_port;
+    uint32_t partition_index;
     uint32_t mbr_disk_id;
     struct limine_uuid gpt_disk_uuid;
     struct limine_uuid gpt_part_uuid;
@@ -774,11 +779,12 @@ struct limine_file {
 * `size` - The size of the file.
 * `path` - The path of the file within the volume, with a leading slash.
 * `cmdline` - A command line associated with the file.
-* `partition_index` - 1-based partition index of the volume from which the
-file was loaded. If 0, it means invalid or unpartitioned.
+* `media_type` - Type of media file resides on.
 * `tftp_ip` - If non-0, this is the IP of the TFTP server the file was loaded
 from.
 * `tftp_port` - Likewise, but port.
+* `partition_index` - 1-based partition index of the volume from which the
+file was loaded. If 0, it means invalid or unpartitioned.
 * `mbr_disk_id` - If non-0, this is the ID of the disk the file was loaded
 from as reported in its MBR.
 * `gpt_disk_uuid` - If non-0, this is the UUID of the disk the file was
diff --git a/common/protos/limine.c b/common/protos/limine.c
index bc181bfb..0760ce4a 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -47,11 +47,17 @@ static struct limine_file get_file(struct file_handle *file, char *cmdline) {
     struct limine_file ret = {0};
 
     if (file->pxe) {
+        ret.media_type = LIMINE_MEDIA_TYPE_TFTP;
+
         ret.tftp_ip = file->pxe_ip;
         ret.tftp_port = file->pxe_port;
     } else {
         struct volume *vol = file->vol;
 
+        if (vol->is_optical) {
+            ret.media_type = LIMINE_MEDIA_TYPE_OPTICAL;
+        }
+
         ret.partition_index = vol->partition;
 
         ret.mbr_disk_id = mbr_get_id(vol);
diff --git a/limine.h b/limine.h
index 35e4493d..cea4c497 100644
--- a/limine.h
+++ b/limine.h
@@ -24,16 +24,21 @@ struct limine_uuid {
     uint8_t d[8];
 };
 
+#define LIMINE_MEDIA_TYPE_GENERIC 0
+#define LIMINE_MEDIA_TYPE_OPTICAL 1
+#define LIMINE_MEDIA_TYPE_TFTP 2
+
 struct limine_file {
     uint64_t revision;
     LIMINE_PTR(void *) address;
     uint64_t size;
     LIMINE_PTR(char *) path;
     LIMINE_PTR(char *) cmdline;
-    uint64_t partition_index;
+    uint32_t media_type;
     uint32_t unused;
     uint32_t tftp_ip;
     uint32_t tftp_port;
+    uint32_t partition_index;
     uint32_t mbr_disk_id;
     struct limine_uuid gpt_disk_uuid;
     struct limine_uuid gpt_part_uuid;
diff --git a/test/limine.c b/test/limine.c
index e809ca00..37e0d810 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -106,6 +106,7 @@ static void print_file(struct limine_file *file) {
     e9_printf("File->Size: %x", file->size);
     e9_printf("File->Path: %s", file->path);
     e9_printf("File->CmdLine: %s", file->cmdline);
+    e9_printf("File->MediaType: %d", file->media_type);
     e9_printf("File->PartIndex: %d", file->partition_index);
     e9_printf("File->TFTPIP: %d.%d.%d.%d",
               (file->tftp_ip & (0xff << 0)) >> 0,
tab: 248 wrap: offon