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

fdo.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS ISA PnP Bus driver
00003  * FILE:            fdo.c
00004  * PURPOSE:         FDO-specific code
00005  * PROGRAMMERS:     Cameron Gutman (cameron.gutman@reactos.org)
00006  */
00007 #include <isapnp.h>
00008 
00009 #define NDEBUG
00010 #include <debug.h>
00011 
00012 NTSTATUS
00013 NTAPI
00014 IsaFdoStartDevice(
00015   IN PISAPNP_FDO_EXTENSION FdoExt,
00016   IN PIRP Irp,
00017   IN PIO_STACK_LOCATION IrpSp)
00018 {
00019   NTSTATUS Status;
00020   KIRQL OldIrql;
00021 
00022   KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
00023 
00024   Status = IsaHwDetectReadDataPort(FdoExt);
00025   if (!NT_SUCCESS(Status))
00026   {
00027       KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
00028       return Status;
00029   }
00030 
00031   FdoExt->Common.State = dsStarted;
00032 
00033   KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
00034 
00035   return STATUS_SUCCESS;
00036 }
00037 
00038 NTSTATUS
00039 NTAPI
00040 IsaFdoQueryDeviceRelations(
00041   IN PISAPNP_FDO_EXTENSION FdoExt,
00042   IN PIRP Irp,
00043   IN PIO_STACK_LOCATION IrpSp)
00044 {
00045   NTSTATUS Status;
00046   PLIST_ENTRY CurrentEntry;
00047   PISAPNP_LOGICAL_DEVICE IsaDevice;
00048   PDEVICE_RELATIONS DeviceRelations;
00049   KIRQL OldIrql;
00050   ULONG i = 0;
00051 
00052   if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
00053       return Irp->IoStatus.Status;
00054 
00055   KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
00056 
00057   Status = IsaHwFillDeviceList(FdoExt);
00058   if (!NT_SUCCESS(Status))
00059   {
00060       KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
00061       return Status;
00062   }
00063 
00064   DeviceRelations = ExAllocatePool(NonPagedPool,
00065                             sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * (FdoExt->DeviceCount - 1));
00066   if (!DeviceRelations)
00067   {
00068       KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
00069       return STATUS_INSUFFICIENT_RESOURCES;
00070   }
00071 
00072   CurrentEntry = FdoExt->DeviceListHead.Flink;
00073   while (CurrentEntry != &FdoExt->DeviceListHead)
00074   {
00075      IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
00076 
00077      DeviceRelations->Objects[i++] = IsaDevice->Common.Self;
00078 
00079      ObReferenceObject(IsaDevice->Common.Self);
00080 
00081      CurrentEntry = CurrentEntry->Flink;
00082   }
00083 
00084   DeviceRelations->Count = FdoExt->DeviceCount;
00085 
00086   KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
00087 
00088   Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
00089 
00090   return STATUS_SUCCESS;
00091 }
00092 
00093 NTSTATUS
00094 NTAPI
00095 IsaFdoPnp(
00096   IN PISAPNP_FDO_EXTENSION FdoExt,
00097   IN PIRP Irp,
00098   IN PIO_STACK_LOCATION IrpSp)
00099 {
00100   NTSTATUS Status = Irp->IoStatus.Status;
00101 
00102   switch (IrpSp->MinorFunction)
00103   {
00104      case IRP_MN_START_DEVICE:
00105        Status = IsaForwardIrpSynchronous(FdoExt, Irp);
00106 
00107        if (NT_SUCCESS(Status))
00108          Status = IsaFdoStartDevice(FdoExt, Irp, IrpSp);
00109 
00110        Irp->IoStatus.Status = Status;
00111 
00112        IoCompleteRequest(Irp, IO_NO_INCREMENT);
00113        return Status;
00114 
00115      case IRP_MN_STOP_DEVICE:
00116        FdoExt->Common.State = dsStopped;
00117 
00118        Status = STATUS_SUCCESS;
00119        break;
00120 
00121      case IRP_MN_QUERY_DEVICE_RELATIONS:
00122        Status = IsaFdoQueryDeviceRelations(FdoExt, Irp, IrpSp);
00123 
00124        Irp->IoStatus.Status = Status;
00125 
00126        IoCompleteRequest(Irp, IO_NO_INCREMENT);
00127        return Status;
00128 
00129      case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
00130        DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
00131        break;
00132 
00133      default:
00134        DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
00135        break;
00136   }
00137 
00138   IoSkipCurrentIrpStackLocation(Irp);
00139 
00140   return IoCallDriver(FdoExt->Ldo, Irp);
00141 }

Generated on Sun May 27 2012 04:27:26 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.