Atari TOS¶
This directory has Atari TOS support (TOS 1.0 and later, and EmuTOS, on
any 68k CPU) for picolibc on the m68k-atari-tos target of the
clang-dos LLVM toolchain. It goes into
libc.a itself, with crt0.o and the linker script tos.ld, so a
program needs nothing else from picolibc. It uses no Atari headers: the
GEMDOS and XBIOS calls it makes are written out in local-tos.h.
Building¶
With clang, llvm-ar and the other LLVM tools on PATH:
meson setup build-tos \
--cross-file scripts/cross-clang-m68k-atari-tos.txt \
-Dos-tos=true -Dmultilib=false -Dpicocrt=false -Dsemihost=false \
-Dtests=false -Dposix-console=true -Dsingle-thread=true \
-Dthread-local-storage=false -Dspecsdir=none \
--prefix=$PWD/install-tos
ninja -C build-tos install
Copy include/ to <sysroot>/include and lib/crt0.o, lib/tos.ld,
lib/libc.a and lib/libm.a to <sysroot>/lib.
clang --target=m68k-atari-tos --sysroot=<sysroot> then links them with
libclang_rt.builtins.a by default. The cross file builds for the 68000,
so the library runs on every Atari.
What it does¶
crt0.Sgets the basepage, keeps the program's text, data, bss and a stack of_stksizebytes (32K unless the program defines it), and gives the rest of memory back withMshrink().start.cmakesenvironfrom the GEMDOS environment andargvfrom the command line in the basepage, or from theARGVenvironment convention when the caller uses it, and callsmain.sbrkhands out one block fromMalloc(), taken on first use, for picolibc'smalloc, which needs its memory in one piece: all of the largest free block but 64K, or_heapsizebytes when the program defines it.- File descriptors 0 and 1 are GEMDOS handles 0 and 1; fd 2 is the
console device (handle -1), since GEMDOS handle 2 is the serial port.
Writing
\nto a character device writes\r\n, and a\rread from one becomes\n. - Files:
open,read,write,lseek,close,stat,fstat,unlink,rename(which replaces an existing file, as in POSIX),mkdir,rmdir,chdir(with a drive letter, it also changes the drive),getcwd,access,isatty,dup,dup2./in paths is taken as\. Errors becomeerrnovalues. - Time: GEMDOS local time, taken as UTC, with the 200 Hz timer for the
fraction of a second and for
CLOCK_MONOTONIC,timesandnanosleep. - Signals are those of the fallback library:
raiseworks.