aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/include/arch/bus/isa.hpp4
-rw-r--r--arch/x86_64/include/arch/devices/legacy_pit.hpp3
-rw-r--r--arch/x86_64/kapi/devices.cpp6
-rw-r--r--arch/x86_64/src/bus/isa.cpp6
-rw-r--r--arch/x86_64/src/devices/legacy_pit.cpp5
-rw-r--r--kernel/kapi/devices.cpp2
-rw-r--r--kernel/src/devices/root_bus.cpp2
7 files changed, 18 insertions, 10 deletions
diff --git a/arch/x86_64/include/arch/bus/isa.hpp b/arch/x86_64/include/arch/bus/isa.hpp
index bd92b2e..5deed25 100644
--- a/arch/x86_64/include/arch/bus/isa.hpp
+++ b/arch/x86_64/include/arch/bus/isa.hpp
@@ -3,12 +3,14 @@
#include "kapi/devices/bus.hpp"
+#include <cstddef>
+
namespace arch::bus
{
struct isa final : public kapi::devices::bus
{
- isa();
+ isa(std::size_t major);
};
} // namespace arch::bus
diff --git a/arch/x86_64/include/arch/devices/legacy_pit.hpp b/arch/x86_64/include/arch/devices/legacy_pit.hpp
index d28e4d6..de742ae 100644
--- a/arch/x86_64/include/arch/devices/legacy_pit.hpp
+++ b/arch/x86_64/include/arch/devices/legacy_pit.hpp
@@ -4,6 +4,7 @@
#include "kapi/devices/device.hpp"
#include "kapi/interrupts.hpp"
+#include <cstddef>
#include <cstdint>
namespace arch::devices
@@ -11,7 +12,7 @@ namespace arch::devices
struct legacy_pit : kapi::devices::device, kapi::interrupts::handler
{
- explicit legacy_pit(std::uint32_t frequency_in_hz);
+ legacy_pit(std::size_t major, std::uint32_t frequency_in_hz);
auto init() -> bool override;
diff --git a/arch/x86_64/kapi/devices.cpp b/arch/x86_64/kapi/devices.cpp
index 7aa7090..b15503d 100644
--- a/arch/x86_64/kapi/devices.cpp
+++ b/arch/x86_64/kapi/devices.cpp
@@ -21,9 +21,11 @@ namespace kapi::devices
{
kstd::println("[x86_64:devices] Initializing ISA bus...");
- auto isa_bus = kstd::make_unique<arch::bus::isa>();
+ auto isa_major_number = kapi::devices::allocate_major_number();
+ auto isa_bus = kstd::make_unique<arch::bus::isa>(isa_major_number);
- auto pit = kstd::make_unique<arch::devices::legacy_pit>(pit_frequency_in_hz);
+ auto pit_major_number = kapi::devices::allocate_major_number();
+ auto pit = kstd::make_unique<arch::devices::legacy_pit>(pit_major_number, pit_frequency_in_hz);
isa_bus->add_child(std::move(pit));
auto & root_bus = get_root_bus();
diff --git a/arch/x86_64/src/bus/isa.cpp b/arch/x86_64/src/bus/isa.cpp
index 2ad4d21..ff4ad71 100644
--- a/arch/x86_64/src/bus/isa.cpp
+++ b/arch/x86_64/src/bus/isa.cpp
@@ -2,11 +2,13 @@
#include "kapi/devices.hpp"
+#include <cstddef>
+
namespace arch::bus
{
- isa::isa()
- : kapi::devices::bus(kapi::devices::allocate_major_number(), 0, "isa")
+ isa::isa(std::size_t major)
+ : kapi::devices::bus{major, 0, "isa"}
{}
} // namespace arch::bus \ No newline at end of file
diff --git a/arch/x86_64/src/devices/legacy_pit.cpp b/arch/x86_64/src/devices/legacy_pit.cpp
index f2fb70e..970f538 100644
--- a/arch/x86_64/src/devices/legacy_pit.cpp
+++ b/arch/x86_64/src/devices/legacy_pit.cpp
@@ -6,6 +6,7 @@
#include "arch/device_io/port_io.hpp"
+#include <cstddef>
#include <cstdint>
namespace arch::devices
@@ -19,8 +20,8 @@ namespace arch::devices
using channel_2_port = io::port<0x42, std::uint8_t, io::port_write>;
} // namespace
- legacy_pit::legacy_pit(std::uint32_t frequency_in_hz)
- : kapi::devices::device{kapi::devices::allocate_major_number(), 0, "legacy_pit"}
+ legacy_pit::legacy_pit(std::size_t major, std::uint32_t frequency_in_hz)
+ : kapi::devices::device{major, 0, "legacy_pit"}
, m_irq_number{0}
, m_frequency_in_hz{frequency_in_hz}
{}
diff --git a/kernel/kapi/devices.cpp b/kernel/kapi/devices.cpp
index 7d35778..031f2c9 100644
--- a/kernel/kapi/devices.cpp
+++ b/kernel/kapi/devices.cpp
@@ -19,7 +19,7 @@ namespace kapi::devices
namespace
{
- auto constinit next_major_number = std::atomic_size_t{0};
+ auto constinit next_major_number = std::atomic_size_t{1};
auto constinit root_bus = std::optional<kernel::devices::root_bus>{};
auto constinit device_tree = kstd::flat_map<std::pair<std::size_t, std::size_t>, kstd::observer_ptr<device>>{};
} // namespace
diff --git a/kernel/src/devices/root_bus.cpp b/kernel/src/devices/root_bus.cpp
index d3ba23f..43a35bf 100644
--- a/kernel/src/devices/root_bus.cpp
+++ b/kernel/src/devices/root_bus.cpp
@@ -6,7 +6,7 @@ namespace kernel::devices
{
root_bus::root_bus()
- : kapi::devices::bus{kapi::devices::allocate_major_number(), 0, "system"}
+ : kapi::devices::bus{0, 0, "system"}
{}
} // namespace kernel::devices \ No newline at end of file