TianoCore EDK2 master
Loading...
Searching...
No Matches
Common.c
Go to the documentation of this file.
1
12#include "Common.h"
13
21BOOLEAN
23 VOID
24 )
25{
26 SBI_RET Ret;
27
28 Ret = SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 1, SBI_EXT_DBCN);
29 if ((TranslateError (Ret.Error) == EFI_SUCCESS) &&
30 (Ret.Value != 0))
31 {
32 return TRUE;
33 }
34
35 return FALSE;
36}
37
45BOOLEAN
47 VOID
48 )
49{
50 SBI_RET Ret;
51
52 Ret = SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 1, SBI_EXT_0_1_CONSOLE_PUTCHAR);
53 if ((TranslateError (Ret.Error) == EFI_SUCCESS) &&
54 (Ret.Value != 0))
55 {
56 return TRUE;
57 }
58
59 return FALSE;
60}
61
78 IN UINT8 *Buffer,
79 IN UINTN NumberOfBytes
80 )
81{
82 SBI_RET Ret;
83 UINTN Index;
84
85 for (Index = 0; Index < NumberOfBytes; Index++) {
86 Ret = SbiCall (SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, 1, Buffer[Index]);
87 if ((INT64)Ret.Error < 0) {
88 break;
89 }
90 }
91
92 return Index;
93}
94
109UINTN
111 IN UINT8 *Buffer,
112 IN UINTN NumberOfBytes
113 )
114{
115 SBI_RET Ret;
116
117 Ret = SbiCall (
118 SBI_EXT_DBCN,
119 SBI_EXT_DBCN_WRITE,
120 3,
121 NumberOfBytes,
122 ((UINTN)Buffer),
123 0
124 );
125
126 /*
127 * May do partial writes. Don't bother decoding
128 * Ret.Error as we're only interested in number of
129 * bytes written to console.
130 */
131 return Ret.Value;
132}
UINT64 UINTN
SBI_RET EFIAPI SbiCall(IN UINTN ExtId, IN UINTN FuncId, IN UINTN NumArgs,...)
EFI_STATUS EFIAPI TranslateError(IN UINTN SbiError)
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
BOOLEAN SbiImplementsLegacyPutchar(VOID)
Definition: Common.c:46
UINTN SbiDbcnWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
Definition: Common.c:110
UINTN SbiLegacyPutchar(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
Definition: Common.c:77
BOOLEAN SbiImplementsDbcn(VOID)
Definition: Common.c:22
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
UINTN Error
SBI status code.
UINTN Value
Value returned.