This commit is contained in:
Vladimir Serbinenko committed 2016-02-22 19:34:30 +01:00
1 parent 2b2a338ad6
commit 95f663ec1d
1 file changed
-310
-310
View File
@@ -604,316 +604,6 @@ struct ec_response_get_features {
uint32_t flags[2];
} __packed;
/*****************************************************************************/
/* Flash commands */
/* Get flash info */
#define EC_CMD_FLASH_INFO 0x10
/* Version 0 returns these fields */
struct ec_response_flash_info {
/* Usable flash size, in bytes */
uint32_t flash_size;
/*
* Write block size. Write offset and size must be a multiple
* of this.
*/
uint32_t write_block_size;
/*
* Erase block size. Erase offset and size must be a multiple
* of this.
*/
uint32_t erase_block_size;
/*
* Protection block size. Protection offset and size must be a
* multiple of this.
*/
uint32_t protect_block_size;
} __packed;
/* Flags for version 1+ flash info command */
/* EC flash erases bits to 0 instead of 1 */
#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
/*
* Version 1 returns the same initial fields as version 0, with additional
* fields following.
*
* gcc anonymous structs don't seem to get along with the __packed directive;
* if they did we'd define the version 0 struct as a sub-struct of this one.
*/
struct ec_response_flash_info_1 {
/* Version 0 fields; see above for description */
uint32_t flash_size;
uint32_t write_block_size;
uint32_t erase_block_size;
uint32_t protect_block_size;
/* Version 1 adds these fields: */
/*
* Ideal write size in bytes. Writes will be fastest if size is
* exactly this and offset is a multiple of this. For example, an EC
* may have a write buffer which can do half-page operations if data is
* aligned, and a slower word-at-a-time write mode.
*/
uint32_t write_ideal_size;
/* Flags; see EC_FLASH_INFO_* */
uint32_t flags;
} __packed;
/*
* Read flash
*
* Response is params.size bytes of data.
*/
#define EC_CMD_FLASH_READ 0x11
struct ec_params_flash_read {
uint32_t offset; /* Byte offset to read */
uint32_t size; /* Size to read in bytes */
} __packed;
/* Write flash */
#define EC_CMD_FLASH_WRITE 0x12
#define EC_VER_FLASH_WRITE 1
/* Version 0 of the flash command supported only 64 bytes of data */
#define EC_FLASH_WRITE_VER0_SIZE 64
struct ec_params_flash_write {
uint32_t offset; /* Byte offset to write */
uint32_t size; /* Size to write in bytes */
/* Followed by data to write */
} __packed;
/* Erase flash */
#define EC_CMD_FLASH_ERASE 0x13
struct ec_params_flash_erase {
uint32_t offset; /* Byte offset to erase */
uint32_t size; /* Size to erase in bytes */
} __packed;
/*
* Get/set flash protection.
*
* If mask!=0, sets/clear the requested bits of flags. Depending on the
* firmware write protect GPIO, not all flags will take effect immediately;
* some flags require a subsequent hard reset to take effect. Check the
* returned flags bits to see what actually happened.
*
* If mask=0, simply returns the current flags state.
*/
#define EC_CMD_FLASH_PROTECT 0x15
#define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
/* Flags for flash protection */
/* RO flash code protected when the EC boots */
#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
/*
* RO flash code protected now. If this bit is set, at-boot status cannot
* be changed.
*/
#define EC_FLASH_PROTECT_RO_NOW (1 << 1)
/* Entire flash code protected now, until reboot. */
#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
/* Flash write protect GPIO is asserted now */
#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
/* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
/*
* Error - flash protection is in inconsistent state. At least one bank of
* flash which should be protected is not protected. Usually fixed by
* re-requesting the desired flags, or by a hard reset if that fails.
*/
#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
/* Entire flash code protected when the EC boots */
#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
struct ec_params_flash_protect {
uint32_t mask; /* Bits in flags to apply */
uint32_t flags; /* New flags to apply */
} __packed;
struct ec_response_flash_protect {
/* Current value of flash protect flags */
uint32_t flags;
/*
* Flags which are valid on this platform. This allows the caller
* to distinguish between flags which aren't set vs. flags which can't
* be set on this platform.
*/
uint32_t valid_flags;
/* Flags which can be changed given the current protection state */
uint32_t writable_flags;
} __packed;
/*
* Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
* write protect. These commands may be reused with version > 0.
*/
/* Get the region offset/size */
#define EC_CMD_FLASH_REGION_INFO 0x16
#define EC_VER_FLASH_REGION_INFO 1
enum ec_flash_region {
/* Region which holds read-only EC image */
EC_FLASH_REGION_RO = 0,
/* Region which holds rewritable EC image */
EC_FLASH_REGION_RW,
/*
* Region which should be write-protected in the factory (a superset of
* EC_FLASH_REGION_RO)
*/
EC_FLASH_REGION_WP_RO,
/* Number of regions */
EC_FLASH_REGION_COUNT,
};
struct ec_params_flash_region_info {
uint32_t region; /* enum ec_flash_region */
} __packed;
struct ec_response_flash_region_info {
uint32_t offset;
uint32_t size;
} __packed;
/* Read/write VbNvContext */
#define EC_CMD_VBNV_CONTEXT 0x17
#define EC_VER_VBNV_CONTEXT 1
#define EC_VBNV_BLOCK_SIZE 16
enum ec_vbnvcontext_op {
EC_VBNV_CONTEXT_OP_READ,
EC_VBNV_CONTEXT_OP_WRITE,
};
struct ec_params_vbnvcontext {
uint32_t op;
uint8_t block[EC_VBNV_BLOCK_SIZE];
} __packed;
struct ec_response_vbnvcontext {
uint8_t block[EC_VBNV_BLOCK_SIZE];
} __packed;
/*****************************************************************************/
/* Verified boot commands */
/*
* Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
* reused for other purposes with version > 0.
*/
/* Verified boot hash command */
#define EC_CMD_VBOOT_HASH 0x2a
struct ec_params_vboot_hash {
uint8_t cmd; /* enum ec_vboot_hash_cmd */
uint8_t hash_type; /* enum ec_vboot_hash_type */
uint8_t nonce_size; /* Nonce size; may be 0 */
uint8_t reserved0; /* Reserved; set 0 */
uint32_t offset; /* Offset in flash to hash */
uint32_t size; /* Number of bytes to hash */
uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
} __packed;
struct ec_response_vboot_hash {
uint8_t status; /* enum ec_vboot_hash_status */
uint8_t hash_type; /* enum ec_vboot_hash_type */
uint8_t digest_size; /* Size of hash digest in bytes */
uint8_t reserved0; /* Ignore; will be 0 */
uint32_t offset; /* Offset in flash which was hashed */
uint32_t size; /* Number of bytes hashed */
uint8_t hash_digest[64]; /* Hash digest data */
} __packed;
enum ec_vboot_hash_cmd {
EC_VBOOT_HASH_GET = 0, /* Get current hash status */
EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */
EC_VBOOT_HASH_START = 2, /* Start computing a new hash */
EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */
};
enum ec_vboot_hash_type {
EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
};
enum ec_vboot_hash_status {
EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
};
/*
* Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
* If one of these is specified, the EC will automatically update offset and
* size to the correct values for the specified image (RO or RW).
*/
#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
/*****************************************************************************/
/* Force lid open command */
/* Make lid event always open */
#define EC_CMD_FORCE_LID_OPEN 0x2c
struct ec_params_force_lid_open {
uint8_t enabled;
} __packed;
/*****************************************************************************/
/* USB charging control commands */
/* Set USB port charging mode */
#define EC_CMD_USB_CHARGE_SET_MODE 0x30
struct ec_params_usb_charge_set_mode {
uint8_t usb_port_id;
uint8_t mode;
} __packed;
/*****************************************************************************/
/* Persistent storage for host */
/* Maximum bytes that can be read/written in a single command */
#define EC_PSTORE_SIZE_MAX 64
/* Get persistent storage info */
#define EC_CMD_PSTORE_INFO 0x40
struct ec_response_pstore_info {
/* Persistent storage size, in bytes */
uint32_t pstore_size;
/* Access size; read/write offset and size must be a multiple of this */
uint32_t access_size;
} __packed;
/*
* Read persistent storage
*
* Response is params.size bytes of data.
*/
#define EC_CMD_PSTORE_READ 0x41
struct ec_params_pstore_read {
uint32_t offset; /* Byte offset to read */
uint32_t size; /* Size to read in bytes */
} __packed;
/* Write persistent storage */
#define EC_CMD_PSTORE_WRITE 0x42
struct ec_params_pstore_write {
uint32_t offset; /* Byte offset to write */
uint32_t size; /* Size to write in bytes */
uint8_t data[EC_PSTORE_SIZE_MAX];
} __packed;
/*****************************************************************************/
/* Real-time clock */