/** Get ControlBits. @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL. @param[out] Control Control signals of the serial device. @retval EFI_SUCCESS Get Control signals successfully. **/ EFI_STATUS EFIAPI SerialGetControl ( IN EFI_SERIAL_IO_PROTOCOL *This, OUT UINT32 *Control ) { DEBUG_PORT_HANDLE Handle; Handle = GetDebugPortHandle (); // // Always assume the output buffer is empty and the Debug Communication Library can process // more write requests. // *Control = mSerialIoMode.ControlMask | EFI_SERIAL_OUTPUT_BUFFER_EMPTY; // // Check to see if the Terminal FIFO is empty and // check to see if the input buffer in the Debug Communication Library is empty // if (!IsDebugTermianlFifoEmpty (&mSerialFifoForTerminal) || DebugPortPollBuffer (Handle)) { *Control &= ~EFI_SERIAL_INPUT_BUFFER_EMPTY; } return EFI_SUCCESS; }
/** Get ControlBits. @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL. @param[out] Control Control signals of the serial device. @retval EFI_SUCCESS Get Control signals successfully. **/ EFI_STATUS EFIAPI SerialGetControl ( IN EFI_SERIAL_IO_PROTOCOL *This, OUT UINT32 *Control ) { DEBUG_PORT_HANDLE Handle; BOOLEAN DebugTimerInterruptState; EFI_TPL Tpl; // // Raise TPL to prevent recursion from EFI timer interrupts // Tpl = gBS->RaiseTPL (TPL_NOTIFY); // // Save and disable Debug Timer interrupt to avoid it to access Debug Port // DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (FALSE); Handle = GetDebugPortHandle (); // // Always assume the output buffer is empty and the Debug Communication Library can process // more write requests. // *Control = mSerialIoMode.ControlMask | EFI_SERIAL_OUTPUT_BUFFER_EMPTY; // // Check to see if the Terminal FIFO is empty and // check to see if the input buffer in the Debug Communication Library is empty // if (!IsDebugTermianlFifoEmpty (&mSerialFifoForTerminal) || DebugPortPollBuffer (Handle)) { *Control &= ~EFI_SERIAL_INPUT_BUFFER_EMPTY; } // // Restore Debug Timer interrupt // SaveAndSetDebugTimerInterrupt (DebugTimerInterruptState); // // Restore to original TPL // gBS->RestoreTPL (Tpl); return EFI_SUCCESS; }
/** Remove data from specific FIFO. @param[in] Fifo A pointer to the Data Structure DEBUG_SERIAL_FIFO. @param[out] Data The data removed from FIFO. @retval EFI_SUCCESS Remove data from specific FIFO successfully. @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty. **/ EFI_STATUS DebugTerminalFifoRemove ( IN DEBUG_SERIAL_FIFO *Fifo, OUT UINT8 *Data ) { // // if FIFO is empty, no data can remove // if (IsDebugTermianlFifoEmpty (Fifo)) { return EFI_OUT_OF_RESOURCES; } // // FIFO is not empty, can remove data // *Data = Fifo->Data[Fifo->First]; Fifo->Surplus++; Fifo->First++; if (Fifo->First == DEBGU_SERIAL_IO_FIFO_DEPTH) { Fifo->First = 0; } return EFI_SUCCESS; }