trshard

Radio Shack TRS-80 Model 1/3/4

Lotech IDE Driver for LDOS/LS-DOS

Table Of Contents

Update History

Introduction

TRSHARD is an alternate lotech IDE driver for the TRS-80 Models 1&3 and LDOS (5.3.1) and for the TRS-80 Model 4 and LS-DOS (6.3.1). TRSHARD is derived from the XTRSHARD emulated hard disk driver for the xtrs/sdltrs emulators. The primary difference between TRSHARD and other lotech LDOS/LS-DOS drivers is it uses LBA mode instead of CHS mode which has a number of benefits that will become apparent. If you have used XTRSHARD then using TRSHARD will be a familiar experience but there are some differences. The name was changed from XTRSHARD to TRSHARD simply to avoid confusion between the two.

NOTE: The lotech adapter supports two different ranges of IO addresses which is jumper selectable between 40h-47h (J1 on) and C8h-CFh (J1 off). As distributed TRSHARD uses C8h-CFh (J1 off). If you prefer to use 40h-47h then you will have to re-assemble the driver (which is easy - see Building From Source below).

My preferred media is Compact Flash (CF) so throughout this tutorial I refer to the physical media as CF but it equally applies to IDE drives or Disk On Module (DOM).

Basic Setup

First download the driver here. The same driver is used with LDOS for the Model 1&3 and LS-DOS for the Model 4. Copy the file TRSHARD/DCT to an LDOS/LS-DOS boot floppy. Attach a spare CF (or IDE drive or DOM) of at least 32Mbyte to your lotech adapter (you can use a smaller CF but will have to specify fewer cylinders below). DO NOT use media with contents that you care about! Make sure J1 is off to select the C8h-CFh IO address range.

NOTE: TRSHARD will not work in an emulator - unless the emulator happens to also emulate an IDE device, which none currently do. For this tutorial the screenshots were captured using a version of the xtrs emulator which I modified to emulate the lotech IDE in LBA mode.

Power the lotech and boot your TRS-80 using the boot disk which contains the TRSHARD/DCT driver. Install the driver by executing the command:

system (drive=6,driver="trshard")

You can just hit Enter to accept the defaults. Use the defaults for unit number (0), cylinders (202) (unless using a CF smaller than 32Mbyte - use 101 for a 16Mbyte CF, etc), and master/slave (M). For a single emulated drive the starting LBA is somewhat arbitrary so just use 2048.

The Ending LBA is computed (based on the starting LBA and the number of cylinders) and reported - it's not important for this example.

Unlike other hard disk drivers (X)TRSHARD doesn't check the disk when the driver is installed to see if it is formatted so there is no message regarding the format status of the disk. In this case we know it isn't formatted so we can simply format it:

format :6

Give it a name such as 'trshard' and master password such as 'password'. Reply 'y' to the subsequent prompts. Unlike other hard disk formatters format does not low-level format the disk - it simply initializes the system and directory information so it is very fast.

Note that by default format will place the directory in the middle of the disk - at cylinder 101 for this 202 cylinder example. However there is a small bug in the format command - the display of the directory cylinder assumes the number is at most two digits so '101' is displayed as ':1' which looks like 1 but it is not, it is 101.

Do a dir to see the newly created empty drive.

If that all looks good then copy LDOS/LS-DOS to the hard disk with backup, then you can make the hard disk the system disk:

backup :0 :6 (inv,sys)

system (system=6)

Hopefully that all worked. If the TRS-80 locks up during the format then verify that JP1 is off (that is the first time that the driver actually tries to talk to the hardware).

Working With Multiple Drives

Most other hard disk drivers create multiple drives by partitioning a single disk. TRSHARD like XTRSHARD instead uses a separate disk for each drive as specified by the Unit number durng driver installation. Setting up multiple disks just requires installing the driver for each disk and specifying a different Unit number for each and using non-overlapping Start-End LBA groups.

A single large CF card can hold many disk images. The TRSHARD driver uses 24 bits for the LBA so the driver can fully utilize up to a 2^24*512 byte CF card which is 8 Gbyte. A maximum size LDOS/LS-DOS hard drive (202 cylinders) is 12,928 kbyte and occupies 25,856.5 kbyte on the CF card (see Computing Size Of Disk Images), so an 8 Gbyte CF can hold 324 maximum size disk images. Users of lotech IDE adapters should already know that half of the CF storage is wasted for both hardware and software convenience so only half of the 8 Gbyte would actually be used.

There are two recommended ways for choosing the starting LBA's. The simple way is to just place them one after another. For example, in the above example the Ending LBA was 53760 so the next disk could start at LBA 53761:

The next disk could then start at LBA 105474. And so on.

The second way is to first partition the CF card and then place the disk images in the partitions. This makes is more convenient when copying the disk images from/to the CF with a (Linux) PC. Since partitions can only start on certain LBA boundaries the CF is first partitioned to determine the partition starting LBA's and then they are used for the Starting LBA's during the driver installation. This is discussed later in more detail.

In either case though you will want to record the cylinder counts and the Starting LBA's so that they can be re-entered when re-installing the driver.

In the following example Starting LBA's will be used that were obtained with the patritioning approach. The CF doesn't have to be partitioned to do this but it does result in gaps between the disk images. (The CF can actully be partitioned later if desired.)

This is an example of a typical setup with two floppy drives and six hard disks. The first disk image (unit 0) is first installed as drive :6, formatted, then LDOS/LS-DOS copied to it and made the system disk (swapped with drive :0). Then the next disk image (unit 1) is installed as drive :7, formatted, then swapped with drive :1. Then disk images 2-5 (units 2-5) are installed as drives :2-:5, and formatted. Finally the configuration is sysgen'ed to save the configuration to the boot floppy.

The driver download includes a do file (TRSHARD/JCL) that will configure the hard disks this way but does NOT do the formatting and other steps.

system (drive=6,driver="trshard")

(Unit = 0, Starting LBA = 4096)

format :6

(Name = lsdos631 or ldos-531)

backup :6 :0 (inv,sys)

system (system=6)

system (drive=7,driver="trshard")

(Unit = 1, Starting LBA = 59392)

format :7

(Name = disk1)

system (drive=1,swap=7)

system (drive=2,disable,driver="trshard")

(Unit = 2, Starting LBA = 114688)

format :2

(Name = disk2)

system (drive=3,disable,driver="trshard")

(Unit = 3, Starting LBA = 169984)

format :3

(Name = disk3)

system (drive=4,driver="trshard")

(Unit = 4, Starting LBA = 225280)

format :4

(Name = disk4)

system (drive=5,driver="trshard")

(Unit = 5, Starting LBA = 280576)

format :5

(Name = disk5)

sysgen (drive=6)

or (for LDOS)

system (drive=6,sysgen)

You can list the drives with the devices command:

The steps which swaps the drives and makes the first disk image the system drive and the sysgen are not required and depend on how you plan to use your system.

Additional disks can be created and used to replace another disk when needed. For example, suppose a DISK6 had been previously created and formatted with 202 cylinders and starting LBA of 335872. Then it can be swapped into drive :2 with the command:

system (drive=2,disable,driver="trshard")

(Unit = 2, Starting LBA = 335872)

As another example, a single CF could contain disk images for both LS-DOS and LDOS with different starting LBA's - the disk images are just installed using these starting LBA's in their respective OS's. Then on a Model 4, to boot into either LS-DOS or LDOS the CF card would not have to be changed - you just have to boot with either a LS-DOS or LDOS floppy which has been correspondingly sysgen'ed.

Computing Size Of Disk Images

Each disk images contains 1 block for the virtual disk header plus 256 blocks per cylinder so the total size in blocks is:

BLOCKS = 1 + 256*CYLINDERS

The capacity of the hard drive is:

CAPACITY(bytes) = 256*256*CYLINDERS = 256*(BLOCKS - 1)

The -1 is because the header isn't used for data storage (it's not used by TRSHARD at all). The actual space occupied on the CF card is 2*CAPACITY since the lotech adapter wastes half of the space.

The Ending LBA is:

EndingLBA = StartingLBA + BLOCKS - 1

Note that this -1 should not be confused with the header - it is simply a consequence of the formula 'end=start+size-1'.

Examining Drive Parameters

The Drive Control Table (DCT) is used by L(S)DOS to store drive parameters. The Misosys C (MC) compiler includes an example program DCT/CCC which prints the DCT's which is a handy utility. However, the DCT's don't have enough room to store the starting LBA's used by TRSHARD so they are actually stored in the driver itself. The driver download includes a modified version of this program which prints the Master/Slave setting and starting LBA value for drives which use the TRSHARD driver. Also, the usage of some fields in the DCT are driver dependent for hard disks so DCT's for TRSHARD (and XTRSHARD and TRSDW) weren't decoded quite right so it is modified for these drivers.

The original behavior is to print all 8 DCT's. The modified version allows you specify a list of drives on the command line - if omitted it defaults to the original behavior of printing all 8 DCT's. The drive numbers can be specified as with or without a leading: (:0-:7 or 0-7).

DCT5/CMD is the LDOS version and DCT6/CMD is the LS-DOS version. Copy the appropriate one to DCT/CMD then the command syntax is:

DCT :drive :drive ...

Below is example of the output:

Transferring Disk Images To/From PC Emulator

Coming soon!

Using Master/Slave Devices

There is nothing particularly special about working with both Master and Slave devices. If using a single device it should be a Master. Just enter 'S' at the Master/Slave prompt during the driver installation for drives to be placed on the Slave device. The only caveat is that some CF cards don't work either as a Slave or as Master with a Slave so if you test your cards and they don't work try some different ones. By 'not working' I mean the TRSHARD driver will hang when when trying to access the CF card. Most seem to work but some definitely do not.

Note that the Start/End LBA mappings for the Slave device can overlap those for the Master since they are physically different devices. Also, a CF card prepared as a Slave can later be used as a Master and vice versa (assuming that the CF cards themselves actually will work that way).

It is difficult to find CF/IDE adapters similar to the one pictured above which accommodate two CF cards - the ones that do will have a second connector on the back but I haven't been able to find one.

However, this style of adapter

is readily available and jumper selectable as Master or Slave - just connect two to your lotech adapter using a standard IDE cable as shown.

Note that devices will display Master devices as 0-7 and Slave devices as 0-9,A-F (hexadecimal). Below is an example which shows drive :0 installed with disk 0 on the Master device and drive :1 installed as disk 7 on the Slave device:

Don't confuse the drive numbers :0-:7 with the disk numbers 0-7. Each drive :0-:7 in L(S)DOS is mapped to a physical disk 0-7. Each disk 0-7 is mapped by TRSHARD to an LBA range on the Master or Slave device. In this example the drive numbers and disk numbers just happen to be the same.

Working With Cylinder Partitioned Disk Images

Coming soon!

Building From Source

The TRSHARD source TRSHARD/ASM is included with the driver download. To build from the source just use the Z80 assembler from Matthew Reed. Assemble with the following commands:

z80asm.exe TRSHARD.ASM

ren TRSHARD.cmd TRSHARD.DCT

Then copy the TRSHARD.DCT file to a real floppy or emulated floppy/disk for use on your TRS-80.

To change the I/O address, change the equate around line 83 and rebuild:

; The lotech IDE is jumper selectable for IO addresses 40h-48h or C8h-CFh

;data equ 040h ;Data transfer port

data equ 0c8h ;Data transfer port