Bringing flexcat 2.15 into the main branch (again)
[AROS.git] / arch / m68k-amiga / cia / ableicr.c
blobb559427a8dfba1cfdd009221188e3eac238e981e
1 /*
2 Copyright © 2010, The AROS Development Team. All rights reserved.
3 $Id:$
5 Desc: AbleICR() function.
6 Lang: english
7 */
9 #include <exec/libraries.h>
10 #include <proto/cia.h>
11 #include <proto/exec.h>
12 #include <hardware/cia.h>
13 #include <hardware/custom.h>
14 #include <hardware/intbits.h>
16 #include "cia_intern.h"
18 AROS_LH1(WORD, AbleICR,
19 AROS_LHA(WORD, mask, D0),
20 struct Library *, resource, 3, Cia)
22 AROS_LIBFUNC_INIT
24 struct CIABase *CiaBase = (struct CIABase *)resource;
25 volatile struct Custom *custom = (struct Custom *)0xdff000;
26 UBYTE old;
28 Disable();
30 old = CiaBase->enable_mask;
32 if (mask & 0x80)
33 CiaBase->enable_mask |= mask & 0x1f;
34 else
35 CiaBase->enable_mask &= ~mask;
37 CiaBase->hw->ciaicr = mask;
38 // do we need to trigger the interrupt now?
39 if (CiaBase->enable_mask & CiaBase->active_mask)
40 custom->intreq = INTF_SETCLR | CiaBase->inten_mask;
42 Enable();
44 return old;
46 AROS_LIBFUNC_EXIT