ReactOS 0.4.16-dev-334-g4d9f67c
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
10#define NDEBUG
11#include <debug.h>
12
15
16CODE_SEG("PAGE")
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}
45
46CODE_SEG("PAGE")
50 _In_ ULONG Channel)
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}
62
72VOID
74 _In_ ULONG DebugPrintLevel,
75 _In_z_ _Printf_format_string_ PCCHAR DebugMessage,
76 ...)
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}
88
89/* May be called at IRQL <= DISPATCH_LEVEL */
93 _In_ PVOID DeviceExtension,
95 _In_ ULONG ConfigDataOffset,
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}
118
119/* May be called at IRQL <= DISPATCH_LEVEL */
121NTAPI
123 _In_ PVOID DeviceExtension,
126 _In_ ULONG ConfigDataOffset,
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}
#define PAGED_CODE()
#define CODE_SEG(...)
static ACPI_BUFFER CurrentBuffer
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)
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Cleanup[]
Definition: register.c:80
@ DPFLTR_PCIIDE_ID
Definition: dpfilter.h:86
@ FdoExtension
Definition: precomp.h:48
#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
struct _IDE_CONTROLLER_PROPERTIES IDE_CONTROLLER_PROPERTIES
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 ASSERT(a)
Definition: mode.c:44
#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 _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
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define TAG_PCIIDEX
Definition: pciidex.h:19
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
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:73
IDE_CHANNEL_STATE PciIdeXChannelState(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Channel)
Definition: miniport.c:48
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:122
NTSTATUS PciIdeXStartMiniport(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: miniport.c:18
NTSTATUS NTAPI PciIdeXGetBusData(_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: miniport.c:92
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:14
#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: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 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:3644
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778