⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bisbasecode.h

📁 Next BIOS Source code : Extensible Firmware Interface
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////
//
// This software is provided "as is" with no warranties, express or
// implied, including but not limited to any implied warranty of
// merchantability, fitness for a particular purpose, or freedom from
// infringement.
//
// Intel Corporation may have patents or pending patent applications,
// trademarks, copyrights, or other intellectual property rights that
// relate to this software.  The furnishing of this document does not
// provide any license, express or implied, by estoppel or otherwise,
// to any such patents, trademarks, copyrights, or other intellectual
// property rights.
//
// This software is furnished under license and may only be used or
// copied in accordance with the terms of the license. Except as
// permitted by such license, no part of this software may be reproduced,
// stored in a retrieval system, or transmitted in any form or by any
// means without the express written consent of Intel Corporation.
//
// Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
// This software and associated documentation (if any) is furnished
// under a license and may only be used or copied in accordance
// with the terms of the license. Except as permitted by such
// license, no part of this software or documentation may be
// reproduced, stored in a retrieval system, or transmitted in any
// form or by any means without the express written consent of
// Intel Corporation.
//
//
//
//

#ifndef BISBASECODE_H
#define BISBASECODE_H

#define MEMFREEBUG 1 		//workaround for bug that is visible in EFI but
							//is somehow obscured by the BIS memmgr.
							//see core_updt_boa.c for reference of this symbol.

#include <efi.h>
//#include <efibis.h>
#include <efidriverlib.h>
#include EFI_PROTOCOL_DEFINITION (Bis)
#include EFI_GUID_DEFINITION (SmBios)

// The following definitions were variously located in bis.h and bistypes.h.
// There were not propagated to efibis.h to avoid clutter in the EFI spec and
// to conform with there typography conventions.
// After this set of typedefs etc there are several more #includes that depend of
// the following definitions. The next set of #includes is preceded by
// this comment: "Second Wave of Includes"
//


//
//  Typedef for pBISEntry32( ).
//  BIS Entry Point Function Definition for 32bit flat address callers.
//

typedef UINT8 (_cdecl *pBisEntry32)(
        UINT32    opCode,                       //BIS OPCODE
        void     *pParamBundle,                 //OPCODE'S PARM BUNDLE
        UINT32    checkFlag);                   //CHECKSUM BIS REQUEST FLAG

typedef struct _BIS_ENTRY_POINT
{
    UINT8  length;          // Length  of  BIS_ENTRY_POINT structure,
                            // not including the two-byte null
                            // terminator. Value = sizeof(BIS_ENTRY_POINT) - 2;
    pBisEntry32 bisEntry32; // Entry point for 32-bit flat-mode callers.

    UINT16 doubleNull;      // 0000h structure terminator-See SMBIOS spec.
}
BIS_ENTRY_POINT,
*pBIS_ENTRY_POINT;


//----------------------------------------------------//
//          BIS Opcodes definitions                   //
//----------------------------------------------------//

#define BISOPBASE (0)

#define BISOP_Initialize                              (BISOPBASE+ 1)
#define BISOP_Free                                    (BISOPBASE+ 2)
#define BISOP_Shutdown                                (BISOPBASE+ 3)
#define BISOP_GetBootObjectAuthorizationCertificate   (BISOPBASE+ 4)
#define BISOP_VerifyBootObject                        (BISOPBASE+ 5)
#define BISOP_GetBootObjectAuthorizationCheckFlag     (BISOPBASE+ 6)
#define BISOP_GetBootObjectAuthorizationUpdateToken   (BISOPBASE+ 7)
#define BISOP_UpdateBootObjectAuthorization           (BISOPBASE+ 8)
#define BISOP_VerifyObjectWithCredential              (BISOPBASE+ 9)
#define BISOP_GetSignatureInfo                        (BISOPBASE+ 10)


//Update BISOP_LAST when adding opcodes. It should be
//equal to the highest numbered opcode used above.
#define BISOP_LAST (BISOP_GetSignatureInfo)

//
// BIS_DATA type.
//
// BIS_DATA instances obtained from BIS must be freed by calling Free( ).
//
typedef struct _BIS_DATA
{
    UINT32       length;        //Length of data in 8 bit bytes.
    UINT8        *data;          //32 Bit Flat Address of data.
}
BIS_DATA;

//
// BIS_VERSION type.
//
typedef struct _BIS_VERSION
{
    UINT32 major;               //BIS Interface version number.
    UINT32 minor;               //Build number.
}
BIS_VERSION;

//
// BIS_SIGNATURE_INFO and related pointers.
//
typedef struct _BIS_SIGNATURE_INFO
{
    BIS_CERT_ID   certificateID; //Truncated hash of platform Boot Object
                                 //  authorization certificate.
    BIS_ALG_ID    algorithmID;   //A signature algorithm number.
    UINT16        keyLength;     //Length of alg. keys in bits.
}
BIS_SIGNATURE_INFO,
*BIS_SIGNATURE_INFO_PTR;


typedef UINT32        BIS_STATUS;
typedef BIS_DATA     *BIS_DATA_PTR;
typedef UINT32        BIS_BOOLEAN;
typedef UINT32       *BIS_BOOLEAN_PTR;
typedef UINT8*        BIS_BYTE_PTR;


//
//  Common constants.
//
#define BIS_TRUE  (1)
#define BIS_FALSE (0)
#define BIS_NULL ((void*)0)


//
//BIS_STATUS values returned in BIS parm bundles 'returnValue' field.
//
#define BIS_OK                 (0)
#define BIS_INVALID_OPCODE     (1) //Returned by BIS_FunctionDispatch()
#define BIS_INVALID_PARMSTRUCT (2) //Null parm or bundle length is wrong.
#define BIS_MEMALLOC_FAILED    (3) //Couldn't alloc requested memory.
#define BIS_BAD_APPHANDLE      (4) //Invalid BIS_APPLICATION_HANDLE passed.
#define BIS_NOT_IMPLEMENTED    (5) //Unimplemented BIS function called.
#define BIS_BAD_PARM           (6) //A parm in the parm struct is invalid.
#define BIS_BOA_CERT_READ_ERR  (7) //An error occurred on CERT READ.
#define BIS_BOA_CERT_NOTFOUND  (8) //A BOA CERT is not configured.
#define BIS_SECURITY_FAILURE   (9) //A security check failed.
#define BIS_INIT_FAILURE       (10) //An internal failure occured in init.
#define BIS_INCOMPAT_VER       (11) //BIS interface version requested is not
                                    //  compatible with available version.
#define BIS_NVM_AREA_IO_LENGTH_ERROR    (12) //Length+offset combo incorrect.
#define BIS_NVM_AREA_UNKNOWN            (13) //Unknown area guid was specified.
#define BIS_NVM_CREATE_ERR_NO_ROOM      (14) //No space to create the new area.
#define BIS_NVM_CREATE_ERR_DUPLICATE_ID (15) //Area already exists.
#define BIS_NVM_BAD_HANDLE              (16) //Invalid handle passed.
#define BIS_NVM_PSI_FXNS_NOT_AVAIL      (17) //Bad/No PSI fxns passed to BIS_main.


#define BIS_PROTOIF_ERR                 (18) //bad protocol/interface array parm.
#define BIS_PROTO_UNDEF                 (19) //a protocol required by BIS is unavailable
#define BIS_PERSIST_MEM_SIZE_MISMATCH   (20) //memory len in persistent data did not match
#define BIS_GETGUID_ERROR               (21) //failed to get system guid




//****************************************//
//  BIS_Free( ) parameter bundle.         //
//  Op code= BISOP_Free                   //
//****************************************//

typedef
struct _BIS_Free_PARMS
{
    UINT32                  sizeOfStruct;   //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;      //[int] From BIS_Initialize( ).
    BIS_DATA_PTR            toFree;         //[in]  BIS_DATA being freed.
}
BIS_FREE_PARMS,
*BIS_FREE_PARMS_PTR;



//*******************************************************************//
//  BIS_GetBootObjectAuthorizationCertificate( ) parameter bundle.   //
//  Op code= BISOP_GetBootObjectAuthorizationCertificate             //
//*******************************************************************//

typedef
struct _BIS_GetBootObjectAuthorizationCertificate_PARMS
{
    UINT32                  sizeOfStruct;   //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;      //[in]  From BIS_Initialize( ).
    BIS_DATA_PTR            certificate;    //[out] Pointer to certificate.
}
BIS_GBOAC_PARMS,
*BIS_GBOAC_PARMS_PTR;



//**********************************************************************//
//   BIS_GetBootObjectAuthorizationCheckFlag( ) parameter bundle.       //
//  Op code= BISOP_IsBootObjectAuthorizationCheckRequired               //
//**********************************************************************//

typedef
struct _BIS_GetBootObjectAuthorizationCheckFlag_PARMS
{
    UINT32                  sizeOfStruct;    //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;     //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;       //[in]  From BIS_Initialize( ).
    BIS_BOOLEAN             checkIsRequired; //[out] Value of check flag.
}
BIS_GBOACF_PARMS,
*BIS_GBOACF_PARMS_PTR;


//***********************************************************************//
//  BIS_GetBootObjectAuthorizationUpdateToken( ) parameter bundle.       //
//  Op code= BISOP_GetBootObjectAuthorizationUpdateToken                 //
//***********************************************************************//

typedef
struct _BIS_GetBootObjectAuthorizationUpdateToken_PARMS
{
    UINT32                  sizeOfStruct;   //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;      //[in]  From BIS_Initialize( ).
    BIS_DATA_PTR            updateToken;    //[out] Value of update token.
}
BIS_GBOAUT_PARMS,
*BIS_GBOAUT_PARMS_PTR;



//**************************************************//
//  BIS_GetSignatureInfo( ) parameter bundle.       //
//  Op code= BISOP_GetSignatureInfo                 //
//      Two macros are define in BISTYPES.H to help //
//      manage 'signatureInfo':                     //
//          BIS_GET_SIGINFO_COUNT                   //
//          BIS_GET_SIGINFO_ARRAY                   //
//**************************************************//

typedef
struct _BIS_GetSignatureInfo_PARMS
{
    UINT32                  sizeOfStruct;   //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;      //[in]  From BIS_Initialize( ).
    BIS_DATA_PTR            signatureInfo;  //[out] Signature info struct.
}
BIS_GSI_PARMS,
*BIS_GSI_PARMS_PTR;



//**************************************************//
//   BIS_Initialize( ) parameter bundle.            //
//  Op code= BISOP_Initialize                       //
//**************************************************//

typedef
struct _BIS_Initialize_PARMS
{
    UINT32                  sizeOfStruct;  //[in]  Byte length of this struct.
    BIS_STATUS              returnValue;   //[out] BIS_OK | error code.
    BIS_VERSION             interfaceVersion; //[in/out] ver needed/available.
    BIS_APPLICATION_HANDLE  appHandle;     //[out] Application handle.
    BIS_DATA                targetAddress; //[in] Address of BIS platform.
}
BIS_INIT_PARMS,
*BIS_INIT_PARMS_PTR;





//**********************************************//
//  BIS_Shutdown( ) parameter bundle.           //
//  Op code= BISOP_Shutdown                     //
//**********************************************//

typedef
struct _BIS_Shutdown_PARMS
{
    UINT32                  sizeOfStruct; //[in]  Byte length of this structure.
    BIS_STATUS              returnValue;  //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;    //[in]  From BIS_Initialize( ).
}
BIS_SHUTDOWN_PARMS,
*BIS_SHUTDOWN_PARMS_PTR;



//***********************************************************//
// BIS_UpdateBootObjectAuthorization( ) parameter bundle.    //
//  Op code= BISOP_UpdateBootObjectAuthorization             //
//***********************************************************//

typedef
struct _BIS_UpdateBootObjectAuthorization_PARMS
{
    UINT32                 sizeOfStruct;   //[in]  Byte length of this struct.
    BIS_STATUS             returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE appHandle;      //[in]  From BIS_Initialize( ).
    BIS_DATA               requestCredential; //[in]  Update Request Manifest.
    BIS_DATA_PTR           newUpdateToken;    //[out] Next update token.
}
BIS_UBOA_PARMS,
*BIS_UBOA_PARMS_PTR;




//************************************************//
//  BIS_VerifyBootObject( ) parameter bundle.     //
//  Op code= BISOP_VerifyBootObject               //
//************************************************//

typedef
struct _BIS_VerifyBootObject_PARMS
{
    UINT32                 sizeOfStruct; //[in]  Byte length of this structure.
    BIS_STATUS             returnValue;  //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE appHandle;    //[in]  From BIS_Initialize( ).
    BIS_DATA               credentials;  //[in]  Verification signed manifest.
    BIS_DATA               dataObject;   //[in]  Boot object to verify.
    BIS_BOOLEAN            isVerified;   //[out] Result of verifcation.
}
BIS_VBO_PARMS,
*BIS_VBO_PARMS_PTR;



//**************************************************************//
//  BIS_VerifyObjectWithCredential( ) parameter bundle.         //
//  Op code= BISOP_VerifyObjectWithCredential                   //
//**************************************************************//

typedef
struct _BIS_VerifyObjectWithCredential_PARMS
{
    UINT32        sizeOfStruct;   //[in]  Byte length of this structure.
    BIS_STATUS    returnValue;    //[out] BIS_OK | error code.
    BIS_APPLICATION_HANDLE  appHandle;    //[in]  From BIS_Initialize( ).
    BIS_DATA      credentials;    //[in]  Verification signed manifest.
    BIS_DATA      dataObject;     //[in]  Data object to verify.
    BIS_DATA      sectionName;    //[in]  Name of credential section to use.
    BIS_DATA      authorityCertificate;   //[in]  Certificate for credentials.
    BIS_BOOLEAN   isVerified;     //[out] Result of verification.
}
BIS_VOWC_PARMS,
*BIS_VOWC_PARMS_PTR;



// ******************************************************
//  Constant strings used to create and parse manifests *
// ******************************************************

//Manifest section name for Update-Request manifests
#define UPDATE_PARMS_SECTION_NAME     "memory:UpdateRequestParameters"

//Manifest section name for Boot Object signature manifests
#define BOOT_OBJECT_SECTION_NAME      "memory:BootObject"


//Update Manifest Data Attribute Names
#define OEM_UNIQUENESS_PREFIX "X-Intel-BIS-"
#define PARMSET_ATTR_NAME     OEM_UNIQUENESS_PREFIX "ParameterSet"
#define UPDATETOKEN_ATTR_NAME OEM_UNIQUENESS_PREFIX "ParameterSetToken"
#define PARMID_ATTR_NAME      OEM_UNIQUENESS_PREFIX "ParameterId"
#define PARMVALUE_ATTR_NAME   OEM_UNIQUENESS_PREFIX "ParameterValue"


//Valid values of the "ParameterId" data object in an update manifest.
#define BOAC_PARMID  "BootObjectAuthorizationCertificate"
#define BOACF_PARMID "BootAuthorizationCheckFlag"


//  The following string constants are used when calling
//  PrepareSignedManifestHandle to locate the signer info
//  in a manifest by name.

#define VERIFIABLE_OBJECT_SIGINFO_NAME "BIS_VerifiableObjectSignerInfoName"

#define UPDATE_MANIFEST_SIGINFO_NAME   "BIS_UpdateManifestSignerInfoName"


// Binary Value of "X-Intel-BIS-ParameterSet" Attribute.
// (Value is Base64 encoded in actual signed manifest).

// {EDD35E31-07B9-11d2-83A3-00A0C91FADCF}
#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE     \
{ 0xedd35e31, 0x7b9, 0x11d2,                            \
{ 0x83, 0xa3, 0x0, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }



// ****************************************************
// 			Second Group of Includes
// ****************************************************


#include <nvm.h>
#include <dbgPrint.h>
#include <psd.h>
#include <collection.h>
#include <buildNbr.h>

#define  BBCIDSIG 0x27bc86aa	//BISBC_INSTANCEDATA magic number/signature value.

typedef struct _EFI_BIS_DEFAULT_AUTH_INTERFACE EFI_BIS_DEFAULT_AUTH_INTERFACE;
typedef struct _EFI_BIS_PERSISTENCE_INTERFACE  EFI_BIS_PERSISTENCE_INTERFACE;


	//
	//
	//
typedef struct _BisBaseCodeInstanceData
{
	UINTN	sizeOfThis;
	UINTN   Signature;

	//Interface pointers for BIS specific protocols.
	EFI_BIS_PERSISTENCE_INTERFACE		*Persist;
	EFI_BIS_DEFAULT_AUTH_INTERFACE		*Authorize;

	//Application memory allocation tracking.
	COLLECTION *appInfoTrackingCollection;


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -