Rev 2787 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2787 | Rev 4377 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | /** @addtogroup ppc32 |
29 | /** @addtogroup ppc32 |
| 30 | * @{ |
30 | * @{ |
| 31 | */ |
31 | */ |
| 32 | /** @file |
32 | /** @file |
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| Line 36... | Line 36... | ||
| 36 | #include <arch/drivers/pic.h> |
36 | #include <arch/drivers/pic.h> |
| 37 | #include <mm/page.h> |
37 | #include <mm/page.h> |
| 38 | #include <byteorder.h> |
38 | #include <byteorder.h> |
| 39 | #include <bitops.h> |
39 | #include <bitops.h> |
| 40 | 40 | ||
| 41 | static volatile uint32_t *pic; |
41 | static volatile uint32_t *pic = NULL; |
| 42 | 42 | ||
| 43 | void pic_init(uintptr_t base, size_t size) |
43 | void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg) |
| 44 | { |
44 | { |
| 45 | pic = (uint32_t *) hw_map(base, size); |
45 | pic = (uint32_t *) hw_map(base, size); |
| - | 46 | *cir = pic_ack_interrupt; |
|
| - | 47 | *cir_arg = NULL; |
|
| 46 | } |
48 | } |
| 47 | 49 | ||
| 48 | void pic_enable_interrupt(int intnum) |
50 | void pic_enable_interrupt(inr_t intnum) |
| 49 | { |
51 | { |
| - | 52 | if (pic) { |
|
| 50 | if (intnum < 32) { |
53 | if (intnum < 32) |
| 51 | pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum); |
54 | pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum); |
| 52 | } else { |
55 | else |
| 53 | pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32)); |
56 | pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32)); |
| 54 | } |
57 | } |
| 55 | 58 | ||
| 56 | } |
59 | } |
| 57 | 60 | ||
| 58 | void pic_disable_interrupt(int intnum) |
61 | void pic_disable_interrupt(inr_t intnum) |
| 59 | { |
62 | { |
| - | 63 | if (pic) { |
|
| 60 | if (intnum < 32) { |
64 | if (intnum < 32) |
| 61 | pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum)); |
65 | pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum)); |
| 62 | } else { |
66 | else |
| 63 | pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32))); |
67 | pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32))); |
| 64 | } |
68 | } |
| 65 | } |
69 | } |
| 66 | 70 | ||
| 67 | void pic_ack_interrupt(int intnum) |
71 | void pic_ack_interrupt(void *arg, inr_t intnum) |
| 68 | { |
72 | { |
| - | 73 | if (pic) { |
|
| 69 | if (intnum < 32) |
74 | if (intnum < 32) |
| 70 | pic[PIC_ACK_LOW] = 1 << intnum; |
75 | pic[PIC_ACK_LOW] = 1 << intnum; |
| 71 | else |
76 | else |
| 72 | pic[PIC_ACK_HIGH] = 1 << (intnum - 32); |
77 | pic[PIC_ACK_HIGH] = 1 << (intnum - 32); |
| - | 78 | } |
|
| 73 | } |
79 | } |
| 74 | 80 | ||
| 75 | /** Return number of pending interrupt */ |
81 | /** Return number of pending interrupt */ |
| 76 | int pic_get_pending(void) |
82 | int pic_get_pending(void) |
| 77 | { |
83 | { |
| - | 84 | if (pic) { |
|
| 78 | int pending; |
85 | int pending; |
| 79 | 86 | ||
| 80 | pending = pic[PIC_PENDING_LOW]; |
87 | pending = pic[PIC_PENDING_LOW]; |
| 81 | if (pending) |
88 | if (pending) |
| 82 | return fnzb32(pending); |
89 | return fnzb32(pending); |
| 83 | 90 | ||
| 84 | pending = pic[PIC_PENDING_HIGH]; |
91 | pending = pic[PIC_PENDING_HIGH]; |
| 85 | if (pending) |
92 | if (pending) |
| 86 | return fnzb32(pending) + 32; |
93 | return fnzb32(pending) + 32; |
| - | 94 | } |
|
| 87 | 95 | ||
| 88 | return -1; |
96 | return -1; |
| 89 | } |
97 | } |
| 90 | 98 | ||
| 91 | /** @} |
99 | /** @} |