ReactOS 0.4.17-dev-116-ga4b6fe9
miniport.c File Reference
#include "pciidex.h"
Include dependency graph for miniport.c:

Go to the source code of this file.

Functions

IDE_CHANNEL_STATE PciIdeXChannelState (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Channel)
 
VOID PciIdeXDebugPrint (_In_ ULONG DebugPrintLevel, _In_z_ _Printf_format_string_ PCCHAR DebugMessage,...)
 Prints the given string with printf-like formatting to the kernel debugger.
 
NTSTATUS NTAPI PciIdeXGetBusData (_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 
NTSTATUS NTAPI PciIdeXSetBusData (_In_ PVOID DeviceExtension, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_reads_bytes_(BufferLength) PVOID DataMask, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 
NTSTATUS NTAPI PciIdexGetBusLocation (_In_ PVOID DeviceExtension, _Out_ PULONG BusLocation)
 

Variables

ULONG PciIdeDebug = 0
 Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
 

Function Documentation

◆ PciIdeXChannelState()

IDE_CHANNEL_STATE PciIdeXChannelState ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Channel 
)

Definition at line 15 of file miniport.c.

18{
19 PCIIDE_CHANNEL_ENABLED MiniportChannelEnabled;
20
21 PAGED_CODE();
22
23 MiniportChannelEnabled = FdoExtension->Properties.PciIdeChannelEnabled;
24 if (MiniportChannelEnabled)
25 return MiniportChannelEnabled(FdoExtension->MiniControllerExtension, Channel);
26
28}
#define PAGED_CODE()
@ FdoExtension
Definition: precomp.h:48
@ ChannelStateUnknown
Definition: ide.h:199
IDE_CHANNEL_STATE(NTAPI * PCIIDE_CHANNEL_ENABLED)(_In_ PVOID DeviceExtension, _In_ ULONG Channel)
Definition: ide.h:203
_In_ ULONG Channel
Definition: pciidex.h:74

◆ PciIdeXDebugPrint()

VOID PciIdeXDebugPrint ( _In_ ULONG  DebugPrintLevel,
_In_z_ _Printf_format_string_ PCCHAR  DebugMessage,
  ... 
)

Prints the given string with printf-like formatting to the kernel debugger.

Parameters
[in]DebugPrintLevelLevel of the debug message. Valid values are between 0 (Error) and 3 (Trace).
[in]DebugMessageFormat of the string/arguments.
[in]...Variable number of arguments matching the format specified in DebugMessage.
See also
PciIdeDebug

Definition at line 40 of file miniport.c.

44{
45 va_list ap;
46
47 /* Check if we can print anything */
48 if (DebugPrintLevel <= PciIdeDebug)
49 DebugPrintLevel = 0;
50
51 va_start(ap, DebugMessage);
52 vDbgPrintEx(DPFLTR_PCIIDE_ID, DebugPrintLevel, DebugMessage, ap);
53 va_end(ap);
54}
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
@ DPFLTR_PCIIDE_ID
Definition: dpfilter.h:86
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:11
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ PciIdeXGetBusData()

NTSTATUS NTAPI PciIdeXGetBusData ( _In_ PVOID  DeviceExtension,
_Out_writes_bytes_all_(BufferLength) PVOID  Buffer,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 59 of file miniport.c.

64{
66 PATA_CONTROLLER Controller;
68
69 INFO("PciIdeXGetBusData(%p %p 0x%lx 0x%lx)\n",
70 DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
71
72 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
73 Controller = &FdoExt->Controller;
74
75 BytesRead = Controller->GetBusData(Controller->BusInterfaceContext,
77 Buffer,
78 ConfigDataOffset,
82
83 return STATUS_SUCCESS;
84}
Definition: bufpool.h:45
#define INFO
Definition: debug.h:89
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID BusInterfaceContext
Definition: pciidex.h:199
PGET_SET_DEVICE_DATA GetBusData
Definition: pciidex.h:198
ATA_CONTROLLER Controller
Definition: pciidex.h:395
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3646

Referenced by PciIdeGetControllerProperties(), and PciIdeXSetBusData().

◆ PciIdexGetBusLocation()

NTSTATUS NTAPI PciIdexGetBusLocation ( _In_ PVOID  DeviceExtension,
_Out_ PULONG  BusLocation 
)

Definition at line 159 of file miniport.c.

162{
166
167 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
168
171 sizeof(*BusLocation),
172 BusLocation,
173 &Length);
174 return Status;
175}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1381
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
@ DevicePropertyAddress
Definition: iotypes.h:1211

◆ PciIdeXSetBusData()

NTSTATUS NTAPI PciIdeXSetBusData ( _In_ PVOID  DeviceExtension,
_In_reads_bytes_(BufferLength) PVOID  Buffer,
_In_reads_bytes_(BufferLength) PVOID  DataMask,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 89 of file miniport.c.

95{
97 PATA_CONTROLLER Controller;
98 UCHAR LocalBuffer[4];
103
104 INFO("PciIdeXSetBusData(%p %p %p 0x%lx 0x%lx)\n",
105 DeviceExtension, Buffer, DataMask, ConfigDataOffset, BufferLength);
106
107 /* Optimize the common case (4-byte PCI access) */
108 if (BufferLength <= sizeof(LocalBuffer))
109 {
110 CurrentBuffer = LocalBuffer;
111 }
112 else
113 {
115 if (!CurrentBuffer)
117 }
118
119 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
120 Controller = &FdoExt->Controller;
121
122 /*
123 * This spinlock protects the PCI configuration space against concurrent modifications.
124 * For example, the PIIX register SIDETIM (0x44) is a byte-sized register
125 * and controls both of the IDE channels.
126 */
127 KeAcquireSpinLock(&Controller->Lock, &OldIrql);
128
129 Status = PciIdeXGetBusData(DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
130 if (!NT_SUCCESS(Status))
131 goto Cleanup;
132
133 for (i = 0; i < BufferLength; i++)
134 {
135 CurrentBuffer[i] = (CurrentBuffer[i] & ~((PUCHAR)DataMask)[i]) |
136 (((PUCHAR)DataMask)[i] & ((PUCHAR)Buffer)[i]);
137 }
138
139 BytesWritten = Controller->SetBusData(Controller->BusInterfaceContext,
142 ConfigDataOffset,
146 else
148
149Cleanup:
150 KeReleaseSpinLock(&Controller->Lock, OldIrql);
151
152 if (CurrentBuffer != LocalBuffer)
154 return Status;
155}
#define ExAllocatePoolUninitialized
static ACPI_BUFFER CurrentBuffer
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Cleanup[]
Definition: register.c:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define TAG_PCIIDEX
Definition: pciidex.h:32
NTSTATUS NTAPI PciIdeXGetBusData(_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: miniport.c:59
PGET_SET_DEVICE_DATA SetBusData
Definition: pciidex.h:197
KSPIN_LOCK Lock
Definition: pciidex.h:232
unsigned char UCHAR
Definition: typedefs.h:53
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Variable Documentation

◆ PciIdeDebug

ULONG PciIdeDebug = 0

Global debugging level. Valid values are between 0 (Error) and 3 (Trace).

Definition at line 11 of file miniport.c.

Referenced by PciIdeXDebugPrint().