AudioPkg在 EDK2 201903 下面使用 build -a X64 -p AudioPkg\AudioPkg.dsc 会遇到如下错误:
c:\buildbs\stable201903\AudioPkg\Platform\BootChimeDxe\BootChimeDxe.c(163): error C2220: warning treated as error - no 'object' file generated
c:\buildbs\stable201903\AudioPkg\Platform\BootChimeDxe\BootChimeDxe.c(163): warning C4244: 'function': conversion from 'UINTN' to 'UINT8', possible loss of data
c:\buildbs\stable201903\AudioPkg\Application\BootChimeCfg\BootChimeCfg.c(415): error C2220: warning treated as error - no 'object' file generated
c:\buildbs\stable201903\AudioPkg\Application\BootChimeCfg\BootChimeCfg.c(415): warning C4244: 'function': conversion from 'UINTN' to 'UINT8', possible loss of data
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
/* The ESP32 has four SPi buses, however as of right now only two of
* them are available to use, HSPI and VSPI. Simply using the SPI API
* as illustrated in Arduino examples will use HSPI, leaving VSPI unused.
*
* However if we simply intialise two instance of the SPI class for both
* of these buses both can be used. However when just using these the Arduino
* way only will actually be outputting at a time.
*
* Logic analyser capture is in the same folder as this example as
* "multiple_bus_output.png"
*
* created 30/04/2018 by Alistair Symonds
*/
#include <SPI.h>
static const int spiClk = 1000000; // 1 MHz
//uninitalised pointers to SPI objects
SPIClass * vspi = NULL;
SPIClass * hspi = NULL;
void setup() {
//initialise two instances of the SPIClass attached to VSPI and HSPI respectively
vspi = new SPIClass(VSPI);
hspi = new SPIClass(HSPI);
//clock miso mosi ss
//initialise vspi with default pins
//SCLK = 18, MISO = 19, MOSI = 23, SS = 5
vspi->begin();
//alternatively route through GPIO pins of your choice
//hspi->begin(0, 2, 4, 33); //SCLK, MISO, MOSI, SS
//initialise hspi with default pins
//SCLK = 14, MISO = 12, MOSI = 13, SS = 15
hspi->begin();
//alternatively route through GPIO pins
//hspi->begin(25, 26, 27, 32); //SCLK, MISO, MOSI, SS
//set up slave select pins as outputs as the Arduino API
//doesn't handle automatically pulling SS low
pinMode(5, OUTPUT); //VSPI SS
pinMode(15, OUTPUT); //HSPI SS
}
// the loop function runs over and over again until power down or reset
void loop() {
//use the SPI buses
vspiCommand();
hspiCommand();
delay(100);
}
void vspiCommand() {
byte data = 0b01010101; // junk data to illustrate usage
//use it as you would the regular arduino SPI API
vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
digitalWrite(5, LOW); //pull SS slow to prep other end for transfer
vspi->transfer(data);
digitalWrite(5, HIGH); //pull ss high to signify end of data transfer
vspi->endTransaction();
}
void hspiCommand() {
byte stuff = 0b11001100;
hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
digitalWrite(15, LOW);
hspi->transfer(stuff);
digitalWrite(15, HIGH);
hspi->endTransaction();
}
Startup Repair diagnosis and repair log
---------------------------
Last successful boot time: 5/19/2020 11:39:04 PM (GMT)
Number of repair attempts: 1
Session details
---------------------------
System Disk = \Device\Harddisk0
Windows directory = C:\Windows
AutoChk Run = 0
Number of root causes = 1
Test Performed:
---------------------------
Name: Check for updates
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: System disk test
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Disk failure diagnosis
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Disk metadata test
Result: Completed successfully. Error code = 0x0
Time taken = 141 ms
Test Performed:
---------------------------
Name: Disk metadata test
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Target OS test
Result: Completed successfully. Error code = 0x0
Time taken = 16 ms
Test Performed:
---------------------------
Name: Volume content check
Result: Completed successfully. Error code = 0x0
Time taken = 31 ms
Test Performed:
---------------------------
Name: Boot manager diagnosis
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: System boot log diagnosis
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Event log diagnosis
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Internal state check
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Check for installed LCU
Result: Completed successfully. Error code = 0x0
Time taken = 4515 ms
Test Performed:
---------------------------
Name: Check for installed driver updates
Result: Completed successfully. Error code = 0x0
Time taken = 750 ms
Test Performed:
---------------------------
Name: Check for pending package install
Result: Completed successfully. Error code = 0x0
Time taken = 1625 ms
Test Performed:
---------------------------
Name: Boot status test
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Test Performed:
---------------------------
Name: Setup state check
Result: Completed successfully. Error code = 0x0
Time taken = 94 ms
Test Performed:
---------------------------
Name: Registry hives test
Result: Completed successfully. Error code = 0x0
Time taken = 469 ms
Test Performed:
---------------------------
Name: Windows boot log diagnosis
Result: Completed successfully. Error code = 0x0
Time taken = 0 ms
Root cause found:
---------------------------
Boot critical file c:\windows\system32\drivers\msdmfilt.sys is corrupt.
Repair action: File repair
Result: Failed. Error code = 0x57
Time taken = 1063 ms
---------------------------
---------------------------
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/IoLib.h>
#include "Ps2Keyboard.h"
extern EFI_BOOT_SERVICES *gBS;
extern EFI_SYSTEM_TABLE *gST;
extern EFI_RUNTIME_SERVICES *gRT;
EFI_GUID gEfiSimpleTextInputExProtocolGuid =
{0xdd9e7534, 0x7762, 0x4698,
{ 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } };
UINTN
EFIAPI
MicroSecondDelay (
IN UINTN MicroSeconds
)
{
gBS->Stall(MicroSeconds);
return MicroSeconds;
}
/**
Write data register.
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@param Data value wanted to be written
**/
VOID
KeyWriteDataRegister (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
IN UINT8 Data
)
{
IoWrite8 (ConsoleIn->DataRegisterAddress, Data);
}
/**
Read data register .
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@return return the value
**/
UINT8
KeyReadDataRegister (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
)
{
return IoRead8 (ConsoleIn->DataRegisterAddress);
}
/**
Read status register.
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@return value in status register
**/
UINT8
KeyReadStatusRegister (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
)
{
return IoRead8 (ConsoleIn->StatusRegisterAddress);
}
/**
wait for a specific value to be presented on
8042 Data register by keyboard and then read it,
used in keyboard commands ack
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@param Value the value wanted to be waited.
@retval EFI_TIMEOUT Fail to get specific value in given time
@retval EFI_SUCCESS Success to get specific value in given time.
**/
EFI_STATUS
KeyboardWaitForValue (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
IN UINT8 Value
)
{
UINT8 Data;
UINT32 TimeOut;
UINT32 SumTimeOut;
UINT32 GotIt;
GotIt = 0;
TimeOut = 0;
SumTimeOut = 0;
//
// Make sure the initial value of 'Data' is different from 'Value'
//
Data = 0;
if (Data == Value) {
Data = 1;
}
//
// Read from 8042 (multiple times if needed)
// until the expected value appears
// use SumTimeOut to control the iteration
//
while (1) {
//
// Perform a read
//
for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
Data = KeyReadDataRegister (ConsoleIn);
break;
}
MicroSecondDelay (30);
}
SumTimeOut += TimeOut;
if (Data == Value) {
GotIt = 1;
break;
}
if (SumTimeOut >= KEYBOARD_WAITFORVALUE_TIMEOUT) {
break;
}
}
//
// Check results
//
if (GotIt == 1) {
return EFI_SUCCESS;
} else {
return EFI_TIMEOUT;
}
}
//
//\MdeModulePkg\Bus\Isa\Ps2KeyboardDxe\Ps2KbdCtrller.c
//
/**
write key to keyboard
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@param Data value wanted to be written
@retval EFI_TIMEOUT The input buffer register is full for putting new value util timeout
@retval EFI_SUCCESS The new value is sucess put into input buffer register.
**/
EFI_STATUS
KeyboardWrite (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
IN UINT8 Data
)
{
UINT32 TimeOut;
UINT32 RegEmptied;
TimeOut = 0;
RegEmptied = 0;
//
// wait for input buffer empty
//
for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {
RegEmptied = 1;
break;
}
MicroSecondDelay (30);
}
if (RegEmptied == 0) {
return EFI_TIMEOUT;
}
//
// Write it
//
KeyWriteDataRegister (ConsoleIn, Data);
return EFI_SUCCESS;
}
//
//\MdeModulePkg\Bus\Isa\Ps2KeyboardDxe\Ps2KbdCtrller.c
//
/**
Show keyboard status lights according to
indicators in ConsoleIn.
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@return status of updating keyboard register
**/
EFI_STATUS
UpdateStatusLights (
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
)
{
EFI_STATUS Status;
UINT8 Command;
//
// Send keyboard command
//
Status = KeyboardWrite (ConsoleIn, 0xed);
if (EFI_ERROR (Status)) {
return Status;
}
KeyboardWaitForValue (ConsoleIn, 0xfa);
//
// Light configuration
//
Command = 0;
if (ConsoleIn->CapsLock) {
Command |= 4;
}
if (ConsoleIn->NumLock) {
Command |= 2;
}
if (ConsoleIn->ScrollLock) {
Command |= 1;
}
Status = KeyboardWrite (ConsoleIn, Command);
if (EFI_ERROR (Status)) {
return Status;
}
KeyboardWaitForValue (ConsoleIn, 0xfa);
return Status;
}
int
EFIAPI
main (
IN int Argc,
IN CHAR16 **Argv
)
{
EFI_STATUS Status;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *ConIn;
KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
UINTN HandleIndex, HandleCount;
EFI_HANDLE *DevicePathHandleBuffer = NULL;
UINTN i;
//
//Get all the Handles that have SimpleTextInputEx Protocol
//
Status = gBS->LocateHandleBuffer(
ByProtocol,
&gEfiSimpleTextInputExProtocolGuid,
NULL,
&HandleCount,
&DevicePathHandleBuffer);
//
//Open SimpleTextInputEx Protocol on each device
//
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++)
{
Status = gBS->HandleProtocol(
DevicePathHandleBuffer[HandleIndex],
&gEfiSimpleTextInputExProtocolGuid,
(VOID**)&ConIn);
if (EFI_ERROR(Status))
{
Print(L"ERROR : Open ConIn fail.\n");
gBS->FreePool(DevicePathHandleBuffer);
return 0;
}
//Get KEYBOARD_CONSOLE_IN_DEV by SimpleTextInputEx Protocol
ConsoleIn = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
//Check the signature if it's what we want
if (ConsoleIn->Signature==KEYBOARD_CONSOLE_IN_DEV_SIGNATURE) {
// Turn Off all LEDs
ConsoleIn->CapsLock=0;
ConsoleIn->NumLock=0;
ConsoleIn->ScrollLock=0;
UpdateStatusLights(ConsoleIn);
for (i=0;i<20;i++) {
ConsoleIn->NumLock=1;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
ConsoleIn->NumLock=0;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
ConsoleIn->CapsLock=1;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
ConsoleIn->CapsLock=0;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
ConsoleIn->ScrollLock=1;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
ConsoleIn->ScrollLock=0;
UpdateStatusLights(ConsoleIn);
MicroSecondDelay(300000UL);
}
} //if (ConsoleIn->Signature
} //for (HandleIndex = 0;
gBS->FreePool(DevicePathHandleBuffer);
return Status;
}