38,7 → 38,7 |
#include <byteorder.h> |
#include <bitops.h> |
|
static volatile uint32_t *pic; |
static volatile uint32_t *pic = NULL; |
|
void pic_init(uintptr_t base, size_t size) |
{ |
47,9 → 47,10 |
|
void pic_enable_interrupt(int intnum) |
{ |
if (intnum < 32) { |
if (pic) { |
if (intnum < 32) |
pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum); |
} else { |
else |
pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32)); |
} |
|
57,9 → 58,10 |
|
void pic_disable_interrupt(int intnum) |
{ |
if (intnum < 32) { |
if (pic) { |
if (intnum < 32) |
pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum)); |
} else { |
else |
pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32))); |
} |
} |
66,15 → 68,18 |
|
void pic_ack_interrupt(int intnum) |
{ |
if (pic) { |
if (intnum < 32) |
pic[PIC_ACK_LOW] = 1 << intnum; |
else |
pic[PIC_ACK_HIGH] = 1 << (intnum - 32); |
} |
} |
|
/** Return number of pending interrupt */ |
int pic_get_pending(void) |
{ |
if (pic) { |
int pending; |
|
pending = pic[PIC_PENDING_LOW]; |
84,6 → 89,7 |
pending = pic[PIC_PENDING_HIGH]; |
if (pending) |
return fnzb32(pending) + 32; |
} |
|
return -1; |
} |