Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions arch/m68k-all/include/gencall.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,16 @@ static const char libextra[] =
"#define __AROS_LC3LONG __AROS_LC3\n"
"#define __AROS_LC4LONG __AROS_LC4\n"
"#define __AROS_LC5LONG __AROS_LC5\n"
"/* 64-bit results are returned in d0/d1, which the plain call macros\n"
" already reassemble, so these map straight through */\n"
"#define __AROS_LC2QUAD __AROS_LC2\n"
"#define __AROS_LC3QUAD __AROS_LC3\n"
"#define __AROS_LC4QUAD __AROS_LC4\n"
"#define __AROS_LC5QUAD __AROS_LC5\n"
"#define __AROS_LC2UQUAD __AROS_LC2\n"
"#define __AROS_LC3UQUAD __AROS_LC3\n"
"#define __AROS_LC4UQUAD __AROS_LC4\n"
"#define __AROS_LC5UQUAD __AROS_LC5\n"
"\n"
"# define AROS_LDQUAD1(t,n,q1,bt,bn,o,s) \\\n"
" __AROS_LD_PREFIX t AROS_SLIB_ENTRY(n,s,o) ( \\\n"
Expand Down
3 changes: 2 additions & 1 deletion arch/m68k-amiga/boot/mmakefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include $(SRCDIR)/config/aros.cfg
#MM kernel-diag-kobj \
#MM kernel-disk-kobj \
#MM kernel-dos-kobj \
#MM kernel-dos64-kobj \
#MM kernel-dosboot-kobj \
#MM kernel-expansion-kobj \
#MM kernel-filesystem-kobj \
Expand Down Expand Up @@ -165,7 +166,7 @@ AFILES := ext_entry

# APOLLOROM = V4 -> Native V4
ifeq ($(APOLLOROM),V4)
KLIBS := keymap graphics layers intuition gadtools workbench mathffp mathieeesingbas freeanim lowlevel setpatch
KLIBS := keymap graphics layers intuition gadtools workbench mathffp mathieeesingbas freeanim lowlevel setpatch dos64
KDEVS := sagasd ata trackdisk
KHNDLRS := con
KHIDDS := bus storage system
Expand Down
133 changes: 78 additions & 55 deletions compiler/include/dos/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,31 @@ struct DateStamp
this value, as it may change in future versions. */
#define MAXCOMMENTLENGTH 80

/*
* 64-bit integers in the DOS structures below follow the Amiga ABI, where
* they are only 2-byte aligned (the MorphOS headers use pack(2)). 32-bit
* ARM and PowerPC compilers align them to 8 bytes by default, which would
* move them away from the offsets other systems and binary handlers use.
* 64-bit AROS has no foreign layout to match and keeps natural alignment.
*/
#if (__WORDSIZE == 64)
#define AROS_DOS64_ALIGN
#else
#define AROS_DOS64_ALIGN __attribute__((__packed__, __aligned__(2)))
#endif

/* Structure used to describe a directory entry. Note that not all fields
are supported by all filesystems. This structure should be allocated
with AllocDosObject(). */
struct FileInfoBlock64
with AllocDosObject().

The 64-bit size fields (fib_Size64, fib_NumBlocks64) overlay the reserved
area as defined by MorphOS (tm) V51. They are filled by the 64-bit examine
calls (dos64.library Examine64(), ExNext64(), ExamineFH64(), packets
ACTION_EXAMINE_OBJECT64, _NEXT64, _FH64). Everything before them keeps
the classic layout, so the block is the same size as before and the
32-bit calls can use it as well. fib_DiskKey is IPTR as handlers may
store a pointer in it. */
struct FileInfoBlock
{
IPTR fib_DiskKey;
/* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
Expand All @@ -81,49 +102,47 @@ struct FileInfoBlock64
UBYTE fib_FileName[MAXFILENAMELENGTH];
LONG fib_Protection; /* The protection bits (see below). */
LONG fib_EntryType;
UQUAD fib_Size; /* The size of the file. */
UQUAD fib_NumBlocks; /* Number of blocks used for file. */
struct DateStamp fib_Date; /* Date of last change to file. */
/* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
UBYTE fib_Comment[MAXCOMMENTLENGTH];
UWORD fib_OwnerUID; /* UserID of fileowner. */
UWORD fib_OwnerGID; /* GroupID of fileowner. */
UBYTE fib_Reserved[32]; /* PRIVATE */
};

struct FileInfoBlock32
{
IPTR fib_DiskKey;
/* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
the file described is a directory, otherwise it is a plain file. */
LONG fib_DirEntryType;
/* The filename.
*
* User applications should always treat this as ASCIIZ.
*
* NOTE: This is created as a BCPL string in the ACTION_EXAMINE_*
* filesystem handler code, but is converted to a C style
* '\0'-terminated string by the Dos/Examine???() functions.
*
*/
UBYTE fib_FileName[MAXFILENAMELENGTH];
LONG fib_Protection; /* The protection bits (see below). */
LONG fib_EntryType;
LONG fib_Size; /* The size of the file. */
LONG fib_Size; /* The size of the file. 0 from the
64-bit calls when it does not
fit; see fib_Size64. */
LONG fib_NumBlocks; /* Number of blocks used for file. */
struct DateStamp fib_Date; /* Date of last change to file. */
/* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
UBYTE fib_Comment[MAXCOMMENTLENGTH];
UWORD fib_OwnerUID; /* UserID of fileowner. */
UWORD fib_OwnerGID; /* GroupID of fileowner. */
UBYTE fib_Reserved[32]; /* PRIVATE */
union
{
UBYTE fib_un_Reserved[32]; /* PRIVATE */
struct
{
UQUAD fib_un_ext_Size64 AROS_DOS64_ALIGN;
UQUAD fib_un_ext_NumBlocks64 AROS_DOS64_ALIGN;
ULONG fib_un_ext_Pad0[3];
UWORD fib_un_ext_Pad1;
UBYTE fib_un_ext_ActExtFlags;
UBYTE fib_un_ext_ReqExtFlags;
} fib_un_ext;
} fib_un;
};

#if (__DOS64)
#define FileInfoBlock FileInfoBlock64
#else
#define FileInfoBlock FileInfoBlock32
#endif
#define fib_Reserved fib_un.fib_un_Reserved
#define fib_Size64 fib_un.fib_un_ext.fib_un_ext_Size64 /* 64-bit size of the file */
#define fib_NumBlocks64 fib_un.fib_un_ext.fib_un_ext_NumBlocks64 /* 64-bit number of blocks */
/* Extensions the handler filled in (FIBEXTF_ flags). Must be 0 when an
ACTION_EXAMINE_*64 packet is sent. The 64-bit size and block count
do not need a flag; they are always filled. */
#define fib_ActExtFlags fib_un.fib_un_ext.fib_un_ext_ActExtFlags
/* Extensions requested from the handler (FIBEXTF_ flags), or 0. */
#define fib_ReqExtFlags fib_un.fib_un_ext.fib_un_ext_ReqExtFlags

/* No FIBEXTF_ extensions are defined on AROS yet. Bit 0 is kept free
for compatibility: MorphOS uses it (FIBEXTB_POSIXDATE) for a POSIX
date in place of fib_Date. */

/* Former names: the 64-bit examine calls use the standard structure */
#define FileInfoBlock32 FileInfoBlock
#define FileInfoBlock64 FileInfoBlock

/* Protection bits for files (fib_Protection). */
/* Flags for owner (they are active-low, i.e. not set means the action is
Expand Down Expand Up @@ -171,37 +190,41 @@ struct FileInfoBlock32
**********************************************************************/

/* Structure used in Info(). Must be longword-aligned. */
struct InfoData64
struct InfoData
{
LONG id_NumSoftErrors; /* Number of soft errors on device. */
LONG id_UnitNumber; /* Unit number of device. */
LONG id_DiskState; /* State the current volume is in (see below). */
UQUAD id_NumBlocks; /* Number of blocks on device. */
UQUAD id_NumBlocksUsed; /* Number of blocks in use. */
LONG id_NumBlocks; /* Number of blocks on device. */
LONG id_NumBlocksUsed; /* Number of blocks in use. */
LONG id_BytesPerBlock; /* Bytes per block. */
LONG id_DiskType; /* Type of disk (see below). */
BPTR id_VolumeNode;
IPTR id_InUse; /* Set, if device is in use. */
};

struct InfoData32
/* AROS extension, used by dos64.library Info64() and ACTION_INFO64: the
standard InfoData followed by 64-bit block counts. The leading part is
identical to struct InfoData, so the block can also be filled by
ACTION_INFO; id_NumBlocks and id_NumBlocksUsed then hold the 32-bit
values. Allocate it with AllocDosObject64(DOS64_INFODATA, NULL). */
struct InfoData64
{
LONG id_NumSoftErrors; /* Number of soft errors on device. */
LONG id_UnitNumber; /* Unit number of device. */
LONG id_DiskState; /* State the current volume is in (see below). */
LONG id_NumBlocks; /* Number of blocks on device. */
LONG id_NumBlocksUsed; /* Number of blocks in use. */
LONG id_BytesPerBlock; /* Bytes per block. */
LONG id_DiskType; /* Type of disk (see below). */
BPTR id_VolumeNode;
IPTR id_InUse; /* Set, if device is in use. */
LONG id_NumSoftErrors;
LONG id_UnitNumber;
LONG id_DiskState;
LONG id_NumBlocks; /* 32-bit count, may be clamped */
LONG id_NumBlocksUsed; /* 32-bit count, may be clamped */
LONG id_BytesPerBlock;
LONG id_DiskType;
BPTR id_VolumeNode;
IPTR id_InUse;
UQUAD id_NumBlocks64 AROS_DOS64_ALIGN; /* Number of blocks on device. */
UQUAD id_NumBlocksUsed64 AROS_DOS64_ALIGN; /* Number of blocks in use. */
};

#if (__DOS64)
#define InfoData InfoData64
#else
#define InfoData InfoData32
#endif
/* Former name */
#define InfoData32 InfoData

/* id_DiskState */
#define ID_WRITE_PROTECTED 80 /* Volume is write-protected. */
Expand Down
144 changes: 144 additions & 0 deletions compiler/include/dos/dos64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#ifndef DOS_DOS64_H
#define DOS_DOS64_H

/*
Copyright (C) 2026, The AROS Development Team. All rights reserved.

Desc: 64-bit filesystem I/O support definitions, for use with
dos64.library and 64-bit aware filesystem handlers.
*/

#ifndef DOS_DOS_H
# include <dos/dos.h>
#endif
#ifndef DOS_DOSEXTENS_H
# include <dos/dosextens.h>
#endif
#ifndef DOS_RECORD_H
# include <dos/record.h>
#endif

/**********************************************************************
********************** 64-bit Packet types ***************************
**********************************************************************/

/*
* MorphOS (tm) compatible extensions (V51). 64-bit values are passed by
* pointer, so the packets are the same on 32-bit and 64-bit systems:
*
* ACTION_SEEK64 dp_Arg1 fh_Arg1, dp_Arg2 QUAD *position,
* dp_Arg3 mode, dp_Arg4 QUAD *oldposition
* ACTION_SET_FILE_SIZE64 dp_Arg1 fh_Arg1, dp_Arg2 QUAD *offset,
* dp_Arg3 mode, dp_Arg4 QUAD *newsize
* ACTION_LOCK_RECORD64 dp_Arg1 fh_Arg1, dp_Arg2 UQUAD *offset,
* dp_Arg3 UQUAD *length, dp_Arg4 mode,
* dp_Arg5 timeout
* ACTION_FREE_RECORD64 dp_Arg1 fh_Arg1, dp_Arg2 UQUAD *offset,
* dp_Arg3 UQUAD *length
* ACTION_QUERY_ATTR dp_Arg1 attribute (FQA_), dp_Arg2 APTR storage,
* dp_Arg3 storage size
*
* dp_Res1 is DOSTRUE on success, or DOSFALSE with the error in dp_Res2;
* the results are stored through the pointers.
*
* ACTION_EXAMINE_OBJECT64, ACTION_EXAMINE_NEXT64 and ACTION_EXAMINE_FH64
* take the same arguments as the 32-bit packets (dp_Arg1 the lock, or
* fh_Arg1 for _FH64; dp_Arg2 a BPTR to a struct FileInfoBlock). The handler
* fills the standard fields and fib_Size64/fib_NumBlocks64 (see <dos/dos.h>),
* with fib_Size 0 for sizes above 2^31-1, and sets fib_ActExtFlags. The
* sender must set fib_ActExtFlags to 0 and fib_ReqExtFlags to the
* extensions it wants (or 0).
*
* A handler that does not know a packet answers DOSFALSE with
* ERROR_ACTION_NOT_KNOWN.
*/
#ifndef ACTION_SEEK64
#define ACTION_SEEK64 26400
#define ACTION_SET_FILE_SIZE64 26401
#define ACTION_LOCK_RECORD64 26402
#define ACTION_FREE_RECORD64 26403
#define ACTION_QUERY_ATTR 26407
#define ACTION_EXAMINE_OBJECT64 26408
#define ACTION_EXAMINE_NEXT64 26409
#define ACTION_EXAMINE_FH64 26410
#endif

/* ACTION_QUERY_ATTR attributes (MorphOS (tm) compatible) */
#ifndef FQA_MaxFileNameLength
#define FQA_MaxFileNameLength 0 /* LONG */
#define FQA_MaxVolumeNameLength 1 /* LONG */
#define FQA_MaxFileSize 2 /* QUAD */
#define FQA_IsCaseSensitive 3 /* LONG */
#define FQA_DeviceType 4 /* LONG */
#define FQA_NumBlocks 6 /* QUAD */
#define FQA_NumBlocksUsed 7 /* QUAD */
#endif

/*
* AROS extension: 64-bit volume information.
* Arguments as for ACTION_INFO, but dp_Arg2 points (BPTR) to a
* struct InfoData64 (see <dos/dos.h>): the standard InfoData followed by
* the 64-bit block counts.
*/
#define ACTION_INFO64 2020

#if (__WORDSIZE != 64)
/*
* AmigaOS 4 (tm) compatible 64-bit packet layout, used on 32-bit
* systems for the ACTION_CHANGE_FILE_POSITION64, ACTION_GET_FILE_POSITION64,
* ACTION_CHANGE_FILE_SIZE64 and ACTION_GET_FILE_SIZE64 packets, where the
* standard DosPacket fields are too small to carry 64-bit values.
*
* This structure overlays the standard DosPacket. The originator must
* additionally store the object (fh_Arg1) in the *standard* packet's
* dp_Arg1 field, set dp_Res0 to DP64_INIT, and place the 64-bit
* argument(s) in the fields below.
*
* On 64-bit AROS builds this structure is not used (see below).
*/
struct DosPacket64
{
struct Message * dp_Link; /* Pointer to a standard exec message. */
struct MsgPort * dp_Port; /* Reply-Port of that packet. */

LONG dp_Type; /* 8: Packet type (ACTION_...) */
LONG dp_Res0; /* 12: Set to DP64_INIT by the originator */
ULONG dp_Res2; /* 16: Secondary result (IoErr() value) */
LONG dp_Pad0; /* 20: see the alignment note below */
QUAD dp_Res1; /* 24: 64-bit primary result */
LONG dp_Arg1; /* 32: the object (fh_Arg1) */
LONG dp_Pad1; /* 36 */
QUAD dp_Arg2; /* 40: 64-bit argument */
ULONG dp_Arg3; /* 48: 32-bit argument (e.g. seek mode) */
ULONG dp_Arg4; /* 52: struct FileHandle * */
QUAD dp_Arg5; /* 56: must be zero to validate dp_Arg4 */
};

/*
* On 64-bit AROS the standard DosPacket argument and result fields are
* already 64-bit wide (SIPTR), so these four packets carry their 64-bit
* values directly in dp_Arg2/dp_Res1 of a standard packet there.
*
* The padding above is deliberate and must not be removed. The 64-bit
* fields of this packet sit at fixed offsets (dp_Res1 at 24, dp_Arg2 at
* 40, dp_Arg5 at 56), which is what a handler on the other side reads
* and writes. Those offsets are what a compiler that gives a 64-bit type
* 8-byte alignment produces on its own - but m68k aligns them to 4, so
* without the padding every 64-bit field would sit 4 bytes early and the
* two sides would disagree about where the result is. Spelling the
* padding out keeps the layout identical whatever the ABI decides.
*/

#define DP64_INIT (-3)
#endif

/**********************************************************************
******************* AllocDosObject64() types *************************
**********************************************************************/

/* Objects allocatable with dos64.library/AllocDosObject64() */
#define DOS64_FIB 1 /* struct FileInfoBlock */
#define DOS64_INFODATA 2 /* struct InfoData64 */
#define DOS64_RECORDLOCK 3 /* struct RecordLock64 */

#endif /* DOS_DOS64_H */
30 changes: 1 addition & 29 deletions compiler/include/dos/dosextens.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,29 +290,7 @@ struct DevProc
should not use this structure in any way and only use library-calls to
access files. Treat this structure as PRIVATE. If you want to create
this structure nevertheless, use AllocDosObject(). */
struct FileHandle64
{
/* The next three are used with packet-based filesystems */
ULONG fh_Flags;
LONG fh_Interactive; /* interactive handle flag */
struct MsgPort * fh_Type; /* port to send packets to */

BPTR fh_Buf;
UQUAD fh_Pos;
UQUAD fh_End;

SIPTR fh_Funcs;
SIPTR fh_Func2;
SIPTR fh_Func3;
SIPTR fh_Args;
SIPTR fh_Arg2;

/* v39+ */
IPTR fh_BufSize; /* Size of buffered io buffer */
BPTR fh_OrigBuf; /* Always the same as fh_Buf */
};

struct FileHandle32
struct FileHandle
{
/* The next three are used with packet-based filesystems */
ULONG fh_Flags;
Expand All @@ -334,12 +312,6 @@ struct FileHandle32
BPTR fh_OrigBuf; /* Always the same as fh_Buf */
};

#if (__DOS64)
#define FileHandle FileHandle64
#else
#define FileHandle FileHandle32
#endif

/* Original AmigaOS aliases */
#define fh_Port fh_Interactive
#define fh_Func1 fh_Funcs
Expand Down
Loading