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

events.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS TDI driver
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            drivers/network/tdi/cte/events.c
00005  * PURPOSE:         CTE events support
00006  * PROGRAMMERS:     Oleg Baikalow (obaikalow@gmail.com)
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #include "precomp.h"
00012 
00013 typedef struct _CTEBLOCK_EVENT
00014 {
00015     NTSTATUS Status;
00016     KEVENT Event;
00017 } CTEBLOCK_EVENT, *PCTEBLOCK_EVENT;
00018 
00019 struct _CTE_DELAYED_EVENT;
00020 typedef void (*CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context);
00021 
00022 typedef struct _CTE_DELAYED_EVENT
00023 {
00024     BOOLEAN Queued;
00025     KSPIN_LOCK Lock;
00026     CTE_WORKER_ROUTINE WorkerRoutine;
00027     PVOID Context;
00028     WORK_QUEUE_ITEM WorkItem;
00029 } CTE_DELAYED_EVENT, *PCTE_DELAYED_EVENT;
00030 
00031 /* FUNCTIONS *****************************************************************/
00032 
00033 /*
00034  * @implemented
00035  */
00036 NTSTATUS
00037 NTAPI
00038 CTEBlock(PCTEBLOCK_EVENT Block)
00039 {
00040     NTSTATUS Status;
00041 
00042     /* Perform the wait */
00043     Status = KeWaitForSingleObject(&Block->Event, UserRequest, KernelMode, FALSE, NULL);
00044 
00045     /* Update event status if wait was not successful */
00046     if (!NT_SUCCESS(Status)) Block->Status = Status;
00047 
00048     return Block->Status;
00049 }
00050 
00051 
00052 VOID
00053 NTAPI
00054 InternalWorker(IN PVOID Parameter)
00055 {
00056     PCTE_DELAYED_EVENT Event = (PCTE_DELAYED_EVENT)Parameter;
00057     KIRQL OldIrql;
00058 
00059     /* Acquire the lock */
00060     KeAcquireSpinLock(&Event->Lock, &OldIrql);
00061 
00062     /* Make sure it is queued */
00063     ASSERT(Event->Queued);
00064     Event->Queued = FALSE;
00065 
00066     /* Release the lock */
00067     KeReleaseSpinLock(&Event->Lock, OldIrql);
00068 
00069     /* Call the real worker routine */
00070     (*Event->WorkerRoutine)(Event, Event->Context);
00071 }
00072 
00073 
00074 /*
00075  * @implemented
00076  */
00077 VOID
00078 NTAPI
00079 CTEInitEvent(PCTE_DELAYED_EVENT Event,
00080              CTE_WORKER_ROUTINE Routine)
00081 {
00082     /* Init the structure, lock and a work item */
00083     Event->Queued = FALSE;
00084     KeInitializeSpinLock(&Event->Lock);
00085     Event->WorkerRoutine = Routine;
00086     ExInitializeWorkItem(&Event->WorkItem, InternalWorker, Event);
00087 }
00088 
00089 /*
00090  * @unimplemented
00091  */
00092 NTSTATUS
00093 NTAPI
00094 CTELogEvent (
00095     ULONG   Unknown0,
00096     ULONG   Unknown1,
00097     ULONG   Unknown2,
00098     ULONG   Unknown3,
00099     ULONG   Unknown4,
00100     ULONG   Unknown5,
00101     ULONG   Unknown6
00102     )
00103 {
00104     /* Probably call
00105      * IoAllocateErrorLogEntry and
00106      * IoWriteErrorLogEntry
00107      */
00108     return STATUS_NOT_IMPLEMENTED;
00109 }
00110 
00111 
00112 /*
00113  * @implemented
00114  */
00115 BOOLEAN
00116 NTAPI
00117 CTEScheduleEvent(PCTE_DELAYED_EVENT Event,
00118                  PVOID Context)
00119 {
00120     KIRQL OldIrql;
00121 
00122     /* Acquire the lock */
00123     KeAcquireSpinLock(&Event->Lock, &OldIrql);
00124 
00125     /* Make sure it is queued */
00126     if (!Event->Queued)
00127     {
00128         /* Mark it as queued and set optional context pointer */
00129         Event->Queued = TRUE;
00130         Event->Context = Context;
00131 
00132         /* Actually queue it */
00133         ExQueueWorkItem(&Event->WorkItem, CriticalWorkQueue);
00134     }
00135 
00136     /* Release the lock */
00137     KeReleaseSpinLock(&Event->Lock, OldIrql);
00138 
00139     return TRUE;
00140 }
00141 
00142 
00143 /*
00144  * @implemented
00145  */
00146 LONG
00147 NTAPI
00148 CTESignal(PCTEBLOCK_EVENT Block, NTSTATUS Status)
00149 {
00150     /* Set status right away */
00151     Block->Status = Status;
00152 
00153     /* Set the event */
00154     return KeSetEvent(&Block->Event, IO_NO_INCREMENT, FALSE);
00155 }
00156 
00157 /* EOF */

Generated on Mon May 28 2012 04:24:50 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.