[Zion][Yellowstone] First pass at adding PCI ioport access.
This commit is contained in:
parent
f2c2cff98a
commit
b677633248
16 changed files with 337 additions and 199 deletions
60
zion/object/pci_port.h
Normal file
60
zion/object/pci_port.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include <glacier/memory/ref_ptr.h>
|
||||
|
||||
#include "include/ztypes.h"
|
||||
#include "object/kernel_object.h"
|
||||
|
||||
class PciPort;
|
||||
class PciPortBound;
|
||||
|
||||
template <>
|
||||
struct KernelObjectTag<PciPort> {
|
||||
static const uint64_t type = KernelObject::PCI_CAP;
|
||||
};
|
||||
|
||||
class PciPort : public KernelObject {
|
||||
public:
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Write | kZionPerm_Read | kZionPerm_Duplicate |
|
||||
kZionPerm_Transmit;
|
||||
}
|
||||
|
||||
uint64_t TypeTag() override { return KernelObject::PCI_CAP; }
|
||||
|
||||
static glcr::RefPtr<PciPort> Create() { return glcr::AdoptPtr(new PciPort); }
|
||||
|
||||
uint32_t ReadAtOffset(uint8_t bus, uint8_t slot, uint8_t func,
|
||||
uint8_t offset);
|
||||
|
||||
private:
|
||||
PciPort() {}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct KernelObjectTag<PciPortBound> {
|
||||
static const uint64_t type = KernelObject::PCI_BOUND_CAP;
|
||||
};
|
||||
|
||||
class PciPortBound : public KernelObject {
|
||||
public:
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Write | kZionPerm_Read | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
uint64_t TypeTag() override { return KernelObject::PCI_BOUND_CAP; }
|
||||
|
||||
static glcr::RefPtr<PciPortBound> Create(uint8_t bus, uint8_t slot,
|
||||
uint8_t func) {
|
||||
return glcr::AdoptPtr(new PciPortBound(bus, slot, func));
|
||||
}
|
||||
|
||||
uint32_t Read(uint8_t offset);
|
||||
void Write(uint8_t offset, uint32_t data);
|
||||
|
||||
private:
|
||||
PciPortBound(uint8_t bus, uint8_t slot, uint8_t func)
|
||||
: bus_(bus), slot_(slot), func_(func) {}
|
||||
|
||||
uint8_t bus_;
|
||||
uint8_t slot_;
|
||||
uint8_t func_;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue