migrate substitution keywords to SVN
[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 <ddk/ntddk.h>
21 #include <hal.h>
22 #include <bus.h>
23 #include "halxbox.h"
24
25 #define NDEBUG
26 #include <internal/debug.h>
27
28 /* VARIABLES ***************************************************************/
29
30 static ULONG (STDCALL *GenericGetPciData)(PBUS_HANDLER BusHandler,
31 ULONG BusNumber,
32 ULONG SlotNumber,
33 PVOID Buffer,
34 ULONG Offset,
35 ULONG Length);
36 static ULONG (STDCALL *GenericSetPciData)(PBUS_HANDLER BusHandler,
37 ULONG BusNumber,
38 ULONG SlotNumber,
39 PVOID Buffer,
40 ULONG Offset,
41 ULONG Length);
42
43 /* FUNCTIONS ***************************************************************/
44
45 static ULONG STDCALL
46 HalpXboxGetPciData(PBUS_HANDLER BusHandler,
47 ULONG BusNumber,
48 ULONG SlotNumber,
49 PVOID Buffer,
50 ULONG Offset,
51 ULONG Length)
52 {
53 DPRINT("HalpXboxGetPciData() called.\n");
54 DPRINT(" BusNumber %lu\n", BusNumber);
55 DPRINT(" SlotNumber %lu\n", SlotNumber);
56 DPRINT(" Offset 0x%lx\n", Offset);
57 DPRINT(" Length 0x%lx\n", Length);
58
59 if ((0 == BusNumber && 0 == (SlotNumber & 0x1f) &&
60 (1 == ((SlotNumber >> 5) & 0x07) || 2 == ((SlotNumber >> 5) & 0x07))) ||
61 (1 == BusNumber && 0 != (SlotNumber & 0x1f)))
62 {
63 DPRINT("Blacklisted PCI slot\n");
64 if (0 == Offset && 2 <= Length)
65 {
66 *(PUSHORT)Buffer = PCI_INVALID_VENDORID;
67 return 2;
68 }
69 return 0;
70 }
71
72 return GenericGetPciData(BusHandler, BusNumber, SlotNumber, Buffer, Offset, Length);
73 }
74
75 static ULONG STDCALL
76 HalpXboxSetPciData(PBUS_HANDLER BusHandler,
77 ULONG BusNumber,
78 ULONG SlotNumber,
79 PVOID Buffer,
80 ULONG Offset,
81 ULONG Length)
82 {
83 DPRINT("HalpXboxSetPciData() called.\n");
84 DPRINT(" BusNumber %lu\n", BusNumber);
85 DPRINT(" SlotNumber %lu\n", SlotNumber);
86 DPRINT(" Offset 0x%lx\n", Offset);
87 DPRINT(" Length 0x%lx\n", Length);
88
89 if ((0 == BusNumber && 0 == (SlotNumber & 0x1f) &&
90 (1 == ((SlotNumber >> 5) & 0x07) || 2 == ((SlotNumber >> 5) & 0x07))) ||
91 (1 == BusNumber && 0 != (SlotNumber & 0x1f)))
92 {
93 DPRINT1("Trying to set data on blacklisted PCI slot\n");
94 return 0;
95 }
96
97 return GenericSetPciData(BusHandler, BusNumber, SlotNumber, Buffer, Offset, Length);
98 }
99
100 void
101 HalpXboxInitPciBus(ULONG BusNumber, PBUS_HANDLER BusHandler)
102 {
103 if (0 == BusNumber || 1 == BusNumber)
104 {
105 GenericGetPciData = BusHandler->GetBusData;
106 BusHandler->GetBusData = HalpXboxGetPciData;
107 GenericSetPciData = BusHandler->SetBusData;
108 BusHandler->SetBusData = HalpXboxSetPciData;
109 }
110 }
111
112 /* EOF */