# Drive

The Drive struct offers a unified API to read and write to mass storage.  It
does so in blocks of bytes of a definite size which we call "sector".  Sectors
in the Drive API are organized in a linear manner (LBA, Logical Block
Addressing). If the underlying mass storage driver interfaces with a CHS
(cylinder, head, sector) system, it's the driver's responsibility to convert LBA
to CHS.

The [lib/drive.fs] unit contains utilities around the Drive structure, which is
defined in [xcomp/boot.fs].

Fields:

secsz   size in bytes of each sector read and written by the driver.
        It's often 512.
seccnt  Number of sectors in the drive

Methods:

:sec@ ( sec dst drv -- )
  Read sector "sec" in memory address "dst", which needs to be a buffer at least
  "secsz" in size. "drv" is a pointer to a Drive structure.

:sec! ( sec src drv -- )
  Write sector "sec" from memory address "src".

## DriveIO

DriveIO is a structure allowing direct access to a Drive through the convenience
of a IO API. Its buffer size is the drive's sector size. It lives on top of a
SectorWindow and by defaults targets the whole drive, although the :move word
can be used to reduce the scope of the file.

Fields:

secwin The target SectorWindow.

Words:

:new ( drv -- hdl )
  Create a new DriveIO interfacing Drive "drv".

:move ( fsec cnt self -- )
  Calls secwin's :move and seek pos 0.
