Bringing flexcat 2.15 into the main branch (again)
[AROS.git] / arch / m68k-amiga / cia / seticr.c
blob44eb20bbb035d29d59ee1921e3526ebee9b195ad
1 /*
2 Copyright © 2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: SetICR() 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, SetICR,
19 AROS_LHA(WORD, mask, D0),
20 struct Library *, resource, 4, Cia)
22 AROS_LIBFUNC_INIT
24 struct CIABase *CiaBase = (struct CIABase *)resource;
25 volatile struct Custom *custom = (struct Custom*)0xdff000;
26 WORD old;
28 Disable();
30 // I think this needs to return interrupt=active status
31 // if called inside CIA interrupt handler
32 CiaBase->active_mask |= CiaBase->hw->ciaicr & 0x1f;
33 old = CiaBase->active_mask | CiaBase->executing_mask;
34 if (mask & 0x80)
35 CiaBase->active_mask |= mask & 0x1f;
36 else
37 CiaBase->active_mask &= ~mask;
39 // do we need to trigger the interrupt now?
40 if (CiaBase->enable_mask & CiaBase->active_mask)
41 custom->intreq = INTF_SETCLR | CiaBase->inten_mask;
43 Enable();
45 return old;
47 AROS_LIBFUNC_EXIT