OpenCBM
interrupt.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 1999-2004 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8  * Copyright 2001-2004 Spiro Trikaliotis
9  *
10  */
11 
22 #include <wdm.h>
23 #include "cbm_driver.h"
24 #include "i_iec.h"
25 
39 BOOLEAN
40 cbmiec_interrupt(IN PDEVICE_EXTENSION Pdx)
41 {
42  BOOLEAN isMyInt;
43  UCHAR irqResult;
44 
45  FUNC_ENTER();
46 
47  PERF_EVENT_VERBOSE(0x2010, 0);
48 
49  /* acknowledge the interrupt */
50  irqResult = READ_PORT_UCHAR(IN_PORT);
51  DBG_PPORT((DBG_PREFIX "irqResult before: %02x", irqResult));
52 
53  DBG_IRQ(("Interrupt occurred"));
54 
58 /*
59  if ((irqResult & 0x04) == 0)
60 
61  Thus, we check DATA_IN directly:
62 
65  if (!CBMIEC_GET(PP_DATA_IN))
66  {
67  isMyInt = TRUE;
68 
69  DBG_IRQ(("It's a PP interrupt!"));
70 
71  if (Pdx->IrqCount != 0)
72  {
73  PERF_EVENT_VERBOSE(0x2011, 0);
74  if (InterlockedDecrement(&Pdx->IrqCount) == 0)
75  {
76  PERF_EVENT_VERBOSE(0x2012, 0);
77  CBMIEC_SET(PP_CLK_OUT);
78  DBG_SUCCESS((DBG_PREFIX "continue to send"));
79 
80 #ifdef USE_DPC
81  // Request a DPC which will wake up wait_for_listener()
82 
83  DBG_DPC((DBG_PREFIX "IoRequestDpc() "));
84 
85  DBG_IRQL( >= DISPATCH_LEVEL); // in fact, at DIRQL
86  IoRequestDpc(Pdx->Fdo, Pdx->IrpQueue.CurrentIrp, NULL);
87  PERF_EVENT_VERBOSE(0x2013, 0);
88 
89 #endif // #ifdef USE_DPC
90 
91  }
92  }
93  else
94  {
95  PERF_EVENT_VERBOSE(0x2014, Pdx->IrqCount);
96  DBG_ERROR((DBG_PREFIX "****************************************************"));
97  DBG_ERROR((DBG_PREFIX "Interrupt occurred, BUT ALREADY IRQCOUNT=0! ********"));
98  DBG_ERROR((DBG_PREFIX "****************************************************"));
99  }
100  }
101  else
102  {
103  isMyInt = FALSE;
104  DBG_WARN((DBG_PREFIX "********************************************"));
105  DBG_WARN((DBG_PREFIX "Interrupt occurred, but not for me! ********"));
106  DBG_WARN((DBG_PREFIX "********************************************"));
107  }
108 
109  irqResult = READ_PORT_UCHAR(IN_PORT);
110  DBG_PPORT((DBG_PREFIX "irqResult afterwards: %02x", irqResult));
111 
112  PERF_EVENT_VERBOSE(0x2015, 0);
113 
114  FUNC_LEAVE_BOOLEAN(isMyInt);
115 }
Internal functions and definitions of the libiec library.
#define IN_PORT
Definition: i_iec.h:58
BOOLEAN cbmiec_interrupt(IN PDEVICE_EXTENSION Pdx)
Interrupt handler for the IEC bus.
Definition: interrupt.c:40
#define DBG_PPORT(_xxx)
Definition: debug.h:391
#define FUNC_ENTER()
Definition: debug.h:347
Definitions for the opencbm driver.
#define DBG_PREFIX
Definition: debug.h:320
#define READ_PORT_UCHAR(_x_)
READ_PORT_UCHAR replacement for debugging.
Definition: i_iec.h:211