[Pdbg] [PATCH v2 05/24] libsbefifo: Drop cmd argument from sbefifo_operation
Amitay Isaacs
amitay at ozlabs.org
Thu Nov 7 13:27:49 AEDT 2019
The command is always the second uint32_t value in the msg buffer.
Extract it from the msg buffer, rather than passing it as argument.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libsbefifo/cmd_array.c | 4 ++--
libsbefifo/cmd_control.c | 2 +-
libsbefifo/cmd_generic.c | 8 ++++----
libsbefifo/cmd_instruction.c | 2 +-
libsbefifo/cmd_memory.c | 8 ++++----
libsbefifo/cmd_mpipl.c | 6 +++---
libsbefifo/cmd_register.c | 4 ++--
libsbefifo/cmd_ring.c | 6 +++---
libsbefifo/cmd_scom.c | 8 ++++----
libsbefifo/operation.c | 5 ++++-
libsbefifo/sbefifo_private.h | 2 +-
11 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/libsbefifo/cmd_array.c b/libsbefifo/cmd_array.c
index c5f5eec..75e294a 100644
--- a/libsbefifo/cmd_array.c
+++ b/libsbefifo/cmd_array.c
@@ -41,7 +41,7 @@ int sbefifo_control_fast_array(struct sbefifo_context *sctx, uint16_t target_typ
msg[2] = htobe32(target);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
if (rc)
return rc;
@@ -71,7 +71,7 @@ int sbefifo_control_trace_array(struct sbefifo_context *sctx, uint16_t target_ty
msg[3] = htobe32(oper);
out_len = 16 * 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 4 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 4 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
index abbfd73..51bf842 100644
--- a/libsbefifo/cmd_control.c
+++ b/libsbefifo/cmd_control.c
@@ -37,7 +37,7 @@ int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
msg[2] = htobe32(step);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_generic.c b/libsbefifo/cmd_generic.c
index f912e92..78e38b2 100644
--- a/libsbefifo/cmd_generic.c
+++ b/libsbefifo/cmd_generic.c
@@ -37,7 +37,7 @@ int sbefifo_get_ffdc(struct sbefifo_context *sctx, uint8_t **ffdc, uint32_t *ffd
/* We don't know how much data to expect, let's assume it's less than 32K */
out_len = 0x8000;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
@@ -72,7 +72,7 @@ int sbefifo_get_capabilities(struct sbefifo_context *sctx, uint32_t *version, ch
msg[1] = htobe32(cmd);
out_len = 23 * 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
@@ -118,7 +118,7 @@ int sbefifo_get_frequencies(struct sbefifo_context *sctx, uint32_t **freq, uint3
msg[1] = htobe32(cmd);
out_len = 8 * 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
@@ -156,7 +156,7 @@ int sbefifo_quiesce(struct sbefifo_context *sctx)
msg[1] = htobe32(cmd);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_instruction.c b/libsbefifo/cmd_instruction.c
index 5185982..c83cdd7 100644
--- a/libsbefifo/cmd_instruction.c
+++ b/libsbefifo/cmd_instruction.c
@@ -41,7 +41,7 @@ int sbefifo_control_insn(struct sbefifo_context *sctx, uint8_t core_id, uint8_t
msg[2] = htobe32(oper);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_memory.c b/libsbefifo/cmd_memory.c
index b20767f..e6fa579 100644
--- a/libsbefifo/cmd_memory.c
+++ b/libsbefifo/cmd_memory.c
@@ -75,7 +75,7 @@ int sbefifo_mem_get(struct sbefifo_context *sctx, uint64_t addr, uint32_t size,
msg[5] = htobe32(len);
out_len = len + extra_bytes + 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 6 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 6 * 4, &out, &out_len);
if (rc)
return rc;
@@ -143,7 +143,7 @@ int sbefifo_mem_put(struct sbefifo_context *sctx, uint64_t addr, uint8_t *data,
memcpy(&msg[6], data, data_len);
out_len = 1 * 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, (6+nwords) * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, (6+nwords) * 4, &out, &out_len);
if (rc)
return rc;
@@ -181,7 +181,7 @@ int sbefifo_occsram_get(struct sbefifo_context *sctx, uint32_t addr, uint32_t si
msg[4] = htobe32(len);
out_len = len + 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 5 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 5 * 4, &out, &out_len);
if (rc)
return rc;
@@ -229,7 +229,7 @@ int sbefifo_occsram_put(struct sbefifo_context *sctx, uint32_t addr, uint8_t *da
memcpy(&msg[6], data, data_len);
out_len = 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, (5+nwords) * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, (5+nwords) * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_mpipl.c b/libsbefifo/cmd_mpipl.c
index b5f9ea5..9e3d59b 100644
--- a/libsbefifo/cmd_mpipl.c
+++ b/libsbefifo/cmd_mpipl.c
@@ -36,7 +36,7 @@ int sbefifo_mpipl_enter(struct sbefifo_context *sctx)
msg[1] = htobe32(cmd);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
@@ -61,7 +61,7 @@ int sbefifo_mpipl_continue(struct sbefifo_context *sctx)
msg[1] = htobe32(cmd);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 2 * 4, &out, &out_len);
if (rc)
return rc;
@@ -89,7 +89,7 @@ int sbefifo_mpipl_stopclocks(struct sbefifo_context *sctx, uint16_t target_type,
msg[2] = htobe32(target);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_register.c b/libsbefifo/cmd_register.c
index 201ceb5..ba4815b 100644
--- a/libsbefifo/cmd_register.c
+++ b/libsbefifo/cmd_register.c
@@ -47,7 +47,7 @@ int sbefifo_register_get(struct sbefifo_context *sctx, uint8_t core_id, uint8_t
}
out_len = reg_count * 8;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+reg_count) * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+reg_count) * 4, &out, &out_len);
if (rc)
return rc;
@@ -102,7 +102,7 @@ int sbefifo_register_put(struct sbefifo_context *sctx, uint8_t core_id, uint8_t
}
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+3*reg_count) * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+3*reg_count) * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_ring.c b/libsbefifo/cmd_ring.c
index 8603e3f..7d239b5 100644
--- a/libsbefifo/cmd_ring.c
+++ b/libsbefifo/cmd_ring.c
@@ -40,7 +40,7 @@ int sbefifo_ring_get(struct sbefifo_context *sctx, uint32_t ring_addr, uint32_t
/* multiples of 64 bits */
out_len = (ring_len_bits + 63) / 8;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 5 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 5 * 4, &out, &out_len);
if (rc)
return rc;
@@ -77,7 +77,7 @@ int sbefifo_ring_put(struct sbefifo_context *sctx, uint16_t ring_mode, uint8_t *
memcpy(&msg[3], ring_data, ring_data_len);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+nwords) * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, (3+nwords) * 4, &out, &out_len);
if (rc)
return rc;
@@ -107,7 +107,7 @@ int sbefifo_ring_put_from_image(struct sbefifo_context *sctx, uint16_t target, u
msg[3] = htobe32(ring_word);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/cmd_scom.c b/libsbefifo/cmd_scom.c
index cc236ca..c0687ef 100644
--- a/libsbefifo/cmd_scom.c
+++ b/libsbefifo/cmd_scom.c
@@ -38,7 +38,7 @@ int sbefifo_scom_get(struct sbefifo_context *sctx, uint64_t addr, uint64_t *valu
msg[3] = htobe32(addr & 0xffffffff);
out_len = 2 * 4;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 4 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 4 * 4, &out, &out_len);
if (rc)
return rc;
@@ -73,7 +73,7 @@ int sbefifo_scom_put(struct sbefifo_context *sctx, uint64_t addr, uint64_t value
msg[3] = htobe32(value & 0xffffffff);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 6 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 6 * 4, &out, &out_len);
if (rc)
return rc;
@@ -103,7 +103,7 @@ int sbefifo_scom_modify(struct sbefifo_context *sctx, uint64_t addr, uint64_t va
msg[6] = htobe32(value & 0xffffffff);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 7 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 7 * 4, &out, &out_len);
if (rc)
return rc;
@@ -134,7 +134,7 @@ int sbefifo_scom_put_mask(struct sbefifo_context *sctx, uint64_t addr, uint64_t
msg[7] = htobe32(mask & 0xffffffff);
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 8 * 4, cmd, &out, &out_len);
+ rc = sbefifo_operation(sctx, (uint8_t *)msg, 8 * 4, &out, &out_len);
if (rc)
return rc;
diff --git a/libsbefifo/operation.c b/libsbefifo/operation.c
index 1ad577c..744dd6c 100644
--- a/libsbefifo/operation.c
+++ b/libsbefifo/operation.c
@@ -55,13 +55,14 @@ static int sbefifo_write(struct sbefifo_context *sctx, void *buf, size_t buflen)
}
int sbefifo_operation(struct sbefifo_context *sctx,
- uint8_t *msg, uint32_t msg_len, uint16_t cmd,
+ uint8_t *msg, uint32_t msg_len,
uint8_t **out, uint32_t *out_len)
{
uint8_t *buf;
size_t buflen;
uint32_t offset_word, header_word, status_word;
uint32_t offset;
+ uint32_t cmd;
int rc;
assert(msg);
@@ -78,6 +79,8 @@ int sbefifo_operation(struct sbefifo_context *sctx,
if (!buf)
return ENOMEM;
+ cmd = be32toh(*(uint32_t *)(msg + 4));
+
LOG("request: cmd=%08x, len=%u\n", cmd, msg_len);
rc = sbefifo_write(sctx, msg, msg_len);
diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
index 87416b7..2ff1a5b 100644
--- a/libsbefifo/sbefifo_private.h
+++ b/libsbefifo/sbefifo_private.h
@@ -76,7 +76,7 @@ void sbefifo_ffdc_clear(struct sbefifo_context *sctx);
void sbefifo_ffdc_set(struct sbefifo_context *sctx, uint32_t status, uint8_t *ffdc, uint32_t ffdc_len);
int sbefifo_operation(struct sbefifo_context *sctx,
- uint8_t *msg, uint32_t msg_len, uint16_t cmd,
+ uint8_t *msg, uint32_t msg_len,
uint8_t **out, uint32_t *out_len);
#ifdef LIBSBEFIFO_DEBUG
--
2.21.0
More information about the Pdbg
mailing list