New Style Device Commands

The "new style device" standard (DevInfo/DeviceDevelopment/NewStyleCommands) gives a uniform way to query a device's type and supported commands. It lives in the reserved range $4000-$7fff for general commands and $c000-$ffff for device-specific ones.

Minimum requirements for a new style device

  • Correctly return IOERR_NOCMD for unknown commands.
  • No redefinition of standard V40 or reserved commands; no 3rd-party commands in reserved areas.
  • Support NSCMD_DEVICEQUERY.
  • lib_IdString must contain the device name, version, and creation date so 3rd parties can identify the exact device.

A device may reject all new style commands except NSCMD_DEVICEQUERY with IOERR_NOCMD unless the caller has first executed a valid, successful query. All query result data must stay constant and valid for the lifetime of the open device; after CloseDevice(), "all bets are off."

The query command

#define NSCMD_DEVICEQUERY   0x4000

Caller clears SizeAvailable, sets DevQueryFormat = 0, points io_Data/io_Length at an NSDeviceQueryResult, and does DoIO(). The device is a confirmed new style device only if all of these hold:

  • no error returned,
  • io_Actual >= 16,
  • nsdqr.SizeAvailable == io_Actual,
  • nsdqr.DeviceType is the expected type.

Only then may any other result field be trusted.

struct NSDeviceQueryResult

struct NSDeviceQueryResult
{
    ULONG   DevQueryFormat;      /* set to 0 by caller            */
    ULONG   SizeAvailable;       /* bytes of valid data; min 16   */

    UWORD   DeviceType;          /* what the device does          */
    UWORD   DeviceSubType;       /* 0 for now                     */
    UWORD  *SupportedCommands;   /* 0-terminated list of cmd ids  */
    /* May be extended — always bounds-check against SizeAvailable */
};
  • SizeAvailable — bytes of valid data; the minimum valid value is 16 (must include SupportedCommands).
  • DeviceType — the device category (see table). If a type maps to an existing V40 device, the driver must implement at least all documented V40 features of that device; anything it cannot support compatibly must return IOERR_NOCMD.
  • DeviceSubType — must be 0 for now; only test it if you need extensions beyond the standard set.
  • SupportedCommands — a 0-terminated UWORD array listing every command (old style, new style, special) the device understands without returning IOERR_NOCMD.

DeviceType values

#define NSDEVTYPE_UNKNOWN       0
#define NSDEVTYPE_GAMEPORT      1   /* like gameport.device   */
#define NSDEVTYPE_TIMER         2   /* like timer.device      */
#define NSDEVTYPE_KEYBOARD      3   /* like keyboard.device   */
#define NSDEVTYPE_INPUT         4   /* like input.device      */
#define NSDEVTYPE_TRACKDISK     5   /* like trackdisk.device  */
#define NSDEVTYPE_CONSOLE       6   /* like console.device    */
#define NSDEVTYPE_SANA2         7   /* >=SANA2R2 net device   */
#define NSDEVTYPE_AUDIOARD      8   /* like audio.device      */
#define NSDEVTYPE_CLIPBOARD     9   /* like clipboard.device  */
#define NSDEVTYPE_PRINTER      10   /* like printer.device    */
#define NSDEVTYPE_SERIAL       11   /* like serial.device     */
#define NSDEVTYPE_PARALLEL     12   /* like parallel.device   */

Reference query idiom

struct IOStdReq *io;
struct NSDeviceQueryResult nsdqr;
LONG error;
BOOL newstyle = FALSE, does64bit = FALSE;
UWORD *cmdcheck;

nsdqr.SizeAvailable  = 0;
nsdqr.DevQueryFormat = 0;

io->io_Command = NSCMD_DEVICEQUERY;
io->io_Length  = sizeof(nsdqr);
io->io_Data    = (APTR)&nsdqr;
error = DoIO((struct IORequest *)io);

if ((!error) &&
    (io->io_Actual >= 16) &&
    (nsdqr.SizeAvailable == io->io_Actual) &&
    (nsdqr.DeviceType == NSDEVTYPE_TRACKDISK))
{
    newstyle = TRUE;
    for (cmdcheck = nsdqr.SupportedCommands; *cmdcheck; cmdcheck++) {
        if (*cmdcheck == NSCMD_TD_READ64) {
            does64bit = TRUE;   /* full 64-bit command set present */
        } /* if */
    } /* for */
} /* if */

Device-specific new style commands

Only NSDEVTYPE_TRACKDISK defines device-specific commands on the CD. A new style trackdisk-like device must also return DRIVE_NEWSTYLE (0x4E535459, 'NSTY') from TD_GETDRIVETYPE, and the four 64-bit commands (which must all be implemented together or none at all):

#define DRIVE_NEWSTYLE      (0x4E535459L)
#define NSCMD_TD_READ64     0xc000
#define NSCMD_TD_WRITE64    0xc001
#define NSCMD_TD_SEEK64     0xc002
#define NSCMD_TD_FORMAT64   0xc003

See 64-bit Storage Access (TrackDisk64) for the offset/length semantics.

  1. OpenDevice() as usual.
  2. Try NSCMD_DEVICEQUERY.
  3. On success by the rules above, use commands listed in SupportedCommands.
  4. Otherwise treat it as an old style device.

If you need 3rd-party commands, identify the device exactly via lib_IdString and reject anything you don't recognise.

See Also


Sources: Heinz Wrobel, Amiga Technologies, "NewStyleCommands" (1996). Raw: raw/devices/new-style-commands.md Updated: 2026-08-04