2 * CAMD Driver for Poseidon USB camdusbmidi.class
4 * Copyright
2006 Chris Hodges
6 ************************************************************************
8 *-----------------------------------------------------------------------
9 * 04-Feb
-2006 : Initial
10 ************************************************************************
12 ;output DEVS:midi/poseidonusb
17 include "exec/types.i"
18 include "exec/execbase.i" ; for FlushDevice()
19 include "exec/macros.i"
20 include "exec/ports.i"
21 include "utility/hooks.i"
22 include "midi/camddevices.i"
24 _LVOusbCAMDOpenPort
equ -108
25 _LVOusbCAMDClosePort
equ -114
33 STRUCTURE CAMDAdapter
,0
36 STRUCT ca_CAMDRXFunc
,h_SIZEOF
37 STRUCT ca_CAMDTXFunc
,IS_SIZE
47 LABEL CAMDAdapter_SIZE
49 ****************************************************************
51 * Standard MIDI Device driver header
53 ****************************************************************
55 ; code at start of file in case anyone tries to execute us as a program
61 MDD
; struct MidiDeviceData
62 dc.l MDD_Magic
; mdd_Magic
64 dc.l IDString
; mdd_IDString
65 dc.w Version
; mdd_Version
66 dc.w Revision
; mdd_Revision
68 dc.l Expunge
; mdd_Expunge
69 dc.l OpenPort
; mdd_OpenPort
70 dc.l ClosePort
; mdd_ClosePort
71 dc.b Ports
; mdd_NPorts
75 Name dc.b
'poseidonusb',0
76 dc.b
'3456789012345678901',0 ; 32 bytes
79 dc.b
'$VER: Poseidon USB camdusbmidi.class driver 1.1 (21-Feb-06)',0
80 dc.b
'Copyright 2006 Chris Hodges',0
83 ****************************************************************
85 * MidiDeviceData Functions
87 ****************************************************************
89 ****************************************************************
94 * Gets called by CAMD after being LoadSeg
'ed.
100 * TRUE if successful, FALSE on failure.
102 ****************************************************************
109 lea .classname(pc),a1
114 lea .classname2(pc),a1
123 dc.b 'camdusbmidi.class
',0
127 ****************************************************************
132 * Gets called by CAMD immediately before being
141 ****************************************************************
144 PUTMSG
10,<"Expunge!">
146 move.l SysBase
(pc
),a6
147 move.l USBClsBase
(pc
),a1
154 ****************************************************************
158 * Called by CallHookA
() from camdusbmidi.class with Buffer address
in a2
161 ****************************************************************
164 PUTMSG
10,<"SendToCAMD %08lx, buf=%08lx">,a0
,a2
167 move.l a2
,a3
; object
170 PUTMSG
10,<"size=%08ld">,d2
171 move.l ca_UserData
(a0
),a2
172 move.l ca_RXFunc
(a0
),a4
182 ****************************************************************
186 * Called by Cause
() from ActivateXmit.
188 ****************************************************************
191 PUTMSG
10,<"GetFromCAMD %08lx">,a1
194 move.l ca_UserData
(a3
),a2
195 move.l ca_TXBuffer
(a3
),a5
196 move.l ca_TXFunc
(a3
),a4
197 move.l ca_TXBufSize
(a3
),d3
198 move.l ca_TXWritePos
(a3
),d2
201 PUTMSG
10,<"Byte... %lx %ld">,d0
,d1
205 cmp.l ca_TXReadPos
(a3
),d2
206 beq.s .oops
; this will lose data!
207 move.l d2
,ca_TXWritePos
(a3
)
211 move.l ca_MsgPort
(a3
),d0
; now inform usb driver
214 move.l MP_SIGTASK
(a0
),a1
217 move.b MP_SIGBIT
(a0
),d1
219 move.l SysBase
(pc
),a6
226 ****************************************************************
234 * D0.b
- Port number
(should always be
0 for
this driver
)
240 * D0
- pointer to MidiPortData structure.
242 ****************************************************************
245 PUTMSG
10,<"OpenPort %ld, Xmit=%08lx,Recv=%08lx,Data=%08lx">,d0
,a0
,a1
,a2
247 move.l USBClsBase
(pc
),a6
253 lea CAMDPortBases
(pc
),a0
254 move.l d0
,(a0
,d2.l
*4)
257 lea ActivateXmit0
(pc
,d2.l
*4),a1
258 move.l a1
,ca_ActivateFunc
(a0
)
260 move.l d0
,ca_CAMDRXFunc
+h_Data
(a0
)
261 lea SendToCAMD
(pc
),a1
262 move.l a1
,ca_CAMDRXFunc
+h_Entry
(a0
)
264 move.b #NT_INTERRUPT
,ca_CAMDTXFunc
+LN_TYPE
(a0
)
265 clr.b ca_CAMDTXFunc
+LN_PRI
(a0
)
266 move.l d0
,ca_CAMDTXFunc
+IS_DATA
(a0
)
267 lea GetFromCAMD
(pc
),a1
268 move.l a1
,ca_CAMDTXFunc
+IS_CODE
(a0
)
270 .toobad PUTMSG
10,<"Result=%08lx">,d0
275 ****************************************************************
283 * D0.b
- Port number
(always
0 for
this driver
).
289 ****************************************************************
293 move.l USBClsBase
(pc
),a6
296 CALL usbCAMDClosePort
301 kprintf PUSHM a2
-a3
/a6
308 .putchr dc.w
$CD4B,$4EAE,$FDFC,$CD4B,$4E75
311 ****************************************************************
315 * Called by CAMD with Midi Data
in a0
(or a2
?)
316 * BUG: Actually
, the Midi Data is
not in any register.
This sucks
318 ****************************************************************
355 PUTMSG
10,<"ActivateXmit Port %ld">,d0
357 move.l SysBase
(pc
),a6
358 move.l CAMDPortBases
(pc
,d0.l
*4),a0
359 lea ca_CAMDTXFunc
(a0
),a1