kernel/ATA: Avoid assuming endianness

This commit is contained in:
apio 2024-07-21 12:51:06 +02:00
parent 31c36b9b83
commit c97876bba0
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -7,6 +7,7 @@
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include "thread/Clock.h" #include "thread/Clock.h"
#include "thread/Scheduler.h" #include "thread/Scheduler.h"
#include <endian.h>
#include <luna/Alignment.h> #include <luna/Alignment.h>
#include <luna/Buffer.h> #include <luna/Buffer.h>
#include <luna/CType.h> #include <luna/CType.h>
@ -517,9 +518,8 @@ namespace ATA
m_is_lba48 = true; m_is_lba48 = true;
// FIXME: This assumes the host machine is little-endian. u32 last_lba = be32toh(reply.last_lba);
u32 last_lba = __builtin_bswap32(reply.last_lba); u32 sector_size = be32toh(reply.sector_size);
u32 sector_size = __builtin_bswap32(reply.sector_size);
m_block_count = last_lba + 1; m_block_count = last_lba + 1;
m_block_size = sector_size; m_block_size = sector_size;