qemu-e2k/include/hw
Peter Maydell feb0b1aa11 pflash_cfi01: fix per-device sector length in CFI table
For configurations of the pflash_cfi01 device which set it up with a
device-width not equal to the width (ie where we are emulating
multiple narrow flash devices wired up in parallel), we were giving
incorrect values in the CFI data table:

(1) the sector length entry should specify the sector length for a
    single device, not the length for the overall collection of
    devices
(2) the number of blocks per device must not be divided by the
    number of devices because the resulting device size would not
    match the overall size
(3) this then means that the overall write block size must be
    modified depending on the number of devices because the entry is
    per device and when the guest writes into the flash it
    calculates the write size by using the CFI entry (write size
    per device) multiplied by the number of chips.
    (It would alternatively be possible to modify the write
    block size in the CFI table (currently hardcoded at 2048) and
    leave the overall write block size alone.)

This commit corrects these bugs, and adds a hw-compat property
to retain the old behaviour on 2.8 and earlier versions. (The
only board we have which uses this sort of flash config and
has machine versioning is the "virt" board -- the PC uses a
single flash device and so behaviour is unaffected whether
using old-multiple-chip-handling or not.)

Here is a configuration example from the vexpress board:

VEXPRESS_FLASH_SIZE = 64M
VEXPRESS_FLASH_SECT_SIZE 256K
num-blocks = VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE = 256
sector-length = 256K
width = 4
device-width = 2

The code will fill the CFI entry with the following entries:
  num-blocks = 256
  sector-length = 128K
  writeblock_size = 2048

This results in two chips, each with 256 * 128K = 32M device size and
a write block size of 2048.

A sector erase will be sent to both chips, thus 256K must be erased.
When the guest sends a block write command, it will write 4096 bytes
data at once (2048 per device).

Signed-off-by: David Engraf <david.engraf@sysgo.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: cleaned up and expanded commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-01-27 15:20:22 +00:00
..
acpi machine: Make possible_cpu_arch_ids() return const pointer 2017-01-23 21:25:37 -02:00
adc STM32F2xx: Add the ADC device 2016-10-04 13:28:07 +01:00
arm hw/arm/virt: Add board property to enable EL2 2017-01-20 11:15:11 +00:00
audio Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
block block/qdev: Allow configuring rerror/werror with qdev properties 2016-07-13 13:32:27 +02:00
char char: use qemu_chr_fe* functions with CharBackend argument 2016-10-24 15:27:21 +02:00
core generic-loader: Add a generic loader 2016-10-04 13:28:09 +01:00
cpu qapi: keep names in 'CpuInstanceProperties' in sync with struct CPUCore 2016-06-27 13:15:06 +10:00
cris Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
display Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
dma include: Fix typos found by codespell 2017-01-24 23:26:52 +03:00
gpio Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
i2c i2c: Allow I2C devices to NAK start events 2017-01-09 11:40:20 +00:00
i386 machine: Make possible_cpu_arch_ids() return const pointer 2017-01-23 21:25:37 -02:00
ide ide: Fix memory leak in ide_register_restart_cb() 2016-09-29 15:50:29 -04:00
input adb-keys.h: initial commit 2016-09-23 10:29:40 +10:00
intc hw/intc/arm_gicv3: Implement gicv3_cpuif_virt_update() 2017-01-20 11:15:10 +00:00
ipack ipack: Update e-mail address 2016-05-18 15:04:27 +03:00
ipmi ipmi: rework the fwinfo to be fetched from the interface 2016-06-07 15:36:54 +03:00
isa portio: keep references on portio 2016-09-08 18:05:21 +04:00
kvm
lm32 intc: make HMP 'info irq' and 'info pic' commands use InterruptStatsProvider interface 2016-10-04 10:00:25 +02:00
m68k m68k: QOMify the MCF Fast Ethernet Controller device 2017-01-20 10:36:38 +08:00
mem nvdimm acpi: rename nvdimm_acpi_hotplug 2016-11-15 17:20:37 +02:00
mips Move target-* CPU file into a target/ folder 2016-12-20 21:52:12 +01:00
misc aspeed: add the definitions for the AST2400 A1 SoC 2016-12-27 14:59:28 +00:00
net cadence_gem: Add support for screening 2016-09-22 18:13:07 +01:00
nvram fw-cfg: turn FW_CFG_FILE_SLOTS into a device property 2017-01-18 22:59:53 +02:00
pci PCI/migration merge vmstate_pci_device and vmstate_pcie_device 2017-01-24 18:00:31 +00:00
pci-host include: Fix typos found by codespell 2017-01-24 23:26:52 +03:00
ppc Move target-* CPU file into a target/ folder 2016-12-20 21:52:12 +01:00
s390x s390x/kvm: disable cpu model for the 2.7 machine 2016-09-19 11:05:51 +02:00
scsi Remove unused function declarations 2016-09-15 15:32:22 +03:00
sd Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
sh4 Move target-* CPU file into a target/ folder 2016-12-20 21:52:12 +01:00
smbios smbios: filter based on CONFIG_SMBIOS rather than TARGET 2017-01-16 17:52:34 +01:00
sparc target-sparc: move common cpu initialisation routines to sparc64.c 2017-01-18 22:03:44 +01:00
ssi aspeed/smc: handle SPI flash Command mode 2017-01-20 11:15:08 +00:00
timer target-sparc: implement sun4v RTC 2017-01-18 22:03:44 +01:00
tricore Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
unicore32 Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
usb Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
vfio vfio: Pass an error object to vfio_get_device 2016-10-17 10:58:00 -06:00
virtio First set of s390x patches for 2.9: 2017-01-20 15:53:58 +00:00
watchdog Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
xen xen: create qdev for each backend device 2016-11-22 10:29:39 -08:00
boards.h machine: Make possible_cpu_arch_ids() return const pointer 2017-01-23 21:25:37 -02:00
bt.h bt-hci-csr: drop unused argument 2016-10-08 09:02:19 +03:00
compat.h pflash_cfi01: fix per-device sector length in CFI table 2017-01-27 15:20:22 +00:00
devices.h
elf_ops.h loader: Add AddressSpace loading support to ELFs 2016-09-22 18:13:08 +01:00
empty_slot.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
fw-path-provider.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
hotplug.h qdev: hotplug: drop HotplugHandler.post_plug callback 2016-11-15 17:20:37 +02:00
hw.h hw: move reset handlers from vl.c to hw/core 2017-01-16 17:52:35 +01:00
ide.h
irq.h irq: Remove qemu_irq_intercept_out 2014-10-23 16:41:25 +02:00
loader.h fw-cfg: support writeable blobs 2017-01-18 22:59:53 +02:00
nmi.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
or-irq.h irq: Add a new irq device that allows the ORing of lines 2016-10-04 13:28:07 +01:00
pcmcia.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
platform-bus.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
ptimer.h hw/ptimer: Add "no counter round down" policy 2016-10-24 16:26:52 +01:00
qdev-core.h bus: simplify name handling 2016-09-08 18:05:22 +04:00
qdev-dma.h
qdev-properties.h char: replace PROP_CHR with CharBackend 2016-10-24 15:27:20 +02:00
qdev.h
register.h hw/registerfields.h: Pull FIELD etc macros out of hw/register.h 2017-01-27 15:20:21 +00:00
registerfields.h hw/registerfields.h: Pull FIELD etc macros out of hw/register.h 2017-01-27 15:20:21 +00:00
stream.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
sysbus.h sysbus: Remove ignored return value of FindSysbusDeviceFunc 2016-09-27 17:03:34 -03:00
usb.h usb: Add QOM property "attached". 2016-06-22 12:53:26 +02:00