From 00a749954601529725caeb687156280bc9fd98f3 Mon Sep 17 00:00:00 2001 From: raywu Date: Thu, 13 Dec 2018 16:24:13 +0800 Subject: DW01 - Re-define OnlyBootHdd Condition --- Core/EM/EfiOsBootOptionNames/EfiOsBootOrder.c | 120 +++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/Core/EM/EfiOsBootOptionNames/EfiOsBootOrder.c b/Core/EM/EfiOsBootOptionNames/EfiOsBootOrder.c index df5ef53..3501a4b 100644 --- a/Core/EM/EfiOsBootOptionNames/EfiOsBootOrder.c +++ b/Core/EM/EfiOsBootOptionNames/EfiOsBootOrder.c @@ -245,6 +245,123 @@ extern UINT16 gSATA[3][2] ; EFI_DEVICE_PATH_PROTOCOL **NewEfiOsOptionDpList = NULL ; UINTN NewEfiOsOptionDpListCount = 0 ; +#define CONFIG_PORT0 0x2E +#define INDEX_PORT0 0x2E +#define DATA_PORT0 0x2F +#define SEND_BYTE_DELEY 0x200 +#define SEND_BYTE_ATEMPTS 0x10 + +#define COM_BASE_ADDR 0x03f8 + +#define LSR_OFFSET 0x05 +#define LCR_OFFSET 0x03 +#define DIV_MSB 0x01 +#define DIV_LSB 0 + +#define TRANSMIT_READY_BIT 0x020 +//#ifdef UART_INPUT_CLOCK +//UINTN UartInputClock=UART_INPUT_CLOCK; +//#else +//// +//// Set the default value((24000000/13)MHz input clock) if the UART_INPUT_CLOCK SDL token is not present. +//// +//UINTN UartInputClock=1843200; +//#endif + +#define BAUD_RATE_DIVISOR 115200 + +#define DATA_BITS 3 // 0 - 5 bits / 1 - 6 bits +// 2 - 7 bits / 3 - 8 bits +// RSP BUGBUG #define STOP_BIT 0 // 0 - 1 stop bit +#define STOP_BIT 1 // 0 - 1 stop bit +// 1 - mutiple bits depending on the databits +#define PARITY_BITS 0 // 0 - None / 1 enables parity +#define BREAK_BIT 0 // 0 - No break +#define DLAB_BIT 1 // 0 - Divisor Latch Disabled + +BOOLEAN EfiOsBootOrder_SendByte(UINT8 Byte) +{ + UINT8 Buffer8; + UINT32 Cntr = 0; + + do + { + // Read the ready signal to see if the serial port is + // ready for the next byte. + Buffer8 = IoRead8(COM_BASE_ADDR + LSR_OFFSET); + // Increment timeout counter. + Cntr++; + // Loop until the serial port is ready for the next byte. + } + while ( (Cntr < SEND_BYTE_DELEY) && + ((Buffer8 & TRANSMIT_READY_BIT) == FALSE) ); + if (Cntr < SEND_BYTE_DELEY){ + + IoWrite8(COM_BASE_ADDR, Byte); + return TRUE; + } else return FALSE; + +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiOsBootOrder_SerialOutput +// +// Description: Writes the given string to the serial port byte by byte +// using the function EfiOsBootOrder_SendByte. +// +// Input: +// IN EFI_PEI_SERVICES **PeiServices - pointer to the PEI Boot Services table +// CHAR8 *String - String to be sent over the serial port +// +// Output: EFI_SUCCESS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS EfiOsBootOrder_SerialOutput( + IN CHAR8 *String +) +{ +//#if SERIAL_STATUS_SUPPORT + UINT8 *Buffer, i; + UINT32 Delay; + BOOLEAN ByteSent; + + if (String == NULL) return EFI_SUCCESS; + // first make data useable + Buffer = String; + + // now send data one byte at a time until the string hits the end of string + // or we hit the max number of characters + while (*Buffer) + { + // replace "\n" with "\r\n" + for (i = 0; i <= SEND_BYTE_ATEMPTS; i++){ + ByteSent = TRUE; + + if (*Buffer=='\n') ByteSent = EfiOsBootOrder_SendByte('\r'); + + if (ByteSent) ByteSent = EfiOsBootOrder_SendByte(*Buffer); + + if (ByteSent) break; + else + for (Delay = 0; Delay <= 100000; Delay++); + } + + // move Data pointer to the next byte if previous was sent + if (ByteSent) Buffer++; + else return EFI_SUCCESS; + } +//#endif + return EFI_SUCCESS; +} +VOID EfiOsBootOrder_SerialCheckpoint(UINT16 Checkpoint) +{ + char s[20]; + Sprintf_s(s, sizeof(s), "=== %X\n",Checkpoint); + EfiOsBootOrder_SerialOutput(s); +} + // //--------------------------------------------------------------------------- // @@ -1432,7 +1549,8 @@ BOOLEAN RemoveLegacyGptHdd(BOOT_DEVICE *Device){ Status = pRS->GetVariable(L"Setup", &SetupGuid, NULL, &Size, &SetupData); - if( Device->BbsEntry->DeviceType != BBS_HARDDISK && SetupData.OnlyBootHDD == 1 ) return TRUE; +// if( Device->BbsEntry->DeviceType != BBS_HARDDISK && SetupData.OnlyBootHDD == 1 ) return TRUE; + if( Device->BbsEntry->Class != PCI_CL_MASS_STOR && SetupData.OnlyBootHDD == 1 ) return TRUE; return FALSE; } #endif -- cgit v1.2.3