- Bless halxbox too.
[reactos.git] / reactos / hal / halx86 / xbox / pci_xbox.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: hal/halx86/xbox/pci_xbox.c
6 * PURPOSE: Xbox specific handling of PCI cards
7 * PROGRAMMER: Ge van Geldorp (gvg@reactos.com)
8 * UPDATE HISTORY:
9 * 2004/12/04: Created
10 *
11 * Trying to get PCI config data from devices 0:0:1 and 0:0:2 will completely
12 * hang the Xbox. Also, the device number doesn't seem to be decoded for the
13 * video card, so it appears to be present on 1:0:0 - 1:31:0.
14 * We hack around these problems by indicating "device not present" for devices
15 * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0
16 */
17
18 /* INCLUDES *****************************************************************/
19
20 #include <halxbox.h>
21
22 #define NDEBUG
23 #include <debug.h>
24
25 /* VARIABLES ***************************************************************/
26
27 static ULONG (STDCALL *GenericGetPciData)(PBUS_HANDLER BusHandler,
28 ULONG BusNumber,
29 ULONG SlotNumber,
30 PVOID Buffer,
31 ULONG Offset,
32 ULONG Length);
33 static ULONG (STDCALL *GenericSetPciData)(PBUS_HANDLER BusHandler,
34 ULONG BusNumber,
35 ULONG SlotNumber,
36 PVOID Buffer,
37 ULONG Offset,
38 ULONG Length);
39
40 /* FUNCTIONS ***************************************************************/
41
42 static ULONG STDCALL
43 HalpXboxGetPciData(PBUS_HANDLER BusHandler,
44 ULONG BusNumber,
45 ULONG SlotNumber,
46 PVOID Buffer,
47 ULONG Offset,
48 ULONG Length)
49 {
50 DPRINT("HalpXboxGetPciData() called.\n");
51 DPRINT(" BusNumber %lu\n", BusNumber);
52 DPRINT(" SlotNumber %lu\n", SlotNumber);
53 DPRINT(" Offset 0x%lx\n", Offset);
54 DPRINT(" Length 0x%lx\n", Length);
55
56 if ((0 == BusNumber && 0 == (SlotNumber & 0x1f) &&
57 (1 == ((SlotNumber >> 5) & 0x07) || 2 == ((SlotNumber >> 5) & 0x07))) ||
58 (1 == BusNumber && 0 != (SlotNumber & 0x1f)))
59 {
60 DPRINT("Blacklisted PCI slot\n");
61 if (0 == Offset && 2 <= Length)
62 {
63 *(PUSHORT)Buffer = PCI_INVALID_VENDORID;
64 return 2;
65 }
66 return 0;
67 }
68
69 return GenericGetPciData(BusHandler, BusNumber, SlotNumber, Buffer, Offset, Length);
70 }
71
72 static ULONG STDCALL
73 HalpXboxSetPciData(PBUS_HANDLER BusHandler,
74 ULONG BusNumber,
75 ULONG SlotNumber,
76 PVOID Buffer,
77 ULONG Offset,
78 ULONG Length)
79 {
80 DPRINT("HalpXboxSetPciData() called.\n");
81 DPRINT(" BusNumber %lu\n", BusNumber);
82 DPRINT(" SlotNumber %lu\n", SlotNumber);
83 DPRINT(" Offset 0x%lx\n", Offset);
84 DPRINT(" Length 0x%lx\n", Length);
85
86 if ((0 == BusNumber && 0 == (SlotNumber & 0x1f) &&
87 (1 == ((SlotNumber >> 5) & 0x07) || 2 == ((SlotNumber >> 5) & 0x07))) ||
88 (1 == BusNumber && 0 != (SlotNumber & 0x1f)))
89 {
90 DPRINT1("Trying to set data on blacklisted PCI slot\n");
91 return 0;
92 }
93
94 return GenericSetPciData(BusHandler, BusNumber, SlotNumber, Buffer, Offset, Length);
95 }
96
97 void
98 HalpXboxInitPciBus(ULONG BusNumber, PBUS_HANDLER BusHandler)
99 {
100 if (0 == BusNumber || 1 == BusNumber)
101 {
102 GenericGetPciData = BusHandler->GetBusData;
103 BusHandler->GetBusData = HalpXboxGetPciData;
104 GenericSetPciData = BusHandler->SetBusData;
105 BusHandler->SetBusData = HalpXboxSetPciData;
106 }
107 }
108
109 /* EOF */