2024-02-20 23:48:09 +01:00
# 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.
2024-02-23 03:14:05 +01:00
/// @param pci_address The string to check.
2024-02-20 23:48:09 +01:00
/// @return The result of the operation.
2024-02-23 03:14:05 +01:00
result_t check_pci_address ( const char * pci_address ) ;
2024-02-20 23:48:09 +01:00
/// @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.
2024-02-23 03:14:05 +01:00
/// @param pci_address The PCI address to check.
2024-02-20 23:48:09 +01:00
/// @return The result of the operation.
2024-02-23 03:14:05 +01:00
result_t check_pci_exists ( const char * pci_address ) ;
2024-02-20 23:48:09 +01:00
/// @brief Gets the IOMMU group of the given PCI address.
/// @param _group The integer pointer to store the resulting IOMMU group in.
2024-02-23 03:14:05 +01:00
/// @param pci_address The PCI address to get the IOMMU group of.
2024-02-20 23:48:09 +01:00
/// @return The result of the operation.
2024-02-23 03:14:05 +01:00
result_t get_iommu_group ( int * _group , const char * pci_address ) ;
2024-02-20 23:48:09 +01:00
2024-02-21 16:39:33 +01:00
/// @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.
2024-02-23 03:14:05 +01:00
/// @param pci_addresses The PCI addresses to get the IOMMU groups of.
2024-02-21 16:39:33 +01:00
/// @return The result of the operation.
2024-02-23 03:14:05 +01:00
result_t get_iommu_groups ( int * * _groups , int * _count , const char * * pci_addresses ) ;
2024-02-21 16:39:33 +01:00
2024-02-20 23:48:09 +01:00
/// @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.
2024-02-21 16:39:33 +01:00
result_t get_iommu_group_devices ( char * * * _devices , int group ) ;
2024-02-21 17:30:13 +01:00
/// @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 ) ;