home *** CD-ROM | disk | FTP | other *** search
- @(#)XHDI/xhdispec.txt
- @(#)Julian F. Reschke, 22. März 1992
-
- Specification of the `XHDI' cookie, March 22, 1992
- --------------------------------------------------
-
- Cookie id: "XHDI". The contents of the cookie is the start address of a
- function, which provides procedures for dealing with block storage devices.
- As an additional check, the function is preceded by the long constant
- $27011992.
-
- The contents of the XHDI cookie may change (because it can be used by
- more than one driver). Therefore, in some applications (example: DA's) the
- cookie contents must be inquired each time before the handler is called.
-
- ALL FUNCTIONS HAVE TO BE CALLED FROM SUPERVISOR MODE. The effects of a call
- in user mode are undefined. All processor registers except d0 are
- preserved. EINVFN is returned for invalid opcodes.
-
- Some of the function calls -- notably `XHReadWrite()' -- might be
- implemented by calls to BIOS or XBIOS functions and therefore can activate
- the `Critical Error Handler'. It's the responsibility of the caller to
- switch of the `CEH', if this is needed.
-
- Some error codes:
-
- TOS error codes:
-
- 0: OK (OK)
- -1: unspecified error (ERROR)
- -2: device not responding (EDRVNR)
- -15: unknown device (EUNDEV)
- -32: invalid function number (EINVFN)
- -36: access denied, device is reserved (EACCDN)
- -46: invalid drive number (EDRIVE)
-
- SCSI error codes (ranging from -200 to -455)
-
- (-200 - N): SCSI error code N (the `Additional Sense Code', Byte 12 in the
- `Extended Sense Format', see section 7.2.14 in `draft proposed
- American National Standard for information systems - SMALL
- COMPUTER SYSTEM INTERFACE - 2 (SCSI-2) March 9, 1990').
-
- Note: obviously, you can get these (SCSI) error codes only for ACSI or
- SCSI devices. For other device types -- like the IDE drives in the ST Book
- -- you can get other error codes which have yet to be defined.
-
- Parameters are passed the same way as to GEMDOS functions. All values are
- put onto the stack, with the 16 bit opcode last. The 32 bit result is
- returned in d0.
-
-
- Definition of data types:
-
- UWORD: 16-Bit, unsigned
- LONG: 32-Bit, signed
- ULONG: 32-Bit, unsigned
- char *: 32-Bit, pointer to a zero terminated string
-
-
- Terms:
-
- major: Major Device Number
-
- 0..7: Devices on the ACSI bus with ATARI-compatible command set
- 8..15: Devices on the SCSI bus
- 16..63: Extensions as defined in the pun field in the PUN_INFO
- structure.
- 64: Devices on the standard floppy controller
- 65..255: Extensions outside the scope of AHDI.
-
- minor: Minor Device Number (for 'major' 0..15: LUN of the ACSI or SCSI
- device), maximal 255.
-
- key: A 16 bit key, returned by `XHReserve()', or 0, if the device is
- not locked or if the key is unknown.
-
-
- The XHDI functions:
-
- -----------------------------------------------------------------------
- Opcode 0: UWORD XHGetVersion (void);
-
- Returns the current protocol version. Example: $0119 is Version 1.19 (the
- format is similar to that returned by `Sversion()', but high and low byte
- are not reversed). This version of the XHDI specification has the version
- number $0100.
-
- -----------------------------------------------------------------------
- Opcode 1: LONG XHInqTarget (UWORD major, UWORD minor, ULONG *blocksize,
- ULONG *device_flags, char *product_name);
-
- Returns information about the device specified by `major' and `minor'.
- Reservation made with `XHReserve()' are reflected in `device_flags'.
-
- block_size: Block size for this device (important for `XHReadWrite()').
- Usually 512.
-
- device_flags: (Bit set -> Capability available)
-
- Bit 0: Device is stoppable (XH_TARGET_STOPPABLE)
- Bit 1: The medium is removable (XH_TARGET_REMOVABLE)
- Bit 2: The eject mechanism can be locked
- (XH_TARGET_LOCKABLE)
- Bit 3: The device can physically eject the medium
- (XH_TARGET_EJECTABLE)
- Bit 31: The device is currently reserved (XH_TARGET_RESERVED).
-
- All other bits are reserved, drivers should set them to zero.
-
- product_name: Product name of the device, similar to the information
- returned by the SCSI command INQUIRE (max. 33 characters
- incl. terminating zero). If this information is not
- available, the driver should return a zero length string.
-
- Note: the caller may pass a zero pointer for `blocksize', `device_flags'
- and `product_name'.
-
- -----------------------------------------------------------------------
- Opcode 2: LONG XHReserve (UWORD major, UWORD minor, UWORD do_reserve,
- UWORD key);
-
- Reserves or releases a device. `XHLock()', `XHStop()' and `XHEject()'
- only work for reserved devices if the correct key parameter is passed.
-
- Example: take a virtual memory manager which has locked a removable hard
- disk with the swap partition. You don't want the user to be able to unlock
- this device with a CPX module!
-
- On success, a 16 bit key is returned.
-
- do_reserve: (1) Reserve or (0) release.
- key: (only used for release).
-
- -----------------------------------------------------------------------
- Opcode 3: LONG XHLock (UWORD major, UWORD minor, UWORD do_lock,
- UWORD key);
-
- Locks or unlocks the eject mechanism of the device.
-
- do_lock: (1) Lock or (0) unlock.
- key: if the device is reserved pass the key, otherwise zero.
-
- -----------------------------------------------------------------------
- Opcode 4: LONG XHStop (UWORD major, UWORD minor, UWORD do_stop,
- UWORD key);
-
- Stops (ships) or starts the device.
-
- do_stop: (1) Stop or (0) start.
- key: if the device is reserved pass the key, otherwise zero.
-
- Note: if the drive is accessed, the driver should restart it without an
- explicit restart call.
-
- -----------------------------------------------------------------------
- Opcode 5: LONG XHEject (UWORD major, UWORD minor, UWORD do_eject,
- UWORD key);
-
- Ejects or inserts the medium.
-
- do_eject: Eject (1) or insert (0) medium.
- key: if the device is reserved pass the key, otherwise zero.
-
- -----------------------------------------------------------------------
- Opcode 6: ULONG XHDrvMap (void);
-
- Returns a bit mask of BIOS devices supported by the XHDI driver(s) (as the
- return value from `Drvmap()').
-
- -----------------------------------------------------------------------
- Opcode 7: LONG XHInqDev (UWORD bios_device, UWORD *major, UWORD *minor,
- ULONG *start_sector, BPB *bpb);
-
- Returns major device number, minor device number, starting sector and BPB
- of a given BIOS device (Note: getting the BPB this way will NOT reset the
- internal media change state).
-
- Note: the caller provides a pointer to the BPB structure, which is filled
- by the driver.
-
- Return values: OK, EDRNVR (device not responding, eg. medium not inserted),
- EDRIVE (wrong BIOS device number) or some other applicable error code. Ff
- the error code is EDRVNR, `major', `minor' and `start_sector' contain the
- correct values anyway.
-
- If `start_sector' is $FFFFFFFF, the device is only temporarily inaccessible
- (example: you have inserted a cartridge with two partitions, but three
- drive bits have been reserved for the device).
-
- The BPB is invalid, if the structure element `recsiz' is zero.
-
- Note: a file system is fully described by major and minor device number and
- the starting block number. This does NOT mean, that it is necessarely a FAT
- file system.
-
- Note: the caller may pass a zero pointer for `major', `minor',
- `start_sector' and `bpb'.
-
- -----------------------------------------------------------------------
- Opcode 8: LONG XHInqDriver (UWORD bios_device, char *name, char *version,
- char *company, UWORD *ahdi_version,
- UWORD *maxIPL);
-
- Gets information about the driver for the bios_device.
-
- name: Name of driver (max. 17 characters).
- version: String with version number (max. 7 characters).
- company: Name of company/programmer (max. 17 characters).
- ahdi_version: AHDI version level (as defined in the PUN_INFO structure).
- maxIPL: Highest IPL, under which the driver can work (usually 5 for
- drivers which use _hz_200 for timing loops).
-
- Note: the caller may pass a zero pointer for `name', `version', `company',
- `ahdi_version' and `maxIPL'.
-
- -----------------------------------------------------------------------
- Opcode 9: LONG XHNewCookie (ULONG newcookie);
-
- - OPTIONAL function, may return EINVFN -
-
- /* send translations to julian@math.uni-muenster.de */
-
-
- ------------------------------------------------------------------------
- Opcode 10: LONG XHReadWrite (UWORD major, UWORD minor, UWORD rwflag,
- ULONG recno, UWORD count, void *buf);
-
- Read or write physical blocks.
-
- rwflag: Bits 0..2: as defined in the AHDI Release Notes (3.00, April
- 18, 1990). Bit 3 (physical mode) is ignored. All other bits
- are reserved and should be set to zero.
- recno: block number
- count: block count
- buf: pointer to buffer
-
-
- ------------------------------------------------------------------------
-
-
- How to install more than one XHDI driver
- ----------------------------------------
-
- (1) During the installation, check if the cookie is alreay set. If so:
-
- (2) For `XHGetVersion()' first jump through the old vector and return the
- minimum of this and your own version number.
-
- (3) For `XHDrvmap()' first jump through the old vector and then or-in the
- drive bits for the devices supported by you.
-
- (4) For all other functions: check, if one of `your' devices. If not, jump
- through the old vector.
-