ReactOS 0.4.17-dev-116-ga4b6fe9
miniport.c
Go to the documentation of this file.
1/*
2 * PROJECT: PCI IDE bus driver extension
3 * LICENSE: See COPYING in the top level directory
4 * PURPOSE: Miniport functions
5 * COPYRIGHT: Copyright 2005 Hervé Poussineau <hpoussin@reactos.org>
6 */
7
8#include "pciidex.h"
9
12
13CODE_SEG("PAGE")
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}
29
39VOID
41 _In_ ULONG DebugPrintLevel,
42 _In_z_ _Printf_format_string_ PCCHAR DebugMessage,
43 ...)
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}
55
56/* May be called at IRQL <= DISPATCH_LEVEL */
60 _In_ PVOID DeviceExtension,
62 _In_ ULONG ConfigDataOffset,
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}
85
86/* May be called at IRQL <= DISPATCH_LEVEL */
90 _In_ PVOID DeviceExtension,
93 _In_ ULONG ConfigDataOffset,
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}
156
158NTAPI
160 _In_ PVOID DeviceExtension,
161 _Out_ PULONG BusLocation)
162{
166
167 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
168
171 sizeof(*BusLocation),
172 BusLocation,
173 &Length);
174 return Status;
175}
#define ExAllocatePoolUninitialized
#define PAGED_CODE()
#define CODE_SEG(...)
static ACPI_BUFFER CurrentBuffer
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
static const WCHAR Cleanup[]
Definition: register.c:80
@ DPFLTR_PCIIDE_ID
Definition: dpfilter.h:86
#define INFO
Definition: debug.h:89
@ FdoExtension
Definition: precomp.h:48
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
IDE_CHANNEL_STATE
Definition: ide.h:196
@ ChannelStateUnknown
Definition: ide.h:199
IDE_CHANNEL_STATE(NTAPI * PCIIDE_CHANNEL_ENABLED)(_In_ PVOID DeviceExtension, _In_ ULONG Channel)
Definition: ide.h:203
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define _In_z_
Definition: no_sal2.h:164
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_all_(s)
Definition: no_sal2.h:194
#define _Printf_format_string_
Definition: no_sal2.h:356
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ ULONG Channel
Definition: pciidex.h:74
#define TAG_PCIIDEX
Definition: pciidex.h:32
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
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID PciIdeXDebugPrint(_In_ ULONG DebugPrintLevel, _In_z_ _Printf_format_string_ PCCHAR DebugMessage,...)
Prints the given string with printf-like formatting to the kernel debugger.
Definition: miniport.c:40
IDE_CHANNEL_STATE PciIdeXChannelState(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Channel)
Definition: miniport.c:15
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: miniport.c:89
NTSTATUS NTAPI PciIdexGetBusLocation(_In_ PVOID DeviceExtension, _Out_ PULONG BusLocation)
Definition: miniport.c:159
NTSTATUS NTAPI PciIdeXGetBusData(_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: miniport.c:59
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:11
PGET_SET_DEVICE_DATA SetBusData
Definition: pciidex.h:197
PVOID BusInterfaceContext
Definition: pciidex.h:199
KSPIN_LOCK Lock
Definition: pciidex.h:232
PGET_SET_DEVICE_DATA GetBusData
Definition: pciidex.h:198
ATA_CONTROLLER Controller
Definition: pciidex.h:395
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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 BytesWritten
Definition: wdfiotarget.h:960
_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
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3646
@ DevicePropertyAddress
Definition: iotypes.h:1211
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778