Alpha system emulation, v7
Changes v6->v7
* Rebase against master, which now includes 2 patches from v6.
The tree is available at
git://repo.or.cz/qemu/rth.git axp-system-5
Please pull, review, or something.
r~
Richard Henderson (7):
Export the unassigned_mem read/write functions.
pci: Export pci_to_cpu_addr.
target-alpha: Add custom PALcode image for CLIPPER emulation.
target-alpha: Add CLIPPER emulation.
target-alpha: Implement WAIT IPR.
target-alpha: Implement HALT IPR.
target-alpha: Add high-resolution access to wall clock and an alarm.
.gitmodules | 3 + Makefile | 3 +- Makefile.target | 1 + configure | 8 +- cpu-common.h | 7 + default-configs/alpha-softmmu.mak | 2 + exec.c | 12 +- hw/alpha_dp264.c | 188 +++++++++ hw/alpha_pci.c | 358 +++++++++++++++++ hw/alpha_sys.h | 44 ++ hw/alpha_typhoon.c | 799 +++++++++++++++++++++++++++++++++++++ hw/pci.c | 3 +- hw/pci.h | 1 + pc-bios/README | 3 + pc-bios/palcode-clipper | Bin 0 -> 185703 bytes roms/qemu-palcode | 1 + target-alpha/cpu.h | 4 + target-alpha/helper.h | 5 + target-alpha/op_helper.c | 25 ++ target-alpha/translate.c | 50 ++- 20 files changed, 1497 insertions(+), 20 deletions(-) create mode 100644 hw/alpha_dp264.c create mode 100644 hw/alpha_pci.c create mode 100644 hw/alpha_sys.h create mode 100644 hw/alpha_typhoon.c create mode 100755 pc-bios/palcode-clipper create mode 160000 roms/qemu-palcode
Signature · 1 line
1.7.4.4
PATCH 1/7 Export the unassigned_mem read/write functions.
--- cpu-common.h | 7 +++++++ exec.c | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
cpu-common.h +7 -0
@@ -56,6 +56,13 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,cpu_register_physical_memory_offset (start_addr, size, phys_offset,0 ); } +extern CPUReadMemoryFunc unassigned_mem_readb; +extern CPUReadMemoryFunc unassigned_mem_readw; +extern CPUReadMemoryFunc unassigned_mem_readl; +extern CPUWriteMemoryFunc unassigned_mem_writeb; +extern CPUWriteMemoryFunc unassigned_mem_writew; +extern CPUWriteMemoryFunc unassigned_mem_writel; +ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr);ram_addr_t qemu_ram_alloc_from_ptr (DeviceState *dev,const char *name,ram_addr_t size,void *host);
exec.c +6 -6
@@ -3232,7 +3232,7 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)return ram_addr; } -static uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3243,7 +3243,7 @@ static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3254,7 +3254,7 @@ static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);
@@ -3265,7 +3265,7 @@ static uint32_t unassigned_mem_readl(void *opaque, target_phys_addr_t addr)return 0 ; } -static void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
@@ -3275,7 +3275,7 @@ static void unassigned_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
@@ -3285,7 +3285,7 @@ static void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
Signature · 1 line
1.7.4.4
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 1 line · Richard Henderson
Signed-off-by Richard Henderson<[email protected]>
Why?
Regards,
Anthony Liguori
Quoted 81 lines
--- cpu-common.h | 7 +++++++ exec.c | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)cpu-common.h +7
-0@@ -56,6 +56,13 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,cpu_register_physical_memory_offset (start_addr, size, phys_offset,0 ); } +extern CPUReadMemoryFunc unassigned_mem_readb; +extern CPUReadMemoryFunc unassigned_mem_readw; +extern CPUReadMemoryFunc unassigned_mem_readl; +extern CPUWriteMemoryFunc unassigned_mem_writeb; +extern CPUWriteMemoryFunc unassigned_mem_writew; +extern CPUWriteMemoryFunc unassigned_mem_writel; +ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr);ram_addr_t qemu_ram_alloc_from_ptr (DeviceState *dev,const char *name,ram_addr_t size,void *host);exec.c +6
-6@@ -3232,7 +3232,7 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)return ram_addr; } -static uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);@@ -3243,7 +3243,7 @@ static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);@@ -3254,7 +3254,7 @@ static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) +uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr);@@ -3265,7 +3265,7 @@ static uint32_t unassigned_mem_readl(void *opaque, target_phys_addr_t addr)return 0 ; } -static void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);@@ -3275,7 +3275,7 @@ static void unassigned_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);@@ -3285,7 +3285,7 @@ static void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, uint32_#endif } -static void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) +void unassigned_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) {#ifdef DEBUG_UNASSIGNED printf ("Unassigned mem write " TARGET_FMT_plx" = 0x%x\n" , addr, val);
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 4 lines · Anthony Liguori
Quoted 1 line · Richard Henderson
Signed-off-by Richard Henderson<[email protected]>Why?
So that I can write i/o functions like this:
switch (addr) {
case 0: ...
case 64: ...
case 128: ...
...
default:
unassigned_mem_readl(...)
}Perhaps Avi's rewrite makes this unnecessary; I browsed through his patch set but didn't immediately see if there's a way for the i/o function to return "failure".
What I certainly don't want to do is write this with 100 tiny functions registering 8 bytes each, registered some tiny distance away from each other.
r~
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Anthony Liguori
Quoted 1 line · Richard Henderson
Signed-off-by Richard Henderson<[email protected]>Why?
So that I can write i/o functions like this:
switch (addr) { case 0: ... case 64: ... case 128: ... ... default: unassigned_mem_readl(...) }
Quoted 3 lines
Perhaps Avi's rewrite makes this unnecessary; I browsed through his patch set but didn't immediately see if there's a way for the i/o function to return "failure".
What is returned by totally unregistered MMIO is defined by the chipset.
What's returned by an empty space in the MMIO space of a device is
device specific.
What does your device return if there's an access at 32?
Regards,
Anthony Liguori
Quoted 8 lines
What I certainly don't want to do is write this with 100 tiny functions registering 8 bytes each, registered some tiny distance away from each other.
r~
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 3 lines · Anthony Liguori
What is returned by totally unregistered MMIO is defined by the chipset. What's returned by an empty space in the MMIO space of a device is device specific.
It's one and the same here, it's the chipset I'm implementing.
Quoted 1 line
What does your device return if there's an access at 32?
A machine check.
r~
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 6 lines · Richard Henderson
Quoted 3 lines · Anthony Liguori
What is returned by totally unregistered MMIO is defined by the chipset. What's returned by an empty space in the MMIO space of a device is device specific.
It's one and the same here, it's the chipset I'm implementing.
Sorry if its obvious, which patch in the series actually uses this?
Regards,
Anthony Liguori
Quoted 7 lines
Quoted 1 line
What does your device return if there's an access at 32?
A machine check.
r~
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Richard Henderson
Quoted 3 lines · Anthony Liguori
What is returned by totally unregistered MMIO is defined by the chipset. What's returned by an empty space in the MMIO space of a device is device specific.
It's one and the same here, it's the chipset I'm implementing.
Sorry if its obvious, which patch in the series actually uses this?
4/7, see hw/alpha_typhoon.c.
r~
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
In reply to Anthony LiguoriQuoted 18 lines · Anthony Liguori
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Anthony Liguori
Quoted 1 line · Richard Henderson
Signed-off-by Richard Henderson<[email protected]>Why?
So that I can write i/o functions like this:
switch (addr) { case 0: ... case 64: ... case 128: ... ... default: unassigned_mem_readl(...) }
Quoted 7 lines
Quoted 3 lines
Perhaps Avi's rewrite makes this unnecessary; I browsed through his patch set but didn't immediately see if there's a way for the i/o function to return "failure".
What is returned by totally unregistered MMIO is defined by the chipset. What's returned by an empty space in the MMIO space of a device is device specific.
Not really, IMO.
Im not going to say that HW does it this way or another because different HW may do it different ways, but from my experience this how most HW generally works:
Accesses to unmapped addresses are decoded, routed and finally handled by the first node that realizes that the addr is unmapped. The action might be to ignore or to signal some kind of error. AFAIK, most systems will signal the error by sending an error back to the CPU via dedicated control signals or by raising interrupts (the latter is very uncommon).
The common case is to signal an error via ctrl signals on the bus that go back to the CPU and the final decision on what to do is made by the CPU. QEMU currently doesnt model ctrl lines for bus accesses so entering a per CPU xxx_unassigned_acceess function is pretty much in line with most HW.
QEMU only models the data lanes so I think Richards patch is quite OK because it brings the decission back to the CPU model.
I would prefer though, if the new Memory API would let devices pass ctrl data back to the CPU in addition to the data lanes. That would probably involve quite a bit of work though. CC:ing Avi, you might have more input on this.
Cheers
Re: [Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.
Quoted 7 lines · Edgar E. Iglesias
QEMU only models the data lanes so I think Richards patch is quite OK because it brings the decission back to the CPU model.
I would prefer though, if the new Memory API would let devices pass ctrl data back to the CPU in addition to the data lanes. That would probably involve quite a bit of work though. CC:ing Avi, you might have more input on this.
Amusingly, after having updated my system to Avi's tree, I find I don't need the unassigned_mem_read[bwl] helpers anymore, but only the cpu_unassigned_access function, which is already exported.
It would be nice if the new api allowed signaling of errors, but I can't think of a really nice way of doing that.
r~
PATCH 2/7 pci: Export pci_to_cpu_addr.
In reply to Richard HendersonThis is, more or less, the read accessor to pci_bus_set_mem_base as a write accessor. It will be needed for implementing sparse memory spaces for Alpha.
--- hw/pci.c | 3 +-- hw/pci.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
hw/pci.c +1 -2
@@ -820,8 +820,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,return pci_dev; } -static target_phys_addr_t pci_to_cpu_addr (PCIBus *bus, -target_phys_addr_t addr) +target_phys_addr_t pci_to_cpu_addr (PCIBus *bus,target_phys_addr_t addr) {return addr + bus->mem_base; }
hw/pci.h +1 -0
@@ -246,6 +246,7 @@ void pci_device_reset(PCIDevice *dev);void pci_bus_reset (PCIBus *bus);void pci_bus_set_mem_base (PCIBus *bus,target_phys_addr_t base); +target_phys_addr_t pci_to_cpu_addr (PCIBus *bus,target_phys_addr_t addr);PCIDevice *pci_nic_init (NICInfo *nd,const char *default_model,const char *default_devaddr);
Signature · 1 line
1.7.4.4
PATCH 3/7 target-alpha: Add custom PALcode image for CLIPPER emulation.
In reply to Richard Henderson--- .gitmodules | 3 +++ Makefile | 3 ++- configure | 8 +++++++- pc-bios/README | 3 +++ pc-bios/palcode-clipper | Bin 0 -> 185703 bytes roms/qemu-palcode | 1 + 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 pc-bios/palcode-clipper create mode 160000 roms/qemu-palcode
.gitmodules +3 -0
@@ -10,3 +10,6 @@ [submodule "roms/ipxe"] path = roms/ipxe url = git://git.qemu.org/ipxe.git +[submodule "roms/qemu-palcode"] + path = roms/qemu-palcode + url = git://repo.or.cz/qemu-palcode.git
Makefile +2 -1
@@ -243,7 +243,8 @@ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ mpc8544ds.dtb \ multiboot.bin linuxboot.bin \ s390-zipl.rom \ -spapr-rtas.bin slof.bin +spapr-rtas.bin slof.bin \ +palcode-sx164 else BLOBS= endif
configure +7 -1
@@ -3522,7 +3522,13 @@ FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" -for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do +for bios_file in \ + $source_path/pc-bios/*.bin \ + $source_path/pc-bios/*.rom \ + $source_path/pc-bios/*.dtb \ + $source_path/pc-bios/openbios-* \ + $source_path/pc-bios/palcode-* +do FILES="$FILES pc-bios/`basename $bios_file`" done mkdir -p $DIRS
pc-bios/README +3 -0
@@ -32,3 +32,6 @@ - The S390 zipl loader is an addition to the official IBM s390-tools package. That fork is maintained in its own git repository at: git://repo.or.cz/s390-tools.git + +- The Alpha palcode image is available from: + git://repo.or.cz/qemu-palcode.git
pc-bios/palcode-clipper new file binary +0 -0
roms/qemu-palcode new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 7abb12f60eb3069019e9497e193733d77d8f0722
Signature · 1 line
1.7.4.4
PATCH 4/7 target-alpha: Add CLIPPER emulation.
In reply to Richard HendersonThis is a DP264 variant, SMP capable, no unusual hardware present.
The emulation does not currently include any PCI IOMMU code. Hopefully the generic support for that can be merged to HEAD soon.
--- Makefile.target | 1 + default-configs/alpha-softmmu.mak | 2 + hw/alpha_dp264.c | 188 +++++++++ hw/alpha_pci.c | 358 +++++++++++++++++ hw/alpha_sys.h | 44 ++ hw/alpha_typhoon.c | 781 +++++++++++++++++++++++++++++++++++++ 6 files changed, 1374 insertions(+), 0 deletions(-) create mode 100644 hw/alpha_dp264.c create mode 100644 hw/alpha_pci.c create mode 100644 hw/alpha_sys.h create mode 100644 hw/alpha_typhoon.c
Makefile.target +1 -0
@@ -371,6 +371,7 @@ obj-s390x-y = s390-virtio-bus.o s390-virtio.o obj-alpha-y = i8259.o mc146818rtc.o obj-alpha-y += vga.o cirrus_vga.o +obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
default-configs/alpha-softmmu.mak +2 -0
@@ -3,7 +3,9 @@ include pci.mak CONFIG_SERIAL=y CONFIG_I8254=y +CONFIG_PCKBD=y CONFIG_VGA_PCI=y CONFIG_IDE_CORE=y CONFIG_IDE_QDEV=y CONFIG_VMWARE_VGA=y +CONFIG_IDE_CMD646=y
hw/alpha_dp264.c new file +188 -0
188 lines not on this page · raw message
hw/alpha_pci.c new file +335 -0
335 lines not on this page · raw message
+void alpha_pci_vga_setup(PCIBus *pci_bus)
+{
+ switch (vga_interface_type) {
+#ifdef CONFIG_SPICE
+ case VGA_QXL:
+ pci_create_simple(pci_bus, -1, "qxl-vga");
+ return;
+#endif
+ case VGA_CIRRUS:
+ pci_cirrus_vga_init(pci_bus);
+ return;
+ case VGA_VMWARE:
+ if (pci_vmsvga_init(pci_bus)) {
+ return;
+ }
+ break;
+ }
+ /* If VGA is enabled at all, and one of the above didn't work, then
+ fallback to Standard VGA. */
+ if (vga_interface_type != VGA_NONE) {
+ pci_vga_init(pci_bus);
+ }
+}
hw/alpha_sys.h new file +44 -0
44 lines not on this page · raw message
hw/alpha_typhoon.c new file +781 -0
781 lines not on this page · raw message
Signature · 1 line
1.7.4.4
PATCH 5/7 target-alpha: Implement WAIT IPR.
In reply to Richard Henderson--- target-alpha/translate.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
target-alpha/translate.c +21 -10
@@ -1617,9 +1617,10 @@ static void gen_mfpr(int ra, int regno) } } -static void gen_mtpr (int rb,int regno) +static ExitStatus gen_mtpr (DisasContext *ctx,int rb,int regno) {TCGv tmp; +int data;if (rb ==31 ) { tmp =tcg_const_i64 (0 );
@@ -1627,19 +1628,27 @@ static void gen_mtpr(int rb, int regno) tmp = cpu_ir[rb]; } -/* These two register numbers perform a TLB cache flush. Thankfully we -can only do this inside PALmode, which means that the current basic -block cannot be affected by the change in mappings. */ -if (regno ==255 ) { +switch (regno) { +case 255 :/* TBIA */ gen_helper_tbia (); - }else if (regno ==254 ) { +break ; + +case 254 :/* TBIS */ gen_helper_tbis (tmp); - }else { +break ; + +case 253 : +/* WAIT */ + tmp =tcg_const_i64 (1 ); +tcg_gen_st32_i64 (tmp, cpu_env, offsetof(CPUState , halted)); +return gen_excp (ctx,EXCP_HLT ,0 ); + +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */ -int data =cpu_pr_data (regno); + data =cpu_pr_data (regno);if (data !=0 ) {if (data &PR_BYTE ) {tcg_gen_st8_i64 (tmp, cpu_env, data & ~PR_BYTE );
@@ -1649,11 +1658,14 @@ static void gen_mtpr(int rb, int regno) tcg_gen_st_i64(tmp, cpu_env, data); } } +break ; }if (rb ==31 ) {tcg_temp_free (tmp); } + +return NO_EXIT ; }#endif /* !USER_ONLY*/
@@ -3053,8 +3065,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)/* HW_MTPR (PALcode) */ #ifndef CONFIG_USER_ONLY if (ctx->tb->flags &TB_FLAGS_PAL_MODE ) { -gen_mtpr (rb, insn &0xffff ); -break ; +return gen_mtpr (ctx, rb, insn &0xffff ); }#endif goto invalid_opc;
Signature · 1 line
1.7.4.4
Re: [Qemu-devel] [PATCH 5/7] target-alpha: Implement WAIT IPR.
Quoted 1 line · Richard Henderson
---
Misses SoB and I don't know how to add it while pulling. Please fix or educate.
Quoted 84 lines
target-alpha/translate.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)target-alpha/translate.c +16
-7@@ -1617,9 +1617,10 @@ static void gen_mfpr(int ra, int regno) } } -static void gen_mtpr (int rb,int regno) +static ExitStatus gen_mtpr (DisasContext *ctx,int rb,int regno) { TCGv tmp; + int data; if (rb == 31) { tmp = tcg_const_i64(0);@@ -1627,19 +1628,27 @@ static void gen_mtpr(int rb, int regno) tmp = cpu_ir[rb]; } - /* These two register numbers perform a TLB cache flush. Thankfully we - can only do this inside PALmode, which means that the current basic - block cannot be affected by the change in mappings. */ - if (regno == 255) { + switch (regno) { + case 255: /* TBIA */ gen_helper_tbia(); - } else if (regno == 254) { + break; + + case 254: /* TBIS */ gen_helper_tbis(tmp); - } else { + break; + + case 253: + /* WAIT */ + tmp = tcg_const_i64(1); + tcg_gen_st32_i64(tmp, cpu_env, offsetof(CPUState, halted)); + return gen_excp(ctx, EXCP_HLT, 0); + + default: /* The basic registers are data only, and unknown registersare read-zero, write-ignore. */
- int data =cpu_pr_data(regno);
+ data =cpu_pr_data(regno);
if (data != 0) {
if (data &PR_BYTE) {tcg_gen_st8_i64(tmp, cpu_env, data & ~PR_BYTE);target-alpha/translate.c +4
-3@@ -1649,11 +1658,14 @@ static void gen_mtpr(int rb, int regno) tcg_gen_st_i64(tmp, cpu_env, data); } } + break; } if (rb == 31) { tcg_temp_free(tmp); } + + return NO_EXIT; } #endif /* !USER_ONLY*/@@ -3053,8 +3065,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) /* HW_MTPR (PALcode) */ #ifndef CONFIG_USER_ONLY if (ctx->tb->flags & TB_FLAGS_PAL_MODE) { - gen_mtpr(rb, insn & 0xffff); - break; + return gen_mtpr(ctx, rb, insn & 0xffff); } #endif goto invalid_opc; --1.7.4.4
PATCH 6/7 target-alpha: Implement HALT IPR.
In reply to Richard Henderson--- target-alpha/helper.h | 1 + target-alpha/op_helper.c | 10 ++++++++++ target-alpha/translate.c | 5 +++++ 3 files changed, 16 insertions(+), 0 deletions(-)
target-alpha/helper.h +1 -0
@@ -113,6 +113,7 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64) DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void) DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64) +DEF_HELPER_1 (halt, void, i64);#endif #include "def-helper.h"
target-alpha/op_helper.c +10 -0
@@ -21,6 +21,7 @@#include "host-utils.h" #include "softfloat.h" #include "helper.h" +#include "sysemu.h" #include "qemu-timer.h" /*****************************************************************************/
@@ -1215,6 +1216,15 @@ void helper_tbis(uint64_t p) {tlb_flush_page (env, p); } + +void helper_halt (uint64_t restart) +{ +if (restart) { +qemu_system_reset_request (); + }else { +qemu_system_shutdown_request (); + } +}#endif /*****************************************************************************/
target-alpha/translate.c +5 -0
@@ -1645,6 +1645,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)tcg_gen_st32_i64 (tmp, cpu_env, offsetof(CPUState , halted));return gen_excp (ctx,EXCP_HLT ,0 ); +case 252 : +/* HALT */ +gen_helper_halt (tmp); +return EXIT_PC_STALE ; +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */
Signature · 1 line
1.7.4.4
PATCH 7/7 target-alpha: Add high-resolution access to wall clock and an alarm.
In reply to Richard HendersonThe alarm is a fully general one-shot time comparator, which will be usable under Linux as a hrtimer source. It's much more flexible than the RTC source available on real hardware.
The wall clock allows the guest access to the host timekeeping. Much like the KVM wall clock source for other guests.
Both are accessed via the PALcode Cserve entry point.
--- hw/alpha_typhoon.c | 22 ++++++++++++++++++++-- target-alpha/cpu.h | 4 ++++ target-alpha/helper.h | 4 ++++ target-alpha/op_helper.c | 15 +++++++++++++++ target-alpha/translate.c | 14 ++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-)
hw/alpha_typhoon.c +20 -2
@@ -681,6 +681,16 @@ static void typhoon_set_timer_irq(void *opaque, int irq, int level) } } +static void typhoon_alarm_timer (void *opaque) +{ +TyphoonState *s = (TyphoonState *)((uintptr_t )opaque & ~3 ); +int cpu = (uintptr_t )opaque &3 ; + +/* Set the ITI bit for this cpu. */ + s->cchip.misc |=1 << (cpu +4 ); +cpu_interrupt (s->cchip.cpu[cpu],CPU_INTERRUPT_TIMER ); +} +PCIBus *typhoon_init (qemu_irq *p_isa_irq,qemu_irq *p_rtc_irq,CPUState *cpus[3 ],pci_map_irq_fn sys_map_irq) {
@@ -689,14 +699,22 @@ PCIBus *typhoon_init(qemu_irq *p_isa_irq, qemu_irq *p_rtc_irq,PCIHostState *p;TyphoonState *s;PCIBus *b; -int region; +int i, region; dev =qdev_create (NULL ,"typhoon-pcihost" ); p =FROM_SYSBUS (PCIHostState,sysbus_from_qdev (dev)); s =container_of (p, TyphoonState, host);/* Remember the CPUs so that we can deliver interrupts to them. */ -memcpy (s->cchip.cpu, cpus,4 *sizeof (CPUState *)); +for (i =0 ; i <4 ; i++) { +CPUState *env = cpus[i]; + s->cchip.cpu[i] = env; +if (env) { + env->alarm_timer =qemu_new_timer_ns (rtc_clock, + typhoon_alarm_timer, + (void *)((uintptr_t )s + i)); + } + } *p_isa_irq = *qemu_allocate_irqs (typhoon_set_isa_irq, s,1 ); *p_rtc_irq = *qemu_allocate_irqs (typhoon_set_timer_irq, s,1 );
target-alpha/cpu.h +4 -0
@@ -265,6 +265,10 @@ struct CPUAlphaState {uint64_t scratch[24 ];#endif +/* This alarm doesn't exist in real hardware; we wish it did. */ +struct QEMUTimer *alarm_timer; +uint64_t alarm_expire; +#if TARGET_LONG_BITS >HOST_LONG_BITS /* temporary fixed-point registers * used to emulate 64 bits target on 32 bits hosts
target-alpha/helper.h +4 -0
@@ -113,7 +113,11 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64) DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void) DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64) +DEF_HELPER_1 (halt, void, i64); + +DEF_HELPER_FLAGS_0(get_time, TCG_CALL_CONST, i64) +DEF_HELPER_FLAGS_1(set_alarm, TCG_CALL_CONST, void, i64)#endif #include "def-helper.h"
target-alpha/op_helper.c +15 -0
@@ -1225,6 +1225,21 @@ void helper_halt(uint64_t restart) qemu_system_shutdown_request(); } } + +uint64_t helper_get_time (void ) +{ +return qemu_get_clock_ns (rtc_clock); +} + +void helper_set_alarm (uint64_t expire) +{ +if (expire) { + env->alarm_expire = expire; +qemu_mod_timer (env->alarm_timer, expire); + }else { +qemu_del_timer (env->alarm_timer); + } +}#endif /*****************************************************************************/
target-alpha/translate.c +14 -0
@@ -1590,6 +1590,9 @@ static int cpu_pr_data(int pr) return offsetof(CPUAlphaState, shadow[pr - 32]); case 40 ... 63: return offsetof(CPUAlphaState, scratch[pr - 40]); + +case 251 : +return offsetof(CPUAlphaState , alarm_expire); }return 0 ; }
@@ -1604,6 +1607,12 @@ static void gen_mfpr(int ra, int regno)return ; } +if (regno ==250 ) { +/* WALL_TIME */ +gen_helper_get_time (cpu_ir[ra]); +return ; + } +/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */ if (data ==0 ) {
@@ -1650,6 +1659,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)gen_helper_halt (tmp);return EXIT_PC_STALE ; +case 251 : +/* ALARM */ +gen_helper_set_alarm (tmp); +break ; +default :/* The basic registers are data only, and unknown registers are read-zero, write-ignore. */
Signature · 1 line
1.7.4.4