Topic : The ATARI Compendium
Author : Scott Sanders / JAY Software
Version : 1.25 (20/6/2003)
Subject : Documentation
Nodes : 1117
Index Size : 32614
HCP-Version : 6
Compiled on : Atari
@charset : UTF-8
@lang : en
@default :
@help : %About
@options : +g -i -t4 +y +z
@width : 100
View Ref-FileDisk FunctionsBoot SectorsBoth floppy disks and hard disks share a similar format for boot sectors
as follows:
Name Offset Contents
BRA 0x0000 This WORD contains a 680x0 BRA.S instruction to the
boot code in this sector if the disk is executable,
otherwise it is unused.
OEM 0x0002 These six bytes are reserved for use as any necessary
filler information. The disk-based TOS loader program
places the string 'Loader' here.
SERIAL 0x0008 The low 24-bits of this LONG represent a unique disk
serial number.
BPS 0x000B This is an Intel format WORD (low byte first) which
indicates the number of bytes per sector on the disk.
SPC 0x000D This is a BYTE which indicates the number of sectors
per cluster on the disk.
RES 0x000E This is an Intel format WORD which indicates the number
of reserved sectors at the beginning of the media
(usually one for floppies).
NFATS 0x0010 This is a BYTE indicating the number of File Allocation
Table's (FAT's) on the disk.
NDIRS 0x0011 This is an Intel format WORD indicating the number of
ROOT directory entries.
NSECTS 0x0013 This is an Intel format WORD indicating the number of
sectors on the disk (including those reserved).
MEDIA 0x0015 This BYTE is a media descriptor. Hard disks set this
value to 0xF8, otherwise it is unused.
SPF 0x0016 This is an Intel format WORD indicating the number of
sectors per FAT.
SPT 0x0018 This is an Intel format WORD indicating the number of
sectors per track.
NSIDES 0x001A This is an Intel format WORD indicating the number of
sides on the disk.
NHID 0x001C This is an Intel format WORD indicating the number of
hidden sectors on a disk (currently ignored).
BOOTCODE 0x001E This area is used by any executable boot code. The code
must be completely relocatable as its loaded position in
memory is not guaranteed.
CHECKSUM 0x01FE The entire boot sector WORD summed with this Motorola
format WORD will equal 0x1234 if the boot sector is
executable or some other value if not.
The boot sector may be found on side 0, track 0, sector 1 of each
physical disk.
The Floppy DriveThe XBIOS provides several functions used for reading, writing,
verifying, and formatting sectors on the hard disk.
Floprd() and Flopwr() read and write from the floppy drive at the sector
level rather than the file level. For example, these functions could be
used to create executable boot sectors on a floppy disk. Flopver() can be
used to verify written sectors against data still in memory.
Formatting a floppy disk is accomplished with flopfmt(). After a floppy
is completely formatted use the function Protobt() to create a prototype
boot sector (as shown above) which can then be written to sector #1 to
make the disk usable by TOS.
ASCI and SCSI DMAThe functions DMAread() and DMAwrite() were added as of TOS 2.00. These
functions provide a method of accessing ACSI and SCSI devices at the
sector level.
ASCI accesses must not use alternate RAM as a transfer buffer because
they are performing DMA. The TT030 uses handshaking for SCSI so alternate
RAM transfers are safe. SCSI transfers on the Falcon030 do, however, use
DMA so alternate RAM must be avoided.
If you need to transfer data using these functions to an alternate RAM
buffer, use the special standard memory block pointed to by the cookie'_FRB' as an intermediary point between the two types of RAM. You must
also use the '_flock' system variable (at 0x43E) to lock out other
attempted uses of this buffer.
Each physical hard disk drive must contain a boot sector. The boot sector
for hard disk drives is the same as floppies except for the following
locations:
Name Offset Contents
hd_siz 0x01C2 This is a Motorola format LONG that indicates the
number of physical 512-byte sectors on the device.
Partition 0x01C6 This section contains a 12 BYTE partition information
Header #0 block for the first logical partition.
Partition 0x01D2 This section contains a 12 BYTE partition information
Header #1 block for the second logical partition.
Partition 0x1DE This section contains a 12 BYTE partition information
Header #2 block for the third logical partition.
Partition 0x1EA This section contains a 12 BYTE partition information
Header #3 block for the fourth logical partition.
bst_st 0x1F6 This is a Motorola format LONG that indicates the
sector offset to the bad sector list (from the
beginning of the physical disk).
bst_cnt 0x01FA This is a Motorola format LONG that indicates the
number of 512-byte sectors reserved for the bad sector
list.
The partition information block is defined as follows:
Name Offset Contents
p_flg 0x00 This is a BYTE size bit field indicating the partition state.
If bit 0 is set, the partition exists, otherwise it does not.
If bit 7 is set, the partition is bootable, otherwise it is
not. Bits 1-6 are unused.
p_id 0x01 This is a three BYTE field that indicates the partition
type as follows: Contents Meaning
'GEM' Regular Partition (<16MB)
'BGM' Big Partition (>=16MB)
'XGM' Extended Partition
p_st 0x04 This is a Motorola format LONG that indicates the start of
the partition as an offset specified in 512-byte sectors.
p_size 0x08 This is a Motorola format LONG that indicates the size of
the partition in 512-byte sectors.
A hard disk may have up to four standard (GEM or BGM) partitions or three
standard and one extended (XGM) partition. The first partition of a hard disk
must be a standard one.
Extended PartitionsThe first sector of an extended partition contains a standard boot sector
with hard disk information except that the hd_siz, bst_st, and bst_cnt fields
are unused. At least one, but no more than two (not necessarily the first
two), partition headers are used. The first partition header is the same as
described above except that p_st describes the offset from the beginning of
the extended partition rather than the beginning of the physical disk.
If another partition needs to be linked, the second partition block should
contain 'XGM' in its p_id field and an offset to the next extended partition
in p_st.
The Bad Sector ListThe bad sector list is a group of three-byte entries describing which
physical sectors on the hard disk are unusable. The first three-byte entry
contains the number of bad sectors recorded. The second three-byte entry
is a checksum and when added to the entire bad sector list bytewise should
cause the list to BYTE sum to 0xA5. If this is not the case then the bad
sector list is considered bad itself.