2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <exec/types.h>
11 #include <exec/interrupts.h>
12 #include <hardware/intbits.h>
13 #include <proto/exec.h>
14 #include <aros/symbolsets.h>
15 #include "card_intern.h"
17 AROS_INTP(card_level2
);
18 AROS_INTP(card_level6
);
20 void CardTask(struct Task
*parent
, struct CardResource
*CardResource
);
22 static BOOL
addpcmciaram(struct CardResource
*CardResource
, struct CardHandle
*ch
, struct DeviceTData
*dtd
)
24 ULONG size
= dtd
->dtd_DTsize
;
25 APTR addr
=(APTR
)GAYLE_RAM
;
29 if (size
> GAYLE_RAMSIZE
)
33 AddMemList(size
, MEMF_FAST
| MEMF_PUBLIC
, -5, addr
, CardResource
->crb_LibNode
.lib_Node
.ln_Name
);
37 static BOOL
checkcard(struct CardResource
*CardResource
)
39 struct CardHandle
*ch
;
42 ch
= AllocVec(sizeof(struct CardHandle
), MEMF_CLEAR
);
44 ch
->cah_CardFlags
= CARDF_IFAVAILABLE
;
47 struct DeviceTData dtd
;
52 if (!CopyTuple(ch
, NULL
, 0, 0)) { /* debug log all tuples, check if tuple chain is valid */
53 CARDDEBUG(bug("Invalid tuple chain detected\n"));
57 CARDDEBUG(bug("CISTPL_AMIGAXIP found\n"));
58 } else if (CopyTuple(ch
, device
, CISTPL_DEVICE
, sizeof(device
) - 2)) {
59 if (DeviceTuple(device
, &dtd
)) {
60 if (dtd
.dtd_DTtype
== DTYPE_SRAM
|| dtd
.dtd_DTtype
== DTYPE_DRAM
) {
61 CARDDEBUG(bug("Type %d RAM card found, size %d bytes, speed %d\n", dtd
.dtd_DTtype
, dtd
.dtd_DTsize
, dtd
.dtd_DTspeed
));
62 if (!CopyTuple(ch
, device
, CISTPL_FORMAT
, 0) && !CopyTuple(ch
, device
, CISTPL_GEOMETRY
, 0) && dtd
.dtd_DTspeed
<= 250) {
63 if (addpcmciaram(CardResource
, ch
, &dtd
)) {
64 CardAccessSpeed(ch
, dtd
.dtd_DTspeed
);
65 CARDDEBUG(bug("Mapped as System RAM.\n"));
69 CARDDEBUG(bug("Not usable as System RAM.\n"));
78 ReleaseCard(ch
, CARDF_REMOVEHANDLE
);
85 static int Cardres_Init(struct CardResource
*CardResource
)
88 struct Interrupt
*intr
;
89 volatile struct GayleIO
*gio
= (struct GayleIO
*)GAYLE_BASE
;
95 /* No Gayle = No PCMCIA slot */
99 /* Address space conflict? */
100 if (TypeOfMem((UBYTE
*)GAYLE_RAM
+ 0x1000) != 0)
103 NEWLIST(&CardResource
->handles
);
105 CARDDEBUG(bug("PCMCIA slot enabled\n"));
107 pcmcia_reset(CardResource
);
110 CardResource
->removed
= TRUE
;
111 if (gio
->status
& GAYLE_CS_CCDET
) {
113 CARDDEBUG(bug("Inserted PCMCIA card detected\n"));
114 pcmcia_cardreset(CardResource
);
115 CardResource
->removed
= FALSE
;
116 if (checkcard(CardResource
)) {
117 CardResource
->resetberr
= GAYLE_IRQ_RESET
;
118 pcmcia_clear_requests(CardResource
);
119 /* Installed as Fast RAM. Do not initialize resource */
124 CardResource
->task
= NewCreateTask(
125 TASKTAG_PC
, CardTask
,
126 TASKTAG_NAME
, CardResource
->crb_LibNode
.lib_Node
.ln_Name
,
128 TASKTAG_ARG1
, FindTask(0),
129 TASKTAG_ARG2
, CardResource
,
131 if (!CardResource
->task
)
133 Wait(SIGBREAKF_CTRL_F
);
137 intr
= &CardResource
->level2
;
138 intr
->is_Node
.ln_Pri
= 127;
139 intr
->is_Node
.ln_Type
= NT_INTERRUPT
;
140 intr
->is_Node
.ln_Name
= CardResource
->crb_LibNode
.lib_Node
.ln_Name
;
141 intr
->is_Code
= (APTR
)card_level2
;
142 intr
->is_Data
= CardResource
;
143 AddIntServer(INTB_PORTS
, intr
);
145 intr
= &CardResource
->level6
;
146 intr
->is_Node
.ln_Pri
= -127;
147 intr
->is_Node
.ln_Type
= NT_INTERRUPT
;
148 intr
->is_Node
.ln_Name
= CardResource
->crb_LibNode
.lib_Node
.ln_Name
;
149 intr
->is_Code
= (APTR
)card_level6
;
150 intr
->is_Data
= CardResource
;
151 AddIntServer(INTB_EXTER
, intr
);
153 pcmcia_clear_requests(CardResource
);
154 pcmcia_enable_interrupts();
161 ADD2INITLIB(Cardres_Init
, 0)