//************************************************************************* //************************************************************************* //** ** //** (C)Copyright 1985-2012, American Megatrends, Inc. ** //** ** //** All Rights Reserved. ** //** ** //** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** //** ** //** Phone: (770)-246-8600 ** //** ** //************************************************************************* //************************************************************************* //************************************************************************* // $Header: $ // // $Revision: $ // // $Date: $ //************************************************************************* // Revision History // ---------------- // $Log: $ // //************************************************************************* // // // Name: CRBDXE.c // // Description: This file contains code for Chipset Reference Board Template // initialization in the DXE stage // // //************************************************************************* //--------------------------------------------------------------------------- // Include(s) //--------------------------------------------------------------------------- #include //EIP137196 #include //EIP137196 #include #include #include #include // Optional the library produce by CRB. #include //EIP137196 #include #include // Optional. should use Mde Library instead. #include // Optional. should use Mde Library instead. #include // Optional. should use Mde Library instead. // Produced Protocols // Consumed Protocols #include //--------------------------------------------------------------------------- // Constant, Macro and Type Definition(s) //--------------------------------------------------------------------------- // Constant Definition(s) #define KBC_DATA_PORT 0x60 //EIP177963 // Macro Definition(s) // Type Definition(s) // Function Prototype(s) //EIP137196 >> UINT8 CrbDxeGetChipsetVendorNo ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); UINT32 CrbDxeGetCpuId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); UINT32 CrbDxeGetNorthBridgePciId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); UINT32 CrbDxeGetSouthBridgePciId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); CHAR8* CrbDxeGetProjectId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); UINT16 CrbDxeGetBiosRevision ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ); //EIP137196 << //--------------------------------------------------------------------------- // Variable and External Declaration(s) //--------------------------------------------------------------------------- // Variable Declaration(s) CHAR8 CONST ProjectTag[5] = CONVERT_TO_STRING(CRB_PROJECT_TAG); //EIP137196 EFI_S3_SAVE_STATE_PROTOCOL *gS3SaveState = NULL; // Optional can use Mde instead. // GUID Definition(s) // Protocol Definition(s) //EIP137196 >> AMI_EFI_CRBINFO_PROTOCOL gAmiCrbInforProtocol = { CrbDxeGetChipsetVendorNo, CrbDxeGetCpuId, CrbDxeGetNorthBridgePciId, CrbDxeGetSouthBridgePciId, CrbDxeGetProjectId, CrbDxeGetBiosRevision, }; //EIP137196 << // External Declaration(s) // Function Definition(s) //--------------------------------------------------------------------------- //EIP137196 >> // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetChipsetVendorNo // // Description: Provide the chipset vendor number. // // Input: VOID // // Output: 0 - Unknown. // 1 - Intel. // 2 - AMD. // // Notes: . //---------------------------------------------------------------------------- // UINT8 CrbDxeGetChipsetVendorNo ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { UINT32 Index; UINT32 RegisterEax; UINT32 RegisterEbx; UINT32 RegisterEcx; UINT32 RegisterEdx; // Intel // EBX 756E6547 "uneG" // ECX 6C65746E "letn" // EDX 49656e69 "Ieni" // AMD //EBX 68747541 "htuA" //ECX 444D4163 "DMAc" //EDX 69746E65 "itne" CHAR8 CONST Intel[5] = "letnI"; CHAR8 CONST Amd[3] = "DMA"; CHAR8 MyString[5]; UINT8 ChipsetVendorNo = 0; Index = 0; Index = AsmCpuid(Index, &RegisterEax, &RegisterEbx, &RegisterEcx, &RegisterEdx); MyString[4] = ((CHAR8*)&RegisterEdx)[3]; MyString[3] = ((CHAR8*)&RegisterEcx)[0]; MyString[2] = ((CHAR8*)&RegisterEcx)[1]; MyString[1] = ((CHAR8*)&RegisterEcx)[2]; MyString[0] = ((CHAR8*)&RegisterEcx)[3]; if (CompareMem(MyString, Intel, 5) == 0) { ChipsetVendorNo = 1; } else if (CompareMem(MyString, Amd, 3) == 0) { ChipsetVendorNo = 2; } return ChipsetVendorNo; } // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetCpuId // // Description: Provide the CPU ID. // // Input: // AMI_EFI_CRBINFO_PROTOCOL *This // // Output: EAX : Version Information (Type, Family, Model, and Stepping ID) // // Notes: . //---------------------------------------------------------------------------- // UINT32 CrbDxeGetCpuId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { UINT32 Index = 1; UINT32 RegisterEax = -1; // EAX : Version Information (Type, Family, Model, and Stepping ID) Index = AsmCpuid(Index, &RegisterEax, NULL, NULL, NULL); return RegisterEax; } // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetNorthBridgePciId // // Description: Provide the PCI DID/VID of the north bridge. // // Input: VOID // // Output: -1 - Undefined. // others - PCI DID/VID. // // Notes: . //---------------------------------------------------------------------------- // UINT32 CrbDxeGetNorthBridgePciId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { UINT32 PciId = -1; if (This->GetChipsetVendorNo(This) == 1) { PciId = PciRead32(PCI_LIB_ADDRESS(0, 0, 0, 0)); } else if (This->GetChipsetVendorNo(This) == 2){ PciId = PciRead32(PCI_LIB_ADDRESS(0, 0, 0, 0)); } return PciId; } // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetSouthBridgePciId // // Description: Provide the PCI DID/VID of the south bridge. // // Input: VOID // // Output: -1 - Undefined. // others - PCI DID/VID. // // Notes: . //---------------------------------------------------------------------------- // UINT32 CrbDxeGetSouthBridgePciId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { UINT32 PciId = -1; if (This->GetChipsetVendorNo(This) == 1) { PciId = PciRead32(PCI_LIB_ADDRESS(0, 31, 0, 0)); } else if (This->GetChipsetVendorNo(This) == 2){ PciId = PciRead32(PCI_LIB_ADDRESS(0, 20, 0, 0)); } return PciId; } // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetProjectId // // Description: Provide the project ID. // // Input: VOID // // Output: NULL - Undefined / error. // others - Project ID. // // Notes: . //---------------------------------------------------------------------------- // CHAR8* CrbDxeGetProjectId ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { return ProjectTag; } // //---------------------------------------------------------------------------- // // Procedure: CrbDxeGetBiosRevision // // Description: Provide the BIOS revision. // // Input: VOID // // Output: -1 - Undefined / error. // others - BIOS revision. // // Notes: . //---------------------------------------------------------------------------- // UINT16 CrbDxeGetBiosRevision ( IN CONST AMI_EFI_CRBINFO_PROTOCOL *This ) { return (CRB_PROJECT_MAJOR_VERSION << 8) | CRB_PROJECT_MINOR_VERSION; } //EIP137196 << // //---------------------------------------------------------------------------- // // Procedure: CrbDxeInit // // Description: This function is the entry point for CRB DXE driver. // This function initializes the CRB in DXE phase. // // Input: ImageHandle - Image handle // SystemTable - Pointer to the system table // // Output: EFI_SUCCESS // // Notes: This routine is called very early, prior to SBDXE and NBDXE. //---------------------------------------------------------------------------- // EFI_STATUS EFIAPI CrbDxeInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status = EFI_SUCCESS; //EIP177963 >> InitAmiLib(ImageHandle,SystemTable); #if KBC_SUPPORT && Recovery_SUPPORT && NPCE791x_SUPPORT { UINTN Data,i; EFI_BOOT_MODE BootMode; BootMode = GetBootMode(); if ( BootMode == BOOT_IN_RECOVERY_MODE ){ // Clear KBC buffer for Ctrl+home recovery for(i=0;i<=0x10000;i++){ Data = IoRead8(KBC_DATA_PORT); } } } #endif //EIP177963 << //EIP137196 >> Status = gBS->InstallMultipleProtocolInterfaces( &ImageHandle, &gAmiEfiCrbInfoProtocolGuid, &gAmiCrbInforProtocol, NULL ); //EIP137196 << return Status; } //************************************************************************* //************************************************************************* //** ** //** (C)Copyright 1985-2012, American Megatrends, Inc. ** //** ** //** All Rights Reserved. ** //** ** //** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** //** ** //** Phone: (770)-246-8600 ** //** ** //************************************************************************* //*************************************************************************