From 27c38d3f6e473d2bf7075fb364db148f22aca203 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 17 Apr 2020 19:55:42 +0200 Subject: Added multiboot smbios table idk why, but grub doesn't seem to find a smbios table in qemu. I tried a local dump of my pc's smbios but this doesn't work either.. *thinking* --- src/kernel/boot.asm | 13 +++++------ src/kernel/fs/ata.c | 4 ++-- src/kernel/kernel.c | 17 ++++++--------- src/kernel/multiboot.c | 6 ++++++ src/kernel/smbios/smbios.c | 54 +++++----------------------------------------- src/kernel/smbios/smbios.h | 30 ++++---------------------- 6 files changed, 31 insertions(+), 93 deletions(-) diff --git a/src/kernel/boot.asm b/src/kernel/boot.asm index 5ce6014..5513fc7 100644 --- a/src/kernel/boot.asm +++ b/src/kernel/boot.asm @@ -5,14 +5,15 @@ section .multiboot dd header_end - header_start dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start)) - ; Information tag (force) + ; Information tag align 8 dw 1 - dw 0 - dd 20 - dd 2 - dd 4 - dd 6 + dw 1 + dd 24 + dd 2 ; bootloader name + dd 4 ; meminfo + dd 6 ; mmap + dd 13 ; smbios ; Empty tag align 8 diff --git a/src/kernel/fs/ata.c b/src/kernel/fs/ata.c index ac42275..e1f749f 100644 --- a/src/kernel/fs/ata.c +++ b/src/kernel/fs/ata.c @@ -287,6 +287,6 @@ void ata_init() ata_device_detect(&primary_master, 1); ata_device_detect(&primary_slave, 1); - /* ata_device_detect(&secondary_master, 0); */ - /* ata_device_detect(&secondary_slave, 0); */ + // ata_device_detect(&secondary_master, 0); + // ata_device_detect(&secondary_slave, 0); } diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 42395d4..144ae8c 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -45,13 +45,6 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address) memory_print(); - vfs_init(); - ata_init(); - ext2_init("/dev/hda", "/"); - - load_binaries(); - set_optimal_resolution(); - // Install drivers cli(); timer_install(); @@ -61,10 +54,14 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address) network_install(); sti(); - // tasking_install(); + vfs_init(); + ata_init(); + ext2_init("/dev/hda", "/"); - // Get hardware information - // get_smbios(); + load_binaries(); + set_optimal_resolution(); + + // tasking_install(); #ifdef INSTALL_MELVIX panic("Installation isn't supported right now!"); diff --git a/src/kernel/multiboot.c b/src/kernel/multiboot.c index 2c5fa60..2df1d0e 100644 --- a/src/kernel/multiboot.c +++ b/src/kernel/multiboot.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,11 @@ void multiboot_parse(uint32_t multiboot_address) case MULTIBOOT_TAG_TYPE_EFI32: info("Got EFI32"); break; + case MULTIBOOT_TAG_TYPE_SMBIOS: + // GRUB doesn't detect SMBIOS on QEMU! + info("Got SMBIOS table"); + smbios_init((struct multiboot_tag_smbios *)tag); + break; case MULTIBOOT_TAG_TYPE_ACPI_OLD: info("Got ACPI table"); break; diff --git a/src/kernel/smbios/smbios.c b/src/kernel/smbios/smbios.c index f2650bb..5e48ffa 100644 --- a/src/kernel/smbios/smbios.c +++ b/src/kernel/smbios/smbios.c @@ -1,53 +1,9 @@ -#include #include +#include +#include #include -struct smbios_entry *smbios = 0; - -size_t smbios_table_len(struct smbios_header *header) -{ - size_t i; - const char *strtab = (char *)header + header->length; - for (i = 1; strtab[i - 1] != '\0' || strtab[i] != '\0'; i++) - ; - return header->length + i + 1; +void smbios_init(struct multiboot_tag_smbios *tag) { + log("%s", ((struct smbios_0 *)tag->tables)->vendor); + return; } - -struct smbios_entry *get_smbios() -{ - if (smbios != 0) - return smbios; - - char *mem = (char *)0xF0000; - int length, i; - unsigned char checksum; - while ((unsigned int)mem < 0x100000) { - if (mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_') { - length = mem[5]; - checksum = 0; - for (i = 0; i < length; i++) { - checksum += mem[i]; - } - if (checksum == 0) - break; - } - mem += 16; - } - - if ((unsigned int)mem == 0x100000) { - warn("No SMBIOS found!"); - return 0; - } - - smbios = (struct smbios_entry *)mem; - if (smbios->major_version != 2) - warn("Non-supported SMBIOS version"); - smbios_table((struct smbios_header *)mem); - return smbios; -} - -void smbios_table(struct smbios_header *header) -{ - // struct smbios_0 *table = (struct smbios_0 *) (header + sizeof(struct smbios_header)); - // log("\n\n %d", table->bios_version); -} \ No newline at end of file diff --git a/src/kernel/smbios/smbios.h b/src/kernel/smbios/smbios.h index 4485f3e..1d0765a 100644 --- a/src/kernel/smbios/smbios.h +++ b/src/kernel/smbios/smbios.h @@ -1,28 +1,8 @@ #ifndef MELVIX_SMBIOS_H #define MELVIX_SMBIOS_H -struct smbios_header { - uint8_t type; - uint8_t length; - uint16_t handle; -}; - -struct smbios_entry { - int8_t signature[4]; - uint8_t checksum; - uint8_t length; - uint8_t major_version; - uint8_t minor_version; - uint8_t max_structure_size; - int8_t entry_point_revision; - int8_t formatted_area[5]; - int8_t entry_point_signature[5]; - uint8_t checksum2; - uint16_t table_length; - uint32_t table_address; - uint16_t number_of_structures; - uint8_t bcd_revision; -}; +#include +#include struct smbios_0 { char *vendor; @@ -42,8 +22,6 @@ struct smbios_1 { uint8_t wakeup_type; }; -struct smbios_entry *get_smbios(); - -void smbios_table(struct smbios_header *header); +void smbios_init(struct multiboot_tag_smbios *tag); -#endif \ No newline at end of file +#endif -- cgit v1.2.3