Skip to content

Commit 80f9321

Browse files
committed
ppc/pnv: Add a default formatted PNOR image
The default PNOR image is erased and not recognised by skiboot, so NVRAM gets disabled. This change adds a tiny pnor file that is a proper FFS image with a formatted NVRAM partition. This is recognised by skiboot and will persist across machine reboots. Signed-off-by: Nicholas Piggin <[email protected]>
1 parent 4c84a0a commit 80f9321

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,7 @@ F: include/hw/ppc/pnv*
15371537
F: include/hw/pci-host/pnv*
15381538
F: include/hw/ssi/pnv_spi*
15391539
F: pc-bios/skiboot.lid
1540+
F: pc-bios/pnv-pnor.bin
15401541
F: tests/qtest/pnv*
15411542
F: tests/functional/test_ppc64_powernv.py
15421543

docs/system/ppc/powernv.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ Use a MTD drive to add a PNOR to the machine, and get a NVRAM :
195195
196196
-drive file=./witherspoon.pnor,format=raw,if=mtd
197197
198+
If no mtd drive is provided, the powernv platform will create a default
199+
PNOR device using a tiny formatted PNOR in pc-bios/pnv-pnor.bin opened
200+
read-only (PNOR changes will be persistent across reboots but not across
201+
invocations of QEMU). If no defaults are used, an erased 128MB PNOR is
202+
provided (which skiboot will probably not recognize since it is not
203+
formatted).
204+
198205
Maintainer contact information
199206
------------------------------
200207

hw/ppc/pnv.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
#define FW_LOAD_ADDR 0x0
6565
#define FW_MAX_SIZE (16 * MiB)
6666

67+
#define PNOR_FILE_NAME "pnv-pnor.bin"
68+
6769
#define KERNEL_LOAD_ADDR 0x20000000
6870
#define KERNEL_MAX_SIZE (128 * MiB)
6971
#define INITRD_LOAD_ADDR 0x28000000
@@ -941,7 +943,7 @@ static void pnv_init(MachineState *machine)
941943
uint64_t chip_ram_start = 0;
942944
int i;
943945
char *chip_typename;
944-
DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
946+
DriveInfo *pnor;
945947
DeviceState *dev;
946948

947949
if (kvm_enabled()) {
@@ -971,6 +973,18 @@ static void pnv_init(MachineState *machine)
971973
* Create our simple PNOR device
972974
*/
973975
dev = qdev_new(TYPE_PNV_PNOR);
976+
pnor = drive_get(IF_MTD, 0, 0);
977+
if (!pnor && defaults_enabled()) {
978+
fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, PNOR_FILE_NAME);
979+
if (!fw_filename) {
980+
warn_report("Could not find PNOR '%s'", PNOR_FILE_NAME);
981+
} else {
982+
QemuOpts *opts;
983+
opts = drive_add(IF_MTD, -1, fw_filename, "format=raw,readonly=on");
984+
pnor = drive_new(opts, IF_MTD, &error_fatal);
985+
g_free(fw_filename);
986+
}
987+
}
974988
if (pnor) {
975989
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(pnor));
976990
}

pc-bios/README

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@
4343
run an hypervisor OS or simply a host OS on the "baremetal"
4444
platform, also known as the PowerNV (Non-Virtualized) platform.
4545

46+
- pnv-pnor.bin is a non-volatile RAM image used by PowerNV, which stores
47+
NVRAM BIOS settings among other things. This image was created with the
48+
following command (the ffspart tool can be found in the skiboot source tree):
49+
50+
ffspart -s 0x1000 -c 34 -i pnv-pnor.in -p pnv-pnor.bin
51+
52+
Where pnv-pnor.in contains the two lines (no leading whitespace):
53+
54+
NVRAM,0x01000,0x00020000,,,/dev/zero
55+
VERSION,0x21000,0x00001000,,,/dev/zero
56+
57+
skiboot is then booted once to format the NVRAM partition.
58+
4659
- QemuMacDrivers (https://github.com/ozbenh/QemuMacDrivers) is a project to
4760
provide virtualised drivers for PPC MacOS guests.
4861

pc-bios/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ blobs = [
7070
's390-ccw.img',
7171
'slof.bin',
7272
'skiboot.lid',
73+
'pnv-pnor.bin',
7374
'palcode-clipper',
7475
'u-boot.e500',
7576
'u-boot-sam460-20100605.bin',

pc-bios/pnv-pnor.bin

136 KB
Binary file not shown.

0 commit comments

Comments
 (0)