ReactOS 0.4.15-dev-5666-gc548b97
pic.c
Go to the documentation of this file.
1/*
2 * PROJECT: NEC PC-98 series HAL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: PIC initialization
5 * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <hal.h>
11
12/* PRIVATE FUNCTIONS *********************************************************/
13
14static VOID
16{
17 UCHAR i;
18
19 /*
20 * Give the old PICs enough time to react to commands.
21 * (KeStallExecutionProcessor is not available at this stage)
22 */
23 for (i = 0; i < 6; i++)
25}
26
27VOID
30{
31 I8259_ICW1 Icw1;
32 I8259_ICW2 Icw2;
33 I8259_ICW3 Icw3;
34 I8259_ICW4 Icw4;
35
37
38 /* Initialize ICW1 for master, interval 8, edge-triggered mode with ICW4 */
39 Icw1.NeedIcw4 = TRUE;
41 Icw1.Interval = Interval8;
43 Icw1.Init = TRUE;
46 HalpIoWait();
47
48 /* ICW2 - interrupt vector offset */
51 HalpIoWait();
52
53 /* Connect slave to cascade IRQ */
54 Icw3.Bits = 0;
55 Icw3.SlaveIrq7 = TRUE;
57 HalpIoWait();
58
59 /* Enable 8086 mode, non-automatic EOI, buffered mode, special fully nested mode */
61 Icw4.EoiMode = NormalEoi;
64 Icw4.Reserved = 0;
66 HalpIoWait();
67
68 /* Mask all interrupts */
70 HalpIoWait();
71
72 /* Initialize ICW1 for slave, interval 8, edge-triggered mode with ICW4 */
73 Icw1.NeedIcw4 = TRUE;
76 Icw1.Interval = Interval8;
77 Icw1.Init = TRUE;
78 Icw1.InterruptVectorAddress = 0; /* This is only used in MCS80/85 mode */
80 HalpIoWait();
81
82 /* Set interrupt vector base */
83 Icw2.Bits = PRIMARY_VECTOR_BASE + 8;
85 HalpIoWait();
86
87 /* Slave ID */
88 Icw3.Bits = 0;
91 HalpIoWait();
92
93 /* Enable 8086 mode, non-automatic EOI, buffered mode, non special fully nested mode */
95 Icw4.EoiMode = NormalEoi;
98 Icw4.Reserved = 0;
100 HalpIoWait();
101
102 /* Mask all interrupts */
104 HalpIoWait();
105}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
VOID NTAPI HalpInitializeLegacyPICs(VOID)
Definition: pic.c:18
static VOID HalpIoWait(VOID)
Definition: pic.c:15
#define PRIMARY_VECTOR_BASE
Definition: halp.h:16
@ BufferedSlave
Definition: halhw.h:196
@ BufferedMaster
Definition: halhw.h:197
#define PIC1_DATA_PORT
Definition: halhw.h:151
@ NormalEoi
Definition: halhw.h:188
@ Cascade
Definition: halhw.h:164
@ New8086Mode
Definition: halhw.h:183
#define PIC2_DATA_PORT
Definition: halhw.h:153
@ EdgeTriggered
Definition: halhw.h:170
#define PIC_CASCADE_IRQ
Definition: halhw.h:156
#define PIC2_CONTROL_PORT
Definition: halhw.h:152
#define PIC1_CONTROL_PORT
Definition: halhw.h:150
@ Interval8
Definition: halhw.h:176
PPC_QUAL void __outbyte(unsigned long const Port, const unsigned char Data)
Definition: intrin_ppc.h:605
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
#define ASSERT(a)
Definition: mode.c:44
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126
#define CPU_IO_o_ARTIC_DELAY
Definition: cpu.h:22
#define NTAPI
Definition: typedefs.h:36
UCHAR Init
Definition: halhw.h:231
UCHAR OperatingMode
Definition: halhw.h:228
UCHAR Bits
Definition: halhw.h:234
UCHAR NeedIcw4
Definition: halhw.h:227
UCHAR Interval
Definition: halhw.h:229
UCHAR InterruptVectorAddress
Definition: halhw.h:232
UCHAR InterruptMode
Definition: halhw.h:230
UCHAR Bits
Definition: halhw.h:244
UCHAR SlaveId
Definition: halhw.h:264
UCHAR Bits
Definition: halhw.h:268
UCHAR SlaveIrq7
Definition: halhw.h:260
UCHAR SystemMode
Definition: halhw.h:275
UCHAR BufferedMode
Definition: halhw.h:277
UCHAR SpecialFullyNestedMode
Definition: halhw.h:278
UCHAR Reserved
Definition: halhw.h:279
UCHAR Bits
Definition: halhw.h:281
UCHAR EoiMode
Definition: halhw.h:276
unsigned char UCHAR
Definition: xmlstorage.h:181