[Zion][Yellowstone] First pass at adding PCI ioport access.

This commit is contained in:
Drew Galbraith 2025-05-07 01:44:09 -07:00
parent f2c2cff98a
commit b677633248
16 changed files with 337 additions and 199 deletions

44
zion/syscall/pci.cpp Normal file
View file

@ -0,0 +1,44 @@
#include "syscall/pci.h"
#include "object/pci_port.h"
#include "scheduler/scheduler.h"
z_err_t PciRead(ZPciReadReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto pci_cap = curr_proc.GetCapability(req->pci_cap);
RET_ERR(ValidateCapability<PciPort>(pci_cap, kZionPerm_Read));
*req->output = pci_cap->obj<PciPort>()->ReadAtOffset(req->bus, req->slot,
req->func, req->offset);
return glcr::OK;
}
z_err_t PciCreateBound(ZPciCreateBoundReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto pci_cap = curr_proc.GetCapability(req->pci_cap);
RET_ERR(ValidateCapability<PciPort>(pci_cap, kZionPerm_Duplicate));
*req->new_cap = curr_proc.AddNewCapability(
PciPortBound::Create(req->bus, req->slot, req->func));
return glcr::OK;
}
z_err_t PciReadBound(ZPciReadBoundReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto pci_cap = curr_proc.GetCapability(req->pci_cap);
RET_ERR(ValidateCapability<PciPortBound>(pci_cap, kZionPerm_Read));
*req->data = pci_cap->obj<PciPortBound>()->Read(req->offset);
return glcr::OK;
}
z_err_t PciWriteBound(ZPciWriteBoundReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto pci_cap = curr_proc.GetCapability(req->pci_cap);
RET_ERR(ValidateCapability<PciPortBound>(pci_cap, kZionPerm_Write));
pci_cap->obj<PciPortBound>()->Write(req->offset, req->data);
return glcr::OK;
}