aboutsummaryrefslogtreecommitdiff
path: root/hw/sh4/r2d.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/sh4/r2d.c')
-rw-r--r--hw/sh4/r2d.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 006010f..7275941 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qapi/error.h"
+#include "qemu/error-report.h"
#include "cpu.h"
#include "hw/sysbus.h"
#include "hw/sh4/sh.h"
@@ -56,10 +57,10 @@
#define LINUX_LOAD_OFFSET 0x0800000
#define INITRD_LOAD_OFFSET 0x1800000
-#define PA_IRLMSK 0x00
-#define PA_POWOFF 0x30
-#define PA_VERREG 0x32
-#define PA_OUTPORT 0x36
+#define PA_IRLMSK 0x00
+#define PA_POWOFF 0x30
+#define PA_VERREG 0x32
+#define PA_OUTPORT 0x36
typedef struct {
uint16_t bcr;
@@ -96,38 +97,41 @@ enum r2d_fpga_irq {
};
static const struct { short irl; uint16_t msk; } irqtab[NR_IRQS] = {
- [CF_IDE] = { 1, 1<<9 },
- [CF_CD] = { 2, 1<<8 },
- [PCI_INTA] = { 9, 1<<14 },
- [PCI_INTB] = { 10, 1<<13 },
- [PCI_INTC] = { 3, 1<<12 },
- [PCI_INTD] = { 0, 1<<11 },
- [SM501] = { 4, 1<<10 },
- [KEY] = { 5, 1<<6 },
- [RTC_A] = { 6, 1<<5 },
- [RTC_T] = { 7, 1<<4 },
- [SDCARD] = { 8, 1<<7 },
- [EXT] = { 11, 1<<0 },
- [TP] = { 12, 1<<15 },
+ [CF_IDE] = { 1, 1 << 9 },
+ [CF_CD] = { 2, 1 << 8 },
+ [PCI_INTA] = { 9, 1 << 14 },
+ [PCI_INTB] = { 10, 1 << 13 },
+ [PCI_INTC] = { 3, 1 << 12 },
+ [PCI_INTD] = { 0, 1 << 11 },
+ [SM501] = { 4, 1 << 10 },
+ [KEY] = { 5, 1 << 6 },
+ [RTC_A] = { 6, 1 << 5 },
+ [RTC_T] = { 7, 1 << 4 },
+ [SDCARD] = { 8, 1 << 7 },
+ [EXT] = { 11, 1 << 0 },
+ [TP] = { 12, 1 << 15 },
};
static void update_irl(r2d_fpga_t *fpga)
{
int i, irl = 15;
- for (i = 0; i < NR_IRQS; i++)
- if (fpga->irlmon & fpga->irlmsk & irqtab[i].msk)
- if (irqtab[i].irl < irl)
- irl = irqtab[i].irl;
+ for (i = 0; i < NR_IRQS; i++) {
+ if ((fpga->irlmon & fpga->irlmsk & irqtab[i].msk) &&
+ irqtab[i].irl < irl) {
+ irl = irqtab[i].irl;
+ }
+ }
qemu_set_irq(fpga->irl, irl ^ 15);
}
static void r2d_fpga_irq_set(void *opaque, int n, int level)
{
r2d_fpga_t *fpga = opaque;
- if (level)
+ if (level) {
fpga->irlmon |= irqtab[n].msk;
- else
+ } else {
fpga->irlmon &= ~irqtab[n].msk;
+ }
update_irl(fpga);
}
@@ -306,7 +310,7 @@ static void r2d_init(MachineState *machine)
/* NIC: rtl8139 on-board, and 2 slots. */
for (i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], pci_bus,
- "rtl8139", i==0 ? "2" : NULL);
+ "rtl8139", i == 0 ? "2" : NULL);
/* USB keyboard */
usb_create_simple(usb_bus_find(-1), "usb-kbd");
@@ -321,8 +325,8 @@ static void r2d_init(MachineState *machine)
SDRAM_BASE + LINUX_LOAD_OFFSET,
INITRD_LOAD_OFFSET - LINUX_LOAD_OFFSET);
if (kernel_size < 0) {
- fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
- exit(1);
+ error_report("qemu: could not load kernel '%s'", kernel_filename);
+ exit(1);
}
/* initialization which should be done by firmware */
@@ -330,7 +334,8 @@ static void r2d_init(MachineState *machine)
MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 SDRAM */
address_space_stw(&address_space_memory, SH7750_BCR2, 3 << (3 * 2),
MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 32bit */
- reset_info->vector = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000; /* Start from P2 area */
+ /* Start from P2 area */
+ reset_info->vector = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000;
}
if (initrd_filename) {
@@ -341,8 +346,8 @@ static void r2d_init(MachineState *machine)
SDRAM_SIZE - INITRD_LOAD_OFFSET);
if (initrd_size < 0) {
- fprintf(stderr, "qemu: could not load initrd '%s'\n", initrd_filename);
- exit(1);
+ error_report("qemu: could not load initrd '%s'", initrd_filename);
+ exit(1);
}
/* initialization which should be done by firmware */
@@ -352,8 +357,10 @@ static void r2d_init(MachineState *machine)
}
if (kernel_cmdline) {
- /* I see no evidence that this .kernel_cmdline buffer requires
- NUL-termination, so using strncpy should be ok. */
+ /*
+ * I see no evidence that this .kernel_cmdline buffer requires
+ * NUL-termination, so using strncpy should be ok.
+ */
strncpy(boot_params.kernel_cmdline, kernel_cmdline,
sizeof(boot_params.kernel_cmdline));
}