[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for sy
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition |
Date: |
Wed, 26 Oct 2016 22:42:15 +1100 |
From: Thomas Huth <address@hidden>
The system and free space NVRAM partitions (for OpenBIOS) are created
in exactly the same way as the Mac-style CHRP NVRAM partitions, so we
can use the new common helper functions to do this job here, too.
Signed-off-by: Thomas Huth <address@hidden>
Tested-by: Mark Cave-Ayland <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/sparc/sun4m.c | 33 ++++++---------------------------
hw/sparc64/sun4u.c | 33 ++++++---------------------------
2 files changed, 12 insertions(+), 54 deletions(-)
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index b3915e4..1b8d172 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -39,6 +39,7 @@
#include "hw/scsi/esp.h"
#include "hw/i386/pc.h"
#include "hw/isa/isa.h"
+#include "hw/nvram/chrp_nvram.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/char/escc.h"
#include "hw/empty_slot.h"
@@ -117,39 +118,17 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr,
int nvram_machine_id, const char *arch)
{
unsigned int i;
- uint32_t start, end;
+ int sysp_end;
uint8_t image[0x1ff0];
- struct OpenBIOS_nvpart_v1 *part_header;
NvramClass *k = NVRAM_GET_CLASS(nvram);
memset(image, '\0', sizeof(image));
- start = 0;
+ /* OpenBIOS nvram variables partition */
+ sysp_end = chrp_nvram_create_system_partition(image, 0);
- // OpenBIOS nvram variables
- // Variable partition
- part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
- part_header->signature = OPENBIOS_PART_SYSTEM;
- pstrcpy(part_header->name, sizeof(part_header->name), "system");
-
- end = start + sizeof(struct OpenBIOS_nvpart_v1);
- for (i = 0; i < nb_prom_envs; i++)
- end = OpenBIOS_set_var(image, end, prom_envs[i]);
-
- // End marker
- image[end++] = '\0';
-
- end = start + ((end - start + 15) & ~15);
- OpenBIOS_finish_partition(part_header, end - start);
-
- // free partition
- start = end;
- part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
- part_header->signature = OPENBIOS_PART_FREE;
- pstrcpy(part_header->name, sizeof(part_header->name), "free");
-
- end = 0x1fd0;
- OpenBIOS_finish_partition(part_header, end - start);
+ /* Free space partition */
+ chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr,
nvram_machine_id);
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 7b8134e..83708ab 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -37,6 +37,7 @@
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/nvram/openbios_firmware_abi.h"
+#include "hw/nvram/chrp_nvram.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/sysbus.h"
#include "hw/ide.h"
@@ -124,39 +125,17 @@ static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t
NVRAM_size,
const uint8_t *macaddr)
{
unsigned int i;
- uint32_t start, end;
+ int sysp_end;
uint8_t image[0x1ff0];
- struct OpenBIOS_nvpart_v1 *part_header;
NvramClass *k = NVRAM_GET_CLASS(nvram);
memset(image, '\0', sizeof(image));
- start = 0;
+ /* OpenBIOS nvram variables partition */
+ sysp_end = chrp_nvram_create_system_partition(image, 0);
- // OpenBIOS nvram variables
- // Variable partition
- part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
- part_header->signature = OPENBIOS_PART_SYSTEM;
- pstrcpy(part_header->name, sizeof(part_header->name), "system");
-
- end = start + sizeof(struct OpenBIOS_nvpart_v1);
- for (i = 0; i < nb_prom_envs; i++)
- end = OpenBIOS_set_var(image, end, prom_envs[i]);
-
- // End marker
- image[end++] = '\0';
-
- end = start + ((end - start + 15) & ~15);
- OpenBIOS_finish_partition(part_header, end - start);
-
- // free partition
- start = end;
- part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
- part_header->signature = OPENBIOS_PART_FREE;
- pstrcpy(part_header->name, sizeof(part_header->name), "free");
-
- end = 0x1fd0;
- OpenBIOS_finish_partition(part_header, end - start);
+ /* Free space partition */
+ chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, 0x80);
--
2.7.4
- [Qemu-ppc] [PULL 00/49] ppc-for-2.8 queue 20161026, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 04/49] tests: don't check if qtest_spapr_boot() returns NULL, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 02/49] ppc/xics: Add xics to the monitor "info pic" command, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 03/49] tests: fix memory leak in virtio-scsi-test, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 09/49] spapr_pci: advertise explicit numa IDs even when there's 1 node, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 19/49] ppc: fix MSR_ME handling for system reset interrupt, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 10/49] nvram: Introduce helper functions for CHRP "system" and "free space" partitions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 06/49] tests: rename target_big_endian() as qvirtio_is_big_endian(), David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 08/49] tests: enable virtio tests on SPAPR, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 21/49] ppc: Fix single step with gdb stub, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition,
David Gibson <=
- [Qemu-ppc] [PULL 14/49] target-ppc: implement vnegw/d instructions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 20/49] pseries: Remove unused callbacks from sPAPR VIO bus state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 12/49] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch], David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 07/49] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 18/49] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 35/49] pseries: Make spapr_create_fdt_skel() get information from machine state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 05/49] tests: move QVirtioBus pointer into QVirtioDevice, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 24/49] ppc/pnv: add a PnvChip object, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 33/49] pseries: Split device tree construction from device tree load, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 31/49] ppc/pnv: add a ISA bus, David Gibson, 2016/10/26