Skip to content

Commit e6e1646

Browse files
committed
continue bring up
1 parent 1466cee commit e6e1646

15 files changed

Lines changed: 481 additions & 94 deletions

File tree

boot/bootdata/hivesys.inf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,21 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Arbiters\ReservedResources","PCStandard",
348348
00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0a,00,00,00,00,00,ff,ff,0b,00,00,00,00,00,\
349349
08,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,f0,ff,00,00,00,00,ff,ff,ff,ff,00,00,00,00
350350

351+
; "BrokenVideo" reserved-resource profile, used by the PCI bus driver's broken
352+
; video hack (ario_ApplyBrokenVideoHack) for old VGA cards that positively
353+
; decode the full legacy VGA I/O range. It is "PCStandard" with the two VGA
354+
; I/O ranges (0x3B0-0x3BB and 0x3C0-0x3DF) removed, so those ports stay in the
355+
; allocatable pool and can be granted to the broken video device. COM1/COM2/LPT
356+
; and the legacy memory ranges remain reserved. (5 descriptors, ListSize 0xC8.)
357+
HKLM,"SYSTEM\CurrentControlSet\Control\Arbiters\ReservedResources","BrokenVideo",0x000a0001,\
358+
c8,00,00,00,00,00,00,00,\
359+
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00,00,00,01,00,01,00,05,00,00,00,\
360+
00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,f8,02,00,00,00,00,00,00,ff,02,00,00,00,00,00,00,\
361+
08,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,bc,03,00,00,00,00,00,00,be,03,00,00,00,00,00,00,\
362+
08,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,f8,03,00,00,00,00,00,00,ff,03,00,00,00,00,00,00,\
363+
00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0a,00,00,00,00,00,ff,ff,0b,00,00,00,00,00,\
364+
08,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,f0,ff,00,00,00,00,ff,ff,ff,ff,00,00,00,00
365+
351366
HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","NtfsDisable8dot3NameCreation",0x00010003,0
352367
HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","NtfsMftZoneReservation",0x00010003,1
353368
HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","Win31FileSystem",0x00010001,0

drivers/bus/pcix/arb/ar_busno.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ arbusno_Constructor(IN PVOID DeviceExtension,
194194
{
195195
/* Not yet implemented */
196196
UNIMPLEMENTED;
197-
while (TRUE);
198197
}
199198
else
200199
{

drivers/bus/pcix/arb/ar_memio.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ NTAPI
198198
ario_ApplyBrokenVideoHack(IN PPCI_FDO_EXTENSION FdoExtension)
199199
{
200200
PPCI_ARBITER_INSTANCE PciArbiter;
201-
//PARBITER_INSTANCE CommonInstance;
202-
//NTSTATUS Status;
201+
PARBITER_INSTANCE CommonInstance;
202+
NTSTATUS Status;
203203

204204
/* Only valid for root FDOs who are being applied the hack for the first time */
205205
ASSERT(!FdoExtension->BrokenVideoHackApplied);
@@ -210,25 +210,45 @@ ario_ApplyBrokenVideoHack(IN PPCI_FDO_EXTENSION FdoExtension)
210210
SecondaryExtension.Next,
211211
PciArb_Io);
212212
ASSERT(PciArbiter);
213-
#if 0 // when arb exist
213+
if (!PciArbiter) return;
214+
214215
/* Get the Arb instance */
215216
CommonInstance = &PciArbiter->CommonInstance;
216217

217-
/* Free the two lists, enabling full VGA access */
218-
ArbFreeOrderingList(&CommonInstance->OrderingList);
219-
ArbFreeOrderingList(&CommonInstance->ReservedList);
220-
221-
/* Build the ordering for broken video PCI access */
218+
/*
219+
* Rebuild the I/O arbiter's assignment ordering using the "BrokenVideo"
220+
* reserved-resource profile in place of the normal "Pci" one. The standard
221+
* profile reserves (holds back) the legacy VGA I/O ranges 0x3B0-0x3BB and
222+
* 0x3C0-0x3DF so they are not handed out during arbitration; the BrokenVideo
223+
* profile deliberately omits them, leaving those ranges in the allocatable
224+
* pool. That lets an old video card which positively decodes the full VGA
225+
* I/O range (PCI_HACK_VIDEO_LEGACY_DECODE) actually be granted them instead
226+
* of being denied and forced into a fallback.
227+
*
228+
* ArbBuildAssignmentOrdering frees and reinitializes the OrderingList and
229+
* ReservedList itself, so there is no need to free them here first.
230+
*/
222231
Status = ArbBuildAssignmentOrdering(CommonInstance,
223232
L"Pci",
224233
L"BrokenVideo",
225234
NULL);
226-
ASSERT(NT_SUCCESS(Status));
227-
#else
228-
//Status = STATUS_SUCCESS;
229-
UNIMPLEMENTED;
230-
while (TRUE);
231-
#endif
235+
if (!NT_SUCCESS(Status))
236+
{
237+
/* On failure ArbBuildAssignmentOrdering leaves BOTH ordering lists
238+
freed/empty, which would break I/O arbitration for the whole root
239+
bus. Restore the normal "Pci" ordering (the same profile the arbiter
240+
was initialized with) so the bus keeps working, and skip the hack. */
241+
DPRINT1("PCI: ario_ApplyBrokenVideoHack - ArbBuildAssignmentOrdering "
242+
"failed (0x%08lx); is Arbiters\\ReservedResources\\BrokenVideo "
243+
"present in the registry? Restoring normal PCI ordering.\n",
244+
Status);
245+
ArbBuildAssignmentOrdering(CommonInstance,
246+
L"Pci",
247+
L"Pci",
248+
PciArbTranslateOrdering);
249+
return;
250+
}
251+
232252
/* Now the hack has been applied */
233253
FdoExtension->BrokenVideoHackApplied = TRUE;
234254
}

drivers/bus/pcix/debug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ PciDebugPoIrpTypeToText(IN USHORT MinorFunction)
103103
{
104104
PCHAR Text;
105105

106-
/* Catch invalid code */
107-
if (MinorFunction >= IRP_MN_QUERY_POWER)
106+
/* Catch invalid code (QUERY_POWER is the highest code we decode, so only
107+
* strictly-greater minor functions are unknown - the old ">=" mislabeled a
108+
* perfectly valid IRP_MN_QUERY_POWER as "UNKNOWN PO IRP Minor Code") */
109+
if (MinorFunction > IRP_MN_QUERY_POWER)
108110
{
109111
/* New version of Windows? Or driver bug */
110112
Text = "** UNKNOWN PO IRP Minor Code **";

drivers/bus/pcix/enum.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ PciComputeNewCurrentSettings(IN PPCI_PDO_EXTENSION PdoExtension,
6868
if (!ResourceList || !ResourceList->Count)
6969
return PdoExtension->UpdateHardware;
7070

71+
/* Fully zero the array: unmatched slots stay a CLEAN CmResourceTypeNull
72+
(== 0) descriptor. Without this the non-Type fields are uninitialized
73+
stack memory, and the compare-and-update loop below copies that garbage
74+
into Current[] via "*Old = *New" - which is what produced the bogus
75+
"changed to: Type 0, ShareDisposition 0xAB, <pointer>" descriptors in the
76+
bridge START dump. */
77+
RtlZeroMemory(NewResources, sizeof(NewResources));
7178
for (i = 0; i < PCI_MAX_RANGE_COUNT; i++)
7279
{
7380
NewResources[i].Type = CmResourceTypeNull;
@@ -366,8 +373,12 @@ PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension,
366373
/* Are the memory decodes enabled? */
367374
if (HaveMemSpace)
368375
{
369-
/* Build a memory descriptor for a 128KB framebuffer at 0xA0000 */
370-
Resource->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
376+
/* Build a memory descriptor for a 128KB framebuffer at 0xA0000.
377+
This range is forwarded to the VGA device behind the bridge, so
378+
flag it as a forwarding window (CM_RESOURCE_MEMORY_WINDOW_DECODE)
379+
and the child's identical decode will not be seen as a conflict. */
380+
Resource->Flags = CM_RESOURCE_MEMORY_READ_WRITE |
381+
CM_RESOURCE_MEMORY_WINDOW_DECODE;
371382
Resource->u.Generic.Start.HighPart = 0;
372383
Resource->Type = CmResourceTypeMemory;
373384
Resource->u.Generic.Start.LowPart = 0xA0000;
@@ -378,16 +389,23 @@ PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension,
378389
/* Are the I/O decodes enabled? */
379390
if (HaveIoSpace)
380391
{
381-
/* Build an I/O descriptor for the graphic ports at 0x3B0 */
392+
/* Build an I/O descriptor for the graphic ports at 0x3B0. These
393+
legacy VGA ports are forwarded to the child VGA device, so they
394+
are tagged as a forwarding window (CM_RESOURCE_PORT_WINDOW_DECODE)
395+
to avoid a false conflict with the child's own VGA decode. */
382396
Resource->Type = CmResourceTypePort;
383-
Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE | CM_RESOURCE_PORT_10_BIT_DECODE;
397+
Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
398+
CM_RESOURCE_PORT_10_BIT_DECODE |
399+
CM_RESOURCE_PORT_WINDOW_DECODE;
384400
Resource->u.Port.Start.QuadPart = 0x3B0u;
385401
Resource->u.Port.Length = 0xC;
386402
Resource++;
387403

388404
/* Build an I/O descriptor for the graphic ports at 0x3C0 */
389405
Resource->Type = CmResourceTypePort;
390-
Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE | CM_RESOURCE_PORT_10_BIT_DECODE;
406+
Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
407+
CM_RESOURCE_PORT_10_BIT_DECODE |
408+
CM_RESOURCE_PORT_WINDOW_DECODE;
391409
Resource->u.Port.Start.QuadPart = 0x3C0u;
392410
Resource->u.Port.Length = 0x20;
393411
Resource++;

drivers/bus/pcix/hookhal.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,37 @@ NTAPI
2525
PciTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
2626
IN ULONG BusNumber,
2727
IN PHYSICAL_ADDRESS BusAddress,
28-
OUT PULONG AddressSpace,
28+
IN OUT PULONG AddressSpace,
2929
OUT PPHYSICAL_ADDRESS TranslatedAddress)
3030
{
31-
UNREFERENCED_PARAMETER(InterfaceType);
32-
UNREFERENCED_PARAMETER(BusNumber);
33-
UNREFERENCED_PARAMETER(AddressSpace);
31+
/*
32+
* This routine is hooked over the HAL's HalPciTranslateBusAddress (see
33+
* PciHookHal), with the original HAL routine stashed in
34+
* PcipSavedTranslateBusAddress. Like the real pci.sys, the hook itself
35+
* performs no translation arithmetic - it simply defers to the HAL, which
36+
* owns the platform-specific PCI bus-address-to-physical mapping and the
37+
* bus-handler chain (range/offset lookup, I/O vs. memory space, etc.).
38+
* This is recursion-safe: the saved routine (HaliTranslateBusAddress)
39+
* dispatches straight to a bus handler's TranslateBusAddress, never back
40+
* through HalPciTranslateBusAddress.
41+
*/
42+
if (PcipSavedTranslateBusAddress &&
43+
PcipSavedTranslateBusAddress(InterfaceType,
44+
BusNumber,
45+
BusAddress,
46+
AddressSpace,
47+
TranslatedAddress))
48+
{
49+
return TRUE;
50+
}
3451

35-
/* FIXME: Broken translation */
36-
UNIMPLEMENTED;
52+
/*
53+
* Fallback for when the HAL has no registered translator for this PCI bus
54+
* (common during this bring-up, where the new bus driver owns enumeration
55+
* and the legacy HAL PCI bus handler may be absent). On x86 a PCI bus
56+
* address is identity-mapped to the CPU physical address for both memory
57+
* and I/O space, so pass it through unchanged and leave AddressSpace as-is.
58+
*/
3759
TranslatedAddress->QuadPart = BusAddress.QuadPart;
3860
return TRUE;
3961
}

drivers/bus/pcix/intrface/cardbus.c

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,97 @@ PCI_INTERFACE PciCardbusPrivateInterface =
3030

3131
/* FUNCTIONS ******************************************************************/
3232

33+
/*
34+
* CardBus (PCI header type 2) resource configurator.
35+
*
36+
* The only PCI-arbitrated resource of a CardBus bridge is its socket (ExCA)
37+
* registers BAR at offset 0x10. The four card-side memory/I/O decode windows
38+
* (the type2 Range[] registers) are read/write registers programmed by the
39+
* CardBus controller driver, not sizeable BARs, so they are not treated as
40+
* device BARs here.
41+
*/
42+
3343
VOID
3444
NTAPI
35-
Cardbus_SaveCurrentSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
45+
Cardbus_MassageHeaderForLimitsDetermination(IN PPCI_CONFIGURATOR_CONTEXT Context)
3646
{
37-
UNREFERENCED_PARAMETER(Context);
38-
UNIMPLEMENTED_DBGBREAK();
47+
PPCI_COMMON_HEADER PciData, Current;
48+
49+
PciData = Context->PciData;
50+
Current = Context->Current;
51+
52+
/* Write all 1s to the socket-registers BAR; the read-back shows which bits
53+
are hardwired to 0, which gives the BAR length. */
54+
PciData->u.type2.SocketRegistersBaseAddress = 0xFFFFFFFF;
55+
56+
/* Preserve the bus-number and latency fields across the discovery write */
57+
PciData->u.type2.PrimaryBus = Current->u.type2.PrimaryBus;
58+
PciData->u.type2.SecondaryBus = Current->u.type2.SecondaryBus;
59+
PciData->u.type2.SubordinateBus = Current->u.type2.SubordinateBus;
60+
PciData->u.type2.SecondaryLatency = Current->u.type2.SecondaryLatency;
61+
62+
/* The card decode windows (Range[]) are not sizeable BARs; leave them at
63+
their current values so they are written back unchanged. */
64+
65+
/* Save and clear the write-1-to-clear secondary status register */
66+
Context->SecondaryStatus = Current->u.type2.SecondaryStatus;
67+
Current->u.type2.SecondaryStatus = 0;
68+
PciData->u.type2.SecondaryStatus = 0;
3969
}
4070

4171
VOID
4272
NTAPI
4373
Cardbus_SaveLimits(IN PPCI_CONFIGURATOR_CONTEXT Context)
4474
{
45-
UNREFERENCED_PARAMETER(Context);
46-
UNIMPLEMENTED_DBGBREAK();
75+
PPCI_COMMON_HEADER PciData;
76+
PPCI_FUNCTION_RESOURCES Resources;
77+
78+
/* PciData holds the sized BAR mask read back after the all-1s write */
79+
PciData = Context->PciData;
80+
Resources = Context->PdoExtension->Resources;
81+
82+
/* Build the limit descriptor for the socket-registers memory BAR. The
83+
remaining limit descriptors are left NULL (the caller zeroed them). */
84+
PciCreateIoDescriptorFromBarLimit(&Resources->Limit[0],
85+
&PciData->u.type2.SocketRegistersBaseAddress,
86+
FALSE);
4787
}
4888

4989
VOID
5090
NTAPI
51-
Cardbus_MassageHeaderForLimitsDetermination(IN PPCI_CONFIGURATOR_CONTEXT Context)
91+
Cardbus_SaveCurrentSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
5292
{
53-
UNREFERENCED_PARAMETER(Context);
54-
UNIMPLEMENTED_DBGBREAK();
93+
PPCI_COMMON_HEADER Current;
94+
PPCI_FUNCTION_RESOURCES Resources;
95+
PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor;
96+
PIO_RESOURCE_DESCRIPTOR IoDescriptor;
97+
98+
Current = Context->Current;
99+
Resources = Context->PdoExtension->Resources;
100+
101+
/* Mirror the socket BAR's limit descriptor into a current-setting one,
102+
using the live (programmed) base address. */
103+
CmDescriptor = &Resources->Current[0];
104+
IoDescriptor = &Resources->Limit[0];
105+
106+
CmDescriptor->Type = IoDescriptor->Type;
107+
if (CmDescriptor->Type != CmResourceTypeNull)
108+
{
109+
CmDescriptor->Flags = IoDescriptor->Flags;
110+
CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
111+
CmDescriptor->u.Generic.Start.HighPart = 0;
112+
CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
113+
CmDescriptor->u.Memory.Start.LowPart =
114+
Current->u.type2.SocketRegistersBaseAddress & PCI_ADDRESS_MEMORY_ADDRESS_MASK;
115+
}
55116
}
56117

57118
VOID
58119
NTAPI
59120
Cardbus_RestoreCurrent(IN PPCI_CONFIGURATOR_CONTEXT Context)
60121
{
61-
UNREFERENCED_PARAMETER(Context);
62-
UNIMPLEMENTED_DBGBREAK();
122+
/* Restore the secondary status register saved during massaging */
123+
Context->Current->u.type2.SecondaryStatus = Context->SecondaryStatus;
63124
}
64125

65126
VOID
@@ -71,7 +132,9 @@ Cardbus_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context,
71132
UNREFERENCED_PARAMETER(Context);
72133
UNREFERENCED_PARAMETER(PciData);
73134
UNREFERENCED_PARAMETER(IoDescriptor);
74-
UNIMPLEMENTED_DBGBREAK();
135+
136+
/* A CardBus bridge exposes no additional fixed legacy resources here; the
137+
card-side windows are owned by the CardBus controller driver. */
75138
}
76139

77140
VOID
@@ -81,7 +144,8 @@ Cardbus_ResetDevice(IN PPCI_PDO_EXTENSION PdoExtension,
81144
{
82145
UNREFERENCED_PARAMETER(PdoExtension);
83146
UNREFERENCED_PARAMETER(PciData);
84-
UNIMPLEMENTED_DBGBREAK();
147+
148+
/* No special reset handling required for a CardBus bridge. */
85149
}
86150

87151
VOID
@@ -91,7 +155,12 @@ Cardbus_ChangeResourceSettings(IN PPCI_PDO_EXTENSION PdoExtension,
91155
{
92156
UNREFERENCED_PARAMETER(PdoExtension);
93157
UNREFERENCED_PARAMETER(PciData);
94-
UNIMPLEMENTED_DBGBREAK();
158+
159+
/*
160+
* PciData already holds the bridge's live configuration (read by
161+
* PciSetResources). The socket BAR and the card decode windows keep their
162+
* firmware-programmed values, so there is nothing to reprogram here.
163+
*/
95164
}
96165

97166
NTSTATUS
@@ -119,9 +188,7 @@ pcicbintrf_Constructor(IN PVOID DeviceExtension,
119188
UNREFERENCED_PARAMETER(Version);
120189
UNREFERENCED_PARAMETER(Size);
121190
UNREFERENCED_PARAMETER(Interface);
122-
123-
/* Not yet implemented */
124-
UNIMPLEMENTED_DBGBREAK();
191+
DPRINT1("PCI pcicbintrf_Constructor, unexpected call.\n");
125192
return STATUS_NOT_IMPLEMENTED;
126193
}
127194

0 commit comments

Comments
 (0)