|Re: [hatari-devel] Trapping OS call accesses under MiNT|
[ Thread Index |
| More lists.tuxfamily.org/hatari-devel Archives
On tiistai 16 lokakuu 2012, Vincent Rivière wrote:
> BTW, FreeMiNT access the drives using NEWFATFS by default (using XHDI
> block device interface), but it can also use TOSFS (direct access to ROM
> GEMDOS functions).
I was checking READMEs for different MiNT versions and
apparently TOSFS had disappeared already in v1.16.0 beta:
FreeMiNT 1.16.0 doesn't use the underlying TOS for file system
access anymore. The kernel will only use it's own (V)FAT(32)
file system driver. The old TOSFS is removed, the NEWFATFS
directive in the MINT.CNF file will be ignored if present.
When grepping MiNT sources, there seems to be OLDTOSFS define
though, but it's disabled by default so apparently although
there might be some support still, it's not available with
MiNT binaries (and likely therefore to be bitrotten).
> I don't know of the latter currently works or not on Hatari.
Is there anywhere a build of 68k (non-Aranym) MiNT that
is built with OLDTOSFS enabled, so that one could test
whether it works at all with Hatari GEMDOS emulation?
Regarding OS call trapping, BIOS/XBIOS/AES/VDI calls Hatari catches
when their traps are called, but GEMDOS it catches by overwriting
the TOS GEMDOS vector (0x84) address with its own.
However, MiNT will overwrite all trap vectors (and much more) when
it starts up. For more info, see init_intr() in init_intr.c in MiNT
(While I don't think implementing just TOS subset of GEMDOS calls
under MINT, such as Hatari's GEMDOS emulation, would be completely safe,
this also disables GEMDOS tracing under MiNT which shouldn't cause
any problems for MiNT.)
One can catch the GEMDOS vector overwrite with:
b (0x84) ! (0x84)
And restore it back to Hatari one after MiNT changes it:
> info gemdos
Current GEMDOS handler: (0x84) = 0x4873c, emu one = 0xfa002a
Stored GEMDOS handler: (0xfa0024) = 0xfc9332
> w 0xfa0024 $00 $04 $87 $3c
> w 0x84 $00 $fa $00 $2a
This will set Hatari handler for GEMDOS again and tell Hatari
to call MiNT's new gemdos handler after that.
I don't know whether MiNT+Hatari will call the TOS stuff then
correctly though, but at least I was able to boot a MiNT setup
on HD image with this and see GEMDOS output tracing.
Because MiNT refers to things through u:/, you cannot boot
MiNT setup from Hatari GEMDOS driver, it needs to happen
from a disk image. Opening GEMDOS emulation drive on u:
naturally fails also.
Hatari GEMDOS emulation stores current TOS basepage as
that's used in some operations for accessing file DTA info,
but ROM TOS and MiNT would seem to share same basepage address.
Additionally, although MiNT does call original TOS for some things,
it doesn't to that through traps, but by jumping directly:
; The functions enter_bios() and enter_gemdos() are called on entry
; to the kernel, and the function leave_kernel() is called on exit.
; These functions are responsible for setting stuff up so that MiNT
; can trap out to TOS directly, but programs can only trap to MiNT.
; NOTICE: trap #1 handler NO LONGER redirects calls to ROM. This is
; done by an indirect jump in trap_1_emu().
; we also call certain BIOS functions directly if these are known
; not to require saving/restoring of context
// NOTICE: MiNT *no longer ever* traps to ROM GEMDOS, because even
// the TOSFS *jumps* (not traps) there.
trap #1 handler no longer wraps to ROM. This makes TOSFS no
longer valid. Underlying functions not supported by MiNT are
still called via wrapper trap_1_emu(). Also similar wrappers
are done for BIOS and XBIOS (now commented out for future
usage). This also causes a (very small) reduction of GEMDOS
To still be able to use old TOSFS XFS, one will have to
change TOS bindings so that they do jsr _tos_1_emu instead of
This means that while Hatari can catch BIOS/XBIOS/AES/VDI with
MiNT without trouble, that works only for user-space programs,
not for calls within kernel.
And same would apply to GEMDOS emulation if it's done with trap handler.
-> Even with TOSFS, it might be better to use a HD
image for booting...
The MiNT TOS call implementation (with coldfire bits left out)
for GEMDOS looks like this:
* initialize all interrupt vectors and new trap routines
* we also get here any TOS variables that we're going to change
* (e.g. the pointer to the cookie jar) so that rest_intr can
* restore them.
new_xbra_install (&old_dos, 0x84L, mint_dos); /* trap #1,
tst.w (0x059e).w // test longframe
#if !(defined(M68000) || defined(__mcoldfire__))
According to tosfs.c, these are the GEMDOS functions used by TOSFS:
Because MiNT does additional things with files and has
many additional file system calls, trapping things at
MiNT GEMDOS trap level probably doesn't work properly
like it does with TOS.
If interception with MiNT would still be done at GEMDOS
level, it would need to be extended to cover all additional
file system related GEMDOS calls (mentioned in my previous
Whereas with TOSFS and MiNTs direct jumps to TOS code, either
Hatari would need to intercept these jumps, or in addition to
enabling OLDTOSFS in MiNT sources, its way of calling above
listed functions would probably need to be changed to be
through NatFEATs (or something similar).
The only difference between this and Aranym-like NatFEATs
file system implementation is the width of the FS API.
TOSFS on reduced NatFEATS FS would implement just
TOS FS API and could probably be done on Hatari side
with some additional gemdos call wrapper.
Pexec loader asm-code might also need some extra support