ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

api.cpp
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Kernel Streaming
00004  * FILE:            drivers/wdm/audio/backpln/portcls/api.cpp
00005  * PURPOSE:         Port api functions
00006  * PROGRAMMER:      Johannes Anderwald
00007  */
00008 
00009 #include "private.hpp"
00010 
00011 NTSTATUS
00012 NTAPI
00013 PcGetDeviceProperty(
00014     IN  PVOID DeviceObject,
00015     IN  DEVICE_REGISTRY_PROPERTY DeviceProperty,
00016     IN  ULONG BufferLength,
00017     OUT PVOID PropertyBuffer,
00018     OUT PULONG ResultLength)
00019 {
00020     PPCLASS_DEVICE_EXTENSION DeviceExtension;
00021 
00022     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
00023 
00024     DeviceExtension = (PPCLASS_DEVICE_EXTENSION)((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
00025 
00026     return IoGetDeviceProperty(DeviceExtension->PhysicalDeviceObject, DeviceProperty, BufferLength, PropertyBuffer, ResultLength);
00027 }
00028 
00029 ULONGLONG
00030 NTAPI
00031 PcGetTimeInterval(
00032     IN  ULONGLONG Since)
00033 {
00034     LARGE_INTEGER CurrentTime;
00035 
00036     KeQuerySystemTime(&CurrentTime);
00037 
00038     return (CurrentTime.QuadPart - Since);
00039 }
00040 
00041 VOID
00042 NTAPI
00043 PcIoTimerRoutine(
00044     IN PDEVICE_OBJECT  DeviceObject,
00045     IN PVOID  Context)
00046 {
00047     PPCLASS_DEVICE_EXTENSION DeviceExtension;
00048     KIRQL OldIrql;
00049     PLIST_ENTRY ListEntry;
00050     PTIMER_CONTEXT CurContext;
00051 
00052     if (!DeviceObject || !DeviceObject->DeviceExtension)
00053         return;
00054 
00055     DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
00056 
00057     KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
00058 
00059     ListEntry = DeviceExtension->TimerList.Flink;
00060     while(ListEntry != &DeviceExtension->TimerList)
00061     {
00062         CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
00063 
00064         CurContext->pTimerRoutine(DeviceObject, CurContext->Context);
00065         ListEntry = ListEntry->Flink;
00066     }
00067 
00068     KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
00069 }
00070 
00071 NTSTATUS
00072 NTAPI
00073 PcRegisterIoTimeout(
00074     IN  PDEVICE_OBJECT pDeviceObject,
00075     IN  PIO_TIMER_ROUTINE pTimerRoutine,
00076     IN  PVOID pContext)
00077 {
00078     NTSTATUS Status = STATUS_SUCCESS;
00079     PTIMER_CONTEXT TimerContext, CurContext;
00080     KIRQL OldIrql;
00081     PLIST_ENTRY ListEntry;
00082     BOOLEAN bFound;
00083     PPCLASS_DEVICE_EXTENSION DeviceExtension;
00084 
00085     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
00086 
00087     if (!pDeviceObject || !pDeviceObject->DeviceExtension)
00088         return STATUS_INVALID_PARAMETER;
00089 
00090     DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
00091 
00092     TimerContext = (PTIMER_CONTEXT)AllocateItem(NonPagedPool, sizeof(TIMER_CONTEXT), TAG_PORTCLASS);
00093     if (!TimerContext)
00094     {
00095         DPRINT("Failed to allocate memory\n");
00096         return STATUS_INSUFFICIENT_RESOURCES;
00097     }
00098 
00099     KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
00100 
00101     ListEntry = DeviceExtension->TimerList.Flink;
00102     bFound = FALSE;
00103     while(ListEntry != &DeviceExtension->TimerList)
00104     {
00105         CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
00106 
00107         if (CurContext->Context == pContext && CurContext->pTimerRoutine == pTimerRoutine)
00108         {
00109             bFound = TRUE;
00110             Status = STATUS_UNSUCCESSFUL;
00111             FreeItem(TimerContext, TAG_PORTCLASS);
00112             break;
00113         }
00114         ListEntry = ListEntry->Flink;
00115     }
00116 
00117     if (!bFound)
00118     {
00119         TimerContext->Context = pContext;
00120         TimerContext->pTimerRoutine = pTimerRoutine;
00121         InsertTailList(&DeviceExtension->TimerList, &TimerContext->Entry);
00122     }
00123 
00124     KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
00125 
00126     return Status;
00127 }
00128 
00129 NTSTATUS
00130 NTAPI
00131 PcUnregisterIoTimeout(
00132     IN  PDEVICE_OBJECT pDeviceObject,
00133     IN  PIO_TIMER_ROUTINE pTimerRoutine,
00134     IN  PVOID pContext)
00135 {
00136     PTIMER_CONTEXT CurContext;
00137     KIRQL OldIrql;
00138     PLIST_ENTRY ListEntry;
00139     BOOLEAN bFound;
00140     PPCLASS_DEVICE_EXTENSION DeviceExtension;
00141 
00142     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
00143 
00144     if (!pDeviceObject || !pDeviceObject->DeviceExtension)
00145         return STATUS_INVALID_PARAMETER;
00146 
00147 
00148     DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
00149 
00150 
00151     KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
00152 
00153     ListEntry = DeviceExtension->TimerList.Flink;
00154     bFound = FALSE;
00155 
00156     while(ListEntry != &DeviceExtension->TimerList)
00157     {
00158         CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
00159 
00160         if (CurContext->Context == pContext && CurContext->pTimerRoutine == pTimerRoutine)
00161         {
00162             bFound = TRUE;
00163             RemoveEntryList(&CurContext->Entry);
00164             FreeItem(CurContext, TAG_PORTCLASS);
00165             break;
00166         }
00167         ListEntry = ListEntry->Flink;
00168     }
00169 
00170     KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
00171 
00172     if (bFound)
00173         return STATUS_SUCCESS;
00174     else
00175         return STATUS_NOT_FOUND;
00176 }
00177 
00178 
00179 
00180 NTSTATUS
00181 NTAPI
00182 PcCompletePendingPropertyRequest(
00183     IN  PPCPROPERTY_REQUEST PropertyRequest,
00184     IN  NTSTATUS NtStatus)
00185 {
00186     // sanity checks
00187     PC_ASSERT_IRQL(DISPATCH_LEVEL);
00188 
00189     if (!PropertyRequest || !PropertyRequest->Irp || NtStatus == STATUS_PENDING)
00190         return STATUS_INVALID_PARAMETER;
00191 
00192     // set the final status code
00193     PropertyRequest->Irp->IoStatus.Status = NtStatus;
00194 
00195     // complete the irp
00196     IoCompleteRequest(PropertyRequest->Irp, IO_SOUND_INCREMENT);
00197 
00198     // free the property request
00199     FreeItem(PropertyRequest, TAG_PORTCLASS);
00200 
00201     // return success
00202     return STATUS_SUCCESS;
00203 }
00204 
00205 NTSTATUS
00206 NTAPI
00207 PcDmaMasterDescription(
00208     IN PRESOURCELIST ResourceList OPTIONAL,
00209     IN BOOLEAN ScatterGather,
00210     IN BOOLEAN Dma32BitAddresses,
00211     IN BOOLEAN IgnoreCount,
00212     IN BOOLEAN Dma64BitAddresses,
00213     IN DMA_WIDTH DmaWidth,
00214     IN DMA_SPEED DmaSpeed,
00215     IN ULONG MaximumLength,
00216     IN ULONG DmaPort,
00217     OUT PDEVICE_DESCRIPTION DeviceDescription)
00218 {
00219 
00220     RtlZeroMemory(DeviceDescription, sizeof(DEVICE_DESCRIPTION));
00221 
00222     DeviceDescription->Master = TRUE;
00223     DeviceDescription->Version = DEVICE_DESCRIPTION_VERSION1;
00224     DeviceDescription->ScatterGather= ScatterGather;
00225     DeviceDescription->Dma32BitAddresses = Dma32BitAddresses;
00226     DeviceDescription->IgnoreCount = IgnoreCount;
00227     DeviceDescription->Dma64BitAddresses = Dma64BitAddresses;
00228     DeviceDescription->DmaWidth = DmaWidth;
00229     DeviceDescription->DmaSpeed = DmaSpeed;
00230     DeviceDescription->MaximumLength = MaximumLength;
00231     DeviceDescription->DmaPort = DmaPort;
00232 
00233     return STATUS_SUCCESS;
00234 }
00235 
00236 NTSTATUS
00237 NTAPI
00238 PcDmaSlaveDescription(
00239     IN PRESOURCELIST  ResourceList OPTIONAL,
00240     IN ULONG DmaIndex,
00241     IN BOOLEAN DemandMode,
00242     IN BOOLEAN AutoInitialize,
00243     IN DMA_SPEED DmaSpeed,
00244     IN ULONG MaximumLength,
00245     IN ULONG DmaPort,
00246     OUT PDEVICE_DESCRIPTION DeviceDescription)
00247 {
00248 
00249     RtlZeroMemory(DeviceDescription, sizeof(DEVICE_DESCRIPTION));
00250 
00251     DeviceDescription->Version = DEVICE_DESCRIPTION_VERSION1;
00252     DeviceDescription->DemandMode = DemandMode;
00253     DeviceDescription->AutoInitialize = AutoInitialize;
00254     DeviceDescription->DmaSpeed = DmaSpeed;
00255     DeviceDescription->MaximumLength = MaximumLength;
00256     DeviceDescription->DmaPort = DmaPort;
00257 
00258     return STATUS_SUCCESS;
00259 }
00260 

Generated on Sat May 26 2012 04:27:06 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.