xref: /haiku/docs/develop/kernel/arch/m68k/atari.rst (revision 3d4afef9cba2f328e238089d4609d00d4b1524f3)
1The Atari ST port
2=================
3
4Atari ST executables
5--------------------
6
7From: DaFi <webmaster@freudenstadt.net>
8
9The specs for Atari ST executables (was listed as requested on www.wotsit.demon.co.uk/wanted.htm)...
10
11applies for TOS, PRG, TTP, PRX, GTP, APP, ACC, ACX (different suffixes indicate different behavior of the program, i.e. TOS and TTP may not use the GEM GUI, while all the others may; only TTP and GTP can be called with parameters; ACC may be installed as desktop accessories; PRX and ACX mean the programs were disabled.
12
13file structure:
14
15+--------------------+---------------------------------------------------------------------------+
16| [2] WORD PRG_magic | magic value 0x601a                                                        |
17+--------------------+---------------------------------------------------------------------------+
18| [4] LONG PRG_tsize | size of text segment                                                      |
19+--------------------+---------------------------------------------------------------------------+
20| [4] LONG PRG_dsize | size of data segment                                                      |
21+--------------------+---------------------------------------------------------------------------+
22| [4] LONG PRG_bsize | size of bss segment                                                       |
23+--------------------+---------------------------------------------------------------------------+
24| [4] LONG PRG_ssize | size of symbol table                                                      |
25+--------------------+---------------------------------------------------------------------------+
26| [4] LONG PRG_res1  | reserved                                                                  |
27+--------------------+---------------------------------------------------------------------------+
28| [4] LONG PRGFLAGS  | bit vector that defines additional process characteristics, as follows:   |
29|                    |                                                                           |
30|                    | * **Bit 0 PF_FASTLOAD** - if set, only the BSS area is cleared, otherwise,|
31|                    |   the program's whole memory is cleared before loading                    |
32|                    | * **Bit 1 PF_TTRAMLOAD** - if set, the program will be loaded into TT RAM |
33|                    | * **Bit 2 PF_TTRAMMEM** - if set, the program will be allowed to allocate |
34|                    |   memory from TT RAM                                                      |
35|                    |                                                                           |
36|                    | Bit 4 AND 5 as a two bit value with the following meanings:               |
37|                    |                                                                           |
38|                    | * 0 PF_PRIVATE - the processes entire memory space is considered private  |
39|                    | * 1 PF_GLOBAL - the processes memory will be r/w-allowed for others       |
40|                    | * 2 PF_SUPER - the memory will be r/w for itself and any supervisor proc  |
41|                    | * 3 PF_READ - the memory will be readable by others                       |
42+--------------------+---------------------------------------------------------------------------+
43| [2] WORD ABSFLAG   | is NON-ZERO, if the program does not need to be relocated                 |
44|                    |                                                                           |
45|                    | is ZERO, if the program needs to be relocated                             |
46|                    |                                                                           |
47|                    | note: since some TOS versions handle files with ABSFLAG>0 incorrectly,    |
48|                    | this value should be set to ZERO also for programs that need to be        |
49|                    | relocated, and the FIXUP_offset should be set to 0.                       |
50+--------------------+---------------------------------------------------------------------------+
51
52From there on... (should be offset 0x1c)
53
54[PRG_tsize] TEXT segment
55[PRG_dsize] DATA segment
56[PRG_ssize] Symbol table
57
58[4] LONG FIXUP_offset - first LONG that needs to be relocated (offset to beginning of file)
59
60From there on till the end of the file...
61
62FIXUP table, with entries as follows:
63
64[1] BYTE value
65
66with value as follows:
67
68- value=0  end of list
69- value=1  advance 254 bytes
70- value=2 to value=254 (only even values!) advance this many bytes and relocate the LONG found there.
71
72That's it. You made it through to EOF.
73
74A final note about fixing up (relocating) an executable: (pseudo-code)
75
76The long value FIXUP_offset tells you your start adress. Let's call it "adr". So, now, that
77you have adr, read the first byte of the table.
78
79(*) loop
80
81- if it's 0, stop relocating -> you're done!
82- if it's 1, add 254 to adr and read the next byte, jump back to the asterisk (*)
83- if it's any other even value, add the value to your adr, then relocate the LONG at adr.
84  (i.e. add the adress of the LONG to its value)
85
86Useful resources
87----------------
88
89* http://toshyp.atari.org/en/index.html
90
91* http://www.lysator.liu.se/~celeborn/sync/atari/misc.html
92* http://www.lysator.liu.se/~celeborn/sync/atari/ATARI/F30.ZIP
93* http://www.lysator.liu.se/~celeborn/sync/atari/ATARI/FALCLIB6.ZIP
94* http://www.lysator.liu.se/~celeborn/sync/atari/ATARI/FALCREGS.ZIP
95
96* http://fxr.watson.org/fxr/source/include/asm-m68k/atarihw.h?v=linux-2.4.22
97* http://lxr.linux.no/linux+v2.6.27/arch/m68k/atari/config.c#L664
98
99* http://www.atari-forum.com/wiki/index.php/MFP_MK68901
100
101* http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/atari/stand/xxboot/ahdi-xxboot/xxboot.ahdi.S
102
103AHDI args
104
105* http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/atari/stand/xxboot/wdboot/wdboot.S
106* http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/atari/stand/xxboot/sdboot/sdboot.S
107* http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/atari/stand/xxboot/fdboot/fdboot.S
108
109