
______________________

ZIDEFS reference guide
______________________


Please read 'Guide' for general information.

The functionality offered by ZIDEFS SWIs is described in detail here.

(Note that if you're using an alternative ROM, i.e. IDEFSROM or ADFSROM, then
wherever you read ZIDEFS, imagine reading IDEFS or ADFS instead, respectively).

Note that SWIs 0x557C0 through 0x557CF provide ZIDEFS specific versions of
Filecore SWIs &40540 through &4054F, using the same name, and the same offset
from the SWI chunk. If a Filecore SWI in this range has no ZIDEFS specific
equivalent, it is called ZIDEFS_NOP, and does nothing when called.

Note that SWIs 0x557D0 and higher are ZIDEFS specific.


ZIDEFS_DiscOp (0x557C0)
-----------------------
See FileCore_DiscOp (RISC OS 3 PRMs page 2-221).

Reason codes 0,1,2,5 and 6 are implemented. Reason code 15 is not faulted but
otherwise ignored.


ZIDEFS_Drives (0x557C2)
-----------------------
See FileCore_Drives (RISC OS 3 PRMs page 2-228).


ZIDEFS_FreeSpace (0x557C3)
--------------------------
See FileCore_FreeSpace (RISC OS 3 PRMs page 2-229).


ZIDEFS_DescribeDisc (0x557C5)
-----------------------------
See FileCore_DescribeDisc (RISC OS 3 PRMs page 2-232).


ZIDEFS_MiscOp (0x557C9)
-----------------------
See FileCore_MiscOp (RISC OS 3 PRMs page 2-238).


ZIDEFS_SectorOp (0x557CA)
-------------------------
See FileCore_SectorOp (RISC OS 3 PRMs page 5a-176).

Reason codes 0,1,2,5 and 6 are implemented. Reason code 15 is not faulted but
otherwise ignored.


ZIDEFS_FreeSpace64 (0x557CB)
----------------------------
See FileCore_FreeSpace64 (RISC OS 3 PRMs page 5a-181).


ZIDEFS_Info (0x557D0)
---------------------
This is for internal use only.


ZIDEFS_Execute (0x557D1)
------------------------
This SWI allows direct, low level access to an IDE harddisc. It is, therefore,
a powerful, but also dangerous SWI. Do NOT use this SWI if you don't know
exactly what you're doing. It is easy to trash the contents of your harddisc
or even make it permanently unusable.

This SWI provides read/write access to all IDE harddisc registers, allows an
IDE command to be issued and completed, and allows single sector sized data
transfers to or from the harddisc. Any one of these accesses is referred to as
an IDE operation.

This SWI takes a list of IDE operations and executes them. An IDE operation is
specified by a single word (4 byte) value. The list is terminated by -1, and
must be word-aligned.

An optional data buffer passed to the SWI supplies data for write transfer
operations, or buffer space for read transfer operations.

On entry

- r1 points to word-aligned operations list
- r2 points to source or target data buffer
- r3 contains size of data buffer in bytes

On exit

- r1 updated to last executed operation
- r2 updated to first unused byte
- r3 updated to remaining size
     if < 0, the data buffer was prematurely exhausted
- V set if error (r0 contains error pointer), else clear

IDE operations list

- Format of an operation word
  bit 0..23  - operation argument (if any)
  bit 24..31 - operation code (mandatory)
- List is terminated by a -1 word

Operation codes

- 0 = Issue IDE command

  Waits for ~BSY, sinks any pending data, issues the IDE command (bits 0..7 of
  the operation argument), waits for ~BSY, checks for an error.

- 1/3/4/5 = Write 8 bit value to an IDE register

  Writes an 8 bit value (bits 0..7 of the operation argument) to an IDE
  register (1=Device/Head, 3=Sector Number, 4=Sector Count, 5=Features).

- 2 = Write 16 bit value to Cylinder Low/High registers

  Writes a 16 bit value (bits 0..15 of the operation argument) to IDE registers
  Cylinder Low (bits 0..7) and Cylinder High (bits 8..15).

- 8/9/11/12/13 = Read 8 bit value from an IDE register

  Reads an 8 bit value (next byte in data buffer) from an IDE register
  (8=Status, 9=Device/Head, 11=Sector Number, 12=Sector Count, 13=Error).

- 10 = Read 16 bit value from Cylinder Low/High registers

  Reads a 16 bit value (next 2 bytes in data buffer) from IDE registers
  Cylinder Low (first byte) and Cylinder High (second byte).

- 16 = Read bytes

  Waits for DRQ, reads data bytes (next <operation argument> bytes in data
  buffer), checks for an error. Number of bytes must be even and equal to the
  number of bytes generated by the last issued IDE command. Data buffer pointer
  must be 2-byte-aligned. Number of bytes is limited to one sector (512 bytes),
  plus, optionally, 4 or 7 ECC bytes.

- 17 = Write bytes

  See 'Read bytes', but writes data bytes from data buffer to IDE.

An example :

Reading 'Identify Device' information of your master harddisc :

- Point R1 to a list of four words :

   1<<24 OR %10100000 ; Write Device/Head register (Device=0, Head=0)
   0<<24 OR &EC       ; Issue and complete 'Identify Device' command
  16<<24 OR 512       ; Read the 512 info bytes
  -1                  ; <End of list>

- Point R2 to a 512 byte buffer to receive the info bytes.
- R3 = 512.


ZIDEFS_DriveOptions (0x557D2)
-----------------------------
This is for internal use only.



