From cd5737dba70c2c640f9b602401a2ffe86a20ab23 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Mon, 29 May 2023 14:40:37 +0200 Subject: [PATCH] feature (drivers): started work on a generic driver interface / driver manager --- inc/drivers/driver.h | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/boot/kmain.c | 3 +++ src/drivers/driver.c | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 inc/drivers/driver.h create mode 100644 src/drivers/driver.c diff --git a/inc/drivers/driver.h b/inc/drivers/driver.h new file mode 100644 index 0000000..b332952 --- /dev/null +++ b/inc/drivers/driver.h @@ -0,0 +1,62 @@ +// This file is part of noxos and licensed under the MIT open source license + +#ifndef NOXOS_DRIVER_H +#define NOXOS_DRIVER_H + +#include +#include + +typedef enum { + DRIVER_TRANSPORT_PCI, + DRIVER_TRANSPORT_USB, + DRIVER_TRANSPORT_FS +} __attribute__((packed)) driver_transport_protocol_E; + +typedef struct { + driver_transport_protocol_E transport_protocol:8; + uint16_t length; + uint8_t specific_config[]; +} __attribute__((packed)) driver_config_header_T; + +typedef struct { + uint16_t vendor_id; + uint16_t device_id; +} __attribute__((packed)) driver_config_device_id_T; + +typedef struct { + bool enable_progif; + uint8_t class; + uint8_t subclass; + uint8_t progif; + uint16_t num_device_ids; + driver_config_device_id_T device_ids; +} __attribute__((packed)) driver_config_pci_T; + +typedef struct { + uint8_t min_version; + uint16_t num_device_ids; + driver_config_device_id_T device_ids; +} __attribute__((packed)) driver_config_usb_T; + +typedef struct { + uint8_t gpt_guid[16]; + uint8_t mbr_type; +} __attribute__((packed)) driver_config_fs_T; + + +typedef struct { + +} driver_T; + +typedef struct { + +} driver_manager_T; + +void driver_manager_init (); +driver_T* driver_register (driver_config_header_T* config, elf_executable_T* executable); +driver_T* driver_lookup_pci_device (uint16_t vendor_id, uint16_t device_id); +driver_T* driver_lookup_usb_device (uint16_t vendor_id, uint16_t device_id); +driver_T* driver_lookup_fs_gpt (uint8_t guid[16]); +driver_T* driver_lookup_fs_mbr (uint8_t type); + +#endif //NOXOS_DRIVER_H diff --git a/src/boot/kmain.c b/src/boot/kmain.c index cacbf5d..33f1b6c 100644 --- a/src/boot/kmain.c +++ b/src/boot/kmain.c @@ -20,6 +20,7 @@ #include "drivers/builtin/pci.h" #include "drivers/builtin/ps2/controller.h" #include "drivers/builtin/tty.h" +#include "drivers/driver.h" #include "proc/scheduler.h" #include "modules/loader.h" @@ -51,6 +52,8 @@ void kernel_init(boot_info_T* boot_info) { scheduler_init(boot_info); + driver_manager_init(); + acpi_init(boot_info); module_manager_init(); diff --git a/src/drivers/driver.c b/src/drivers/driver.c new file mode 100644 index 0000000..40b0a46 --- /dev/null +++ b/src/drivers/driver.c @@ -0,0 +1,50 @@ +// This file is part of noxos and licensed under the MIT open source license + +#include +#include + +driver_manager_T g_driver_manager; + +void driver_manager_init() { + +} + +driver_T* driver_find_pci_device(uint16_t vendor_id, uint16_t device_id) { + log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + return NULL; +} + +driver_T* driver_find_usb_device(uint16_t vendor_id, uint16_t device_id) { + log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + return NULL; +} + +driver_T* driver_find_fs_gpt(uint8_t guid[16]) { + log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + return NULL; +} + +driver_T* driver_find_fs_mbr(uint8_t type) { + log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + return NULL; +} + +driver_T* driver_register(driver_config_header_T* config, elf_executable_T* executable) { + return NULL; +} + +driver_T* driver_lookup_pci_device(uint16_t vendor_id, uint16_t device_id) { + return NULL; +} + +driver_T* driver_lookup_usb_device(uint16_t vendor_id, uint16_t device_id) { + return NULL; +} + +driver_T* driver_lookup_fs_gpt(uint8_t guid[16]) { + return NULL; +} + +driver_T* driver_lookup_fs_mbr(uint8_t type) { + return NULL; +} \ No newline at end of file