ReactOS 0.4.17-dev-117-g313be0c
machuefi.h File Reference
#include <machine.h>
#include <drivers/acpi/acpi.h>
Include dependency graph for machuefi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID UefiConsPutChar (int Ch)
 
BOOLEAN UefiConsKbHit (VOID)
 
int UefiConsGetCh (void)
 
EFI_STATUS UefiInitializeVideo (VOID)
 
VOID UefiVideoClearScreen (UCHAR Attr)
 
VIDEODISPLAYMODE UefiVideoSetDisplayMode (PCSTR DisplayMode, BOOLEAN Init)
 
VOID UefiVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
ULONG UefiVideoGetBufferSize (VOID)
 
VOID UefiVideoGetFontsFromFirmware (PULONG RomFontPointers)
 
VOID UefiVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID UefiVideoHideShowTextCursor (BOOLEAN Show)
 
VOID UefiVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
VOID UefiVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
BOOLEAN UefiVideoIsPaletteFixed (VOID)
 
VOID UefiVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID UefiVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 
PDESCRIPTION_HEADER UefiFindAcpiTable (_In_ ULONG Signature)
 
VOID UefiVideoSync (VOID)
 
VOID UefiPcBeep (VOID)
 
PFREELDR_MEMORY_DESCRIPTOR UefiMemGetMemoryMap (ULONG *MemoryMapSize)
 
VOID UefiGetExtendedBIOSData (PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
 
UCHAR UefiGetFloppyCount (VOID)
 
BOOLEAN UefiDiskReadLogicalSectors (IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
 
BOOLEAN UefiDiskGetDriveGeometry (UCHAR DriveNumber, PGEOMETRY Geometry)
 
ULONG UefiDiskGetCacheableBlockCount (UCHAR DriveNumber)
 
TIMEINFOUefiGetTime (VOID)
 
BOOLEAN UefiInitializeBootDevices (VOID)
 
PCONFIGURATION_COMPONENT_DATA UefiHwDetect (_In_opt_ PCSTR Options)
 
VOID UefiPrepareForReactOS (VOID)
 
VOID UefiHwIdle (VOID)
 
VOID UefiInitializeFileSystemSupport (_In_ EFI_HANDLE ImageHandle, _In_ EFI_SYSTEM_TABLE *SystemTable)
 

Function Documentation

◆ UefiConsGetCh()

int UefiConsGetCh ( void  )

Definition at line 128 of file ueficon.c.

129{
132 UCHAR KeyOutput = 0;
133
134 /* If an extended key press was detected the last time we were called
135 * then return the scan code of that key. */
136 if (ExtendedKey)
137 {
139 return ExtendedScanCode;
140 }
141
143 if (EFI_ERROR(Status))
144 return 0;
145
146 if (Key.UnicodeChar != 0)
147 {
148 KeyOutput = Key.UnicodeChar;
149 }
150 else
151 {
154 KeyOutput = KEY_EXTENDED;
155 }
156 return KeyOutput;
157}
#define EFI_ERROR(A)
Definition: UefiBaseType.h:165
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
#define KEY_EXTENDED
Definition: keycodes.h:38
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:1932
EFI_INPUT_READ_KEY ReadKeyStroke
Definition: SimpleTextIn.h:125
unsigned char UCHAR
Definition: typedefs.h:53
static UCHAR ConvertToBiosExtValue(UCHAR KeyIn)
Definition: ueficon.c:67
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static BOOLEAN ExtendedKey
Definition: ueficon.c:20
static char ExtendedScanCode
Definition: ueficon.c:21

Referenced by MachInit().

◆ UefiConsKbHit()

BOOLEAN UefiConsKbHit ( VOID  )

Definition at line 121 of file ueficon.c.

122{
125}
#define EFI_SUCCESS
Definition: UefiBaseType.h:120
EFI_CHECK_EVENT CheckEvent
Definition: UefiSpec.h:1824
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959

Referenced by MachInit().

◆ UefiConsPutChar()

VOID UefiConsPutChar ( int  Ch)

Definition at line 26 of file ueficon.c.

27{
29 BOOLEAN NeedScroll;
30
32
33 NeedScroll = (CurrentCursorY >= Height);
34 if (NeedScroll)
35 {
38 }
39 if (c == '\r')
40 {
42 }
43 else if (c == '\n')
44 {
46 if (!NeedScroll)
48 }
49 else if (c == '\t')
50 {
51 CurrentCursorX = (CurrentCursorX + 8) & ~7;
52 }
53 else
54 {
57 }
58 if (CurrentCursorX >= Width)
59 {
62 }
63}
unsigned char BOOLEAN
Definition: actypes.h:127
const GLubyte * c
Definition: glext.h:8905
#define Unused(x)
Definition: atlwin.h:28
uint32_t ULONG
Definition: typedefs.h:59
static unsigned CurrentCursorX
Definition: ueficon.c:15
static unsigned CurrentCursorY
Definition: ueficon.c:16
static UCHAR CurrentAttr
Definition: ueficon.c:17
VOID UefiVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: uefivid.c:654
VOID UefiVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: uefivid.c:648
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
VOID FbConsScrollUp(_In_ UCHAR Attr)
Definition: vidfb.c:513

Referenced by MachInit().

◆ UefiDiskGetCacheableBlockCount()

ULONG UefiDiskGetCacheableBlockCount ( UCHAR  DriveNumber)

Definition at line 1301 of file uefidisk.c.

1302{
1303 ULONG ArcDriveIndex;
1304 EFI_BLOCK_IO* BlockIo;
1306
1307 if (DriveNumber < FIRST_BIOS_DISK)
1308 return 0;
1309
1310 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1311
1312 if (InternalUefiDisk == NULL)
1313 {
1314 ERR("InternalUefiDisk not initialized\n");
1315 return 0;
1316 }
1317
1318 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1319 {
1320 ERR("Invalid drive number: %d\n", DriveNumber);
1321 return 0;
1322 }
1323
1325 InternalUefiDisk[ArcDriveIndex].Handle,
1326 &BlockIoGuid,
1327 (VOID**)&BlockIo);
1328
1329 if (EFI_ERROR(Status) || BlockIo == NULL)
1330 {
1331 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1332 return 0;
1333 }
1334
1335 if (!BlockIo->Media->MediaPresent)
1336 {
1337 ERR("Media not present for drive %d\n", DriveNumber);
1338 return 0;
1339 }
1340
1341 return (ULONG)(BlockIo->Media->LastBlock + 1);
1342}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
ULONG Handle
Definition: gdb_input.c:15
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1832
static EFI_GUID BlockIoGuid
Definition: uefidisk.c:65
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define FIRST_BIOS_DISK
Definition: uefidisk.c:17
static INTERNAL_UEFI_DISK * InternalUefiDisk
Definition: uefidisk.c:64

Referenced by MachInit().

◆ UefiDiskGetDriveGeometry()

BOOLEAN UefiDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  Geometry 
)

Definition at line 1251 of file uefidisk.c.

1252{
1253 ULONG ArcDriveIndex;
1254 EFI_BLOCK_IO* BlockIo;
1256
1257 if (DriveNumber < FIRST_BIOS_DISK)
1258 return FALSE;
1259
1260 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1261
1262 if (InternalUefiDisk == NULL)
1263 {
1264 ERR("InternalUefiDisk not initialized\n");
1265 return FALSE;
1266 }
1267
1268 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1269 {
1270 ERR("Invalid drive number: %d\n", DriveNumber);
1271 return FALSE;
1272 }
1273
1275 InternalUefiDisk[ArcDriveIndex].Handle,
1276 &BlockIoGuid,
1277 (VOID**)&BlockIo);
1278
1279 if (EFI_ERROR(Status) || BlockIo == NULL)
1280 {
1281 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1282 return FALSE;
1283 }
1284
1285 if (!BlockIo->Media->MediaPresent)
1286 {
1287 ERR("Media not present for drive %d\n", DriveNumber);
1288 return FALSE;
1289 }
1290
1291 Geometry->Cylinders = 1; /* Not relevant for UEFI Block I/O protocol */
1292 Geometry->Heads = 1; /* Not relevant for UEFI Block I/O protocol */
1293 Geometry->SectorsPerTrack = (ULONG)(BlockIo->Media->LastBlock + 1);
1294 Geometry->BytesPerSector = BlockIo->Media->BlockSize;
1295 Geometry->Sectors = BlockIo->Media->LastBlock + 1;
1296
1297 return TRUE;
1298}
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:28
ULONG Cylinders
Number of cylinders on the disk.
Definition: disk.h:25
ULONGLONG Sectors
Total number of disk sectors/LBA blocks.
Definition: disk.h:29
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:27
ULONG Heads
Number of heads on the disk.
Definition: disk.h:26

Referenced by MachInit().

◆ UefiDiskReadLogicalSectors()

BOOLEAN UefiDiskReadLogicalSectors ( IN UCHAR  DriveNumber,
IN ULONGLONG  SectorNumber,
IN ULONG  SectorCount,
OUT PVOID  Buffer 
)

Definition at line 1116 of file uefidisk.c.

1121{
1122 ULONG ArcDriveIndex;
1123 EFI_BLOCK_IO* BlockIo;
1125 ULONG BlockSize;
1126 ULONG IoAlign;
1127
1128 if (DriveNumber < FIRST_BIOS_DISK)
1129 return FALSE;
1130
1131 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1132
1133 if (InternalUefiDisk == NULL)
1134 {
1135 ERR("InternalUefiDisk not initialized\n");
1136 return FALSE;
1137 }
1138
1139 if (ArcDriveIndex >= 32)
1140 {
1141 ERR("Drive index out of bounds: %d (ArcDriveIndex=%lu)\n", DriveNumber, ArcDriveIndex);
1142 return FALSE;
1143 }
1144
1145 /* Allow access during initialization: check if handle is set up.
1146 * During initialization, Handle is set before GetHarddiskInformation is called. */
1147 if (InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1148 {
1149 ERR("Invalid drive number: %d (ArcDriveIndex=%lu, PcBiosDiskCount=%lu, Handle=NULL)\n",
1150 DriveNumber, ArcDriveIndex, PcBiosDiskCount);
1151 return FALSE;
1152 }
1153
1155 InternalUefiDisk[ArcDriveIndex].Handle,
1156 &BlockIoGuid,
1157 (VOID**)&BlockIo);
1158
1159 if (EFI_ERROR(Status) || BlockIo == NULL)
1160 {
1161 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1162 return FALSE;
1163 }
1164
1165 if (!BlockIo->Media->MediaPresent)
1166 {
1167 ERR("Media not present for drive %d\n", DriveNumber);
1168 return FALSE;
1169 }
1170
1171 BlockSize = BlockIo->Media->BlockSize;
1172 IoAlign = BlockIo->Media->IoAlign;
1173
1174 if (!UefiEnsureDiskReadBufferAligned(IoAlign))
1175 {
1176 ERR("Failed to align disk read buffer for drive %d\n", DriveNumber);
1177 return FALSE;
1178 }
1179
1180 if (!UefiIsAlignedPointer(Buffer, (IoAlign == 0) ? 1 : IoAlign))
1181 {
1182 ULONG TotalSectors = SectorCount;
1183 ULONG MaxSectors = DiskReadBufferSize / BlockSize;
1184 ULONGLONG CurrentSector = SectorNumber;
1185 PUCHAR OutPtr = (PUCHAR)Buffer;
1186
1187 if (MaxSectors == 0)
1188 {
1189 ERR("DiskReadBufferSize too small for block size %lu\n", BlockSize);
1190 return FALSE;
1191 }
1192
1193 while (TotalSectors)
1194 {
1195 ULONG ReadSectors = min(TotalSectors, MaxSectors);
1196 UINTN ReadSize = ReadSectors * BlockSize;
1197
1198 Status = BlockIo->ReadBlocks(
1199 BlockIo,
1200 BlockIo->Media->MediaId,
1201 CurrentSector,
1202 ReadSize,
1204
1205 if (EFI_ERROR(Status))
1206 {
1207 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1208 DriveNumber, CurrentSector, ReadSectors, (ULONG)Status);
1209 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1210 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1211 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1212 BlockIo->Media->LastBlock,
1213 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1214 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1215 return FALSE;
1216 }
1217
1218 RtlCopyMemory(OutPtr, DiskReadBuffer, ReadSize);
1219 OutPtr += ReadSize;
1220 CurrentSector += ReadSectors;
1221 TotalSectors -= ReadSectors;
1222 }
1223
1224 return TRUE;
1225 }
1226
1227 Status = BlockIo->ReadBlocks(
1228 BlockIo,
1229 BlockIo->Media->MediaId,
1230 SectorNumber,
1231 SectorCount * BlockSize,
1232 Buffer);
1233
1234 if (EFI_ERROR(Status))
1235 {
1236 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1237 DriveNumber, SectorNumber, SectorCount, (ULONG)Status);
1238 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1239 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1240 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1241 BlockIo->Media->LastBlock,
1242 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1243 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1244 return FALSE;
1245 }
1246
1247 return TRUE;
1248}
UINT32 UINTN
Definition: bufpool.h:45
#define min(a, b)
Definition: monoChain.cc:55
ULONG SectorCount
Definition: part_brfr.c:22
uint64_t ULONGLONG
Definition: typedefs.h:67
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
PVOID DiskReadBuffer
Definition: uefidisk.c:50
static BOOLEAN UefiEnsureDiskReadBufferAligned(IN ULONG Alignment)
Definition: uefidisk.c:96
static UCHAR PcBiosDiskCount
Definition: uefidisk.c:55
SIZE_T DiskReadBufferSize
Definition: uefidisk.c:59
static BOOLEAN UefiIsAlignedPointer(IN PVOID Pointer, IN ULONG Alignment)
Definition: uefidisk.c:81

Referenced by MachInit().

◆ UefiFindAcpiTable()

PDESCRIPTION_HEADER UefiFindAcpiTable ( _In_ ULONG  Signature)

Definition at line 94 of file uefihw.c.

96{
99
100 Rsdp = FindAcpiBios();
101 if (Rsdp == NULL)
102 return NULL;
103
104 if ((Rsdp->revision > 0) && (Rsdp->xsdt_physical_address != 0))
105 {
107
108 if ((Xsdt != NULL) && (Xsdt->Header.Length >= sizeof(Xsdt->Header)))
109 {
110 Count = (Xsdt->Header.Length - sizeof(Xsdt->Header)) / sizeof(Xsdt->Tables[0]);
111 for (Index = 0; Index < Count; ++Index)
112 {
115
116 if ((Header != NULL) && (Header->Signature == Signature))
117 return Header;
118 }
119 }
120 }
121
122 if (Rsdp->rsdt_physical_address != 0)
123 {
125
126 if ((Rsdt != NULL) && (Rsdt->Header.Length >= sizeof(Rsdt->Header)))
127 {
128 Count = (Rsdt->Header.Length - sizeof(Rsdt->Header)) / sizeof(Rsdt->Tables[0]);
129 for (Index = 0; Index < Count; ++Index)
130 {
133
134 if ((Header != NULL) && (Header->Signature == Signature))
135 return Header;
136 }
137 }
138 }
139
140 return NULL;
141}
Definition: Header.h:9
static const WCHAR Signature[]
Definition: parser.c:141
int Count
Definition: noreturn.cpp:7
RSDT * PRSDT
Definition: acpi.h:206
DESCRIPTION_HEADER * PDESCRIPTION_HEADER
Definition: acpi.h:109
XSDT * PXSDT
Definition: acpi.h:214
ULONG rsdt_physical_address
Definition: winldr.h:26
UCHAR revision
Definition: winldr.h:25
ULONGLONG xsdt_physical_address
Definition: winldr.h:28
Definition: acpi.h:201
ULONG Tables[ANYSIZE_ARRAY]
Definition: acpi.h:204
DESCRIPTION_HEADER Header
Definition: acpi.h:203
Definition: acpi.h:209
PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY]
Definition: acpi.h:212
DESCRIPTION_HEADER Header
Definition: acpi.h:211
uint32_t ULONG_PTR
Definition: typedefs.h:65
static PRSDP_DESCRIPTOR FindAcpiBios(VOID)
Definition: uefihw.c:74
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by UefiInitializeBgrtLogo().

◆ UefiGetExtendedBIOSData()

VOID UefiGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 32 of file stubs.c.

34{
35
36}

Referenced by MachInit().

◆ UefiGetFloppyCount()

UCHAR UefiGetFloppyCount ( VOID  )

Definition at line 1109 of file uefidisk.c.

1110{
1111 /* No floppy support in UEFI */
1112 return 0;
1113}

Referenced by MachInit().

◆ UefiGetTime()

TIMEINFO * UefiGetTime ( VOID  )

Definition at line 20 of file uefiutil.c.

21{
22 static TIMEINFO TimeInfo;
24 EFI_TIME time = {0};
25
27 if (Status != EFI_SUCCESS)
28 ERR("UefiGetTime: cannot get time status %d\n", Status);
29
30 TimeInfo.Year = time.Year;
31 TimeInfo.Month = time.Month;
32 TimeInfo.Day = time.Day;
33 TimeInfo.Hour = time.Hour;
34 TimeInfo.Minute = time.Minute;
35 TimeInfo.Second = time.Second;
36 return &TimeInfo;
37}
__u16 time
Definition: mkdosfs.c:8
EFI_GET_TIME GetTime
Definition: UefiSpec.h:1752
EFI_RUNTIME_SERVICES * RuntimeServices
Definition: UefiSpec.h:1955
Definition: fw.h:10
USHORT Month
Definition: fw.h:12
USHORT Day
Definition: fw.h:13
USHORT Minute
Definition: fw.h:15
USHORT Hour
Definition: fw.h:14
USHORT Second
Definition: fw.h:16
USHORT Year
Definition: fw.h:11
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16

Referenced by MachInit().

◆ UefiHwDetect()

PCONFIGURATION_COMPONENT_DATA UefiHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 326 of file uefihw.c.

328{
330 ULONG BusNumber = 0;
331
332 TRACE("DetectHardware()\n");
333
334 /* Create the 'System' key */
335#if defined(_M_IX86) || defined(_M_AMD64)
336 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
337#elif defined(_M_IA64)
338 FldrCreateSystemKey(&SystemKey, "Intel Itanium processor family");
339#elif defined(_M_ARM) || defined(_M_ARM64)
340 FldrCreateSystemKey(&SystemKey, "ARM processor family");
341#else
342 #error Please define a system key for your architecture
343#endif
344
345 /* Detect buses */
346 DetectInternal(SystemKey, &BusNumber);
347 // TODO: DetectPciBios
348 DetectAcpiBios(SystemKey, &BusNumber);
349
350 TRACE("DetectHardware() Done\n");
351 return SystemKey;
352}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:161
_In_ ULONG BusNumber
Definition: pciidex.h:65
#define TRACE(s)
Definition: solgame.cpp:4
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:144
static VOID DetectInternal(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:283

Referenced by MachInit().

◆ UefiHwIdle()

VOID UefiHwIdle ( VOID  )

Definition at line 38 of file uefihw.c.

39{
43
44 /* Keep one timer event around and arm it each idle tick */
45 if (IdleTimerEvent == NULL)
46 {
47 Status = BootServices->CreateEvent(EVT_TIMER,
49 NULL,
50 NULL,
52 if (EFI_ERROR(Status))
53 {
54 StallExecutionProcessor(10000); /* 10 ms fallback */
55 return;
56 }
57 }
58
59 /* Set a 10ms (100,000 * 100ns) relative timer */
60 Status = BootServices->SetTimer(IdleTimerEvent, TimerRelative, 100000);
61 if (!EFI_ERROR(Status))
62 Status = BootServices->WaitForEvent(1, &IdleTimerEvent, &Index);
63 if (EFI_ERROR(Status))
64 StallExecutionProcessor(10000); /* 10 ms fallback */
65}
#define TPL_APPLICATION
Definition: UefiSpec.h:561
@ TimerRelative
Definition: UefiSpec.h:464
#define EVT_TIMER
Definition: UefiSpec.h:362
EFI_SET_TIMER SetTimer
Definition: UefiSpec.h:1820
EFI_CREATE_EVENT CreateEvent
Definition: UefiSpec.h:1819
EFI_WAIT_FOR_EVENT WaitForEvent
Definition: UefiSpec.h:1821
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: uefihw.c:32
static EFI_EVENT IdleTimerEvent
Definition: uefihw.c:27

Referenced by MachInit().

◆ UefiInitializeBootDevices()

BOOLEAN UefiInitializeBootDevices ( VOID  )

Definition at line 1040 of file uefidisk.c.

1041{
1042 EFI_BLOCK_IO* BlockIo;
1044 ULONG ArcDriveIndex;
1045
1052 {
1053 ERR("Failed to allocate disk read buffer\n");
1054 return FALSE;
1055 }
1056
1058
1059 if (PcBiosDiskCount == 0)
1060 {
1061 ERR("No block devices found\n");
1062 return FALSE;
1063 }
1064
1065 if (!UefiSetBootpath())
1066 {
1067 ERR("Failed to set boot path\n");
1068 return FALSE;
1069 }
1070
1071 /* Handle CD-ROM boot device registration */
1072 ArcDriveIndex = PublicBootArcDisk;
1073 if (ArcDriveIndex >= PcBiosDiskCount || InternalUefiDisk == NULL)
1074 {
1075 ERR("Invalid boot arc disk index\n");
1076 return FALSE;
1077 }
1078
1080 InternalUefiDisk[ArcDriveIndex].Handle,
1081 &BlockIoGuid,
1082 (VOID**)&BlockIo);
1083
1084 if (EFI_ERROR(Status) || BlockIo == NULL)
1085 {
1086 ERR("Failed to get Block I/O protocol\n");
1087 return FALSE;
1088 }
1089
1090 if (BlockIo->Media->RemovableMedia == TRUE && BlockIo->Media->BlockSize == 2048)
1091 {
1093
1098
1099 if (Status == ESUCCESS)
1100 TRACE("Registered CD-ROM boot device: 0x%02X\n", FrldrBootDrive);
1101 else
1102 ERR("CD-ROM boot device 0x%02X failed\n", FrldrBootDrive);
1103 }
1104
1105 return TRUE;
1106}
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:189
ARC_STATUS DiskInitialize(_In_ UCHAR DriveNumber, _In_ PCSTR DeviceName, _In_ CONFIGURATION_TYPE DeviceType, _In_ const DEVVTBL *FuncTable, _Out_opt_ PULONG pChecksum, _Out_opt_ PULONG pSignature, _Out_opt_ PBOOLEAN pValidPartitionTable)
Definition: disk.c:78
LONG DiskReportError(_In_ BOOLEAN bShowError)
Definition: disk.c:38
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
@ CdromController
Definition: arc.h:128
static ULONG PublicBootArcDisk
Definition: uefidisk.c:63
static BOOLEAN DiskReadBufferFromPool
Definition: uefidisk.c:53
static ULONG DiskReadBufferAlignment
Definition: uefidisk.c:52
static const DEVVTBL UefiDiskVtbl
Definition: uefidisk.c:634
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:706
static PVOID DiskReadBufferRaw
Definition: uefidisk.c:51
UCHAR FrldrBootDrive
Definition: uefidisk.c:57
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:962

Referenced by MachInit().

◆ UefiInitializeFileSystemSupport()

VOID UefiInitializeFileSystemSupport ( _In_ EFI_HANDLE  ImageHandle,
_In_ EFI_SYSTEM_TABLE SystemTable 
)

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 620 of file uefivid.c.

621{
623
624 /* First, try GOP */
626 if (Status == EFI_SUCCESS)
627 return Status;
628
629 /* Try Apple Graphics Info if that fails */
630 TRACE("Failed to detect GOP, trying Apple Graphics Info\n");
632 if (Status == EFI_SUCCESS)
633 return Status;
634
635 /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
636 ERR("Cannot find framebuffer!\n");
637 return Status;
638}
static EFI_STATUS UefiInitializeAppleGraphics(VOID)
Definition: uefivid.c:564
static EFI_STATUS UefiInitializeGop(VOID)
Definition: uefivid.c:483

Referenced by MachInit().

◆ UefiMemGetMemoryMap()

PFREELDR_MEMORY_DESCRIPTOR UefiMemGetMemoryMap ( ULONG MemoryMapSize)

Definition at line 144 of file uefimem.c.

145{
146 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
147 UINT32 DescriptorVersion;
148 SIZE_T FreeldrMemMapSize;
151 UINTN MapSize;
152 UINTN MapKey;
154
155 EFI_GUID EfiLoadedImageProtocol = EFI_LOADED_IMAGE_PROTOCOL_GUID;
156 PFREELDR_MEMORY_DESCRIPTOR FreeldrMem = NULL;
157 EFI_MEMORY_DESCRIPTOR* MapEntry = NULL;
158 UINT32 EntryCount = 0;
160
162 &EfiLoadedImageProtocol,
163 (VOID**)&LoadedImage);
164 if (Status != EFI_SUCCESS)
165 {
166 TRACE("Failed to find LoadedImageHandle with status: %d\n", Status);
167 UiMessageBoxCritical("Unable to initialize memory manager.");
168 return NULL;
169 }
170 OsLoaderBase = LoadedImage->ImageBase;
171 OsLoaderSize = LoadedImage->ImageSize;
172 PublicBootHandle = LoadedImage->DeviceHandle;
174
175 TRACE("UefiMemGetMemoryMap: Gather memory map\n");
176 PUEFI_LoadMemoryMap(&MapKey,
177 &MapSize,
179 &DescriptorVersion);
180
181 TRACE("Value of MapKey: %d\n", MapKey);
182 TRACE("Value of MapSize: %d\n", MapSize);
183 TRACE("Value of DescriptorSize: %d\n", DescriptorSize);
184 TRACE("Value of DescriptorVersion: %d\n", DescriptorVersion);
185
186 EntryCount = (MapSize / DescriptorSize);
187
188 FreeldrMemMapSize = (sizeof(FREELDR_MEMORY_DESCRIPTOR) * EntryCount);
190 FreeldrMemMapSize,
191 (void**)&FreeldrMem);
192 if (Status != EFI_SUCCESS)
193 {
194 TRACE("Failed to allocate pool with status %d\n", Status);
195 UiMessageBoxCritical("Unable to initialize memory manager.");
196 return NULL;
197 }
198
199 RtlZeroMemory(FreeldrMem, FreeldrMemMapSize);
200 MapEntry = EfiMemoryMap;
201 for (Index = 0; Index < EntryCount; ++Index)
202 {
203 TYPE_OF_MEMORY MemoryType = UefiConvertToFreeldrDesc(MapEntry->Type);
204 if (MemoryType == LoaderFree)
205 {
208 MapEntry->NumberOfPages,
209 &MapEntry->PhysicalStart);
210 if (Status != EFI_SUCCESS)
211 {
212 /* We failed to reserve the page, so change its type */
213 MemoryType = LoaderFirmwareTemporary;
214 }
215 }
216
217 /* We really don't want to touch these reserved spots at all */
218 if (MemoryType != LoaderReserve)
219 {
220 UefiSetMemory(FreeldrMem,
221 MapEntry->PhysicalStart,
222 MapEntry->NumberOfPages,
223 MemoryType);
224 }
225
226 MapEntry = NEXT_MEMORY_DESCRIPTOR(MapEntry, DescriptorSize);
227 }
228
229 /* Windows expects the first page to be reserved, otherwise it asserts.
230 * However it can be just a free page on some UEFI systems. */
231 UefiSetMemory(FreeldrMem, 0x000000, 1, LoaderFirmwarePermanent);
232 *MemoryMapSize = FreeldrDescCount;
233 return FreeldrMem;
234}
#define EFI_LOADED_IMAGE_PROTOCOL_GUID
Definition: LoadedImage.h:21
@ EfiLoaderData
@ AllocateAddress
Definition: UefiSpec.h:45
struct _FREELDR_MEMORY_DESCRIPTOR FREELDR_MEMORY_DESCRIPTOR
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
@ LoaderReserve
Definition: arc.h:317
@ LoaderFree
Definition: arc.h:295
@ LoaderFirmwareTemporary
Definition: arc.h:298
@ LoaderFirmwarePermanent
Definition: arc.h:299
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
EFI_ALLOCATE_PAGES AllocatePages
Definition: UefiSpec.h:1810
EFI_ALLOCATE_POOL AllocatePool
Definition: UefiSpec.h:1813
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:99
_In_ SIZE_T DescriptorSize
Definition: nls.c:40
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t UINT32
Definition: typedefs.h:59
UINT32 FreeldrDescCount
Definition: uefimem.c:34
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:33
static VOID PUEFI_LoadMemoryMap(_Out_ UINTN *LocMapKey, _Out_ UINTN *LocMapSize, _Out_ UINTN *LocDescriptorSize, _Out_ UINT32 *LocDescriptorVersion)
Definition: uefimem.c:47
EFI_HANDLE PublicBootHandle
Definition: uefimem.c:37
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static TYPE_OF_MEMORY UefiConvertToFreeldrDesc(EFI_MEMORY_TYPE EfiMemoryType)
Definition: uefimem.c:107
PVOID OsLoaderBase
Definition: uefimem.c:35
static VOID UefiSetMemory(_Inout_ PFREELDR_MEMORY_DESCRIPTOR MemoryMap, _In_ ULONG_PTR BaseAddress, _In_ PFN_COUNT SizeInPages, _In_ TYPE_OF_MEMORY MemoryType)
Definition: uefimem.c:86
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
SIZE_T OsLoaderSize
Definition: uefimem.c:36
#define NEXT_MEMORY_DESCRIPTOR(Descriptor, DescriptorSize)
Definition: uefimem.c:15

Referenced by MachInit().

◆ UefiPcBeep()

VOID UefiPcBeep ( VOID  )

Definition at line 39 of file stubs.c.

40{
41 /* Not possible on UEFI, for now */
42}

Referenced by MachInit().

◆ UefiPrepareForReactOS()

VOID UefiPrepareForReactOS ( VOID  )

Definition at line 272 of file uefimem.c.

273{
274 _exituefi();
275}
void _exituefi(VOID)

Referenced by MachInit().

◆ UefiVideoClearScreen()

VOID UefiVideoClearScreen ( UCHAR  Attr)

Definition at line 642 of file uefivid.c.

643{
644 FbConsClearScreen(Attr);
645}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413

Referenced by MachInit().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 673 of file uefivid.c.

674{
677}
static VOID UefiDrawBgrtLogo(VOID)
Definition: uefivid.c:433
VOID FbConsCopyOffScreenBufferToVRAM(_In_ PVOID Buffer)
Copies a full text-mode CGA-style character buffer rectangle to the console.
Definition: vidfb.c:492

Referenced by MachInit().

◆ UefiVideoGetBufferSize()

ULONG UefiVideoGetBufferSize ( VOID  )

Definition at line 667 of file uefivid.c.

668{
669 return FbConsGetBufferSize();
670}
ULONG FbConsGetBufferSize(VOID)
Returns the size in bytes, of a full text-mode CGA-style character buffer rectangle that can fill the...
Definition: vidfb.c:481

Referenced by MachInit().

◆ UefiVideoGetDisplaySize()

VOID UefiVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 654 of file uefivid.c.

655{
657}
VOID FbConsGetDisplaySize(_Out_ PULONG Width, _Out_ PULONG Height, _Out_ PULONG Depth)
Returns the width and height in number of CGA characters/attributes, of a full text-mode CGA-style ch...
Definition: vidfb.c:462
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by MachInit(), and UefiConsPutChar().

◆ UefiVideoGetFontsFromFirmware()

VOID UefiVideoGetFontsFromFirmware ( PULONG  RomFontPointers)

Definition at line 20 of file stubs.c.

21{
22
23}

Referenced by MachInit().

◆ UefiVideoGetPaletteColor()

VOID UefiVideoGetPaletteColor ( UCHAR  Color,
UCHAR Red,
UCHAR Green,
UCHAR Blue 
)

Definition at line 705 of file uefivid.c.

707{
708 /* Not supported */
709}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 686 of file uefivid.c.

687{
688 /* We don't have a cursor yet */
689}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 692 of file uefivid.c.

693{
694 return 0;
695}

Referenced by MachInit().

◆ UefiVideoPutChar()

VOID UefiVideoPutChar ( int  Ch,
UCHAR  Attr,
unsigned  X,
unsigned  Y 
)

Definition at line 648 of file uefivid.c.

649{
650 FbConsPutChar(Ch, Attr, X, Y);
651}
#define Y(I)
#define Ch(x, y, z)
Definition: sha2.c:141
VOID FbConsPutChar(_In_ UCHAR Char, _In_ UCHAR Attr, _In_ ULONG Column, _In_ ULONG Row)
Displays a character with specific text attributes at a given position.
Definition: vidfb.c:445

Referenced by MachInit(), and UefiConsPutChar().

◆ UefiVideoSetDisplayMode()

VIDEODISPLAYMODE UefiVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 660 of file uefivid.c.

661{
662 /* We only have one mode, semi-text */
663 return VideoTextMode;
664}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

VOID UefiVideoSetPaletteColor ( UCHAR  Color,
UCHAR  Red,
UCHAR  Green,
UCHAR  Blue 
)

Definition at line 698 of file uefivid.c.

700{
701 /* Not supported */
702}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 680 of file uefivid.c.

681{
682 /* We don't have a cursor yet */
683}

Referenced by MachInit().

◆ UefiVideoSync()

VOID UefiVideoSync ( VOID  )

Definition at line 26 of file stubs.c.

27{
28
29}

Referenced by MachInit().