xref: /aosp_15_r20/external/sg3_utils/inhex/nvme_write_ctl.hex (revision 44704f698541f6367e81f991ef8bb54ccbf3fc18)
1# 64 byte NVMe, Write command (a NVM command) that is suitable for:
2#       sg_raw --cmdfile=<this_file_name> --nvm --request=2048 <nvme_device>
3#
4# The address field (at byte offset 24, 8 bytes and little endian) gives
5# special meaning to the highest address pointers:
6#    ffffffff fffffffe         use address of data-in buffer
7#    ffffffff fffffffd         use address of data-out buffer
8#
9# The data length field (at byte offset 36, 4 bytes and little endian)
10# gives special meaning to the highest block counts:
11#    fffffffe                  use byte length of data-in buffer
12#    fffffffd                  use byte length of data-out buffer
13#
14# 512 byte logical block size is assumed. Write 4 blocks hence 2048 bytes.
15# The first LBA written is 0x12345 and the namespace is 1. If successful the
16# four blocks will be written out of the data-out buffer. Submission queue
17# is used (the same queue that Admin commands use). The NVM opcode for the
18# Write command is 0x1 and appears in the first command byte.
19
2001 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00
2100 00 00 00 00 00 00 00  fd ff ff ff ff ff ff ff
2200 00 00 00 fd ff ff ff  45 23 01 00 00 00 00 00
2303 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
24
25# Notice NVMe uses its quirky "0's based" number of blocks so
26# 03 appears at byte offset 48 to mean "write 4 blocks".
27#
28# A typical invocation in Linux and FreeBSD would look like this:
29#    sg_raw --cmdfile=nvme_write_ctl.hex --nvm -s 2048
30#           --infile=t.bin /dev/nvme0
31#
32# Notice the '--nvm' option which is needed to distinguish a NVM
33# command from an Admin command as Admin commands are the default
34# in this utility.
35#
36# This utility (and most others in the package) aligns data-in and
37# data-out buffers to the beginning of pages which are 4096 bytes
38# long at a minimum. This is the way NVMe likes things as well.
39