meson: convert hw/vfio
[qemu.git] / hw / sd / sdmmc-internal.c
1 /*
2 * SD/MMC cards common helpers
3 *
4 * Copyright (c) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org>
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #include "qemu/osdep.h"
12 #include "sdmmc-internal.h"
13
14 const char *sd_cmd_name(uint8_t cmd)
15 {
16 static const char *cmd_abbrev[SDMMC_CMD_MAX] = {
17 [0] = "GO_IDLE_STATE",
18 [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR",
19 [4] = "SET_DSR", [5] = "IO_SEND_OP_COND",
20 [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD",
21 [8] = "SEND_IF_COND", [9] = "SEND_CSD",
22 [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH",
23 [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS",
24 [15] = "GO_INACTIVE_STATE",
25 [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK",
26 [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK",
27 [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec",
28 [23] = "SET_BLOCK_COUNT",
29 [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK",
30 [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD",
31 [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT",
32 [30] = "SEND_WRITE_PROT",
33 [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END",
34 [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD",
35 [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD",
36 [38] = "ERASE",
37 [40] = "DPS_spec",
38 [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT",
39 [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B",
40 [46] = "Q_RD_TASK", [47] = "Q_WR_TASK",
41 [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE",
42 [50] = "SW_FUNC_RSVD",
43 [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED",
44 [54] = "SDIO_RSVD", [55] = "APP_CMD",
45 [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD",
46 [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI",
47 [60] = "MANUF_RSVD", [61] = "MANUF_RSVD",
48 [62] = "MANUF_RSVD", [63] = "MANUF_RSVD",
49 };
50 return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD";
51 }
52
53 const char *sd_acmd_name(uint8_t cmd)
54 {
55 static const char *acmd_abbrev[SDMMC_CMD_MAX] = {
56 [6] = "SET_BUS_WIDTH",
57 [13] = "SD_STATUS",
58 [14] = "DPS_spec", [15] = "DPS_spec",
59 [16] = "DPS_spec",
60 [18] = "SECU_spec",
61 [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT",
62 [41] = "SD_SEND_OP_COND",
63 [42] = "SET_CLR_CARD_DETECT",
64 [51] = "SEND_SCR",
65 [52] = "SECU_spec", [53] = "SECU_spec",
66 [54] = "SECU_spec",
67 [56] = "SECU_spec", [57] = "SECU_spec",
68 [58] = "SECU_spec", [59] = "SECU_spec",
69 };
70
71 return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD";
72 }