adjust the memheader is necessary when adding blocks to tlsf. alter debug for consist...
[AROS.git] / workbench / devs / midi / debugdriver.c
blobb0ca063504a8e263dc21b0e0b861c51b3c05a8aa
1 /*
2 Copyright © 1995-2011, 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 struct ExecBase *SysBase;
39 int main(void){
40 /* A camd mididriver is not supposed to be run directly, so we return an error. */
41 return -1;
46 /* Prototypes */
48 extern void kprintf(char *bla,...);
50 BOOL ASM Init(REG(a6) APTR sysbase);
51 void Expunge(void);
52 SAVEDS ASM struct MidiPortData *OpenPort(
53 REG(a3) struct MidiDeviceData *data,
54 REG(d0) LONG portnum,
55 REG(a0) ULONG (* ASM transmitfunc)(APTR REG(a2) userdata),
56 REG(a1) void (* ASM receivefunc)(UWORD REG(d0) input,APTR REG(a2) userdata),
57 REG(a2) APTR userdata
59 ASM void ClosePort(
60 REG(a3) struct MidiDeviceData *data,
61 REG(d0) LONG portnum
64 /* End prototypes */
68 /***********************************************************************
69 The mididevicedata struct.
70 Note. It doesn't have to be declared with the const qualifier, since
71 NPorts may be set at Init. You should set the name-field to the
72 same as the filename, that might be a demand...
73 ***********************************************************************/
74 const struct MidiDeviceData mididevicedata={
75 MDD_Magic,
76 "debugdriver",
77 "Debugdriver V41.0 (c) 2001 AROS - The AROS Research OS",
78 41,
80 Init,
81 Expunge,
82 OpenPort,
83 ClosePort,
84 NUMPORTS,
88 /****************************************************************
89 We only store sysbase, thats all we need in this example.
90 Otherwise, you may want to open libraries, set number of
91 ports, obtain interrupts, etc.
92 ***************************************************************/
93 SAVEDS ASM BOOL Init(REG(a6) APTR sysbase){
94 SysBase=sysbase;
95 return TRUE;
98 /****************************************************************
99 Nothing to do here. Normally, you may want to free memory,
100 close some libraries, free some interrupts, etc.
101 *****************************************************************/
102 void Expunge(void){
103 return;
108 ULONG (ASM *TransmitFunc)(REG(a2) APTR userdata);
109 APTR UserData[NUMPORTS];
113 /****************************************************************
114 Normally, you may want to start an interrupt, or signal another task,
115 or send a message to a port, that calls the transmit-function.
116 But for this small example, sending the signal directly via
117 kprintf is excactly what we want to do.
118 ****************************************************************/
119 SAVEDS ASM void ActivateXmit(REG(a2) APTR userdata,ULONG REG(d0) portnum){
120 ULONG data;
121 for(;;){
123 data=(TransmitFunc)(userdata);
125 if(data==0x100) return;
126 kprintf("Debugdriver has received: %lx at port %ld\n",data,portnum);
130 struct MidiPortData midiportdata={
131 ActivateXmit
135 /****************************************************************
136 This one is called whenever a program that has opened
137 camd.library wants to use your services.
138 ****************************************************************/
139 SAVEDS ASM struct MidiPortData *OpenPort(
140 REG(a3) struct MidiDeviceData *data,
141 REG(d0) LONG portnum,
142 REG(a0) ULONG (* ASM transmitfunc)(APTR REG(a2) userdata),
143 REG(a1) void (* ASM receiverfunc)(UWORD REG(d0) input,APTR REG(a2) userdata),
144 REG(a2) APTR userdata
146 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
148 TransmitFunc=transmitfunc;
149 UserData[portnum-1]=userdata;
150 return &midiportdata;
155 /****************************************************************
156 Nothing to do here. Normally, you may want to free memory,
157 mark the port not to be in use anymore, delete a task, etc.
158 *****************************************************************/
159 ASM void ClosePort(
160 REG(a3) struct MidiDeviceData *data,
161 REG(d0) LONG portnum
163 return;