118 lines
3.4 KiB
C
118 lines
3.4 KiB
C
|
|
#ifndef NOXOS_DRIVER_H
|
|
#define NOXOS_DRIVER_H
|
|
|
|
#include "utils/stdtypes.h"
|
|
|
|
#define DRIVER_COMMAND_SIZE 32
|
|
|
|
typedef enum {
|
|
|
|
DRIVER_UNKNOWN = 0x0000,
|
|
DRIVER_RESERVED = 0x0001,
|
|
|
|
// Specific Driver
|
|
|
|
DRIVER_MASS_STORAGE = 0x0101,
|
|
DRIVER_FILESYSTEM = 0x0102,
|
|
DRIVER_GRAPHICS = 0x0103,
|
|
DRIVER_AUDIO = 0x0104,
|
|
|
|
// Drivers which define the transmission of data but have multiple
|
|
// intended usages, such as USB for mass storage, input, etc..
|
|
|
|
DRIVER_TRANSMISSION = 0x0201,
|
|
DRIVER_USB_DEVICE = 0x0202,
|
|
DRIVER_PCI_DEVICE = 0x0203,
|
|
DRIVER_PCIE_DEVICE = 0x0204,
|
|
DRIVER_NVME_DEVICE = 0x0205,
|
|
DRIVER_BLUETOOTH = 0x0206,
|
|
DRIVER_ETHERNET = 0x0207,
|
|
|
|
// MISCELLANEOUS
|
|
|
|
DRIVER_EMULATION = 0x7fff
|
|
|
|
} driver_category_E;
|
|
|
|
typedef struct driver_mass_storage_t {
|
|
|
|
|
|
|
|
} driver_mass_storage_T;
|
|
|
|
|
|
|
|
typedef struct driver_configuration_t
|
|
{
|
|
uint16_t category;
|
|
uint16_t max_command_buffers;
|
|
|
|
uint16_t category_dependencies[16];
|
|
|
|
uint8_t reserved[220];
|
|
|
|
} driver_configuration_T;
|
|
|
|
|
|
|
|
typedef struct driver_command_buffer_config_t
|
|
{
|
|
uint64_t num_commands;
|
|
void *mapping_address;
|
|
|
|
uint8_t reserved[240];
|
|
|
|
} driver_command_buffer_config_T;
|
|
|
|
typedef struct driver_command_buffer_t
|
|
{
|
|
uint64_t command_capacity;
|
|
void *mapping_address;
|
|
|
|
} driver_command_buffer_T;
|
|
|
|
typedef struct driver_t // TODO: Accesses must be thread-safe
|
|
{
|
|
driver_category_E category;
|
|
uint32_t id;
|
|
|
|
uint16_t max_command_buffers;
|
|
driver_command_buffer_T *command_buffers;
|
|
|
|
} driver_T;
|
|
|
|
|
|
|
|
typedef struct driver_manager_t {
|
|
|
|
uint32_t max_drivers;
|
|
uint32_t num_drivers;
|
|
driver_T *drivers;
|
|
|
|
} driver_manager_T;
|
|
|
|
extern driver_manager_T g_driver_manager;
|
|
|
|
|
|
|
|
void driver_manager_init ();
|
|
void driver_manager_load_single_driver (char *driver_config_path);
|
|
void driver_manager_load_drivers (char *main_config_path);
|
|
|
|
uint32_t driver_manager_register_driver (driver_configuration_T *configuration);
|
|
driver_T * driver_manager_resolve_driver_id (uint32_t id);
|
|
|
|
// driver_add_command_buffer: Adds a command buffer to the 'command_buffers'-array in the given driver.
|
|
void driver_add_command_buffer (driver_T *driver, driver_command_buffer_config_T *configuration);
|
|
|
|
// driver_flush_command_buffer: Flushes the command buffer that 'buffer' points to,
|
|
// meaning that it executes all commands stored in it. 'buffer' doesn't need to be the first
|
|
// byte; the function will execute from the first command in a buffer even if some byte in the
|
|
// middle of the buffer is given into this function.
|
|
void driver_flush_command_buffer (driver_T *driver, void *buffer);
|
|
|
|
|
|
#endif
|
|
|