revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Test / examine_ahi / examine_ahi.c
blob67ce5b91f1454f2e5c6c55400d72406cfc700c16
3 #include <stdio.h>
4 #include <exec/execbase.h>
5 #include <proto/exec.h>
7 #include "ahi_def.h"
8 //#include "ahi_device.h"
10 extern struct ExecBase *SysBase;
12 void printlist(struct MinList *);
14 #if defined(__AROSPLATFORM_SMP__)
15 #include <aros/types/spinlock_s.h>
16 #include <proto/execlock.h>
17 #include <resources/execlock.h>
18 #endif
20 int main(void)
22 struct AHIBase *AHIBase;
23 struct AHIDevUnit *iounit;
25 #if defined(__AROSPLATFORM_SMP__)
26 void *ExecLockBase = OpenResource("execlock.resource");
28 if (ExecLockBase)
29 ObtainSystemLock(&SysBase->DeviceList, SPINLOCK_MODE_READ, LOCKF_DISABLE);
30 else
31 Disable();
32 #else
33 Disable();
34 #endif
35 AHIBase = (struct AHIBase *) FindName(& SysBase->DeviceList, AHINAME);
36 #if defined(__AROSPLATFORM_SMP__)
37 if (ExecLockBase)
38 ReleaseSystemLock(&SysBase->DeviceList, LOCKF_DISABLE);
39 else
40 Enable();
41 #else
42 Enable();
43 #endif
46 printf("Base: 0x%08lx\n", AHIBase);
47 if(AHIBase == NULL)
48 return -1;
50 iounit = AHIBase->ahib_DevUnits[0];
51 printf("iounit 0: 0x%08lx\n", iounit);
52 if(iounit != NULL) {
54 if(iounit->IsPlaying)
55 printf("Is playing.\n");
57 if(iounit->IsRecording)
58 printf("Is recording.\n");
60 printf("ReadList\n");
61 printlist(&iounit->ReadList);
62 printf("PlayingList\n");
63 printlist(&iounit->PlayingList);
64 printf("SilentList\n");
65 printlist(&iounit->SilentList);
66 printf("WaitingList\n");
67 printlist(&iounit->WaitingList);
69 printf("S: %ld, R: %ld, R:%ld\n", iounit->SampleSignal,
70 iounit->RecordSignal, iounit->PlaySignal);
73 iounit = AHIBase->ahib_DevUnits[1];
74 printf("iounit 1: 0x%08lx\n", iounit);
75 if(iounit != NULL) {
77 if(iounit->IsPlaying)
78 printf("Is playing.\n");
80 if(iounit->IsRecording)
81 printf("Is recording.\n");
83 printf("ReadList\n");
84 printlist(&iounit->ReadList);
85 printf("PlayingList\n");
86 printlist(&iounit->PlayingList);
87 printf("SilentList\n");
88 printlist(&iounit->SilentList);
89 printf("WaitingList\n");
90 printlist(&iounit->WaitingList);
92 printf("S: %ld, R: %ld, R:%ld\n", iounit->SampleSignal,
93 iounit->RecordSignal, iounit->PlaySignal);
96 return 0;
99 const static char * commands[] =
101 "CMD_INVALID",
102 "CMD_RESET",
103 "CMD_READ",
104 "CMD_WRITE",
105 "CMD_UPDATE",
106 "CMD_CLEAR",
107 "CMD_STOP",
108 "CMD_START",
109 "CMD_FLUSH"
112 void printlist(struct MinList *list)
114 struct AHIRequest *ioreq;
116 ioreq = (struct AHIRequest *) list->mlh_Head;
117 while (ioreq->ahir_Std.io_Message.mn_Node.ln_Succ)
119 printf("iorequest: 0x%08lx\n", ioreq);
120 printf("command : %s (0x%lx)\n",
121 (ioreq->ahir_Std.io_Command < CMD_NONSTD ?
122 commands[ioreq->ahir_Std.io_Command] :
123 "Annan..."),
124 ioreq->ahir_Std.io_Command);
125 ioreq = (struct AHIRequest *) ioreq->ahir_Std.io_Message.mn_Node.ln_Succ;