Naraeon SSD Tools internals – 4. Command set and Interpreting buffer

Necessity

I think reason for visiting my blog is in this. Function that includes all features other than Read, Write, Open, Close, ioctl. Called DeviceIoControl in winapi. In undergraduate course, there would be only introduction about this function. I also firstly had no idea about where to find information to use ioctls. So I would write about this.

If we use this, we need to say goodbye to most of the protections OS provides. Former four commands have various protections to block fatal mistakes, but ioctl only has minimum protection. And it doesn’t automatically translates function into each command set. So we need know about them.

Language of storage, Command set

Using ioctl means speaking in command set which the device supports. SATA devices use ATAPI, Some of latest M.2 devices and PCIe devices use NVM express, USB devices use SCSI(SAT). We need to know all of them. And we call them Command set.

We cannot ignore drivers’ though, passthrough

As I said, we gave up most of the protections and chose ioctl. And we learnt command sets. But there is another obstacle. Driver’s support of the ioctl code. To send a command directly to the device, we need to firstly send a command to driver. That is passthrough.

I personally don’t have experience before IOCTL_ATA_PASS_THROUGH exists. Though, I heard that this came out after XP SP2 released, after quite a long time from release of ATA. If there is no passthrough ioctl provided, full-featured disk management tool cannot be made. So disk management tool developers need to find the ioctl code for each new command sets.

Abstraction of command set: TCommandSet

It’s easier to abstract command sets than use them directly. Directly using them makes adopting new command set hard, because that needs modification of front-end code. Just using one needs per-command abstraction, but using various sets needs per-set abstraction. Naraeon SSD Tools defines these commands.

  • Identify: BIOS and device manager shows model name, firmware version, capacity using this command. We need this to get them.
  • SMART: This shows current status of the device. It is vendor-specific, so we need to interpret them to get what these value mean.
  • Trim(Data Set Management): Send that the specified space is no more used to the SSD. So the space would be used for other purpose.

Abstraction of output buffer: TBufferInterpreter

Output buffer also need abstraction. Disk tools only need little subset of information, and standards have it’s own output format. In this situation, interpreter makes thing easier. Naraeon SSD Tools abstracts Identify buffer and SMART buffer.

Before interpreting, there are just bits

After interpreting, it became human-readable form

Leave a Reply

Your email address will not be published. Required fields are marked *