linuxinstall/src/pci.h

44 lines
2.4 KiB
C

#pragma once
#include "utils.h"
/// @brief Checks whether the given string is a valid PCI address. If the string is not a valid PCI address, the call will return a failure result with an error message.
/// @param pci_address The string to check.
/// @return The result of the operation.
result_t check_pci_address(const char* pci_address);
/// @brief Checks whether the given PCI address exists. If the PCI address does not exist, the call will return a failure result with an error message.
/// @param pci_address The PCI address to check.
/// @return The result of the operation.
result_t check_pci_exists(const char* pci_address);
/// @brief Gets the IOMMU group of the given PCI address.
/// @param _group The integer pointer to store the resulting IOMMU group in.
/// @param pci_address The PCI address to get the IOMMU group of.
/// @return The result of the operation.
result_t get_iommu_group(int* _group, const char* pci_address);
/// @brief Gets the IOMMU groups of the given PCI addresses.
/// @param _groups The integer array pointer to store the resulting IOMMU groups in. The caller is responsible for freeing the array.
/// @param _count The integer pointer to store the number of IOMMU groups in.
/// @param pci_addresses The PCI addresses to get the IOMMU groups of.
/// @return The result of the operation.
result_t get_iommu_groups(int** _groups, int* _count, const char** pci_addresses);
/// @brief Checks that the given file is a PCI device. This function is used as a filter for listing PCI devices.
/// @param file The file to check.
/// @return Whether the file is a PCI device.
bool pci_filter(const char* file);
/// @brief Get the PCI devices in the given IOMMU group.
/// @param _devices The string array pointer to store the resulting devices in. The caller is responsible for freeing the strings and the array.
/// @param group The IOMMU group to get the devices of.
/// @return The result of the operation.
result_t get_iommu_group_devices(char*** _devices, int group);
/// @brief Get the PCI devices in the given IOMMU groups.
/// @param _devices The string array pointer to store the resulting devices in. The caller is responsible for freeing the strings and the array.
/// @param groups The IOMMU groups to get the devices of.
/// @param groups_count The number of IOMMU groups.
/// @return The result of the operation.
result_t get_iommu_groups_devices(char*** _devices, const int* groups, int groups_count);