diskimage.device: If we are using GCC, simplify the PLUGIN_NODE() macro
[AROS.git] / workbench / devs / diskimage / include / devices / diskimage.h
blob0a5aef9035b8a5800ec621dd953075ffd0bd745f
1 /* Copyright 2007-2012 Fredrik Wikstrom. All rights reserved.
2 **
3 ** Redistribution and use in source and binary forms, with or without
4 ** modification, are permitted provided that the following conditions
5 ** are met:
6 **
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer.
9 **
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
14 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
15 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 ** POSSIBILITY OF SUCH DAMAGE.
27 #ifndef DEVICES_DISKIMAGE_H
28 #define DEVICES_DISKIMAGE_H
30 #ifndef EXEC_EXEC_H
31 #include <exec/exec.h>
32 #endif
33 #ifndef DOS_DOS_H
34 #include <dos/dos.h>
35 #endif
36 #ifndef UTILITY_TAGITEM_H
37 #include <utility/tagitem.h>
38 #endif
39 #ifndef UTILITY_HOOKS_H
40 #include <utility/hooks.h>
41 #endif
42 #ifndef DEVICES_TRACKDISK_H
43 #include <devices/trackdisk.h>
44 #endif
45 #ifndef DEVICES_SCSIDISK_H
46 #include <devices/scsidisk.h>
47 #endif
48 #ifndef LIBRARIES_IFFPARSE_H
49 #include <libraries/iffparse.h>
50 #endif
51 #ifndef TYPES_H
52 #include <types.h>
53 #endif
54 #ifndef INTERFACES_DIPLUGIN_H
55 #include <interfaces/diplugin.h>
56 #endif
58 #define TEMPDIR_VAR "DiskImageTempPath"
60 #define NO_ERROR 0
61 #define NO_ERROR_STRING 0
62 #define ZERO MKBADDR(NULL)
64 #ifndef min
65 #define min(a,b) (((a)<(b))?(a):(b))
66 #define max(a,b) (((a)>(b))?(a):(b))
67 #define clamp(a,b,c) ((a)>(b)?(min(a,c)):(b))
68 #endif
70 enum {
71 DITAG_DUMMY = TAG_USER,
72 DITAG_Error,
73 DITAG_OBSOLETE1,
74 DITAG_CurrentDir,
75 DITAG_Filename,
76 DITAG_WriteProtect,
77 DITAG_GetImageName,
78 DITAG_GetWriteProtect,
79 DITAG_DiskImageType,
80 DITAG_Screen,
81 DITAG_Password,
82 DITAG_OBSOLETE2,
83 DITAG_Plugin,
84 DITAG_OBSOLETE3,
85 DITAG_ErrorStringLength,
86 DITAG_ErrorString,
87 DITAG_RESERVED1,
88 DITAG_RESERVED2,
89 DITAG_RESERVED3,
90 DITAG_SetDeviceType,
91 DITAG_GetDeviceType,
92 DITAG_SetFlags,
93 DITAG_GetFlags
96 enum {
97 DITYPE_NONE,
98 DITYPE_DISK
100 #define DITYPE_RAW DITYPE_DISK
102 struct PluginData {
103 struct Library *SysBase;
104 struct Library *DOSBase;
105 struct Library *UtilityBase;
106 struct DIPluginIFace *IPlugin;
107 #ifdef __AROS__
108 struct Library *aroscbase;
109 #endif
112 #define PLUGIN_MAGIC MAKE_ID('D','I','5','2')
113 #define MIN_PLUGIN_API_VERSION 8
114 #define MAX_PLUGIN_API_VERSION 8
115 #define PLUGIN_FLAG_BUILTIN 0x80000000
116 #define PLUGIN_FLAG_M68K 0x40000000
117 #define PLUGIN_FLAG_USERCHOICE 0x20000000
118 #define PLUGIN_FLAG_FOOTER 0x00000001
119 #define PLUGIN_UNUSED_FLAGS 0x1ffffffe
121 #ifndef QUOTEME
122 #define _QUOTEME(x) #x
123 #define QUOTEME(x) _QUOTEME(x)
124 #endif
126 #ifdef DEVICE
127 #define PLUGIN_VERSTAG(name)
128 #define PLUGIN_TABLE(...)
129 #else
130 #define PLUGIN_VERSTAG(name) \
131 CONST TEXT USED verstag[] = "\0$VER: "name" "QUOTEME(VERSION)"."QUOTEME(REVISION)" ("DATE")";
132 #define PLUGIN_TABLE(...) \
133 static struct DiskImagePlugin * const plugin_array[] = { \
134 __VA_ARGS__, NULL \
135 }; \
136 struct DiskImagePluginTable plugin_table = { \
137 PLUGIN_MAGIC, \
138 USED_PLUGIN_API_VERSION, \
139 0, \
140 plugin_array \
142 #endif
144 #ifdef __GNUC__
145 #define PLUGIN_NODE(pri,name) { .ln_Name = name, .ln_Pri = pri }
146 #else
147 #if defined(__AROS__) && defined(AROS_FLAVOUR) && !(AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT)
148 #define PLUGIN_NODE(pri,name) { NULL, NULL, name, 0, pri }
149 #else
150 #define PLUGIN_NODE(pri,name) { NULL, NULL, 0, pri, name }
151 #endif
152 #endif
154 #ifdef USED_PLUGIN_API_VERSION
155 #if (USED_PLUGIN_API_VERSION < MIN_PLUGIN_API_VERSION) || (USED_PLUGIN_API_VERSION > MAX_PLUGIN_API_VERSION)
156 #error "Unsupported plugin API version"
157 #endif
158 #else
159 #define USED_PLUGIN_API_VERSION MAX_PLUGIN_API_VERSION
160 #endif
162 struct DiskImagePlugin;
164 struct DiskImagePluginTable {
165 ULONG Magic;
166 ULONG API_Version;
167 ULONG RefCount;
168 struct DiskImagePlugin * const *Plugins;
171 struct CDTrack;
173 struct DiskImagePlugin {
174 struct Node Node;
175 ULONG Flags;
176 ULONG TestSize;
177 BPTR SegList;
178 ULONG *RefCount;
180 BOOL (*plugin_Init)(struct DiskImagePlugin *Self, const struct PluginData *data);
181 void (*plugin_Exit)(struct DiskImagePlugin *Self);
182 BOOL (*plugin_CheckImage)(struct DiskImagePlugin *Self, BPTR file, CONST_STRPTR name, QUAD file_size,
183 const UBYTE *test, LONG test_len);
184 APTR (*plugin_OpenImage)(struct DiskImagePlugin *Self, APTR unit, BPTR file, CONST_STRPTR name);
185 void (*plugin_CloseImage)(struct DiskImagePlugin *Self, APTR image);
186 LONG (*plugin_Geometry)(struct DiskImagePlugin *Self, APTR image, struct DriveGeometry *dg);
187 LONG (*plugin_Read)(struct DiskImagePlugin *Self, APTR image, struct IOStdReq *io);
188 LONG (*plugin_Write)(struct DiskImagePlugin *Self, APTR image, struct IOStdReq *io);
189 LONG (*plugin_RawRead)(struct DiskImagePlugin *Self, APTR image, struct IOStdReq *io);
190 LONG (*plugin_RawWrite)(struct DiskImagePlugin *Self, APTR image, struct IOStdReq *io);
191 void (*plugin_GetCDTracks)(struct DiskImagePlugin *Self, APTR image, struct CDTrack **tracks, ULONG *num_tracks);
192 LONG (*plugin_ReadCDDA)(struct DiskImagePlugin *Self, APTR image, APTR buffer, ULONG addr, ULONG frames);
195 #define Plugin_Init(p,a) p->plugin_Init(p,a)
196 #define Plugin_Exit(p) p->plugin_Exit(p)
197 #define Plugin_CheckImage(p,a,b,c,d,e) p->plugin_CheckImage(p,a,b,c,d,e)
198 #define Plugin_OpenImage(p,a,b,c) p->plugin_OpenImage(p,a,b,c)
199 #define Plugin_CloseImage(p,a) p->plugin_CloseImage(p,a)
200 #define Plugin_Geometry(p,a,b) p->plugin_Geometry(p,a,b)
201 #define Plugin_Read(p,a,b) p->plugin_Read(p,a,b)
202 #define Plugin_Write(p,a,b) p->plugin_Write(p,a,b)
203 #define Plugin_RawRead(p,a,b) p->plugin_RawRead(p,a,b)
204 #define Plugin_RawWrite(p,a,b) p->plugin_RawWrite(p,a,b)
205 #define Plugin_GetCDTracks(p,a,b,c) p->plugin_GetCDTracks(p,a,b,c)
206 #define Plugin_ReadCDDA(p,a,b,c,d) p->plugin_ReadCDDA(p,a,b,c,d)
208 struct CDTrack {
209 struct CDTrack *next;
210 UBYTE track_num;
211 UBYTE audio;
212 UWORD sector_size;
213 UBYTE sync_size;
214 UQUAD offset;
215 UQUAD length;
216 UQUAD sectors;
217 // plugin specific data starts here
220 #ifndef SUPPORT_H
221 #include "support.h"
222 #endif
224 #endif