Fixes MS storport.sys not being able to work with the qla1xxx.sys driver.
Storport miniport drivers use the PCIConfiguration value
to access the PCI configuration space
(see StorPortGetBusData and StorPortSetBusDataByOffset).
CORE-13866 CORE-20545 CORE-20628
* [PCIX] Use the bridge's parent bus in the IRQ translator constructor
* [PCIX] Stop the limit descriptor scan from running off the array
* [PCIX] Build a real resource requirements list for each function
* [PCIX] Skip the right descriptors when draining a device-private group
* [PCIX] Record assigned resources against the BAR they satisfy
* [PCIX] Program device BARs with their arbitrated addresses
---------
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
DebugPrint starts a va_list with va_start and formats from it, but never
calls va_end on any path. On the targets ReactOS builds for this happens
to be harmless, but it is undefined behaviour and breaks on any ABI
where va_end has real work to do.
The VIRTIO_DBG_USE_IOPORT block has the same problem in a worse form: it
hands the list to RtlStringCbVPrintfA after PrintProcedure has already
walked it, so on that configuration the second pass formats from an
indeterminate va_list. End the list right after the first consumer and
start a fresh one for the second, ending that too.
netkvm is listed in media/doc/3rd Party Files.txt, but the entry pins a
commit-tree URL rather than a branch, because upstream virtio-win
deleted its NDIS5 driver: this copy has no live upstream to send the fix
to, and ReactOS has already patched this same file locally. Hence
ReactOS rather than virtio-win, and no __REACTOS__ guard - there are
none anywhere in this directory.
CORE-15841
Reviewed-by: Whindmar Saksit <whindsaks@proton.me>
Reviewed-by: Stanislav Motylkov <x86corez@gmail.com>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Signed-off-by: John Rowe <opensource@rowe.lol>
* [PCIX][NTOS:IO][ARBITER] Rename the default callbacks
* [SDK:ARBITER] Implement OrderingList Support
This implements the arbiter ordering list.
When you have a PCI device let's say and it provides a wide range of placements that satisfies it, Arbiter has some functionality to apply some "preferred rule-sets" even before these assignments start happening. While windows can Rebalance PNP, there are some quirks that the kernel can't immediately see right away. So this was more for some BIOSes to have a static set of rules and avoid rebalancing too many times per boot as this was expensive, and couldn't account for ALL of these quirks.
Honestly if you are super bored and care that much about these things you can pull up BIOSINFO.inf on different installs of pre-vista windows and see what kind of vendor hooks exists, There's a lot. Vista prebakes this.
Since Windows 11 24H2 (host build 26100), Hyper-V's emulated PS/2
mouse reports vertical movement already in Windows orientation, so
the usual PS/2 -> Windows Y inversion made the pointer move
backwards. The same host regression also affects other legacy
guests such as Windows XP.
Detect this via the CPUID hypervisor interface (Hyper-V signature
and host build number) combined with the SMBIOS system identity,
so that other hypervisors exposing the Hyper-V CPUID interface
(e.g. VMware/VirtualBox on top of the Windows Hypervisor Platform)
are never affected, and skip the Y negation in that case.
Also OR the flags in the SMBIOS hardware table matching instead of
overwriting them, so flags set by other detections are preserved.
CORE-20561
Signed-off-by: Pavel Parfenov <pavel.parfenov91@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Debug more members of PCFILTER_DESCRIPTOR and its sub-items (PCPIN_DESCRIPTOR, PCNODE_DESCRIPTOR and PCCONNECTION_DESCRIPTOR).
This allows to achieve the following things:
1) Actually debug more contents from the internal Filter Descriptor's definition of any audio miniport driver, including proprietary ones (e. g., Intel AC97, Realtek HD Audio codec etc.), and therefore to learn better how the Filters, Pins, Nodes and Connections are organized inside it.
2) Hence the proper debugging of them is also very useful and helpful for developing new audio miniport drivers both for Windows and ReactOS as well (as an example, it helps a lot to develop a new generic HD audio miniport driver for ReactOS personally for me).
Proposed changes:
- Debug DataFlow, Communication, Category and Name fields of all Pins and Nodes inside Filter Descriptor in particular. This allows to see the actual names and types for the audio-related items, to know whether the Pin or Node is of an input, output or bridge type and which is its actual purpose (for example, which thing the Node should do: Volume, Mute, Mux etc. and with which extental physical or virtual device the Pin is associated: WaveOut, WaveIn, Topology Speaker, Microphone, Headphones etc.).
- Reorganize debug output of the Connections list: first debug FromNode and ToNode, and only then FromPin and ToPin fields of PCCONNECTION_DESCRIPTOR. This follows the original sequence of the members in the structure as it's defined at MSDN and improves readability and understandability of the Connections list in general (at least personally for me).
- Wrap debug-only functions into #if DBG condition, to ensure they are enabled only for debug builds, but not for release ones.
- Enable the call of the main DumpFilterDescriptor() debug routine inside PcCreateSubdeviceDescriptor() (which actually converts audio miniport's Filter Descriptor to the understandable format for the system PortCls driver), to make it possible to debug it at all. Mute some DPTINTs (debug prints) appropriately, so now debug output is printed ONLY in case when NDEBUG is NOT defined (so hence it's possible to get it by either disabling #define NDEBUG line at the top, or modifying it to #define YDEBUG instead). Since no any other debug prints are currently added in this source file (undoc.cpp), nothing else will be printed except Filter Descriptor debugging.
- Fix code formatting for all related "for()" loops a little bit. Add one space between the for keyword and the condition of the loop iteration.
Fix an out of bounds heap read when compacting the ghost device list.
Change the loop condition from `GhostPort < DeviceRelations->Count` to
`GhostPort < DeviceRelations->Count - 1` so the array shift never reads
past the last valid entry.
Fix ACPI table discovery on the UEFI boot path by teaching the ACPI OSL
to use the loader-provided ACPI root table information instead of relying
only on legacy BIOS RSDP scanning:
- Build a synthetic RSDP from the ACPI BIOS configuration node
populated by the bootloader
- Fallback to the old scan only if that data is unavailable
- Keep full 64-bit physical addresses when mapping ACPI tables
- Improve failure diagnostics if initialization still fails
This lets ACPICA initialize from the UEFI-provided RSDT/XSDT path.
CORE-11954
So QEMU Q35 on UEFI is now able to discover ACPI tables through the loader-
provided root table path, which fixes 0x7B INACCESSIBLE_BOOT_DEVICE bugcheck:
https://github.com/user-attachments/assets/25d4d9c9-4197-496b-84f9-e5642c65809d
AddControllers already disconnects the controller interrupt on its error paths but left InterruptObject pointing at the freed object.
Now that DriverEntry runs Cleanup on failure (and Unload() routes through it too), that stale pointer is handed to IoDisconnectInterrupt a second time, bugchecking with BAD_POOL_HEADER.
Clear InterruptObject right after disconnecting so Cleanup() skips it.
CORE-20669
- Fix memory leak in WdmAudGetDeviceInterface() (FreeItem(Device) was not called on STATUS_BUFFER_OVERFLOW early return path).
- Wrap user-mode buffer write in ProbeForWrite() + SEH2().
Import the following upstream commits:
30a807de7d76dbc244c3afb1d55817da286c78245477b93a3b
which contain new supported devices added in inf file and two bugfixes from me, which fix all playback distortions with all XP-compatible HD audio codecs.
Tested and works fine with Realtek HD audio codec R2.74 on ALC660 controller at least, but it still needs to be tested with other codecs as well (like SigmaTel etc.).
Also update the commit hash in 3rd party files.txt appropriately.
Remove *_new prefix from the new HDAudBus driver, since it's now used by default and the previous (old) one was removed.
[DOC] Update the path of the new HDAudBus driver to the current actual one.
CORE-20528
Addendum to commit 912c8ad987 (PR #5187)
Fix a bug where "KDCOM/KDGDB_NAME_ON_CD" CMake variables weren't used
as variables, but directly as names.
```
gdb_input.c(243): error C4477: '_snprintf' : format string '%p' requires
an argument of type 'void *', but variadic argument 1 has type 'UINT_PTR'
i386_sup.c(98): error C4090: 'return': different 'const' qualifiers
amd64_sup.c(115): error C4090: 'return': different 'const' qualifiers
```
But add KDGDB compilation only for x86 and x64, since for other
architectures (e.g. ARM) it currently emits the following error:
```
drivers/base/kdgdb/kdgdb.h(149): fatal error C1189: #error:
"Please define relevant macros for your architecture"
```
For the time being, keep the "GDB" build configuration macro, used for
Gitpod testing... but this needs to be replaced with a more robust solution.
Because of this, rename kdgdb.dll to kdcom.dll, and kdcom.dll to kdser.dll
so that GDB is used by default, and we don't get a file name clash too.
Revert also commit 57cf5cdc5d.
This is the same feature as the one that already exists in the
NTOS:KD!kdmain.c module used by the in-kernel KDBG debugger
(GCC builds), first introduced in commit 4ce30245de (r54473),
and documented at:
https://reactos.org/wiki/Debugging#Changing_the_serial_port_address
This feature is useful if one uses a PCI, PCIe, PCMCIA, or ExpressCard
serial card on real hardware (these cards are used e.g. with laptops
without a built-in serial port), or with AMT serial over LAN.
After determining the serial port I/O address (say, 0xCC00), specify
the debug port as follows:
/DEBUGPORT=COM:0xCC00
instead of the usual syntax: /DEBUGPORT=COMn (n an integer).
The same syntax can be used for debugging FreeLoader as well: in the
FREELDR.INI file, add a "Debug" line in the "FREELOADER" section,
as follows:
```
[FREELOADER]
Debug=/DEBUG /DEBUGPORT=COM:0xCC00 /BAUDRATE=115200
```
----
NOTE for KDCOM/KDGDB:
Since `strtoul()` is used, but isn't exported by ntoskrnl, link against
the "strtol" static library that has been introduced in commit d317d4fbcc
(r71481).
Don't loop past the end of the command-line buffer, if the command-line
terminates with a lone "DEBUGPORT" without any extra parameter following.
For example: "some things DEBUGPORT "
- Don't hardcode constant string lengths.
- Use `_strnicmp()` -- Ideally we shouldn't have to unconditionally upcase
the global kernel command-line string to perform substrings comparisons.
- Cast `atol()` returned value to `ULONG`.
- The "IRQ" debugger option was introduced in commit 5a6adb4f13 (r2546).
It was used by the in-kernel GDB stub, to manually wire an interrupt
handler `GspBreakIn()` to allow the debugger to break into the system
when a command is received on the GDB serial port.
Side-remark:
The hooking was done via `HalGetInterruptVector()` + `IoConnectInterrupt()`,
but only at phase 1 initialization when the memory manager was up, which
can be "late" enough during system boot initialization.
Instead of using `IoConnectInterrupt()`, one could have used explicit
`KeInitializeInterrupt()` + `KeConnectInterrupt()` calls that would
have worked much earlier in the boot stage.
- This functionality was soon after disabled in commit c804ca06be (r2946)
in the GDB stub (see `ntoskrnl/kd/gdbstub.c!KdGdbStubInit()`), never
to be re-enabled again.
It was removed completely in commit e160c0fb26 (r14799).
- Since ReactOS was (until recently) always debugged locally using the
in-kernel KDBG debugger, break-in was done with TAB-K keypress,
intercepted by the keyboard driver that triggered a `DbgBreakPoint()`,
thus no break-in via serial port interrupt was necessary.
- Remote debugger break-in detection, which is the standard method that
is used when remote-debugging using KD transport DLLs and WinDbg, was
introduced in commit 12e7593f24 (r25984). As with the rest of debugger
communication and as done on Windows, detection is done by polling the
serial port at certain times, namely in the `KeUpdateSystemTime()`
kernel procedure periodically invoked by the timer interrupt.
This break-in detection was then erroneously removed in commit bf8b9467dc
(r45140), and reinstated in commit 014b23b9a (r56194).
- Parsing of this "IRQ" option was copy-pasted in other modules (FreeLoader,
KDCOM, and KDGDB), even though it was never used. The parsing was then
removed in KDBG itself in commit 95faf65ebf, but left in the other
modules... until now!
Cherry-picking commit
3158b917a2
See https://github.com/bobranten/Ext4Fsd/issues/83 for more information,
and debug traces.
## How to reproduce:
- Format a partition in Ext2 with Paragon Hard Disk Manager 2010 Professional.
- Compile ReactOS with MSVC, ensuring that the driver is compiled with
`EXT2_HTREE_INDEX` defined and set to 1, and with Run-time error checks
enabled with the `/RTC1` flag (this is the default in our source tree).
- Install ReactOS on this partition.
## What's being observed:
After reboot, some filesystem paths are accessed, and the code inside the
`#ifdef EXT2_HTREE_INDEX` block is taken (in ext2/src/dirctl.c#L777-L794).
For some reasons, the retrieved `rc` doesn't get the "expected" value and
the `goto errorout;` path is taken. After this label, `FileIndex` was
reset to `ByteOffset`, which remained uninitialized.
A bugcheck ensues because of the failed check (usage of uninitialized variable).