2 Copyright © 1995-2001, 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>
38 struct ExecBase
*SysBase
;
39 struct Library
*OOPBase
;
46 /* A camd mididriver is not supposed to be run directly, so we return an error. */
55 extern void kprintf(char *bla
,...);
57 BOOL ASM
Init(REG(a6
) APTR sysbase
);
59 SAVEDS ASM
struct MidiPortData
*OpenPort(
60 REG(a3
) struct MidiDeviceData
*data
,
62 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
63 REG(a1
) void (* ASM recievefunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
67 REG(a3
) struct MidiDeviceData
*data
,
75 /***********************************************************************
76 The mididevicedata struct.
77 Note. It doesn't have to be declared with the const qualifier, since
78 NPorts may be set at Init. You should set the name-field to the
79 same as the filename, that might be a demand...
80 ***********************************************************************/
81 const struct MidiDeviceData mididevicedata
=
85 "HostMidi V41.0 (c) 2001 AROS - The AROS Research OS",
96 /****************************************************************
97 We only store sysbase, thats all we need in this example.
98 Otherwise, you may want to open libraries, set number of
99 ports, obtain interrupts, etc.
100 ***************************************************************/
102 SAVEDS ASM BOOL
Init(REG(a6
) APTR sysbase
)
106 kprintf("hostmidi_init\n");
107 OOPBase
= OpenLibrary("oop.library", 0);
108 if (!OOPBase
) return FALSE
;
110 unixio
= OOP_NewObject(NULL
, CLID_Hidd_UnixIO
, NULL
);
113 CloseLibrary(OOPBase
);
117 midi_fd
= Hidd_UnixIO_OpenFile((HIDD
*)unixio
, "/dev/midi",
124 OOP_DisposeObject(unixio
);
125 CloseLibrary(OOPBase
);
134 /****************************************************************
135 Nothing to do here. Normally, you may want to free memory,
136 close some libraries, free some interrupts, etc.
137 *****************************************************************/
140 if (midi_fd
) Hidd_UnixIO_CloseFile((HIDD
*)unixio
, midi_fd
, NULL
);
141 if (unixio
) OOP_DisposeObject(unixio
);
143 CloseLibrary(OOPBase
);
148 ULONG (ASM
*TransmitFunc
)(REG(a2
) APTR userdata
);
149 APTR UserData
[NUMPORTS
];
153 /****************************************************************
154 Normally, you may want to start an interrupt, or signal another task,
155 or send a message to a port, that calls the transmit-function.
156 But for this small example, sending the signal directly via
157 kprintf is excactly what we want to do.
158 ****************************************************************/
160 SAVEDS ASM
void ActivateXmit(REG(a2
) APTR userdata
,ULONG
REG(d0
) portnum
)
169 data
=(TransmitFunc
)(userdata
);
171 if(data
==0x100) return;
175 written
= Hidd_UnixIO_WriteFile((HIDD
*)unixio
, midi_fd
, buf
, 1, &errno
);
179 struct MidiPortData midiportdata
=
185 /****************************************************************
186 This one is called whenever a program that has opened
187 camd.library wants to use your services.
188 ****************************************************************/
189 SAVEDS ASM
struct MidiPortData
*OpenPort(
190 REG(a3
) struct MidiDeviceData
*data
,
191 REG(d0
) LONG portnum
,
192 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
193 REG(a1
) void (* ASM recieverfunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
194 REG(a2
) APTR userdata
197 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
199 TransmitFunc
=transmitfunc
;
200 UserData
[portnum
-1]=userdata
;
202 return &midiportdata
;
207 /****************************************************************
208 Nothing to do here. Normally, you may want to free memory,
209 mark the port not to be in use anymore, delete a task, etc.
210 *****************************************************************/
212 REG(a3
) struct MidiDeviceData
*data
,