Phase #2 of multiple output console modifications

Signed-off-by: Eugene D Myers <cedarhouse@comcast.net>
This commit is contained in:
Eugene D Myers 2020-06-23 18:20:29 -04:00
parent 0d14bc42ea
commit ebff226762
3 changed files with 76 additions and 6 deletions

View File

@ -94,8 +94,8 @@ void PeIoHandler( IN UINT32 CpuIndex)
}
AcquireSpinLock (&mInternalDebugLock);
SerialPortWrite ((UINT8 *)"(VM/PE) ", sizeof("(VM/PE) ") - 1);
SerialPortWrite ((UINT8 *) PhysAddress, DataSize);
DebugPortWrite ((UINT8 *)"(VM/PE) ", sizeof("(VM/PE) ") - 1);
DebugPortWrite ((UINT8 *) PhysAddress, DataSize);
ReleaseSpinLock (&mInternalDebugLock);
}
}

View File

@ -466,5 +466,32 @@ DebugClearMemoryEnabled (
#define CR(Record, TYPE, Field, TestSignature) \
BASE_CR (Record, TYPE, Field)
#endif
/**
Write data from buffer to device interface.
Writes NumberOfBytes data bytes from Buffer to the device interface.
The number of bytes actually written to the serial device is returned.
If the return value is less than NumberOfBytes, then the write operation failed.
If Buffer is NULL, then ASSERT().
If NumberOfBytes is zero, then return 0.
@param Buffer Pointer to the data buffer to be written.
@param NumberOfBytes Number of bytes to written to the serial device.
@retval 0 NumberOfBytes is 0.
@retval >0 The number of bytes written to the serial device.
If this value is less than NumberOfBytes, then the read operation failed.
**/
UINTN
EFIAPI
DebugPortWrite (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);
#endif

View File

@ -37,6 +37,49 @@
SPIN_LOCK mInternalDebugLock = SPIN_LOCK_RELEASED; // TBD: need call InitializeSpinLock
static int serial_initialized = 0;
/**
Write data from buffer to device interface.
Writes NumberOfBytes data bytes from Buffer to the device interface.
The number of bytes actually written to the serial device is returned.
If the return value is less than NumberOfBytes, then the write operation failed.
If Buffer is NULL, then ASSERT().
If NumberOfBytes is zero, then return 0.
@param Buffer Pointer to the data buffer to be written.
@param NumberOfBytes Number of bytes to written to the serial device.
@retval 0 NumberOfBytes is 0.
@retval >0 The number of bytes written to the serial device.
If this value is less than NumberOfBytes, then the read operation failed.
**/
UINTN
EFIAPI
DebugPortWrite (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
)
{
UINTN Result;
UINT8 Data;
if (Buffer == NULL) {
return 0;
}
Result = NumberOfBytes;
while (NumberOfBytes--) {
SerialPortWriteSingle(*Buffer++);
}
return Result;
}
/**
Prints a debug message to the debug output device if the specified error level is enabled.
@ -93,8 +136,8 @@ DebugPrint (
// Send the print string to a Serial Port
//
AcquireSpinLock (&mInternalDebugLock);
SerialPortWrite ((UINT8 *)"(STM) ", sizeof("(STM) ") - 1);
SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen(Buffer));
DebugPortWrite ((UINT8 *)"(STM) ", sizeof("(STM) ") - 1);
DebugPortWrite ((UINT8 *) Buffer, AsciiStrLen(Buffer));
ReleaseSpinLock (&mInternalDebugLock);
}
@ -145,8 +188,8 @@ DebugAssert (
// Send the print string to the Console Output device
//
AcquireSpinLock (&mInternalDebugLock);
SerialPortWrite ((UINT8 *)"(STM) ", sizeof("(STM) ") - 1);
SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen(Buffer));
DebugPortWrite ((UINT8 *)"(STM) ", sizeof("(STM) ") - 1);
DebugPortWrite ((UINT8 *) Buffer, AsciiStrLen(Buffer));
ReleaseSpinLock (&mInternalDebugLock);
//