[Skiboot] [PATCH v5 26/27] Add more sparse endian annotations
Nicholas Piggin
npiggin at gmail.com
Tue Oct 15 14:07:16 AEDT 2019
This fixes quite a few sparse endian annotations across the tree.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
core/device.c | 17 +++++++++--------
core/fdt.c | 2 +-
core/interrupts.c | 3 ++-
core/mem_region.c | 2 +-
core/pci.c | 2 +-
core/trace.c | 3 ++-
hdata/fsp.c | 2 +-
hdata/memory.c | 8 ++++----
hdata/spira.c | 2 +-
hw/ast-bmc/ast-sf-ctrl.c | 5 +++--
hw/imc.c | 4 ++--
hw/psi.c | 2 +-
hw/slw.c | 10 +++++-----
include/ipmi.h | 2 +-
include/opal-internal.h | 4 ++--
libflash/mbox-flash.c | 8 ++++----
libstb/secureboot.c | 2 +-
platforms/astbmc/vesnin.c | 8 ++++----
18 files changed, 45 insertions(+), 41 deletions(-)
diff --git a/core/device.c b/core/device.c
index f48a80159..6c7794677 100644
--- a/core/device.c
+++ b/core/device.c
@@ -514,12 +514,12 @@ struct dt_property *__dt_add_property_cells(struct dt_node *node,
int count, ...)
{
struct dt_property *p;
- u32 *val;
+ fdt32_t *val;
unsigned int i;
va_list args;
p = new_property(node, name, count * sizeof(u32));
- val = (u32 *)p->prop;
+ val = (fdt32_t *)p->prop;
va_start(args, count);
for (i = 0; i < count; i++)
val[i] = cpu_to_fdt32(va_arg(args, u32));
@@ -532,12 +532,12 @@ struct dt_property *__dt_add_property_u64s(struct dt_node *node,
int count, ...)
{
struct dt_property *p;
- u64 *val;
+ fdt64_t *val;
unsigned int i;
va_list args;
p = new_property(node, name, count * sizeof(u64));
- val = (u64 *)p->prop;
+ val = (fdt64_t *)p->prop;
va_start(args, count);
for (i = 0; i < count; i++)
val[i] = cpu_to_fdt64(va_arg(args, u64));
@@ -590,7 +590,7 @@ u32 dt_property_get_cell(const struct dt_property *prop, u32 index)
{
assert(prop->len >= (index+1)*sizeof(u32));
/* Always aligned, so this works. */
- return fdt32_to_cpu(((const u32 *)prop->prop)[index]);
+ return fdt32_to_cpu(((const fdt32_t *)prop->prop)[index]);
}
u64 dt_property_get_u64(const struct dt_property *prop, u32 index)
@@ -918,7 +918,7 @@ void dt_expand(const void *fdt)
u64 dt_get_number(const void *pdata, unsigned int cells)
{
- const u32 *p = pdata;
+ const __be32 *p = pdata;
u64 ret = 0;
while(cells--)
@@ -1095,6 +1095,7 @@ void dt_adjust_subtree_phandle(struct dt_node *dev,
struct dt_node *node;
struct dt_property *prop;
u32 phandle, max_phandle = 0, import_phandle = new_phandle();
+ __be32 p;
const char **name;
dt_for_each_node(dev, node) {
@@ -1117,8 +1118,8 @@ void dt_adjust_subtree_phandle(struct dt_node *dev,
continue;
phandle = dt_prop_get_u32(node, *name);
phandle += import_phandle;
- phandle = cpu_to_be32(phandle);
- memcpy((char *)&prop->prop, &phandle, prop->len);
+ p = cpu_to_be32(phandle);
+ memcpy((char *)&prop->prop, &p, prop->len);
}
}
diff --git a/core/fdt.c b/core/fdt.c
index e093e8b54..92fdc5b03 100644
--- a/core/fdt.c
+++ b/core/fdt.c
@@ -136,7 +136,7 @@ static void flatten_dt_node(void *fdt, const struct dt_node *root,
static void create_dtb_reservemap(void *fdt, const struct dt_node *root)
{
uint64_t base, size;
- const uint64_t *ranges;
+ const __be64 *ranges;
const struct dt_property *prop;
int i;
diff --git a/core/interrupts.c b/core/interrupts.c
index d4a2c3124..681483209 100644
--- a/core/interrupts.c
+++ b/core/interrupts.c
@@ -194,7 +194,8 @@ void add_opal_interrupts(void)
{
struct irq_source *is;
unsigned int i, ns, tns = 0, count = 0;
- uint32_t *irqs = NULL, isn;
+ uint32_t isn;
+ __be32 *irqs = NULL;
char *names = NULL;
lock(&irq_lock);
diff --git a/core/mem_region.c b/core/mem_region.c
index 47d754455..e331e17b2 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -1447,7 +1447,7 @@ void mem_region_add_dt_reserved(void)
struct mem_region *region;
void *names, *ranges;
struct dt_node *node;
- uint64_t *range;
+ fdt64_t *range;
char *name;
names_len = 0;
diff --git a/core/pci.c b/core/pci.c
index 718569d64..4d0671661 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1332,7 +1332,7 @@ void pci_std_swizzle_irq_map(struct dt_node *np,
struct pci_lsi_state *lstate,
uint8_t swizzle)
{
- uint32_t *map, *p;
+ __be32 *p, *map;
int dev, irq, esize, edevcount;
size_t map_size;
diff --git a/core/trace.c b/core/trace.c
index 614be08d7..dc746b833 100644
--- a/core/trace.c
+++ b/core/trace.c
@@ -158,7 +158,8 @@ void trace_add(union trace *trace, u8 type, u16 len)
static void trace_add_dt_props(void)
{
unsigned int i;
- u64 *prop, tmask;
+ fdt64_t *prop;
+ u64 tmask;
struct dt_node *exports;
char tname[256];
diff --git a/hdata/fsp.c b/hdata/fsp.c
index fe36eef18..d351f5ac5 100644
--- a/hdata/fsp.c
+++ b/hdata/fsp.c
@@ -174,7 +174,7 @@ static uint32_t fsp_create_link(const struct spss_iopath *iopath, int index,
static void fsp_create_links(const void *spss, int index,
struct dt_node *fsp_node)
{
- uint32_t *links = NULL;
+ __be32 *links = NULL;
unsigned int i, lp, lcount = 0;
int count;
diff --git a/hdata/memory.c b/hdata/memory.c
index 7839dea3f..9c588ff61 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -329,8 +329,8 @@ static void vpd_add_ram_area(const struct HDIF_common_hdr *msarea)
static void vpd_parse_spd(struct dt_node *dimm, const char *spd, u32 size)
{
- u16 *vendor;
- u32 *sn;
+ __be16 *vendor;
+ __be32 *sn;
/* SPD is too small */
if (size < 512) {
@@ -355,14 +355,14 @@ static void vpd_parse_spd(struct dt_node *dimm, const char *spd, u32 size)
dt_add_property_cells(dimm, "product-version", spd[0x15d]);
/* Serial number */
- sn = (u32 *)&spd[0x145];
+ sn = (__be32 *)&spd[0x145];
dt_add_property_cells(dimm, "serial-number", be32_to_cpu(*sn));
/* Part number */
dt_add_property_nstr(dimm, "part-number", &spd[0x149], 20);
/* Module manufacturer ID */
- vendor = (u16 *)&spd[0x140];
+ vendor = (__be16 *)&spd[0x140];
dt_add_property_cells(dimm, "manufacturer-id", be16_to_cpu(*vendor));
}
diff --git a/hdata/spira.c b/hdata/spira.c
index 6900b71e8..cde81cd9f 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -993,7 +993,7 @@ static void opal_dump_add_mpipl_boot(const struct iplparams_iplparams *p)
static void add_opal_dump_node(void)
{
- u64 fw_load_area[4];
+ __be64 fw_load_area[4];
struct dt_node *node;
opal_node = dt_new_check(dt_root, "ibm,opal");
diff --git a/hw/ast-bmc/ast-sf-ctrl.c b/hw/ast-bmc/ast-sf-ctrl.c
index ece847d6b..e97315067 100644
--- a/hw/ast-bmc/ast-sf-ctrl.c
+++ b/hw/ast-bmc/ast-sf-ctrl.c
@@ -169,12 +169,13 @@ static void ast_sf_end_cmd(struct ast_sf_ctrl *ct)
static int ast_sf_send_addr(struct ast_sf_ctrl *ct, uint32_t addr)
{
const void *ap;
+ __be32 tmp;
/* Layout address MSB first in memory */
- addr = cpu_to_be32(addr);
+ tmp = cpu_to_be32(addr);
/* Send the right amount of bytes */
- ap = (char *)&addr;
+ ap = (char *)&tmp;
if (ct->mode_4b)
return ast_copy_to_ahb(ct->flash, ap, 4);
diff --git a/hw/imc.c b/hw/imc.c
index 16b060d39..36c2cf3a5 100644
--- a/hw/imc.c
+++ b/hw/imc.c
@@ -448,8 +448,8 @@ void imc_catalog_preload(void)
static void imc_dt_update_nest_node(struct dt_node *dev)
{
struct proc_chip *chip;
- uint64_t *base_addr = NULL;
- uint32_t *chipids = NULL;
+ __be64 *base_addr = NULL;
+ __be32 *chipids = NULL;
int i=0, nr_chip = nr_chips();
struct dt_node *node;
const struct dt_property *type;
diff --git a/hw/psi.c b/hw/psi.c
index 3b497a092..381b35eda 100644
--- a/hw/psi.c
+++ b/hw/psi.c
@@ -782,7 +782,7 @@ static void psi_activate_phb(struct psi *psi)
static void psi_create_p9_int_map(struct psi *psi, struct dt_node *np)
{
- uint32_t map[P9_PSI_NUM_IRQS][4];
+ __be32 map[P9_PSI_NUM_IRQS][4];
int i;
for (i = 0; i < P9_PSI_NUM_IRQS; i++) {
diff --git a/hw/slw.c b/hw/slw.c
index ed8a5f9e6..336dc906d 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -729,8 +729,8 @@ void add_cpu_idle_state_properties(void)
bool has_stop_inst = false;
u8 i;
- u64 *pm_ctrl_reg_val_buf;
- u64 *pm_ctrl_reg_mask_buf;
+ fdt64_t *pm_ctrl_reg_val_buf;
+ fdt64_t *pm_ctrl_reg_mask_buf;
u32 supported_states_mask;
u32 opal_disabled_states_mask = ~0xEC000000; /* all but stop11 */
const char* nvram_disable_str;
@@ -743,9 +743,9 @@ void add_cpu_idle_state_properties(void)
/* Buffers to hold idle state properties */
char *name_buf, *alloced_name_buf;
- u32 *latency_ns_buf;
- u32 *residency_ns_buf;
- u32 *flags_buf;
+ fdt32_t *latency_ns_buf;
+ fdt32_t *residency_ns_buf;
+ fdt32_t *flags_buf;
prlog(PR_DEBUG, "CPU idle state device tree init\n");
diff --git a/include/ipmi.h b/include/ipmi.h
index 4f5134745..50deec01a 100644
--- a/include/ipmi.h
+++ b/include/ipmi.h
@@ -164,7 +164,7 @@ struct ipmi_msg {
};
struct ipmi_backend {
- __be64 opal_event_ipmi_recv;
+ uint64_t opal_event_ipmi_recv;
struct ipmi_msg *(*alloc_msg)(size_t, size_t);
void (*free_msg)(struct ipmi_msg *);
int (*queue_msg)(struct ipmi_msg *);
diff --git a/include/opal-internal.h b/include/opal-internal.h
index fd2187f09..83bf77084 100644
--- a/include/opal-internal.h
+++ b/include/opal-internal.h
@@ -49,8 +49,8 @@ extern struct dt_node *opal_node;
extern void opal_table_init(void);
extern void opal_update_pending_evt(uint64_t evt_mask, uint64_t evt_values);
-__be64 opal_dynamic_event_alloc(void);
-void opal_dynamic_event_free(__be64 event);
+uint64_t opal_dynamic_event_alloc(void);
+void opal_dynamic_event_free(uint64_t event);
extern void add_opal_node(void);
#define opal_register(token, func, nargs) \
diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 5df020f55..3fd2c057a 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -239,23 +239,23 @@ static void msg_put_u8(struct bmc_mbox_msg *msg, int i, uint8_t val)
static uint16_t msg_get_u16(struct bmc_mbox_msg *msg, int i)
{
- return le16_to_cpu(*(uint16_t *)(&msg->args[i]));
+ return le16_to_cpu(*(__le16 *)(&msg->args[i]));
}
static void msg_put_u16(struct bmc_mbox_msg *msg, int i, uint16_t val)
{
- uint16_t tmp = cpu_to_le16(val);
+ __le16 tmp = cpu_to_le16(val);
memcpy(&msg->args[i], &tmp, sizeof(val));
}
static uint32_t msg_get_u32(struct bmc_mbox_msg *msg, int i)
{
- return le32_to_cpu(*(uint32_t *)(&msg->args[i]));
+ return le32_to_cpu(*(__le32 *)(&msg->args[i]));
}
static void msg_put_u32(struct bmc_mbox_msg *msg, int i, uint32_t val)
{
- uint32_t tmp = cpu_to_le32(val);
+ __le32 tmp = cpu_to_le32(val);
memcpy(&msg->args[i], &tmp, sizeof(val));
}
diff --git a/libstb/secureboot.c b/libstb/secureboot.c
index bfc98f2ae..022e2aa09 100644
--- a/libstb/secureboot.c
+++ b/libstb/secureboot.c
@@ -163,7 +163,7 @@ void secureboot_init(void)
int secureboot_verify(enum resource_id id, void *buf, size_t len)
{
const char *name;
- uint64_t log;
+ __be64 log;
int rc = -1;
name = flash_map_resource_name(id);
diff --git a/platforms/astbmc/vesnin.c b/platforms/astbmc/vesnin.c
index bd412aa8d..b1d909e29 100644
--- a/platforms/astbmc/vesnin.c
+++ b/platforms/astbmc/vesnin.c
@@ -38,13 +38,13 @@
* All fields have Big Endian byte order.
*/
struct pciinv_device {
- uint16_t domain_num;
+ beint16_t domain_num;
uint8_t bus_num;
uint8_t device_num;
uint8_t func_num;
- uint16_t vendor_id;
- uint16_t device_id;
- uint32_t class_code;
+ beint16_t vendor_id;
+ beint16_t device_id;
+ beint32_t class_code;
uint8_t revision;
} __packed;
--
2.23.0
More information about the Skiboot
mailing list