aboutsummaryrefslogtreecommitdiff
path: root/devices/pic_8259.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2023-06-29 21:45:11 +0300
committeraqua <aqua@iserlohn-fortress.net>2023-06-29 21:45:11 +0300
commiteb84566d236df6b0dd4f5ce8fc47d66e55e33654 (patch)
tree7e03ca126781c67336edf9f3ce6888aad23f74e4 /devices/pic_8259.c
parentRework leaf makefiles to be included from top-level (diff)
downloadkernel-eb84566d236df6b0dd4f5ce8fc47d66e55e33654.tar.xz
Fix compiler warnings
Diffstat (limited to 'devices/pic_8259.c')
-rw-r--r--devices/pic_8259.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/devices/pic_8259.c b/devices/pic_8259.c
index 7b4807c..75aaf6d 100644
--- a/devices/pic_8259.c
+++ b/devices/pic_8259.c
@@ -33,17 +33,25 @@ pic_init()
outb(0xff, PIC2 + DATA);
}
+static unsigned char
+irq_mask(unsigned char irq)
+{
+ unsigned char mask = (unsigned char)~(1u << irq);
+ return 0xff & mask;
+}
+
void
pic_enable()
{
unsigned char mask1 = 0xff;
- mask1 &= ~(1 << 0); /* irq0 timer */
- mask1 &= ~(1 << 1); /* irq1 keyboard */
- mask1 &= ~(1 << 2); /* irq1 cascade */
+ unsigned char mask2 = 0xff;
+
+ mask1 &= irq_mask(0); /* irq0 timer */
+ mask1 &= irq_mask(1); /* irq1 keyboard */
+ mask1 &= irq_mask(2); /* irq2 cascade */
outb(mask1, PIC1 + DATA);
- unsigned char mask2 = 0xff;
- mask2 &= ~(1 << 4); /* irq12 mouse */
+ mask2 &= irq_mask(12 - 8); /* irq12 mouse */
outb(mask2, PIC2 + DATA);
enable_interrupts();