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