#include <freeldr.h>
#include <debug.h>
-
DBG_DEFAULT_CHANNEL(HWDETECT);
+BOOLEAN
+XboxFindPciBios(PPCI_REGISTRY_INFO BusData)
+{
+ /* We emulate PCI BIOS here, there are 2 known working PCI buses on an original Xbox */
+
+ BusData->NoBuses = 2;
+ BusData->MajorRevision = 1;
+ BusData->MinorRevision = 0;
+ BusData->HardwareMechanism = 1;
+ return TRUE;
+}
+
+extern
+VOID
+DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base);
+
+static
+ULONG
+XboxGetSerialPort(ULONG Index, PULONG Irq)
+{
+ /*
+ * Xbox may have maximum two Serial COM ports
+ * if the Super I/O chip is connected via LPC
+ */
+ static const UCHAR Device[MAX_XBOX_COM_PORTS] = {LPC_DEVICE_SERIAL_PORT_1, LPC_DEVICE_SERIAL_PORT_2};
+ ULONG ComBase = 0;
+
+ // Enter Configuration
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_ENTER_CONFIG_KEY);
+
+ // Select serial device
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_NUMBER);
+ WRITE_PORT_UCHAR(LPC_IO_BASE + 1, Device[Index]);
+
+ // Check if selected device is active
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_ACTIVATE);
+ if (READ_PORT_UCHAR(LPC_IO_BASE + 1) == 1)
+ {
+ // Read LSB
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_LOW);
+ ComBase = READ_PORT_UCHAR(LPC_IO_BASE + 1);
+ // Read MSB
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_BASE_ADDRESS_HIGH);
+ ComBase |= (READ_PORT_UCHAR(LPC_IO_BASE + 1) << 8);
+ // Read IRQ
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_CONFIG_DEVICE_INTERRUPT);
+ *Irq = READ_PORT_UCHAR(LPC_IO_BASE + 1);
+ }
+
+ // Exit Configuration
+ WRITE_PORT_UCHAR(LPC_IO_BASE, LPC_EXIT_CONFIG_KEY);
+
+ return ComBase;
+}
+
+extern
+VOID
+DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, ULONG Count);
+
+VOID
+XboxGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
+{
+ TRACE("XboxGetExtendedBIOSData(): UNIMPLEMENTED\n");
+ *ExtendedBIOSDataArea = 0;
+ *ExtendedBIOSDataSize = 0;
+}
+
// NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
// but without extended geometry support.
static
/* Detect ISA/BIOS devices */
DetectBiosDisks(SystemKey, BusKey);
+ DetectSerialPorts(BusKey, XboxGetSerialPort, MAX_XBOX_COM_PORTS);
/* FIXME: Detect more ISA devices */
}
+static
+UCHAR
+XboxGetFloppyCount(VOID)
+{
+ /* On a PC we use CMOS/RTC I/O ports 0x70 and 0x71 to detect floppies.
+ * However an Xbox CMOS memory range [0x10, 0x70) and [0x80, 0x100)
+ * is filled with 0x55 0xAA 0x55 0xAA ... byte pattern which is used
+ * to validate the date/time settings by Xbox OS.
+ *
+ * Technically it's possible to connect a floppy drive to Xbox, but
+ * CMOS detection method should not be used here. */
+
+ WARN("XboxGetFloppyCount() is UNIMPLEMENTED, returning 0\n");
+ return 0;
+}
+
PCONFIGURATION_COMPONENT_DATA
XboxHwDetect(VOID)
{
FldrCreateSystemKey(&SystemKey);
GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData;
+ FindPciBios = XboxFindPciBios;
/* TODO: Build actual xbox's hardware configuration tree */
+ DetectPciBios(SystemKey, &BusNumber);
DetectIsaBios(SystemKey, &BusNumber);
TRACE("DetectHardware() Done\n");
MachVtbl.VideoSetDisplayMode = XboxVideoSetDisplayMode;
MachVtbl.VideoGetDisplaySize = XboxVideoGetDisplaySize;
MachVtbl.VideoGetBufferSize = XboxVideoGetBufferSize;
+ MachVtbl.VideoGetFontsFromFirmware = XboxVideoGetFontsFromFirmware;
+ MachVtbl.VideoSetTextCursorPosition = XboxVideoSetTextCursorPosition;
MachVtbl.VideoHideShowTextCursor = XboxVideoHideShowTextCursor;
MachVtbl.VideoPutChar = XboxVideoPutChar;
MachVtbl.VideoCopyOffScreenBufferToVRAM = XboxVideoCopyOffScreenBufferToVRAM;
MachVtbl.Beep = PcBeep;
MachVtbl.PrepareForReactOS = XboxPrepareForReactOS;
MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
+ MachVtbl.GetExtendedBIOSData = XboxGetExtendedBIOSData;
+ MachVtbl.GetFloppyCount = XboxGetFloppyCount;
MachVtbl.DiskGetBootPath = DiskGetBootPath;
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
MachVtbl.HwDetect = XboxHwDetect;
MachVtbl.HwIdle = XboxHwIdle;
- DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
-
/* Set LEDs to orange after init */
XboxSetLED("oooo");
}