1 /* Copyright 2007-2012 Fredrik Wikstrom. All rights reserved.
3 ** Redistribution and use in source and binary forms, with or without
4 ** modification, are permitted provided that the following conditions
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer.
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
31 #include <exec/exec.h>
36 #ifndef UTILITY_TAGITEM_H
37 #include <utility/tagitem.h>
39 #ifndef UTILITY_HOOKS_H
40 #include <utility/hooks.h>
42 #ifndef DEVICES_TRACKDISK_H
43 #include <devices/trackdisk.h>
45 #ifndef DEVICES_SCSIDISK_H
46 #include <devices/scsidisk.h>
48 #ifndef LIBRARIES_IFFPARSE_H
49 #include <libraries/iffparse.h>
54 #ifndef INTERFACES_DIPLUGIN_H
55 #include <interfaces/diplugin.h>
58 #define TEMPDIR_VAR "DiskImageTempPath"
61 #define NO_ERROR_STRING 0
62 #define ZERO MKBADDR(NULL)
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))
71 DITAG_DUMMY
= TAG_USER
,
78 DITAG_GetWriteProtect
,
85 DITAG_ErrorStringLength
,
100 #define DITYPE_RAW DITYPE_DISK
103 struct Library
*SysBase
;
104 struct Library
*DOSBase
;
105 struct Library
*UtilityBase
;
106 struct DIPluginIFace
*IPlugin
;
108 struct Library
*StdCBase
;
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
122 #define _QUOTEME(x) #x
123 #define QUOTEME(x) _QUOTEME(x)
127 #define PLUGIN_VERSTAG(name)
128 #define PLUGIN_TABLE(...)
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[] = { \
136 struct DiskImagePluginTable plugin_table = { \
138 USED_PLUGIN_API_VERSION, \
145 #define PLUGIN_NODE(pri,name) { .ln_Name = name, .ln_Pri = pri }
147 #if defined(__AROS__) && defined(AROS_FLAVOUR) && !(AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT)
148 #define PLUGIN_NODE(pri,name) { NULL, NULL, name, 0, pri }
150 #define PLUGIN_NODE(pri,name) { NULL, NULL, 0, pri, name }
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"
159 #define USED_PLUGIN_API_VERSION MAX_PLUGIN_API_VERSION
162 struct DiskImagePlugin
;
164 struct DiskImagePluginTable
{
168 struct DiskImagePlugin
* const *Plugins
;
173 struct DiskImagePlugin
{
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)
209 struct CDTrack
*next
;
217 // plugin specific data starts here