ReactOS 0.4.16-dev-2232-gc2aaa52
machuefi.h File Reference
#include <machine.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)
 
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{
130 UCHAR KeyOutput = 0;
131
132 /* If an extended key press was detected the last time we were called
133 * then return the scan code of that key. */
134 if (ExtendedKey)
135 {
137 return ExtendedScanCode;
138 }
139
140 if (Key.UnicodeChar != 0)
141 {
142 KeyOutput = Key.UnicodeChar;
143 }
144 else
145 {
148 KeyOutput = KEY_EXTENDED;
149 }
150
151 /* UEFI will stack input requests, we have to clear it */
152 Key.UnicodeChar = 0;
153 Key.ScanCode = 0;
154 return KeyOutput;
155}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KEY_EXTENDED
Definition: keycodes.h:38
static UCHAR ConvertToBiosExtValue(UCHAR KeyIn)
Definition: ueficon.c:68
static BOOLEAN ExtendedKey
Definition: ueficon.c:21
static char ExtendedScanCode
Definition: ueficon.c:22
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by MachInit().

◆ UefiConsKbHit()

BOOLEAN UefiConsKbHit ( VOID  )

Definition at line 122 of file ueficon.c.

123{
125}
#define EFI_NOT_READY
Definition: UefiBaseType.h:126
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:1932
EFI_INPUT_READ_KEY ReadKeyStroke
Definition: SimpleTextIn.h:125
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16

Referenced by MachInit().

◆ UefiConsPutChar()

VOID UefiConsPutChar ( int  Ch)

Definition at line 27 of file ueficon.c.

28{
30 BOOLEAN NeedScroll;
31
33
34 NeedScroll = (CurrentCursorY >= Height);
35 if (NeedScroll)
36 {
39 }
40 if (c == '\r')
41 {
43 }
44 else if (c == '\n')
45 {
47 if (!NeedScroll)
49 }
50 else if (c == '\t')
51 {
52 CurrentCursorX = (CurrentCursorX + 8) & ~7;
53 }
54 else
55 {
58 }
59 if (CurrentCursorX >= Width)
60 {
63 }
64}
unsigned char BOOLEAN
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:144
VOID UefiVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: uefivid.c:138
_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 1563 of file uefidisk.c.

1564{
1565 ULONG ArcDriveIndex;
1566 EFI_BLOCK_IO* BlockIo;
1568
1569 if (DriveNumber < FIRST_BIOS_DISK)
1570 return 0;
1571
1572 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1573
1574 if (InternalUefiDisk == NULL)
1575 {
1576 ERR("InternalUefiDisk not initialized\n");
1577 return 0;
1578 }
1579
1580 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1581 {
1582 ERR("Invalid drive number: %d\n", DriveNumber);
1583 return 0;
1584 }
1585
1587 InternalUefiDisk[ArcDriveIndex].Handle,
1588 &BlockIoGuid,
1589 (VOID**)&BlockIo);
1590
1591 if (EFI_ERROR(Status) || BlockIo == NULL)
1592 {
1593 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1594 return 0;
1595 }
1596
1597 if (!BlockIo->Media->MediaPresent)
1598 {
1599 ERR("Media not present for drive %d\n", DriveNumber);
1600 return 0;
1601 }
1602
1603 return (ULONG)(BlockIo->Media->LastBlock + 1);
1604}
#define EFI_ERROR(A)
Definition: UefiBaseType.h:165
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1832
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959
static EFI_GUID BlockIoGuid
Definition: uefidisk.c:116
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define FIRST_BIOS_DISK
Definition: uefidisk.c:17
static INTERNAL_UEFI_DISK * InternalUefiDisk
Definition: uefidisk.c:115

Referenced by MachInit().

◆ UefiDiskGetDriveGeometry()

BOOLEAN UefiDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  Geometry 
)

Definition at line 1513 of file uefidisk.c.

1514{
1515 ULONG ArcDriveIndex;
1516 EFI_BLOCK_IO* BlockIo;
1518
1519 if (DriveNumber < FIRST_BIOS_DISK)
1520 return FALSE;
1521
1522 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1523
1524 if (InternalUefiDisk == NULL)
1525 {
1526 ERR("InternalUefiDisk not initialized\n");
1527 return FALSE;
1528 }
1529
1530 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1531 {
1532 ERR("Invalid drive number: %d\n", DriveNumber);
1533 return FALSE;
1534 }
1535
1537 InternalUefiDisk[ArcDriveIndex].Handle,
1538 &BlockIoGuid,
1539 (VOID**)&BlockIo);
1540
1541 if (EFI_ERROR(Status) || BlockIo == NULL)
1542 {
1543 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1544 return FALSE;
1545 }
1546
1547 if (!BlockIo->Media->MediaPresent)
1548 {
1549 ERR("Media not present for drive %d\n", DriveNumber);
1550 return FALSE;
1551 }
1552
1553 Geometry->Cylinders = 1; /* Not relevant for UEFI Block I/O protocol */
1554 Geometry->Heads = 1; /* Not relevant for UEFI Block I/O protocol */
1555 Geometry->SectorsPerTrack = (ULONG)(BlockIo->Media->LastBlock + 1);
1556 Geometry->BytesPerSector = BlockIo->Media->BlockSize;
1557 Geometry->Sectors = BlockIo->Media->LastBlock + 1;
1558
1559 return TRUE;
1560}
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:30
ULONG Cylinders
Number of cylinders on the disk.
Definition: disk.h:27
ULONGLONG Sectors
Total number of disk sectors/LBA blocks.
Definition: disk.h:31
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:29
ULONG Heads
Number of heads on the disk.
Definition: disk.h:28

Referenced by MachInit().

◆ UefiDiskReadLogicalSectors()

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

Definition at line 1378 of file uefidisk.c.

1383{
1384 ULONG ArcDriveIndex;
1385 EFI_BLOCK_IO* BlockIo;
1387 ULONG BlockSize;
1388 ULONG IoAlign;
1389
1390 if (DriveNumber < FIRST_BIOS_DISK)
1391 return FALSE;
1392
1393 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1394
1395 if (InternalUefiDisk == NULL)
1396 {
1397 ERR("InternalUefiDisk not initialized\n");
1398 return FALSE;
1399 }
1400
1401 if (ArcDriveIndex >= 32)
1402 {
1403 ERR("Drive index out of bounds: %d (ArcDriveIndex=%lu)\n", DriveNumber, ArcDriveIndex);
1404 return FALSE;
1405 }
1406
1407 /* Allow access during initialization: check if handle is set up */
1408 /* During initialization, Handle is set before GetHarddiskInformation is called */
1409 if (InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1410 {
1411 ERR("Invalid drive number: %d (ArcDriveIndex=%lu, PcBiosDiskCount=%lu, Handle=NULL)\n",
1412 DriveNumber, ArcDriveIndex, PcBiosDiskCount);
1413 return FALSE;
1414 }
1415
1417 InternalUefiDisk[ArcDriveIndex].Handle,
1418 &BlockIoGuid,
1419 (VOID**)&BlockIo);
1420
1421 if (EFI_ERROR(Status) || BlockIo == NULL)
1422 {
1423 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1424 return FALSE;
1425 }
1426
1427 if (!BlockIo->Media->MediaPresent)
1428 {
1429 ERR("Media not present for drive %d\n", DriveNumber);
1430 return FALSE;
1431 }
1432
1433 BlockSize = BlockIo->Media->BlockSize;
1434 IoAlign = BlockIo->Media->IoAlign;
1435
1436 if (!UefiEnsureDiskReadBufferAligned(IoAlign))
1437 {
1438 ERR("Failed to align disk read buffer for drive %d\n", DriveNumber);
1439 return FALSE;
1440 }
1441
1442 if (!UefiIsAlignedPointer(Buffer, (IoAlign == 0) ? 1 : IoAlign))
1443 {
1444 ULONG TotalSectors = SectorCount;
1445 ULONG MaxSectors = DiskReadBufferSize / BlockSize;
1446 ULONGLONG CurrentSector = SectorNumber;
1447 PUCHAR OutPtr = (PUCHAR)Buffer;
1448
1449 if (MaxSectors == 0)
1450 {
1451 ERR("DiskReadBufferSize too small for block size %lu\n", BlockSize);
1452 return FALSE;
1453 }
1454
1455 while (TotalSectors)
1456 {
1457 ULONG ReadSectors = min(TotalSectors, MaxSectors);
1458 UINTN ReadSize = ReadSectors * BlockSize;
1459
1460 Status = BlockIo->ReadBlocks(
1461 BlockIo,
1462 BlockIo->Media->MediaId,
1463 CurrentSector,
1464 ReadSize,
1466
1467 if (EFI_ERROR(Status))
1468 {
1469 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1470 DriveNumber, CurrentSector, ReadSectors, (ULONG)Status);
1471 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1472 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1473 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1474 BlockIo->Media->LastBlock,
1475 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1476 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1477 return FALSE;
1478 }
1479
1480 RtlCopyMemory(OutPtr, DiskReadBuffer, ReadSize);
1481 OutPtr += ReadSize;
1482 CurrentSector += ReadSectors;
1483 TotalSectors -= ReadSectors;
1484 }
1485
1486 return TRUE;
1487 }
1488
1489 Status = BlockIo->ReadBlocks(
1490 BlockIo,
1491 BlockIo->Media->MediaId,
1492 SectorNumber,
1493 SectorCount * BlockSize,
1494 Buffer);
1495
1496 if (EFI_ERROR(Status))
1497 {
1498 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1499 DriveNumber, SectorNumber, SectorCount, (ULONG)Status);
1500 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1501 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1502 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1503 BlockIo->Media->LastBlock,
1504 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1505 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1506 return FALSE;
1507 }
1508
1509 return TRUE;
1510}
UINT32 UINTN
Definition: bufpool.h:45
#define min(a, b)
Definition: monoChain.cc:55
ULONG SectorCount
Definition: part_xbox.c:31
#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:98
static BOOLEAN UefiEnsureDiskReadBufferAligned(IN ULONG Alignment)
Definition: uefidisk.c:137
UCHAR PcBiosDiskCount
Definition: uefidisk.c:102
SIZE_T DiskReadBufferSize
Definition: uefidisk.c:106
static BOOLEAN UefiIsAlignedPointer(IN PVOID Pointer, IN ULONG Alignment)
Definition: uefidisk.c:122

Referenced by MachInit().

◆ UefiGetExtendedBIOSData()

VOID UefiGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 38 of file stubs.c.

40{
41
42}

Referenced by MachInit().

◆ UefiGetFloppyCount()

UCHAR UefiGetFloppyCount ( VOID  )

Definition at line 1371 of file uefidisk.c.

1372{
1373 /* No floppy support in UEFI */
1374 return 0;
1375}

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}
#define EFI_SUCCESS
Definition: UefiBaseType.h:120
__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 245 of file uefihw.c.

247{
249 ULONG BusNumber = 0;
250
251 TRACE("DetectHardware()\n");
252
253 /* Create the 'System' key */
254#if defined(_M_IX86) || defined(_M_AMD64)
255 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
256#elif defined(_M_IA64)
257 FldrCreateSystemKey(&SystemKey, "Intel Itanium processor family");
258#elif defined(_M_ARM) || defined(_M_ARM64)
259 FldrCreateSystemKey(&SystemKey, "ARM processor family");
260#else
261 #error Please define a system key for your architecture
262#endif
263
264 /* Detect buses */
265 DetectInternal(SystemKey, &BusNumber);
266 // TODO: DetectPciBios
267 DetectAcpiBios(SystemKey, &BusNumber);
268
269 TRACE("DetectHardware() Done\n");
270 return SystemKey;
271}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
#define TRACE(s)
Definition: solgame.cpp:4
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:60
static VOID DetectInternal(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:202
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

Referenced by MachInit().

◆ UefiHwIdle()

VOID UefiHwIdle ( VOID  )

Definition at line 51 of file stubs.c.

52{
53
54}

Referenced by MachInit().

◆ UefiInitializeBootDevices()

BOOLEAN UefiInitializeBootDevices ( VOID  )

Definition at line 1282 of file uefidisk.c.

1283{
1284 EFI_BLOCK_IO* BlockIo;
1286 ULONG ArcDriveIndex;
1288 PULONG Buffer;
1289 ULONG Checksum = 0;
1291 ULONG i;
1292
1299 {
1300 ERR("Failed to allocate disk read buffer\n");
1301 return FALSE;
1302 }
1303
1305
1306 if (PcBiosDiskCount == 0)
1307 {
1308 ERR("No block devices found\n");
1309 return FALSE;
1310 }
1311
1312 if (!UefiSetBootpath())
1313 {
1314 ERR("Failed to set boot path\n");
1315 return FALSE;
1316 }
1317
1318 /* Handle CD-ROM boot device registration */
1319 ArcDriveIndex = PublicBootArcDisk;
1320 if (ArcDriveIndex >= PcBiosDiskCount || InternalUefiDisk == NULL)
1321 {
1322 ERR("Invalid boot arc disk index\n");
1323 return FALSE;
1324 }
1325
1327 InternalUefiDisk[ArcDriveIndex].Handle,
1328 &BlockIoGuid,
1329 (VOID**)&BlockIo);
1330
1331 if (EFI_ERROR(Status) || BlockIo == NULL)
1332 {
1333 ERR("Failed to get Block I/O protocol\n");
1334 return FALSE;
1335 }
1336
1337 if (BlockIo->Media->RemovableMedia == TRUE && BlockIo->Media->BlockSize == 2048)
1338 {
1339 /* Read the MBR from CD-ROM (sector 16) */
1341 {
1342 ERR("Reading MBR from CD-ROM failed\n");
1343 return FALSE;
1344 }
1345
1348
1349 Signature = Mbr->Signature;
1350 TRACE("CD-ROM Signature: %x\n", Signature);
1351
1352 /* Calculate the MBR checksum */
1353 for (i = 0; i < 2048 / sizeof(ULONG); i++)
1354 {
1355 Checksum += Buffer[i];
1356 }
1357 Checksum = ~Checksum + 1;
1358 TRACE("CD-ROM Checksum: %x\n", Checksum);
1359
1360 /* Fill out the ARC disk block */
1362
1364 TRACE("Registered CD-ROM boot device: 0x%02X\n", (int)FrldrBootDrive);
1365 }
1366
1367 return TRUE;
1368}
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:189
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
Definition: archwsup.c:77
struct _MASTER_BOOT_RECORD * PMASTER_BOOT_RECORD
VOID FsRegisterDevice(_In_ PCSTR DeviceName, _In_ const DEVVTBL *FuncTable)
Definition: fs.c:673
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)
Definition: machine.h:120
static const WCHAR Signature[]
Definition: parser.c:141
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG Signature
Definition: disk.h:60
uint32_t * PULONG
Definition: typedefs.h:59
static ULONG PublicBootArcDisk
Definition: uefidisk.c:114
PVOID Buffer
Definition: uefidisk.c:107
static BOOLEAN DiskReadBufferFromPool
Definition: uefidisk.c:101
static ULONG DiskReadBufferAlignment
Definition: uefidisk.c:100
static const DEVVTBL UefiDiskVtbl
Definition: uefidisk.c:824
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:935
static PVOID DiskReadBufferRaw
Definition: uefidisk.c:99
UCHAR FrldrBootDrive
Definition: uefidisk.c:104
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:1191

Referenced by MachInit().

◆ UefiInitializeFileSystemSupport()

VOID UefiInitializeFileSystemSupport ( _In_ EFI_HANDLE  ImageHandle,
_In_ EFI_SYSTEM_TABLE SystemTable 
)

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 56 of file uefivid.c.

57{
60
62 EFI_PIXEL_BITMASK* pPixelBitmask;
63 ULONG BitsPerPixel;
64
66 if (Status != EFI_SUCCESS)
67 {
68 TRACE("Failed to find GOP with status %d\n", Status);
69 return Status;
70 }
71
72 /* We don't need high resolutions for freeldr */
73 gop->SetMode(gop, LOWEST_SUPPORTED_RES);
74
75 /* Physical format of the pixel */
76 PixelFormat = gop->Mode->Info->PixelFormat;
77 switch (PixelFormat)
78 {
81 {
82 pPixelBitmask = &EfiPixelMasks[PixelFormat];
84 break;
85 }
86
87 case PixelBitMask:
88 {
89 /*
90 * When the GOP pixel format is given by PixelBitMask, the pixel
91 * element size _may be_ different from 4 bytes.
92 * See UEFI Spec Rev.2.10 Section 12.9 "Graphics Output Protocol":
93 * example code "GetPixelElementSize()" function.
94 */
95 pPixelBitmask = &gop->Mode->Info->PixelInformation;
96 BitsPerPixel =
97 PixelBitmasksToBpp(pPixelBitmask->RedMask,
98 pPixelBitmask->GreenMask,
99 pPixelBitmask->BlueMask,
100 pPixelBitmask->ReservedMask);
101 break;
102 }
103
104 case PixelBltOnly:
105 default:
106 {
107 ERR("Unsupported UEFI GOP format %lu\n", PixelFormat);
108 pPixelBitmask = NULL;
109 BitsPerPixel = 0;
110 break;
111 }
112 }
113
114 VramAddress = (ULONG_PTR)gop->Mode->FrameBufferBase;
115 VramSize = gop->Mode->FrameBufferSize;
118 VramSize,
119 gop->Mode->Info->HorizontalResolution,
120 gop->Mode->Info->VerticalResolution,
121 gop->Mode->Info->PixelsPerScanLine,
122 BitsPerPixel,
123 (PPIXEL_BITMASK)pPixelBitmask))
124 {
125 ERR("Couldn't initialize video framebuffer\n");
127 }
128 return Status;
129}
EFI_GRAPHICS_PIXEL_FORMAT
@ PixelBitMask
@ PixelRedGreenBlueReserved8BitPerColor
@ PixelBlueGreenRedReserved8BitPerColor
@ PixelBltOnly
#define EFI_UNSUPPORTED
Definition: UefiBaseType.h:123
#define ULONG_PTR
Definition: config.h:101
INT PixelFormat
if(dx< 0)
Definition: linetemp.h:194
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:680
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1873
Physical format of an RGB pixel, specified with per-component bit-masks. A bit being set defines thos...
Definition: vidfb.h:22
EFI_GUID EfiGraphicsOutputProtocol
Definition: uefivid.c:18
ULONG_PTR VramAddress
Definition: uefivid.c:20
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define LOWEST_SUPPORTED_RES
Definition: uefivid.c:24
PCM_FRAMEBUF_DEVICE_DATA FrameBufferData
Definition: uefivid.c:22
ULONG VramSize
Definition: uefivid.c:21
BOOLEAN VidFbInitializeVideo(_Out_opt_ PCM_FRAMEBUF_DEVICE_DATA *pFbData, _In_ ULONG_PTR BaseAddress, _In_ ULONG BufferSize, _In_ UINT32 ScreenWidth, _In_ UINT32 ScreenHeight, _In_ UINT32 PixelsPerScanLine, _In_ UINT32 BitsPerPixel, _In_opt_ PPIXEL_BITMASK PixelMasks)
Initializes internal framebuffer information based on the given parameters.
Definition: vidfb.c:99
FORCEINLINE ULONG PixelBitmasksToBpp(_In_ ULONG RedMask, _In_ ULONG GreenMask, _In_ ULONG BlueMask, _In_ ULONG ReservedMask)
Calculates the number of bits per pixel ("PixelDepth") for the given pixel format,...
Definition: vidfb.h:41

Referenced by MachInit().

◆ UefiMemGetMemoryMap()

PFREELDR_MEMORY_DESCRIPTOR UefiMemGetMemoryMap ( ULONG MemoryMapSize)

Definition at line 145 of file uefimem.c.

146{
147 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
148 UINT32 DescriptorVersion;
149 SIZE_T FreeldrMemMapSize;
152 UINTN MapSize;
153 UINTN MapKey;
155
157 PFREELDR_MEMORY_DESCRIPTOR FreeldrMem = NULL;
158 EFI_MEMORY_DESCRIPTOR* MapEntry = NULL;
159 UINT32 EntryCount = 0;
161
164 (VOID**)&LoadedImage);
165 if (Status != EFI_SUCCESS)
166 {
167 TRACE("Failed to find LoadedImageHandle with status: %d\n", Status);
168 UiMessageBoxCritical("Unable to initialize memory manager.");
169 return NULL;
170 }
171 OsLoaderBase = LoadedImage->ImageBase;
172 OsLoaderSize = LoadedImage->ImageSize;
173 PublicBootHandle = LoadedImage->DeviceHandle;
175
176 TRACE("UefiMemGetMemoryMap: Gather memory map\n");
177 PUEFI_LoadMemoryMap(&MapKey,
178 &MapSize,
180 &DescriptorVersion);
181
182 TRACE("Value of MapKey: %d\n", MapKey);
183 TRACE("Value of MapSize: %d\n", MapSize);
184 TRACE("Value of DescriptorSize: %d\n", DescriptorSize);
185 TRACE("Value of DescriptorVersion: %d\n", DescriptorVersion);
186
187 EntryCount = (MapSize / DescriptorSize);
188
189 FreeldrMemMapSize = (sizeof(FREELDR_MEMORY_DESCRIPTOR) * EntryCount);
191 FreeldrMemMapSize,
192 (void**)&FreeldrMem);
193 if (Status != EFI_SUCCESS)
194 {
195 TRACE("Failed to allocate pool with status %d\n", Status);
196 UiMessageBoxCritical("Unable to initialize memory manager.");
197 return NULL;
198 }
199
200 RtlZeroMemory(FreeldrMem, FreeldrMemMapSize);
201 MapEntry = EfiMemoryMap;
202 for (Index = 0; Index < EntryCount; ++Index)
203 {
204 TYPE_OF_MEMORY MemoryType = UefiConvertToFreeldrDesc(MapEntry->Type);
205 if (MemoryType == LoaderFree)
206 {
209 MapEntry->NumberOfPages,
210 &MapEntry->PhysicalStart);
211 if (Status != EFI_SUCCESS)
212 {
213 /* We failed to reserve the page, so change its type */
214 MemoryType = LoaderFirmwareTemporary;
215 }
216 }
217
218 /* Sometimes our loader can be loaded into higher memory than we ever allocate */
219 if (MemoryType == LoaderLoadedProgram)
220 {
221 if (((MapEntry->PhysicalStart + (MapEntry->NumberOfPages * PAGE_SIZE)) >> EFI_PAGE_SHIFT) > LoaderPagesSpanned)
222 {
223 /* This value needs to be adjusted if this occurs */
224 LoaderPagesSpanned = ((MapEntry->PhysicalStart + (MapEntry->NumberOfPages * PAGE_SIZE)) >> EFI_PAGE_SHIFT);
225 }
226 }
227
228 /* We really don't want to touch these reserved spots at all */
229 if (MemoryType != LoaderReserve)
230 {
231 UefiSetMemory(FreeldrMem,
232 MapEntry->PhysicalStart,
233 MapEntry->NumberOfPages,
234 MemoryType);
235 }
236
237 MapEntry = NEXT_MEMORY_DESCRIPTOR(MapEntry, DescriptorSize);
238 }
239
240 /* Windows expects the first page to be reserved, otherwise it asserts.
241 * However it can be just a free page on some UEFI systems. */
242 UefiSetMemory(FreeldrMem, 0x000000, 1, LoaderFirmwarePermanent);
243 *MemoryMapSize = FreeldrDescCount;
244 return FreeldrMem;
245}
#define EFI_LOADED_IMAGE_PROTOCOL_GUID
Definition: LoadedImage.h:21
unsigned int UINT32
#define EFI_PAGE_SHIFT
Definition: UefiBaseType.h:191
@ EfiLoaderData
@ AllocateAddress
Definition: UefiSpec.h:45
EFI_GUID EfiLoadedImageProtocol
Definition: firmware.c:30
struct _FREELDR_MEMORY_DESCRIPTOR FREELDR_MEMORY_DESCRIPTOR
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
#define PAGE_SIZE
Definition: env_spec_w32.h:49
@ LoaderReserve
Definition: arc.h:317
@ LoaderFree
Definition: arc.h:295
@ LoaderFirmwareTemporary
Definition: arc.h:298
@ LoaderLoadedProgram
Definition: arc.h:297
@ 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 FreeldrDescCount
Definition: uefimem.c:35
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:34
static VOID PUEFI_LoadMemoryMap(_Out_ UINTN *LocMapKey, _Out_ UINTN *LocMapSize, _Out_ UINTN *LocDescriptorSize, _Out_ UINT32 *LocDescriptorVersion)
Definition: uefimem.c:48
EFI_HANDLE PublicBootHandle
Definition: uefimem.c:38
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static TYPE_OF_MEMORY UefiConvertToFreeldrDesc(EFI_MEMORY_TYPE EfiMemoryType)
Definition: uefimem.c:108
PVOID OsLoaderBase
Definition: uefimem.c:36
static VOID UefiSetMemory(_Inout_ PFREELDR_MEMORY_DESCRIPTOR MemoryMap, _In_ ULONG_PTR BaseAddress, _In_ PFN_COUNT SizeInPages, _In_ TYPE_OF_MEMORY MemoryType)
Definition: uefimem.c:87
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
SIZE_T OsLoaderSize
Definition: uefimem.c:37
ULONG LoaderPagesSpanned
Definition: mm.c:29
#define NEXT_MEMORY_DESCRIPTOR(Descriptor, DescriptorSize)
Definition: uefimem.c:15
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MachInit().

◆ UefiPcBeep()

VOID UefiPcBeep ( VOID  )

Definition at line 45 of file stubs.c.

46{
47 /* Not possible on UEFI, for now */
48}

Referenced by MachInit().

◆ UefiPrepareForReactOS()

VOID UefiPrepareForReactOS ( VOID  )

Definition at line 283 of file uefimem.c.

284{
285 _exituefi();
286}
void _exituefi(VOID)

Referenced by MachInit().

◆ UefiVideoClearScreen()

VOID UefiVideoClearScreen ( UCHAR  Attr)

Definition at line 132 of file uefivid.c.

133{
134 FbConsClearScreen(Attr);
135}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413

Referenced by MachInit().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 163 of file uefivid.c.

164{
166}
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 157 of file uefivid.c.

158{
159 return FbConsGetBufferSize();
160}
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 144 of file uefivid.c.

145{
147}
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 26 of file stubs.c.

27{
28
29}

Referenced by MachInit().

◆ UefiVideoGetPaletteColor()

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

Definition at line 194 of file uefivid.c.

196{
197 /* Not supported */
198}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 175 of file uefivid.c.

176{
177 /* We don't have a cursor yet */
178}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 181 of file uefivid.c.

182{
183 return 0;
184}

Referenced by MachInit().

◆ UefiVideoPutChar()

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

Definition at line 138 of file uefivid.c.

139{
140 FbConsPutChar(Ch, Attr, X, Y);
141}
#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 150 of file uefivid.c.

151{
152 /* We only have one mode, semi-text */
153 return VideoTextMode;
154}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

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

Definition at line 187 of file uefivid.c.

189{
190 /* Not supported */
191}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 169 of file uefivid.c.

170{
171 /* We don't have a cursor yet */
172}

Referenced by MachInit().

◆ UefiVideoSync()

VOID UefiVideoSync ( VOID  )

Definition at line 32 of file stubs.c.

33{
34
35}

Referenced by MachInit().