ReactOS 0.4.16-dev-297-gc569aee
miniport.c File Reference
#include "pciidex.h"
#include <debug.h>
Include dependency graph for miniport.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS PciIdeXStartMiniport (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 
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)
 

Variables

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

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file miniport.c.

Function Documentation

◆ PciIdeXChannelState()

IDE_CHANNEL_STATE PciIdeXChannelState ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Channel 
)

Definition at line 48 of file miniport.c.

51{
52 PCIIDE_CHANNEL_ENABLED MiniportChannelEnabled;
53
54 PAGED_CODE();
55
56 MiniportChannelEnabled = FdoExtension->Properties.PciIdeChannelEnabled;
57 if (MiniportChannelEnabled)
58 return MiniportChannelEnabled(FdoExtension->MiniControllerExtension, Channel);
59
61}
#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

Referenced by PciIdeXFdoQueryBusRelations(), PciIdeXPdoQueryResourceRequirements(), and PciIdeXPdoQueryResources().

◆ 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 73 of file miniport.c.

77{
78 va_list ap;
79
80 /* Check if we can print anything */
81 if (DebugPrintLevel <= PciIdeDebug)
82 DebugPrintLevel = 0;
83
84 va_start(ap, DebugMessage);
85 vDbgPrintEx(DPFLTR_PCIIDE_ID, DebugPrintLevel, DebugMessage, ap);
86 va_end(ap);
87}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
@ DPFLTR_PCIIDE_ID
Definition: dpfilter.h:86
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:14
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 92 of file miniport.c.

97{
100
101 DPRINT("PciIdeXGetBusData(%p %p 0x%lx 0x%lx)\n",
102 DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
103
104 FdoExtension = CONTAINING_RECORD(DeviceExtension,
106 MiniControllerExtension);
107
108 BytesRead = (*FdoExtension->BusInterface.GetBusData)(FdoExtension->BusInterface.Context,
110 Buffer,
111 ConfigDataOffset,
113 if (BytesRead != BufferLength)
114 return STATUS_UNSUCCESSFUL;
115
116 return STATUS_SUCCESS;
117}
Definition: bufpool.h:45
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
#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:3771
_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:3644

Referenced by PciIdeChannelEnabled(), and PciIdeXSetBusData().

◆ 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 122 of file miniport.c.

128{
134
135 DPRINT("PciIdeXSetBusData(%p %p %p 0x%lx 0x%lx)\n",
136 DeviceExtension, Buffer, DataMask, ConfigDataOffset, BufferLength);
137
139 if (!CurrentBuffer)
141
142 FdoExtension = CONTAINING_RECORD(DeviceExtension,
144 MiniControllerExtension);
145
146 KeAcquireSpinLock(&FdoExtension->BusDataLock, &OldIrql);
147
148 Status = PciIdeXGetBusData(DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
149 if (!NT_SUCCESS(Status))
150 goto Cleanup;
151
152 for (i = 0; i < BufferLength; i++)
153 {
154 CurrentBuffer[i] = (CurrentBuffer[i] & ~((PUCHAR)DataMask)[i]) |
155 (((PUCHAR)DataMask)[i] & ((PUCHAR)Buffer)[i]);
156 }
157
158 BytesWritten = (*FdoExtension->BusInterface.SetBusData)(FdoExtension->BusInterface.Context,
161 ConfigDataOffset,
165 else
167
168Cleanup:
169 KeReleaseSpinLock(&FdoExtension->BusDataLock, OldIrql);
170
172 return Status;
173}
static ACPI_BUFFER CurrentBuffer
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
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
Status
Definition: gdiplustypes.h:25
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:19
NTSTATUS NTAPI PciIdeXGetBusData(_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: miniport.c:92
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

◆ PciIdeXStartMiniport()

NTSTATUS PciIdeXStartMiniport ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)

Definition at line 18 of file miniport.c.

20{
23
24 PAGED_CODE();
25
26 if (FdoExtension->MiniportStarted)
27 return STATUS_SUCCESS;
28
29 DPRINT("Starting miniport\n");
30
32 FdoExtension->DriverObject);
34
35 FdoExtension->Properties.Size = sizeof(IDE_CONTROLLER_PROPERTIES);
36 FdoExtension->Properties.ExtensionSize = DriverExtension->MiniControllerExtensionSize;
37 Status = DriverExtension->HwGetControllerProperties(FdoExtension->MiniControllerExtension,
38 &FdoExtension->Properties);
39 if (!NT_SUCCESS(Status))
40 return Status;
41
42 FdoExtension->MiniportStarted = TRUE;
43 return STATUS_SUCCESS;
44}
#define TRUE
Definition: types.h:120
struct _IDE_CONTROLLER_PROPERTIES IDE_CONTROLLER_PROPERTIES
#define ASSERT(a)
Definition: mode.c:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31

Referenced by PciIdeXFdoStartDevice().

Variable Documentation

◆ PciIdeDebug

ULONG PciIdeDebug = 0

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

Definition at line 14 of file miniport.c.

Referenced by PciIdeXDebugPrint().