ReactOS  0.4.13-dev-985-gcbf4784
pic.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PIC_MASTER_CMD   0x20
 
#define PIC_MASTER_DATA   0x21
 
#define PIC_SLAVE_CMD   0xA0
 
#define PIC_SLAVE_DATA   0xA1
 
#define PIC_ICW1   0x10
 
#define PIC_ICW1_ICW4   (1 << 0)
 
#define PIC_ICW1_SINGLE   (1 << 1)
 
#define PIC_ICW4_8086   (1 << 0)
 
#define PIC_ICW4_AEOI   (1 << 1)
 
#define PIC_OCW2_NUM_MASK   0x07
 
#define PIC_OCW2_EOI   (1 << 5)
 
#define PIC_OCW2_SL   (1 << 6)
 
#define PIC_OCW3   (1 << 3)
 
#define PIC_OCW3_READ_ISR   0x0B
 

Functions

VOID PicInterruptRequest (BYTE Number)
 
BYTE PicGetInterrupt (VOID)
 
VOID PicInitialize (VOID)
 

Macro Definition Documentation

◆ PIC_ICW1

#define PIC_ICW1   0x10

Definition at line 20 of file pic.h.

◆ PIC_ICW1_ICW4

#define PIC_ICW1_ICW4   (1 << 0)

Definition at line 21 of file pic.h.

◆ PIC_ICW1_SINGLE

#define PIC_ICW1_SINGLE   (1 << 1)

Definition at line 22 of file pic.h.

◆ PIC_ICW4_8086

#define PIC_ICW4_8086   (1 << 0)

Definition at line 23 of file pic.h.

◆ PIC_ICW4_AEOI

#define PIC_ICW4_AEOI   (1 << 1)

Definition at line 24 of file pic.h.

◆ PIC_MASTER_CMD

#define PIC_MASTER_CMD   0x20

Definition at line 15 of file pic.h.

◆ PIC_MASTER_DATA

#define PIC_MASTER_DATA   0x21

Definition at line 16 of file pic.h.

◆ PIC_OCW2_EOI

#define PIC_OCW2_EOI   (1 << 5)

Definition at line 27 of file pic.h.

◆ PIC_OCW2_NUM_MASK

#define PIC_OCW2_NUM_MASK   0x07

Definition at line 26 of file pic.h.

◆ PIC_OCW2_SL

#define PIC_OCW2_SL   (1 << 6)

Definition at line 28 of file pic.h.

◆ PIC_OCW3

#define PIC_OCW3   (1 << 3)

Definition at line 30 of file pic.h.

◆ PIC_OCW3_READ_ISR

#define PIC_OCW3_READ_ISR   0x0B

Definition at line 31 of file pic.h.

◆ PIC_SLAVE_CMD

#define PIC_SLAVE_CMD   0xA0

Definition at line 17 of file pic.h.

◆ PIC_SLAVE_DATA

#define PIC_SLAVE_DATA   0xA1

Definition at line 18 of file pic.h.

Function Documentation

◆ PicGetInterrupt()

BYTE PicGetInterrupt ( VOID  )

Definition at line 244 of file pic.c.

245 {
246  UINT i;
247 
248  /* Search the master PIC interrupts by priority */
249  for (i = 0; i < 8; i++)
250  {
251  if (MasterPic.IntRequestRegister & (1 << i))
252  {
253  /* Clear the IRR flag */
254  MasterPic.IntRequestRegister &= ~(1 << i);
255 
256  /* Set the ISR flag, unless AEOI is enabled */
258 
259  /* Return the interrupt number */
260  return MasterPic.IntOffset + i;
261  }
262  }
263 
264  /* Search the slave PIC interrupts by priority */
265  for (i = 0; i < 8; i++)
266  {
267  if (SlavePic.IntRequestRegister & (1 << i))
268  {
269  /* Clear the IRR flag */
270  SlavePic.IntRequestRegister &= ~(1 << i);
271 
272  if ((i == 1) && SlavePic.CascadeRegisterSet)
273  {
274  /* This interrupt is routed to the master PIC */
276  }
277  else
278  {
279  /* Set the ISR flag, unless AEOI is enabled */
280  if (!SlavePic.AutoEoi) SlavePic.InServiceRegister |= (1 << i);
281 
282  /* Return the interrupt number */
283  return SlavePic.IntOffset + i;
284  }
285  }
286  }
287 
288  /* Spurious interrupt */
289  if (MasterPic.InServiceRegister & (1 << 2))
290  return SlavePic.IntOffset + 7;
291  else
292  return MasterPic.IntOffset + 7;
293 }
BYTE IntOffset
Definition: pic.c:30
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOLEAN CascadeRegisterSet
Definition: pic.c:33
BOOLEAN AutoEoi
Definition: pic.c:34
BYTE CascadeRegister
Definition: pic.c:32
unsigned int UINT
Definition: ndis.h:50
BYTE IntRequestRegister
Definition: pic.c:28
BYTE InServiceRegister
Definition: pic.c:29
static PIC MasterPic
Definition: pic.c:39
static PIC SlavePic
Definition: pic.c:39

Referenced by EmulatorIntAcknowledge().

◆ PicInitialize()

VOID PicInitialize ( VOID  )

Definition at line 295 of file pic.c.

296 {
297  /* Register the I/O Ports */
302 }
#define PIC_MASTER_DATA
Definition: pic.h:16
static VOID WINAPI PicWriteData(USHORT Port, BYTE Data)
Definition: pic.c:129
static BYTE WINAPI PicReadData(USHORT Port)
Definition: pic.c:120
VOID RegisterIoPort(USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler)
Definition: io.c:320
#define PIC_SLAVE_DATA
Definition: pic.h:18
#define PIC_MASTER_CMD
Definition: pic.h:15
static BYTE WINAPI PicReadCommand(USHORT Port)
Definition: pic.c:43
static VOID WINAPI PicWriteCommand(USHORT Port, BYTE Data)
Definition: pic.c:66
#define PIC_SLAVE_CMD
Definition: pic.h:17

Referenced by EmulatorInitialize().

◆ PicInterruptRequest()

VOID PicInterruptRequest ( BYTE  Number)

Definition at line 192 of file pic.c.

193 {
194  BYTE i;
195 
196  if (/* Number >= 0 && */ Number < 8)
197  {
198  /* Check if any of the higher-priority interrupts are busy */
199  for (i = 0; i <= Number; i++)
200  {
201  if (MasterPic.InServiceRegister & (1 << Number)) return;
202  }
203 
204  /* Check if the interrupt is masked */
205  if (MasterPic.MaskRegister & (1 << Number)) return;
206 
207  /* Set the appropriate bit in the IRR and interrupt the CPU */
210  }
211  else if (Number >= 8 && Number < 16)
212  {
213  Number -= 8;
214 
215  /*
216  * The slave PIC is connected to IRQ 2, always! If the master PIC
217  * was misconfigured, don't do anything.
218  */
219  if (!(MasterPic.CascadeRegister & (1 << 2))
220  || SlavePic.CascadeRegister != 2)
221  {
222  return;
223  }
224 
225  /* Check if any of the higher-priority interrupts are busy */
226  if (MasterPic.InServiceRegister != 0) return;
227  for (i = 0; i <= Number; i++)
228  {
229  if (SlavePic.InServiceRegister & (1 << Number)) return;
230  }
231 
232  /* Check if the interrupt is masked */
233  if (SlavePic.MaskRegister & (1 << Number)) return;
234 
235  /* Set the IRQ 2 bit in the master ISR */
236  if (!MasterPic.AutoEoi) MasterPic.InServiceRegister |= (1 << 2);
237 
238  /* Set the appropriate bit in the IRR and interrupt the CPU */
241  }
242 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char BYTE
Definition: mem.h:68
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
VOID EmulatorInterruptSignal(VOID)
Definition: emulator.c:120
BOOLEAN AutoEoi
Definition: pic.c:34
BYTE CascadeRegister
Definition: pic.c:32
BYTE IntRequestRegister
Definition: pic.c:28
BYTE MaskRegister
Definition: pic.c:27
BYTE InServiceRegister
Definition: pic.c:29
static PIC MasterPic
Definition: pic.c:39
static PIC SlavePic
Definition: pic.c:39

Referenced by call_ica_hw_interrupt(), EmulatorFpu(), GeneratePS2Irq(), PitChan0Out(), RtcPeriodicTick(), and RtcTimeUpdate().