summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/scsitools/stmp_scsi.h
blob: 2da17baf474a014fd7e54d1c97bbd22b3f485712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2012 Amaury Pouly
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#ifndef __STMP_SCSI__
#define __STMP_SCSI__

#include <stdint.h>

#define SCSI_STMP_READ                          0xc0
#define SCSI_STMP_WRITE                         0xc1
/** STMP: Command */
#define SCSI_STMP_CMD_GET_PROTOCOL_VERSION      0x0
#define SCSI_STMP_CMD_GET_LOGICAL_MEDIA_INFO    0x2
#define SCSI_STMP_CMD_GET_LOGICAL_TABLE         0x5
#define SCSI_STMP_CMD_ALLOCATE_LOGICAL_MEDIA    0x6
#define SCSI_STMP_CMD_ERASE LOGICAL MEDIA       0x7
#define SCSI_STMP_CMD_GET_LOGICAL_DRIVE_INFO    0x12
#define SCSI_STMP_CMD_READ_LOGICAL_DRIVE_SECTOR 0x13
#define SCSI_STMP_CMD_SET_LOGICAL_DRIVE_INFO    0x20
#define SCSI_STMP_CMD_WRITE_LOGICAL_DRIVE_SECTOR    0x23
#define SCSI_STMP_CMD_ERASE_LOGICAL_DRIVE       0x2f
#define SCSI_STMP_CMD_GET_CHIP_MAJOR_REV_ID     0x30
#define SCSI_STMP_CMD_CHIP_RESET                0x31
#define SCSI_STMP_CMD_GET_CHIP_SERIAL_NUMBER    0x32
#define SCSI_STMP_CMD_GET_ROM_REV_ID            0x37
#define SCSI_STMP_CMD_GET_JANUS_STATUS          0x40
#define SCSI_STMP_CMD_INITIALIZE_STATUS         0x41
#define SCSI_STMP_CMD_RESET_TO_RECOVERY         0x42
#define SCSI_STMP_CMD_INITIALIZE_DATA_STORE     0x43
#define SCSI_STMP_CMD_RESET_TO_UPDATER          0x44
#define SCSI_STMP_CMD_GET_DEVICE_INFO           0x45

struct scsi_stmp_protocol_version_t
{
    uint8_t major;
    uint8_t minor;
} __attribute__((packed));

struct scsi_stmp_rom_rev_id_t
{
    uint16_t rev; /* big-endian */
} __attribute__((packed));

struct scsi_stmp_chip_major_rev_id_t
{
    uint16_t rev; /* big-endian */
} __attribute__((packed));

struct scsi_stmp_logical_table_entry_t
{
    uint8_t drive_no;
    uint8_t type;
    uint8_t tag;
    uint64_t size; /* big-endian */
} __attribute__((packed));

struct scsi_stmp_logical_table_t
{
    uint16_t count; /* big-endian */
} __attribute__((packed));

#define SCSI_STMP_MEDIA_INFO_TYPE   6
#define SCSI_STMP_MEDIA_INFO_VENDOR 12

#define SCSI_STMP_MEDIA_TYPE_NAND   0
#define SCSI_STMP_MEDIA_TYPE_SDMMC  1
#define SCSI_STMP_MEDIA_TYPE_HDD    2
#define SCSI_STMP_MEDIA_TYPE_RAM    3
#define SCSI_STMP_MEDIA_TYPE_iNAND  4

#define SCSI_STMP_MEDIA_VENDOR_SAMSUNG  0xEC
#define SCSI_STMP_MEDIA_VENDOR_STMICRO  0x20
#define SCSI_STMP_MEDIA_VENDOR_HYNIX    0xAD
#define SCSI_STMP_MEDIA_VENDOR_MICRON   0x2C
#define SCSI_STMP_MEDIA_VENDOR_TOSHIBA  0x98
#define SCSI_STMP_MEDIA_VENDOR_RENESAS  0x07
#define SCSI_STMP_MEDIA_VENDOR_SANDISK  0x45
#define SCSI_STMP_MEDIA_VENDOR_INTEL    0x89

struct scsi_stmp_logical_media_info_type_t
{
    uint8_t type;
}  __attribute__((packed));

struct scsi_stmp_logical_media_info_manufacturer_t
{
    uint32_t type; /* big-endian */
}  __attribute__((packed));

#define SCSI_STMP_DRIVE_INFO_SECTOR 0 /** Sector Size (bytes) */
#define SCSI_STMP_DRIVE_INFO_SIZE   2 /** Total Size (bytes) */
#define SCSI_STMP_DRIVE_INFO_COUNT  4 /** Sector Count */
#define SCSI_STMP_DRIVE_INFO_TYPE   5 /** Drive Type */

#define SCSI_STMP_DRIVE_TYPE_USER   0
#define SCSI_STMP_DRIVE_TYPE_SYSTEM 1
#define SCSI_STMP_DRIVE_TYPE_DRM    2

struct scsi_stmp_logical_drive_info_sector_t
{
    uint32_t size; /* big-endian */
}  __attribute__((packed));

struct scsi_stmp_logical_drive_info_count_t
{
    uint64_t count; /* big-endian */
}  __attribute__((packed));

struct scsi_stmp_logical_drive_info_size_t
{
    uint64_t size; /* big-endian */
}  __attribute__((packed));

struct scsi_stmp_logical_drive_info_type_t
{
    uint8_t type;
}  __attribute__((packed));

#endif /* __STMP_SCSI__ */