DCB Layout
DCT Layout
Disk Layout
Dir Layout
GAT Layout
HIT Layout
Disk I/O Table

LDOS 5.1.x Internals

LDOS Device Control Blocks (DCB)

The Device Control Block, or DCB, is used to interface with all the various devices in LDOS. This includes the keyboard, video display, printer and communications port. Each DCB is six bytes long, and has the following layout:

Byte 0 - DCB Type

  • Bit 7 - If set, the DCB is really a file control block (FCB) with the file in an OPEN state. Used for I/O redirection.
  • Bit 5 and 6 - Reserved
  • Bit 4 - If set, the device is ROUTEd to another device
  • Bit 3 - If set, the device is set to NIL. Output is discarded and input returns zero.
  • Bit 2 - If set, the device supports the @CTL system call
  • Bit 1 - If set, the device supports the @PUT system call
  • Bit 0 - If set, the device supports the @GET system call

Byte 1 - Low order driver address

This byte contains the low byte of the driver routine that services this device.

Byte 2 - High order driver address

This byte contains the high byte of the driver routine that services this device.

Bytes 3-5 - Variable storage

These three bytes are for the driver routine to use as variable storage. It is up to the driver to define their use.

The system stores DCBs at the following addresses:

Address    Assignment
--------   -----------------------
4015h      *KI - Keyboard
401Dh      *DO - Video
4025h      *PR - Printer
42C2h      *JL - Job Log
42C8h      *SI - Standard input
42CEh      *SO - Standard output
42D4h            Spare #1
42DAh            Spare #2
42E0h            Spare #3
42E6h            Spare #4

The two character device names for each of the ten available devices are stored in the 20 byte block of memory at 42ECh.


LDOS Drive Control Table (DCT)

The drive control table (DCT) is what LDOS uses to interface with disk drives. The DCT contains the memory variables LDOS needs in order to determine the disk's geometry as well as the address of the driver routine that services requests to the drive.

The DCT contains eight entries, one for each of the drives :0 to :7. In a floppy disk system, only the first four will be used.

DCT+0  Three byte jump vector to the driver.  If this contains
       0C9h (a Z-80 RET instruction) then the drive is disabled.

DCT+1  Two byte address of the driver

DCT+3  Drive specifications
       Bit 7 - 1 if the drive is software write protected.
           6 - 1 for double density.  0 for single density.
           5 - 1 for 8 inch drives.  0 for 5 1/4 inch.
           4 - 1 if using the second side of the disk at the time.
           3 - 1 for hard disk.  0 for floppy disk.
           2 - Start delay - 0 = 1 second  1 = 0.5 second.
         1-0 - Step rate.  00 = 6ms   01 = 12ms
                           10 = 20ms  11 = 30ms

DCT+4  Additional drive specifications
       Bit 7 - Reserved.
           6 - 1 if controller is capable of double density.
           5 - 1 for double sided operation if floppy disk.
               If this is a hard disk entry, this bit means
               that the cylinder counts stored in the DCT
               entry are half the physical number of cylinders.
           4 - 1 indicates a non-standard disk controller.
         3-0 - Physical drive address by bit.  1, 2, 4, or 8.
               Only one bit may be set.  If the non-standard
               bit is set, these 4 bits indicate the starting
               head number.

DCT+5  Current cylinder position of the drive

DCT+6  Highest numbered cylinder of the drive.

DCT+7  Allocation information
       Bit 7-5 - Number of heads for a hard disk.
           4-0 - Highest numbered sector relative to 0.  If
                 DCT+4 bit 5 is 1, the sectors per cylinder
                 is actually twice this number.

DCT+8  Additional allocation information
       Bit 7-5 - Number of granules per track.  If DCT+4 bit 5
                 is 1, this is half the actual granules per
           4-0 - Number of sectors per granule.

DCT+9  Directory location.  This byte is looked at first when
       looking for the directory of a disk.  If the read fails
       then the disks boot sector is examined for the proper
       value and this entry is updated.

It is important that the entries at DCT+6 through DCT+8 all relate without conflicts. This information is used by LDOS to properly position the drive's heads.


LDOS Diskette Layout

The layout of an LDOS diskette or hard disk partition is as follows: The first sector of the first track is reserved for the boot sector. The third byte of the boot sector is used to indicate the location of the directory track, which is normally in the center of the disk. The directory track consists of one GAT sector, one HIT sector, and the remaining sectors are allocated to directory records.

Though not to scale, since it only shows six sectors on each track, the following table illustrates the disk layout. The general idea is the same for any size LDOS diskette or hard disk partition.

Key:  (B) = Boot Sector
      (x) = Data Sector
      (G) = Granule Allocation Table
      (H) = Hash Index Table
      (D) = Directory Sector

Trk Sector Sector Sector Sector Sector Sector Sector Sector
Num 012345 012345 012345 012345 012345 012345 012345 012345
--- ------ ------ ------ ------ ------ ------ ------ ------
 0  Bxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx
 8  xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx
16  xxxxxx xxxxxx xxxxxx xxxxxx GHDDDD xxxxxx xxxxxx xxxxxx
24  xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx
32  xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx


LDOS Directory Records (DIRREC)

The directory contains all the information needed to access files on an LDOS disk. The directory track contains one Granule Allocation Table (GAT), one Hash Index Table (HIT) and up to 32 sectors of directory records. The number of directory records is limited by the physical layout of the HIT. On a double sided double density floppy disk, which has 36 sectors available, the last two sectors of the second side will not be used.

Each directory record is 32 bytes long, giving eight entries per sector. This makes the number of files that can be placed on a disk dependent on the size of the disk. The following table summarizes the number of entries available based on disk size. The number of files available will be reduced by 16 to account for the directory entries reserved for use by the operating system files. On non-bootable data disks, the number of available files is only two less than the total.

 Disk           # of   Secs/  Dir   Total  Avail
 Size  Density  sides  cyl    Secs  Files  Files
-----  -------  -----  -----  ----  -----  -----
  5     Single     1     10     8     64     48
  5     Single     2     20    18    144    128
  5     Double     1     18    16    128    112
  5     Double     2     36    32    256    240
  5     Hard            128    32    256    240
  8     Single     1     16    14    112     96
  8     Single     2     32    30    240    224
  8     Double     1     30    28    224    208
  8     Double     2     60    32    256    240
  8     Hard            256    32    256    240

LDOS is upward compatible with other operating systems that are TRSDOS 2.3 compatible. Each record contains space for up to four extents (contiguous granules of disk allocation). If a file requires more than four extents, an additional directory record is allocated to the file. In order to distinguish between primary and secondary entries, a bit in the directory record is used. The following table documents the layout of the LDOS directory records.

DIR+0     This byte contains the attributes of the file.

    Bit 7 - 0 = primary DIRREC  1 = secondard DIRREC
        6 - 0 = user file  1 = system file
        5 - Reserved
        4 - 0 = record unused  1 = record in use
        3 - 0 = file is visible  1 = file is invisible
      2-0 - File protection level.
            000 = Full access to the file
            001 - All but change attributes
            010 - Rename, write, read, execute
            011 - unused
            100 - Write, read, execute
            101 - Read, execute
            110 - Execute only
            111 - No access to the file

DIR+1     Various flags and month of modification

DIR+2     Remaining date of modification flags

DIR+3     End of file offset

DIR+4     Logical Record Length

DIR+5-12  File name, padded with blanks

DIR+13-15 File extension, padded with blanks

DIR+16-17 Update password hash code

DIR+18-19 Access password hash code

DIR+20-21 Ending record number.  Based on full sectors.

DIR+22-23 First file extent field.  The extent is laid out as:

     EXT+0 - One byte containing the cylinder the extent starts on.
     EXT+1 - Bits 0-4 contain the number of contiguous granules.
     EXT+1 - Bits 7-5 contain the starting granule on the cylinder.

DIR+24-25 Second file extent field.

DIR+26-27 Third file extent field.

DIR+28-29 Fourth file extent field.

DIR+30    If 0FFh then there is no link to an secondary directory
          record.  If 0FEh, then there is a link to a FXDE.

DIR+31    If a secondary entry is in use, this contains the 
          directory entry code (DEC) of the entry.  This DEC
          is a pointer into the Hash Index Table.  See the
          information below about the HIT for more information.

LDOS Granule Allocation Table (GAT)

The granule allocation table contains information LDOS needs to determine the free space on a floppy or hard disk.

This section is still under construction


LDOS Hash Index Table (HIT)

This section is still under construction


LDOS Disk I/O Table

This section is still under construction



The TRS-80 Home Page created and maintained by Pete Cervasio

Copyright © 1998 Pete Cervasio