+++ /dev/null
-/*
- * FreeLoader
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <freeldr.h>
-
-#define NDEBUG
-#include <debug.h>
-
-DBG_DEFAULT_CHANNEL(HWDETECT);
-
-
-// NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
-// but without extended geometry support.
-static
-PCM_PARTIAL_RESOURCE_LIST
-XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
-{
- PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
- PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
- //EXTENDED_GEOMETRY ExtGeometry;
- GEOMETRY Geometry;
- ULONG Size;
-
- //
- // Initialize returned size
- //
- *pSize = 0;
-
- /* Set 'Configuration Data' value */
- Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
- sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
- PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
- if (PartialResourceList == NULL)
- {
- ERR("Failed to allocate a full resource descriptor\n");
- return NULL;
- }
-
- memset(PartialResourceList, 0, Size);
- PartialResourceList->Version = 1;
- PartialResourceList->Revision = 1;
- PartialResourceList->Count = 1;
- PartialResourceList->PartialDescriptors[0].Type =
- CmResourceTypeDeviceSpecific;
-// PartialResourceList->PartialDescriptors[0].ShareDisposition =
-// PartialResourceList->PartialDescriptors[0].Flags =
- PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
- sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
-
- /* Get pointer to geometry data */
- DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
-
- /* Get the disk geometry */
- //ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
-
- if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
- {
- DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
- DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
- DiskGeometry->SectorsPerTrack = Geometry.Sectors;
- DiskGeometry->NumberOfHeads = Geometry.Heads;
- }
- else
- {
- ERR("Reading disk geometry failed\n");
- FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
- return NULL;
- }
- TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
- DriveNumber,
- DiskGeometry->NumberOfCylinders,
- DiskGeometry->NumberOfHeads,
- DiskGeometry->SectorsPerTrack,
- DiskGeometry->BytesPerSector);
-
- //
- // Return configuration data
- //
- *pSize = Size;
- return PartialResourceList;
-}
-
-static
-VOID
-DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
-{
- PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
- PCONFIGURATION_COMPONENT_DATA BusKey;
- ULONG Size;
-
- /* Set 'Configuration Data' value */
- Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
- sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
- PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
- if (PartialResourceList == NULL)
- {
- TRACE("Failed to allocate resource descriptor\n");
- return;
- }
-
- /* Initialize resource descriptor */
- memset(PartialResourceList, 0, Size);
- PartialResourceList->Version = 1;
- PartialResourceList->Revision = 1;
- PartialResourceList->Count = 0;
-
- /* Create new bus key */
- FldrCreateComponentKey(SystemKey,
- AdapterClass,
- MultiFunctionAdapter,
- 0x0,
- 0x0,
- 0xFFFFFFFF,
- "ISA",
- PartialResourceList,
- Size,
- &BusKey);
-
- /* Increment bus number */
- (*BusNumber)++;
-
- /* Detect ISA/BIOS devices */
- DetectBiosDisks(SystemKey, BusKey);
-
- /* FIXME: Detect more ISA devices */
-}
-
-PCONFIGURATION_COMPONENT_DATA
-XboxHwDetect(VOID)
-{
- PCONFIGURATION_COMPONENT_DATA SystemKey;
- ULONG BusNumber = 0;
-
- TRACE("DetectHardware()\n");
-
- /* Create the 'System' key */
- FldrCreateSystemKey(&SystemKey);
-
- GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData;
-
- /* TODO: Build actual xbox's hardware configuration tree */
- DetectIsaBios(SystemKey, &BusNumber);
-
- TRACE("DetectHardware() Done\n");
- return SystemKey;
-}
-
-VOID XboxHwIdle(VOID)
-{
- /* UNIMPLEMENTED */
-}
-
-
-/******************************************************************************/
-
-VOID
-XboxMachInit(const char *CmdLine)
-{
- /* Set LEDs to red before anything is initialized */
- XboxSetLED("rrrr");
-
- /* Initialize our stuff */
- XboxMemInit();
- XboxVideoInit();
-
- /* Setup vtbl */
- MachVtbl.ConsPutChar = XboxConsPutChar;
- MachVtbl.ConsKbHit = XboxConsKbHit;
- MachVtbl.ConsGetCh = XboxConsGetCh;
- MachVtbl.VideoClearScreen = XboxVideoClearScreen;
- MachVtbl.VideoSetDisplayMode = XboxVideoSetDisplayMode;
- MachVtbl.VideoGetDisplaySize = XboxVideoGetDisplaySize;
- MachVtbl.VideoGetBufferSize = XboxVideoGetBufferSize;
- MachVtbl.VideoHideShowTextCursor = XboxVideoHideShowTextCursor;
- MachVtbl.VideoPutChar = XboxVideoPutChar;
- MachVtbl.VideoCopyOffScreenBufferToVRAM = XboxVideoCopyOffScreenBufferToVRAM;
- MachVtbl.VideoIsPaletteFixed = XboxVideoIsPaletteFixed;
- MachVtbl.VideoSetPaletteColor = XboxVideoSetPaletteColor;
- MachVtbl.VideoGetPaletteColor = XboxVideoGetPaletteColor;
- MachVtbl.VideoSync = XboxVideoSync;
- MachVtbl.Beep = PcBeep;
- MachVtbl.PrepareForReactOS = XboxPrepareForReactOS;
- MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
- MachVtbl.DiskGetBootPath = DiskGetBootPath;
- MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
- MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
- MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
- MachVtbl.GetTime = XboxGetTime;
- MachVtbl.InitializeBootDevices = PcInitializeBootDevices;
- MachVtbl.HwDetect = XboxHwDetect;
- MachVtbl.HwIdle = XboxHwIdle;
-
- DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
-
- /* Set LEDs to orange after init */
- XboxSetLED("oooo");
-}
-
-VOID
-XboxPrepareForReactOS(IN BOOLEAN Setup)
-{
- /* On XBOX, prepare video and turn off the floppy motor */
- XboxVideoPrepareForReactOS(Setup);
- DiskStopFloppyMotor();
-}
-
-/* EOF */