#include "RQPCIErrors.h"

typedef struct 
{
	RETURN_CODE		code;
	char *			text;
} pciAPIErrors ;

pciAPIErrors pciApiErrors[] =
{
    { ApiSuccess,                   "PCISuccess"                   },
    { ApiFailed,                    "PCIFailed"                    },
    { ApiAccessDenied,              "PCIAccessDenied"              },
    { ApiDmaChannelUnavailable,     "PCIDmaChannelUnavailable"     },
    { ApiDmaChannelInvalid,         "PCIDmaChannelInvalid"         },
    { ApiDmaChannelTypeError,       "PCIDmaChannelTypeError"       },
    { ApiDmaInProgress,             "PCIDmaInProgress"             },
    { ApiDmaDone,                   "PCIDmaDone"                   },
    { ApiDmaPaused,                 "PCIDmaPaused"                 },
    { ApiDmaNotPaused,              "PCIDmaNotPaused"              },
    { ApiDmaCommandInvalid,         "PCIDmaCommandInvalid"         },
    { ApiDmaManReady,               "PCIDmaManReady"               },
    { ApiDmaManNotReady,            "PCIDmaManNotReady"            },
    { ApiDmaInvalidChannelPriority, "PCIDmaInvalidChannelPriority" },
    { ApiDmaManCorrupted,           "PCIDmaManCorrupted"           },
    { ApiDmaInvalidElementIndex,    "PCIDmaInvalidElementIndex"    },
    { ApiDmaNoMoreElements,         "PCIDmaNoMoreElements"         },
    { ApiDmaSglInvalid,             "PCIDmaSglInvalid"             },
    { ApiDmaSglQueueFull,           "PCIDmaSglQueueFull"           },
    { ApiNullParam,                 "PCINullParam"                 },
    { ApiInvalidBusIndex,           "PCIInvalidBusIndex"           },
    { ApiUnsupportedFunction,       "PCIUnsupportedFunction"       },
    { ApiInvalidPciSpace,           "PCIInvalidPCISpace"           },
    { ApiInvalidIopSpace,           "PCIInvalidIopSpace"           },
    { ApiInvalidSize,               "PCIInvalidSize"               },
    { ApiInvalidAddress,            "PCIInvalidAddress"            },
    { ApiInvalidAccessType,         "PCIInvalidAccessType"         },
    { ApiInvalidIndex,              "PCIInvalidIndex"              },
    { ApiMuNotReady,                "PCIMuNotReady"                },
    { ApiMuFifoEmpty,               "PCIMuFifoEmpty"               },
    { ApiMuFifoFull,                "PCIMuFifoFull"                },
    { ApiInvalidRegister,           "PCIInvalidRegister"           },
    { ApiDoorbellClearFailed,       "PCIDoorbellClearFailed"       },
    { ApiInvalidUserPin,            "PCIInvalidUserPin"            },
    { ApiInvalidUserState,          "PCIInvalidUserState"          },
    { ApiEepromNotPresent,          "PCIEepromNotPresent"          },
    { ApiEepromTypeNotSupported,    "PCIEepromTypeNotSupported"    },
    { ApiEepromBlank,               "PCIEepromBlank"               },
    { ApiConfigAccessFailed,        "PCIConfigAccessFailed"        },
    { ApiInvalidDeviceInfo,         "PCIInvalidDeviceInfo"         },
    { ApiNoActiveDriver,            "PCINoActiveDriver"            },
    { ApiInsufficientResources,     "PCIInsufficientResources"     },
    { ApiObjectAlreadyAllocated,    "PCIObjectAlreadyAllocated"    },
    { ApiAlreadyInitialized,        "PCIAlreadyInitialized"        },
    { ApiNotInitialized,            "PCINotInitialized"            },
    { ApiBadConfigRegEndianMode,    "PCIBadConfigRegEndianMode"    },
    { ApiInvalidPowerState,         "PCIInvalidPowerState"         },
    { ApiPowerDown,                 "PCIPowerDown"                 },
    { ApiFlybyNotSupported,         "PCIFlybyNotSupported"         },
    { ApiNotSupportThisChannel,     "PCINotSupportThisChannel"     },
    { ApiNoAction,                  "PCINoAction"                  },
    { ApiHSNotSupported,            "PCIHSNotSupported"            },
    { ApiVPDNotSupported,           "PCIVPDNotSupported"           },
    { ApiVpdNotEnabled,             "PCIVpdNotEnabled"             },
    { ApiNoMoreCap,                 "PCINoMoreCap"                 },
    { ApiInvalidOffset,             "PCIInvalidOffset"             },
    { ApiBadPinDirection,           "PCIBadPinDirection"           },
    { ApiPciTimeout,                "PCITimeout"                   },
    { ApiDmaChannelClosed,          "PCIDmaChannelClosed"          },
    { ApiDmaChannelError,           "PCIDmaChannelError"           },
    { ApiInvalidHandle,             "PCIInvalidHandle"             },
    { ApiBufferNotReady,            "PCIBufferNotReady"            },
    { ApiInvalidData,               "PCIInvalidData"               },
    { ApiDoNothing,                 "PCIDoNothing"                 },
    { ApiDmaSglBuildFailed,         "PCIDmaSglBuildFailed"         },
    { ApiInvalidDriverVersion,      "PCIInvalidDriverVersion"      },
    { ApiWaitTimeout,               "PCIWaitTimeout"               },
    { ApiWaitCanceled,              "PCIWaitCanceled"              },
    { ApiLastError,                 "Unknown"                      }
} ;

RQ_API char *CALL_CONV RQ_GetPCICodeString(RETURN_CODE code)
{
	U32 i = 0;
	static char message[100];

	while (pciApiErrors[i].code != code && pciApiErrors[i].code != ApiLastError)
		i++ ;

	return pciApiErrors[i].text ;
}

