1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

Kernel/Storage: Remove the ramdisk implementation

Nobody uses this because the x86 prekernel environment is corrupting the
ramdisk image prior to running the actual kernel. In the future we can
ensure that the prekernel doesn't corrupt the ramdisk if we want to
bring support back. In addition to that, we could just use a RAM based
filesystem to load whatever is needed like in Linux, without the need of
additional filesystem driver.

For the mentioned corruption problem, look at issue #9893.
This commit is contained in:
Liav A 2022-08-10 22:08:41 +03:00 committed by Andreas Kling
parent 37f527be9c
commit 4e0f85432a
9 changed files with 0 additions and 227 deletions

View file

@ -1,60 +0,0 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Memory.h>
#include <AK/StringView.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/Storage/Ramdisk/Controller.h>
#include <Kernel/Storage/Ramdisk/Device.h>
namespace Kernel {
NonnullLockRefPtr<RamdiskDevice> RamdiskDevice::create(RamdiskController const& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor)
{
auto device_or_error = DeviceManagement::try_create_device<RamdiskDevice>(controller, move(region), major, minor);
// FIXME: Find a way to propagate errors
VERIFY(!device_or_error.is_error());
return device_or_error.release_value();
}
RamdiskDevice::RamdiskDevice(RamdiskController const& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor)
: StorageDevice({}, LUNAddress { controller.controller_id(), 0, 0 }, 0, major, minor, 512, region->size() / 512)
, m_region(move(region))
{
dmesgln("Ramdisk: Device #{} @ {}, Capacity={}", minor, m_region->vaddr(), max_addressable_block() * 512);
}
RamdiskDevice::~RamdiskDevice() = default;
StringView RamdiskDevice::class_name() const
{
return "RamdiskDevice"sv;
}
void RamdiskDevice::start_request(AsyncBlockDeviceRequest& request)
{
MutexLocker locker(m_lock);
u8* base = m_region->vaddr().as_ptr();
size_t size = m_region->size();
u8* offset = base + request.block_index() * request.block_size();
size_t length = request.buffer_size();
if ((offset + length > base + size) || (offset + length < base)) {
request.complete(AsyncDeviceRequest::Failure);
} else {
ErrorOr<void> result;
if (request.request_type() == AsyncBlockDeviceRequest::Read) {
result = request.buffer().write(offset, length);
} else {
result = request.buffer().read(offset, length);
}
request.complete(!result.is_error() ? AsyncDeviceRequest::Success : AsyncDeviceRequest::MemoryFault);
}
}
}