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
);
26 // NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
27 // but without extended geometry support.
29 PCM_PARTIAL_RESOURCE_LIST
30 XboxGetHarddiskConfigurationData(UCHAR DriveNumber
, ULONG
* pSize
)
32 PCM_PARTIAL_RESOURCE_LIST PartialResourceList
;
33 PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
34 //EXTENDED_GEOMETRY ExtGeometry;
39 // Initialize returned size
43 /* Set 'Configuration Data' value */
44 Size
= sizeof(CM_PARTIAL_RESOURCE_LIST
) +
45 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
46 PartialResourceList
= FrLdrHeapAlloc(Size
, TAG_HW_RESOURCE_LIST
);
47 if (PartialResourceList
== NULL
)
49 ERR("Failed to allocate a full resource descriptor\n");
53 memset(PartialResourceList
, 0, Size
);
54 PartialResourceList
->Version
= 1;
55 PartialResourceList
->Revision
= 1;
56 PartialResourceList
->Count
= 1;
57 PartialResourceList
->PartialDescriptors
[0].Type
=
58 CmResourceTypeDeviceSpecific
;
59 // PartialResourceList->PartialDescriptors[0].ShareDisposition =
60 // PartialResourceList->PartialDescriptors[0].Flags =
61 PartialResourceList
->PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
62 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
64 /* Get pointer to geometry data */
65 DiskGeometry
= (PVOID
)(((ULONG_PTR
)PartialResourceList
) + sizeof(CM_PARTIAL_RESOURCE_LIST
));
67 /* Get the disk geometry */
68 //ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
70 if (MachDiskGetDriveGeometry(DriveNumber
, &Geometry
))
72 DiskGeometry
->BytesPerSector
= Geometry
.BytesPerSector
;
73 DiskGeometry
->NumberOfCylinders
= Geometry
.Cylinders
;
74 DiskGeometry
->SectorsPerTrack
= Geometry
.Sectors
;
75 DiskGeometry
->NumberOfHeads
= Geometry
.Heads
;
79 ERR("Reading disk geometry failed\n");
80 FrLdrHeapFree(PartialResourceList
, TAG_HW_RESOURCE_LIST
);
83 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
85 DiskGeometry
->NumberOfCylinders
,
86 DiskGeometry
->NumberOfHeads
,
87 DiskGeometry
->SectorsPerTrack
,
88 DiskGeometry
->BytesPerSector
);
91 // Return configuration data
94 return PartialResourceList
;
99 DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey
, ULONG
*BusNumber
)
101 PCM_PARTIAL_RESOURCE_LIST PartialResourceList
;
102 PCONFIGURATION_COMPONENT_DATA BusKey
;
105 /* Set 'Configuration Data' value */
106 Size
= sizeof(CM_PARTIAL_RESOURCE_LIST
) -
107 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
108 PartialResourceList
= FrLdrHeapAlloc(Size
, TAG_HW_RESOURCE_LIST
);
109 if (PartialResourceList
== NULL
)
111 TRACE("Failed to allocate resource descriptor\n");
115 /* Initialize resource descriptor */
116 memset(PartialResourceList
, 0, Size
);
117 PartialResourceList
->Version
= 1;
118 PartialResourceList
->Revision
= 1;
119 PartialResourceList
->Count
= 0;
121 /* Create new bus key */
122 FldrCreateComponentKey(SystemKey
,
124 MultiFunctionAdapter
,
133 /* Increment bus number */
136 /* Detect ISA/BIOS devices */
137 DetectBiosDisks(SystemKey
, BusKey
);
139 /* FIXME: Detect more ISA devices */
142 PCONFIGURATION_COMPONENT_DATA
145 PCONFIGURATION_COMPONENT_DATA SystemKey
;
148 TRACE("DetectHardware()\n");
150 /* Create the 'System' key */
151 FldrCreateSystemKey(&SystemKey
);
153 GetHarddiskConfigurationData
= XboxGetHarddiskConfigurationData
;
155 /* TODO: Build actual xbox's hardware configuration tree */
156 DetectIsaBios(SystemKey
, &BusNumber
);
158 TRACE("DetectHardware() Done\n");
162 VOID
XboxHwIdle(VOID
)
168 /******************************************************************************/
171 XboxMachInit(const char *CmdLine
)
173 /* Set LEDs to red before anything is initialized */
176 /* Initialize our stuff */
181 MachVtbl
.ConsPutChar
= XboxConsPutChar
;
182 MachVtbl
.ConsKbHit
= XboxConsKbHit
;
183 MachVtbl
.ConsGetCh
= XboxConsGetCh
;
184 MachVtbl
.VideoClearScreen
= XboxVideoClearScreen
;
185 MachVtbl
.VideoSetDisplayMode
= XboxVideoSetDisplayMode
;
186 MachVtbl
.VideoGetDisplaySize
= XboxVideoGetDisplaySize
;
187 MachVtbl
.VideoGetBufferSize
= XboxVideoGetBufferSize
;
188 MachVtbl
.VideoHideShowTextCursor
= XboxVideoHideShowTextCursor
;
189 MachVtbl
.VideoPutChar
= XboxVideoPutChar
;
190 MachVtbl
.VideoCopyOffScreenBufferToVRAM
= XboxVideoCopyOffScreenBufferToVRAM
;
191 MachVtbl
.VideoIsPaletteFixed
= XboxVideoIsPaletteFixed
;
192 MachVtbl
.VideoSetPaletteColor
= XboxVideoSetPaletteColor
;
193 MachVtbl
.VideoGetPaletteColor
= XboxVideoGetPaletteColor
;
194 MachVtbl
.VideoSync
= XboxVideoSync
;
195 MachVtbl
.Beep
= PcBeep
;
196 MachVtbl
.PrepareForReactOS
= XboxPrepareForReactOS
;
197 MachVtbl
.GetMemoryMap
= XboxMemGetMemoryMap
;
198 MachVtbl
.DiskGetBootPath
= DiskGetBootPath
;
199 MachVtbl
.DiskReadLogicalSectors
= XboxDiskReadLogicalSectors
;
200 MachVtbl
.DiskGetDriveGeometry
= XboxDiskGetDriveGeometry
;
201 MachVtbl
.DiskGetCacheableBlockCount
= XboxDiskGetCacheableBlockCount
;
202 MachVtbl
.GetTime
= XboxGetTime
;
203 MachVtbl
.InitializeBootDevices
= PcInitializeBootDevices
;
204 MachVtbl
.HwDetect
= XboxHwDetect
;
205 MachVtbl
.HwIdle
= XboxHwIdle
;
207 DiskGetPartitionEntry
= XboxDiskGetPartitionEntry
;
209 /* Set LEDs to orange after init */
214 XboxPrepareForReactOS(VOID
)
216 /* On XBOX, prepare video and turn off the floppy motor */
217 XboxVideoPrepareForReactOS();
218 DiskStopFloppyMotor();