1 | Index: i386/libsa/interrupts.c␊ |
2 | ===================================================================␊ |
3 | --- i386/libsa/interrupts.c␉(revision 2750)␊ |
4 | +++ i386/libsa/interrupts.c␉(working copy)␊ |
5 | @@ -84,9 +84,6 @@␊ |
6 | static␊ |
7 | uint32_t lapic_base = 0U;␊ |
8 | ␊ |
9 | -static␊ |
10 | -uint8_t const PicPorts[2][2] = { { 0x20U, 0x21U }, { 0xA0U, 0xA1U } };␊ |
11 | -␊ |
12 | #pragma mark -␊ |
13 | #pragma mark Assembly Stubs␊ |
14 | #pragma mark -␊ |
15 | @@ -107,7 +104,6 @@␊ |
16 | ␉␉␉␉␉ "addl $4, %%esp\n\t"␊ |
17 | ␉␉␉␉␉ "iretl"␊ |
18 | ␉␉␉␉␉ :);␊ |
19 | -␉__builtin_unreachable();␊ |
20 | }␊ |
21 | ␊ |
22 | static␊ |
23 | @@ -132,7 +128,6 @@␊ |
24 | ␉␉␉␉␉ "addl $8, %%esp\n\t"␊ |
25 | ␉␉␉␉␉ "iretl"␊ |
26 | ␉␉␉␉␉ :);␊ |
27 | -␉__builtin_unreachable();␊ |
28 | }␊ |
29 | ␊ |
30 | /*␊ |
31 | @@ -197,19 +192,15 @@␊ |
32 | ␉*(uint32_t volatile*) (lapic_base + offset) = value;␊ |
33 | }␊ |
34 | ␊ |
35 | -static inline␊ |
36 | -uint8_t ReadPic(int pic, int index)␊ |
37 | -{␊ |
38 | -␉uint8_t value;␊ |
39 | -␉__asm__ volatile ("inb %1, %0" : "=a"(value) : "N"(PicPorts[pic][index]));␊ |
40 | -␉return value;␊ |
41 | -}␊ |
42 | +#define ChoosePicPort(pic, index) (pic == 0 ? (index == 0 ? 0x20U : 0x21U) : (index == 0 ? 0xA0U : 0xA1U))␊ |
43 | ␊ |
44 | -static inline␊ |
45 | -void WritePic(int pic, int index, uint8_t value)␊ |
46 | -{␊ |
47 | -␉__asm__ volatile ("outb %0, %1" : : "a"(value), "N"(PicPorts[pic][index]));␊ |
48 | -}␊ |
49 | +#define ReadPic(pic, index) ({ \␊ |
50 | +␉uint8_t value; \␊ |
51 | +␉__asm__ volatile ("inb %1, %0" : "=a"(value) : "N"(ChoosePicPort(pic, index))); \␊ |
52 | +␉value; \␊ |
53 | +})␊ |
54 | +␉␊ |
55 | +#define WritePic(pic, index, value) __asm__ volatile ("outb %0, %1" : : "a"((uint8_t)value), "N"(ChoosePicPort(pic, index)))␊ |
56 | ␊ |
57 | #pragma mark -␊ |
58 | #pragma mark Main Code␊ |
59 |