mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Expose block size in AsyncBlockDeviceRequest struct
Expose the block size variable via a member function in the AsyncBlockDeviceRequest so that the driver doesn't need to assume any value such as 512 bytes.
This commit is contained in:
parent
4b2094506b
commit
2786a71bc0
Notes:
sideshowbarker
2024-07-17 16:41:29 +09:00
Author: https://github.com/Panky-codes Commit: https://github.com/SerenityOS/serenity/commit/2786a71bc0 Pull-request: https://github.com/SerenityOS/serenity/pull/13282 Reviewed-by: https://github.com/bgianfo ✅
1 changed files with 40 additions and 39 deletions
|
@ -12,45 +12,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
class BlockDevice;
|
||||
|
||||
class AsyncBlockDeviceRequest final : public AsyncDeviceRequest {
|
||||
public:
|
||||
enum RequestType {
|
||||
Read,
|
||||
Write
|
||||
};
|
||||
AsyncBlockDeviceRequest(Device& block_device, RequestType request_type,
|
||||
u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size);
|
||||
|
||||
RequestType request_type() const { return m_request_type; }
|
||||
u64 block_index() const { return m_block_index; }
|
||||
u32 block_count() const { return m_block_count; }
|
||||
UserOrKernelBuffer& buffer() { return m_buffer; }
|
||||
const UserOrKernelBuffer& buffer() const { return m_buffer; }
|
||||
size_t buffer_size() const { return m_buffer_size; }
|
||||
|
||||
virtual void start() override;
|
||||
virtual StringView name() const override
|
||||
{
|
||||
switch (m_request_type) {
|
||||
case Read:
|
||||
return "BlockDeviceRequest (read)"sv;
|
||||
case Write:
|
||||
return "BlockDeviceRequest (write)"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BlockDevice& m_block_device;
|
||||
const RequestType m_request_type;
|
||||
const u64 m_block_index;
|
||||
const u32 m_block_count;
|
||||
UserOrKernelBuffer m_buffer;
|
||||
const size_t m_buffer_size;
|
||||
};
|
||||
class AsyncBlockDeviceRequest;
|
||||
|
||||
class BlockDevice : public Device {
|
||||
public:
|
||||
|
@ -83,4 +45,43 @@ private:
|
|||
u8 m_block_size_log { 0 };
|
||||
};
|
||||
|
||||
class AsyncBlockDeviceRequest final : public AsyncDeviceRequest {
|
||||
public:
|
||||
enum RequestType {
|
||||
Read,
|
||||
Write
|
||||
};
|
||||
AsyncBlockDeviceRequest(Device& block_device, RequestType request_type,
|
||||
u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size);
|
||||
|
||||
RequestType request_type() const { return m_request_type; }
|
||||
u64 block_index() const { return m_block_index; }
|
||||
u32 block_count() const { return m_block_count; }
|
||||
size_t block_size() const { return m_block_device.block_size(); }
|
||||
UserOrKernelBuffer& buffer() { return m_buffer; }
|
||||
const UserOrKernelBuffer& buffer() const { return m_buffer; }
|
||||
size_t buffer_size() const { return m_buffer_size; }
|
||||
|
||||
virtual void start() override;
|
||||
virtual StringView name() const override
|
||||
{
|
||||
switch (m_request_type) {
|
||||
case Read:
|
||||
return "BlockDeviceRequest (read)"sv;
|
||||
case Write:
|
||||
return "BlockDeviceRequest (write)"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BlockDevice& m_block_device;
|
||||
const RequestType m_request_type;
|
||||
const u64 m_block_index;
|
||||
const u32 m_block_count;
|
||||
UserOrKernelBuffer m_buffer;
|
||||
const size_t m_buffer_size;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue