disable debug.
[AROS.git] / arch / m68k-amiga / cia / addicrvector.c
blob45f11747c762e85540ebbcfd71415d0f7adb92a4
1 /*
2 Copyright © 2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AddICRVector() function.
6 Lang: english
7 */
9 #include <exec/interrupts.h>
10 #include <proto/cia.h>
11 #include <proto/exec.h>
13 #include "cia_intern.h"
15 AROS_LH2(struct Interrupt *, AddICRVector,
16 AROS_LHA(LONG, iCRBit, D0),
17 AROS_LHA(struct Interrupt *, interrupt, A1),
18 struct Library *, resource, 1, Cia)
20 AROS_LIBFUNC_INIT
22 struct CIABase *CiaBase = (struct CIABase *)resource;
23 struct Interrupt *old;
25 if (iCRBit == -1) {
26 /* Hack. Was called by timer.device, see below */
27 CiaBase->hook_func = (void(*)(APTR, APTR, WORD))interrupt->is_Code;
28 CiaBase->hook_data = interrupt->is_Data;
29 return NULL;
32 /* 68k lowlevel library calls have garbage in upper word */
33 iCRBit = (WORD)iCRBit;
34 Disable();
35 old = CiaBase->Vectors[iCRBit];
36 if (old) {
37 /* timer.device move out of our way hack.
38 * Check timer.device for details
40 if (CiaBase->hook_func) {
41 void (*hook)(APTR, APTR, WORD) = CiaBase->hook_func;
42 CiaBase->hook_func = NULL;
43 hook(CiaBase, CiaBase->hook_data, iCRBit);
44 CiaBase->hook_func = hook;
45 old = CiaBase->Vectors[iCRBit];
48 if (old == NULL) {
49 CiaBase->Vectors[iCRBit] = interrupt;
50 AbleICR(resource, 0x80 | (1 << iCRBit));
52 Enable();
53 return old;
55 AROS_LIBFUNC_EXIT