Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / device / include / diskimage_device.h
blob9ac4c3b22be63e8509bf51f8626cd447d86441fa
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 DISKIMAGE_DEVICE_H
28 #define DISKIMAGE_DEVICE_H
30 #include <exec/exec.h>
31 #include <dos/dos.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>
43 #include <string.h>
44 #include <SDI_compiler.h>
45 #include "support.h"
46 #include "prefs.h"
47 #include "td64.h"
49 #define InitMsgPort(port) \
50 (port)->mp_Flags = PA_IGNORE; \
51 NewList(&(port)->mp_MsgList);
53 #define GetProcMsgPort(proc) (&proc->pr_MsgPort);
55 #define dbug(args)
57 struct DiskImageBase {
58 struct Library LibNode;
59 UWORD Pad;
60 BPTR SegList;
62 struct SignalSemaphore *UnitSemaphore;
63 struct SignalSemaphore *PluginSemaphore;
64 struct SignalSemaphore *DiskChangeSemaphore;
65 struct List *Units;
66 struct List *Plugins;
67 struct List *ReloadPluginsHooks;
68 struct List *DiskChangeHooks;
69 UWORD HeaderTestSize;
70 UWORD FooterTestSize;
72 struct LocaleInfo LocaleInfo;
74 struct Library *SysBase;
75 struct Library *DOSBase;
76 struct Library *UtilityBase;
77 struct Library *IntuitionBase;
78 #ifdef __AROS__
79 struct Library *StdCBase;
80 #endif
83 enum {
84 DICMD_DIE = 0,
85 DICMD_STARTUP,
86 DICMD_TAGLIST
89 struct DiskImageMsg {
90 struct Message dim_Msg;
91 struct DiskImageUnit *dim_Unit;
92 ULONG dim_Command;
93 const struct TagItem *dim_Tags;
96 struct DeathMessage {
97 struct Message dm_Msg;
98 LONG dm_ReturnCode;
99 LONG dm_Result2;
102 struct DiskImageUnit {
103 struct Node Node;
104 UBYTE DeviceType;
105 UBYTE Flags;
106 ULONG UnitNum;
107 ULONG OpenCnt;
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;
120 STRPTR Name;
121 struct DiskImagePlugin *Plugin;
122 APTR ImageData;
124 BPTR TempDir;
125 STRPTR TempName;
127 ULONG ChangeCnt;
128 struct Interrupt *ObsoleteChangeInt;
129 struct List *ChangeInts;
131 ULONG WriteProtect;
132 struct Screen *Screen;
133 CONST_STRPTR Password;
135 LONG Error;
136 LONG *ErrorPtr;
137 STRPTR ErrorString;
138 ULONG ErrorStringLength;
140 PrefsObject *Prefs;
143 /* io.c */
144 #ifndef __AROS__
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));
147 #endif
149 /* unit.c */
150 #ifdef __AROS__
151 AROS_PROCP (UnitProcEntry);
152 void SetDiskImageErrorA (APTR Self, struct DiskImageUnit *unit, LONG error, LONG error_string, VA_LIST error_args);
153 #else
154 int UnitProcEntry (void);
155 void SetDiskImageErrorA (APTR Self, struct DiskImageUnit *unit, LONG error, LONG error_string, CONST_APTR error_args);
156 #endif
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, ...);
161 /* scsicmd.c */
162 LONG DoSCSICmd (struct IOStdReq *io, struct SCSICmd *scsi);
164 /* main_vectors.c */
165 #ifndef __AROS__
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));
180 #endif
182 /* plugin_vectors.c */
183 extern struct DIPluginIFace IPluginIFace;
185 /* plugins.c */
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);
191 /* tempfile.c */
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);
197 /* password.c */
198 STRPTR RequestPassword (APTR Self, struct DiskImageUnit *unit);
200 #endif