diff mbox

[1/2] niagara: fail if a firmware file is missing

Message ID 1485206518-32403-1-git-send-email-atar4qemu@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Artyom Tarasenko Jan. 23, 2017, 9:21 p.m. UTC
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
---
 hw/sparc64/niagara.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

Comments

Peter Maydell Jan. 23, 2017, 10:17 p.m. UTC | #1
On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
> ---
>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index b55d4bb..e945b5a 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -35,6 +35,7 @@
>  #include "hw/timer/sun4v-rtc.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/block-backend.h"
> +#include "qemu/error-report.h"
>
>
>  typedef struct NiagaraBoardState {
> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>
> +static void add_rom_or_fail(const char *file, const hwaddr addr)
> +{
> +    if (rom_add_file_fixed(file, addr, -1)) {
> +        error_report("Unable to load a firmware for -M niagara");
> +        exit(1);

It would be nice to include the name of the file in the
error message -- or is that reported already inside
rom_add_file_fixed() somehow?

thanks
-- PMM
Peter Maydell Jan. 23, 2017, 10:18 p.m. UTC | #2
On 23 January 2017 at 22:17, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>> ---
>>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
>> index b55d4bb..e945b5a 100644
>> --- a/hw/sparc64/niagara.c
>> +++ b/hw/sparc64/niagara.c
>> @@ -35,6 +35,7 @@
>>  #include "hw/timer/sun4v-rtc.h"
>>  #include "exec/address-spaces.h"
>>  #include "sysemu/block-backend.h"
>> +#include "qemu/error-report.h"
>>
>>
>>  typedef struct NiagaraBoardState {
>> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>>
>> +static void add_rom_or_fail(const char *file, const hwaddr addr)
>> +{
>> +    if (rom_add_file_fixed(file, addr, -1)) {
>> +        error_report("Unable to load a firmware for -M niagara");
>> +        exit(1);
>
> It would be nice to include the name of the file in the
> error message -- or is that reported already inside
> rom_add_file_fixed() somehow?

PS: doesn't this break 'make check' if the rom files
are missing?

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index b55d4bb..e945b5a 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -35,6 +35,7 @@ 
 #include "hw/timer/sun4v-rtc.h"
 #include "exec/address-spaces.h"
 #include "sysemu/block-backend.h"
+#include "qemu/error-report.h"
 
 
 typedef struct NiagaraBoardState {
@@ -85,6 +86,14 @@  typedef struct NiagaraBoardState {
 #define NIAGARA_OBP_OFFSET  0x80000ULL
 #define PROM_SIZE_MAX       (4 * 1024 * 1024)
 
+static void add_rom_or_fail(const char *file, const hwaddr addr)
+{
+    if (rom_add_file_fixed(file, addr, -1)) {
+        error_report("Unable to load a firmware for -M niagara");
+        exit(1);
+    }
+
+}
 /* Niagara hardware initialisation */
 static void niagara_init(MachineState *machine)
 {
@@ -119,14 +128,13 @@  static void niagara_init(MachineState *machine)
                                          "sun4v.prom", PROM_SIZE_MAX);
     memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom);
 
-    rom_add_file_fixed("nvram1", NIAGARA_NVRAM_BASE, -1);
-    rom_add_file_fixed("1up-md.bin", NIAGARA_MD_ROM_BASE, -1);
-    rom_add_file_fixed("1up-hv.bin", NIAGARA_HV_ROM_BASE, -1);
+    add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE);
+    add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE);
+    add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE);
 
-    rom_add_file_fixed("reset.bin", NIAGARA_PROM_BASE, -1);
-    rom_add_file_fixed("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET, -1);
-    rom_add_file_fixed("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET,
-                       -1);
+    add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE);
+    add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET);
+    add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET);
 
     /* the virtual ramdisk is kind of initrd, but it resides
        outside of the partition RAM */