4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 DBG_DEFAULT_CHANNEL(HWDETECT
);
27 XboxGetExtendedBIOSData(PULONG ExtendedBIOSDataArea
, PULONG ExtendedBIOSDataSize
)
29 TRACE("XboxGetExtendedBIOSData(): UNIMPLEMENTED\n");
30 *ExtendedBIOSDataArea
= 0;
31 *ExtendedBIOSDataSize
= 0;
34 // NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
35 // but without extended geometry support.
37 PCM_PARTIAL_RESOURCE_LIST
38 XboxGetHarddiskConfigurationData(UCHAR DriveNumber
, ULONG
* pSize
)
40 PCM_PARTIAL_RESOURCE_LIST PartialResourceList
;
41 PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
42 //EXTENDED_GEOMETRY ExtGeometry;
47 // Initialize returned size
51 /* Set 'Configuration Data' value */
52 Size
= sizeof(CM_PARTIAL_RESOURCE_LIST
) +
53 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
54 PartialResourceList
= FrLdrHeapAlloc(Size
, TAG_HW_RESOURCE_LIST
);
55 if (PartialResourceList
== NULL
)
57 ERR("Failed to allocate a full resource descriptor\n");
61 memset(PartialResourceList
, 0, Size
);
62 PartialResourceList
->Version
= 1;
63 PartialResourceList
->Revision
= 1;
64 PartialResourceList
->Count
= 1;
65 PartialResourceList
->PartialDescriptors
[0].Type
=
66 CmResourceTypeDeviceSpecific
;
67 // PartialResourceList->PartialDescriptors[0].ShareDisposition =
68 // PartialResourceList->PartialDescriptors[0].Flags =
69 PartialResourceList
->PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
70 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
72 /* Get pointer to geometry data */
73 DiskGeometry
= (PVOID
)(((ULONG_PTR
)PartialResourceList
) + sizeof(CM_PARTIAL_RESOURCE_LIST
));
75 /* Get the disk geometry */
76 //ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
78 if (MachDiskGetDriveGeometry(DriveNumber
, &Geometry
))
80 DiskGeometry
->BytesPerSector
= Geometry
.BytesPerSector
;
81 DiskGeometry
->NumberOfCylinders
= Geometry
.Cylinders
;
82 DiskGeometry
->SectorsPerTrack
= Geometry
.Sectors
;
83 DiskGeometry
->NumberOfHeads
= Geometry
.Heads
;
87 ERR("Reading disk geometry failed\n");
88 FrLdrHeapFree(PartialResourceList
, TAG_HW_RESOURCE_LIST
);
91 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
93 DiskGeometry
->NumberOfCylinders
,
94 DiskGeometry
->NumberOfHeads
,
95 DiskGeometry
->SectorsPerTrack
,
96 DiskGeometry
->BytesPerSector
);
99 // Return configuration data
102 return PartialResourceList
;
107 DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey
, ULONG
*BusNumber
)
109 PCM_PARTIAL_RESOURCE_LIST PartialResourceList
;
110 PCONFIGURATION_COMPONENT_DATA BusKey
;
113 /* Set 'Configuration Data' value */
114 Size
= sizeof(CM_PARTIAL_RESOURCE_LIST
) -
115 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
116 PartialResourceList
= FrLdrHeapAlloc(Size
, TAG_HW_RESOURCE_LIST
);
117 if (PartialResourceList
== NULL
)
119 TRACE("Failed to allocate resource descriptor\n");
123 /* Initialize resource descriptor */
124 memset(PartialResourceList
, 0, Size
);
125 PartialResourceList
->Version
= 1;
126 PartialResourceList
->Revision
= 1;
127 PartialResourceList
->Count
= 0;
129 /* Create new bus key */
130 FldrCreateComponentKey(SystemKey
,
132 MultiFunctionAdapter
,
141 /* Increment bus number */
144 /* Detect ISA/BIOS devices */
145 DetectBiosDisks(SystemKey
, BusKey
);
147 /* FIXME: Detect more ISA devices */
152 XboxGetFloppyCount(VOID
)
154 /* On a PC we use CMOS/RTC I/O ports 0x70 and 0x71 to detect floppies.
155 * However an Xbox CMOS memory range [0x10, 0x70) and [0x80, 0x100)
156 * is filled with 0x55 0xAA 0x55 0xAA ... byte pattern which is used
157 * to validate the date/time settings by Xbox OS.
159 * Technically it's possible to connect a floppy drive to Xbox, but
160 * CMOS detection method should not be used here. */
162 WARN("XboxGetFloppyCount() is UNIMPLEMENTED, returning 0\n");
166 PCONFIGURATION_COMPONENT_DATA
169 PCONFIGURATION_COMPONENT_DATA SystemKey
;
172 TRACE("DetectHardware()\n");
174 /* Create the 'System' key */
175 FldrCreateSystemKey(&SystemKey
);
177 GetHarddiskConfigurationData
= XboxGetHarddiskConfigurationData
;
179 /* TODO: Build actual xbox's hardware configuration tree */
180 DetectIsaBios(SystemKey
, &BusNumber
);
182 TRACE("DetectHardware() Done\n");
186 VOID
XboxHwIdle(VOID
)
192 /******************************************************************************/
195 XboxMachInit(const char *CmdLine
)
197 /* Set LEDs to red before anything is initialized */
200 /* Initialize our stuff */
205 MachVtbl
.ConsPutChar
= XboxConsPutChar
;
206 MachVtbl
.ConsKbHit
= XboxConsKbHit
;
207 MachVtbl
.ConsGetCh
= XboxConsGetCh
;
208 MachVtbl
.VideoClearScreen
= XboxVideoClearScreen
;
209 MachVtbl
.VideoSetDisplayMode
= XboxVideoSetDisplayMode
;
210 MachVtbl
.VideoGetDisplaySize
= XboxVideoGetDisplaySize
;
211 MachVtbl
.VideoGetBufferSize
= XboxVideoGetBufferSize
;
212 MachVtbl
.VideoGetFontsFromFirmware
= XboxVideoGetFontsFromFirmware
;
213 MachVtbl
.VideoHideShowTextCursor
= XboxVideoHideShowTextCursor
;
214 MachVtbl
.VideoPutChar
= XboxVideoPutChar
;
215 MachVtbl
.VideoCopyOffScreenBufferToVRAM
= XboxVideoCopyOffScreenBufferToVRAM
;
216 MachVtbl
.VideoIsPaletteFixed
= XboxVideoIsPaletteFixed
;
217 MachVtbl
.VideoSetPaletteColor
= XboxVideoSetPaletteColor
;
218 MachVtbl
.VideoGetPaletteColor
= XboxVideoGetPaletteColor
;
219 MachVtbl
.VideoSync
= XboxVideoSync
;
220 MachVtbl
.Beep
= PcBeep
;
221 MachVtbl
.PrepareForReactOS
= XboxPrepareForReactOS
;
222 MachVtbl
.GetMemoryMap
= XboxMemGetMemoryMap
;
223 MachVtbl
.GetExtendedBIOSData
= XboxGetExtendedBIOSData
;
224 MachVtbl
.GetFloppyCount
= XboxGetFloppyCount
;
225 MachVtbl
.DiskGetBootPath
= DiskGetBootPath
;
226 MachVtbl
.DiskReadLogicalSectors
= XboxDiskReadLogicalSectors
;
227 MachVtbl
.DiskGetDriveGeometry
= XboxDiskGetDriveGeometry
;
228 MachVtbl
.DiskGetCacheableBlockCount
= XboxDiskGetCacheableBlockCount
;
229 MachVtbl
.GetTime
= XboxGetTime
;
230 MachVtbl
.InitializeBootDevices
= PcInitializeBootDevices
;
231 MachVtbl
.HwDetect
= XboxHwDetect
;
232 MachVtbl
.HwIdle
= XboxHwIdle
;
234 DiskGetPartitionEntry
= XboxDiskGetPartitionEntry
;
236 /* Set LEDs to orange after init */
241 XboxPrepareForReactOS(VOID
)
243 /* On XBOX, prepare video and turn off the floppy motor */
244 XboxVideoPrepareForReactOS();
245 DiskStopFloppyMotor();