Datei: CALL-IDE.DOK     (18 Seiten)      5. Mrz im Jahre des CPC 2015


          Dokumentation aller FutureOS Routinen des IDE ROMs
          --------------------------------------------------

This file is a  documentation  of  FutureOS  system routines which are
located in the IDE-ROM. They're used for management of IDE devices and
the FAT32 file-system.
Hardware support is provided  for  the  following interfaces: IDE8255,
CPC-IDE, SYMBiFACE II and the X-MASS.
Some OS functions only work with CPC-IDE / SF2 / X-MASS OR IDE8255.
In this case the headline contains the remark (CPC-IDE) or (IDE8255).
All routines usable for the CPC-IDE  or  the  SF2 can also be used for
the X-MASS.


       Alle OS Funktionen werden in folgender Form beschrieben:

1. Kurzbeschreibung: In  einem  Satz  wird  kurz  die  Funktion der OS
Funktion beschrieben.

2. Label: Mit  diesem  Label  wird  die  OS  Funktion  im  Source Code
bezeichnet. In der mitgelieferten  Label-Bibliothek (siehe Datei #E.D)
mit den jehweils aktuellen ROM  Adressen findet ebenfalls dieses Label
Verwendung. Aus  Grnden  der  Kompatibilitt  sollte  man  in eigenen
Programmen alle OS- /  System-Funktionen  (und System-Variablen) stets
mit diesen Labels ansprechen.

3. ROM-Nummer: Hier ist die  logische  ROM  - Nummer des FutureOS ROMs
angegeben, in dem die entsprechende OS Funktion zu finden ist.
Manche Routinen kommen, wegen ihrer Krze,  in mehreren ROMs vor, dann
sind hier auch mehrere ROM Nummern angegeben.
Da die ROM Nummer logisch zu  verstehen  ist, sollte man sie nicht mit
dem physikalischen ROM Select gleichsetzen.  Wie man die physikalische
ROM Nummer eines der FutureOS ROMs ermittelt wird im Handbuch erklrt.

4. Startadresse: Gibt  die Einsprung-Adresse der OS Funktion an. Falls
diese in mehreren ROMs  vorkommt,  wird  hier  auch eine entsprechende
Anzahl von Adressen angegeben.

5. Einsprungbedingungen:  Die  Einsprungbedingungen  der  OS  Funktion
werden beschrieben und es wird sowohl auf Registerinhalte als auch auf
RAM-Variablen eingegangen.

6.  Aussprungbedingungen:  Die  Aussprungbedingungen  der  OS-Funktion
werden beschrieben und es wird sowohl auf Registerinhalte als auch auf
RAM-Variablen eingegangen.

7. Manipuliert: Es werden alle  manipulierten oder zerstrten Register
und RAM-Variablen  wiedergegeben.  Manchmal  werden  auch manipulierte
Pheripheriebausteine wiedergegeben.

8. Beschreibung: Es folgt  eine  vollstndige  Erklrung der Anwendung
und Wirkungsweise der beschriebenen OS Funktion.

9. Bitte Beachten: Es  werden  einige  wichtige  Details kurz erklrt.
Dies ist besonders wichtig,  da  alle  OS  Funktionen kompromilos auf
Hchstgeschwindigkeit  getrimmt worden  sind.  Bei falscher Handhabung
kann es zu Problemen mit der Systemstabilitt kommen.

Die aktuelle Version dieser Datei finden Sie auch im Internet unter:
FutureOS Homepage: http://www.FutureOS.de (-Links-Yahoo Group)

           TEST IF DEVICE IS CONNECTED (CPC-IDE)
           =====================================

Short description: This routine tests if a device (Master or Slave) is
connected or not.

Label: IDE_SMM

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register D decides if the Master-device or the
Slave-device should be tested:

D = &00 --> Test if MASTER is connected.
D = &10 --> Test if SLAVE is connected.

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device:

A = &00 and the Zero flag is set to 1: No error, device is connected!
A = &04 --> Device (Slave) is NOT connected.

Manipulated: AF, BC and the IDE device.

Description: This routine IDE_SMM  is  used  to  test  if a Master- or
Slave-device is connected to your IDE interface. Therefore is uses the
IDE command "Set Multiple Mode" (Code &C6).
Before calling the routine you have to  decide if you want to test the
Master (register D must containt value  &00)  or  the Slave (D = &10).
Then call IDE_SMM. The routine will return with the result in register
A. If A contains value &00  (the  Zero  flag  is  set to 1) the tested
device is connected to the IDE interface.  Else  if A = &04 the tested
device is NOT connected.
If you test the master without a  slave this can bring the result "Not
connected". This depends on your deviedes. So  test it ;-) This is NOT
a problem of the software, it's an IDE problem.

Attention: Try  to  experiment  with  this  routine  and  your special
hardware equippment before using it.























                SOFT RESET OF THE CPC-IDE CONTROLLER
                ====================================

Short description: Routine makes a soft  reset  of the CPC-IDE (or SF)
controller.

Label: IDE_SRS

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: -

Jump out conditions: CPC-IDE / Symbiface IDE controller reset.

Manipulated: AF, BC and the IDE-controller.

Description: This routine IDE_SRS makes  a  software reset of the CPC-
IDE controller of the IDE part of the Symbiface.

Attention: This routine is not usable for the IDE8255 interface.










































            EXECUTE DRIVE DIAGNOSTICS (CPC-IDE)
            ===================================

Short description: Routine executes the  drive diagnostics of the CPC-
IDE (Symbiface) interface.

Label: IDE_EXD

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: -

Jump out conditions: The Z80  processor  register  A reports about the
status of the CPC-IDE (or Symbiface) device, it contains the IDE error
register:

A = &01 --> The Master shows NO IDE error.
A = &03 --> The Master has an DAMAGED sector buffer.
A = &81 --> The Slave OR Master without connected Slave shows NO error
A = &83 --> The Slave OR Master without connected Slave has an DAMAGED
            sector buffer.

If the Zero Flag is set to "1", then NO error was found!

Manipulated: AF, BC and the CPC-IDE controller.

Description: This routine IDE_EXD initializes the IDE command code &90
"EXECUTE DIAGNOSTICS" using the CPC-IDE or Symbiface IDE interface.
No parameters must be  provided,  just  call  routine IDE_EXD. It will
return with the IDE Error Registe provided in Z80 register A. You must
take care if you have connected a Master, a Slave or both. If register
A contains value &01 or &81  then  the  IDE interface has NO error. If
register A contains  values  &03  or  &83  then  the  sector buffer is
damaged. Other values indicate  other  errors.  However you can simple
test the Zero flag for errors. If IDE_EXD returns with a set Zero Flag
"1", then NO error has been found in the IDE interface / devices.

Attention: Take care if you have connected a Master, a Slave or both.
























                TEST IF LBA IS POSSIBLE (CPC-IDE)
                =================================

Short description: Tests if  LBA  (Logical  Block Address) is possible
for a defined device.

Label: IDE_LBA

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register D decides if the Master-device or the
Slave-device should be tested:

D = &00 --> Test if MASTER can use LBA.
D = &10 --> Test if SLAVE can use LBA.

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device:

A = &00 and the Zero flag is set to 1: LBA is possible.

Manipulated: AF, BC, D and the CPC-IDE interface.

Description: This routine IDE_LBA investigates if a device can use the
LBA - Logical Block Address - method of data access. Therefore the IDE
command &F8 - "Read Native Max Address" is used.
You have to select Master of Slave  device  by value &00 or &00 in Z80
register D, then call routine  IDE_LBA.  The  routine returns with the
IDE Error register in Z80 register A. If A contains the value &00 (the
Zero flag is set to "1") LBA is possible. Else LBA is NOT possible.

Attention: Older IDE devices may not  be  able to use LBA mode. Please
don't use them.
For FutureOS you must use IDE devices capable of using LBA!




























                         IDENTIFY DRIVE (CPC-IDE)
                         ========================

Short description: Reads 512 bytes  drive identification data from IDE
device connected to CPC-IDE or Symbiface.

Label: IDE_IDD

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register D decides if the Master-device or the
Slave-device should be used:

D = &00 --> Use MASTER device.
D = &10 --> Use SLAVE device.

HL = Pointer to 512 bytes of free RAM. L must(!) be &00, HL = &XX00.

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device. If A = 0 and the Zero  flag is set to 1 all went well.
In this case:
HL points to 512 bytes of "Drive Identify Data", that have been read.

Manipulated: AF, BC, 512 bytes RAM beginning at HL and the IDE contr.

Description: The routine IDE_IDD is used  to  read 512 bytes of the so
called "Drive Identify Data" from an IDE device to the RAM of the CPC.
The source can be the IDE - Master (load register D with the value &00
before you call routine) or  the  IDE  Slave  (load D with value &10).
Further you have to load HL with the target address of 512 bytes data.
The format of the target address in HL must be &XX00.
When calling IDE_IDD the IDE command &EC "Identify Drive" is issued to
the CPC-IDE or Symbiface controller.
After the return of the routine  512  bytes "Drive Identify Data" have
been read to RAM (beginning at HL,  HL  was not changed). In this data
area you can get all needed information about the uses Master or Slave
device. But also test the IDE  error register provided in Z80 register
A. If A is set to &00 and the Zero flag is set to "1" then the command
went well. Else an error has occured!

Attention: When calling routine IDE_IDD,  the register HL must contain
the value &XX00, that means that register L MUST contain &00, else the
routine will cause errors.



















     READ 512 BYTES SECTOR FROM IDE DEVICE - LBA28 MODE (CPC-IDE)
     ============================================================

Short description: Reads a sector of  512  bytes  from an LBA (28 bit)
capable device.

Label: IDE_R28

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register A  decides  if routine reads from the
Master- or the Slave-device:

A = &00 --> Use MASTER device.
A = &10 --> Use SLAVE device.

The Z80 registers D, E, H and L contain the 28 bit LBA number:

E = LBA bits  7 -  0
D = LBA bits 15 -  8
L = LBA bits 23 - 16
H = LBA bits 27 - 24 (H has the format &0X)

HL' = 512 Byte target Buffer in RAM (&xx00), L must be &00

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device. If A = &00 and/or the Zero flag is set to "1" NO error
has occured.

Manipulated: AF, BC, AF', BC', HL' and 512 bytes of RAM.

Description: The routine IDE_R28  is  able  to  read  an sector of 512
bytes from an IDE device  connected  to  the CPC-IDE or Symbiface. The
LBA method with an LBA number of 28 bits is used (IDE command &20).
Before you call the routine IDE_R28  you  have to load register A with
the device number and registers D,  E,  H  and  L  with the 28 bit LBA
sector number. Further  the  register  HL'  must  point  to the target
address (space for 512 byte data).
When the routine returns register A is set to &00 and the Zero flag is
set if all went well. In case of an error register A contains the code
of the error (and the Zero flag is cleared to "0").

Attention: Investigate the IDE Error register (provided in Z80 reg.A).



















READ 512 BYTES SECTOR EXTENDED FROM IDE DEVICE - LBA48 MODE (CPC-IDE)
=====================================================================

Short description: Reads a sector of  512  bytes  from an LBA (48 bit)
capable device.

Label: IDE_R48

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register A selects device to read from:

A = &00 --> Use MASTER device.
A = &10 --> Use SLAVE device.

The Z80 registers D, E, H, L, D' and E' contain the 48 bit LBA number:

E = LBA bits  7 -  0
D = LBA bits 15 -  8
L = LBA bits 23 - 16
H = LBA bits 31 - 24
E'= LBA bits 39 - 32
D'= LBA bits 47 - 40

HL' = 512 Byte target Buffer in RAM (&xx00), L must be &00

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device. If A = &00 and/or the Zero flag is set to "1" NO error
has occured.

Manipulated: AF, BC, AF', BC', HL' and 512 bytes of RAM.

Description: The routine IDE_R48  is  able  to  read  an sector of 512
bytes from an IDE device  connected  to  the CPC-IDE or Symbiface. The
LBA method with an LBA number of 48 bits is used (IDE command &24).
Before you call the routine IDE_R48  you  have to load register A with
the device number and registers D, E, H,  L, D' and E' with the 48 bit
LBA sector number. Further the register  HL'  must point to the target
address (space for 512 byte data).
When the routine returns register A is set to &00 and the Zero flag is
set if all went well. In case of an error register A contains the code
of the error (and the Zero flag is cleared to "0").

Attention: Investigate the IDE Error register (provided in Z80 reg.A).


















     WRITE 512 BYTES SECTOR TO IDE DEVICE - LBA28 MODE (CPC-IDE)
     ===========================================================

Short description: Writes a sector  of  512  bytes  to an LBA (28 bit)
capable device.

Label: IDE_W28

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register A selects device to write:

A = &00 --> Use MASTER device.
A = &10 --> Use SLAVE device.

The Z80 registers D, E, H and L contain the 28 bit LBA number:

E = LBA bits  7 -  0
D = LBA bits 15 -  8
L = LBA bits 23 - 16
H = LBA bits 27 - 24 (H has the format &0X)

HL' = 512 Byte target Buffer in RAM (&xx00), L must be &00

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device. If A = &00 and/or the Zero flag is set to "1" NO error
has occured.

Manipulated: AF, BC, AF', BC', HL'.

Description: The routine IDE_W28 is  able  to  write  an sector of 512
bytes to an IDE device connected to  the CPC-IDE or Symbiface. The LBA
method with an LBA number of 28 bits is used (IDE command &30).
Before you call the routine IDE_W28  you  have to load register A with
the device number and registers D,  E,  H  and  L  with the 28 bit LBA
sector number. Further  the  register  HL'  must  point  to the source
address (source of 512 byte data).
When the routine returns register A is set to &00 and the Zero flag is
set if all went well. In case of an error register A contains the code
of the error (and the Zero flag is cleared to "0").

Attention: Investigate the IDE Error register (provided in Z80 reg.A).




















 WRITE 512 BYTES SECTOR EXTENDED TO IDE DEVICE - LBA48 MODE (CPC-IDE)
 ====================================================================

Short description: Writes a sector  of  512  bytes  to an LBA (48 bit)
capable device.

Label: IDE_W48

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register A selects device to read from:

A = &00 --> Use MASTER device.
A = &10 --> Use SLAVE device.

The Z80 registers D, E, H, L, D' and E' contain the 48 bit LBA number:

E = LBA bits  7 -  0
D = LBA bits 15 -  8
L = LBA bits 23 - 16
H = LBA bits 31 - 24
E'= LBA bits 39 - 32
D'= LBA bits 47 - 40

HL' = 512 Byte source buffer (&xx00), L must be &00

Jump out conditions: The Z80 register A contains the Error register of
the IDE-device. If A = &00 and/or the Zero flag is set to "1" NO error
has occured.

Manipulated: AF, BC, AF', BC', HL'.

Description: The routine IDE_W48 is  able  to  write  an sector of 512
bytes to an IDE device connected to  the CPC-IDE or Symbiface. The LBA
method with an LBA number of 48 bits is used (IDE command &34).
Before you call the routine IDE_W48  you  have to load register A with
the device number and registers D, E, H,  L, D' and E' with the 48 bit
LBA sector number. Further the register  HL'  must point to the source
address (source of 512 byte data).
When the routine returns register A is set to &00 and the Zero flag is
set if all went well. In case of an error register A contains the code
of the error (and the Zero flag is cleared to "0").

Attention: Investigate the IDE Error register (provided in Z80 reg.A).


















         INITIALIZE IDE RAM VARIABLES AND IDE CACHE
         ==========================================

Short description: This  routine  is  used  by  FutureOS to initialize
FutureOS system RAM variables dealing with  IDE  devices and the 16 KB
cache buffer. The user doesn't usually need this function.

Label: IDE_INIT

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: -

Jump out conditions: The Carry Flag reports about errors and success.
Carry Flag set ---------> Bad Error!
Carry Flag cleared -----> No Error, IDE system RAM variables and cache
                            have been initialized.

Manipulated: nearly all Z80 registers, system variables, cache.

Description: Routine IDE_INIT is  used  by  FutureOS when initializing
the OS and the IDE management. It does the following:
- Initialize system RAM variables dealing with IDE devices.
- Initialize IDE devices itself.
- Test IDE devices for errors.
- Declare an 16 KB expanson RAM as buffer and cache.
- Read Drive Identification of all IDE devices.
- Read Master Boot Sector of all IDE devices.
- Report about heavy, uncorrectable errors.

Normally you wouldn't need to use this routine.

Attention: This routine is called ONCE by the OS when initializing the
IDE management ROM.




























                            SELECT IDE DEVICE
                            =================

Short description: Selects an IDE device for reading or writing.

Label: SEL_IDE

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions: Z80 register A selects the device to be used:

A = &00 --> selects IDE8255 MASTER device.
A = &01 --> selects IDE8255 SLAVE device.
A = &02 --> selects CPC-IDE MASTER device.
A = &03 --> selects CPC-IDE SLAVE device.

Jump out conditions: The Zero Flag reports the success of selection.

Zero Flag cleared --> New IDE device is selected!
Zero Flag set ------> The desired IDE device is NOT usable!

Manipulated: AF, HL and system RAM variable IDE.

Description: The routine SEL_IDE is  used  to  select  one of the four
possible IDE devices for read  or  write  operations.  If you select a
device once, this device  is  selected  as  long  as  you don't select
another IDE device.
Just load Z80 register A  with  the  corresponding value (look before)
and call routine SEL_IDE to select the desired IDE device.
If the selected IDE device is  connected  and accessible then the Zero
flag is cleared when the routine  returns. But if SEL_IDE returns with
a set Zero flag, then something  went  wrong! Maybe the desired device
is not connected or reports an error.
Routine IDE-ROM writes the new selected  IDE  device in the system RAM
variable IDE. So you can look at  system RAM variable IDE which device
is actually selected for read- / write-operations. (Look file #D.).

Attention: Zero Flag reports success of the operation.

























=====================================

Short description:

Label:

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions:

Jump out conditions:

Manipulated:

Description:

Attention:













































=====================================

Short description:

Label:

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions:

Jump out conditions:

Manipulated:

Description:

Attention:













































=====================================

Short description:

Label:

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions:

Jump out conditions:

Manipulated:

Description:

Attention:













































=====================================

Short description:

Label:

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions:

Jump out conditions:

Manipulated:

Description:

Attention:













































=====================================

Short description:

Label:

ROM-number(s): IDE-ROM

Start addresses: &

Jump in conditions:

Jump out conditions:

Manipulated:

Description:

Attention:












































                           IDE E-RAM MEMORY MAP
                           ====================

The IDE management software uses one 16  KB block of the expansion RAM
as buffer for: Drive Identification Data,  the Master Boot Sector (LBA
Sector 0) and as data cache.
When using IDE devices its  an  advantage to have additional expansion
memory. No problem for the Symbiface.  Users of the CPC-IDE or IDE8255
should add an memory expansion to the CPC.
Like you can see (table  below)  the  CPC  running FutureOS can manage
four different IDE devices at the same time.


Memory Table
=============+=========================================
   Address   ! Descripton
    Space    !  Content
=============+=========================================
 &4000-&41FF ! Master CPC-IDE Identify Drive Bytes
-------------+-----------------------------------------
 &4200-&&3FF ! Slave CPC-IDE Identify Drive Bytes
-------------+-----------------------------------------
 &4400-&45FF ! Master IDE8255 Identify Drive Byhtes
-------------+-----------------------------------------
 &4600-&47FF ! Slave IDE8255 Identify Drive Byhtes
=============+=========================================
 &4800-&49FF ! Master CPC-IDE LBA Sektor 0
-------------+-----------------------------------------
 &4A00-&4BFF ! Slave CPC-IDE LBA Sektor 0
-------------+-----------------------------------------
 &4C00-&4DFF ! Master IDE8255 LBA Sektor 0
-------------+-----------------------------------------
 &4E00-&4FFF ! Slave IDE8255 LBA Sektor 0
=============+=========================================
 &5000-&7FFF ! 12 KB unused / reserverd / Cache
=============+=========================================
























You can download the latest version of this file at ...

The FutureOS homepage...: http://www.FutureOS.de/ ... or at ...
The FutureOS-Yahoo group: http://tech.groups.yahoo.com/group/FutureOS/
OS homepage...: http://www.FutureOS.de/ ... or at ...
The FutureOS-Yahoo group: http://tech.groups.yahoo.com/group/Fut