/* module FSHWA_ROUTINES.H "X-1" ** ************************************************************************** ** * ** © Copyright 2005 Hewlett-Packard Development Company, L.P. * ** * ** Confidential computer software. * ** Valid license from HP required for possession, use or copying. * ** * ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, * ** Computer Software Documentation, and Technical Data for Commercial * ** Items are licensed to the U.S. Government under vendor's standard * ** commercial license. * ** * ** Neither HP nor any of its subsidiaries shall be liable for technical * ** or editorial errors or omissions contained herein. The information * ** in this document is provided "as is" without warranty of any kind and * ** is subject to change without notice. The warranties for HP products * ** are set forth in the express limited warranty statements accompanying * ** such products. Nothing herein should be construed as constituting an * ** additional warranty. * ** * ************************************************************************** ** **++ ** FACILITY: ** ** VMS Executive (LIB_H) ** ** MODULE DESCRIPTION: ** ** This module contains support routines for the fPars ** Shared Hardware Assist (FSHWA) protocol interface. ** ** AUTHORS: ** ** Eric Rasmussen ** ** CREATION DATE: 22-Apr-2005 ** ** SUPPORTING DOCUMENTS: ** ** SPPA Firmware EAS Version 1.6 (Draft 0.56) 20-Apr-2005 ** Appendix E: fPar Extensions ** http://arch.cup.hp.com/sppa_platform/doc/sppa-x/hp_sal/fw1_6.pdf ** ** MODIFICATION HISTORY: ** ** X-1 ER Eric Rasmussen 22-Apr-2005 ** Initial revision. **-- */ #ifndef __FSHWA_ROUTINES_H_ #define __FSHWA_ROUTINES_H_ 1 #pragma __required_pointer_size __save #pragma __required_pointer_size __long #include #include #include #include extern FSHWA_INTERFACE *exe$gpq_fshwa; /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Get the current FSHWA protocol revision level. ** ** FORMAL PARAMETERS: ** ** rev: ** Pointer to returned revision level. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The revision level was returned successfully. ** ** SS$_BADPARAM: ** The rev parameter is invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_version( uint64 *rev ) { if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; if ( rev == NULL ) return SS$_BADPARAM; *rev = exe$gpq_fshwa->Revision; return SS$_NORMAL; } // // FSHWA Shared Register Interface // /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Get a bit mask that identifies registers, or groups of registers, that ** must be accessed using the FSHWA virtual read/write register functions. ** ** FORMAL PARAMETERS: ** ** mask: ** Returned bit mask of virtualized registers. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The register mask data was returned successfully. ** ** SS$_BADPARAM: ** The mask parameter is invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_virtualized_mask ( uint64 *mask ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetVirtualizedMask( exe$gpq_fshwa, mask ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Read a virtualized (shared) register resource. ** ** FORMAL PARAMETERS: ** ** width: ** The access size in bytes. Valid values are: ** 1 - Byte ** 2 - Word ** 4 - Longword ** 8 - Quadword ** ** address: ** The address of the virtualized register. ** ** size: ** The number of bytes to read. ** ** data: ** Pointer to where the data will be returned. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The virtualized register was read and data returned successfully. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$virtual_read ( FSHWA_ACCESS_WIDTH width, uint64 address, uint64 size, void *data ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; switch ( width ) { case FshwaAccessWidthUint8: FshwaRet = exe$gpq_fshwa->VirtualRead( exe$gpq_fshwa, width, address, size, ( uint8 * )data ); break; case FshwaAccessWidthUint16: FshwaRet = exe$gpq_fshwa->VirtualRead( exe$gpq_fshwa, width, address, size, ( uint16 * )data ); break; case FshwaAccessWidthUint32: FshwaRet = exe$gpq_fshwa->VirtualRead( exe$gpq_fshwa, width, address, size, ( uint32 * )data ); break; case FshwaAccessWidthUint64: FshwaRet = exe$gpq_fshwa->VirtualRead( exe$gpq_fshwa, width, address, size, ( uint64 * )data ); break; default: return SS$_BADPARAM; } if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Write a virtualized (shared) register resource. ** ** FORMAL PARAMETERS: ** ** width: ** The access size in bytes. Valid values are: ** 1 - Byte ** 2 - Word ** 4 - Longword ** 8 - Quadword ** ** address: ** The address of the virtualized register. ** ** size: ** The number of bytes to write. ** ** data: ** Pointer from where the data will be copied. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The virtualized register was written successfully. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$virtual_write ( FSHWA_ACCESS_WIDTH width, uint64 address, uint64 size, void *data ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; switch ( width ) { case FshwaAccessWidthUint8: FshwaRet = exe$gpq_fshwa->VirtualWrite( exe$gpq_fshwa, width, address, size, ( uint8 * )data ); break; case FshwaAccessWidthUint16: FshwaRet = exe$gpq_fshwa->VirtualWrite( exe$gpq_fshwa, width, address, size, ( uint16 * )data ); break; case FshwaAccessWidthUint32: FshwaRet = exe$gpq_fshwa->VirtualWrite( exe$gpq_fshwa, width, address, size, ( uint32 * )data ); break; case FshwaAccessWidthUint64: FshwaRet = exe$gpq_fshwa->VirtualWrite( exe$gpq_fshwa, width, address, size, ( uint64 * )data ); break; default: return SS$_BADPARAM; } if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } // // FSHWA Shared IOSAPIC Interface // /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Get the number of virtualized (shared) IOSAPIC devices. ** ** FORMAL PARAMETERS: ** ** count: ** Returned number of IOSAPIC devices that must be accessed ** using the FSHWA protocol interface. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The number of shared IOSAPICs was returned successfully. ** ** SS$_BADPARM: ** The count parameter is invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_shared_iosapic_count ( uint64 *count ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetSharedIoSapicCount( exe$gpq_fshwa, count ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Get a list of virtualized (shared) IOSAPIC descriptors. ** ** FORMAL PARAMETERS: ** ** list: ** Buffer to return a list of virtualized IOSAPIC descriptors. ** ** size: ** The size of the buffer in bytes. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The list of shared IOSAPIC descriptors was returned successfully. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_IVBUFLEN: ** The size parameter is too small. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_shared_iosapic_list ( FSHWA_SHARED_IOSAPIC_DESC *list, uint64 *size ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetSharedIoSapicList( exe$gpq_fshwa, list, size ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_BUFFER_TOO_SMALL ) return SS$_IVBUFLEN; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Read the contents of the specified virtualized (shared) IOSAPIC's ** Version register (VR). ** ** VR<23:16> contains the maximum Redirection Table Entry (RTE) number ** for the specified IOSAPIC. This value is needed for the calculation ** of each RTE's Global System Interrupt Number (GSIN). ** ** FORMAL PARAMETERS: ** ** iosapic: ** The base address of the virtualized IOSAPIC. ** ** version: ** The returned contents of the IOSAPIC's VR. ** ** RETURN VALUE: ** ** SS$_NORMAL: ** The contents of VR were returned successfully. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_shared_iosapic_vers ( uint64 iosapic, uint64 *version ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetSharedIoSapicVers( exe$gpq_fshwa, iosapic, version ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Write a Redirection Table Entry (RTE) register on the specified ** virtualized (shared) IOSAPIC. ** ** FORMAL PARAMETERS: ** ** iosapic: ** Base address of the virtualized IOSAPIC. ** ** rte: ** The redirection table entry register number to be written. ** ** value: ** The value to be written. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The RTE register was successfully written. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$set_iosapic_redir ( uint64 iosapic, uint64 rte, uint64 value ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->SetIoSapicRedir( exe$gpq_fshwa, iosapic, rte, value ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Read a Redirection Table Entry (RTE) register from the specified ** virtualized (shared) IOSAPIC. ** ** FORMAL PARAMETERS: ** ** iosapic: ** Base address of the virtualized IOSAPIC. ** ** rte: ** The redirection table entry register number to be read. ** ** value: ** The returned data value. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The RTE register was successfully read. ** ** SS$_BADPARM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_iosapic_redir ( uint64 iosapic, uint64 rte, uint64 *value ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetIoSapicRedir( exe$gpq_fshwa, iosapic, rte, value ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Clear an interrupt from the specified virtualized (shared) IOSAPIC ** to complete the processing of an interrupt received from the ** specified Redirection Table Entry (RTE) register. ** ** FORMAL PARAMETERS: ** ** iosapic: ** Base address of the virtualized IOSAPIC. ** ** rte: ** The redirection table entry register number that corresponds to ** the interrupt being cleared. ** ** value: ** The value to be written into the virtualized EOI register. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The interrupt was successfully cleared. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$clear_iosapic_interrupt ( uint64 iosapic, uint64 rte, uint64 value ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->ClearIoSapicInterrupt( exe$gpq_fshwa, iosapic, rte, value ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Acquire exclusive access rights to a Redirection Table Entry (RTE) ** register on the specified virtualized (shared) IOSAPIC. ** ** FORMAL PARAMETERS: ** ** iosapic: ** Base address of the virtualized IOSAPIC. ** ** rte: ** The redirection table entry register whose exclusive access ** is being requested. ** ** owner: ** The fPar number of the current owner if access is denied. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** Exclusive rights to the specified RTE were successfully acquired. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_LOCKINUSE: ** The RTE is currently owned by another fPar. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$acquire_exclusive ( uint64 iosapic, uint64 rte, uint64 *owner ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->AcquireExclusiveIoSapicRedir( exe$gpq_fshwa, iosapic, rte, owner ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_ACCESS_DENIED ) return SS$_LOCKINUSE; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Release exclusive access rights to a Redirection Table Entry (RTE) ** register on the specified virtualized (shared) IOSAPIC. ** ** FORMAL PARAMETERS: ** ** iosapic: ** Base address of the virtualized IOSAPIC. ** ** rte: ** The redirection table entry register whose exclusive access ** are being released. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** Exclusive rights to the specified RTE were successfully released. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_LOCKINUSE: ** The RTE is currently owned by another fPar. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$release_exclusive ( uint64 iosapic, uint64 rte ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->ReleaseExclusiveIoSapicRedir( exe$gpq_fshwa, iosapic, rte ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_ACCESS_DENIED ) return SS$_LOCKINUSE; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } // // FSHWA Shared IPMI Interface // /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Obtain a virtualized (shared) IPMI message sequence number. ** ** FORMAL PARAMETERS: ** ** number: ** The returned sequence number, guaranteed to be unique (i.e. ** not to match that allocated to, or in use by, any other ** fPar). ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The sequence number was successfully returned. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_TIMEOUT: ** The FSHWA protocol lock was held too long. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$get_ipmi_sequence ( uint64 *number ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->GetIpmiSeq( exe$gpq_fshwa, number ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_TIMEOUT ) return SS$_TIMEOUT; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Queue an IPMI BT message to the virtualized (shared) BT interface. ** ** FORMAL PARAMETERS: ** ** sequence: ** The virtual sequence number. ** ** message: ** Pointer to a buffer containing a properly formed IPMI ** BT message. ** ** size: ** The size of the IPMI BT message in bytes. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The message was successfully queued. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_NOTQUEUED: ** The per-fPar instance limit of outstanding messages has ** been reached. ** ** SS$_DEVREQERR: ** The message could not be queued due to a device error. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$enqueue_ipmi ( uint64 sequence, void *message, uint64 size ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->EnqueueIpmiMsg( exe$gpq_fshwa, sequence, message, size ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_OUT_OF_RESOURCES ) return SS$_NOTQUEUED; if ( FshwaRet.Status == EFI_DEVICE_ERROR ) return SS$_DEVREQERR; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } /* **++ ** FUNCTIONAL DESCRIPTION: ** ** Retrieve an IPMI BT response message from the virtualized (shared) ** BT interface. ** ** FORMAL PARAMETERS: ** ** sequence: ** The returned virtualized sequence number of the response. ** The actual sequence number for the message is inside the ** returned message buffer. ** ** message: ** Pointer to a buffer for the returned IPMI BT response. ** ** size: ** On input: the size of the specified message buffer. ** ** On output: the size of the returned BT message, or the size ** of the next message to be removed if the specified buffer ** is too small, otherwise, zero. ** ** RETURN VALUE: ** ** Status indicating success or failure. ** ** SS$_NORMAL: ** The response message was successfully retrieved. ** ** SS$_BADPARAM: ** One or more parameters are invalid. ** ** SS$_IVBUFLEN: ** The specified buffer size is too small. ** ** SS$_INSFRSPID: ** A response message, matching the specified sequence number, ** could not be found. ** ** SS$_UNSUPPORTED: ** This function is not supported. ** **-- */ static int fshwa$dequeue_ipmi ( uint64 *sequence, void *message, uint64 *size ) { FSHWA_RET FshwaRet; if ( exe$gpq_fshwa == NULL ) return SS$_UNSUPPORTED; FshwaRet = exe$gpq_fshwa->DequeueIpmiMsg( exe$gpq_fshwa, sequence, message, size ); if ( EFI_SUCCESS( FshwaRet.Status ) ) return SS$_NORMAL; if ( FshwaRet.Status == EFI_INVALID_PARAMETER ) return SS$_BADPARAM; if ( FshwaRet.Status == EFI_BUFFER_TOO_SMALL ) return SS$_IVBUFLEN; if ( FshwaRet.Status == EFI_NOT_FOUND ) return SS$_INSFRSPID; if ( FshwaRet.Status == EFI_UNSUPPORTED ) return SS$_UNSUPPORTED; return 0; } #pragma __required_pointer_size __restore #endif /* __FSHWA_ROUTINES_H_ */