1 // Copyright 2016 The Fuchsia Authors
2 // Copyright (c) 2009 Corey Tabaka
3 // Copyright (c) 2015 Intel Corporation
4 //
5 // Use of this source code is governed by a MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT
8 
9 #include <sys/types.h>
10 
11 #include <arch/ops.h>
12 #include <platform/pc.h>
13 #include <platform/pic.h>
14 
15 #define PIC1 0x20
16 #define PIC2 0xA0
17 
18 #define ICW1 0x11
19 #define ICW4 0x01
20 
21 /*
22  * init the PICs and remap them
23  */
pic_map(uint8_t pic1,uint8_t pic2)24 void pic_map(uint8_t pic1, uint8_t pic2) {
25     /* send ICW1 */
26     outp(PIC1, ICW1);
27     outp(PIC2, ICW1);
28 
29     /* send ICW2 */
30     outp(PIC1 + 1, pic1); /* remap */
31     outp(PIC2 + 1, pic2); /*  pics */
32 
33     /* send ICW3 */
34     outp(PIC1 + 1, 4); /* IRQ2 -> connection to slave */
35     outp(PIC2 + 1, 2);
36 
37     /* send ICW4 */
38     outp(PIC1 + 1, 5);
39     outp(PIC2 + 1, 1);
40 
41     /* disable all IRQs */
42     outp(PIC1 + 1, 0xff);
43     outp(PIC2 + 1, 0xff);
44 }
45 
pic_disable(void)46 void pic_disable(void) {
47     outp(PIC2 + 1, 0xff);
48     outp(PIC1 + 1, 0xff);
49 }
50