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 DISKIMAGE_DEVICE_H
28 #define DISKIMAGE_DEVICE_H
30 #include <exec/exec.h>
32 #include <dos/dostags.h>
33 #include <utility/tagitem.h>
34 #include <proto/exec.h>
35 #include <proto/dos.h>
36 #include <proto/utility.h>
37 #include <proto/intuition.h>
38 #include <clib/alib_protos.h>
39 #include <devices/diskimage.h>
40 #include <devices/trackdisk.h>
41 #include <devices/newstyle.h>
42 #include <devices/scsidisk.h>
44 #include <SDI_compiler.h>
49 #define InitMsgPort(port) \
50 (port)->mp_Flags = PA_IGNORE; \
51 NewList(&(port)->mp_MsgList);
53 #define GetProcMsgPort(proc) (&proc->pr_MsgPort);
57 struct DiskImageBase
{
58 struct Library LibNode
;
62 struct SignalSemaphore
*UnitSemaphore
;
63 struct SignalSemaphore
*PluginSemaphore
;
64 struct SignalSemaphore
*DiskChangeSemaphore
;
67 struct List
*ReloadPluginsHooks
;
68 struct List
*DiskChangeHooks
;
72 struct LocaleInfo LocaleInfo
;
74 struct Library
*SysBase
;
75 struct Library
*DOSBase
;
76 struct Library
*UtilityBase
;
77 struct Library
*IntuitionBase
;
79 struct Library
*StdCBase
;
90 struct Message dim_Msg
;
91 struct DiskImageUnit
*dim_Unit
;
93 const struct TagItem
*dim_Tags
;
97 struct Message dm_Msg
;
102 struct DiskImageUnit
{
108 struct DiskImageBase
*LibBase
;
109 struct Process
*UnitProc
;
111 struct SignalSemaphore
*IOSemaphore
;
112 struct MsgPort
*IOPort
;
114 struct SignalSemaphore
*MsgSemaphore
;
115 struct MsgPort
*ReplyPort
;
116 struct MsgPort
*MsgPort
;
117 struct DiskImageMsg
*DiskImageMsg
;
118 struct DeathMessage
*DeathMsg
;
121 struct DiskImagePlugin
*Plugin
;
128 struct Interrupt
*ObsoleteChangeInt
;
129 struct List
*ChangeInts
;
132 struct Screen
*Screen
;
133 CONST_STRPTR Password
;
138 ULONG ErrorStringLength
;
145 LONG
LibAbortIO (REG(a1
, struct IOStdReq
*which_io
), REG(a6
, struct DiskImageBase
*libBase
));
146 void LibBeginIO (REG(a1
, struct IOExtTD
*iotd
), REG(a6
, struct DiskImageBase
*libBase
));
151 AROS_PROCP (UnitProcEntry
);
152 void SetDiskImageErrorA (APTR Self
, struct DiskImageUnit
*unit
, LONG error
, LONG error_string
, VA_LIST error_args
);
154 int UnitProcEntry (void);
155 void SetDiskImageErrorA (APTR Self
, struct DiskImageUnit
*unit
, LONG error
, LONG error_string
, CONST_APTR error_args
);
157 int UnitProcMain (struct DiskImageUnit
*unit
);
158 LONG
DOS2IOErr (APTR Self
, LONG error
);
159 VARARGS68K
void SetDiskImageError (APTR Self
, struct DiskImageUnit
*unit
, LONG error
, LONG error_string
, ...);
162 LONG
DoSCSICmd (struct IOStdReq
*io
, struct SCSICmd
*scsi
);
166 LONG
MountImage (REG(d0
, ULONG unit_num
), REG(a0
, CONST_STRPTR filename
),
167 REG(a6
, struct DiskImageBase
*libBase
));
168 LONG
UnitInfo (REG(d0
, ULONG unit_num
), REG(a0
, STRPTR
*filename
), REG(a1
, BOOL
*writeprotect
),
169 REG(a6
, struct DiskImageBase
*libBase
));
170 LONG
WriteProtect (REG(d0
, ULONG unit_num
), REG(d1
, BOOL writeprotect
),
171 REG(a6
, struct DiskImageBase
*libBase
));
172 LONG
UnitControlA (REG(d0
, ULONG unit_num
), REG(a0
, struct TagItem
*tags
),
173 REG(a6
, struct DiskImageBase
*libBase
));
174 LONG
ReloadPlugins (REG(a6
, struct DiskImageBase
*libBase
));
175 void DoHookPlugins (REG(a0
, struct Hook
*hook
), REG(a6
, struct DiskImageBase
*libBase
));
176 void AddDiskChangeHook (REG(a0
, struct Hook
*hook
), REG(d0
, BOOL add_or_remove
),
177 REG(a6
, struct DiskImageBase
*libBase
));
178 void AddReloadPluginsHook (REG(a0
, struct Hook
*hook
), REG(d0
, BOOL add_or_remove
),
179 REG(a6
, struct DiskImageBase
*libBase
));
182 /* plugin_vectors.c */
183 extern struct DIPluginIFace IPluginIFace
;
186 void LoadPlugins (struct DiskImageBase
*libBase
);
187 void FreePlugins (struct DiskImageBase
*libBase
);
188 struct DiskImagePlugin
*FindPlugin (struct DiskImageUnit
*unit
, BPTR file
, CONST_STRPTR name
);
189 APTR
OpenImage (APTR Self
, struct DiskImageUnit
*unit
, BPTR file
, CONST_STRPTR name
);
192 LONG
CreateTempFile (APTR Self
, struct DiskImageUnit
*unit
, CONST_STRPTR ext
,
193 BPTR
*tmpdir
, CONST_STRPTR
*tmpname
);
194 BPTR
OpenTempFile (APTR Self
, struct DiskImageUnit
*unit
, ULONG mode
);
195 void RemoveTempFile (APTR Self
, struct DiskImageUnit
*unit
);
198 STRPTR
RequestPassword (APTR Self
, struct DiskImageUnit
*unit
);