kernel/ATA: Read ATA strings properly instead of backwards
Now we can see the model string. What does it say... "QEMU DVD-ROM". Let's go!
This commit is contained in:
parent
e118c9ea0d
commit
6307b01689
@ -12,6 +12,20 @@ static void irq_handler(Registers* regs, void* ctx)
|
||||
((ATA::Channel*)ctx)->irq_handler(regs);
|
||||
}
|
||||
|
||||
static usize copy_ata_string(char* out, u16* in, usize size)
|
||||
{
|
||||
for (usize i = 0; i < size; i += 2)
|
||||
{
|
||||
u16 val = in[i / 2];
|
||||
out[i] = (u8)(val >> 8);
|
||||
out[i + 1] = (u8)(val & 0xff);
|
||||
}
|
||||
|
||||
out[size + 1] = '\0';
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
namespace ATA
|
||||
{
|
||||
Result<void> Controller::scan()
|
||||
@ -275,9 +289,9 @@ namespace ATA
|
||||
|
||||
if (!identify_ata()) return false;
|
||||
|
||||
m_serial = StringView::from_fixed_size_cstring((const char*)&m_identify_words[10], SERIAL_LEN);
|
||||
m_revision = StringView::from_fixed_size_cstring((const char*)&m_identify_words[23], REVISION_LEN);
|
||||
m_model = StringView::from_fixed_size_cstring((const char*)&m_identify_words[27], MODEL_LEN);
|
||||
m_serial.set_length(copy_ata_string(m_serial.data(), &m_identify_words[10], SERIAL_LEN));
|
||||
m_revision.set_length(copy_ata_string(m_revision.data(), &m_identify_words[23], REVISION_LEN));
|
||||
m_model.set_length(copy_ata_string(m_model.data(), &m_identify_words[27], MODEL_LEN));
|
||||
|
||||
m_serial.trim(" ");
|
||||
m_revision.trim(" ");
|
||||
|
@ -62,6 +62,16 @@ template <usize Size> class StaticString
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
char* data()
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
void set_length(usize len)
|
||||
{
|
||||
m_length = len;
|
||||
}
|
||||
|
||||
usize length() const
|
||||
{
|
||||
return m_length;
|
||||
|
Loading…
Reference in New Issue
Block a user