EINSTEIN SILICON DISC The Einstein silicon disc consists of 256K of RAM, arranged as 2048 sectors of 128 bytes each. The RAM is port-mapped and thus is not directly accessible as program memory. The input/output ports used by the silicon disc are given below. Port Use XXF8H Output low byte of sector number XXF9H Output high byte of sector number NNFAH Input or output data byte [NN = 00H-7FH, XX = irrelevant.] Before reading or writing data, it is necessary to specify which sector is being accessed by outputting the sector number, e.g LD DE,0 Select sector 0 LD C,F8H OUT (C),E Output sector no. low INC C OUT (C),D Output sector no. high [The order of outputting the sector number is irrelevant.] When reading or writing data, address lines A8-A14 are used to specify one of the 128 bytes in the sector. Given below are read sector and write sector routines that are essentially identical to those in the silicon disc ROM. Both routines assume the sector number has already been output. READ: LD HL,BUFF HL -> sector buffer LD BC,7FFAH INIR Read first 127 bytes INI Read last byte RET WRITE: LD HL,BUFF HL -> sector buffer LD BC,80FAH OTIR Write 128 bytes RET The following points should be noted. The value in register B is used both to define the byte within the sector and as a counter. The OUTI and OTIR instructions decrement the value in register B before placing it on A8-A15, whereas the INI and INIR do not. Thus, the first byte in the sector is accessed using port 7FFAH and the last byte using port 00FAH. Although this is how the the silicon disc software operates, bytes may be read or written individually, and in any order, if desired. The silicon disc ROM patches the following MOS MCAL routines, so that the silicon disc may be accessed as drive 3. Number Name Description A2H ZRSECT 512-byte sector read A3H ZWSECT 512-byte sector write A4H ZRBLK Block 512-byte sector read A5H ZWBLK Block 512-byte sector write B6H ZSLDSC Select disc drive (DOS) BAH ZRD128 128-byte sector read (DOS) BBH ZWR128 128-byte sector write (DOS) A description of the changes to each MCAL routine is given below. ZRSECT If byte at FB50H (HSTDSC) = 3, then read 512-byte sector from silicon disc, else do normal read. ZWSECT If byte at FB50H (HSTDSC) = 3, then write 512-byte sector to silicon disc, else do normal write. ZRBLK If value in register A = 3, then read block of 512-byte sectors from silicon disc, else do normal block read. ZWBLK If value in register A = 3, then write block of 512-byte sectors to silicon disc, else do normal block write. ZSLDSC This is the DOS select disc routine kept in ROM for convenience. The changes to this routine are explained later. ZRD128 This is the DOS sector read routine kept in ROM for convenience. If byte at FB7DH (DISC) = 3, then read 128-byte sector from silicon disc, else do normal read. ZWR128 This is the DOS sector write routine kept in ROM for convenience. If byte at FB7DH (DISC) = 3, then write 128-byte sector to silicon disc, else do normal write. Provision has been made in the silicon disc ROM for logical (DOS) disc drive to physical (MOS) disc drive mapping. The routine that accomplishes this is the patched DOS drive select routine ZSLDSC. This routine uses a special silicon disc variable at address FDFFH to determine which physical drive corresponds to which logical drive. This variable is interpreted in the following way Bits 0,1 give physical drive number for logical drive 0 Bits 2,3 give physical drive number for logical drive 1 Bits 4,5 give physical drive number for logical drive 2 Bits 6,7 give physical drive number for logical drive 3 The default value is E4H or 11100100B, which gives a logical-to- physical mapping of 0-0, 1-1, 2-2 and 3-3. The main reason for having disc drive mapping is so that the silicon disc can be configured as drive 0 when using the DOS, making programs which refer to drive 0 when loading, for example, do so much more quickly. [Note that the silicon disc is always drive 3 when using the MOS. To make the silicon disc any other MOS drive requires a silicon disc ROM alteration.] The following code makes the silicon disc act as logical drive 0, physical drive 0 act as logical drive 1, physical drive 1 act as logical drive 2 and physical drive 2 act as logical drive 3. Alternatively, the MOS 'M' command could be used. LD A,93H LD (FDFFH),A Logical-to-physical drive mapping is purely a software feature operating within the DOS and requires no hardware changes to any floppy disc drive. When the silicon disc is logical drive 0, it may be found that physical drive 0 is accessed when a program is loaded or exited. This is because the DOS warm-boot routine loads the DOS from MOS (physical) drive 0, then selects DOS (logical) drive 0. The solution is to patch the DOS warm-boot routine to load the DOS from the silicon disc, after copying the DOS onto the silicon disc. Code that copies the DOS from the system tracks of physical drive 0 to the silicon disc is given overleaf. The MOS 'R' and 'W' commands may be used instead. LD BC,0 Track 0, sector 0 LD DE,5A00H End address for DOS LD HL,4000H Start address for DOS PUSH BC PUSH DE PUSH HL XOR A Physical drive 0 RST 8 DB A4H Read block POP HL POP DE POP BC LD A,3 Physical drive 3 RST 8 DB A5H Write block The code in the warm-boot routine for DOS version 1.31 that loads the DOS from disc is given below. 0000H: JP FA03H Jump to BIOS warm-boot jump FA03H: JP FAC9H Jump to warm-boot routine FAC9H: LD SP,0100H Reset stack LD HL,E100H Start address for DOS to load LD DE,EC00H End address for DOS to load XOR A Physical drive 0 LD B,A Start at sector 0 LD C,A Start at track 0 RST 8 FAD6H: DB A4H Load DOS (MCAL routine ZRBLK) The silicon disc ROM contains a new MCAL routine, function number FFH, that simply calls ZRBLK after loading register A with the value 3. Therefore, to load the DOS from silicon disc, it is only necessary to change the MCAL number A4H to FFH. The following code patches DOS version 1.31. The MOS 'M' command could be used if wished. LD A,FFH LD (FAD6H),A Note that the address of the warm-boot routine and the start and end addresses for the DOS to load will vary from one version of the DOS to another. Overleaf is a program that patches the warm- boot routine which works for all DOS versions. It also copies the DOS from physical drive 0 to the silicon disc, which it then makes logical drive 0. The program is relocatable and should be executed from drive 0. If the program is run from the silicon disc, an error will occur when the program warm-boots, since logical drive 3 has been mapped to physical drive 2, unless physical drive 2 is present. Firstly, copy DOS. LD BC,0 LD DE,5A00H LD HL,4000H PUSH BC PUSH DE PUSH HL XOR A RST 8 DB A4H Read DOS from physical drive 0 POP HL POP DE POP BC LD A,3 RST 8 DB A5H Write DOS to silicon disc Now patch warm-boot routine. LD HL,(0001H) HL -> BIOS warm-boot jump INC HL Skip 'JP' LD E,(HL) INC HL LD D,(HL) DE -> warm-boot routine EX DE,HL HL -> warm-boot routine LD BC,0 LD A,CFH CPIR Search for 'RST 8' LD (HL),0FFH Change A4H to FFH Finally, make silicon disc logical drive 0. LD A,93H LD (FDFFH),A RST 0 A hex dump for this program is given below. 01 00 00 11 00 5A 21 00 40 C5 D5 E5 AF CF A4 E1 D1 C1 3E 03 CF A5 2A 01 00 23 5E 23 56 EB 01 00 00 3E CF ED B1 36 FF 3E 93 32 FF FD C7 The above program can easily be made into a .COM file by loading the hexadecimal values from address 0100H onwards using the MOS 'M' command and then saving on disc using the DOS 'SAVE' command. As mentioned earlier, the silicon disc consists of 2048 sectors of 128 bytes each, the DOS sector size. The MOS sector size is 512 bytes, so there are four DOS sectors for every one MOS sector. Both DOS and MOS have the same number of bytes per track (5K), comprising 40 DOS sectors per track or 10 MOS sectors per track. The relationship between silicon disc number and DOS and MOS track and sector numbers as used in the silicon disc ROM is given below. Sector DOS MOS number Track Sector Track Sector 0 0 0 0 0 (1st 128 bytes) 1 0 1 0 0 (2nd 128 bytes) 2 0 2 0 0 (3rd 128 bytes) 3 0 3 0 0 (4th 128 bytes) 4 0 4 0 1 (1st 128 bytes) . . . . . . . . . . 39 0 39 0 9 (4th 128 bytes) 40 1 0 1 0 (1st 128 bytes) . . . . . . . . . . 2047 51 7 51 1 (4th 128 bytes) Below is a routine that outputs the sector number of a particular DOS sector and track, given by the values in registers D and E respectively. Sector and track values are assumed to be valid. LD L,E LD H,0 HL = track ADD HL,HL HL = track * 2 ADD HL,HL HL = track * 4 ADD HL,HL HL = track * 8 LD B,H LD C,L BC = track * 8 ADD HL,HL HL = track * 16 ADD HL,HL HL = track * 32 ADD HL,BC HL = track * 40 LD C,D LD B,0 BC = sector ADD HL,BC HL = track * 40 + sector LD A,L OUT (F8H),A Output sector number low LD A,H OUT (F9H),A Output sector number high RET The above code can easily be modified for MOS sectors by left shifting the MOS sector number twice before entering the routine. Any of the MCAL disc read or write routines mentioned earlier (ZRSECT,ZWSECT,ZRBLK,ZWBLK,ZRD128,ZWR128) may be used to transfer data to or from the silicon disc. It is not necessary to call the select disc drive routine (ZSLDSC) beforehand since the silicon disc is not physically 'selected'. * * * When the Einstein is first switched on with the silicon disc connected, the silicon disc is formatted by filling every sector with E5H. When the Einstein is thereafter reset, the silicon disc ROM reads the last sector (512 bytes) on track 1 and, provided every byte is E5H, it assumes that the silicon disc is already formatted. Therefore, this track is reserved and data should not be written to it. * * * The current version of the silicon disc software (version 1.1) uses only 1.5K of the available 8K in the EPROM. The size of the DOS is exactly 6.5K, so it is possible in theory to include the DOS in the silicon disc EPROM. Alternatively, the silicon disc routines could be merged with other routines into one EPROM (upto a maximum of 16K) to fit into the one spare ROM socket inside the Einstein. * * * The silicon disc patches only those MCAL routines needed by the silicon disc but could patch ALL of the MCAL routines and create new ones. The spare bytes in the EPROM might be used to hold these new or modified routines. * * * Copyright (c) Tony Brewer 1986.