summaryrefslogtreecommitdiff
path: root/util/uut/cmd.h
blob: 44cebbe98969e34b23da696099d1ddfeb9d0f64b (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
/*
 * Copyright 2018 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __UTIL_UUT_CMD_H
#define __UTIL_UUT_CMD_H

#include <stdbool.h>

/*---------------------------------------------------------------------------
 * Constant definitions
 *---------------------------------------------------------------------------
 */

#define MAX_CMD_BUF_SIZE 10
#define MAX_RESP_BUF_SIZE 512

enum uart_protocol_cmd {
	UFPP_H2D_SYNC_CMD = 0x55,   /* Single-Byte Host to Device	 */
				    /* synchronization command	 */
	UFPP_D2H_SYNC_CMD = 0x5A,   /* Single-Byte Device to Host	 */
				    /* synchronization response	 */
	UFPP_WRITE_CMD = 0x07,      /* Write command and response	 */
	UFPP_READ_CMD = 0x1C,       /* Read command and response	 */
	UFPP_READ_CRC_CMD = 0x89,   /* Read CRC command and response */
	UFPP_FCALL_CMD = 0x70,      /* Call function command	 */
	UFPP_FCALL_RSLT_CMD = 0x73, /* Call function response	 */
	UFPP_SPI_CMD = 0x92,        /* SPI specific command		 */
	UFPP_ERROR_CMD = 0xFF       /* Error response		 */
};

struct command_node {
	uint8_t cmd[512];
	uint32_t cmd_size;
	uint32_t resp_size;
};

/*---------------------------------------------------------------------------
 * Functions prototypes
 *---------------------------------------------------------------------------
 */

void cmd_create_sync(uint8_t *cmd_info, uint32_t *cmd_len);
void cmd_create_write(uint32_t addr, uint32_t size, uint8_t *data_buf,
					uint8_t *cmd_info, uint32_t *cmd_len);
void cmd_create_read(uint32_t addr, uint8_t size, uint8_t *cmd_info,
					uint32_t *cmd_len);
void cmd_create_exec(uint32_t addr, uint8_t *cmd_info, uint32_t *cmd_len);

void cmd_build_sync(struct command_node *cmd_buf, uint32_t *cmd_num);
void cmd_build_exec_exit(uint32_t addr, struct command_node *cmd_buf,
						uint32_t *cmd_num);
void cmd_build_exec_ret(uint32_t addr, struct command_node *cmd_buf,
						uint32_t *cmd_num);

bool cmd_disp_sync(uint8_t *resp_buf);
bool cmd_disp_write(uint8_t *resp_buf, uint32_t resp_size, uint32_t resp_num,
					uint32_t total_size);
bool cmd_disp_read(uint8_t *resp_buf, uint32_t resp_size, uint32_t resp_num,
					uint32_t total_size);
void cmd_disp_data(uint8_t *resp_buf, uint32_t resp_size);
void cmd_disp_flash_erase_dev(uint8_t *resp_buf, uint32_t dev_num);
void cmd_disp_flash_erase_sect(uint8_t *resp_buf, uint32_t dev_num);
void cmd_disp_exec_exit(uint8_t *resp_buf);
void cmd_disp_exec_ret(uint8_t *resp_buf);

#endif /* __UTIL_UUT_CMD_H */