ReactOS 0.4.16-dev-2617-g01a0906
machpc.h File Reference
#include "mm.h"
Include dependency graph for machpc.h:

Go to the source code of this file.

Functions

VOID PcBeep (VOID)
 
VOID PcConsPutChar (int Ch)
 
BOOLEAN PcConsKbHit (VOID)
 
int PcConsGetCh (VOID)
 
VOID PcVideoInit (VOID)
 
VOID PcVideoClearScreen (UCHAR Attr)
 
VIDEODISPLAYMODE PcVideoSetDisplayMode (PCSTR DisplayMode, BOOLEAN Init)
 
VOID PcVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
ULONG PcVideoGetBufferSize (VOID)
 
VOID PcVideoGetFontsFromFirmware (PULONG RomFontPointers)
 
VOID PcVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID PcVideoHideShowTextCursor (BOOLEAN Show)
 
VOID PcVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
VOID PcVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
BOOLEAN PcVideoIsPaletteFixed (VOID)
 
VOID PcVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID PcVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 
VOID PcVideoSync (VOID)
 
VOID PcVideoPrepareForReactOS (VOID)
 
VOID PcPrepareForReactOS (VOID)
 
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap (ULONG *MemoryMapSize)
 
BOOLEAN PcFindPciBios (PPCI_REGISTRY_INFO BusData)
 
CONFIGURATION_TYPE DiskGetConfigType (_In_ UCHAR DriveNumber)
 
LONG DiskReportError (BOOLEAN bShowError)
 
BOOLEAN DiskResetController (UCHAR DriveNumber)
 
BOOLEAN PcDiskReadLogicalSectors (UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
 
BOOLEAN PcDiskGetDriveGeometry (UCHAR DriveNumber, PGEOMETRY DriveGeometry)
 
ULONG PcDiskGetCacheableBlockCount (UCHAR DriveNumber)
 
TIMEINFOPcGetTime (VOID)
 
BOOLEAN PcInitializeBootDevices (VOID)
 
PCONFIGURATION_COMPONENT_DATA PcHwDetect (_In_opt_ PCSTR Options)
 
VOID PcHwIdle (VOID)
 

Variables

UCHAR FrldrBootDrive
 
ULONG FrldrBootPartition
 
BIOS_MEMORY_MAP PcBiosMemoryMap []
 
ULONG PcBiosMapCount
 

Function Documentation

◆ DiskGetConfigType()

CONFIGURATION_TYPE DiskGetConfigType ( _In_ UCHAR  DriveNumber)

Definition at line 381 of file pcdisk.c.

383{
384 if ((DriveNumber == FrldrBootDrive)/* && DiskIsDriveRemovable(DriveNumber) */ && (FrldrBootPartition == 0xFF))
385 return CdromController; /* This is our El Torito boot CD-ROM */
386 else if (DiskIsDriveRemovable(DriveNumber))
388 else
389 return DiskPeripheral;
390}
static BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber)
Definition: pcdisk.c:199
@ DiskPeripheral
Definition: arc.h:138
@ FloppyDiskPeripheral
Definition: arc.h:139
@ CdromController
Definition: arc.h:128
UCHAR FrldrBootDrive
Definition: uefidisk.c:57
ULONG FrldrBootPartition
Definition: uefidisk.c:58

Referenced by DiskOpen().

◆ DiskReportError()

LONG DiskReportError ( BOOLEAN  bShowError)

◆ DiskResetController()

BOOLEAN DiskResetController ( UCHAR  DriveNumber)

Definition at line 174 of file pcdisk.c.

175{
176 REGS RegsIn, RegsOut;
177
178 WARN("DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n", DriveNumber);
179
180 /*
181 * BIOS Int 13h, function 0 - Reset disk system
182 * AH = 00h
183 * DL = drive (if bit 7 is set both hard disks and floppy disks reset)
184 * Return:
185 * AH = status
186 * CF clear if successful
187 * CF set on error
188 */
189 RegsIn.b.ah = 0x00;
190 RegsIn.b.dl = DriveNumber;
191
192 /* Reset the disk controller */
193 Int386(0x13, &RegsIn, &RegsOut);
194
195 return INT386_SUCCESS(RegsOut);
196}
#define WARN(fmt,...)
Definition: precomp.h:61
#define INT386_SUCCESS(regs)
Definition: pcbios.h:181
int __cdecl Int386(int ivec, REGS *in, REGS *out)
unsigned char dl
Definition: pcbios.h:142
unsigned char ah
Definition: pcbios.h:134
Definition: pcbios.h:161
BYTEREGS b
Definition: pcbios.h:165

Referenced by DetectBiosFloppyPeripheral(), PcDiskReadLogicalSectorsCHS(), and PcDiskReadLogicalSectorsLBA().

◆ PcBeep()

VOID PcBeep ( VOID  )

Definition at line 34 of file pcbeep.c.

35{
36 Sound(700);
38 Sound(0);
39}
static VOID Sound(USHORT Frequency)
Definition: pcbeep.c:17
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: pchw.c:60

Referenced by MachInit().

◆ PcConsGetCh()

int PcConsGetCh ( VOID  )

Definition at line 84 of file pccons.c.

85{
86 REGS Regs;
87 static BOOLEAN ExtendedKey = FALSE;
88 static char ExtendedScanCode = 0;
89
90 /* If the last time we were called an
91 * extended key was pressed then return
92 * that keys scan code. */
93 if (ExtendedKey)
94 {
96 return ExtendedScanCode;
97 }
98
99 /* Int 16h AH=00h
100 * KEYBOARD - GET KEYSTROKE
101 *
102 * AH = 00h
103 * Return:
104 * AH = BIOS scan code
105 * AL = ASCII character
106 */
107 Regs.b.ah = 0x00;
108 Int386(0x16, &Regs, &Regs);
109
110 /* Check for an extended keystroke */
111 if (Regs.b.al == 0)
112 {
114 ExtendedScanCode = Regs.b.ah;
115 }
116
117 /* Return keystroke */
118 return Regs.b.al;
119}
unsigned char BOOLEAN
Definition: actypes.h:127
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char al
Definition: pcbios.h:133
static BOOLEAN ExtendedKey
Definition: ueficon.c:20
static char ExtendedScanCode
Definition: ueficon.c:21

Referenced by MachInit(), and PcVideoSetDisplayMode().

◆ PcConsKbHit()

BOOLEAN PcConsKbHit ( VOID  )

Definition at line 63 of file pccons.c.

64{
65 REGS Regs;
66
67 /* Int 16h AH=01h
68 * KEYBOARD - CHECK FOR KEYSTROKE
69 *
70 * AH = 01h
71 * Return:
72 * ZF set if no keystroke available
73 * ZF clear if keystroke available
74 * AH = BIOS scan code
75 * AL = ASCII character
76 */
77 Regs.b.ah = 0x01;
78 Int386(0x16, &Regs, &Regs);
79
80 return !(Regs.x.eflags & EFLAGS_ZF);
81}
#define EFLAGS_ZF
Definition: ketypes.h:194
unsigned long eflags
Definition: pcbios.h:107
DWORDREGS x
Definition: pcbios.h:162

Referenced by MachInit().

◆ PcConsPutChar()

VOID PcConsPutChar ( int  Ch)

Definition at line 22 of file pccons.c.

23{
24 REGS Regs;
25
26 /* If we are displaying a CR '\n' then do a LF also */
27 if (Ch == '\n')
28 {
29 /* Display the LF */
30 PcConsPutChar('\r');
31 }
32
33 /* If we are displaying a TAB '\t' then display 8 spaces ' ' */
34 if (Ch == '\t')
35 {
36 /* Display the 8 spaces ' ' */
37 PcConsPutChar(' ');
38 PcConsPutChar(' ');
39 PcConsPutChar(' ');
40 PcConsPutChar(' ');
41 PcConsPutChar(' ');
42 PcConsPutChar(' ');
43 PcConsPutChar(' ');
44 PcConsPutChar(' ');
45 return;
46 }
47
48 /* Int 10h AH=0Eh
49 * VIDEO - TELETYPE OUTPUT
50 *
51 * AH = 0Eh
52 * AL = character to write
53 * BH = page number
54 * BL = foreground color (graphics modes only)
55 */
56 Regs.b.ah = 0x0E;
57 Regs.b.al = Ch;
58 Regs.w.bx = 1;
59 Int386(0x10, &Regs, &Regs);
60}
VOID PcConsPutChar(int Ch)
Definition: pccons.c:22
#define Ch(x, y, z)
Definition: sha2.c:141
unsigned short bx
Definition: pcbios.h:114
WORDREGS w
Definition: pcbios.h:164

Referenced by MachInit(), and PcConsPutChar().

◆ PcDiskGetCacheableBlockCount()

ULONG PcDiskGetCacheableBlockCount ( UCHAR  DriveNumber)

Definition at line 835 of file pcdisk.c.

836{
837 PPC_DISK_DRIVE DiskDrive;
838
839 DiskDrive = PcDiskDriveNumberToDrive(DriveNumber);
840 if (!DiskDrive)
841 return 1; // Unknown count.
842
843 /*
844 * If LBA is supported then the block size will be 64 sectors (32k).
845 * If not then the block size is the size of one track.
846 */
847 if (DiskDrive->Int13ExtensionsSupported)
848 return 64;
849 else
850 return DiskDrive->Geometry.SectorsPerTrack;
851}
static PPC_DISK_DRIVE PcDiskDriveNumberToDrive(IN UCHAR DriveNumber)
Definition: pcdisk.c:517
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:27
BOOLEAN Int13ExtensionsSupported
Definition: pcdisk.c:102
GEOMETRY Geometry
Definition: pcdisk.c:98

Referenced by MachInit().

◆ PcDiskGetDriveGeometry()

BOOLEAN PcDiskGetDriveGeometry ( UCHAR  DriveNumber,
PGEOMETRY  DriveGeometry 
)

Definition at line 805 of file pcdisk.c.

806{
807 PPC_DISK_DRIVE DiskDrive;
808
809 TRACE("PcDiskGetDriveGeometry(0x%x)\n", DriveNumber);
810
811 DiskDrive = PcDiskDriveNumberToDrive(DriveNumber);
812 if (!DiskDrive)
813 return FALSE;
814
815 /* Try to get the extended geometry first */
816 if (DiskDrive->ExtGeometry.Size == sizeof(DiskDrive->ExtGeometry))
817 {
818 /* Extended geometry has been initialized, return it */
819 Geometry->Cylinders = DiskDrive->ExtGeometry.Cylinders;
820 Geometry->Heads = DiskDrive->ExtGeometry.Heads;
821 Geometry->SectorsPerTrack = DiskDrive->ExtGeometry.SectorsPerTrack;
822 Geometry->BytesPerSector = DiskDrive->ExtGeometry.BytesPerSector;
823 Geometry->Sectors = DiskDrive->ExtGeometry.Sectors;
824 }
825 else
826 /* Fall back to legacy BIOS geometry */
827 {
828 *Geometry = DiskDrive->Geometry;
829 }
830
831 return TRUE;
832}
#define TRACE(s)
Definition: solgame.cpp:4
ULONGLONG Sectors
Definition: pcdisk.c:88
USHORT BytesPerSector
Definition: pcdisk.c:89
ULONG SectorsPerTrack
Definition: pcdisk.c:87
ULONG Cylinders
Definition: pcdisk.c:85
EXTENDED_GEOMETRY ExtGeometry
Definition: pcdisk.c:99

Referenced by MachInit(), and PcGetHarddiskConfigurationData().

◆ PcDiskReadLogicalSectors()

BOOLEAN PcDiskReadLogicalSectors ( UCHAR  DriveNumber,
ULONGLONG  SectorNumber,
ULONG  SectorCount,
PVOID  Buffer 
)

◆ PcFindPciBios()

BOOLEAN PcFindPciBios ( PPCI_REGISTRY_INFO  BusData)

Definition at line 77 of file hwpci.c.

78{
79 REGS RegsIn;
80 REGS RegsOut;
81
82 RegsIn.b.ah = 0xB1; /* Subfunction B1h */
83 RegsIn.b.al = 0x01; /* PCI BIOS present */
84
85 Int386(0x1A, &RegsIn, &RegsOut);
86
87 if (INT386_SUCCESS(RegsOut) &&
88 (RegsOut.d.edx == ' ICP') &&
89 (RegsOut.b.ah == 0))
90 {
91 TRACE("Found PCI bios\n");
92
93 TRACE("AL: %x\n", RegsOut.b.al);
94 TRACE("BH: %x\n", RegsOut.b.bh);
95 TRACE("BL: %x\n", RegsOut.b.bl);
96 TRACE("CL: %x\n", RegsOut.b.cl);
97
98 BusData->NoBuses = RegsOut.b.cl + 1;
99 BusData->MajorRevision = RegsOut.b.bh;
100 BusData->MinorRevision = RegsOut.b.bl;
101 BusData->HardwareMechanism = RegsOut.b.al;
102
103 return TRUE;
104 }
105
106 TRACE("No PCI bios found\n");
107
108 return FALSE;
109}
unsigned char bl
Definition: pcbios.h:136
unsigned char cl
Definition: pcbios.h:139
unsigned char bh
Definition: pcbios.h:137
unsigned long edx
Definition: pcbios.h:96
UCHAR MajorRevision
Definition: pci.h:107
UCHAR NoBuses
Definition: pci.h:109
UCHAR HardwareMechanism
Definition: pci.h:110
UCHAR MinorRevision
Definition: pci.h:108
DWORDREGS d
Definition: pcbios.h:163

Referenced by Pc98HwDetect(), and PcHwDetect().

◆ PcGetTime()

TIMEINFO * PcGetTime ( VOID  )

Definition at line 30 of file pcrtc.c.

31{
32 static TIMEINFO TimeInfo;
33 REGS Regs;
34
35 for (;;)
36 {
37 /* Some BIOSes, such as the 1998/07/25 system ROM
38 * in the Compaq Deskpro EP/SB, leave CF unchanged
39 * if successful, so CF should be cleared before
40 * calling this function. */
41 Regs.x.eflags = 0;
42// __writeeflags(__readeflags() & ~EFLAGS_CF);
43
44 /* Int 1Ah AH=04h
45 * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
46 *
47 * AH = 04h
48 * CF clear to avoid bug
49 * Return:
50 * CF clear if successful
51 * CH = century (BCD)
52 * CL = year (BCD)
53 * DH = month (BCD)
54 * DL = day (BCD)
55 * CF set on error
56 */
57 Regs.b.ah = 0x04;
58 Int386(0x1A, &Regs, &Regs);
59
60 if (!INT386_SUCCESS(Regs)) continue;
61
62 TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
63 TimeInfo.Month = BCD_INT(Regs.b.dh);
64 TimeInfo.Day = BCD_INT(Regs.b.dl);
65
66 /* Some BIOSes leave CF unchanged if successful,
67 * so CF should be cleared before calling this function. */
68 Regs.x.eflags = 0;
69// __writeeflags(__readeflags() & ~EFLAGS_CF);
70
71 /* Int 1Ah AH=02h
72 * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
73 *
74 * AH = 02h
75 * CF clear to avoid bug
76 * Return:
77 * CF clear if successful
78 * CH = hour (BCD)
79 * CL = minutes (BCD)
80 * DH = seconds (BCD)
81 * DL = daylight savings flag (00h standard time, 01h daylight time)
82 * CF set on error (i.e. clock not running or in middle of update)
83 */
84 Regs.b.ah = 0x02;
85 Int386(0x1A, &Regs, &Regs);
86
87 if (!INT386_SUCCESS(Regs)) continue;
88
89 TimeInfo.Hour = BCD_INT(Regs.b.ch);
90 TimeInfo.Minute = BCD_INT(Regs.b.cl);
91 TimeInfo.Second = BCD_INT(Regs.b.dh);
92
93 break;
94 }
95 return &TimeInfo;
96}
static UCHAR BCD_INT(_In_ UCHAR Bcd)
Definition: pcrtc.c:23
unsigned char ch
Definition: pcbios.h:140
unsigned char dh
Definition: pcbios.h:143
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

Referenced by MachInit().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1684 of file machpc.c.

1686{
1688 ULONG BusNumber = 0;
1689
1690 TRACE("DetectHardware()\n");
1691
1692 /* Create the 'System' key */
1693 // TODO: Discover and set the other machine types
1694 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1695
1697
1698 /* Detect buses */
1700 DetectApmBios(SystemKey, &BusNumber);
1701 DetectPnpBios(SystemKey, &BusNumber);
1702 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1703 DetectAcpiBios(SystemKey, &BusNumber);
1704
1705 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1706 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1707
1708 TRACE("DetectHardware() Done\n");
1709 return SystemKey;
1710}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:161
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:59
VOID DetectPciBios(_In_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Inout_ PULONG BusNumber, _In_ FIND_PCI_BIOS MachFindPciBios)
Definition: hwpci.c:169
BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData)
Definition: hwpci.c:77
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:253
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1618
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:131
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: pchw.c:45
uint32_t ULONG
Definition: typedefs.h:59
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

Referenced by MachInit().

◆ PcHwIdle()

VOID PcHwIdle ( VOID  )

Definition at line 1713 of file machpc.c.

1714{
1715 REGS Regs;
1716
1717 /* Select APM 1.0+ function */
1718 Regs.b.ah = 0x53;
1719
1720 /* Function 05h: CPU idle */
1721 Regs.b.al = 0x05;
1722
1723 /* Call INT 15h */
1724 Int386(0x15, &Regs, &Regs);
1725
1726 /* Check if successfull (CF set on error) */
1727 if (INT386_SUCCESS(Regs))
1728 return;
1729
1730 /*
1731 * No futher processing here.
1732 * Optionally implement HLT instruction handling.
1733 */
1734}

Referenced by MachInit().

◆ PcInitializeBootDevices()

BOOLEAN PcInitializeBootDevices ( VOID  )

Definition at line 427 of file hwdisk.c.

428{
429 UCHAR DiskCount;
430 BOOLEAN BootDriveReported = FALSE;
432
433 DiskCount = EnumerateHarddisks(&BootDriveReported);
434
435 /* Initialize FrLdrBootPath, the path FreeLoader starts from */
437
438 /* Add it, if it's a floppy or CD-ROM */
439 if ((FrldrBootDrive >= FIRST_BIOS_DISK && !BootDriveReported) ||
441 {
443
446 &DiskVtbl, NULL, NULL, NULL);
448
449 if (Status == ESUCCESS)
450 {
451 DiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives!
452 TRACE("Additional boot drive detected: 0x%02X\n", FrldrBootDrive);
453 }
454 else
455 {
456 ERR("Additional boot drive 0x%02X failed\n", FrldrBootDrive);
457 }
458 }
459
460 return (DiskCount != 0);
461}
UINT DriveType
#define ERR(fmt,...)
Definition: precomp.h:57
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
#define NULL
Definition: types.h:112
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29
BOOLEAN PxeInit(VOID)
Definition: pxe.c:376
Status
Definition: gdiplustypes.h:25
static const DEVVTBL DiskVtbl
Definition: hwdisk.c:239
static BOOLEAN DiskGetBootPath(_In_ BOOLEAN IsPxe, _Out_ PCONFIGURATION_TYPE DeviceType)
Definition: hwdisk.c:366
#define FIRST_BIOS_DISK
Definition: hwdisk.c:31
static UCHAR EnumerateHarddisks(OUT PBOOLEAN BootDriveReported)
Definition: hwdisk.c:308
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by MachInit(), and Pc98InitializeBootDevices().

◆ PcMemGetMemoryMap()

PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap ( ULONG MemoryMapSize)

Definition at line 609 of file pcmem.c.

610{
611 ULONG EntryCount;
612 ULONG ExtendedMemorySizeAtOneMB;
613 ULONG ExtendedMemorySizeAtSixteenMB;
614 ULONG EbdaBase, EbdaSize;
615
616 TRACE("PcMemGetMemoryMap()\n");
617
619
621
622 /* If the BIOS didn't provide a memory map, synthesize one */
623 if (EntryCount == 0)
624 {
625 GetExtendedMemoryConfiguration(&ExtendedMemorySizeAtOneMB,
626 &ExtendedMemorySizeAtSixteenMB);
627
628 /* Conventional memory */
631 0,
633 LoaderFree);
634
635 /* Extended memory */
638 1024 * 1024 / PAGE_SIZE,
639 ExtendedMemorySizeAtOneMB * 1024 / PAGE_SIZE,
640 LoaderFree);
641
642 if (ExtendedMemorySizeAtSixteenMB != 0)
643 {
644 /* Extended memory at 16MB */
647 0x1000000 / PAGE_SIZE,
648 ExtendedMemorySizeAtSixteenMB * 64 * 1024 / PAGE_SIZE,
649 LoaderFree);
650 }
651
652 /* Check if we have an EBDA and get it's location */
653 if (GetEbdaLocation(&EbdaBase, &EbdaSize))
654 {
655 /* Add the descriptor */
658 (EbdaBase / PAGE_SIZE),
659 ADDRESS_AND_SIZE_TO_SPAN_PAGES(EbdaBase, EbdaSize),
661 }
662 }
663
664 /* Setup some protected ranges */
665 SetMemory(PcMemoryMap, 0x000000, 0x01000, LoaderFirmwarePermanent); // Realmode IVT / BDA
666 SetMemory(PcMemoryMap, 0x0A0000, 0x50000, LoaderFirmwarePermanent); // Video memory
667 SetMemory(PcMemoryMap, 0x0F0000, 0x10000, LoaderSpecialMemory); // ROM
668 SetMemory(PcMemoryMap, 0xFFF000, 0x01000, LoaderSpecialMemory); // unusable memory (do we really need this?)
669
670 *MemoryMapSize = PcMemFinalizeMemoryMap(PcMemoryMap);
671 return PcMemoryMap;
672}
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define MAX_BIOS_DESCRIPTORS
Definition: pcbios.h:12
static FREELDR_MEMORY_DESCRIPTOR PcMemoryMap[MAX_BIOS_DESCRIPTORS+1]
Definition: pcmem.c:41
ULONG PcMemFinalizeMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap)
Definition: pcmem.c:554
static VOID PcMemCheckUsableMemorySize(VOID)
Definition: pcmem.c:214
static BOOLEAN GetExtendedMemoryConfiguration(ULONG *pMemoryAtOneMB, ULONG *pMemoryAtSixteenMB)
Definition: pcmem.c:58
static ULONG PcMemGetConventionalMemorySize(VOID)
Definition: pcmem.c:154
ULONG AddMemoryDescriptor(IN OUT PFREELDR_MEMORY_DESCRIPTOR List, IN ULONG MaxCount, IN PFN_NUMBER BasePage, IN PFN_NUMBER PageCount, IN TYPE_OF_MEMORY MemoryType)
Definition: meminit.c:123
ULONG PcMapCount
Definition: pcmem.c:43
static ULONG PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSize)
Definition: pcmem.c:240
VOID SetMemory(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG_PTR BaseAddress, SIZE_T Size, TYPE_OF_MEMORY MemoryType)
Definition: pcmem.c:534
static BOOLEAN GetEbdaLocation(PULONG BaseAddress, PULONG Size)
Definition: pcmem.c:180
@ LoaderFree
Definition: arc.h:295
@ LoaderFirmwarePermanent
Definition: arc.h:299
@ LoaderSpecialMemory
Definition: arc.h:315
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1809 of file machpc.c.

1810{
1811 /* Prepare video and turn off the floppy motor */
1814}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1216
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1308

Referenced by MachInit().

◆ PcVideoClearScreen()

VOID PcVideoClearScreen ( UCHAR  Attr)

Definition at line 1236 of file pcvideo.c.

1237{
1238 USHORT AttrChar;
1239 USHORT *BufPtr;
1240
1241 AttrChar = ((USHORT)Attr << 8) | ' ';
1242 for (BufPtr = (USHORT*)VIDEOTEXT_MEM_ADDRESS;
1244 BufPtr++)
1245 {
1247 *BufPtr = AttrChar;
1248 }
1249}
#define VIDEOTEXT_MEM_ADDRESS
Definition: pcvideo.c:31
#define VIDEOTEXT_MEM_SIZE
Definition: pcvideo.c:32
unsigned short USHORT
Definition: pedump.c:61
#define __WARNING_DEREF_NULL_PTR
Definition: suppress.h:32
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28

Referenced by MachInit().

◆ PcVideoCopyOffScreenBufferToVRAM()

VOID PcVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 1195 of file pcvideo.c.

1196{
1197 USHORT BanksToCopy;
1198 ULONG BytesInLastBank;
1199 USHORT CurrentBank;
1200 ULONG BankSize;
1201
1202 /* PcVideoWaitForVerticalRetrace(); */
1203
1204 /* Text mode (BIOS or VESA) */
1206 {
1208 }
1209 /* VESA graphics mode */
1211 {
1215
1216 /* Copy all the banks but the last one because
1217 * it is probably a partial bank */
1218 for (CurrentBank = 0; CurrentBank < BanksToCopy; CurrentBank++)
1219 {
1220 PcVideoSetMemoryBank(CurrentBank);
1221 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BankSize);
1222 }
1223
1224 /* Copy the remaining bytes into the last bank */
1225 PcVideoSetMemoryBank(CurrentBank);
1226 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BytesInLastBank);
1227 }
1228 /* BIOS graphics mode */
1229 else
1230 {
1232 }
1233}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
@ VideoTextMode
Definition: machine.h:35
@ VideoGraphicsMode
Definition: machine.h:36
Definition: bufpool.h:45
static SVGA_MODE_INFORMATION VesaVideoModeInformation
Definition: pcvideo.c:121
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:119
#define VIDEOVGA_MEM_ADDRESS
Definition: pcvideo.c:30
static BOOLEAN VesaVideoMode
Definition: pcvideo.c:120
static VOID PcVideoSetMemoryBank(USHORT BankNumber)
Definition: pcvideo.c:984
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:1121
USHORT HeightInPixels
Definition: pcvideo.c:68
USHORT BytesPerScanLine
Definition: pcvideo.c:65
USHORT WindowGranularity
Definition: pcvideo.c:60
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by MachInit().

◆ PcVideoGetBufferSize()

ULONG PcVideoGetBufferSize ( VOID  )

Definition at line 1121 of file pcvideo.c.

1122{
1124}
static ULONG ScreenHeight
Definition: pcvideo.c:117
static ULONG BytesPerScanLine
Definition: pcvideo.c:118

Referenced by MachInit(), and PcVideoCopyOffScreenBufferToVRAM().

◆ PcVideoGetDisplaySize()

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

Definition at line 1097 of file pcvideo.c.

1098{
1099 *Width = ScreenWidth;
1102 {
1104 {
1105 /* 16-bit color modes give green an extra bit (5:6:5)
1106 * 15-bit color modes have just 5:5:5 for R:G:B */
1107 *Depth = (VesaVideoModeInformation.GreenMaskSize == 6 ? 16 : 15);
1108 }
1109 else
1110 {
1112 }
1113 }
1114 else
1115 {
1116 *Depth = 0;
1117 }
1118}
static ULONG ScreenWidth
Definition: pcvideo.c:116
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_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().

◆ PcVideoGetFontsFromFirmware()

VOID PcVideoGetFontsFromFirmware ( PULONG  RomFontPointers)

Definition at line 1127 of file pcvideo.c.

1128{
1129 REGS BiosRegs;
1130
1131 /* Get the address of the BIOS ROM fonts.
1132 * Int 10h, AX=1130h, BH = pointer specifier
1133 * Returns: es:bp = address */
1134 BiosRegs.d.eax = 0x1130;
1135 BiosRegs.b.bh = ROM_8x14CharacterFont;
1136 Int386(0x10, &BiosRegs, &BiosRegs);
1137 RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
1138
1139 BiosRegs.b.bh = ROM_8x8DoubleDotFontLo;
1140 Int386(0x10, &BiosRegs, &BiosRegs);
1141 RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1142
1143 BiosRegs.b.bh = ROM_8x8DoubleDotFontHi;
1144 Int386(0x10, &BiosRegs, &BiosRegs);
1145 RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1146
1147 BiosRegs.b.bh = ROM_AlphaAlternate;
1148 Int386(0x10, &BiosRegs, &BiosRegs);
1149 RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1150
1151 BiosRegs.b.bh = ROM_8x16Font;
1152 Int386(0x10, &BiosRegs, &BiosRegs);
1153 RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1154
1155 BiosRegs.b.bh = ROM_Alternate9x16Font;
1156 Int386(0x10, &BiosRegs, &BiosRegs);
1157 RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1158}
#define RomFontPointers
Definition: winldr.c:348
@ ROM_AlphaAlternate
Definition: pcvideo.c:131
@ ROM_8x16Font
Definition: pcvideo.c:132
@ ROM_8x14CharacterFont
Definition: pcvideo.c:128
@ ROM_8x8DoubleDotFontHi
Definition: pcvideo.c:130
@ ROM_8x8DoubleDotFontLo
Definition: pcvideo.c:129
@ ROM_Alternate9x16Font
Definition: pcvideo.c:133
unsigned long eax
Definition: pcbios.h:93
unsigned short bp
Definition: pcbios.h:120
unsigned short es
Definition: pcbios.h:123

Referenced by MachInit().

◆ PcVideoGetPaletteColor()

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

Definition at line 1276 of file pcvideo.c.

1277{
1282}
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define VIDEOPORT_PALETTE_READ
Definition: pcvideo.c:25
#define VIDEOPORT_PALETTE_DATA
Definition: pcvideo.c:27

Referenced by MachInit().

◆ PcVideoHideShowTextCursor()

VOID PcVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 1186 of file pcvideo.c.

1187{
1188 if (Show)
1189 PcVideoDefineCursor(0x0D, 0x0E);
1190 else
1191 PcVideoDefineCursor(0x20, 0x00);
1192}
static VOID PcVideoDefineCursor(UCHAR StartScanLine, UCHAR EndScanLine)
Definition: pcvideo.c:638

Referenced by MachInit(), and PcVideoPrepareForReactOS().

◆ PcVideoInit()

VOID PcVideoInit ( VOID  )

Definition at line 1020 of file pcvideo.c.

1021{
1022 /* Detect the installed video card */
1024
1025 /* Retrieve the initial display mode parameters */
1027
1028 /* If any video options have been specified, try to set a display mode */
1031
1032 // FIXME: We don't support graphics modes yet!
1033 // Revert to 80x25 text mode.
1036}
BOOTMGRINFO BootMgrInfo
Definition: settings.c:19
static ULONG PcVideoDetectVideoCard(VOID)
Definition: pcvideo.c:139
#define VIDEOMODE_NORMAL_TEXT
Definition: pcvideo.c:38
static ULONG VideoCard
Definition: pcvideo.c:114
static BOOLEAN PcVideoSetMode(USHORT NewMode)
Definition: pcvideo.c:878
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:1045
static VOID PcVideoGetDisplayMode(VOID)
Definition: pcvideo.c:380
PCSTR VideoOptions
Definition: settings.h:13

Referenced by MachInit().

◆ PcVideoIsPaletteFixed()

BOOLEAN PcVideoIsPaletteFixed ( VOID  )

Definition at line 1261 of file pcvideo.c.

1262{
1263 return FALSE;
1264}

Referenced by MachInit().

◆ PcVideoPrepareForReactOS()

VOID PcVideoPrepareForReactOS ( VOID  )

Definition at line 1308 of file pcvideo.c.

1309{
1310 // PcVideoSetMode80x50_80x43();
1313}
static BOOLEAN PcVideoSetMode80x25(VOID)
Definition: pcvideo.c:770
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1186

Referenced by PcPrepareForReactOS().

◆ PcVideoPutChar()

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

Definition at line 1252 of file pcvideo.c.

1253{
1254 USHORT *BufPtr;
1255
1256 BufPtr = (USHORT*)(ULONG_PTR)(VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
1257 *BufPtr = ((USHORT)Attr << 8) | (Ch & 0xff);
1258}
#define Y(I)
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by MachInit().

◆ PcVideoSetDisplayMode()

VIDEODISPLAYMODE PcVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 1045 of file pcvideo.c.

1046{
1048
1049 if (!DisplayModeName || *DisplayModeName == '\0')
1050 goto Quit;
1051
1053 {
1054 TRACE_printf("CGA or other display adapter detected.\n");
1055 TRACE_printf("Using 80x25 text mode.\n");
1057 }
1058 else if (VideoCard == VIDEOCARD_EGA)
1059 {
1060 TRACE_printf("EGA display adapter detected.\n");
1061 TRACE_printf("Using 80x25 text mode.\n");
1063 }
1064 else /* VIDEOCARD_VGA */
1065 {
1066 TRACE_printf("VGA display adapter detected.\n");
1067
1068 /* Get the video option separator, if any */
1069 size_t NameLen = strcspn(DisplayModeName, ",");
1070 if (!NameLen)
1071 goto Quit;
1072
1073 if (_strnicmp(DisplayModeName, "NORMAL_VGA", NameLen) == 0)
1075 else if (_strnicmp(DisplayModeName, "EXTENDED_VGA", NameLen) == 0)
1077 else
1078 VideoMode = (USHORT)strtoul(DisplayModeName, NULL, 0);
1079 }
1080
1082 {
1083 TRACE_printf("Error: unable to set video display mode 0x%x\n", VideoMode);
1084 TRACE_printf("Defaulting to 80x25 text mode.\n");
1085 printf("Press any key to continue.\n");
1086 PcConsGetCh();
1087
1089 }
1090
1091Quit:
1093 return DisplayMode;
1094}
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1859
_ACRTIMP size_t __cdecl strcspn(const char *, const char *)
Definition: string.c:3493
#define printf
Definition: freeldr.h:103
int PcConsGetCh(void)
Definition: pccons.c:84
#define VIDEOCARD_CGA_OR_OTHER
Definition: pcvideo.c:34
#define TRACE_printf(Format,...)
Definition: pcvideo.c:1038
#define VIDEOMODE_EXTENDED_TEXT
Definition: pcvideo.c:39
#define VIDEOCARD_EGA
Definition: pcvideo.c:35
static VOID PcVideoSetBlinkBit(BOOLEAN Enable)
Definition: pcvideo.c:959

Referenced by MachInit(), and PcVideoInit().

◆ PcVideoSetPaletteColor()

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

Definition at line 1267 of file pcvideo.c.

Referenced by MachInit().

◆ PcVideoSetTextCursorPosition()

VOID PcVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 1161 of file pcvideo.c.

1162{
1163 REGS Regs;
1164
1165 /* Int 10h AH=02h
1166 * VIDEO - SET CURSOR POSITION
1167 *
1168 * AH = 02h
1169 * BH = page number
1170 * 0-3 in modes 2&3
1171 * 0-7 in modes 0&1
1172 * 0 in graphics modes
1173 * DH = row (00h is top)
1174 * DL = column (00h is left)
1175 * Return:
1176 * Nothing
1177 */
1178 Regs.b.ah = 0x02;
1179 Regs.b.bh = 0x00;
1180 Regs.b.dh = Y;
1181 Regs.b.dl = X;
1182 Int386(0x10, &Regs, &Regs);
1183}
#define X(b, s)

Referenced by MachInit().

◆ PcVideoSync()

VOID PcVideoSync ( VOID  )

Definition at line 1285 of file pcvideo.c.

1286{
1288 {
1289 /*
1290 * Keep reading the port until bit 3 is clear
1291 * This waits for the current retrace to end and
1292 * we can catch the next one so we know we are
1293 * getting a full retrace.
1294 */
1295 }
1296
1298 {
1299 /*
1300 * Keep reading the port until bit 3 is set
1301 * Now that we know we aren't doing a vertical
1302 * retrace we need to wait for the next one.
1303 */
1304 }
1305}
#define VIDEOPORT_VERTICAL_RETRACE
Definition: pcvideo.c:28

Referenced by MachInit().

Variable Documentation

◆ FrldrBootDrive

◆ FrldrBootPartition

◆ PcBiosMapCount

ULONG PcBiosMapCount
extern

Definition at line 38 of file pcmem.c.

Referenced by DetectAcpiBios(), Pc98MemGetMemoryMap(), and PcMemGetBiosMemoryMap().

◆ PcBiosMemoryMap

BIOS_MEMORY_MAP PcBiosMemoryMap[]
extern

Definition at line 37 of file pcmem.c.

Referenced by DetectAcpiBios(), Pc98MemGetMemoryMap(), and PcMemGetBiosMemoryMap().