1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 /** 10 * @addtogroup PCIE 11 * @{ 12 * 13 * @brief Declares standard APIs of basic Peripheral Component Interconnect Express (PCIE) capabilities. 14 * 15 * You can use this module to access the PCIE and enable the driver to operate an PCIE device. 16 * These capabilities include read and write the PCIE configuration Space. 17 * 18 * @since 1.0 19 */ 20 21 /** 22 * @file pcie_if.h 23 * 24 * @brief Declares the standard PCIE interface functions. 25 * 26 * @since 1.0 27 */ 28 29 #ifndef PCIE_IF_H 30 #define PCIE_IF_H 31 32 #include "platform_if.h" 33 34 #ifdef __cplusplus 35 #if __cplusplus 36 extern "C" { 37 #endif 38 #endif /* __cplusplus */ 39 40 /** 41 * @brief Opens an PCIE controller with a specified bus number. 42 * 43 * Before using the PCIE interface, you can obtain the device handle of the PCIE controller 44 * by calling {@link PcieOpen}. This function is used in pair with {@link PcieClose}. 45 * 46 * @param busNum Indicates the bus number. 47 * 48 * @return Returns the device handle {@link DevHandle} of the PCIE controller if the operation is successful; 49 * returns <b>NULL</b> otherwise. 50 * 51 * @since 1.0 52 */ 53 DevHandle PcieOpen(uint16_t busNum); 54 55 /** 56 * @brief Reads a given length of data from the PCIE configuration Space. 57 * 58 * @param handle Indicates the pointer to the device handle of the PCIE controller obtained by {@link PcieOpen}. 59 * @param pos Indicates the start address of the data to read. 60 * @param data Indicates the pointer to the data to read. 61 * @param len Indicates the length of the data to read. 62 * 63 * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails. 64 * 65 * @since 1.0 66 */ 67 int32_t PcieRead(DevHandle handle, uint32_t pos, uint8_t *data, uint32_t len); 68 69 /** 70 * @brief Writes a given length of data into the PCIE configuration Space. 71 * 72 * @param handle Indicates the pointer to the device handle of the PCIE controller obtained by {@link PcieOpen}. 73 * @param pos Indicates the start address of the data to write. 74 * @param data Indicates the pointer to the data to write. 75 * @param len Indicates the length of the data to write. 76 * 77 * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails. 78 * 79 * @since 1.0 80 */ 81 int32_t PcieWrite(DevHandle handle, uint32_t pos, uint8_t *data, uint32_t len); 82 83 /** 84 * @brief Closes an PCIE controller. 85 * 86 * After the PCIE interface is used, you can close the PCIE controller by calling {@link PcieClose}. 87 * This function is used in pair with {@link PcieOpen}. 88 * 89 * @param handle Indicates the pointer to the device handle of the PCIE controller. 90 * 91 * @since 1.0 92 */ 93 void PcieClose(DevHandle handle); 94 95 #ifdef __cplusplus 96 #if __cplusplus 97 } 98 #endif 99 #endif /* __cplusplus */ 100 101 #endif /* PCIE_IF_H */ 102