OpenCBM
startio.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 2004 Spiro Trikaliotis
8  *
9  */
10 
19 #include <wdm.h>
20 #include "cbm_driver.h"
21 
38 NTSTATUS
39 cbm_startio(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
40 {
41  PIO_STACK_LOCATION irpSp;
42  PDEVICE_EXTENSION pdx;
43  NTSTATUS ntStatus;
44 
45  FUNC_ENTER();
46 
47  // get current stack location
48 
49  irpSp = IoGetCurrentIrpStackLocation(Irp);
50 
51  // get device extension
52 
53  pdx = Fdo->DeviceExtension;
54 
55  PERF_EVENT_STARTIO(Irp);
56 
57  // Execute the appropriate IRP
58 
59  switch (irpSp->MajorFunction)
60  {
61  case IRP_MJ_CREATE:
62  ntStatus = cbm_execute_createopen(pdx, Irp);
63  break;
64 
65  case IRP_MJ_CLOSE:
66  ntStatus = cbm_execute_close(pdx, Irp);
67  break;
68 
69  case IRP_MJ_READ:
70  /* FALL THROUGH */
71 
72  case IRP_MJ_WRITE:
73  ntStatus = cbm_execute_readwrite(pdx, Irp);
74  break;
75 
76  case IRP_MJ_DEVICE_CONTROL:
77  case IRP_MJ_INTERNAL_DEVICE_CONTROL:
78  ntStatus = cbm_execute_devicecontrol(pdx, Irp);
79  break;
80 
81  default:
82  DBG_ERROR((DBG_PREFIX "THIS SHOULD NOT HAPPEN: UNKNOWN MAJORFUNCTION %08x",
83  irpSp->MajorFunction));
84  DBG_ASSERT(1==0);
85  ntStatus = STATUS_NOT_SUPPORTED;
86  }
87 
88  FUNC_LEAVE_NTSTATUS(ntStatus);
89 }
NTSTATUS cbm_execute_createopen(IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
Execute IRPs containing the IRP_MJ_CREATEOPEN I/O function code.
NTSTATUS cbm_execute_readwrite(IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
Executes reads from or writes to the driver.
Definition: readwrite.c:178
#define DBG_ASSERT(_xxx)
Definition: debug.h:401
#define DBG_ERROR(_xxx)
Definition: debug.h:397
NTSTATUS cbm_startio(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Execute an IRP.
Definition: startio.c:39
#define PERF_EVENT_STARTIO(_x_)
Definition: cbm_driver.h:40
#define FUNC_ENTER()
Definition: debug.h:347
Definitions for the opencbm driver.
#define DBG_PREFIX
Definition: debug.h:320
NTSTATUS cbm_execute_devicecontrol(IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
Executes IOCTLs.
Definition: ioctl.c:363
NTSTATUS cbm_execute_close(IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
Execute IRPs containing the IRP_MJ_CLOSE I/O function code.