ReactOS 0.4.16-dev-2359-g4b75ec5
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{
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
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
unsigned char UCHAR
Definition: xmlstorage.h:181

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:221
VOID UefiVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: uefivid.c:215
_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 1585 of file uefidisk.c.

1586{
1587 ULONG ArcDriveIndex;
1588 EFI_BLOCK_IO* BlockIo;
1590
1591 if (DriveNumber < FIRST_BIOS_DISK)
1592 return 0;
1593
1594 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1595
1596 if (InternalUefiDisk == NULL)
1597 {
1598 ERR("InternalUefiDisk not initialized\n");
1599 return 0;
1600 }
1601
1602 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1603 {
1604 ERR("Invalid drive number: %d\n", DriveNumber);
1605 return 0;
1606 }
1607
1609 InternalUefiDisk[ArcDriveIndex].Handle,
1610 &BlockIoGuid,
1611 (VOID**)&BlockIo);
1612
1613 if (EFI_ERROR(Status) || BlockIo == NULL)
1614 {
1615 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1616 return 0;
1617 }
1618
1619 if (!BlockIo->Media->MediaPresent)
1620 {
1621 ERR("Media not present for drive %d\n", DriveNumber);
1622 return 0;
1623 }
1624
1625 return (ULONG)(BlockIo->Media->LastBlock + 1);
1626}
#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:117
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define FIRST_BIOS_DISK
Definition: uefidisk.c:17
static INTERNAL_UEFI_DISK * InternalUefiDisk
Definition: uefidisk.c:116

Referenced by MachInit().

◆ UefiDiskGetDriveGeometry()

BOOLEAN UefiDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  Geometry 
)

Definition at line 1535 of file uefidisk.c.

1536{
1537 ULONG ArcDriveIndex;
1538 EFI_BLOCK_IO* BlockIo;
1540
1541 if (DriveNumber < FIRST_BIOS_DISK)
1542 return FALSE;
1543
1544 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1545
1546 if (InternalUefiDisk == NULL)
1547 {
1548 ERR("InternalUefiDisk not initialized\n");
1549 return FALSE;
1550 }
1551
1552 if (ArcDriveIndex >= 32 || InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1553 {
1554 ERR("Invalid drive number: %d\n", DriveNumber);
1555 return FALSE;
1556 }
1557
1559 InternalUefiDisk[ArcDriveIndex].Handle,
1560 &BlockIoGuid,
1561 (VOID**)&BlockIo);
1562
1563 if (EFI_ERROR(Status) || BlockIo == NULL)
1564 {
1565 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1566 return FALSE;
1567 }
1568
1569 if (!BlockIo->Media->MediaPresent)
1570 {
1571 ERR("Media not present for drive %d\n", DriveNumber);
1572 return FALSE;
1573 }
1574
1575 Geometry->Cylinders = 1; /* Not relevant for UEFI Block I/O protocol */
1576 Geometry->Heads = 1; /* Not relevant for UEFI Block I/O protocol */
1577 Geometry->SectorsPerTrack = (ULONG)(BlockIo->Media->LastBlock + 1);
1578 Geometry->BytesPerSector = BlockIo->Media->BlockSize;
1579 Geometry->Sectors = BlockIo->Media->LastBlock + 1;
1580
1581 return TRUE;
1582}
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 1400 of file uefidisk.c.

1405{
1406 ULONG ArcDriveIndex;
1407 EFI_BLOCK_IO* BlockIo;
1409 ULONG BlockSize;
1410 ULONG IoAlign;
1411
1412 if (DriveNumber < FIRST_BIOS_DISK)
1413 return FALSE;
1414
1415 ArcDriveIndex = DriveNumber - FIRST_BIOS_DISK;
1416
1417 if (InternalUefiDisk == NULL)
1418 {
1419 ERR("InternalUefiDisk not initialized\n");
1420 return FALSE;
1421 }
1422
1423 if (ArcDriveIndex >= 32)
1424 {
1425 ERR("Drive index out of bounds: %d (ArcDriveIndex=%lu)\n", DriveNumber, ArcDriveIndex);
1426 return FALSE;
1427 }
1428
1429 /* Allow access during initialization: check if handle is set up */
1430 /* During initialization, Handle is set before GetHarddiskInformation is called */
1431 if (InternalUefiDisk[ArcDriveIndex].Handle == NULL)
1432 {
1433 ERR("Invalid drive number: %d (ArcDriveIndex=%lu, PcBiosDiskCount=%lu, Handle=NULL)\n",
1434 DriveNumber, ArcDriveIndex, PcBiosDiskCount);
1435 return FALSE;
1436 }
1437
1439 InternalUefiDisk[ArcDriveIndex].Handle,
1440 &BlockIoGuid,
1441 (VOID**)&BlockIo);
1442
1443 if (EFI_ERROR(Status) || BlockIo == NULL)
1444 {
1445 ERR("Failed to get Block I/O protocol for drive %d\n", DriveNumber);
1446 return FALSE;
1447 }
1448
1449 if (!BlockIo->Media->MediaPresent)
1450 {
1451 ERR("Media not present for drive %d\n", DriveNumber);
1452 return FALSE;
1453 }
1454
1455 BlockSize = BlockIo->Media->BlockSize;
1456 IoAlign = BlockIo->Media->IoAlign;
1457
1458 if (!UefiEnsureDiskReadBufferAligned(IoAlign))
1459 {
1460 ERR("Failed to align disk read buffer for drive %d\n", DriveNumber);
1461 return FALSE;
1462 }
1463
1464 if (!UefiIsAlignedPointer(Buffer, (IoAlign == 0) ? 1 : IoAlign))
1465 {
1466 ULONG TotalSectors = SectorCount;
1467 ULONG MaxSectors = DiskReadBufferSize / BlockSize;
1468 ULONGLONG CurrentSector = SectorNumber;
1469 PUCHAR OutPtr = (PUCHAR)Buffer;
1470
1471 if (MaxSectors == 0)
1472 {
1473 ERR("DiskReadBufferSize too small for block size %lu\n", BlockSize);
1474 return FALSE;
1475 }
1476
1477 while (TotalSectors)
1478 {
1479 ULONG ReadSectors = min(TotalSectors, MaxSectors);
1480 UINTN ReadSize = ReadSectors * BlockSize;
1481
1482 Status = BlockIo->ReadBlocks(
1483 BlockIo,
1484 BlockIo->Media->MediaId,
1485 CurrentSector,
1486 ReadSize,
1488
1489 if (EFI_ERROR(Status))
1490 {
1491 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1492 DriveNumber, CurrentSector, ReadSectors, (ULONG)Status);
1493 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1494 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1495 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1496 BlockIo->Media->LastBlock,
1497 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1498 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1499 return FALSE;
1500 }
1501
1502 RtlCopyMemory(OutPtr, DiskReadBuffer, ReadSize);
1503 OutPtr += ReadSize;
1504 CurrentSector += ReadSectors;
1505 TotalSectors -= ReadSectors;
1506 }
1507
1508 return TRUE;
1509 }
1510
1511 Status = BlockIo->ReadBlocks(
1512 BlockIo,
1513 BlockIo->Media->MediaId,
1514 SectorNumber,
1515 SectorCount * BlockSize,
1516 Buffer);
1517
1518 if (EFI_ERROR(Status))
1519 {
1520 ERR("ReadBlocks failed: DriveNumber=%d, SectorNumber=%llu, SectorCount=%lu, Status=0x%lx\n",
1521 DriveNumber, SectorNumber, SectorCount, (ULONG)Status);
1522 ERR("ReadBlocks details: BlockSize=%lu, IoAlign=%lu, Buffer=%p, DiskReadBuffer=%p, MediaId=0x%lx\n",
1523 BlockSize, IoAlign, Buffer, DiskReadBuffer, (ULONG)BlockIo->Media->MediaId);
1524 ERR("ReadBlocks media: LastBlock=%llu, LogicalPartition=%s, RemovableMedia=%s\n",
1525 BlockIo->Media->LastBlock,
1526 BlockIo->Media->LogicalPartition ? "TRUE" : "FALSE",
1527 BlockIo->Media->RemovableMedia ? "TRUE" : "FALSE");
1528 return FALSE;
1529 }
1530
1531 return TRUE;
1532}
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:138
UCHAR PcBiosDiskCount
Definition: uefidisk.c:103
SIZE_T DiskReadBufferSize
Definition: uefidisk.c:107
static BOOLEAN UefiIsAlignedPointer(IN PVOID Pointer, IN ULONG Alignment)
Definition: uefidisk.c:123

Referenced by MachInit().

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

1394{
1395 /* No floppy support in UEFI */
1396 return 0;
1397}

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 277 of file uefihw.c.

279{
281 ULONG BusNumber = 0;
282
283 TRACE("DetectHardware()\n");
284
285 /* Create the 'System' key */
286#if defined(_M_IX86) || defined(_M_AMD64)
287 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
288#elif defined(_M_IA64)
289 FldrCreateSystemKey(&SystemKey, "Intel Itanium processor family");
290#elif defined(_M_ARM) || defined(_M_ARM64)
291 FldrCreateSystemKey(&SystemKey, "ARM processor family");
292#else
293 #error Please define a system key for your architecture
294#endif
295
296 /* Detect buses */
297 DetectInternal(SystemKey, &BusNumber);
298 // TODO: DetectPciBios
299 DetectAcpiBios(SystemKey, &BusNumber);
300
301 TRACE("DetectHardware() Done\n");
302 return SystemKey;
303}
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:95
static VOID DetectInternal(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:234
_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 39 of file uefihw.c.

40{
44
45 /* Keep one timer event around and arm it each idle tick */
46 if (IdleTimerEvent == NULL)
47 {
48 Status = BootServices->CreateEvent(EVT_TIMER,
50 NULL,
51 NULL,
53 if (EFI_ERROR(Status))
54 {
55 StallExecutionProcessor(10000); /* 10 ms fallback */
56 return;
57 }
58 }
59
60 /* Set a 10ms (100,000 * 100ns) relative timer */
61 Status = BootServices->SetTimer(IdleTimerEvent, TimerRelative, 100000);
62 if (!EFI_ERROR(Status))
63 Status = BootServices->WaitForEvent(1, &IdleTimerEvent, &Index);
64 if (EFI_ERROR(Status))
65 StallExecutionProcessor(10000); /* 10 ms fallback */
66}
#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:33
static EFI_EVENT IdleTimerEvent
Definition: uefihw.c:28
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MachInit().

◆ UefiInitializeBootDevices()

BOOLEAN UefiInitializeBootDevices ( VOID  )

Definition at line 1304 of file uefidisk.c.

1305{
1306 EFI_BLOCK_IO* BlockIo;
1308 ULONG ArcDriveIndex;
1310 PULONG Buffer;
1311 ULONG Checksum = 0;
1313 ULONG i;
1314
1321 {
1322 ERR("Failed to allocate disk read buffer\n");
1323 return FALSE;
1324 }
1325
1327
1328 if (PcBiosDiskCount == 0)
1329 {
1330 ERR("No block devices found\n");
1331 return FALSE;
1332 }
1333
1334 if (!UefiSetBootpath())
1335 {
1336 ERR("Failed to set boot path\n");
1337 return FALSE;
1338 }
1339
1340 /* Handle CD-ROM boot device registration */
1341 ArcDriveIndex = PublicBootArcDisk;
1342 if (ArcDriveIndex >= PcBiosDiskCount || InternalUefiDisk == NULL)
1343 {
1344 ERR("Invalid boot arc disk index\n");
1345 return FALSE;
1346 }
1347
1349 InternalUefiDisk[ArcDriveIndex].Handle,
1350 &BlockIoGuid,
1351 (VOID**)&BlockIo);
1352
1353 if (EFI_ERROR(Status) || BlockIo == NULL)
1354 {
1355 ERR("Failed to get Block I/O protocol\n");
1356 return FALSE;
1357 }
1358
1359 if (BlockIo->Media->RemovableMedia == TRUE && BlockIo->Media->BlockSize == 2048)
1360 {
1361 /* Read the MBR from CD-ROM (sector 16) */
1363 {
1364 ERR("Reading MBR from CD-ROM failed\n");
1365 return FALSE;
1366 }
1367
1370
1371 Signature = Mbr->Signature;
1372 TRACE("CD-ROM Signature: %x\n", Signature);
1373
1374 /* Calculate the MBR checksum */
1375 for (i = 0; i < 2048 / sizeof(ULONG); i++)
1376 {
1377 Checksum += Buffer[i];
1378 }
1379 Checksum = ~Checksum + 1;
1380 TRACE("CD-ROM Checksum: %x\n", Checksum);
1381
1382 /* Fill out the ARC disk block */
1384
1386 TRACE("Registered CD-ROM boot device: 0x%02X\n", (int)FrldrBootDrive);
1387 }
1388
1389 return TRUE;
1390}
#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:115
PVOID Buffer
Definition: uefidisk.c:108
static BOOLEAN DiskReadBufferFromPool
Definition: uefidisk.c:101
static ULONG DiskReadBufferAlignment
Definition: uefidisk.c:100
static const DEVVTBL UefiDiskVtbl
Definition: uefidisk.c:846
static VOID UefiSetupBlockDevices(VOID)
Definition: uefidisk.c:957
static PVOID DiskReadBufferRaw
Definition: uefidisk.c:99
UCHAR FrldrBootDrive
Definition: uefidisk.c:105
static BOOLEAN UefiSetBootpath(VOID)
Definition: uefidisk.c:1213

Referenced by MachInit().

◆ UefiInitializeFileSystemSupport()

VOID UefiInitializeFileSystemSupport ( _In_ EFI_HANDLE  ImageHandle,
_In_ EFI_SYSTEM_TABLE SystemTable 
)

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 187 of file uefivid.c.

188{
190
191 /* First, try GOP */
193 if (Status == EFI_SUCCESS)
194 return Status;
195
196 /* Try Apple Graphics Info if that fails */
197 TRACE("Failed to detect GOP, trying Apple Graphics Info\n");
199 if (Status == EFI_SUCCESS)
200 return Status;
201
202 /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
203 ERR("Cannot find framebuffer!\n");
204 return Status;
205}
static EFI_STATUS UefiInitializeAppleGraphics(VOID)
Definition: uefivid.c:135
static EFI_STATUS UefiInitializeGop(VOID)
Definition: uefivid.c:58

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 209 of file uefivid.c.

210{
211 FbConsClearScreen(Attr);
212}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413

Referenced by MachInit().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 240 of file uefivid.c.

241{
243}
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 234 of file uefivid.c.

235{
236 return FbConsGetBufferSize();
237}
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 221 of file uefivid.c.

222{
224}
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 271 of file uefivid.c.

273{
274 /* Not supported */
275}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 252 of file uefivid.c.

253{
254 /* We don't have a cursor yet */
255}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 258 of file uefivid.c.

259{
260 return 0;
261}

Referenced by MachInit().

◆ UefiVideoPutChar()

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

Definition at line 215 of file uefivid.c.

216{
217 FbConsPutChar(Ch, Attr, X, Y);
218}
#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 227 of file uefivid.c.

228{
229 /* We only have one mode, semi-text */
230 return VideoTextMode;
231}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

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

Definition at line 264 of file uefivid.c.

266{
267 /* Not supported */
268}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 246 of file uefivid.c.

247{
248 /* We don't have a cursor yet */
249}

Referenced by MachInit().

◆ UefiVideoSync()

VOID UefiVideoSync ( VOID  )

Definition at line 26 of file stubs.c.

27{
28
29}

Referenced by MachInit().