# Drive I/O

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.

Destination and source buffers for Drive I/Os must be aligned to 4 bytes.

## API

### Struct

struct Drive
  fields secsz seccnt
  method readsector ( sec dst drv -- )
  method writesector ( sec dst drv -- )
endstruct

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

readsector ( sec dst drv -- )
  Read sector "sec" in memory address "dst", which needs to be a buffer at least
  "secsz" in size.

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

### Words

newdrive ( 'readsector 'writesector secsz seccnt -- drv )
  Create a new drive struct with the specified values/methods.
