diff --git a/src/kernel/ahci/ata.h b/src/drivers/ahci/ata.h similarity index 100% rename from src/kernel/ahci/ata.h rename to src/drivers/ahci/ata.h diff --git a/src/kernel/ahci/driver.cpp b/src/drivers/ahci/driver.cpp similarity index 74% rename from src/kernel/ahci/driver.cpp rename to src/drivers/ahci/driver.cpp index 621135e..8c9d236 100644 --- a/src/kernel/ahci/driver.cpp +++ b/src/drivers/ahci/driver.cpp @@ -3,16 +3,20 @@ #include "log.h" #include "pci.h" +namespace ahci { -ahci_driver::ahci_driver() + +driver::driver() { } void -ahci_driver::register_device(pci_device *device) +driver::register_device(pci_device *device) { log::info(logs::driver, "AHCI registering device %d:%d:%d:", device->bus(), device->device(), device->function()); ahci::hba &hba = m_devices.emplace(device); } + +} // namespace diff --git a/src/kernel/ahci/driver.h b/src/drivers/ahci/driver.h similarity index 89% rename from src/kernel/ahci/driver.h rename to src/drivers/ahci/driver.h index 1099f39..0377f6c 100644 --- a/src/kernel/ahci/driver.h +++ b/src/drivers/ahci/driver.h @@ -6,13 +6,15 @@ class pci_device; +namespace ahci { + /// Basic AHCI driver -class ahci_driver +class driver { public: /// Constructor. - ahci_driver(); + driver(); /// Register a device with the driver /// \arg device The PCI device to handle @@ -26,3 +28,4 @@ private: kutil::vector m_devices; }; +} // namespace diff --git a/src/kernel/ahci/fis.h b/src/drivers/ahci/fis.h similarity index 100% rename from src/kernel/ahci/fis.h rename to src/drivers/ahci/fis.h diff --git a/src/kernel/ahci/hba.cpp b/src/drivers/ahci/hba.cpp similarity index 100% rename from src/kernel/ahci/hba.cpp rename to src/drivers/ahci/hba.cpp diff --git a/src/kernel/ahci/hba.h b/src/drivers/ahci/hba.h similarity index 100% rename from src/kernel/ahci/hba.h rename to src/drivers/ahci/hba.h diff --git a/src/kernel/ahci/port.cpp b/src/drivers/ahci/port.cpp similarity index 100% rename from src/kernel/ahci/port.cpp rename to src/drivers/ahci/port.cpp diff --git a/src/kernel/ahci/port.h b/src/drivers/ahci/port.h similarity index 100% rename from src/kernel/ahci/port.h rename to src/drivers/ahci/port.h diff --git a/src/kernel/device_manager.cpp b/src/kernel/device_manager.cpp index 1a64e90..6a9165f 100644 --- a/src/kernel/device_manager.cpp +++ b/src/kernel/device_manager.cpp @@ -1,10 +1,10 @@ #include #include +#include "ahci/driver.h" #include "kutil/assert.h" #include "kutil/memory.h" #include "acpi_tables.h" -#include "ahci/driver.h" #include "apic.h" #include "console.h" #include "device_manager.h" @@ -17,7 +17,6 @@ static const char expected_signature[] = "RSD PTR "; device_manager device_manager::s_instance(nullptr); -ahci_driver ahcid; struct acpi1_rsdp { @@ -292,6 +291,7 @@ device_manager::init_drivers() { // Eventually this should be e.g. a lookup into a loadable driver list // for now, just look for AHCI devices + /* for (auto &device : m_devices) { if (device.devclass() != 1 || device.subclass() != 6) continue; @@ -303,6 +303,7 @@ device_manager::init_drivers() ahcid.register_device(&device); } + */ } bool diff --git a/wscript b/wscript index 4c6af59..ddf417f 100644 --- a/wscript +++ b/wscript @@ -66,6 +66,7 @@ def configure(ctx): join(ctx.path.abspath(), "src", "include"), join(ctx.path.abspath(), "src", "include", ctx.env.POPCORN_ARCH), join(ctx.path.abspath(), "src", "libraries"), + join(ctx.path.abspath(), "src", "drivers"), ]) libraries = [] @@ -75,6 +76,13 @@ def configure(ctx): if exists(join(mod_path, "wscript")): libraries.append(mod_path) + drivers = [] + mod_root = join("src", "drivers") + for module in os.listdir(mod_root): + mod_path = join(mod_root, module) + if exists(join(mod_path, "wscript")): + drivers.append(mod_path) + baseflags = [ '-nostdlib', '-ffreestanding', @@ -168,6 +176,10 @@ def configure(ctx): for mod_path in ctx.env.LIBRARIES: ctx.recurse(mod_path) + ctx.env.DRIVERS = drivers + for mod_path in ctx.env.DRIVERS: + ctx.recurse(mod_path) + ctx.recurse(join("src", "kernel")) ## Testing configuration @@ -200,6 +212,8 @@ def build(bld): bld.env = bld.all_envs['kernel'] for mod_path in bld.env.LIBRARIES: bld.recurse(mod_path) + for mod_path in bld.env.DRIVERS: + bld.recurse(mod_path) bld.recurse(join("src", "kernel"))