2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
11 /*********************************************************************************
12 Not a very good example at all. But at least it should prove that
13 AROS is able to use camd-drivers. -Kjetil M.
15 Compiling it up is easy. Its just like any other AROS-program, showed
19 debugdriver: debugdriver.o
20 gcc -nostartfiles -nostdlib -Xlinker -i ../../lib/startup.o debugdriver.o -o debugdriver -L../../lib -larossupport -lamiga -larosc -larosm
22 debugdriver.o: debugdriver.c makefile
23 gcc debugdriver.c -c -I../../Include -Wall
26 ***********************************************************************************/
29 #include <exec/types.h>
30 #include <midi/camddevices.h>
31 #include <hidd/unixio.h>
32 #include <proto/exec.h>
33 #include <proto/oop.h>
34 #include <libcore/compiler.h>
40 struct ExecBase
*SysBase
;
41 struct Library
*OOPBase
;
42 struct Library
*UnixIOBase
;
49 /* A camd mididriver is not supposed to be run directly, so we return an error. */
58 static const char version
[];
60 extern void kprintf(char *bla
,...);
62 BOOL ASM
Init(REG(a6
) APTR sysbase
);
64 SAVEDS ASM
struct MidiPortData
*OpenPort(
65 REG(a3
) struct MidiDeviceData
*data
,
67 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
68 REG(a1
) void (* ASM receivefunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
72 REG(a3
) struct MidiDeviceData
*data
,
78 /***********************************************************************
79 The mididevicedata struct.
80 Note. It doesn't have to be declared with the const qualifier, since
81 NPorts may be set at Init. You should set the name-field to the
82 same as the filename, that might be a demand...
83 ***********************************************************************/
84 const struct MidiDeviceData mididevicedata
=
99 static const char version
[] = "$VER: HostMidi V41.0 (c) 2001 AROS - The AROS Research OS";
101 /****************************************************************
102 We only store sysbase, thats all we need in this example.
103 Otherwise, you may want to open libraries, set number of
104 ports, obtain interrupts, etc.
105 ***************************************************************/
107 SAVEDS ASM BOOL
Init(REG(a6
) APTR sysbase
)
111 D(kprintf("hostmidi_init\n"));
113 OOPBase
= OpenLibrary("oop.library", 0);
114 if (!OOPBase
) return FALSE
;
116 UnixIOBase
= OpenLibrary("unixio.hidd", 0);
119 CloseLibrary(OOPBase
);
123 unixio
= OOP_NewObject(NULL
, CLID_Hidd_UnixIO
, NULL
);
126 CloseLibrary(UnixIOBase
);
127 CloseLibrary(OOPBase
);
131 midi_fd
= Hidd_UnixIO_OpenFile(unixio
, "/dev/midi",
138 OOP_DisposeObject(unixio
);
139 CloseLibrary(UnixIOBase
);
140 CloseLibrary(OOPBase
);
149 /****************************************************************
150 Nothing to do here. Normally, you may want to free memory,
151 close some libraries, free some interrupts, etc.
152 *****************************************************************/
155 if (midi_fd
) Hidd_UnixIO_CloseFile(unixio
, midi_fd
, NULL
);
156 if (unixio
) OOP_DisposeObject(unixio
);
158 CloseLibrary(OOPBase
);
163 ULONG (ASM
*TransmitFunc
)(REG(a2
) APTR userdata
);
164 APTR UserData
[NUMPORTS
];
168 /****************************************************************
169 Normally, you may want to start an interrupt, or signal another task,
170 or send a message to a port, that calls the transmit-function.
171 But for this small example, sending the signal directly via
172 kprintf is excactly what we want to do.
173 ****************************************************************/
175 SAVEDS ASM
void ActivateXmit(REG(a2
) APTR userdata
,ULONG
REG(d0
) portnum
)
184 data
=(TransmitFunc
)(userdata
);
186 if(data
==0x100) return;
190 Hidd_UnixIO_WriteFile(unixio
, midi_fd
, buf
, 1, &errno
);
194 struct MidiPortData midiportdata
=
200 /****************************************************************
201 This one is called whenever a program that has opened
202 camd.library wants to use your services.
203 ****************************************************************/
204 SAVEDS ASM
struct MidiPortData
*OpenPort(
205 REG(a3
) struct MidiDeviceData
*data
,
206 REG(d0
) LONG portnum
,
207 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
208 REG(a1
) void (* ASM receiverfunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
209 REG(a2
) APTR userdata
212 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
214 TransmitFunc
=transmitfunc
;
215 UserData
[portnum
-1]=userdata
;
217 return &midiportdata
;
222 /****************************************************************
223 Nothing to do here. Normally, you may want to free memory,
224 mark the port not to be in use anymore, delete a task, etc.
225 *****************************************************************/
227 REG(a3
) struct MidiDeviceData
*data
,