11 #include "cdi-osdep.h" 12 #include "cdi/lists.h" 14 #include "pedigree/kernel/compiler.h" 15 #include "pedigree/kernel/machine/Device.h" 16 #include "pedigree/kernel/utilities/Vector.h" 17 #include "pedigree/kernel/utilities/utility.h" 21 static void add_child_device(cdi_list_t list,
Device *pDev)
25 struct cdi_pci_device* dev = (
struct cdi_pci_device*) malloc(
sizeof(*dev));
26 ByteSet(dev, 0,
sizeof(*dev));
33 dev->meta.backdev =
reinterpret_cast<void*
>(pDev);
37 dev->resources = cdi_list_create();
38 for (
unsigned int j = 0; j < addresses.
size(); j++) {
41 struct cdi_pci_resource* res = (
struct cdi_pci_resource*) malloc(
sizeof(*res));
42 ByteSet(res, 0,
sizeof(*res));
44 res->type = bar->
m_IsIoSpace ? CDI_PCI_IOPORTS : CDI_PCI_MEMORY;
50 cdi_list_push(dev->resources, res);
53 cdi_list_push(list, dev);
62 auto f = [list] (
Device *p) {
63 add_child_device(list, p);
67 auto c = pedigree_std::make_callable(f);
74 EXPORTED_PUBLIC void cdi_pci_device_destroy(
struct cdi_pci_device* device)
83 EXPORTED_PUBLIC void cdi_pci_alloc_ioports(
struct cdi_pci_device* device)
85 struct cdi_pci_resource* res;
88 for (i = 0; (res = (
struct cdi_pci_resource*) cdi_list_get(device->resources, i)); i++) {
89 if (res->type == CDI_PCI_IOPORTS) {
98 EXPORTED_PUBLIC void cdi_pci_free_ioports(
struct cdi_pci_device* device)
100 struct cdi_pci_resource* res;
103 for (i = 0; (res = (
struct cdi_pci_resource*)cdi_list_get(device->resources, i)); i++) {
104 if (res->type == CDI_PCI_IOPORTS) {
112 EXPORTED_PUBLIC void cdi_pci_alloc_memory(
struct cdi_pci_device* device)
114 struct cdi_pci_resource* res;
117 for (i = 0; (res = (
struct cdi_pci_resource*)cdi_list_get(device->resources, i)); i++) {
118 if (res->type == CDI_PCI_MEMORY) {
127 EXPORTED_PUBLIC void cdi_pci_free_memory(
struct cdi_pci_device* device)
129 struct cdi_pci_resource* res;
132 for (i = 0; (res = (
struct cdi_pci_resource*)cdi_list_get(device->resources, i)); i++) {
133 if (res->type == CDI_PCI_MEMORY) {
uint8_t getPciSubclassCode()
virtual Vector< Address * > & addresses()
virtual uintptr_t getInterruptNumber()
uint16_t getPciDeviceId()
static void foreach(Callback callback, Device *root=0)
uint8_t getPciClassCode()
uint16_t getPciVendorId()