ReactOS 0.4.16-dev-2636-g02c744d
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 1302 of file uefidisk.c.

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

Referenced by MachInit().

◆ UefiDiskGetDriveGeometry()

BOOLEAN UefiDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  Geometry 
)

Definition at line 1252 of file uefidisk.c.

1253{
1254 ULONG ArcDriveIndex;
1255 EFI_BLOCK_IO* BlockIo;
1257
1258 if (DriveNumber < FIRST_BIOS_DISK)
1259 return FALSE;
1260
1261 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1262
1263 if (InternalUefiDisk == NULL)
1264 {
1265 ERR("InternalUefiDisk not initialized\n");
1266 return FALSE;
1267 }
1268
1269 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1270 {
1271 ERR("Invalid drive number: %d\n", DriveNumber);
1272 return FALSE;
1273 }
1274
1276 InternalUefiDisk[ArcDriveIndex].Handle,
1277 &BlockIoGuid,
1278 (VOID**)&BlockIo);
1279
1280 if (EFI_ERROR(Status) || BlockIo == NULL)
1281 {
1282 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1283 return FALSE;
1284 }
1285
1286 if (!BlockIo->Media->MediaPresent)
1287 {
1288 ERR("Media not present for drive %d\n", DriveNumber);
1289 return FALSE;
1290 }
1291
1292 Geometry->Cylinders = 1; /* Not relevant for UEFI Block I/O protocol */
1293 Geometry->Heads = 1; /* Not relevant for UEFI Block I/O protocol */
1294 Geometry->SectorsPerTrack = (ULONG)(BlockIo->Media->LastBlock + 1);
1295 Geometry->BytesPerSector = BlockIo->Media->BlockSize;
1296 Geometry->Sectors = BlockIo->Media->LastBlock + 1;
1297
1298 return TRUE;
1299}
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 1117 of file uefidisk.c.

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

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

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

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

1042{
1043 EFI_BLOCK_IO* BlockIo;
1045 ULONG ArcDriveIndex;
1046
1053 {
1054 ERR("Failed to allocate disk read buffer\n");
1055 return FALSE;
1056 }
1057
1059
1060 if (PcBiosDiskCount == 0)
1061 {
1062 ERR("No block devices found\n");
1063 return FALSE;
1064 }
1065
1066 if (!UefiSetBootpath())
1067 {
1068 ERR("Failed to set boot path\n");
1069 return FALSE;
1070 }
1071
1072 /* Handle CD-ROM boot device registration */
1073 ArcDriveIndex = PublicBootArcDisk;
1074 if (ArcDriveIndex >= PcBiosDiskCount || InternalUefiDisk == NULL)
1075 {
1076 ERR("Invalid boot arc disk index\n");
1077 return FALSE;
1078 }
1079
1081 InternalUefiDisk[ArcDriveIndex].Handle,
1082 &BlockIoGuid,
1083 (VOID**)&BlockIo);
1084
1085 if (EFI_ERROR(Status) || BlockIo == NULL)
1086 {
1087 ERR("Failed to get Block I/O protocol\n");
1088 return FALSE;
1089 }
1090
1091 if (BlockIo->Media->RemovableMedia == TRUE && BlockIo->Media->BlockSize == 2048)
1092 {
1094
1099
1100 if (Status == ESUCCESS)
1101 TRACE("Registered CD-ROM boot device: 0x%02X\n", FrldrBootDrive);
1102 else
1103 ERR("CD-ROM boot device 0x%02X failed\n", FrldrBootDrive);
1104 }
1105
1106 return TRUE;
1107}
#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:64
static BOOLEAN DiskReadBufferFromPool
Definition: uefidisk.c:53
static ULONG DiskReadBufferAlignment
Definition: uefidisk.c:52
static const DEVVTBL UefiDiskVtbl
Definition: uefidisk.c:635
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:707
static PVOID DiskReadBufferRaw
Definition: uefidisk.c:51
UCHAR FrldrBootDrive
Definition: uefidisk.c:57
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:963

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().