[zion] Use ErrorOr in PciConfiguration
This commit is contained in:
parent
3a3ab8717b
commit
c2dfe17363
|
@ -12,7 +12,7 @@ class ErrorOr {
|
||||||
ErrorOr(ErrorOr&&) = delete;
|
ErrorOr(ErrorOr&&) = delete;
|
||||||
|
|
||||||
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
|
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
|
||||||
ErrorOr(T obj) : obj_(obj), ok_(true) {}
|
ErrorOr(const T& obj) : obj_(obj), ok_(true) {}
|
||||||
ErrorOr(T&& obj) : obj_(obj), ok_(true) {}
|
ErrorOr(T&& obj) : obj_(obj), ok_(true) {}
|
||||||
|
|
||||||
bool ok() { return ok_; }
|
bool ok() { return ok_; }
|
||||||
|
|
|
@ -255,12 +255,10 @@ void ProbeRsdp() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
z_err_t GetPciExtendedConfiguration(uint64_t* base, uint64_t* offset) {
|
glcr::ErrorOr<PcieConfiguration> GetPciExtendedConfiguration() {
|
||||||
if (gPcieEcSize == 0) {
|
if (gPcieEcSize == 0) {
|
||||||
return glcr::NOT_FOUND;
|
return glcr::NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
*base = gPcieEcBase;
|
return PcieConfiguration{gPcieEcBase, gPcieEcSize};
|
||||||
*offset = gPcieEcSize;
|
|
||||||
return glcr::OK;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glacier/status/error_or.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "include/ztypes.h"
|
#include "include/ztypes.h"
|
||||||
|
|
||||||
void ProbeRsdp();
|
void ProbeRsdp();
|
||||||
|
|
||||||
z_err_t GetPciExtendedConfiguration(uint64_t* base, uint64_t* offset);
|
struct PcieConfiguration {
|
||||||
|
uint64_t base;
|
||||||
|
uint64_t offset;
|
||||||
|
};
|
||||||
|
glcr::ErrorOr<PcieConfiguration> GetPciExtendedConfiguration();
|
||||||
|
|
|
@ -32,11 +32,11 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) {
|
||||||
|
|
||||||
z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req) {
|
z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req) {
|
||||||
auto& curr_proc = gScheduler->CurrentProcess();
|
auto& curr_proc = gScheduler->CurrentProcess();
|
||||||
uint64_t pci_base, pci_size;
|
ASSIGN_OR_RETURN(PcieConfiguration config, GetPciExtendedConfiguration());
|
||||||
RET_ERR(GetPciExtendedConfiguration(&pci_base, &pci_size));
|
auto vmmo_ref =
|
||||||
auto vmmo_ref = glcr::MakeRefCounted<FixedMemoryObject>(pci_base, pci_size);
|
glcr::MakeRefCounted<FixedMemoryObject>(config.base, config.offset);
|
||||||
*req->vmmo_cap = curr_proc.AddNewCapability(
|
*req->vmmo_cap = curr_proc.AddNewCapability(
|
||||||
StaticCastRefPtr<MemoryObject>(vmmo_ref), ZC_WRITE);
|
StaticCastRefPtr<MemoryObject>(vmmo_ref), ZC_WRITE);
|
||||||
*req->vmmo_size = pci_size;
|
*req->vmmo_size = config.offset;
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue