[Denali] Record SATA device sector size and count.
This commit is contained in:
parent
e308d8e120
commit
0375306f5e
|
@ -55,10 +55,20 @@ glcr::ErrorCode AhciPort::Identify() {
|
||||||
ASSIGN_OR_RETURN(auto* sem, IssueCommand(identify));
|
ASSIGN_OR_RETURN(auto* sem, IssueCommand(identify));
|
||||||
sem->Wait();
|
sem->Wait();
|
||||||
uint16_t* ident = reinterpret_cast<uint16_t*>(region.vaddr());
|
uint16_t* ident = reinterpret_cast<uint16_t*>(region.vaddr());
|
||||||
uint32_t* sector_size = reinterpret_cast<uint32_t*>(ident + 117);
|
if (ident[106] & (1 << 12)) {
|
||||||
dbgln("Sector size: {}", *sector_size);
|
sector_size_ = *reinterpret_cast<uint32_t*>(ident + 117);
|
||||||
uint64_t* lbas = reinterpret_cast<uint64_t*>(ident + 100);
|
} else {
|
||||||
dbgln("LBA Count: {}", *lbas);
|
sector_size_ = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ident[83] & (1 << 10)) {
|
||||||
|
lba_count_ = *reinterpret_cast<uint64_t*>(ident + 100);
|
||||||
|
} else {
|
||||||
|
lba_count_ = *reinterpret_cast<uint32_t*>(ident + 60);
|
||||||
|
}
|
||||||
|
dbgln("Sector size: {x}", sector_size_);
|
||||||
|
dbgln("LBA Count: {x}", lba_count_);
|
||||||
|
is_init_ = true;
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AhciPort {
|
||||||
void DumpInfo();
|
void DumpInfo();
|
||||||
|
|
||||||
bool IsSata() { return port_struct_->signature == 0x101; }
|
bool IsSata() { return port_struct_->signature == 0x101; }
|
||||||
bool IsInit() { return port_struct_ != nullptr && command_structures_; }
|
bool IsInit() { return is_init_; }
|
||||||
|
|
||||||
glcr::ErrorCode Identify();
|
glcr::ErrorCode Identify();
|
||||||
|
|
||||||
|
@ -43,5 +43,9 @@ class AhciPort {
|
||||||
glcr::Array<mmth::Semaphore> command_signals_;
|
glcr::Array<mmth::Semaphore> command_signals_;
|
||||||
uint32_t commands_issued_ = 0;
|
uint32_t commands_issued_ = 0;
|
||||||
|
|
||||||
|
bool is_init_ = false;
|
||||||
|
uint64_t lba_count_ = 0;
|
||||||
|
uint32_t sector_size_ = 0;
|
||||||
|
|
||||||
glcr::ErrorOr<mmth::Semaphore*> IssueCommand(const CommandInfo& command);
|
glcr::ErrorOr<mmth::Semaphore*> IssueCommand(const CommandInfo& command);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue