ReactOS  0.4.13-dev-247-g0f29b3f
machxbox.c
Go to the documentation of this file.
1 /*
2  * FreeLoader
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #include <freeldr.h>
20 
21 #include <debug.h>
22 
23 DBG_DEFAULT_CHANNEL(HWDETECT);
24 
25 
26 // NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
27 // but without extended geometry support.
28 static
31 {
32  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
33  PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
34  //EXTENDED_GEOMETRY ExtGeometry;
35  GEOMETRY Geometry;
36  ULONG Size;
37 
38  //
39  // Initialize returned size
40  //
41  *pSize = 0;
42 
43  /* Set 'Configuration Data' value */
44  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
46  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
47  if (PartialResourceList == NULL)
48  {
49  ERR("Failed to allocate a full resource descriptor\n");
50  return NULL;
51  }
52 
53  memset(PartialResourceList, 0, Size);
54  PartialResourceList->Version = 1;
55  PartialResourceList->Revision = 1;
56  PartialResourceList->Count = 1;
57  PartialResourceList->PartialDescriptors[0].Type =
59 // PartialResourceList->PartialDescriptors[0].ShareDisposition =
60 // PartialResourceList->PartialDescriptors[0].Flags =
61  PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
63 
64  /* Get pointer to geometry data */
65  DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
66 
67  /* Get the disk geometry */
68  //ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
69 
70  if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
71  {
72  DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
73  DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
74  DiskGeometry->SectorsPerTrack = Geometry.Sectors;
75  DiskGeometry->NumberOfHeads = Geometry.Heads;
76  }
77  else
78  {
79  ERR("Reading disk geometry failed\n");
80  FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
81  return NULL;
82  }
83  TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
84  DriveNumber,
85  DiskGeometry->NumberOfCylinders,
86  DiskGeometry->NumberOfHeads,
87  DiskGeometry->SectorsPerTrack,
88  DiskGeometry->BytesPerSector);
89 
90  //
91  // Return configuration data
92  //
93  *pSize = Size;
94  return PartialResourceList;
95 }
96 
97 static
98 VOID
100 {
101  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
103  ULONG Size;
104 
105  /* Set 'Configuration Data' value */
106  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
108  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
109  if (PartialResourceList == NULL)
110  {
111  TRACE("Failed to allocate resource descriptor\n");
112  return;
113  }
114 
115  /* Initialize resource descriptor */
116  memset(PartialResourceList, 0, Size);
117  PartialResourceList->Version = 1;
118  PartialResourceList->Revision = 1;
119  PartialResourceList->Count = 0;
120 
121  /* Create new bus key */
122  FldrCreateComponentKey(SystemKey,
123  AdapterClass,
124  MultiFunctionAdapter,
125  0x0,
126  0x0,
127  0xFFFFFFFF,
128  "ISA",
129  PartialResourceList,
130  Size,
131  &BusKey);
132 
133  /* Increment bus number */
134  (*BusNumber)++;
135 
136  /* Detect ISA/BIOS devices */
137  DetectBiosDisks(SystemKey, BusKey);
138 
139  /* FIXME: Detect more ISA devices */
140 }
141 
144 {
146  ULONG BusNumber = 0;
147 
148  TRACE("DetectHardware()\n");
149 
150  /* Create the 'System' key */
151  FldrCreateSystemKey(&SystemKey);
152 
154 
155  /* TODO: Build actual xbox's hardware configuration tree */
156  DetectIsaBios(SystemKey, &BusNumber);
157 
158  TRACE("DetectHardware() Done\n");
159  return SystemKey;
160 }
161 
163 {
164  /* UNIMPLEMENTED */
165 }
166 
167 
168 /******************************************************************************/
169 
170 VOID
171 XboxMachInit(const char *CmdLine)
172 {
173  /* Set LEDs to red before anything is initialized */
174  XboxSetLED("rrrr");
175 
176  /* Initialize our stuff */
177  XboxMemInit();
178  XboxVideoInit();
179 
180  /* Setup vtbl */
195  MachVtbl.Beep = PcBeep;
206 
208 
209  /* Set LEDs to orange after init */
210  XboxSetLED("oooo");
211 }
212 
213 VOID
215 {
216  /* On XBOX, prepare video and turn off the floppy motor */
219 }
220 
221 /* EOF */
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
BOOLEAN XboxConsKbHit(VOID)
Definition: xboxcons.c:59
PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID)
Definition: machxbox.c:143
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:62
char CmdLine[0x100]
Definition: mach.c:35
#define IN
Definition: typedefs.h:38
DISK_GET_PARTITION_ENTRY DiskGetPartitionEntry
Definition: partition.c:33
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:170
GLint x0
Definition: linetemp.h:95
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
Definition: acpixf.h:816
ULONG Cylinders
Definition: disk.h:26
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:75
BOOLEAN(* DiskGetBootPath)(PCHAR BootPath, ULONG Size)
Definition: machine.h:64
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: xboxvideo.c:196
VOID XboxVideoClearScreen(UCHAR Attr)
Definition: xboxvideo.c:102
VOID XboxConsPutChar(int c)
Definition: xboxcons.c:26
BOOLEAN XboxDiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
Definition: xboxdisk.c:474
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:53
uint32_t ULONG_PTR
Definition: typedefs.h:63
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: hardware.c:42
VOID XboxMemInit(VOID)
Definition: xboxmem.c:32
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:349
int XboxConsGetCh(void)
Definition: xboxcons.c:66
unsigned char BOOLEAN
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:66
smooth NULL
Definition: ftsmooth.c:416
ULONG XboxVideoGetBufferSize(VOID)
Definition: xboxvideo.c:178
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
void * PVOID
Definition: retypes.h:9
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:70
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:122
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:74
BOOLEAN XboxDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: xboxdisk.c:431
BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
Definition: disk.c:102
ULONG Sectors
Definition: disk.h:28
#define TRACE(s)
Definition: solgame.cpp:4
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
DBG_DEFAULT_CHANNEL(HWDETECT)
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:55
BOOLEAN XboxVideoIsPaletteFixed(VOID)
Definition: xboxvideo.c:212
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: hardware.c:353
PFREELDR_MEMORY_DESCRIPTOR XboxMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: xboxmem.c:80
VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: xboxvideo.c:170
VOID XboxHwIdle(VOID)
Definition: machxbox.c:162
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:65
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID XboxVideoSync(VOID)
Definition: xboxvideo.c:230
VOID XboxMachInit(const char *CmdLine)
Definition: machxbox.c:171
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:51
VOID XboxVideoInit(VOID)
Definition: xboxvideo.c:122
void XboxSetLED(PCSTR pattern)
Definition: xboxi2c.c:198
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: xboxvideo.c:112
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:54
VOID PcBeep(VOID)
Definition: i386rtl.c:25
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:190
VOID NTAPI FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN IDENTIFIER_FLAG Flags, IN ULONG Key, IN ULONG Affinity, IN PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
int(* ConsGetCh)(VOID)
Definition: machine.h:43
#define ERR(fmt,...)
Definition: debug.h:109
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:67
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
BOOLEAN XboxDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: xboxdisk.c:500
ULONG BytesPerSector
Definition: disk.h:29
VOID(* HwIdle)(VOID)
Definition: machine.h:76
Definition: disk.h:24
VOID XboxVideoPrepareForReactOS(IN BOOLEAN Setup)
Definition: xboxvideo.c:243
VOID(* VideoSync)(VOID)
Definition: machine.h:56
VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: xboxvideo.c:218
unsigned int ULONG
Definition: retypes.h:1
VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: xboxvideo.c:224
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:52
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init)
Definition: xboxvideo.c:163
MACHVTBL MachVtbl
Definition: machine.c:21
VOID(* Beep)(VOID)
Definition: machine.h:57
#define memset(x, y, z)
Definition: compat.h:39
TIMEINFO * XboxGetTime(VOID)
Definition: xboxrtc.c:40
static VOID DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machxbox.c:99
static PCM_PARTIAL_RESOURCE_LIST XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machxbox.c:30
struct _CM_DISK_GEOMETRY_DEVICE_DATA CM_DISK_GEOMETRY_DEVICE_DATA
VOID XboxPrepareForReactOS(IN BOOLEAN Setup)
Definition: machxbox.c:214
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
ULONG XboxDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: xboxdisk.c:560
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:50
VOID(* PrepareForReactOS)(IN BOOLEAN Setup)
Definition: machine.h:58
VOID DiskStopFloppyMotor(VOID)
Definition: macharm.c:62
ULONG Heads
Definition: disk.h:27