1 #ifndef DOS_DOSEXTENS_H
2 #define DOS_DOSEXTENS_H
5 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 Desc: LibBase and some important structures
13 # include <aros/config.h>
16 # include <exec/types.h>
19 # include <exec/tasks.h>
22 # include <exec/ports.h>
24 #ifndef EXEC_LIBRARIES_H
25 # include <exec/libraries.h>
27 #ifndef EXEC_DEVICES_H
28 # include <exec/devices.h>
30 #ifndef EXEC_SEMAPHORES
31 # include <exec/semaphores.h>
33 #ifndef DEVICES_TIMER_H
34 # include <devices/timer.h>
36 #ifndef EXEC_INTERRUPTS_H
37 # include <exec/interrupts.h>
42 #include <dos/dosextaros.h>
44 /**********************************************************************
45 ***************************** DosLibrary *****************************
46 **********************************************************************/
48 /* This is how the base of dos.library looks like. */
51 /* A normal library-base as defined in <exec/libraries.h>. */
52 struct Library dl_lib
;
54 struct RootNode
* dl_Root
;
56 #if (AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT)
57 /* The following fields are not used by AROS and are just there to
58 guarantee binary compatibility. DO NOT USE THESE FIELDS IN ANY WAY.
59 Original names were: dl_GV, dl_A2, dl_A5 and dl_A6 */
64 /* The following fields are PRIVATE! */
65 struct ErrorString
* dl_Errors
;
66 struct Device
* dl_TimerBase
;
67 struct Library
* dl_UtilityBase
;
68 struct Library
* dl_IntuitionBase
;
70 /* These are AROS specific extensions. They are all PRIVATE! */
71 struct timerequest dl_TimerIO
;
73 struct DosList
* dl_DevInfo
;
74 struct ExecBase
* dl_SysBase
;
76 struct Device
* dl_NulHandler
;
77 struct Unit
* dl_NulLock
;
79 struct SignalSemaphore dl_LDObjectsListSigSem
;
80 struct List dl_LDObjectsList
;
81 struct Interrupt dl_LDHandler
;
82 struct MsgPort
* dl_LDDemonPort
;
83 struct Process
* dl_LDDemonTask
;
90 /* The flags are the same, as they were in RootNode->rn_Flags. See below
94 /* Resident segment list **PRIVATE** */
98 /* dl_Flags/rn_Flags */
99 #define RNB_WILDSTAR 24 /* Activate '*' as wildcard character. */
100 #define RNF_WILDSTAR (1L << RNB_WILDSTAR)
105 /* (IPTR *) Pointer to an array containing pointers to CLI processes.
106 The CLI process number is equal to the index of that array. The
107 first field (index 0) contains the maximal number of CLI processes.
108 See also rn_CliList. */
110 /* (void *) Pointer to the SegList for CLIs. */
111 BPTR rn_ConsoleSegment
;
112 /* The current time. */
113 struct DateStamp rn_Time
;
114 /* (APTR) The SegList of the process that handles validation of devices.
117 /* (struct DosInfo *) see below for DosInfo */
119 BPTR rn_FileHandlerSegment
;
120 /* List of all CLI processes (struct CliProcList - see below). See also
122 struct MinList rn_CliList
;
123 /* Message port of boot filesystem. (PRIVATE) */
124 struct MsgPort
* rn_BootProc
;
125 /* (void *) Pointer to the SegList for shells. */
126 BPTR rn_ShellSegment
;
127 /* Additional flags (see above). */
130 /* RootNode arbitrator */
131 struct SignalSemaphore rn_RootLock
;
135 /* Structure that is linked into the rootnode's rn_CliList. Completely
136 private, of course! ... and it's not compatible to AmigaOS. */
140 struct Process
*ci_Process
;
145 BPTR di_McName
; /* PRIVATE */
151 /* The following semaphores are PRIVATE. */
152 struct SignalSemaphore di_DevLock
;
153 struct SignalSemaphore di_EntryLock
;
154 struct SignalSemaphore di_DeleteLock
;
156 #define di_ResList di_McName
158 /**********************************************************************
159 ***************************** Processes ******************************
160 **********************************************************************/
162 /* Standard process structure. Processes are just extended tasks. */
165 /* Embedded task structure as defined in <exec/tasks.h>. */
168 /* Processes standard message-port. Used for various puposes. */
169 struct MsgPort pr_MsgPort
;
170 WORD pr_Pad
; /* PRIVATE */
171 /* SegList array, used by this process. (void **) */
173 /* StackSize of the current process. */
176 /* CLI process number. This may be 0, in which case the process is not
177 connected to a CLI. */
179 /* Pointer to upper end of stack. (void *) */
181 /* Secondary return-value, as defined in <dos/dos.h>. As of now this
182 field is declared PRIVATE. Use IoErr()/SetIoErr() to access it. */
184 /* Lock of the current directory. As of now this is declared READ-ONLY.
185 Use CurrentDir() to set it. (struct FileLock *) */
187 /* Standard input file. As of now this is declared WRITE-ONLY. Use
188 Input() to query it. */
190 /* Standard output file. As of now this is declared WRITE-ONLY. Use
191 Output() to query it. */
193 /* Task to handle the console associated with process. */
195 /* The task that is responsible for handling the filesystem. */
196 APTR pr_FileSystemTask
;
197 /* CLI the process is connected to. (struct CommandLineInterface *) */
200 /* Function to be called, when process waits for a packet-message. */
202 /* Standard-Window of process. */
204 /* Lock to home-directory of process. (struct FileLock *) */
206 LONG pr_Flags
; /* see below */
208 /* Code that is called, when the process exits. pr_ExitData takes an
209 argument to be passed to this code. */
210 void (* pr_ExitCode
)();
212 /* Arguments passed to the process from caller. */
215 /* List of local environment variables. This list should be in
216 alphabetical order. Multiple entries may have the same name, if they
217 are of different types. See <dos/var.h> for more information. */
218 struct MinList pr_LocalVars
;
219 ULONG pr_ShellPrivate
;
220 /* Standard error file. May be NULL, in which case pr_COS is to be used.
221 Use this instead of Output() to report errors. */
225 /* pr_Flags (all PRIVATE) They mainly descibe what happens if the process
226 exits, i.e. which resources the process should clean itself. The flags
227 are self-explaining. */
228 #define PRB_FREESEGLIST 0
229 #define PRB_FREECURRDIR 1
230 #define PRB_FREECLI 2
231 #define PRB_CLOSEINPUT 3
232 #define PRB_CLOSEOUTPUT 4
233 #define PRB_FREEARGS 5
234 #define PRB_CLOSEERROR 6
235 #define PRB_SYNCHRONOUS 7
236 #define PRB_WAITINGFORCHILD 8 /* This one is subject to change! */
237 #define PRB_NOTIFYONDEATH 9
239 #define PRF_FREESEGLIST (1L << PRB_FREESEGLIST)
240 #define PRF_FREECURRDIR (1L << PRB_FREECURRDIR)
241 #define PRF_FREECLI (1L << PRB_FREECLI)
242 #define PRF_CLOSEINPUT (1L << PRB_CLOSEINPUT)
243 #define PRF_CLOSEOUTPUT (1L << PRB_CLOSEOUTPUT)
244 #define PRF_FREEARGS (1L << PRB_FREEARGS)
245 #define PRF_CLOSEERROR (1L << PRB_CLOSEERROR)
246 #define PRF_SYNCHRONOUS (1L << PRB_SYNCHRONOUS)
247 #define PRF_WAITINGFORCHILD (1L << PRB_WAITINGFORCHILD)
248 #define PRF_NOTIFYONDEATH (1L << PRB_NOTIFYONDEATH)
250 /* Structure used for CLIs and Shells. Allocate this structure with
251 AllocDosObject() only! */
252 struct CommandLineInterface
254 /* Secondary error code, set by last command. */
256 /* Name of the current directory. */
258 /* Lock of the first directory in path. (struct FileLock *) */
260 /* Error code, the last command returned. See <dos/dos.h> for
263 /* Name of the command that is currently executed. */
264 BSTR cli_CommandName
;
265 /* Fail-Level as set by the command "FailAt". */
267 /* Current prompt in the CLI window. */
269 /* Standard/Default input file. (struct FileLock *) */
270 BPTR cli_StandardInput
;
271 /* Current input file. (struct FileLock *) */
272 BPTR cli_CurrentInput
;
273 /* Name of the file that is currently executed. */
274 BSTR cli_CommandFile
;
275 /* TRUE if the currently CLI is connected to a controlling terminal,
277 LONG cli_Interactive
;
278 /* FALSE if there is no controlling terminal, otherwise TRUE. */
280 /* Current output file. (struct FileLock *) */
281 BPTR cli_CurrentOutput
;
282 /* Default stack size as set by the command "Stack". */
283 LONG cli_DefaultStack
;
284 /* Standard/Default output file. (struct FileLock *) */
285 BPTR cli_StandardOutput
;
286 /* SegList of currently loaded command. */
289 /* Here begins the aros specific part */
290 /* Standard/Default Error file. (struct FileLock *) */
291 BPTR cli_StandardError
;
294 /* CLI_DEFAULTSTACK_UNIT * cli_DefaultStack = stack in bytes */
296 #define CLI_DEFAULTSTACK_UNIT sizeof(IPTR)
298 /* Devices process structure as returned by GetDeviceProc(). */
301 struct MsgPort
* dvp_Port
;
302 BPTR dvp_Lock
; /* struct FileLock * */
303 ULONG dvp_Flags
; /* see below */
304 struct DosList
* dvp_DevNode
; /* PRIVATE */
308 #define DVPB_UNLOCK 0
309 #define DVPB_ASSIGN 1
310 #define DVPF_UNLOCK (1L<<DVPB_UNLOCK)
311 #define DVPF_ASSIGN (1L<<DVPB_ASSIGN)
313 /**********************************************************************
314 ******************************* Files ********************************
315 **********************************************************************/
317 /* Standard file-handle as returned by Open() (as BPTR). Generally said, you
318 should not use this structure in any way and only use library-calls to
319 access files. Note that this structure is very different to the structure
320 used in AmigaOS! Treat this structure as PRIVATE. If you want to create
321 this structure nevertheless, use AllocDosObject(). */
324 /* The next three are used with packet-based filesystems */
325 struct Message
* fh_Link
; /* exec message containing packet */
326 struct MsgPort
* fh_Port
; /* packet reply port */
327 struct MsgPort
* fh_Type
; /* port to send packets to */
333 /* The following four fields have different names and a different
334 function than their AmigaOS equivalents. The original names were:
335 fh_Funcs/fh_Func1, fh_Func2, fh_Func3, fh_Args/fh_Arg1 and fh_Arg2 */
337 ULONG fh_Flags
; /* see below */
338 /* This is a pointer to a filesystem handler. See <dos/filesystems.h> for
340 struct Device
* fh_Device
;
342 /* SDuvan: Added this and removed the #if below. This field allows us
343 to emulate packets -- specifically it makes it possible
344 to implement the ***Pkt() functions */
345 SIPTR fh_CompatibilityHack
;
347 /* A private pointer to a device specific filehandle structure. See
348 <dos/filesystems.h> for more information. */
349 struct Unit
* fh_Unit
;
352 #define fh_Arg1 fh_CompatibilityHack
354 /* fh_Flags. The flags are AROS specific and therefore PRIVATE.. */
355 #define FHF_WRITE 0x80000000
358 #define FHF_LINEBUF 4
361 /* Structure of a lock. This is provided as it may be required internally by
362 * packet-based filesystems, but it is not used by dos.library and the rest of
363 * AROS. Lock() returns a struct FileHandle! */
366 BPTR fl_Link
; /* (struct FileLock *) Pointer to next lock. */
369 struct MsgPort
* fl_Task
;
370 BPTR fl_Volume
; /* (struct DeviceList * - see below) */
373 /* This is a definition telling that AROS uses fake FileLocks which are
374 FileHandles in fact. It will go away when real FileLocks are implemented. */
375 #define AROS_FAKE_LOCK
377 /* Constants, defining of what kind a file is. These constants are used in
378 many structures, including FileInfoBlock (<dos/dos.h>) and ExAllData
380 #define ST_PIPEFILE -5 /* File is a pipe */
381 #define ST_LINKFILE -4 /* Hard link to a file */
382 #define ST_FILE -3 /* Plain file */
383 #define ST_ROOT 1 /* Root directory of filesystem */
384 #define ST_USERDIR 2 /* Normal directory */
385 #define ST_SOFTLINK 3 /* Soft link (may be a file or directory) */
386 #define ST_LINKDIR 4 /* Hard link to a directory */
388 /**********************************************************************
389 ****************************** DosLists ******************************
390 **********************************************************************/
392 /* This structure is returned by LockDosList() and similar calls. This
393 structure is different to the AmigaOS one. But this structure is PRIVATE
394 anyway. Use system-calls for dos list-handling. */
397 /* PRIVATE pointer to next entry. In AmigaOS this used to be a BPTR. */
398 struct DosList
* dol_Next
;
399 /* Type of the current node (see below). */
401 /* Filesystem task handling this entry (for old-style filesystems) */
402 struct MsgPort
* dol_Task
;
403 /* The lock passed to AssignLock(). Only set if the type is
407 /* This union combines all the different types. */
409 /* See struct DevInfo below. */
417 /* See struct DeviceList below. */
419 struct DateStamp dol_VolumeDate
;
424 /* Structure used for assigns. */
426 /* The name for the late or nonbinding assign. */
427 UBYTE
*dol_AssignName
;
428 /* A list of locks, used by AssignAdd(). */
429 struct AssignList
*dol_List
;
433 /* Name as a BCPL string */
436 /* Private extensions for the DosList struct.
437 * Should not be used in user land code.
441 IPTR dol_Reserved
[5];
442 struct DosListAROSExt dol_AROS
;
446 /* dol_Type/dl_Type/dvi_Type. Given to MakeDosEntry(). */
447 #define DLT_DEVICE 0 /* A real filesystem (or similar) */
448 #define DLT_DIRECTORY 1 /* Just a simple assign */
449 #define DLT_VOLUME 2 /* Volume node (for removable media) */
450 #define DLT_LATE 3 /* Late binding assign (not yet) */
451 #define DLT_NONBINDING 4 /* Nonbinding assign (not yet) */
454 /* The following structures are essentially the same as DosList above. The
455 difference is that they support just one type of entry. You can use them
456 instead of DosList if you have a list containing just one type of
457 entry. For more information see above. */
461 struct DeviceList
* dl_Next
;
462 LONG dl_Type
; /* see above, always = DLT_VOLUME */
464 struct MsgPort
* dl_Task
;
467 /* Embedded DateStamp structured as defined in <dos/dos.h>. At this
468 date the volume was created. */
469 struct DateStamp dl_VolumeDate
;
470 /* (void *) List of all locks on the volume. */
472 /* Type of the disk. (see <dos/dos.h> for definitions) */
474 BPTR dl_unused
; /* PRIVATE */
476 /* In DevInfo we have three pointers and three longwords,
477 * in this structure two pointers and four longwords,
478 * add some bytes if pointers are longer then longwords
479 * FIXME: ptr alignment not taken into account
481 #if AROS_SIZEOFPTR > AROS_SIZEOFULONG
482 // UBYTE dl_unused2[(AROS_SIZEOFPTR-AROS_SIZEOFULONG)];
487 /* Private extensions
488 * Should not be used in user land code.
493 struct DosListAROSExt dl_AROS
;
498 /* Structure that describes a device. This is essentially the same structure
499 as DeviceNode, defined in <dos/filehandler.h>. */
502 struct DevInfo
* dvi_Next
;
503 LONG dvi_Type
; /* see above, always = DLT_DEVICE */
505 struct MsgPort
* dvi_Task
;
508 BSTR dvi_Handler
; /* Device name for handler. */
509 LONG dvi_StackSize
; /* Packet-handler initial stack size */
510 LONG dvi_Priority
; /* Packet-handler initial priority */
511 BPTR dvi_Startup
; /* (struct FileSysStartupMsg * - defined in
512 <dos/filehandler.h>) */
513 BPTR dvi_NoAROS4
[2]; /* PRIVATE */
517 /* Private extensions
518 * Should not be used in user land code.
522 IPTR dvi_Reserved
[5];
523 struct DosListAROSExt dvi_AROS
;
527 /* Dos list scanning and locking modes as used in LockDosList() */
528 /* Specify either LDF_READ, if you want a non-exclusive lock, or LDF_WRITE,
529 if you want an exclusive lock (i.e. if you want to modify the list).
531 #define LDB_READ 0 /* Non-exclusive/read lock */
532 #define LDB_WRITE 1 /* Exclusive/write lock */
533 /* Specify which list(s) to lock. */
534 #define LDB_DEVICES 2 /* Device list */
535 #define LDB_VOLUMES 3 /* Volume list */
536 #define LDB_ASSIGNS 4 /* Assign list */
540 #define LDF_READ (1L<<LDB_READ)
541 #define LDF_WRITE (1L<<LDB_WRITE)
542 #define LDF_DEVICES (1L<<LDB_DEVICES)
543 #define LDF_VOLUMES (1L<<LDB_VOLUMES)
544 #define LDF_ASSIGNS (1L<<LDB_ASSIGNS)
545 #define LDF_ENTRY (1L<<LDB_ENTRY)
546 #define LDF_DELETE (1L<<LDB_DELETE)
547 #define LDF_ALL (LDF_DEVICES | LDF_VOLUMES | LDF_ASSIGNS)
550 /* Used for assigns that point to multiple directories. */
553 struct AssignList
* al_Next
; /* Pointer to next assign node. */
554 BPTR al_Lock
; /* (struct FileLock *) Lock of on of the
558 /**********************************************************************
559 ********************** Low Level File Handling ***********************
560 **********************************************************************/
562 /* This section is OBSOLETE and is not implemented in AROS! AROS uses a
563 different concept for filesystem-handling. See <dos/filesystem.h> for
564 more information. Use the structures and defines in this section only, if
565 you are programming just for AmigaOS. */
568 /* Allocate this structure with AllocDosObject(). */
571 struct Message
* dp_Link
; /* Pointer to a standard exec message. */
572 struct MsgPort
* dp_Port
; /* Reply-Port of that packet. */
574 LONG dp_Type
; /* see below */
575 LONG dp_Res1
; /* Normal return value. */
576 LONG dp_Res2
; /* Secondary return value (as returned by IoErr()). See
577 <dos/dos.h> for possible values. */
579 /* The actual data. */
588 #define dp_Action dp_Type
589 #define dp_Status dp_Res1
590 #define dp_Status2 dp_Res2
591 #define dp_BufAddr dp_Arg1
594 /* These are defined for packet emulation purposes only! AROS doesn't use
595 packets at all, but emulates (some of) them via DoPkt(), SendPkt() and
596 others to function like they did in AmigaOS */
600 #define ACTION_STARTUP 0
601 #define ACTION_GET_BLOCK 2 /* Obsolete */
602 #define ACTION_SET_MAP 4
604 #define ACTION_EVENT 6
605 #define ACTION_CURRENT_VOLUME 7
606 #define ACTION_LOCATE_OBJECT 8
607 #define ACTION_RENAME_DISK 9
608 #define ACTION_FREE_LOCK 15
609 #define ACTION_DELETE_OBJECT 16
610 #define ACTION_RENAME_OBJECT 17
611 #define ACTION_MORE_CACHE 18
612 #define ACTION_COPY_DIR 19
613 #define ACTION_WAIT_CHAR 20
614 #define ACTION_SET_PROTECT 21
615 #define ACTION_CREATE_DIR 22
616 #define ACTION_EXAMINE_OBJECT 23
617 #define ACTION_EXAMINE_NEXT 24
618 #define ACTION_DISK_INFO 25
619 #define ACTION_INFO 26
620 #define ACTION_FLUSH 27
621 #define ACTION_SET_COMMENT 28
622 #define ACTION_PARENT 29
623 #define ACTION_TIMER 30
624 #define ACTION_INHIBIT 31
625 #define ACTION_DISK_TYPE 32
626 #define ACTION_DISK_CHANGE 33
627 #define ACTION_SET_DATE 34
628 #define ACTION_SAME_LOCK 40
630 #define ACTION_WRITE 'W'
631 #define ACTION_READ 'R'
633 #define ACTION_SCREEN_MODE 994
634 #define ACTION_CHANGE_SIGNAL 995
635 #define ACTION_READ_RETURN 1001
636 #define ACTION_WRITE_RETURN 1002
637 #define ACTION_FINDUPDATE 1004
638 #define ACTION_FINDINPUT 1005
639 #define ACTION_FINDOUTPUT 1006
640 #define ACTION_END 1007
641 #define ACTION_SEEK 1008
642 #define ACTION_FORMAT 1020
643 #define ACTION_MAKE_LINK 1021
644 #define ACTION_SET_FILE_SIZE 1022
645 #define ACTION_WRITE_PROTECT 1023
646 #define ACTION_READ_LINK 1024
647 #define ACTION_FH_FROM_LOCK 1026
648 #define ACTION_IS_FILESYSTEM 1027
649 #define ACTION_CHANGE_MODE 1028
650 #define ACTION_COPY_DIR_FH 1030
651 #define ACTION_PARENT_FH 1031
652 #define ACTION_EXAMINE_ALL 1033
653 #define ACTION_EXAMINE_FH 1034
654 #define ACTION_EXAMINE_ALL_END 1035
655 #define ACTION_SET_OWNER 1036
657 #define ACTION_LOCK_RECORD 2008
658 #define ACTION_FREE_RECORD 2009
660 #define ACTION_ADD_NOTIFY 4097
661 #define ACTION_REMOVE_NOTIFY 4098
663 #define ACTION_SERIALIZE_DISK 4200
665 /* Structure for easy handling of DosPackets. DosPackets don't have to be in
666 this structure, but this struture may ease the use of it. */
667 struct StandardPacket
669 struct Message sp_Msg
;
670 struct DosPacket sp_Pkt
;
674 /* NOTE: AROS doesn't use startup packets. This will ONLY make a difference
675 for shell writers... */
677 /* Types of command execution */
678 #define RUN_EXECUTE -1
679 #define RUN_SYSTEM -2
680 #define RUN_SYSTEM_ASYNCH -3
683 /**********************************************************************
684 ****************************** Segments ******************************
685 **********************************************************************/
687 /* Resident list structure as returned by AddSegment(). */
690 BPTR seg_Next
; /* Pointer to next segment. */
691 LONG seg_UC
; /* Usage count/type */
692 BPTR seg_Seg
; /* Actual Segment */
693 UBYTE seg_Name
[4]; /* The first characters of the name (BSTR). */
696 #define CMD_SYSTEM -1
697 #define CMD_INTERNAL -2
698 #define CMD_DISABLED -999
700 /**********************************************************************
701 *************************** Error Handling ***************************
702 **********************************************************************/
710 /* Return values for ErrorReport(). */
711 #define REPORT_STREAM 0
712 #define REPORT_TASK 1
713 #define REPORT_LOCK 2
714 #define REPORT_VOLUME 3
715 #define REPORT_INSERT 4
717 #define ABORT_BUSY 288
718 #define ABORT_DISK_ERROR 296
720 #endif /* DOS_DOSEXTENS_H */