2 * This is a skeleton of cia.resource implementation.
4 * Note that it uses custom initcode because cia.resource does not
5 * act in standard way. This module in fact contains two resources:
6 * ciaa.resource and ciab.resource.
7 * genmodule does not support such thing, so everything is written
10 * Since we don't use genmodule, we have to use some other way for
11 * generating include files. A standard SFD file is used to keep all
12 * the definitions, it's processed using sfdc (note that it had to
13 * be fixed in order to support explicit base specification correctly)
15 * Note that fd2inline (which also supports generating AROS macros) will
16 * generate a BROKEN inline file for this resource. It handles missing
17 * base specification incorrectly.
19 * sonic <pavel_fedin@mail.ru>
22 #include <exec/types.h>
23 #include <exec/libraries.h>
24 #include <exec/resident.h>
25 #include <aros/libcall.h>
26 #include <aros/asmcall.h>
29 #include <proto/exec.h>
30 #include <proto/alib.h>
32 #include <hardware/cia.h>
33 #include <hardware/custom.h>
34 #include <hardware/intbits.h>
37 #include <aros/debug.h>
39 #include "cia_intern.h"
42 #define STR(A) _STR(A)
44 AROS_LD2(struct Interrupt
*, AddICRVector
,
45 AROS_LDA(WORD
, iCRBit
, D0
),
46 AROS_LDA(struct Interrupt
*, interrupt
, A1
),
47 struct Library
*, resource
, 1, Cia
49 AROS_LD2(void, RemICRVector
,
50 AROS_LDA(WORD
, iCRBit
, A0
),
51 AROS_LDA(struct Interrupt
*, interrupt
, A1
),
52 struct Library
*, resource
, 2, Cia
54 AROS_LD1(WORD
, AbleICR
,
55 AROS_LDA(WORD
, mask
, D0
),
56 struct Library
*, resource
, 3, Cia
58 AROS_LD1(WORD
, SetICR
,
59 AROS_LDA(WORD
, mask
, D0
),
60 struct Library
*, resource
, 4, Cia
63 #define RESIDENT_FLAGS RTF_COLDSTART
64 #define RESIDENT_PRIORITY 80
65 #define RESIDENT_NAME "cia.resource"
66 #define RESIDENT_VERSION 0
67 #define RESIDENT_REVISION 1
69 static const char resident_name
[] = RESIDENT_NAME
;
70 static const char resident_id
[] = "\0$VER:" RESIDENT_NAME
" " STR(RESIDENT_VERSION
) "." STR(RESIDENT_REVISION
) " (" ADATE
")";
72 AROS_INTP(Cia_Handler
);
74 static AROS_UFP3 (APTR
, Cia_Init
,
75 AROS_UFPA(struct Library
*, lh
, D0
),
76 AROS_UFPA(BPTR
, segList
, A0
),
77 AROS_UFPA(struct ExecBase
*, sysBase
, A6
));
79 extern void Cia_End(void);
81 struct Resident
const Cia_ROMTag
=
95 static const APTR Cia_FuncTable
[]=
97 &AROS_SLIB_ENTRY(AddICRVector
,Cia
,1),
98 &AROS_SLIB_ENTRY(RemICRVector
,Cia
,2),
99 &AROS_SLIB_ENTRY(AbleICR
,Cia
,3),
100 &AROS_SLIB_ENTRY(SetICR
,Cia
,4),
104 static struct CIABase
*InitResource(char *Name
, struct ExecBase
*SysBase
)
106 struct CIABase
*base
;
108 base
= (struct CIABase
*)MakeLibrary((APTR
)Cia_FuncTable
, NULL
, NULL
, sizeof(struct CIABase
), 0);
111 base
->lib
.lib_Node
.ln_Type
= NT_RESOURCE
;
112 base
->lib
.lib_Node
.ln_Name
= Name
;
113 base
->lib
.lib_Version
= RESIDENT_VERSION
;
114 base
->lib
.lib_IdString
= (STRPTR
)&resident_id
[6];
115 base
->lib
.lib_Flags
= LIBF_SUMUSED
|LIBF_CHANGED
;
116 base
->lib
.lib_Revision
= RESIDENT_REVISION
;
123 static AROS_UFH3 (APTR
, Cia_Init
,
124 AROS_UFHA(struct Library
*, lh
, D0
),
125 AROS_UFHA(BPTR
, segList
, A0
),
126 AROS_UFHA(struct ExecBase
*, sysBase
, A6
)
131 struct CIABase
*base
;
133 /* Initialize ciaa.resource */
134 base
= InitResource("ciaa.resource", SysBase
);
138 base
->hw
= (struct CIA
*)0xbfe001;
139 base
->hw
->ciaicr
= 0x7f;
140 base
->hw
->ciacra
= 0x00;
141 base
->hw
->ciacrb
= 0x80;
142 base
->hw
->ciatodhi
= 0x00;
143 base
->hw
->ciatodmid
= 0x0f;
144 base
->hw
->ciatodlow
= 0x00;
145 base
->hw
->ciacrb
= 0x00;
146 base
->hw
->ciapra
= 0x00;
147 base
->hw
->ciaddra
= 0x03;
148 base
->hw
->ciaddrb
= 0xff;
149 base
->inten_mask
= INTF_PORTS
;
151 base
->ciaint
.is_Node
.ln_Pri
= 120;
152 base
->ciaint
.is_Node
.ln_Type
= NT_INTERRUPT
;
153 base
->ciaint
.is_Node
.ln_Name
= "CIA-A";
154 base
->ciaint
.is_Code
= (APTR
)Cia_Handler
;
155 base
->ciaint
.is_Data
= base
;
156 AddIntServer(INTB_PORTS
, &base
->ciaint
);
158 D(bug("CIA-A %p\n", base
));
160 /* Initialize ciab.resource */
161 base
= InitResource("ciab.resource", SysBase
);
165 base
->hw
= (struct CIA
*)0xbfd000;
166 base
->hw
->ciaicr
= 0x7f;
167 base
->hw
->ciacra
= 0x00;
168 base
->hw
->ciacrb
= 0x80;
169 base
->hw
->ciatodhi
= 0x00;
170 base
->hw
->ciatodmid
= 0x0f;
171 base
->hw
->ciatodlow
= 0x00;
172 base
->hw
->ciacrb
= 0x00;
173 base
->hw
->ciapra
= 0xff;
174 base
->hw
->ciaprb
= 0xff;
175 base
->hw
->ciaddra
= 0xff;
176 base
->hw
->ciaddrb
= 0xff;
177 base
->inten_mask
= INTF_EXTER
;
179 base
->ciaint
.is_Node
.ln_Pri
= 120;
180 base
->ciaint
.is_Node
.ln_Type
= NT_INTERRUPT
;
181 base
->ciaint
.is_Node
.ln_Name
= "CIA-B";
182 base
->ciaint
.is_Code
= (APTR
)Cia_Handler
;
183 base
->ciaint
.is_Data
= base
;
184 AddIntServer(INTB_EXTER
, &base
->ciaint
);
186 D(bug("CIA-B %p\n", base
));