Fixes to comments.
[AROS.git] / compiler / include / dos / dosextens.h
blobe823e01b9e1d8e5ebf6cdce0ce2750774554b5ec
1 #ifndef DOS_DOSEXTENS_H
2 #define DOS_DOSEXTENS_H
4 /*
5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: LibBase and some important structures
9 Lang: English
12 #ifndef EXEC_TYPES_H
13 # include <exec/types.h>
14 #endif
15 #ifndef EXEC_TASKS_H
16 # include <exec/tasks.h>
17 #endif
18 #ifndef EXEC_PORTS_H
19 # include <exec/ports.h>
20 #endif
21 #ifndef EXEC_LIBRARIES_H
22 # include <exec/libraries.h>
23 #endif
24 #ifndef EXEC_DEVICES_H
25 # include <exec/devices.h>
26 #endif
27 #ifndef EXEC_SEMAPHORES
28 # include <exec/semaphores.h>
29 #endif
30 #ifndef DEVICES_TIMER_H
31 # include <devices/timer.h>
32 #endif
33 #ifndef EXEC_INTERRUPTS_H
34 # include <exec/interrupts.h>
35 #endif
36 #ifndef DOS_DOS_H
37 # include <dos/dos.h>
38 #endif
40 /**********************************************************************
41 ***************************** DosLibrary *****************************
42 **********************************************************************/
44 /* This is how the base of dos.library looks like. */
45 struct DosLibrary
47 /* A normal library-base as defined in <exec/libraries.h>. */
48 struct Library dl_lib;
50 struct RootNode * dl_Root;
52 /* private BCPL fields. Do not use. */
53 APTR dl_GV;
54 SIPTR dl_A2;
55 SIPTR dl_A5;
56 SIPTR dl_A6;
58 /* The following fields are PRIVATE! */
59 struct ErrorString * dl_Errors;
60 struct timerequest * dl_TimeReq;
61 struct Library * dl_UtilityBase;
62 struct Library * dl_IntuitionBase;
65 /* dl_Flags/rn_Flags */
66 #define RNB_WILDSTAR 24 /* Activate '*' as wildcard character. */
67 #define RNF_WILDSTAR (1L << RNB_WILDSTAR)
70 struct RootNode
72 /* (IPTR *) Pointer to an array containing pointers to CLI processes.
73 The CLI process number is equal to the index of that array. The
74 first field (index 0) contains the maximal number of CLI processes.
75 See also rn_CliList. */
76 BPTR rn_TaskArray;
77 /* (void *) Pointer to the SegList for CLIs. */
78 BPTR rn_ConsoleSegment;
79 /* The current time. */
80 struct DateStamp rn_Time;
81 /* (APTR) The SegList of the process that handles validation of devices.
83 APTR rn_RestartSeg;
84 /* (struct DosInfo *) see below for DosInfo */
85 BPTR rn_Info;
86 /* BPTR to default (FFS) filesystem, used for example by WB C:Mount
87 * when mountlist filesystem is not specified */
88 BPTR rn_FileHandlerSegment;
89 /* List of all CLI processes (struct CliProcList - see below). See also
90 rn_TaskArray. */
91 struct MinList rn_CliList;
92 /* Message port of boot filesystem. (PRIVATE) */
93 struct MsgPort * rn_BootProc;
94 /* (void *) Pointer to the SegList for shells. */
95 BPTR rn_ShellSegment;
96 /* Additional flags (see above). */
97 LONG rn_Flags;
99 /* RootNode arbitrator */
100 struct SignalSemaphore rn_RootLock;
104 /* Structure that is linked into the rootnode's rn_CliList. Completely
105 private, of course! ... and it's not compatible to AmigaOS. */
106 struct CLIInfo
108 struct Node ci_Node;
109 struct Process *ci_Process;
112 struct DosInfo
114 BPTR di_McName; /* Used as resident segment list (says official documentation but it is wrong) */
115 BPTR di_DevInfo; /* Devices list */
116 BPTR di_Devices; /* Reserved */
117 BPTR di_Handlers; /* Reserved */
118 BPTR di_NetHand; /* Reserved (actually resident segment list) */
120 /* The following semaphores are PRIVATE. */
121 struct SignalSemaphore di_DevLock;
122 struct SignalSemaphore di_EntryLock;
123 struct SignalSemaphore di_DeleteLock;
125 #define di_ResList di_NetHand
127 /**********************************************************************
128 ***************************** Processes ******************************
129 **********************************************************************/
131 /* Standard process structure. Processes are just extended tasks. */
132 struct Process
134 /* Embedded task structure as defined in <exec/tasks.h>. */
135 struct Task pr_Task;
137 /* Processes standard message-port. Used for various puposes. */
138 struct MsgPort pr_MsgPort;
139 WORD pr_Pad; /* PRIVATE */
140 /* SegList array, used by this process. (void **) */
141 BPTR pr_SegList;
142 /* StackSize of the current process. */
143 LONG pr_StackSize;
144 APTR pr_GlobVec;
145 /* CLI process number. This may be 0, in which case the process is not
146 connected to a CLI. */
147 LONG pr_TaskNum;
148 /* Pointer to upper end of stack. (void *) */
149 BPTR pr_StackBase;
150 /* Secondary return-value, as defined in <dos/dos.h>. As of now this
151 field is declared PRIVATE. Use IoErr()/SetIoErr() to access it. */
152 SIPTR pr_Result2;
153 /* Lock of the current directory. As of now this is declared READ-ONLY.
154 Use CurrentDir() to set it. (struct FileLock *) */
155 BPTR pr_CurrentDir;
156 /* Standard input file. As of now this is declared WRITE-ONLY. Use
157 Input() to query it. */
158 BPTR pr_CIS;
159 /* Standard output file. As of now this is declared WRITE-ONLY. Use
160 Output() to query it. */
161 BPTR pr_COS;
162 /* Task to handle the console associated with process. */
163 APTR pr_ConsoleTask;
164 /* The task that is responsible for handling the filesystem. */
165 APTR pr_FileSystemTask;
166 /* CLI the process is connected to. (struct CommandLineInterface *) */
167 BPTR pr_CLI;
168 APTR pr_ReturnAddr;
169 /* Function to be called, when process waits for a packet-message. */
170 APTR pr_PktWait;
171 /* Standard-Window of process. */
172 APTR pr_WindowPtr;
173 /* Lock to home-directory of process. (struct FileLock *) */
174 BPTR pr_HomeDir;
175 LONG pr_Flags; /* see below */
177 /* Code that is called, when the process exits. pr_ExitData takes an
178 argument to be passed to this code. */
179 void (* pr_ExitCode)();
180 IPTR pr_ExitData;
181 /* Arguments passed to the process from caller. */
182 STRPTR pr_Arguments;
184 /* List of local environment variables. This list should be in
185 alphabetical order. Multiple entries may have the same name, if they
186 are of different types. See <dos/var.h> for more information. */
187 struct MinList pr_LocalVars;
188 ULONG pr_ShellPrivate;
189 /* Standard error file. May be NULL, in which case pr_COS is to be used.
190 Use this instead of Output() to report errors. */
191 BPTR pr_CES;
194 /* pr_Flags (all PRIVATE) They mainly descibe what happens if the process
195 exits, i.e. which resources the process should clean itself. The flags
196 are self-explaining. */
197 #define PRB_FREESEGLIST 0
198 #define PRB_FREECURRDIR 1
199 #define PRB_FREECLI 2
200 #define PRB_CLOSEINPUT 3
201 #define PRB_CLOSEOUTPUT 4
202 #define PRB_FREEARGS 5
203 #define PRB_CLOSEERROR 6
204 /* The following are AROS-specific */
205 #define PRB_SYNCHRONOUS 18
206 #define PRB_WAITINGFORCHILD 19 /* This one is subject to change! */
207 #define PRB_NOTIFYONDEATH 20
209 #define PRF_FREESEGLIST (1L << PRB_FREESEGLIST)
210 #define PRF_FREECURRDIR (1L << PRB_FREECURRDIR)
211 #define PRF_FREECLI (1L << PRB_FREECLI)
212 #define PRF_CLOSEINPUT (1L << PRB_CLOSEINPUT)
213 #define PRF_CLOSEOUTPUT (1L << PRB_CLOSEOUTPUT)
214 #define PRF_FREEARGS (1L << PRB_FREEARGS)
215 #define PRF_CLOSEERROR (1L << PRB_CLOSEERROR)
216 #define PRF_SYNCHRONOUS (1L << PRB_SYNCHRONOUS)
217 #define PRF_WAITINGFORCHILD (1L << PRB_WAITINGFORCHILD)
218 #define PRF_NOTIFYONDEATH (1L << PRB_NOTIFYONDEATH)
220 /* Structure used for CLIs and Shells. Allocate this structure with
221 AllocDosObject() only! */
222 struct CommandLineInterface
224 /* Secondary error code, set by last command. */
225 LONG cli_Result2;
226 /* Name of the current directory. */
227 BSTR cli_SetName;
228 /* Lock of the first directory in path. (struct FileLock *) */
229 BPTR cli_CommandDir;
230 /* Error code, the last command returned. See <dos/dos.h> for
231 definitions. */
232 LONG cli_ReturnCode;
233 /* Name of the command that is currently executed. */
234 BSTR cli_CommandName;
235 /* Fail-Level as set by the command "FailAt". */
236 LONG cli_FailLevel;
237 /* Current prompt in the CLI window. */
238 BSTR cli_Prompt;
239 /* Standard/Default input file. (struct FileLock *) */
240 BPTR cli_StandardInput;
241 /* Current input file. (struct FileLock *) */
242 BPTR cli_CurrentInput;
243 /* Name of the file that is currently executed. */
244 BSTR cli_CommandFile;
245 /* TRUE if the currently CLI is connected to a controlling terminal,
246 otherwise FALSE. */
247 LONG cli_Interactive;
248 /* FALSE if there is no controlling terminal, otherwise TRUE. */
249 LONG cli_Background;
250 /* Current output file. (struct FileLock *) */
251 BPTR cli_CurrentOutput;
252 /* Default stack size as set by the command "Stack". */
253 LONG cli_DefaultStack;
254 /* Standard/Default output file. (struct FileLock *) */
255 BPTR cli_StandardOutput;
256 /* SegList of currently loaded command. */
257 BPTR cli_Module;
259 /* Here begins the aros specific part */
260 /* Standard/Default Error file. (struct FileLock *) */
261 BPTR cli_StandardError;
264 /* CLI_DEFAULTSTACK_UNIT * cli_DefaultStack = stack in bytes */
266 #define CLI_DEFAULTSTACK_UNIT sizeof(IPTR)
268 /* Devices process structure as returned by GetDeviceProc(). */
269 struct DevProc
271 struct MsgPort * dvp_Port;
272 BPTR dvp_Lock; /* struct FileLock * */
273 ULONG dvp_Flags; /* see below */
274 struct DosList * dvp_DevNode; /* PRIVATE */
277 /* dvp_Flags */
278 #define DVPB_UNLOCK 0
279 #define DVPB_ASSIGN 1
280 #define DVPF_UNLOCK (1L<<DVPB_UNLOCK)
281 #define DVPF_ASSIGN (1L<<DVPB_ASSIGN)
283 /**********************************************************************
284 ******************************* Files ********************************
285 **********************************************************************/
287 /* Standard file-handle as returned by Open() (as BPTR). Generally said, you
288 should not use this structure in any way and only use library-calls to
289 access files. Note that this structure is very different to the structure
290 used in AmigaOS! Treat this structure as PRIVATE. If you want to create
291 this structure nevertheless, use AllocDosObject(). */
292 struct FileHandle
294 /* The next three are used with packet-based filesystems */
295 ULONG fh_Flags;
296 LONG fh_Interactive; /* interactive handle flag */
297 struct MsgPort * fh_Type; /* port to send packets to */
299 BPTR fh_Buf;
300 LONG fh_Pos;
301 LONG fh_End;
303 SIPTR fh_Funcs;
304 SIPTR fh_Func2;
305 SIPTR fh_Func3;
306 SIPTR fh_Args;
307 SIPTR fh_Arg2;
309 /* v39+ */
310 ULONG fh_BufSize; /* Size of buffered io buffer */
311 BPTR fh_OrigBuf; /* Always the same as fh_Buf */
314 /* Original AmigaOS aliases */
315 #define fh_Port fh_Interactive
316 #define fh_Func1 fh_Funcs
317 #define fh_Arg1 fh_Args
319 /* Structure of a lock. This is provided as it may be required internally by
320 * packet-based filesystems.
322 struct FileLock
324 BPTR fl_Link; /* (struct FileLock *) Pointer to next lock. */
325 IPTR fl_Key;
326 LONG fl_Access;
327 struct MsgPort * fl_Task;
328 BPTR fl_Volume; /* (struct DeviceList * - see below) */
331 /* Constants, defining of what kind a file is. These constants are used in
332 many structures, including FileInfoBlock (<dos/dos.h>) and ExAllData
333 (<dos/exall.h>). */
334 #define ST_PIPEFILE -5 /* File is a pipe */
335 #define ST_LINKFILE -4 /* Hard link to a file */
336 #define ST_FILE -3 /* Plain file */
337 #define ST_ROOT 1 /* Root directory of filesystem */
338 #define ST_USERDIR 2 /* Normal directory */
339 #define ST_SOFTLINK 3 /* Soft link (may be a file or directory) */
340 #define ST_LINKDIR 4 /* Hard link to a directory */
342 /**********************************************************************
343 ****************************** DosLists ******************************
344 **********************************************************************/
346 /* This structure is returned by LockDosList() and similar calls. This
347 * structure is identical the AmigaOS one, but this structure is PRIVATE
348 * anyway. Use system-calls for dos list-handling.
350 struct DosList
352 /* PRIVATE pointer to next entry. */
353 BPTR dol_Next;
354 /* Type of the current node (see below). */
355 LONG dol_Type;
356 /* Filesystem task handling this entry (for old-style filesystems) */
357 struct MsgPort * dol_Task;
358 /* The lock passed to AssignLock(). Only set if the type is
359 DLT_DIRECTORY. */
360 BPTR dol_Lock;
362 /* This union combines all the different types. */
363 union {
364 /* See struct DevInfo below. */
365 struct {
366 BSTR dol_Handler;
367 LONG dol_StackSize;
368 LONG dol_Priority;
369 BPTR dol_Startup;
370 BPTR dol_SegList;
371 BPTR dol_GlobVec;
372 } dol_handler;
373 /* See struct DeviceList below. */
374 struct {
375 struct DateStamp dol_VolumeDate;
376 BPTR dol_LockList;
377 LONG dol_DiskType;
378 BPTR dol_unused;
379 } dol_volume;
380 /* Structure used for assigns. */
381 struct {
382 /* The name for the late or nonbinding assign. */
383 UBYTE *dol_AssignName;
384 /* A list of locks, used by AssignAdd(). */
385 struct AssignList *dol_List;
386 } dol_assign;
387 } dol_misc;
389 /* Name as a BCPL string */
390 BSTR dol_Name;
393 /* dol_Type/dl_Type/dvi_Type. Given to MakeDosEntry(). */
394 #define DLT_DEVICE 0 /* A real filesystem (or similar) */
395 #define DLT_DIRECTORY 1 /* Just a simple assign */
396 #define DLT_VOLUME 2 /* Volume node (for removable media) */
397 #define DLT_LATE 3 /* Late binding assign (not yet) */
398 #define DLT_NONBINDING 4 /* Nonbinding assign (not yet) */
401 /* The following structures are essentially the same as DosList above. The
402 difference is that they support just one type of entry. You can use them
403 instead of DosList if you have a list containing just one type of
404 entry. For more information see above.
405 Note that these two entries have the same size, and dl_Name has the same
406 offset. Also they have to correspond to the union above.
409 struct DeviceList
411 BPTR dl_Next;
412 LONG dl_Type; /* see above, always = DLT_VOLUME */
413 struct MsgPort * dl_Task;
414 BPTR dl_Lock;
416 struct DateStamp dl_VolumeDate; /* At this date the volume was created. */
417 /* ULONG padding is inserted here on 64 bits */
418 BPTR dl_LockList; /* (void *) List of all locks on the volume. */
419 LONG dl_DiskType; /* Type of the disk. (see <dos/dos.h> for definitions) */
420 /* ULONG padding is inserted here on 64 bits */
421 BPTR dl_unused; /* PRIVATE */
423 BSTR dl_Name;
427 /* Structure that describes a device. This is essentially the same structure
428 as DeviceNode, defined in <dos/filehandler.h>. */
429 struct DevInfo
431 BPTR dvi_Next;
432 LONG dvi_Type; /* see above, always = DLT_DEVICE */
433 struct MsgPort * dvi_Task;
434 BPTR dvi_Lock;
436 BSTR dvi_Handler; /* Device name for handler. */
437 LONG dvi_StackSize; /* Packet-handler initial stack size */
438 LONG dvi_Priority; /* Packet-handler initial priority */
439 BPTR dvi_Startup; /* (struct FileSysStartupMsg *) */
440 BPTR dvi_SegList; /* SegList for the handler */
441 BPTR dvi_GlobalVec; /* Global Vector, should be (BPTR)-1 */
443 BSTR dvi_Name;
446 /* Dos list scanning and locking modes as used in LockDosList() */
447 /* Specify either LDF_READ, if you want a non-exclusive lock, or LDF_WRITE,
448 if you want an exclusive lock (i.e. if you want to modify the list).
450 #define LDB_READ 0 /* Non-exclusive/read lock */
451 #define LDB_WRITE 1 /* Exclusive/write lock */
452 /* Specify which list(s) to lock. */
453 #define LDB_DEVICES 2 /* Device list */
454 #define LDB_VOLUMES 3 /* Volume list */
455 #define LDB_ASSIGNS 4 /* Assign list */
456 #define LDB_ENTRY 5
457 #define LDB_DELETE 6
459 #define LDF_READ (1L<<LDB_READ)
460 #define LDF_WRITE (1L<<LDB_WRITE)
461 #define LDF_DEVICES (1L<<LDB_DEVICES)
462 #define LDF_VOLUMES (1L<<LDB_VOLUMES)
463 #define LDF_ASSIGNS (1L<<LDB_ASSIGNS)
464 #define LDF_ENTRY (1L<<LDB_ENTRY)
465 #define LDF_DELETE (1L<<LDB_DELETE)
466 #define LDF_ALL (LDF_DEVICES | LDF_VOLUMES | LDF_ASSIGNS)
469 /* Used for assigns that point to multiple directories. */
470 struct AssignList
472 struct AssignList * al_Next; /* Pointer to next assign node. */
473 BPTR al_Lock; /* (struct FileLock *) Lock of on of the
474 directories. */
477 /**********************************************************************
478 ********************** Low Level File Handling ***********************
479 **********************************************************************/
481 /* Allocate this structure with AllocDosObject(). */
482 struct DosPacket
484 struct Message * dp_Link; /* Pointer to a standard exec message. */
485 struct MsgPort * dp_Port; /* Reply-Port of that packet. */
487 LONG dp_Type; /* see below */
488 SIPTR dp_Res1; /* Normal return value. */
489 SIPTR dp_Res2; /* Secondary return value (as returned by IoErr()). See
490 <dos/dos.h> for possible values. */
492 /* The actual data. */
493 SIPTR dp_Arg1;
494 SIPTR dp_Arg2;
495 SIPTR dp_Arg3;
496 SIPTR dp_Arg4;
497 SIPTR dp_Arg5;
498 SIPTR dp_Arg6;
499 SIPTR dp_Arg7;
501 #define dp_Action dp_Type
502 #define dp_Status dp_Res1
503 #define dp_Status2 dp_Res2
504 #define dp_BufAddr dp_Arg1
507 /* These are defined for DOS Packet filesystems, and are
508 * passed by DoPkt(), SendPkt(), and others
511 /* dp_Type */
512 #define ACTION_NIL 0
513 #define ACTION_STARTUP 0
514 #define ACTION_GET_BLOCK 2 /* Obsolete */
515 #define ACTION_SET_MAP 4
516 #define ACTION_DIE 5
517 #define ACTION_EVENT 6
518 #define ACTION_CURRENT_VOLUME 7
519 #define ACTION_LOCATE_OBJECT 8
520 #define ACTION_RENAME_DISK 9
521 #define ACTION_FREE_LOCK 15
522 #define ACTION_DELETE_OBJECT 16
523 #define ACTION_RENAME_OBJECT 17
524 #define ACTION_MORE_CACHE 18
525 #define ACTION_COPY_DIR 19
526 #define ACTION_WAIT_CHAR 20
527 #define ACTION_SET_PROTECT 21
528 #define ACTION_CREATE_DIR 22
529 #define ACTION_EXAMINE_OBJECT 23
530 #define ACTION_EXAMINE_NEXT 24
531 #define ACTION_DISK_INFO 25
532 #define ACTION_INFO 26
533 #define ACTION_FLUSH 27
534 #define ACTION_SET_COMMENT 28
535 #define ACTION_PARENT 29
536 #define ACTION_TIMER 30
537 #define ACTION_INHIBIT 31
538 #define ACTION_DISK_TYPE 32
539 #define ACTION_DISK_CHANGE 33
540 #define ACTION_SET_DATE 34
541 #define ACTION_SAME_LOCK 40
543 #define ACTION_WRITE 'W'
544 #define ACTION_READ 'R'
546 #define ACTION_SCREEN_MODE 994
547 #define ACTION_CHANGE_SIGNAL 995
548 #define ACTION_READ_RETURN 1001
549 #define ACTION_WRITE_RETURN 1002
550 #define ACTION_FINDUPDATE 1004
551 #define ACTION_FINDINPUT 1005
552 #define ACTION_FINDOUTPUT 1006
553 #define ACTION_END 1007
554 #define ACTION_SEEK 1008
555 #define ACTION_FORMAT 1020
556 #define ACTION_MAKE_LINK 1021
557 #define ACTION_SET_FILE_SIZE 1022
558 #define ACTION_WRITE_PROTECT 1023
559 #define ACTION_READ_LINK 1024
560 #define ACTION_FH_FROM_LOCK 1026
561 #define ACTION_IS_FILESYSTEM 1027
562 #define ACTION_CHANGE_MODE 1028
563 #define ACTION_COPY_DIR_FH 1030
564 #define ACTION_PARENT_FH 1031
565 #define ACTION_EXAMINE_ALL 1033
566 #define ACTION_EXAMINE_FH 1034
567 #define ACTION_EXAMINE_ALL_END 1035
568 #define ACTION_SET_OWNER 1036
570 #define ACTION_LOCK_RECORD 2008
571 #define ACTION_FREE_RECORD 2009
573 #define ACTION_ADD_NOTIFY 4097
574 #define ACTION_REMOVE_NOTIFY 4098
576 #define ACTION_SERIALIZE_DISK 4200
578 #define ACTION_CHANGE_FILE_POSITION64 8001
579 #define ACTION_GET_FILE_POSITION64 8002
580 #define ACTION_CHANGE_FILE_SIZE64 8003
581 #define ACTION_GET_FILE_SIZE64 8004
583 /* Structure for easy handling of DosPackets. DosPackets don't have to be in
584 this structure, but this struture may ease the use of it. */
585 struct StandardPacket
587 struct Message sp_Msg;
588 struct DosPacket sp_Pkt;
592 /* NOTE: AROS doesn't use startup packets. This will ONLY make a difference
593 for shell writers... */
595 /* Types of command execution */
596 #define RUN_EXECUTE -1
597 #define RUN_SYSTEM -2
598 #define RUN_SYSTEM_ASYNCH -3
601 /**********************************************************************
602 ****************************** Segments ******************************
603 **********************************************************************/
605 /* Resident list structure as returned by AddSegment(). */
606 struct Segment
608 BPTR seg_Next; /* Pointer to next segment. */
609 LONG seg_UC; /* Usage count/type */
610 BPTR seg_Seg; /* Actual Segment */
611 UBYTE seg_Name[4]; /* The first characters of the name (BSTR). */
614 #define CMD_SYSTEM -1
615 #define CMD_INTERNAL -2
616 #define CMD_DISABLED -999
618 /**********************************************************************
619 *************************** Error Handling ***************************
620 **********************************************************************/
622 struct ErrorString
624 LONG * estr_Nums;
625 STRPTR estr_Strings;
628 /* Return values for ErrorReport(). */
629 #define REPORT_STREAM 0
630 #define REPORT_TASK 1
631 #define REPORT_LOCK 2
632 #define REPORT_VOLUME 3
633 #define REPORT_INSERT 4
635 #define ABORT_BUSY 288
636 #define ABORT_DISK_ERROR 296
638 #endif /* DOS_DOSEXTENS_H */