revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / midi / debugdriver.c
blob05b2a27d33cfff3aa307af0df11567576c9fe916
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
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
16 by this makefile:
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 <proto/exec.h>
30 #include <exec/types.h>
31 #include <midi/camddevices.h>
32 #include <libcore/compiler.h>
34 #define NUMPORTS 4
36 #define D(x)
38 struct ExecBase *SysBase;
41 int main(void){
42 /* A camd mididriver is not supposed to be run directly, so we return an error. */
43 return -1;
48 /* Prototypes */
50 extern void kprintf(char *bla,...);
52 BOOL ASM Init(REG(a6) APTR sysbase);
53 void Expunge(void);
54 SAVEDS ASM struct MidiPortData *OpenPort(
55 REG(a3) struct MidiDeviceData *data,
56 REG(d0) LONG portnum,
57 REG(a0) ULONG (* ASM transmitfunc)(APTR REG(a2) userdata),
58 REG(a1) void (* ASM receivefunc)(UWORD REG(d0) input,APTR REG(a2) userdata),
59 REG(a2) APTR userdata
61 ASM void ClosePort(
62 REG(a3) struct MidiDeviceData *data,
63 REG(d0) LONG portnum
66 /* End prototypes */
70 /***********************************************************************
71 The mididevicedata struct.
72 Note. It doesn't have to be declared with the const qualifier, since
73 NPorts may be set at Init. You should set the name-field to the
74 same as the filename, that might be a demand...
75 ***********************************************************************/
76 const struct MidiDeviceData mididevicedata={
77 MDD_Magic,
78 "debugdriver",
79 "Debugdriver V41.0 (c) 2001 AROS - The AROS Research OS",
80 41,
82 Init,
83 Expunge,
84 OpenPort,
85 ClosePort,
86 NUMPORTS,
90 /****************************************************************
91 We only store sysbase, thats all we need in this example.
92 Otherwise, you may want to open libraries, set number of
93 ports, obtain interrupts, etc.
94 ***************************************************************/
95 SAVEDS ASM BOOL Init(REG(a6) APTR sysbase){
96 SysBase=sysbase;
97 return TRUE;
100 /****************************************************************
101 Nothing to do here. Normally, you may want to free memory,
102 close some libraries, free some interrupts, etc.
103 *****************************************************************/
104 void Expunge(void){
105 return;
110 ULONG (ASM *TransmitFunc)(REG(a2) APTR userdata);
111 APTR UserData[NUMPORTS];
115 /****************************************************************
116 Normally, you may want to start an interrupt, or signal another task,
117 or send a message to a port, that calls the transmit-function.
118 But for this small example, sending the signal directly via
119 kprintf is excactly what we want to do.
120 ****************************************************************/
121 SAVEDS ASM void ActivateXmit(REG(a2) APTR userdata,ULONG REG(d0) portnum){
122 ULONG data;
123 for(;;){
125 data=(TransmitFunc)(userdata);
127 if(data==0x100) return;
128 D(kprintf("Debugdriver has received: %lx at port %ld\n",data,portnum);)
132 struct MidiPortData midiportdata={
133 ActivateXmit
137 /****************************************************************
138 This one is called whenever a program that has opened
139 camd.library wants to use your services.
140 ****************************************************************/
141 SAVEDS ASM struct MidiPortData *OpenPort(
142 REG(a3) struct MidiDeviceData *data,
143 REG(d0) LONG portnum,
144 REG(a0) ULONG (* ASM transmitfunc)(APTR REG(a2) userdata),
145 REG(a1) void (* ASM receiverfunc)(UWORD REG(d0) input,APTR REG(a2) userdata),
146 REG(a2) APTR userdata
148 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
150 TransmitFunc=transmitfunc;
151 UserData[portnum-1]=userdata;
152 return &midiportdata;
157 /****************************************************************
158 Nothing to do here. Normally, you may want to free memory,
159 mark the port not to be in use anymore, delete a task, etc.
160 *****************************************************************/
161 ASM void ClosePort(
162 REG(a3) struct MidiDeviceData *data,
163 REG(d0) LONG portnum
165 return;