aboutsummaryrefslogtreecommitdiff
path: root/hw/block/pflash_cfi01.c
diff options
context:
space:
mode:
authorDavid Edmondson <david.edmondson@oracle.com>2021-02-16 14:27:18 +0000
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2021-03-18 11:16:31 +0100
commit91316cbb3830bb845c42da2d6eab06de56b889b0 (patch)
tree816dc5ca691ce28f627dbea942b7fb890df4e9b4 /hw/block/pflash_cfi01.c
parent2231bee28c03a60836fc75bc737448042e33272b (diff)
downloadqemu-91316cbb3830bb845c42da2d6eab06de56b889b0.zip
qemu-91316cbb3830bb845c42da2d6eab06de56b889b0.tar.gz
qemu-91316cbb3830bb845c42da2d6eab06de56b889b0.tar.bz2
hw/block/pflash_cfi: Replace DPRINTF with trace events
Rather than having a device specific debug implementation in pflash_cfi01.c and pflash_cfi02.c, use the standard tracing facility. Signed-off-by: David Edmondson <david.edmondson@oracle.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210216142721.1985543-2-david.edmondson@oracle.com> [PMD: Rebased, fixed pflash_write_block_erase trace event format] Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'hw/block/pflash_cfi01.c')
-rw-r--r--hw/block/pflash_cfi01.c80
1 files changed, 33 insertions, 47 deletions
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 0791035..81f9f97 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -56,16 +56,6 @@
#include "sysemu/runstate.h"
#include "trace.h"
-/* #define PFLASH_DEBUG */
-#ifdef PFLASH_DEBUG
-#define DPRINTF(fmt, ...) \
-do { \
- fprintf(stderr, "PFLASH: " fmt , ## __VA_ARGS__); \
-} while (0)
-#else
-#define DPRINTF(fmt, ...) do { } while (0)
-#endif
-
#define PFLASH_BE 0
#define PFLASH_SECURE 1
@@ -155,10 +145,8 @@ static uint32_t pflash_cfi_query(PFlashCFI01 *pfl, hwaddr offset)
* wider part.
*/
if (pfl->device_width != 1 || pfl->bank_width > 4) {
- DPRINTF("%s: Unsupported device configuration: "
- "device_width=%d, max_device_width=%d\n",
- __func__, pfl->device_width,
- pfl->max_device_width);
+ trace_pflash_unsupported_device_configuration(pfl->name,
+ pfl->device_width, pfl->max_device_width);
return 0;
}
/* CFI query data is repeated, rather than zero padded for
@@ -210,14 +198,14 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, hwaddr offset)
switch (boff & 0xFF) {
case 0:
resp = pfl->ident0;
- trace_pflash_manufacturer_id(resp);
+ trace_pflash_manufacturer_id(pfl->name, resp);
break;
case 1:
resp = pfl->ident1;
- trace_pflash_device_id(resp);
+ trace_pflash_device_id(pfl->name, resp);
break;
default:
- trace_pflash_device_info(offset);
+ trace_pflash_device_info(pfl->name, offset);
return 0;
}
/* Replicate responses for each device in bank. */
@@ -265,10 +253,9 @@ static uint32_t pflash_data_read(PFlashCFI01 *pfl, hwaddr offset,
}
break;
default:
- DPRINTF("BUG in %s\n", __func__);
abort();
}
- trace_pflash_data_read(offset, width, ret);
+ trace_pflash_data_read(pfl->name, offset, width, ret);
return ret;
}
@@ -282,7 +269,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset,
switch (pfl->cmd) {
default:
/* This should never happen : reset state & treat it as a read */
- DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd);
+ trace_pflash_read_unknown_state(pfl->name, pfl->cmd);
pfl->wcycle = 0;
/*
* The command 0x00 is not assigned by the CFI open standard,
@@ -320,7 +307,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset,
*/
ret |= pfl->status << 16;
}
- DPRINTF("%s: status %x\n", __func__, ret);
+ trace_pflash_read_status(pfl->name, ret);
break;
case 0x90:
if (!pfl->device_width) {
@@ -335,14 +322,14 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset,
switch (boff) {
case 0:
ret = pfl->ident0 << 8 | pfl->ident1;
- trace_pflash_manufacturer_id(ret);
+ trace_pflash_manufacturer_id(pfl->name, ret);
break;
case 1:
ret = pfl->ident2 << 8 | pfl->ident3;
- trace_pflash_device_id(ret);
+ trace_pflash_device_id(pfl->name, ret);
break;
default:
- trace_pflash_device_info(boff);
+ trace_pflash_device_info(pfl->name, boff);
ret = 0;
break;
}
@@ -389,7 +376,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset,
break;
}
- trace_pflash_io_read(offset, width, ret, pfl->cmd, pfl->wcycle);
+ trace_pflash_io_read(pfl->name, offset, width, ret, pfl->cmd, pfl->wcycle);
return ret;
}
@@ -419,7 +406,7 @@ static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset,
{
uint8_t *p = pfl->storage;
- trace_pflash_data_write(offset, width, value, pfl->counter);
+ trace_pflash_data_write(pfl->name, offset, width, value, pfl->counter);
switch (width) {
case 1:
p[offset] = value;
@@ -458,7 +445,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
cmd = value;
- trace_pflash_io_write(offset, width, value, pfl->wcycle);
+ trace_pflash_io_write(pfl->name, offset, width, value, pfl->wcycle);
if (!pfl->wcycle) {
/* Set the device in I/O access mode */
memory_region_rom_device_set_romd(&pfl->mem, false);
@@ -472,14 +459,13 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
goto mode_read_array;
case 0x10: /* Single Byte Program */
case 0x40: /* Single Byte Program */
- DPRINTF("%s: Single Byte Program\n", __func__);
+ trace_pflash_write(pfl->name, "single byte program (0)");
break;
case 0x20: /* Block erase */
p = pfl->storage;
offset &= ~(pfl->sector_len - 1);
- DPRINTF("%s: block erase at " TARGET_FMT_plx " bytes %x\n",
- __func__, offset, (unsigned)pfl->sector_len);
+ trace_pflash_write_block_erase(pfl->name, offset, pfl->sector_len);
if (!pfl->ro) {
memset(p + offset, 0xff, pfl->sector_len);
@@ -490,25 +476,25 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
pfl->status |= 0x80; /* Ready! */
break;
case 0x50: /* Clear status bits */
- DPRINTF("%s: Clear status bits\n", __func__);
+ trace_pflash_write(pfl->name, "clear status bits");
pfl->status = 0x0;
goto mode_read_array;
case 0x60: /* Block (un)lock */
- DPRINTF("%s: Block unlock\n", __func__);
+ trace_pflash_write(pfl->name, "block unlock");
break;
case 0x70: /* Status Register */
- DPRINTF("%s: Read status register\n", __func__);
+ trace_pflash_write(pfl->name, "read status register");
pfl->cmd = cmd;
return;
case 0x90: /* Read Device ID */
- DPRINTF("%s: Read Device information\n", __func__);
+ trace_pflash_write(pfl->name, "read device information");
pfl->cmd = cmd;
return;
case 0x98: /* CFI query */
- DPRINTF("%s: CFI query\n", __func__);
+ trace_pflash_write(pfl->name, "CFI query");
break;
case 0xe8: /* Write to buffer */
- DPRINTF("%s: Write to buffer\n", __func__);
+ trace_pflash_write(pfl->name, "write to buffer");
/* FIXME should save @offset, @width for case 1+ */
qemu_log_mask(LOG_UNIMP,
"%s: Write to buffer emulation is flawed\n",
@@ -516,10 +502,10 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
pfl->status |= 0x80; /* Ready! */
break;
case 0xf0: /* Probe for AMD flash */
- DPRINTF("%s: Probe for AMD flash\n", __func__);
+ trace_pflash_write(pfl->name, "probe for AMD flash");
goto mode_read_array;
case 0xff: /* Read Array */
- DPRINTF("%s: Read array mode\n", __func__);
+ trace_pflash_write(pfl->name, "read array mode");
goto mode_read_array;
default:
goto error_flash;
@@ -531,7 +517,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
switch (pfl->cmd) {
case 0x10: /* Single Byte Program */
case 0x40: /* Single Byte Program */
- DPRINTF("%s: Single Byte Program\n", __func__);
+ trace_pflash_write(pfl->name, "single byte program (1)");
if (!pfl->ro) {
pflash_data_write(pfl, offset, value, width, be);
pflash_update(pfl, offset, width);
@@ -563,7 +549,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
} else {
value = extract32(value, 0, pfl->bank_width * 8);
}
- DPRINTF("%s: block write of %x bytes\n", __func__, value);
+ trace_pflash_write_block(pfl->name, value);
pfl->counter = value;
pfl->wcycle++;
break;
@@ -577,7 +563,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
} else if (cmd == 0xff) { /* Read Array */
goto mode_read_array;
} else {
- DPRINTF("%s: Unknown (un)locking command\n", __func__);
+ trace_pflash_write(pfl->name, "unknown (un)locking command");
goto mode_read_array;
}
break;
@@ -585,7 +571,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
if (cmd == 0xff) { /* Read Array */
goto mode_read_array;
} else {
- DPRINTF("%s: leaving query mode\n", __func__);
+ trace_pflash_write(pfl->name, "leaving query mode");
}
break;
default:
@@ -613,7 +599,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
hwaddr mask = pfl->writeblock_size - 1;
mask = ~mask;
- DPRINTF("%s: block write finished\n", __func__);
+ trace_pflash_write(pfl->name, "block write finished");
pfl->wcycle++;
if (!pfl->ro) {
/* Flush the entire write buffer onto backing storage. */
@@ -652,7 +638,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
break;
default:
/* Should never happen */
- DPRINTF("%s: invalid write state\n", __func__);
+ trace_pflash_write(pfl->name, "invalid write state");
goto mode_read_array;
}
return;
@@ -663,7 +649,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
"\n", __func__, offset, pfl->wcycle, pfl->cmd, value);
mode_read_array:
- trace_pflash_mode_read_array();
+ trace_pflash_mode_read_array(pfl->name);
memory_region_rom_device_set_romd(&pfl->mem, true);
pfl->wcycle = 0;
pfl->cmd = 0x00; /* This model reset value for READ_ARRAY (not CFI) */
@@ -886,7 +872,7 @@ static void pflash_cfi01_system_reset(DeviceState *dev)
{
PFlashCFI01 *pfl = PFLASH_CFI01(dev);
- trace_pflash_reset();
+ trace_pflash_reset(pfl->name);
/*
* The command 0x00 is not assigned by the CFI open standard,
* but QEMU historically uses it for the READ_ARRAY command (0xff).
@@ -1041,7 +1027,7 @@ static void postload_update_cb(void *opaque, bool running, RunState state)
qemu_del_vm_change_state_handler(pfl->vmstate);
pfl->vmstate = NULL;
- DPRINTF("%s: updating bdrv for %s\n", __func__, pfl->name);
+ trace_pflash_postload_cb(pfl->name);
pflash_update(pfl, 0, pfl->sector_len * pfl->nb_blocs);
}