mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-30 14:43:38 +03:00
Kernel: Refactor storage stack with u64 as block index
This commit is contained in:
parent
9a3aa7eb0b
commit
999c57ef2d
Notes:
sideshowbarker
2024-07-18 21:16:03 +09:00
Author: https://github.com/boricj Commit: https://github.com/SerenityOS/serenity/commit/999c57ef2df Pull-request: https://github.com/SerenityOS/serenity/pull/5766 Reviewed-by: https://github.com/supercomputer7
@ -28,7 +28,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u32 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
: AsyncDeviceRequest(block_device)
|
||||
, m_block_device(static_cast<BlockDevice&>(block_device))
|
||||
, m_request_type(request_type)
|
||||
@ -48,7 +48,7 @@ BlockDevice::~BlockDevice()
|
||||
{
|
||||
}
|
||||
|
||||
bool BlockDevice::read_block(unsigned index, UserOrKernelBuffer& buffer)
|
||||
bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
|
||||
{
|
||||
auto read_request = make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Read, index, 1, buffer, 512);
|
||||
switch (read_request->wait().request_result()) {
|
||||
@ -69,7 +69,7 @@ bool BlockDevice::read_block(unsigned index, UserOrKernelBuffer& buffer)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BlockDevice::write_block(unsigned index, const UserOrKernelBuffer& buffer)
|
||||
bool BlockDevice::write_block(u64 index, const UserOrKernelBuffer& buffer)
|
||||
{
|
||||
auto write_request = make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Write, index, 1, buffer, 512);
|
||||
switch (write_request->wait().request_result()) {
|
||||
|
@ -39,10 +39,10 @@ public:
|
||||
Write
|
||||
};
|
||||
AsyncBlockDeviceRequest(Device& block_device, RequestType request_type,
|
||||
u32 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size);
|
||||
u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size);
|
||||
|
||||
RequestType request_type() const { return m_request_type; }
|
||||
u32 block_index() const { return m_block_index; }
|
||||
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; }
|
||||
@ -64,7 +64,7 @@ public:
|
||||
private:
|
||||
BlockDevice& m_block_device;
|
||||
const RequestType m_request_type;
|
||||
const u32 m_block_index;
|
||||
const u64 m_block_index;
|
||||
const u32 m_block_count;
|
||||
UserOrKernelBuffer m_buffer;
|
||||
const size_t m_buffer_size;
|
||||
@ -77,8 +77,8 @@ public:
|
||||
size_t block_size() const { return m_block_size; }
|
||||
virtual bool is_seekable() const override { return true; }
|
||||
|
||||
bool read_block(unsigned index, UserOrKernelBuffer&);
|
||||
bool write_block(unsigned index, const UserOrKernelBuffer&);
|
||||
bool read_block(u64 index, UserOrKernelBuffer&);
|
||||
bool write_block(u64 index, const UserOrKernelBuffer&);
|
||||
|
||||
virtual void start_request(AsyncBlockDeviceRequest&) = 0;
|
||||
|
||||
|
@ -401,7 +401,7 @@ UNMAP_AFTER_INIT void IDEChannel::detect_disks()
|
||||
}
|
||||
}
|
||||
|
||||
void IDEChannel::ata_access(Direction direction, bool slave_request, u32 lba, u8 block_count, u16 capabilities, bool use_dma)
|
||||
void IDEChannel::ata_access(Direction direction, bool slave_request, u64 lba, u8 block_count, u16 capabilities, bool use_dma)
|
||||
{
|
||||
LBAMode lba_mode;
|
||||
u8 head = 0;
|
||||
@ -432,8 +432,8 @@ void IDEChannel::ata_access(Direction direction, bool slave_request, u32 lba, u8
|
||||
if (lba_mode == LBAMode::FortyEightBit) {
|
||||
m_io_group.io_base().offset(ATA_REG_SECCOUNT1).out<u8>(0);
|
||||
m_io_group.io_base().offset(ATA_REG_LBA3).out<u8>((lba & 0xFF000000) >> 24);
|
||||
m_io_group.io_base().offset(ATA_REG_LBA4).out<u8>(0);
|
||||
m_io_group.io_base().offset(ATA_REG_LBA5).out<u8>(0);
|
||||
m_io_group.io_base().offset(ATA_REG_LBA4).out<u8>((lba & 0xFF00000000ull) >> 32);
|
||||
m_io_group.io_base().offset(ATA_REG_LBA5).out<u8>((lba & 0xFF0000000000ull) >> 40);
|
||||
}
|
||||
|
||||
m_io_group.io_base().offset(ATA_REG_SECCOUNT0).out<u8>(block_count);
|
||||
@ -470,7 +470,7 @@ void IDEChannel::ata_access(Direction direction, bool slave_request, u32 lba, u8
|
||||
void IDEChannel::ata_read_sectors_with_dma(bool slave_request, u16 capabilities)
|
||||
{
|
||||
auto& request = *m_current_request;
|
||||
u32 lba = request.block_index();
|
||||
auto lba = request.block_index();
|
||||
dbgln_if(PATA_DEBUG, "IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count());
|
||||
|
||||
prdt().offset = m_dma_buffer_page->paddr();
|
||||
@ -530,7 +530,7 @@ void IDEChannel::ata_read_sectors(bool slave_request, u16 capabilities)
|
||||
void IDEChannel::ata_write_sectors_with_dma(bool slave_request, u16 capabilities)
|
||||
{
|
||||
auto& request = *m_current_request;
|
||||
u32 lba = request.block_index();
|
||||
auto lba = request.block_index();
|
||||
dbgln_if(PATA_DEBUG, "IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count());
|
||||
|
||||
prdt().offset = m_dma_buffer_page->paddr();
|
||||
@ -586,7 +586,7 @@ void IDEChannel::ata_write_sectors(bool slave_request, u16 capabilities)
|
||||
auto& request = *m_current_request;
|
||||
|
||||
VERIFY(request.block_count() <= 256);
|
||||
u32 start_sector = request.block_index();
|
||||
auto start_sector = request.block_index();
|
||||
u32 count = request.block_count();
|
||||
dbgln_if(PATA_DEBUG, "IDEChannel: Writing {} sector(s) @ LBA {}", count, start_sector);
|
||||
|
||||
|
@ -140,7 +140,7 @@ private:
|
||||
|
||||
void clear_pending_interrupts() const;
|
||||
|
||||
void ata_access(Direction, bool, u32, u8, u16, bool);
|
||||
void ata_access(Direction, bool, u64, u8, u16, bool);
|
||||
void ata_read_sectors_with_dma(bool, u16);
|
||||
void ata_read_sectors(bool, u16);
|
||||
bool ata_do_read_sector();
|
||||
|
Loading…
Reference in New Issue
Block a user