[denali] Get Ahci device address from yellowstone.
This commit is contained in:
parent
02e6b49d90
commit
16dd675828
11 changed files with 125 additions and 52 deletions
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
const uint64_t kSataPciPhys = 0xB00FA000;
|
||||
const uint64_t kPciSize = 0x1000;
|
||||
|
||||
const uint64_t kGhc_InteruptEnable = 0x2;
|
||||
|
|
@ -155,7 +154,7 @@ void AhciDriver::InterruptLoop() {
|
|||
}
|
||||
|
||||
glcr::ErrorCode AhciDriver::LoadPciDeviceHeader() {
|
||||
pci_region_ = MappedMemoryRegion::DirectPhysical(kSataPciPhys, kPciSize);
|
||||
pci_region_ = MappedMemoryRegion::DirectPhysical(ahci_phys_, kPciSize);
|
||||
pci_device_header_ = reinterpret_cast<PciDeviceHeader*>(pci_region_.vaddr());
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
class AhciDriver {
|
||||
public:
|
||||
AhciDriver(uint64_t ahci_phys) : ahci_phys_(ahci_phys) {}
|
||||
glcr::ErrorCode Init();
|
||||
|
||||
void InterruptLoop();
|
||||
|
|
@ -19,6 +20,7 @@ class AhciDriver {
|
|||
void DumpPorts();
|
||||
|
||||
private:
|
||||
uint64_t ahci_phys_;
|
||||
MappedMemoryRegion pci_region_;
|
||||
PciDeviceHeader* pci_device_header_ = nullptr;
|
||||
MappedMemoryRegion ahci_region_;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ glcr::ErrorOr<MappedMemoryRegion> DenaliClient::ReadSectors(
|
|||
.lba = lba,
|
||||
.size = num_sectors,
|
||||
};
|
||||
auto pair_or = endpoint_->CallEndpoint<DenaliRead, DenaliReadResponse>(read);
|
||||
auto pair_or =
|
||||
endpoint_->CallEndpointGetCap<DenaliRead, DenaliReadResponse>(read);
|
||||
if (!pair_or) {
|
||||
return pair_or.error();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,18 +11,28 @@
|
|||
|
||||
uint64_t main(uint64_t init_port_cap) {
|
||||
check(ParseInitPort(init_port_cap));
|
||||
AhciDriver driver;
|
||||
RET_ERR(driver.Init());
|
||||
|
||||
glcr::UniquePtr<EndpointClient> yellowstone =
|
||||
EndpointClient::AdoptEndpoint(gInitEndpointCap);
|
||||
YellowstoneGetReq ahci_req{
|
||||
.type = kYellowstoneGetAhci,
|
||||
};
|
||||
auto resp_or =
|
||||
yellowstone->CallEndpoint<YellowstoneGetReq, YellowstoneGetAhciResp>(
|
||||
ahci_req);
|
||||
if (!resp_or.ok()) {
|
||||
check(resp_or.error());
|
||||
}
|
||||
|
||||
uint64_t ahci_addr = resp_or.value().ahci_phys_offset;
|
||||
AhciDriver driver(ahci_addr);
|
||||
RET_ERR(driver.Init());
|
||||
|
||||
YellowstoneGetReq req{
|
||||
.type = kYellowstoneGetRegistration,
|
||||
};
|
||||
auto resp_cap_or =
|
||||
yellowstone
|
||||
->CallEndpoint<YellowstoneGetReq, YellowstoneGetRegistrationResp>(
|
||||
req);
|
||||
yellowstone->CallEndpointGetCap<YellowstoneGetReq,
|
||||
YellowstoneGetRegistrationResp>(req);
|
||||
if (!resp_cap_or.ok()) {
|
||||
dbgln("Bad call");
|
||||
check(resp_cap_or.error());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue