OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
ResolutionParsing.c
Go to the documentation of this file.
1
15#include <Library/BaseLib.h>
16#include <Library/BaseOverflowLib.h>
17#include <Library/DebugLib.h>
19
29STATIC
30VOID
32 IN CONST CHAR8 *String,
33 OUT UINT32 *Width,
34 OUT UINT32 *Height,
35 OUT UINT32 *Bpp OPTIONAL,
36 OUT BOOLEAN *Max
37 )
38{
39 UINT32 TmpWidth;
40 UINT32 TmpHeight;
41
42 *Width = 0;
43 *Height = 0;
44 *Max = FALSE;
45
46 if (Bpp != NULL) {
47 *Bpp = 0;
48 }
49
50 if (AsciiStrCmp (String, "Max") == 0) {
51 *Max = TRUE;
52 return;
53 }
54
55 if ((*String == '\0') || (*String < '0') || (*String > '9')) {
56 return;
57 }
58
59 TmpWidth = TmpHeight = 0;
60
61 while (*String >= '0' && *String <= '9') {
62 if (BaseOverflowMulAddU32 (TmpWidth, 10, *String++ - '0', &TmpWidth)) {
63 return;
64 }
65 }
66
67 if ((*String++ != 'x') || (*String < '0') || (*String > '9')) {
68 return;
69 }
70
71 while (*String >= '0' && *String <= '9') {
72 if (BaseOverflowMulAddU32 (TmpHeight, 10, *String++ - '0', &TmpHeight)) {
73 return;
74 }
75 }
76
77 if ((*String != '\0') && ((*String != '@') || (Bpp == NULL))) {
78 return;
79 }
80
81 *Width = TmpWidth;
82 *Height = TmpHeight;
83
84 if (*String == '\0') {
85 return;
86 }
87
88 TmpWidth = 0;
89 while (*String >= '0' && *String <= '9') {
90 if (BaseOverflowMulAddU32 (TmpWidth, 10, *String++ - '0', &TmpWidth)) {
91 return;
92 }
93 }
94
95 if (*String != '\0') {
96 return;
97 }
98
99 *Bpp = TmpWidth;
100}
101
102VOID
104 IN CONST CHAR8 *String,
105 OUT UINT32 *Width,
106 OUT UINT32 *Height,
107 OUT UINT32 *Bpp,
108 OUT BOOLEAN *Max
109 )
110{
111 ASSERT (String != NULL);
112 ASSERT (Width != NULL);
113 ASSERT (Height != NULL);
114 ASSERT (Bpp != NULL);
115 ASSERT (Max != NULL);
116
117 ParseResolution (String, Width, Height, Bpp, Max);
118}
119
120VOID
122 IN CONST CHAR8 *String,
123 OUT UINT32 *Width,
124 OUT UINT32 *Height,
125 OUT BOOLEAN *Max
126 )
127{
128 ASSERT (String != NULL);
129 ASSERT (Width != NULL);
130 ASSERT (Height != NULL);
131 ASSERT (Max != NULL);
132
133 ParseResolution (String, Width, Height, NULL, Max);
134}
VOID OcParseScreenResolution(IN CONST CHAR8 *String, OUT UINT32 *Width, OUT UINT32 *Height, OUT UINT32 *Bpp, OUT BOOLEAN *Max)
VOID OcParseConsoleMode(IN CONST CHAR8 *String, OUT UINT32 *Width, OUT UINT32 *Height, OUT BOOLEAN *Max)
STATIC VOID ParseResolution(IN CONST CHAR8 *String, OUT UINT32 *Width, OUT UINT32 *Height, OUT UINT32 *Bpp OPTIONAL, OUT BOOLEAN *Max)
#define ASSERT(x)
Definition coder.h:55