blob: 48b9116d5b7f0327ede7aa15f157ce5897c112bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include "devices/storage/RAMDisk/RAMDiskController.hpp"
#include "kapi/boot_module/boot_module.hpp"
#include "kapi/boot_module/boot_module_registry.hpp"
#include "devices/storage/RAMDisk/RAMDiskDevice.hpp"
#include <kstd/print>
#include <algorithm>
#include <cstddef>
namespace devices::storage::ram_disk
{
ram_disk_controller::ram_disk_controller(kapi::boot_modules::boot_module_registry const * registry)
: m_boot_module_registry(registry)
{}
auto ram_disk_controller::probe() -> void
{
std::ranges::for_each(*m_boot_module_registry,
[this](auto const & module) { create_device_from_boot_module(module); });
// TODO BA-FS26 just for testing, remove again
std::ranges::for_each(m_devices, [](auto const & device) { device.read_block(0, nullptr); });
}
auto ram_disk_controller::create_device_from_boot_module(kapi::boot_modules::boot_module const & module) -> void
{
m_devices.at(0) = ram_disk_device{module.start_address, module.size};
kstd::println("[RAM DISK CONTROLLER] Found boot module: {} at address {} with size {} bytes", module.name,
module.start_address, module.size);
}
auto ram_disk_controller::devices_count() -> size_t
{
return m_devices.size();
}
} // namespace devices::storage::ram_disk
|