ReactOS 0.4.17-dev-684-ga6524ef
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:24
#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 1328 of file uefidisk.c.

1329{
1330 ULONG ArcDriveIndex;
1331 EFI_BLOCK_IO* BlockIo;
1333
1334 if (DriveNumber < FIRST_BIOS_DISK)
1335 return 0;
1336
1337 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1338
1339 if (InternalUefiDisk == NULL)
1340 {
1341 ERR("InternalUefiDisk not initialized\n");
1342 return 0;
1343 }
1344
1345 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1346 {
1347 ERR("Invalid drive number: %d\n", DriveNumber);
1348 return 0;
1349 }
1350
1352 InternalUefiDisk[ArcDriveIndex].Handle,
1353 &BlockIoGuid,
1354 (VOID**)&BlockIo);
1355
1356 if (EFI_ERROR(Status) || BlockIo == NULL)
1357 {
1358 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1359 return 0;
1360 }
1361
1362 if (!BlockIo->Media->MediaPresent)
1363 {
1364 ERR("Media not present for drive %d\n", DriveNumber);
1365 return 0;
1366 }
1367
1368 return (ULONG)(BlockIo->Media->LastBlock + 1);
1369}
#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 1278 of file uefidisk.c.

1279{
1280 ULONG ArcDriveIndex;
1281 EFI_BLOCK_IO* BlockIo;
1283
1284 if (DriveNumber < FIRST_BIOS_DISK)
1285 return FALSE;
1286
1287 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1288
1289 if (InternalUefiDisk == NULL)
1290 {
1291 ERR("InternalUefiDisk not initialized\n");
1292 return FALSE;
1293 }
1294
1295 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1296 {
1297 ERR("Invalid drive number: %d\n", DriveNumber);
1298 return FALSE;
1299 }
1300
1302 InternalUefiDisk[ArcDriveIndex].Handle,
1303 &BlockIoGuid,
1304 (VOID**)&BlockIo);
1305
1306 if (EFI_ERROR(Status) || BlockIo == NULL)
1307 {
1308 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1309 return FALSE;
1310 }
1311
1312 if (!BlockIo->Media->MediaPresent)
1313 {
1314 ERR("Media not present for drive %d\n", DriveNumber);
1315 return FALSE;
1316 }
1317
1318 Geometry->Cylinders = 1; /* Not relevant for UEFI Block I/O protocol */
1319 Geometry->Heads = 1; /* Not relevant for UEFI Block I/O protocol */
1320 Geometry->SectorsPerTrack = (ULONG)(BlockIo->Media->LastBlock + 1);
1321 Geometry->BytesPerSector = BlockIo->Media->BlockSize;
1322 Geometry->Sectors = BlockIo->Media->LastBlock + 1;
1323
1324 return TRUE;
1325}
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 1143 of file uefidisk.c.

1148{
1149 ULONG ArcDriveIndex;
1150 EFI_BLOCK_IO* BlockIo;
1152 ULONG BlockSize;
1153 ULONG IoAlign;
1154
1155 if (DriveNumber < FIRST_BIOS_DISK)
1156 return FALSE;
1157
1158 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1159
1160 if (InternalUefiDisk == NULL)
1161 {
1162 ERR("InternalUefiDisk not initialized\n");
1163 return FALSE;
1164 }
1165
1166 if (ArcDriveIndex >= 32)
1167 {
1168 ERR("Drive index out of bounds: %d (ArcDriveIndex=%lu)\n", DriveNumber, ArcDriveIndex);
1169 return FALSE;
1170 }
1171
1172 /* Allow access during initialization: check if handle is set up.
1173 * During initialization, Handle is set before GetHarddiskInformation is called. */
1174 if (InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1175 {
1176 ERR("Invalid drive number: %d (ArcDriveIndex=%lu, PcBiosDiskCount=%lu, Handle=NULL)\n",
1177 DriveNumber, ArcDriveIndex, PcBiosDiskCount);
1178 return FALSE;
1179 }
1180
1182 InternalUefiDisk[ArcDriveIndex].Handle,
1183 &BlockIoGuid,
1184 (VOID**)&BlockIo);
1185
1186 if (EFI_ERROR(Status) || BlockIo == NULL)
1187 {
1188 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1189 return FALSE;
1190 }
1191
1192 if (!BlockIo->Media->MediaPresent)
1193 {
1194 ERR("Media not present for drive %d\n", DriveNumber);
1195 return FALSE;
1196 }
1197
1198 BlockSize = BlockIo->Media->BlockSize;
1199 IoAlign = BlockIo->Media->IoAlign;
1200
1201 if (!UefiEnsureDiskReadBufferAligned(IoAlign))
1202 {
1203 ERR("Failed to align disk read buffer for drive %d\n", DriveNumber);
1204 return FALSE;
1205 }
1206
1207 if (!UefiIsAlignedPointer(Buffer, (IoAlign == 0) ? 1 : IoAlign))
1208 {
1209 ULONG TotalSectors = SectorCount;
1210 ULONG MaxSectors = DiskReadBufferSize / BlockSize;
1211 ULONGLONG CurrentSector = SectorNumber;
1212 PUCHAR OutPtr = (PUCHAR)Buffer;
1213
1214 if (MaxSectors == 0)
1215 {
1216 ERR("DiskReadBufferSize too small for block size %lu\n", BlockSize);
1217 return FALSE;
1218 }
1219
1220 while (TotalSectors)
1221 {
1222 ULONG ReadSectors = min(TotalSectors, MaxSectors);
1223 UINTN ReadSize = ReadSectors * BlockSize;
1224
1225 Status = BlockIo->ReadBlocks(
1226 BlockIo,
1227 BlockIo->Media->MediaId,
1228 CurrentSector,
1229 ReadSize,
1231
1232 if (EFI_ERROR(Status))
1233 {
1234 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1235 DriveNumber, CurrentSector, ReadSectors, (ULONG)Status);
1236 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1237 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1238 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1239 BlockIo->Media->LastBlock,
1240 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1241 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1242 return FALSE;
1243 }
1244
1245 RtlCopyMemory(OutPtr, DiskReadBuffer, ReadSize);
1246 OutPtr += ReadSize;
1247 CurrentSector += ReadSectors;
1248 TotalSectors -= ReadSectors;
1249 }
1250
1251 return TRUE;
1252 }
1253
1254 Status = BlockIo->ReadBlocks(
1255 BlockIo,
1256 BlockIo->Media->MediaId,
1257 SectorNumber,
1258 SectorCount * BlockSize,
1259 Buffer);
1260
1261 if (EFI_ERROR(Status))
1262 {
1263 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1264 DriveNumber, SectorNumber, SectorCount, (ULONG)Status);
1265 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1266 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1267 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1268 BlockIo->Media->LastBlock,
1269 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1270 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1271 return FALSE;
1272 }
1273
1274 return TRUE;
1275}
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 1136 of file uefidisk.c.

1137{
1138 /* No floppy support in UEFI */
1139 return 0;
1140}

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 1067 of file uefidisk.c.

1068{
1069 EFI_BLOCK_IO* BlockIo;
1071 ULONG ArcDriveIndex;
1072
1079 {
1080 ERR("Failed to allocate disk read buffer\n");
1081 return FALSE;
1082 }
1083
1085
1086 if (PcBiosDiskCount == 0)
1087 {
1088 ERR("No block devices found\n");
1089 return FALSE;
1090 }
1091
1092 if (!UefiSetBootpath())
1093 {
1094 ERR("Failed to set boot path\n");
1095 return FALSE;
1096 }
1097
1098 /* Handle CD-ROM boot device registration */
1099 ArcDriveIndex = PublicBootArcDisk;
1100 if (ArcDriveIndex >= PcBiosDiskCount || InternalUefiDisk == NULL)
1101 {
1102 ERR("Invalid boot arc disk index\n");
1103 return FALSE;
1104 }
1105
1107 InternalUefiDisk[ArcDriveIndex].Handle,
1108 &BlockIoGuid,
1109 (VOID**)&BlockIo);
1110
1111 if (EFI_ERROR(Status) || BlockIo == NULL)
1112 {
1113 ERR("Failed to get Block I/O protocol\n");
1114 return FALSE;
1115 }
1116
1117 if (BlockIo->Media->RemovableMedia == TRUE && BlockIo->Media->BlockSize == 2048)
1118 {
1120
1125
1126 if (Status == ESUCCESS)
1127 TRACE("Registered CD-ROM boot device: 0x%02X\n", FrldrBootDrive);
1128 else
1129 ERR("CD-ROM boot device 0x%02X failed\n", FrldrBootDrive);
1130 }
1131
1132 return TRUE;
1133}
#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().