ppc/pnv: Add PNOR support
cover ppc/pnv: Add PNOR support
Hello,
On a POWERPC PowerNV system, the host firmware is stored in a PNOR flash chip which contents is mapped on the LPC bus. This model adds a simple dummy device to map the contents of a block device in the host address space and activates HIOMAP support on the QEMU PowerNV machine to let the host negotiate with the BMC the access to the mapping.
The command options to activate these models in QEMU:
-device ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0,irq=10 \ -drive file=./witherspoon.pnor,format=raw,if=mtd
The last two patches add the logic to load in the machine memory the PAYLOAD partition (skiboot) from an OpenPOWER firmware file. These should be considered as RFCs as the firmware file could have a different format. Something to discuss.
Thanks,
C.
Cédric Le Goater (5):
ppc/pnv: Add a PNOR model
ipmi: Add support to customize OEM functions
ppc/pnv: Add HIOMAP commands
libxz: Add XZ Embedded library for PPC
ppc/pnv: Read the PNOR partition table
include/hw/ipmi/ipmi.h | 36 ++ include/hw/ppc/ffs.h | 150 +++++ include/hw/ppc/pnv.h | 4 + include/hw/ppc/pnv_pnor.h | 36 ++ libxz/xz.h | 304 ++++++++++ libxz/xz_config.h | 124 ++++ libxz/xz_lzma2.h | 204 +++++++ libxz/xz_private.h | 156 +++++ libxz/xz_stream.h | 62 ++ hw/ipmi/ipmi_bmc_sim.c | 41 +- hw/ppc/pnv.c | 48 +- hw/ppc/pnv_bmc.c | 101 ++++ hw/ppc/pnv_lpc.c | 13 + hw/ppc/pnv_pnor.c | 291 +++++++++ libxz/xz_crc32.c | 59 ++ libxz/xz_dec_lzma2.c | 1171 +++++++++++++++++++++++++++++++++++++ libxz/xz_dec_stream.c | 847 +++++++++++++++++++++++++++ hw/ppc/Makefile.objs | 4 +- libxz/Makefile.objs | 1 + target/ppc/Makefile.objs | 1 + 20 files changed, 3606 insertions(+), 47 deletions(-) create mode 100644 include/hw/ppc/ffs.h create mode 100644 include/hw/ppc/pnv_pnor.h create mode 100644 libxz/xz.h create mode 100644 libxz/xz_config.h create mode 100644 libxz/xz_lzma2.h create mode 100644 libxz/xz_private.h create mode 100644 libxz/xz_stream.h create mode 100644 hw/ppc/pnv_pnor.c create mode 100644 libxz/xz_crc32.c create mode 100644 libxz/xz_dec_lzma2.c create mode 100644 libxz/xz_dec_stream.c create mode 100644 libxz/Makefile.objs
Signature · 1 line
2.21.0
PATCH 1/5 ppc/pnv: Add a PNOR model
From: Cédric Le Goater <[email protected]>
On a POWERPC PowerNV system, the host firmware is stored in a PNOR flash chip which contents is mapped on the LPC bus. This model adds a simple dummy device to map the contents of a block device in the host address space.
--- include/hw/ppc/pnv.h | 3 + include/hw/ppc/pnv_pnor.h | 25 +++++++ hw/ppc/pnv.c | 14 ++++ hw/ppc/pnv_pnor.c | 135 ++++++++++++++++++++++++++++++++++++++ hw/ppc/Makefile.objs | 4 +- 5 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 include/hw/ppc/pnv_pnor.h create mode 100644 hw/ppc/pnv_pnor.c
include/hw/ppc/pnv.h +3 -0
@@ -24,6 +24,7 @@#include "hw/sysbus.h" #include "hw/ipmi/ipmi.h" #include "hw/ppc/pnv_lpc.h" +#include "hw/ppc/pnv_pnor.h" #include "hw/ppc/pnv_psi.h" #include "hw/ppc/pnv_occ.h" #include "hw/ppc/pnv_homer.h"
@@ -173,6 +174,8 @@ typedef struct PnvMachineState {IPMIBmc *bmc;Notifier powerdown_notifier; + +PnvPnor *pnor; } PnvMachineState;static inline bool pnv_chip_is_power9 (const PnvChip *chip)
include/hw/ppc/pnv_pnor.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* QEMU PowerNV PNOR simple model +* +* Copyright (c) 2019, IBM Corporation. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +*/ +#ifndef _PPC_PNV_PNOR_H +#define _PPC_PNV_PNOR_H + +#define TYPE_PNV_PNOR "pnv-pnor" +#define PNV_PNOR (obj) OBJECT_CHECK(PnvPnor, (obj), TYPE_PNV_PNOR) + +typedef struct PnvPnor { +SysBusDevice parent_obj; + +BlockBackend *blk; + +uint8_t *storage; +uint32_t size; +MemoryRegion mmio; +}PnvPnor ; + +#endif /* _PPC_PNV_PNOR_H */
hw/ppc/pnv.c +14 -0
@@ -44,6 +44,7 @@#include "hw/ppc/xics.h" #include "hw/qdev-properties.h" #include "hw/ppc/pnv_xscom.h" +#include "hw/ppc/pnv_pnor.h" #include "hw/isa/isa.h" #include "hw/boards.h"
@@ -633,6 +634,8 @@ static void pnv_init(MachineState *machine)long fw_size;int i;char *chip_typename; +DriveInfo *pnor =drive_get (IF_MTD ,0 ,0 ); +DeviceState *dev;/* allocate RAM */ if (machine->ram_size < (1 * GiB)) {
@@ -644,6 +647,17 @@ static void pnv_init(MachineState *machine) machine->ram_size);memory_region_add_subregion (get_system_memory (),0 , ram); +/* +* Create our simple PNOR device +*/ + dev =qdev_create (NULL ,TYPE_PNV_PNOR ); +if (pnor) { +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (pnor), + &error_abort); + } +qdev_init_nofail (dev); + pnv->pnor =PNV_PNOR (dev); +/* load skiboot firmware */ if (bios_name ==NULL ) { bios_name =FW_FILE_NAME ;
hw/ppc/pnv_pnor.c new file +135 -0
135 lines not on this page · raw message
hw/ppc/Makefile.objs +3 -1
@@ -9,7 +9,9 @@ obj-$(CONFIG_PSERIES) += spapr_tpm_proxy.o obj-$(CONFIG_SPAPR_RNG) += spapr_rng.o # IBM PowerNV obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o pnv_lpc.o pnv_psi.o pnv_occ.o pnv_bmc.o -obj-$(CONFIG_POWERNV) += pnv_homer.o +obj-$(CONFIG_POWERNV) += pnv_homer.o pnv_pnor.o + + ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o spapr_pci_nvlink2.o endif
Signature · 1 line
2.21.0
David Gibson
AppliedRe: [PATCH 1/5] ppc/pnv: Add a PNOR model
Quoted 8 lines · Cédric Le Goater
From: Cédric Le Goater <[email protected]>
On a POWERPC PowerNV system, the host firmware is stored in a PNOR flash chip which contents is mapped on the LPC bus. This model adds a simple dummy device to map the contents of a block device in the host address space.
Signed-off-by Cédric Le Goater <[email protected]>
Applied to ppc-for-4.2. The rest of the series will need acks for the generic IPMI changes, of course.
Quoted 257 lines
--- include/hw/ppc/pnv.h | 3 + include/hw/ppc/pnv_pnor.h | 25 +++++++ hw/ppc/pnv.c | 14 ++++ hw/ppc/pnv_pnor.c | 135 ++++++++++++++++++++++++++++++++++++++ hw/ppc/Makefile.objs | 4 +- 5 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 include/hw/ppc/pnv_pnor.h create mode 100644 hw/ppc/pnv_pnor.cinclude/hw/ppc/pnv.h +3
-0@@ -24,6 +24,7 @@#include "hw/sysbus.h" #include "hw/ipmi/ipmi.h" #include "hw/ppc/pnv_lpc.h" +#include "hw/ppc/pnv_pnor.h" #include "hw/ppc/pnv_psi.h" #include "hw/ppc/pnv_occ.h" #include "hw/ppc/pnv_homer.h" @@ -173,6 +174,8 @@ typedef struct PnvMachineState {IPMIBmc *bmc;Notifier powerdown_notifier; + +PnvPnor *pnor; } PnvMachineState;static inline bool pnv_chip_is_power9 (const PnvChip *chip)include/hw/ppc/pnv_pnor.h new file +25
-0@@ -0,0 +1,25 @@ +/* +* QEMU PowerNV PNOR simple model +* +* Copyright (c) 2019, IBM Corporation. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +*/ +#ifndef _PPC_PNV_PNOR_H +#define _PPC_PNV_PNOR_H + +#define TYPE_PNV_PNOR "pnv-pnor" +#define PNV_PNOR (obj) OBJECT_CHECK(PnvPnor, (obj), TYPE_PNV_PNOR) + +typedef struct PnvPnor { +SysBusDevice parent_obj; + +BlockBackend *blk; + +uint8_t *storage; +uint32_t size; +MemoryRegion mmio; +}PnvPnor ; + +#endif /* _PPC_PNV_PNOR_H */ hw/ppc/pnv.c +14
-0@@ -44,6 +44,7 @@#include "hw/ppc/xics.h" #include "hw/qdev-properties.h" #include "hw/ppc/pnv_xscom.h" +#include "hw/ppc/pnv_pnor.h" #include "hw/isa/isa.h" #include "hw/boards.h" @@ -633,6 +634,8 @@ static void pnv_init(MachineState *machine)long fw_size;int i;char *chip_typename; +DriveInfo *pnor =drive_get (IF_MTD ,0 ,0 ); +DeviceState *dev;/* allocate RAM */ if (machine->ram_size < (1 * GiB)) {@@ -644,6 +647,17 @@ static void pnv_init(MachineState *machine) machine->ram_size);memory_region_add_subregion (get_system_memory (),0 , ram); +/* +* Create our simple PNOR device +*/ + dev =qdev_create (NULL ,TYPE_PNV_PNOR ); +if (pnor) { +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (pnor), + &error_abort); + } +qdev_init_nofail (dev); + pnv->pnor =PNV_PNOR (dev); +/* load skiboot firmware */ if (bios_name ==NULL ) { bios_name =FW_FILE_NAME ;hw/ppc/pnv_pnor.c new file +135
-0@@ -0,0 +1,135 @@ +/* +* QEMU PowerNV PNOR simple model +* +* Copyright (c) 2015-2019, IBM Corporation. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "sysemu/block-backend.h" +#include "sysemu/blockdev.h" +#include "hw/loader.h" +#include "hw/ppc/pnv_pnor.h" +#include "hw/qdev-properties.h" + +static uint64_t pnv_pnor_read (void *opaque,hwaddr addr,unsigned size) +{ +PnvPnor *s =PNV_PNOR (opaque); +uint64_t ret =0 ; +int i; + +for (i =0 ; i < size; i++) { + ret |= (uint64_t ) s->storage[addr + i] << (8 * (size - i -1 )); + } + +return ret; +} + +static void pnv_pnor_update (PnvPnor *s,int offset,int size) +{ +int offset_end; + +if (s->blk) { +return ; + } + + offset_end = offset + size; + offset =QEMU_ALIGN_DOWN (offset,BDRV_SECTOR_SIZE ); + offset_end =QEMU_ALIGN_UP (offset_end,BDRV_SECTOR_SIZE ); + +blk_pwrite (s->blk, offset, s->storage + offset, + offset_end - offset,0 ); +} + +static void pnv_pnor_write (void *opaque,hwaddr addr,uint64_t data, +unsigned size) +{ +PnvPnor *s =PNV_PNOR (opaque); +int i; + +for (i =0 ; i < size; i++) { + s->storage[addr + i] = (data >> (8 * (size - i -1 ))) &0xFF ; + } +pnv_pnor_update (s, addr, size); +} + +/* +* TODO: Check endianness: skiboot is BIG, Aspeed AHB is LITTLE, flash +* is BIG. +*/ +static const MemoryRegionOps pnv_pnor_ops = { + .read = pnv_pnor_read, + .write = pnv_pnor_write, + .endianness =DEVICE_BIG_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, +}; + +static void pnv_pnor_realize (DeviceState *dev,Error **errp) +{ +PnvPnor *s =PNV_PNOR (dev); +int ret; + +if (s->blk) { +uint64_t perm =BLK_PERM_CONSISTENT_READ | + (blk_is_read_only (s->blk) ?0 :BLK_PERM_WRITE ); + ret =blk_set_perm (s->blk, perm,BLK_PERM_ALL , errp); +if (ret <0 ) { +return ; + } + + s->size =blk_getlength (s->blk); +if (s->size <=0 ) { +error_setg (errp,"failed to get flash size" ); +return ; + } + + s->storage =blk_blockalign (s->blk, s->size); + +if (blk_pread (s->blk,0 , s->storage, s->size) != s->size) { +error_setg (errp,"failed to read the initial flash content" ); +return ; + } + }else { + s->storage =blk_blockalign (NULL , s->size); +memset (s->storage,0xFF , s->size); + } + +memory_region_init_io (&s->mmio,OBJECT (s), &pnv_pnor_ops, s, +TYPE_PNV_PNOR , s->size); +} + +static Property pnv_pnor_properties[] = { +DEFINE_PROP_UINT32 ("size" , PnvPnor, size,128 <<20 ), +DEFINE_PROP_DRIVE ("drive" , PnvPnor, blk), +DEFINE_PROP_END_OF_LIST (), +}; + +static void pnv_pnor_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->realize = pnv_pnor_realize; + dc->props = pnv_pnor_properties; +} + +static const TypeInfo pnv_pnor_info = { + .name =TYPE_PNV_PNOR , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (PnvPnor), + .class_init = pnv_pnor_class_init, +}; + +static void pnv_pnor_register_types (void ) +{ +type_register_static (&pnv_pnor_info); +} + +type_init (pnv_pnor_register_types)hw/ppc/Makefile.objs +3
-1@@ -9,7 +9,9 @@ obj-$(CONFIG_PSERIES) += spapr_tpm_proxy.o obj-$(CONFIG_SPAPR_RNG) += spapr_rng.o # IBM PowerNV obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o pnv_lpc.o pnv_psi.o pnv_occ.o pnv_bmc.o -obj-$(CONFIG_POWERNV) += pnv_homer.o +obj-$(CONFIG_POWERNV) += pnv_homer.o pnv_pnor.o + + ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o spapr_pci_nvlink2.o endif
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 2/5 ipmi: Add support to customize OEM functions
In reply to Cédric Le GoaterThe routine ipmi_register_oem_netfn() lets external modules register command handlers for OEM functions. Required for the PowerNV machine.
--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)
include/hw/ipmi/ipmi.h +36 -0
@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ; + +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif
hw/ipmi/ipmi_bmc_sim.c +6 -35
69 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 2 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.
Comments inline.
Quoted 13 lines
Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +0
-0
include/hw/ipmi/ipmi.h int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, · line 268
Quoted 4 lines
include/hw/ipmi/ipmi.h +1
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ;
This type isn't very useful outside of the simulator, but changes for that can come as they are needed. I don't see an easy way to avoid putting it here.
Quoted 102 lines
include/hw/ipmi/ipmi.h +35
-0+ +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +1
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {
hw/ipmi/ipmi_bmc_sim.c static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn, · line 612
Quoted 7 lines
hw/ipmi/ipmi_bmc_sim.c +4
-0@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +}
I think I would prefer just exposing ipmi_register_netfn() and maybe rename it ipmi_sim_register_netfn() or something like that. There may be other netfns needed in the future.
But with that change, this looks good to me:
Quoted 7 lines
hw/ipmi/ipmi_bmc_sim.c +1
-0+static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)Signature · 1 line
2.21.0
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 142 lines · Corey Minyard
Quoted 2 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.Comments inline.
Quoted 13 lines
Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +0
-0include/hw/ipmi/ipmi.h int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, · line 268
Quoted 4 lines
include/hw/ipmi/ipmi.h +1
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ;This type isn't very useful outside of the simulator, but changes for that can come as they are needed. I don't see an easy way to avoid putting it here.
Quoted 102 lines
include/hw/ipmi/ipmi.h +35
-0+ +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +1
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {hw/ipmi/ipmi_bmc_sim.c static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn, · line 612
Quoted 7 lines
hw/ipmi/ipmi_bmc_sim.c +4
-0@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +}I think I would prefer just exposing
ipmi_register_netfn()and maybe rename itipmi_sim_register_netfn()or something like that. There may be other netfns needed in the future.
Quoted 3 lines
But with that change, this looks good to me:
Reviewed-by Corey Minyard <[email protected]>
What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
Quoted 6 lines
Quoted 5 lines
hw/ipmi/ipmi_bmc_sim.c +1
-0+static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 143 lines · David Gibson
Quoted 142 lines · Corey Minyard
Quoted 2 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.Comments inline.
Quoted 13 lines
Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +0
-0include/hw/ipmi/ipmi.h int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, · line 268
Quoted 4 lines
include/hw/ipmi/ipmi.h +1
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ;This type isn't very useful outside of the simulator, but changes for that can come as they are needed. I don't see an easy way to avoid putting it here.
Quoted 102 lines
include/hw/ipmi/ipmi.h +35
-0+ +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +1
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {hw/ipmi/ipmi_bmc_sim.c static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn, · line 612
Quoted 7 lines
hw/ipmi/ipmi_bmc_sim.c +4
-0@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +}I think I would prefer just exposing
ipmi_register_netfn()and maybe rename itipmi_sim_register_netfn()or something like that. There may be other netfns needed in the future.
Quoted 7 lines
Quoted 3 lines
But with that change, this looks good to me:
Reviewed-by Corey Minyard <[email protected]>What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
I have an IPMI tree for this. I was assuming it was going in to the PPC tree, but it's not big deal.
-corey
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
hw/ipmi/ipmi_bmc_sim.c +1
-0+static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 146 lines · Corey Minyard
Quoted 145 lines · David Gibson
Quoted 144 lines · Corey Minyard
Quoted 2 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.Comments inline.
Quoted 13 lines
Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +0
-0include/hw/ipmi/ipmi.h int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, · line 268
Quoted 4 lines
include/hw/ipmi/ipmi.h +1
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ;This type isn't very useful outside of the simulator, but changes for that can come as they are needed. I don't see an easy way to avoid putting it here.
Quoted 102 lines
include/hw/ipmi/ipmi.h +35
-0+ +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +1
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {hw/ipmi/ipmi_bmc_sim.c static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn, · line 612
Quoted 7 lines
hw/ipmi/ipmi_bmc_sim.c +4
-0@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +}I think I would prefer just exposing
ipmi_register_netfn()and maybe rename itipmi_sim_register_netfn()or something like that. There may be other netfns needed in the future.But with that change, this looks good to me:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Reviewed-by Corey Minyard <[email protected]>What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
I have an IPMI tree for this. I was assuming it was going in to the PPC tree, but it's not big deal.
I'd be more comfortable if the generic ipmi changes went through the ipmi tree. Note that I've moved the initial ppc specific patch from my ppc-for-4.2 tree to my ppc-for-4.3 tree, since it missed my previous pull request and it's not really post-freeze material.
Quoted 13 lines
-corey
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
hw/ipmi/ipmi_bmc_sim.c +1
-0+static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
I have an IPMI tree for this. I was assuming it was going in to the PPC tree, but it's not big deal.
I'd be more comfortable if the generic ipmi changes went through the ipmi tree.
Here is the patch :
http://patchwork.ozlabs.org/patch/1185187/
Quoted 3 lines
Note that I've moved the initial ppc specific patch from my ppc-for-4.2 tree to my ppc-for-4.3 tree, since it missed my previous pull request and it's not really post-freeze material.
OK. I was wondering where it had gone.
Thanks,
C.
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 7 lines · Cédric Le Goater
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
I have an IPMI tree for this. I was assuming it was going in to the PPC tree, but it's not big deal.
Quoted 6 lines
Quoted 2 lines
I'd be more comfortable if the generic ipmi changes went through the ipmi tree.
Here is the patch :
http://patchwork.ozlabs.org/patch/1185187/
Ok, I have this in my tree.
I assume there is nothing like the linux-next tree for qemu, right?
-corey
Quoted 11 lines
Quoted 5 lines
Note that I've moved the initial ppc specific patch from my ppc-for-4.2 tree to my ppc-for-4.3 tree, since it missed my previous pull request and it's not really post-freeze material.
OK. I was wondering where it had gone.
Thanks,
C.
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 11 lines · Corey Minyard
Quoted 10 lines · Cédric Le Goater
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
What's the plan for merging this, once it's ready? Is there an IPMI tree for it to be staged in? If not I could take it through the ppc tree, but I'd need some Acked-bys in that case.
I have an IPMI tree for this. I was assuming it was going in to the PPC tree, but it's not big deal.
I'd be more comfortable if the generic ipmi changes went through the ipmi tree.
Quoted 7 lines
Quoted 3 lines
Here is the patch :
http://patchwork.ozlabs.org/patch/1185187/Ok, I have this in my tree.
I assume there is nothing like the linux-next tree for qemu, right?
no. These IPMI OEM commands are handled by the OPAL firmware only.
C.
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
In reply to Cédric Le GoaterQuoted 5 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
David,
Sorry, I wasn't thinking on this. I should have realized what you wanted. So, this is:
Quoted 130 lines
--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +36
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ; + +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +6
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +} +static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)Signature · 1 line
2.21.0
Re: [PATCH 2/5] ipmi: Add support to customize OEM functions
Quoted 7 lines · Corey Minyard
Quoted 5 lines · Cédric Le Goater
The routine
ipmi_register_oem_netfn()lets external modules register command handlers for OEM functions. Required for the PowerNV machine.Cc Corey Minyard <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 6 lines
David,
Sorry, I wasn't thinking on this. I should have realized what you wanted. So, this is:
Acked-by Corey Minyard <[email protected]>
No worries, and thanks. I've put these patches into my ppc-for-5.0 tree with this ack.
Quoted 129 lines
Quoted 128 lines
--- include/hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 41 ++++++----------------------------------- 2 files changed, 42 insertions(+), 35 deletions(-)include/hw/ipmi/ipmi.h +36
-0@@ -265,4 +265,40 @@ int ipmi_bmc_sdr_find(IPMIBmc *b, uint16_t recid, const struct ipmi_sdr_compact **sdr, uint16_t *nextrec);void ipmi_bmc_gen_event (IPMIBmc *b,uint8_t *evt,bool log); +typedef struct IPMIBmcSim IPMIBmcSim ; + +typedef struct RspBuffer { +uint8_t buffer[MAX_IPMI_MSG_SIZE ]; +unsigned int len; +}RspBuffer ; + +static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) +{ + rsp->buffer[2 ] = byte; +} + +/* Add a byte to the response. */ +static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) +{ +if (rsp->len >=sizeof (rsp->buffer)) { +rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); +return ; + } + rsp->buffer[rsp->len++] = byte; +} + +typedef struct IPMICmdHandler { +void (*cmd_handler)(IPMIBmcSim *s, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp); +unsigned int cmd_len_min; +}IPMICmdHandler ; + +typedef struct IPMINetfn { +unsigned int cmd_nums; +const IPMICmdHandler *cmd_handlers; +}IPMINetfn ; + +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd); +#endif hw/ipmi/ipmi_bmc_sim.c +6
-35@@ -98,6 +98,7 @@#define IPMI_CMD_GET_SEL_TIME 0x48#define IPMI_CMD_SET_SEL_TIME 0x49 +#define IPMI_NETFN_OEM 0x3a/* Same as a timespec struct. */ struct ipmi_time {@@ -167,23 +168,8 @@ typedef struct IPMISensor {#define MAX_SENSORS 20#define IPMI_WATCHDOG_SENSOR 0 -typedef struct IPMIBmcSim IPMIBmcSim ; -typedef struct RspBuffer RspBuffer ; -#define MAX_NETFNS 64 -typedef struct IPMICmdHandler { -void (*cmd_handler)(IPMIBmcSim *s, -uint8_t *cmd,unsigned int cmd_len, -RspBuffer *rsp); -unsigned int cmd_len_min; -}IPMICmdHandler ; - -typedef struct IPMINetfn { -unsigned int cmd_nums; -const IPMICmdHandler *cmd_handlers; -}IPMINetfn ; - typedef struct IPMIRcvBufEntry { QTAILQ_ENTRY(IPMIRcvBufEntry) entry; uint8_t len;@@ -279,28 +265,8 @@ struct IPMIBmcSim {#define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN 2#define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE 3 -struct RspBuffer { -uint8_t buffer[MAX_IPMI_MSG_SIZE ]; -unsigned int len; -}; -#define RSP_BUFFER_INITIALIZER { } -static inline void rsp_buffer_set_error (RspBuffer *rsp,uint8_t byte) -{ - rsp->buffer[2 ] = byte; -} - -/* Add a byte to the response. */ -static inline void rsp_buffer_push (RspBuffer *rsp,uint8_t byte) -{ -if (rsp->len >=sizeof (rsp->buffer)) { -rsp_buffer_set_error (rsp,IPMI_CC_REQUEST_DATA_TRUNCATED ); -return ; - } - rsp->buffer[rsp->len++] = byte; -} -static inline void rsp_buffer_pushmore (RspBuffer *rsp,uint8_t *bytes,unsigned int n) {@@ -640,6 +606,11 @@ static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn,return 0 ; } +int ipmi_register_oem_netfn (IPMIBmc *b,const IPMINetfn *netfnd) +{ +return ipmi_register_netfn (IPMI_BMC_SIMULATOR (b),IPMI_NETFN_OEM , netfnd); +} +static const IPMICmdHandler *ipmi_get_handler (IPMIBmcSim *ibs,unsigned int netfn,unsigned int cmd)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 3/5 ppc/pnv: Add HIOMAP commands
In reply to Cédric Le GoaterThis activates HIOMAP support on the QEMU PowerNV machine. The PnvPnor model is used to access the flash contents. The model simply maps the contents at a fix offset and enables or disables the mapping.
HIOMAP Protocol description :
https://github.com/openbmc/hiomapd/blob/master/Documentation/protocol.md
--- include/hw/ppc/pnv.h | 1 + include/hw/ppc/pnv_pnor.h | 5 ++ hw/ppc/pnv.c | 1 + hw/ppc/pnv_bmc.c | 101 ++++++++++++++++++++++++++++++++++++++ hw/ppc/pnv_lpc.c | 13 +++++ 5 files changed, 121 insertions(+)
include/hw/ppc/pnv.h +1 -0
@@ -209,6 +209,7 @@ static inline PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id)*/ void pnv_dt_bmc_sensors (IPMIBmc *bmc,void *fdt);void pnv_bmc_powerdown (IPMIBmc *bmc); +int pnv_bmc_hiomap (IPMIBmc *bmc);/* * POWER8 MMIO base addresses
include/hw/ppc/pnv_pnor.h +5 -0
@@ -9,6 +9,11 @@#ifndef _PPC_PNV_PNOR_H#define _PPC_PNV_PNOR_H +/* +* PNOR offset on the LPC FW address space +*/ +#define PNOR_SPI_OFFSET 0x0c000000UL +#define TYPE_PNV_PNOR "pnv-pnor"#define PNV_PNOR (obj) OBJECT_CHECK(PnvPnor, (obj), TYPE_PNV_PNOR)
hw/ppc/pnv.c +1 -0
@@ -566,6 +566,7 @@ static void pnv_reset(MachineState *machine) obj =object_resolve_path_type ("" ,"ipmi-bmc-sim" ,NULL );if (obj) { pnv->bmc =IPMI_BMC (obj); +pnv_bmc_hiomap (pnv->bmc); } fdt =pnv_dt_create (machine);
hw/ppc/pnv_bmc.c +101 -0
104 lines not on this page · raw message
hw/ppc/pnv_lpc.c +13 -0
@@ -801,6 +801,7 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)ISABus *isa_bus;qemu_irq *irqs;qemu_irq_handler handler; +PnvMachineState *pnv =PNV_MACHINE (qdev_get_machine ());/* let isa_bus_new() create its own bridge on SysBus otherwise * devices speficied on the command line won't find the bus and
@@ -825,5 +826,17 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp) irqs =qemu_allocate_irqs (handler, lpc,ISA_NUM_IRQS );isa_bus_irqs (isa_bus, irqs); + +/* +* TODO: Map PNOR on the LPC FW address space on demand ? +*/ +memory_region_add_subregion (&lpc->isa_fw,PNOR_SPI_OFFSET , + &pnv->pnor->mmio); +/* +* Start disabled. The HIOMAP protocol will activate the mapping +* with HIOMAP_C_CREATE_WRITE_WINDOW +*/ +memory_region_set_enabled (&pnv->pnor->mmio, false); +return isa_bus; }
Signature · 1 line
2.21.0
Re: [PATCH 3/5] ppc/pnv: Add HIOMAP commands
Quoted 10 lines · Cédric Le Goater
This activates HIOMAP support on the QEMU PowerNV machine. The PnvPnor model is used to access the flash contents. The model simply maps the contents at a fix offset and enables or disables the mapping.
HIOMAP Protocol description :
https://github.com/openbmc/hiomapd/blob/master/Documentation/protocol.md
Signed-off-by Cédric Le Goater <[email protected]>
PATCH 4/5 libxz: Add XZ Embedded library for PPC
In reply to Cédric Le Goaterversion 20130513 from https://tukaani.org/xz/embedded.html
--- libxz/xz.h | 304 ++++++++++ libxz/xz_config.h | 124 ++++ libxz/xz_lzma2.h | 204 +++++++ libxz/xz_private.h | 156 +++++ libxz/xz_stream.h | 62 ++ libxz/xz_crc32.c | 59 ++ libxz/xz_dec_lzma2.c | 1171 ++++++++++++++++++++++++++++++++++++++ libxz/xz_dec_stream.c | 847 +++++++++++++++++++++++++++ libxz/Makefile.objs | 1 + target/ppc/Makefile.objs | 1 + 10 files changed, 2929 insertions(+) create mode 100644 libxz/xz.h create mode 100644 libxz/xz_config.h create mode 100644 libxz/xz_lzma2.h create mode 100644 libxz/xz_private.h create mode 100644 libxz/xz_stream.h create mode 100644 libxz/xz_crc32.c create mode 100644 libxz/xz_dec_lzma2.c create mode 100644 libxz/xz_dec_stream.c create mode 100644 libxz/Makefile.objs
libxz/xz.h new file +304 -0
@@ -0,0 +1,304 @@ +/* +* XZ decompressor +* +* Authors: Lasse Collin <[email protected]> +* Igor Pavlov <http://7-zip.org/> +* +* This file has been put into the public domain. +* You can do whatever you want with this file. +*/ + +#ifndef XZ_H +#define XZ_H + +#ifdef __KERNEL__ +#include <linux/stddef.h> +#include <linux/types.h> +#else +#include <stddef.h> +#include <stdint.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* In Linux, this is used to make extern functions static when needed. */ +#ifndef XZ_EXTERN +#define XZ_EXTERN extern +#endif + +/** +* enum xz_mode - Operation mode +* +* @XZ_SINGLE: Single-call mode. This uses less RAM than +* than multi-call modes, because the LZMA2 +* dictionary doesn't need to be allocated as +* part of the decoder state. All required data +* structures are allocated at initialization, +* so xz_dec_run() cannot return XZ_MEM_ERROR. +* @XZ_PREALLOC: Multi-call mode with preallocated LZMA2 +* dictionary buffer. All data structures are +* allocated at initialization, so xz_dec_run() +* cannot return XZ_MEM_ERROR. +* @XZ_DYNALLOC: Multi-call mode. The LZMA2 dictionary is +* allocated once the required size has been +* parsed from the stream headers. If the +* allocation fails, xz_dec_run() will return +* XZ_MEM_ERROR. +* +* It is possible to enable support only for a subset of the above +* modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC, +* or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled +* with support for all operation modes, but the preboot code may +* be built with fewer features to minimize code size. +*/ +enum xz_mode { +XZ_SINGLE , +XZ_PREALLOC , +XZ_DYNALLOC +}; + +/** +* enum xz_ret - Return codes +* @XZ_OK: Everything is OK so far. More input or more +* output space is required to continue. This +* return code is possible only in multi-call mode +* (XZ_PREALLOC or XZ_DYNALLOC). +* @XZ_STREAM_END: Operation finished successfully. +* @XZ_UNSUPPORTED_CHECK: Integrity check type is not supported. Decoding +* is still possible in multi-call mode by simply +* calling xz_dec_run() again. +* Note that this return value is used only if +* XZ_DEC_ANY_CHECK was defined at build time, +* which is not used in the kernel. Unsupported +* check types return XZ_OPTIONS_ERROR if +* XZ_DEC_ANY_CHECK was not defined at build time. +* @XZ_MEM_ERROR: Allocating memory failed. This return code is +* possible only if the decoder was initialized +* with XZ_DYNALLOC. The amount of memory that was +* tried to be allocated was no more than the +* dict_max argument given to xz_dec_init(). +* @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than +* allowed by the dict_max argument given to +* xz_dec_init(). This return value is possible +* only in multi-call mode (XZ_PREALLOC or +* XZ_DYNALLOC); the single-call mode (XZ_SINGLE) +* ignores the dict_max argument. +* @XZ_FORMAT_ERROR: File format was not recognized (wrong magic +* bytes). +* @XZ_OPTIONS_ERROR: This implementation doesn't support the requested +* compression options. In the decoder this means +* that the header CRC32 matches, but the header +* itself specifies something that we don't support. +* @XZ_DATA_ERROR: Compressed data is corrupt. +* @XZ_BUF_ERROR: Cannot make any progress. Details are slightly +* different between multi-call and single-call +* mode; more information below. +* +* In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls +* to XZ code cannot consume any input and cannot produce any new output. +* This happens when there is no new input available, or the output buffer +* is full while at least one output byte is still pending. Assuming your +* code is not buggy, you can get this error only when decoding a compressed +* stream that is truncated or otherwise corrupt. +* +* In single-call mode, XZ_BUF_ERROR is returned only when the output buffer +* is too small or the compressed input is corrupt in a way that makes the +* decoder produce more output than the caller expected. When it is +* (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR +* is used instead of XZ_BUF_ERROR. +*/ +enum xz_ret { +XZ_OK , +XZ_STREAM_END , +XZ_UNSUPPORTED_CHECK , +XZ_MEM_ERROR , +XZ_MEMLIMIT_ERROR , +XZ_FORMAT_ERROR , +XZ_OPTIONS_ERROR , +XZ_DATA_ERROR , +XZ_BUF_ERROR +}; + +/** +* struct xz_buf - Passing input and output buffers to XZ code +* @in: Beginning of the input buffer. This may be NULL if and only +* if in_pos is equal to in_size. +* @in_pos: Current position in the input buffer. This must not exceed +* in_size. +* @in_size: Size of the input buffer +* @out: Beginning of the output buffer. This may be NULL if and only +* if out_pos is equal to out_size. +* @out_pos: Current position in the output buffer. This must not exceed +* out_size. +* @out_size: Size of the output buffer +* +* Only the contents of the output buffer from out[out_pos] onward, and +* the variables in_pos and out_pos are modified by the XZ code. +*/ +struct xz_buf { +const uint8_t *in; +size_t in_pos; +size_t in_size; + +uint8_t *out; +size_t out_pos; +size_t out_size; +}; + +/** +* struct xz_dec - Opaque type to hold the XZ decoder state +*/ +struct xz_dec ; + +/** +* xz_dec_init() - Allocate and initialize a XZ decoder state +* @mode: Operation mode +* @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for +* multi-call decoding. This is ignored in single-call mode +* (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes +* or 2^n + 2^(n-1) bytes (the latter sizes are less common +* in practice), so other values for dict_max don't make sense. +* In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB, +* 512 KiB, and 1 MiB are probably the only reasonable values, +* except for kernel and initramfs images where a bigger +* dictionary can be fine and useful. +* +* Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at +* once. The caller must provide enough output space or the decoding will +* fail. The output space is used as the dictionary buffer, which is why +* there is no need to allocate the dictionary as part of the decoder's +* internal state. +* +* Because the output buffer is used as the workspace, streams encoded using +* a big dictionary are not a problem in single-call mode. It is enough that +* the output buffer is big enough to hold the actual uncompressed data; it +* can be smaller than the dictionary size stored in the stream headers. +* +* Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes +* of memory is preallocated for the LZMA2 dictionary. This way there is no +* risk that xz_dec_run() could run out of memory, since xz_dec_run() will +* never allocate any memory. Instead, if the preallocated dictionary is too +* small for decoding the given input stream, xz_dec_run() will return +* XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be +* decoded to avoid allocating excessive amount of memory for the dictionary. +* +* Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC): +* dict_max specifies the maximum allowed dictionary size that xz_dec_run() +* may allocate once it has parsed the dictionary size from the stream +* headers. This way excessive allocations can be avoided while still +* limiting the maximum memory usage to a sane value to prevent running the +* system out of memory when decompressing streams from untrusted sources. +* +* On success, xz_dec_init() returns a pointer to struct xz_dec, which is +* ready to be used with xz_dec_run(). If memory allocation fails, +* xz_dec_init() returns NULL. +*/ +XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); + +/** +* xz_dec_run() - Run the XZ decoder +* @s: Decoder state allocated using xz_dec_init() +* @b: Input and output buffers +* +* The possible return values depend on build options and operation mode. +* See enum xz_ret for details. +* +* Note that if an error occurs in single-call mode (return value is not +* XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the +* contents of the output buffer from b->out[b->out_pos] onward are +* undefined. This is true even after XZ_BUF_ERROR, because with some filter +* chains, there may be a second pass over the output buffer, and this pass +* cannot be properly done if the output buffer is truncated. Thus, you +* cannot give the single-call decoder a too small buffer and then expect to +* get that amount valid data from the beginning of the stream. You must use +* the multi-call decoder if you don't want to uncompress the whole stream. +*/ +XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); + +/** +* xz_dec_reset() - Reset an already allocated decoder state +* @s: Decoder state allocated using xz_dec_init() +* +* This function can be used to reset the multi-call decoder state without +* freeing and reallocating memory with xz_dec_end() and xz_dec_init(). +* +* In single-call mode, xz_dec_reset() is always called in the beginning of +* xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in +* multi-call mode. +*/ +XZ_EXTERN void xz_dec_reset(struct xz_dec *s); + +/** +* xz_dec_end() - Free the memory allocated for the decoder state +* @s: Decoder state allocated using xz_dec_init(). If s is NULL, +* this function does nothing. +*/ +XZ_EXTERN void xz_dec_end(struct xz_dec *s); + +/* +* Standalone build (userspace build or in-kernel build for boot time use) +* needs a CRC32 implementation. For normal in-kernel use, kernel's own +* CRC32 module is used instead, and users of this module don't need to +* care about the functions below. +*/ +#ifndef XZ_INTERNAL_CRC32 +#ifdef __KERNEL__ +#define XZ_INTERNAL_CRC32 0 +#else +#define XZ_INTERNAL_CRC32 1 +#endif +#endif + +/* +* If CRC64 support has been enabled with XZ_USE_CRC64, a CRC64 +* implementation is needed too. +*/ +#ifndef XZ_USE_CRC64 +#undef XZ_INTERNAL_CRC64 +#define XZ_INTERNAL_CRC64 0 +#endif +#ifndef XZ_INTERNAL_CRC64 +#ifdef __KERNEL__ +#error Using CRC64 in the kernel has not been implemented. +#else +#define XZ_INTERNAL_CRC64 1 +#endif +#endif + +#if XZ_INTERNAL_CRC32 +/* +* This must be called before any other xz_* function to initialize +* the CRC32 lookup table. +*/ +XZ_EXTERN void xz_crc32_init(void); + +/* +* Update CRC32 value using the polynomial from IEEE-802.3. To start a new +* calculation, the third argument must be zero. To continue the calculation, +* the previously returned value is passed as the third argument. +*/ +XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); +#endif + +#if XZ_INTERNAL_CRC64 +/* +* This must be called before any other xz_* function (except xz_crc32_init()) +* to initialize the CRC64 lookup table. +*/ +XZ_EXTERN void xz_crc64_init(void); + +/* +* Update CRC64 value using the polynomial from ECMA-182. To start a new +* calculation, the third argument must be zero. To continue the calculation, +* the previously returned value is passed as the third argument. +*/ +XZ_EXTERN uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc); +#endif + +#ifdef __cplusplus +} +#endif + +#endif
libxz/xz_config.h new file +124 -0
124 lines not on this page · raw message
libxz/xz_lzma2.h new file +204 -0
204 lines not on this page · raw message
libxz/xz_private.h new file +156 -0
156 lines not on this page · raw message
libxz/xz_stream.h new file +62 -0
62 lines not on this page · raw message
libxz/xz_crc32.c new file +59 -0
59 lines not on this page · raw message
libxz/xz_dec_lzma2.c new file +1171 -0
1,171 lines not on this page · raw message
libxz/xz_dec_stream.c new file +847 -0
847 lines not on this page · raw message
libxz/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-y += xz_dec_stream.o xz_dec_lzma2.o xz_crc32.o
target/ppc/Makefile.objs +1 -0
@@ -18,3 +18,4 @@ obj-y += mem_helper.o obj-y += ../../libdecnumber/ obj-$(CONFIG_USER_ONLY) += user_only_helper.o obj-y += gdbstub.o +obj-$(TARGET_PPC64) += ../../libxz/
Signature · 1 line
2.21.0
PATCH 5/5 ppc/pnv: Read the PNOR partition table
In reply to Cédric Le GoaterFrom: Cédric Le Goater <[email protected]>
This patch adds the logic to read the partition table of a PNOR file and a routine to load the PAYLOAD (skiboot) partition in the machine memory.
Code based on the libflash of skiboot:
https://github.com/open-power/skiboot/blob/master/libflash/
--- include/hw/ppc/ffs.h | 150 ++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv_pnor.h | 6 ++ hw/ppc/pnv.c | 33 +++++--- hw/ppc/pnv_pnor.c | 156 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 334 insertions(+), 11 deletions(-) create mode 100644 include/hw/ppc/ffs.h
include/hw/ppc/ffs.h new file +150 -0
@@ -0,0 +1,150 @@ +/* +* Copyright 2013-2014 IBM Corp. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +* implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/* +* Copyright (c) International Business Machines Corp., 2012 +* +* FSP Flash Structure +* +* This header defines the layout for the FSP Flash Structure. +*/ + +#ifndef FFS_H +#define FFS_H + +#include <stdint.h> + +/* The version of this partition implementation */ +#define FFS_VERSION_1 1 + +/* Magic number for the partition header (ASCII 'PART') */ +#define FFS_MAGIC 0x50415254 + +/* The maximum length of the partition name */ +#define PART_NAME_MAX 15 + +/* +* Sizes of the data structures +*/ +#define FFS_HDR_SIZE sizeof(struct ffs_hdr) +#define FFS_ENTRY_SIZE sizeof(struct ffs_entry) + +/* +* Sizes of the data structures w/o checksum +*/ +#define FFS_HDR_SIZE_CSUM (FFS_HDR_SIZE - sizeof(uint32_t)) +#define FFS_ENTRY_SIZE_CSUM (FFS_ENTRY_SIZE - sizeof(uint32_t)) + +/* pid of logical partitions/containers */ +#define FFS_PID_TOPLEVEL 0xFFFFFFFF + +/* +* Type of image contained w/in partition +*/ +enum type { +FFS_TYPE_DATA =1 , +FFS_TYPE_LOGICAL =2 , +FFS_TYPE_PARTITION =3 , +}; + +/* +* Flag bit definitions +*/ +#define FFS_FLAGS_PROTECTED 0x0001 +#define FFS_FLAGS_U_BOOT_ENV 0x0002 + +/* Data integrity flags */ +#define FFS_ENRY_INTEG_ECC 0x8000 + +/** +* struct ffs_entry_user - User data enties +* +* @chip: Chip Select (0,1) +* @compressType: Compression Indication/alg (0=not compressed) +* @dataInteg: Indicates Data Integrity mechanism +* @verCheck: Indicates Version check type +* @miscFlags: Misc Partition related Flags +* @freeMisc[2]: Unused Miscellaneious Info +* @freeUser[14]: Unused User Data +*/ +struct ffs_entry_user { +uint8_t chip; +uint8_t compresstype; +uint16_t datainteg; +uint8_t vercheck; +uint8_t miscflags; +uint8_t freemisc[2 ]; +uint32_t reserved[14 ]; +}; + +/** +* struct ffs_entry - Partition entry +* +* @name: Opaque null terminated string +* @base: Starting offset of partition in flash (in hdr.block_size) +* @size: Partition size (in hdr.block_size) +* @pid: Parent partition entry (FFS_PID_TOPLEVEL for toplevel) +* @id: Partition entry ID [1..65536] +* @type: Describe type of partition +* @flags: Partition attributes (optional) +* @actual: Actual partition size (in bytes) +* @resvd: Reserved words for future use +* @user: User data (optional) +* @checksum: Partition entry checksum (includes all above) +*/ +struct ffs_entry { +char name[PART_NAME_MAX +1 ]; +uint32_t base; +uint32_t size; +uint32_t pid; +uint32_t id; +uint32_t type; +uint32_t flags; +uint32_t actual; +uint32_t resvd[4 ]; +struct ffs_entry_user user; +uint32_t checksum; +} __attribute__ ((packed)); + +/** +* struct ffs_hdr - FSP Flash Structure header +* +* @magic: Eye catcher/corruption detector +* @version: Version of the structure +* @size: Size of partition table (in block_size) +* @entry_size: Size of struct ffs_entry element (in bytes) +* @entry_count: Number of struct ffs_entry elements in @entries array +* @block_size: Size of block on device (in bytes) +* @block_count: Number of blocks on device +* @resvd: Reserved words for future use +* @checksum: Header checksum +* @entries: Pointer to array of partition entries +*/ +struct ffs_hdr { +uint32_t magic; +uint32_t version; +uint32_t size; +uint32_t entry_size; +uint32_t entry_count; +uint32_t block_size; +uint32_t block_count; +uint32_t resvd[4 ]; +uint32_t checksum; +struct ffs_entry entries[]; +} __attribute__ ((packed)); + + +#endif /* FFS_H */
include/hw/ppc/pnv_pnor.h +6 -0
@@ -25,6 +25,12 @@ typedef struct PnvPnor {uint8_t *storage;uint32_t size;MemoryRegion mmio; + +uint32_t skiboot_addr; + uint32_t skiboot_size; } PnvPnor; +extern int pnv_pnor_load_skiboot (PnvPnor *pnor,hwaddr addr,size_t max_size, +Error **errp); +#endif /* _PPC_PNV_PNOR_H */
hw/ppc/pnv.c +22 -11
@@ -637,6 +637,7 @@ static void pnv_init(MachineState *machine)char *chip_typename;DriveInfo *pnor =drive_get (IF_MTD ,0 ,0 );DeviceState *dev; +bool load_skiboot_from_pnor = false;/* allocate RAM */ if (machine->ram_size < (1 * GiB)) {
@@ -659,23 +660,33 @@ static void pnv_init(MachineState *machine)qdev_init_nofail (dev); pnv->pnor =PNV_PNOR (dev); -/* load skiboot firmware */ +/* +* Try to load skiboot from pnor if no 'bios' was provided on the +* command line. skiboot will load the kernel and initramfs from +* the PNOR. +*/ if (bios_name ==NULL ) { bios_name =FW_FILE_NAME ; + load_skiboot_from_pnor = !!pnor; } - fw_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); -if (!fw_filename) { -error_report ("Could not find OPAL firmware '%s'" , bios_name); -exit (1 ); - } +if (load_skiboot_from_pnor) { +pnv_pnor_load_skiboot (pnv->pnor,FW_LOAD_ADDR ,FW_MAX_SIZE , + &error_fatal); + }else { + fw_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (!fw_filename) { +error_report ("Could not find OPAL firmware '%s'" , bios_name); +exit (1 ); + } - fw_size =load_image_targphys (fw_filename,FW_LOAD_ADDR ,FW_MAX_SIZE ); -if (fw_size <0 ) { -error_report ("Could not load OPAL firmware '%s'" , fw_filename); -exit (1 ); + fw_size =load_image_targphys (fw_filename,FW_LOAD_ADDR ,FW_MAX_SIZE ); +if (fw_size <0 ) { +error_report ("Could not load OPAL firmware '%s'" , fw_filename); +exit (1 ); + } +g_free (fw_filename); } -g_free (fw_filename);/* load kernel */ if (machine->kernel_filename) {
hw/ppc/pnv_pnor.c +156 -0
170 lines not on this page · raw message
Signature · 1 line
2.21.0
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH 0/5] ppc/pnv: Add PNOR support
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
7419b33 ppc/pnv: Read the PNOR partition table 94fb18c libxz: Add XZ Embedded library for PPC b618eb6 ppc/pnv: Add HIOMAP commands
3ee95f6 ipmi: Add support to customize OEM functions bb5d940 ppc/pnv: Add a PNOR model
=== OUTPUT BEGIN ===
1/5 Checking commit bb5d940733f4 (ppc/pnv: Add a PNOR model)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #70:
new file mode 100644
total: 0 errors, 1 warnings, 217 lines checked
Patch 1/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/5 Checking commit 3ee95f66e7df (ipmi: Add support to customize OEM functions) 3/5 Checking commit b618eb627b5d (ppc/pnv: Add HIOMAP commands) 4/5 Checking commit 94fb18ca0ddf (libxz: Add XZ Embedded library for PPC)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #13:
new file mode 100644
WARNING: architecture specific defines should be avoided #38: FILE: libxz/xz.h:14:
+#ifdef __KERNEL__
WARNING: architecture specific defines should be avoided #46: FILE: libxz/xz.h:22:
+#ifdef __cplusplus
ERROR: storage class should be at the beginning of the declaration #52: FILE: libxz/xz.h:28:
+ #define XZ_EXTERN extern
WARNING: architecture specific defines should be avoided #271: FILE: libxz/xz.h:247:
+ #ifdef __KERNEL__
WARNING: architecture specific defines should be avoided #287: FILE: libxz/xz.h:263:
+ #ifdef __KERNEL__
WARNING: architecture specific defines should be avoided #324: FILE: libxz/xz.h:300:
+#ifdef __cplusplus
WARNING: architecture specific defines should be avoided #399: FILE: libxz/xz_config.h:65:
+#ifndef __always_inline
WARNING: architecture specific defines should be avoided #400: FILE: libxz/xz_config.h:66:
+ #ifdef __GNUC__
ERROR: code indent should never use tabs
#489: FILE: libxz/xz_crc32.c:25:
+#^Idefine STATIC_RW_DATA static$
ERROR: storage class should be at the beginning of the declaration #489: FILE: libxz/xz_crc32.c:25:
+# define STATIC_RW_DATA static
ERROR: code indent should never use tabs
#496: FILE: libxz/xz_crc32.c:32:
+^Iconst uint32_t poly = 0xEDB88320;$
ERROR: code indent should never use tabs
#498: FILE: libxz/xz_crc32.c:34:
+^Iuint32_t i;$
ERROR: code indent should never use tabs
#499: FILE: libxz/xz_crc32.c:35:
+^Iuint32_t j;$
ERROR: code indent should never use tabs
#500: FILE: libxz/xz_crc32.c:36:
+^Iuint32_t r;$
ERROR: code indent should never use tabs
#502: FILE: libxz/xz_crc32.c:38:
+^Ifor (i = 0; i < 256; ++i) {$
ERROR: code indent should never use tabs
#503: FILE: libxz/xz_crc32.c:39:
+^I^Ir = i;$
ERROR: code indent should never use tabs
#504: FILE: libxz/xz_crc32.c:40:
+^I^Ifor (j = 0; j < 8; ++j)$
ERROR: braces {} are necessary for all arms of this statement #504: FILE: libxz/xz_crc32.c:40:
+ for (j = 0; j < 8; ++j)
[...]
ERROR: code indent should never use tabs
#505: FILE: libxz/xz_crc32.c:41:
+^I^I^Ir = (r >> 1) ^ (poly & ~((r & 1) - 1));$
ERROR: code indent should never use tabs
#507: FILE: libxz/xz_crc32.c:43:
+^I^Ixz_crc32_table[i] = r;$
ERROR: code indent should never use tabs
#508: FILE: libxz/xz_crc32.c:44:
+^I}$
ERROR: code indent should never use tabs
#510: FILE: libxz/xz_crc32.c:46:
+^Ireturn;$
ERROR: code indent should never use tabs
#515: FILE: libxz/xz_crc32.c:51:
+^Icrc = ~crc;$
ERROR: code indent should never use tabs
#517: FILE: libxz/xz_crc32.c:53:
+^Iwhile (size != 0) {$
ERROR: code indent should never use tabs
#518: FILE: libxz/xz_crc32.c:54:
+^I^Icrc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);$
ERROR: code indent should never use tabs
#519: FILE: libxz/xz_crc32.c:55:
+^I^I--size;$
ERROR: code indent should never use tabs
#520: FILE: libxz/xz_crc32.c:56:
+^I}$
ERROR: code indent should never use tabs
#522: FILE: libxz/xz_crc32.c:58:
+^Ireturn ~crc;$
WARNING: Block comments use a leading /* on a separate line #807: FILE: libxz/xz_dec_lzma2.c:278:
+/**************
ERROR: braces {} are necessary for all arms of this statement #831: FILE: libxz/xz_dec_lzma2.c:302:
+ if (dict->end - dict->pos <= out_max)
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement #853: FILE: libxz/xz_dec_lzma2.c:324:
+ if (dist >= dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #866: FILE: libxz/xz_dec_lzma2.c:337:
+ if (dict->full < dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #880: FILE: libxz/xz_dec_lzma2.c:351:
+ if (dist >= dict->full || dist >= dict->size)
[...]
ERROR: braces {} are necessary for all arms of this statement #887: FILE: libxz/xz_dec_lzma2.c:358:
+ if (dist >= dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #892: FILE: libxz/xz_dec_lzma2.c:363:
+ if (back == dict->end)
[...]
ERROR: braces {} are necessary for all arms of this statement #896: FILE: libxz/xz_dec_lzma2.c:367:
+ if (dict->full < dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #912: FILE: libxz/xz_dec_lzma2.c:383:
+ if (copy_size > dict->end - dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #914: FILE: libxz/xz_dec_lzma2.c:385:
+ if (copy_size > *left)
[...]
ERROR: braces {} are necessary for all arms of this statement #922: FILE: libxz/xz_dec_lzma2.c:393:
+ if (dict->full < dict->pos)
[...]
ERROR: braces {} are necessary for all arms of this statement #926: FILE: libxz/xz_dec_lzma2.c:397:
+ if (dict->pos == dict->end)
[...]
ERROR: braces {} are necessary for all arms of this statement #950: FILE: libxz/xz_dec_lzma2.c:421:
+ if (dict->pos == dict->end)
[...]
WARNING: Block comments use a leading /* on a separate line #962: FILE: libxz/xz_dec_lzma2.c:433:
+/*****************
ERROR: braces {} are necessary for all arms of this statement #981: FILE: libxz/xz_dec_lzma2.c:452:
+ if (b->in_pos == b->in_size)
[...]
ERROR: braces {} are necessary for all arms of this statement #1054: FILE: libxz/xz_dec_lzma2.c:525:
+ if (rc_bit(rc, &probs[symbol]))
[...]
+ else
[...]
WARNING: Block comments use a leading /* on a separate line #1096: FILE: libxz/xz_dec_lzma2.c:567:
+/********
ERROR: braces {} are necessary for all arms of this statement #1259: FILE: libxz/xz_dec_lzma2.c:730:
+ if (dict_has_space(&s->dict) && s->lzma.len > 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #1273: FILE: libxz/xz_dec_lzma2.c:744:
+ if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state]))
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement #1278: FILE: libxz/xz_dec_lzma2.c:749:
+ if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0))
[...]
ERROR: braces {} are necessary for all arms of this statement #1317: FILE: libxz/xz_dec_lzma2.c:788:
+ for (i = 0; i < PROBS_TOTAL; ++i)
[...]
ERROR: braces {} are necessary for all arms of this statement #1330: FILE: libxz/xz_dec_lzma2.c:801:
+ if (props > (4 * 5 + 4) * 9 + 8)
[...]
ERROR: braces {} are necessary for all arms of this statement #1349: FILE: libxz/xz_dec_lzma2.c:820:
+ if (s->lzma.lc + s->lzma.literal_pos_mask > 4)
[...]
WARNING: Block comments use a leading /* on a separate line #1359: FILE: libxz/xz_dec_lzma2.c:830:
+/*********
ERROR: braces {} are necessary for all arms of this statement #1383: FILE: libxz/xz_dec_lzma2.c:854:
+ if (tmp > s->lzma2.compressed - s->temp.size)
[...]
ERROR: braces {} are necessary for all arms of this statement #1385: FILE: libxz/xz_dec_lzma2.c:856:
+ if (tmp > in_avail)
[...]
ERROR: braces {} are necessary for all arms of this statement #1406: FILE: libxz/xz_dec_lzma2.c:877:
+ if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp)
[...]
ERROR: braces {} are necessary for all arms of this statement #1427: FILE: libxz/xz_dec_lzma2.c:898:
+ if (in_avail >= s->lzma2.compressed + LZMA_IN_REQUIRED)
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement #1432: FILE: libxz/xz_dec_lzma2.c:903:
+ if (!lzma_main(s))
[...]
ERROR: braces {} are necessary for all arms of this statement #1436: FILE: libxz/xz_dec_lzma2.c:907:
+ if (in_avail > s->lzma2.compressed)
[...]
ERROR: braces {} are necessary for all arms of this statement #1445: FILE: libxz/xz_dec_lzma2.c:916:
+ if (in_avail > s->lzma2.compressed)
[...]
ERROR: braces {} are necessary for all arms of this statement #1501: FILE: libxz/xz_dec_lzma2.c:972:
+ if (tmp == 0x00)
[...]
ERROR: braces {} are necessary for all arms of this statement #1532: FILE: libxz/xz_dec_lzma2.c:1003:
+ if (tmp >= 0xA0)
[...]
ERROR: braces {} are necessary for all arms of this statement #1536: FILE: libxz/xz_dec_lzma2.c:1007:
+ if (tmp > 0x02)
[...]
ERROR: braces {} are necessary for all arms of this statement #1570: FILE: libxz/xz_dec_lzma2.c:1041:
+ if (!lzma_props(s, b->in[b->in_pos++]))
[...]
ERROR: braces {} are necessary for all arms of this statement #1576: FILE: libxz/xz_dec_lzma2.c:1047:
+ if (s->lzma2.compressed < RC_INIT_BYTES)
[...]
ERROR: braces {} are necessary for all arms of this statement #1579: FILE: libxz/xz_dec_lzma2.c:1050:
+ if (!rc_read_init(&s->rc, b))
[...]
ERROR: braces {} are necessary for all arms of this statement #1598: FILE: libxz/xz_dec_lzma2.c:1069:
+ if (!lzma2_lzma(s, b))
[...]
ERROR: braces {} are necessary for all arms of this statement #1622: FILE: libxz/xz_dec_lzma2.c:1093:
+ if (s->lzma2.compressed > 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #1637: FILE: libxz/xz_dec_lzma2.c:1108:
+ if (s == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #1660: FILE: libxz/xz_dec_lzma2.c:1131:
+ if (props > 39)
[...]
ERROR: braces {} are necessary for all arms of this statement #1667: FILE: libxz/xz_dec_lzma2.c:1138:
+ if (s->dict.size > s->dict.size_max)
[...]
ERROR: braces {} are necessary for all arms of this statement #1696: FILE: libxz/xz_dec_lzma2.c:1167:
+ if (DEC_IS_MULTI(s->dict.mode))
[...]
ERROR: braces {} are necessary for all arms of this statement #1897: FILE: libxz/xz_dec_stream.c:191:
+ if (s->pos == 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #1908: FILE: libxz/xz_dec_stream.c:202:
+ if (byte == 0 && s->pos != 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #1916: FILE: libxz/xz_dec_stream.c:210:
+ if (s->pos == 7 * VLI_BYTES_MAX)
[...]
ERROR: braces {} are necessary for all arms of this statement #1987: FILE: libxz/xz_dec_stream.c:281:
+ if (s->check_type == XZ_CHECK_CRC32)
[...]
+ else if (IS_CRC64(s->check_type))
[...]
ERROR: braces {} are necessary for all arms of this statement #1989: FILE: libxz/xz_dec_stream.c:283:
+ else if (IS_CRC64(s->check_type))
[...]
ERROR: braces {} are necessary for all arms of this statement #2040: FILE: libxz/xz_dec_stream.c:334:
+ if (s->index.count != s->block.count)
[...]
ERROR: braces {} are necessary for all arms of this statement #2075: FILE: libxz/xz_dec_stream.c:369:
+ if (b->in_pos == b->in_size)
[...]
ERROR: braces {} are necessary for all arms of this statement #2078: FILE: libxz/xz_dec_stream.c:372:
+ if (((s->crc >> s->pos) & 0xFF) != b->in[b->in_pos++])
[...]
ERROR: braces {} are necessary for all arms of this statement #2099: FILE: libxz/xz_dec_stream.c:393:
+ if (b->in_pos == b->in_size)
[...]
ERROR: braces {} are necessary for all arms of this statement #2115: FILE: libxz/xz_dec_stream.c:409:
+ if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
[...]
ERROR: braces {} are necessary for all arms of this statement #2122: FILE: libxz/xz_dec_stream.c:416:
+ if (s->temp.buf[HEADER_MAGIC_SIZE] != 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #2135: FILE: libxz/xz_dec_stream.c:429:
+ if (s->check_type > XZ_CHECK_MAX)
[...]
ERROR: braces {} are necessary for all arms of this statement #2138: FILE: libxz/xz_dec_stream.c:432:
+ if (s->check_type > XZ_CHECK_CRC32 && !IS_CRC64(s->check_type))
[...]
ERROR: braces {} are necessary for all arms of this statement #2141: FILE: libxz/xz_dec_stream.c:435:
+ if (s->check_type > XZ_CHECK_CRC32 && !IS_CRC64(s->check_type))
[...]
ERROR: braces {} are necessary for all arms of this statement #2151: FILE: libxz/xz_dec_stream.c:445:
+ if (!memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE))
[...]
ERROR: braces {} are necessary for all arms of this statement #2154: FILE: libxz/xz_dec_stream.c:448:
+ if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
[...]
ERROR: braces {} are necessary for all arms of this statement #2162: FILE: libxz/xz_dec_stream.c:456:
+ if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
[...]
ERROR: braces {} are necessary for all arms of this statement #2165: FILE: libxz/xz_dec_stream.c:459:
+ if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->check_type)
[...]
ERROR: braces {} are necessary for all arms of this statement #2228: FILE: libxz/xz_dec_stream.c:522:
+ if (s->temp.size - s->temp.pos < 2)
[...]
ERROR: braces {} are necessary for all arms of this statement #2232: FILE: libxz/xz_dec_stream.c:526:
+ if (ret != XZ_OK)
[...]
ERROR: braces {} are necessary for all arms of this statement #2239: FILE: libxz/xz_dec_stream.c:533:
+ if (s->temp.buf[s->temp.pos++] != 0x00)
[...]
ERROR: braces {} are necessary for all arms of this statement #2245: FILE: libxz/xz_dec_stream.c:539:
+ if (s->temp.size - s->temp.pos < 2)
[...]
ERROR: braces {} are necessary for all arms of this statement #2249: FILE: libxz/xz_dec_stream.c:543:
+ if (s->temp.buf[s->temp.pos++] != 0x21)
[...]
ERROR: braces {} are necessary for all arms of this statement #2253: FILE: libxz/xz_dec_stream.c:547:
+ if (s->temp.buf[s->temp.pos++] != 0x01)
[...]
ERROR: braces {} are necessary for all arms of this statement #2257: FILE: libxz/xz_dec_stream.c:551:
+ if (s->temp.size - s->temp.pos < 1)
[...]
ERROR: braces {} are necessary for all arms of this statement #2261: FILE: libxz/xz_dec_stream.c:555:
+ if (ret != XZ_OK)
[...]
ERROR: braces {} are necessary for all arms of this statement #2266: FILE: libxz/xz_dec_stream.c:560:
+ if (s->temp.buf[s->temp.pos++] != 0x00)
[...]
ERROR: braces {} are necessary for all arms of this statement #2297: FILE: libxz/xz_dec_stream.c:591:
+ if (!fill_temp(s, b))
[...]
ERROR: braces {} are necessary for all arms of this statement #2310: FILE: libxz/xz_dec_stream.c:604:
+ if (ret != XZ_OK)
[...]
ERROR: braces {} are necessary for all arms of this statement #2315: FILE: libxz/xz_dec_stream.c:609:
+ if (b->in_pos == b->in_size)
[...]
ERROR: braces {} are necessary for all arms of this statement #2337: FILE: libxz/xz_dec_stream.c:631:
+ if (!fill_temp(s, b))
[...]
ERROR: braces {} are necessary for all arms of this statement #2341: FILE: libxz/xz_dec_stream.c:635:
+ if (ret != XZ_OK)
[...]
ERROR: braces {} are necessary for all arms of this statement #2348: FILE: libxz/xz_dec_stream.c:642:
+ if (ret != XZ_STREAM_END)
[...]
ERROR: braces {} are necessary for all arms of this statement #2362: FILE: libxz/xz_dec_stream.c:656:
+ if (b->in_pos == b->in_size)
[...]
ERROR: braces {} are necessary for all arms of this statement #2365: FILE: libxz/xz_dec_stream.c:659:
+ if (b->in[b->in_pos++] != 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #2376: FILE: libxz/xz_dec_stream.c:670:
+ if (ret != XZ_STREAM_END)
[...]
ERROR: else should follow close brace '}'
#2379: FILE: libxz/xz_dec_stream.c:673:
+ }
+ else if (IS_CRC64(s->check_type)) {
ERROR: braces {} are necessary for all arms of this statement #2381: FILE: libxz/xz_dec_stream.c:675:
+ if (ret != XZ_STREAM_END)
[...]
ERROR: braces {} are necessary for all arms of this statement #2395: FILE: libxz/xz_dec_stream.c:689:
+ if (ret != XZ_STREAM_END)
[...]
ERROR: braces {} are necessary for all arms of this statement #2408: FILE: libxz/xz_dec_stream.c:702:
+ if (b->in[b->in_pos++] != 0)
[...]
ERROR: braces {} are necessary for all arms of this statement #2424: FILE: libxz/xz_dec_stream.c:718:
+ if (ret != XZ_STREAM_END)
[...]
ERROR: braces {} are necessary for all arms of this statement #2431: FILE: libxz/xz_dec_stream.c:725:
+ if (!fill_temp(s, b))
[...]
ERROR: braces {} are necessary for all arms of this statement #2472: FILE: libxz/xz_dec_stream.c:766:
+ if (DEC_IS_SINGLE(s->mode))
[...]
ERROR: braces {} are necessary for all arms of this statement #2491: FILE: libxz/xz_dec_stream.c:785:
+ if (s->allow_buf_error)
[...]
ERROR: braces {} are necessary for all arms of this statement #2505: FILE: libxz/xz_dec_stream.c:799:
+ if (s == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #2512: FILE: libxz/xz_dec_stream.c:806:
+ if (s->bcj == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #2517: FILE: libxz/xz_dec_stream.c:811:
+ if (s->lzma2 == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #2625: FILE: libxz/xz_lzma2.h:66:
+ if (*state <= STATE_SHORTREP_LIT_LIT)
[...]
+ else if (*state <= STATE_LIT_SHORTREP)
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement #2627: FILE: libxz/xz_lzma2.h:68:
+ else if (*state <= STATE_LIT_SHORTREP)
[...]
+ else
[...]
WARNING: Block comments use a leading /* on a separate line #2657: FILE: libxz/xz_lzma2.h:98:
+/* Each literal coder is divided in three sections:
WARNING: Block comments use a leading /* on a separate line #2673: FILE: libxz/xz_lzma2.h:114:
+/* Match length is encoded with 4, 5, or 10 bits.
WARNING: Block comments use a leading /* on a separate line #2720: FILE: libxz/xz_lzma2.h:161:
+/* Match distances up to 127 are fully encoded using probabilities. Since
WARNING: architecture specific defines should be avoided #2782: FILE: libxz/xz_private.h:13:
+#ifdef __KERNEL__
WARNING: architecture specific defines should be avoided #2944: FILE: libxz/xz_stream.h:13:
+#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
total: 109 errors, 17 warnings, 2932 lines checked
Patch 4/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/5 Checking commit 7419b332e89b (ppc/pnv: Read the PNOR partition table)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #252:
new file mode 100644
total: 0 errors, 1 warnings, 383 lines checked
Patch 5/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]