QEMU OpenRISC support
Re: [Qemu-devel] [PATCH v5 11/16] target-or32: Add a IIS dummy board
In reply to Max FilippovHi Max,
Quoted 12 lines · Max Filippov
Quoted 3 lines · Jia Liu
Add a dummy board for IIS.
Signed-off-by Jia Liu<[email protected]>[...]
Quoted 3 lines
+ if (nd_table[0].vlan) {
+ isa_ne2000_init(isa_bus,0x92000000, 4,&nd_table[0]);
+ }
Quoted 6 lines
I have noticed that the kernel you provided expects OpenCores ethernet device.
We have a model for it (: You can look atlx60_net_init()in thehw/xtensa_lx60.c
to see how it may be connected.
Thank you very much for remind me!
Is this code OK?
static void or1200_net_init(MemoryRegion *address_space,
target_phys_addr_t base, target_phys_addr_t buffers, qemu_irq irq, NICInfo *nd)
{
DeviceState *dev;
SysBusDevice *s;
MemoryRegion *ram;
dev = qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
memory_region_add_subregion(get_system_memory(), base,
sysbus_mmio_get_region(s, 0));
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "open_eth.ram", 0x100);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space, buffers, ram);
} if (nd_table[0].vlan) {
or1200_net_init(get_system_memory(), 0x92000000,
0x92100000, env->irq[4], nd_table);
}Quoted 3 lines
--
Thanks.
-- Max
Regards,
Jia.
Re: [Qemu-devel] [PATCH v5 11/16] target-or32: Add a IIS dummy board
Quoted 44 lines · Jia Liu
Hi Max,
Quoted 12 lines · Max Filippov
Quoted 3 lines · Jia Liu
Add a dummy board for IIS.
Signed-off-by Jia Liu<[email protected]>[...]
Quoted 3 lines
+ if (nd_table[0].vlan) {
+ isa_ne2000_init(isa_bus,0x92000000, 4,&nd_table[0]);
+ }Quoted 6 lines
I have noticed that the kernel you provided expects OpenCores ethernet device.
We have a model for it (: You can look atlx60_net_init()in thehw/xtensa_lx60.c
to see how it may be connected.Thank you very much for remind me!
Is this code OK?
static void or1200_net_init(MemoryRegion
*address_space,target_phys_addr_tbase,target_phys_addr_tbuffers,qemu_irqirq, NICInfo *nd) {
DeviceState *dev;
SysBusDevice *s;
MemoryRegion *ram;dev =
qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);s =
sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);memory_region_add_subregion(get_system_memory(), base, sysbus_mmio_get_region(s, 0));
Quoted 5 lines
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "open_eth.ram", 0x100);vmstate_register_ram_global(ram);memory_region_add_subregion(address_space, buffers, ram); }
You haven't mapped descriptors window. Seems to me it should look like this:
static void or1200_net_init(MemoryRegion *address_space,
target_phys_addr_t base, target_phys_addr_t descriptors, qemu_irq irq, NICInfo *nd)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
memory_region_add_subregion(address_space, base,
sysbus_mmio_get_region(s, 0));
memory_region_add_subregion(address_space, descriptors,
sysbus_mmio_get_region(s, 1));
}Quoted 6 lines
if (nd_table[0].vlan) {
or1200_net_init(get_system_memory(), 0x92000000, 0x92100000, env->irq[4], nd_table); }
Also I haven't found where 0x92100000 comes from. Is there a memory map documentation for this machine?
Signature · 2 lines
Thanks. -- Max
Re: [Qemu-devel] [PATCH v5 11/16] target-or32: Add a IIS dummy board
Hi Max,
Quoted 65 lines · Max Filippov
Quoted 44 lines · Jia Liu
Hi Max,
Quoted 12 lines · Max Filippov
Quoted 3 lines · Jia Liu
Add a dummy board for IIS.
Signed-off-by Jia Liu<[email protected]>[...]
Quoted 3 lines
+ if (nd_table[0].vlan) {
+ isa_ne2000_init(isa_bus,0x92000000, 4,&nd_table[0]);
+ }Quoted 6 lines
I have noticed that the kernel you provided expects OpenCores ethernet device.
We have a model for it (: You can look atlx60_net_init()in thehw/xtensa_lx60.c
to see how it may be connected.Thank you very much for remind me!
Is this code OK?
static void or1200_net_init(MemoryRegion
*address_space,target_phys_addr_tbase,target_phys_addr_tbuffers,qemu_irqirq, NICInfo *nd) {
DeviceState *dev;
SysBusDevice *s;
MemoryRegion *ram;dev =
qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);s =
sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);memory_region_add_subregion(get_system_memory(), base, sysbus_mmio_get_region(s, 0));Quoted 5 lines
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "open_eth.ram", 0x100);vmstate_register_ram_global(ram);memory_region_add_subregion(address_space, buffers, ram); }You haven't mapped descriptors window. Seems to me it should look like this:
static void or1200_net_init(MemoryRegion
*address_space,target_phys_addr_tbase,target_phys_addr_tdescriptors,
qemu_irq irq, NICInfo *nd)
{
DeviceState *dev;
SysBusDevice *s;dev =
qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
Quoted 8 lines
s =
sysbus_from_qdev(dev);sysbus_connect_irq(s, 0, irq);memory_region_add_subregion(address_space, base, sysbus_mmio_get_region(s, 0));memory_region_add_subregion(address_space, descriptors, sysbus_mmio_get_region(s, 1));
}
Thank you very much for the code.
Quoted 10 lines
Quoted 6 lines
if (nd_table[0].vlan) {
or1200_net_init(get_system_memory(), 0x92000000, 0x92100000, env->irq[4], nd_table); }Also I haven't found where
0x92100000comes from. Is there a memory map documentation for this machine?
I'm confused about descriptors, I'm not sure whether 0x92100000 is suitable.
I find the code in linux/arch/openrisc/boot/dts/or1ksim.dts
enet0: ethoc@92000000 {
compatible = "opencores,ethmac-rtlsvn338";
reg = <0x92000000 0x100>;
interrupts = <4>;
};but I'm not sure what value should a pass to target_phys_addr_t descriptors, that is, I don't know how can I get the address of descriptors.
Will you please give me more comment about it? I have no idea how to deal with it.
Quoted 3 lines
--
Thanks.
-- Max
Regards,
Jia.
Re: [Qemu-devel] [PATCH v5 11/16] target-or32: Add a IIS dummy board
Quoted 99 lines · Jia Liu
Hi Max,
Quoted 65 lines · Max Filippov
Quoted 44 lines · Jia Liu
Hi Max,
Quoted 12 lines · Max Filippov
Quoted 3 lines · Jia Liu
Add a dummy board for IIS.
Signed-off-by Jia Liu<[email protected]>[...]
Quoted 3 lines
+ if (nd_table[0].vlan) {
+ isa_ne2000_init(isa_bus,0x92000000, 4,&nd_table[0]);
+ }Quoted 6 lines
I have noticed that the kernel you provided expects OpenCores ethernet device.
We have a model for it (: You can look atlx60_net_init()in thehw/xtensa_lx60.c
to see how it may be connected.Thank you very much for remind me!
Is this code OK?
static void or1200_net_init(MemoryRegion
*address_space,target_phys_addr_tbase,target_phys_addr_tbuffers,qemu_irqirq, NICInfo *nd) {
DeviceState *dev;
SysBusDevice *s;
MemoryRegion *ram;dev =
qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);s =
sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);memory_region_add_subregion(get_system_memory(), base, sysbus_mmio_get_region(s, 0));Quoted 5 lines
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "open_eth.ram", 0x100);vmstate_register_ram_global(ram);memory_region_add_subregion(address_space, buffers, ram); }You haven't mapped descriptors window. Seems to me it should look like this:
static void or1200_net_init(MemoryRegion
*address_space,target_phys_addr_tbase,target_phys_addr_tdescriptors,
qemu_irq irq, NICInfo *nd)
{
DeviceState *dev;
SysBusDevice *s;dev =
qdev_create(NULL, "open_eth");
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);Quoted 8 lines
s =
sysbus_from_qdev(dev);sysbus_connect_irq(s, 0, irq);memory_region_add_subregion(address_space, base, sysbus_mmio_get_region(s, 0));memory_region_add_subregion(address_space, descriptors, sysbus_mmio_get_region(s, 1));
}Thank you very much for the code.
Quoted 10 lines
Quoted 6 lines
if (nd_table[0].vlan) {
or1200_net_init(get_system_memory(), 0x92000000, 0x92100000, env->irq[4], nd_table); }Also I haven't found where
0x92100000comes from. Is there a memory map documentation for this machine?I'm confused about descriptors, I'm not sure whether
0x92100000is suitable.I find the code in
linux/arch/openrisc/boot/dts/or1ksim.dts
enet0: ethoc@92000000 {
compatible = "opencores,ethmac-rtlsvn338"; reg = <0x920000000x100>; interrupts = <4>;
};
Quoted 3 lines
but I'm not sure what value should a pass to target_phys_addr_t descriptors, that is, I don't know how can I get the address of descriptors.
Ok, with
if (nd_table[0].vlan) {
- isa_ne2000_init(isa_bus, 0x92000000, 4, &nd_table[0]);
+ openrisc_sim_net_init(get_system_memory(), 0x92000000,
+ 0x92000400, env->irq[4], nd_table);
}I was able to ping the host from the guest. I guess that from OpenCores ethernet perspective descriptors window is a logical continuation of the registers window,
always starting at offset 0x400.
I will post a patch that you can squish into this ISS dummy board patch.
Signature · 2 lines
Thanks. -- Max
PATCH 1/1 target-or32: replace NE2000 with OpenCores 10/100 ethernet adapter
--- default-configs/or32-softmmu.mak | 2 +- hw/openrisc_sim.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-)
default-configs/or32-softmmu.mak +1 -1
@@ -2,5 +2,5 @@ include pci.mak CONFIG_SERIAL=y -CONFIG_NE2000_ISA=y +CONFIG_OPENCORES_ETH=y CONFIG_I8259=y
hw/openrisc_sim.c +23 -1
@@ -28,6 +28,7 @@#include "sysemu.h" #include "isa.h" #include "qtest.h" +#include "sysbus.h" #define KERNEL_LOAD_ADDR 0x100
@@ -80,6 +81,26 @@ static uint64_t openrisc_load_kernel(void)return entry; } +static void openrisc_sim_net_init (MemoryRegion *address_space, +target_phys_addr_t base, +target_phys_addr_t descriptors, +qemu_irq irq,NICInfo *nd) +{ +DeviceState *dev; +SysBusDevice *s; + + dev =qdev_create (NULL ,"open_eth" ); +qdev_set_nic_properties (dev, nd); +qdev_init_nofail (dev); + + s =sysbus_from_qdev (dev); +sysbus_connect_irq (s,0 , irq); +memory_region_add_subregion (address_space, base, +sysbus_mmio_get_region (s,0 )); +memory_region_add_subregion (address_space, descriptors, +sysbus_mmio_get_region (s,1 )); +} + static void openrisc_sim_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,
@@ -125,7 +146,8 @@ static void openrisc_sim_init(ram_addr_t ram_size, env->irq[2], 115200, serial_hds[0], DEVICE_NATIVE_ENDIAN);if (nd_table[0 ].vlan) { -isa_ne2000_init (isa_bus,0x92000000 ,4 , &nd_table[0 ]); +openrisc_sim_net_init (get_system_memory (),0x92000000 , +0x92000400 , env->irq[4 ], nd_table); } }
Signature · 1 line
1.7.7.6
Re: [Qemu-devel] [PATCH] target-or32: replace NE2000 with OpenCores 10/100 ethernet adapter
Hi Max,
Quoted 57 lines · Max Filippov
Signed-off-by Max Filippov <[email protected]>---
default-configs/or32-softmmu.mak | 2 +-hw/openrisc_sim.c| 24 +++++++++++++++++++++++-2 files changed, 24 insertions(+), 2 deletions(-)default-configs/or32-softmmu.mak +0
-0@@ -2,5 +2,5 @@include pci.mak
CONFIG_SERIAL=ydefault-configs/or32-softmmu.mak +1
-1-CONFIG_NE2000_ISA=y +CONFIG_OPENCORES_ETH=yCONFIG_I8259=y
hw/openrisc_sim.c +21
-0@@ -28,6 +28,7 @@ #include "sysemu.h" #include "isa.h" #include "qtest.h" +#include "sysbus.h" #define KERNEL_LOAD_ADDR 0x100@@ -80,6 +81,26 @@ static uint64_t openrisc_load_kernel(void) return entry; } +static void openrisc_sim_net_init (MemoryRegion *address_space, + target_phys_addr_t base, + target_phys_addr_t descriptors, + qemu_irq irq, NICInfo *nd) +{ + DeviceState *dev; + SysBusDevice *s; + + dev = qdev_create(NULL, "open_eth"); + qdev_set_nic_properties(dev, nd); + qdev_init_nofail(dev); + + s = sysbus_from_qdev(dev); + sysbus_connect_irq(s, 0, irq); + memory_region_add_subregion(address_space, base, + sysbus_mmio_get_region(s, 0)); + memory_region_add_subregion(address_space, descriptors, + sysbus_mmio_get_region(s, 1)); +} + static void openrisc_sim_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,
hw/openrisc_sim.c static void openrisc_sim_init(ram_addr_t ram_size, · line 153
Quoted 9 lines
hw/openrisc_sim.c +2
-1@@ -125,7 +146,8 @@ static void openrisc_sim_init(ram_addr_t ram_size, env->irq[2], 115200, serial_hds[0], DEVICE_NATIVE_ENDIAN); if (nd_table[0].vlan) { - isa_ne2000_init(isa_bus, 0x92000000, 4, &nd_table[0]); + openrisc_sim_net_init(get_system_memory(), 0x92000000, + 0x92000400, env->irq[4], nd_table); } }
Thank you very much!
I've combine it into v6 patches.
Quoted 3 lines
--
1.7.7.6
Regards,
Jia.
PATCH v5 12/16 target-or32: Add system instructions
In reply to Jia LiuAdd OpenRISC system instruction support.
--- target-openrisc/Makefile.objs | 3 +- target-openrisc/helper.h | 4 + target-openrisc/sys_helper.c | 233 +++++++++++++++++++++++++++++++++++++++++ target-openrisc/translate.c | 20 ++++ 4 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 target-openrisc/sys_helper.c
target-openrisc/Makefile.objs +2 -1
@@ -1,3 +1,4 @@ obj-$(CONFIG_SOFTMMU) += machine.o obj-y += cpu.o excp.o intrpt.o mmu.o translate.o -obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o mmu_helper.o +obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o \ + mmu_helper.o sys_helper.o
target-openrisc/helper.h +4 -0
@@ -62,4 +62,8 @@ DEF_HELPER_FLAGS_1(fl1, 0, tl, tl)/* interrupt */ DEF_HELPER_FLAGS_1 (rfe,0 , void, env) +/* sys */ +DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) +DEF_HELPER_FLAGS_4(mfspr, 0, void, env, tl, tl, tl) +#include "def-helper.h"
target-openrisc/sys_helper.c new file +233 -0
233 lines not on this page · raw message
target-openrisc/translate.c +20 -0
@@ -1241,10 +1241,30 @@ static void dec_misc(DisasContext *dc, CPUOpenRISCState *env, uint32_t insn)case 0x2d :/*l.mfspr*/ LOG_DIS ("l.mfspr r%d, r%d, %d\n" , rd, ra,I16 ); + { +TCGv_i32 ti =tcg_const_i32 (I16 ); +TCGv td =tcg_const_tl (rd); +TCGv ta =tcg_const_tl (ra); +gen_helper_mfspr (cpu_env, td, ta, ti); +tcg_temp_free_i32 (ti); +tcg_temp_free (td); +tcg_temp_free (ta); + }break ;case 0x30 :/*l.mtspr*/ LOG_DIS ("l.mtspr %d, r%d, r%d, %d\n" ,I5 , ra, rb,I11 ); + { +TCGv_i32 im =tcg_const_i32 (tmp); +TCGv ta =tcg_temp_new (); +TCGv tb =tcg_temp_new (); +tcg_gen_mov_tl (ta, cpu_R[ra]); +tcg_gen_mov_tl (tb, cpu_R[rb]); +gen_helper_mtspr (cpu_env, ta, tb, im); +tcg_temp_free_i32 (im); +tcg_temp_free (ta); +tcg_temp_free (tb); + }break ;case 0x34 :/*l.sd*/
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v5 12/16] target-or32: Add system instructions
Quoted 167 lines · Jia Liu
Add OpenRISC system instruction support.
Signed-off-by Jia Liu <[email protected]>---
target-openrisc/Makefile.objs | 3 +-
target-openrisc/helper.h | 4 +target-openrisc/sys_helper.c| 233 +++++++++++++++++++++++++++++++++++++++++target-openrisc/translate.c| 20 ++++4 files changed, 259 insertions(+), 1 deletion(-)create mode 100644
target-openrisc/sys_helper.ctarget-openrisc/Makefile.objs +0
-0@@ -1,3 +1,4 @@obj-$(CONFIG_SOFTMMU) += machine.o
obj-y += cpu.o excp.o intrpt.o mmu.o translate.otarget-openrisc/Makefile.objs +2
-1-obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o mmu_helper.o +obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o \ + mmu_helper.o sys_helper.otarget-openrisc/helper.h +4
-0@@ -62,4 +62,8 @@ DEF_HELPER_FLAGS_1(fl1, 0, tl, tl) /* interrupt */ DEF_HELPER_FLAGS_1(rfe, 0, void, env) +/* sys */ +DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) +DEF_HELPER_FLAGS_4(mfspr, 0, void, env, tl, tl, tl) + #include "def-helper.h"target-openrisc/sys_helper.c new file +127
-0@@ -0,0 +1,233 @@ +/* +* OpenRISC system instructions helper routines +* +* Copyright (c) 2011-2012 Jia Liu <[email protected]> +* Zhizhou Zhang <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "cpu.h" +#include "helper.h" + +#define TO_SPR (group, number) (((group) << 11) + (number)) + +void HELPER (mtspr )(CPUOpenRISCState * env, + target_ulong ra, target_ulong rb, target_ulong offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = (ra | offset); + int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->vr = rb; + break; + + case TO_SPR(0, 16): /* NPC */ + env->npc = rb; + break; + + case TO_SPR(0, 17): /* SR */ + if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ + (rb & (SR_IME | SR_DME | SR_SM))) { + tlb_flush(env, 1); + } + env->sr = rb; + env->sr |= SR_FO; /* FO is const equal to 1 */ + if (env->sr & SR_DME) { + env->tlb->map_address_data = &get_phys_data; + } else { + env->tlb->map_address_data = &get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->map_address_code = &get_phys_code; + } else { + env->tlb->map_address_code = &get_phys_nommu; + } + break; + + case TO_SPR(0, 18): /* PPC */ + env->ppc = rb; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->epcr = rb; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->eear = rb; + break; + + case TO_SPR(0, 64): /* ESR */ + env->esr = rb; + break; + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->dtlb[0][idx].mr = rb; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->tlb->dtlb[0][idx].tr = rb; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->itlb[0][idx].mr = rb; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->tlb->itlb[0][idx].tr = rb; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */ + cpu_openrisc_store_picmr(env, rb); + break; + case TO_SPR(9, 2): /* PICSR */ + cpu_openrisc_store_picsr(env, rb); + break; + case TO_SPR(10, 0): /* TTMR */ + cpu_openrisc_store_compare(env, rb); + break; + case TO_SPR(10, 1): /* TTCR */ + cpu_openrisc_store_count(env, rb); + break; + default:
target-openrisc/sys_helper.c line 137
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ break; + } +#endif +} + +void HELPER (mfspr )(CPUOpenRISCState * env, + target_ulong rd, target_ulong ra, uint32_t offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = env->gpr[ra] | offset;
[1]
Quoted 80 lines
target-openrisc/sys_helper.c new file +80
-0+ int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->gpr[rd] = (env->vr & SPR_VR); + break; + + case TO_SPR(0, 1): /* UPR */ + env->gpr[rd] = env->upr; /* TT, DM, IM, UP present */ + break; + + case TO_SPR(0, 2): /* CPUCFGR */ + env->gpr[rd] = env->cpucfgr; + break; + + case TO_SPR(0, 3): /* DMMUCFGR */ + env->gpr[rd] = env->dmmucfgr; /* 1Way, 64 entries */ + break; + case TO_SPR(0, 4): /* IMMUCFGR */ + env->gpr[rd] = env->immucfgr; + break; + + case TO_SPR(0, 16): /* NPC */ + env->gpr[rd] = env->npc; + break; + + case TO_SPR(0, 17): /* SR */ + env->gpr[rd] = env->sr; + break; + + case TO_SPR(0, 18): /* PPC */ + env->gpr[rd] = env->ppc; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->gpr[rd] = env->epcr; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->gpr[rd] = env->eear; + break; + + case TO_SPR(0, 64): /* ESR */ + env->gpr[rd] = env->esr; + break; + + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + env->gpr[rd] = env->tlb->dtlb[0][idx].mr; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->gpr[rd] = env->tlb->dtlb[0][idx].tr; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + env->gpr[rd] = env->tlb->itlb[0][idx].mr; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->gpr[rd] = env->tlb->itlb[0][idx].tr; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */
target-openrisc/sys_helper.c line 227
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ env->gpr[rd] = env->picmr; + break; + case TO_SPR(9, 2): /* PICSR */ + env->gpr[rd] = env->picsr; + break; + case TO_SPR(10, 0): /* TTMR */ + env->gpr[rd] = env->ttmr; + break; + case TO_SPR(10, 1): /* TTCR */ + env->gpr[rd] = cpu_openrisc_get_count(env);
[2]
Quoted 12 lines
target-openrisc/sys_helper.c new file +6
-0+ break; + default: + break; + } +#endif +}target-openrisc/translate.c +0
-0@@ -1241,10 +1241,30 @@ static void dec_misc(DisasContext *dc, CPUOpenRISCState *env, uint32_t insn)
Quoted 7 lines
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
+ {
+ TCGv_i32 ti =tcg_const_i32(I16);
+ TCGv td =tcg_const_tl(rd);
+ TCGv ta =tcg_const_tl(ra);
+ gen_helper_mfspr(cpu_env, td, ta, ti);
The helper should a return target_ulong, so the line would become gen_helper_mfspr(cpu_R[rd], cpu_env, td, cpu_R[ra], ti);
Then the register moves inside the mfspr helper could be avoided:
[1]
Quoted 1 line
+ int spr = env->gpr[ra] | offset;
int spr = ra | offset;
As an example [2]:
Quoted 1 line
+ env->gpr[rd] =
cpu_openrisc_get_count(env);
return cpu_openrisc_get_count(env);
Quoted 4 lines
+ tcg_temp_free_i32(ti);
+ tcg_temp_free(td);
+ tcg_temp_free(ta);
+ }
Also here you could try later to avoid to compile sys_helper.c for user emulator by surrounding the previous block by #ifndef CONFIG_USER_ONLY/#endif (ditto for mtspr).
Quoted 11 lines
break;
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
+ {
+ TCGv_i32 im =tcg_const_i32(tmp);
+ TCGv ta =tcg_temp_new();
+ TCGv tb =tcg_temp_new();
+ tcg_gen_mov_tl(ta, cpu_R[ra]);
+ tcg_gen_mov_tl(tb, cpu_R[rb]);
+ gen_helper_mtspr(cpu_env, ta, tb, im);
Simplygen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);
Quoted 11 lines
+ tcg_temp_free_i32(im);
+ tcg_temp_free(ta);
+ tcg_temp_free(tb);
+ }
break;case
0x34: /*l.sd*/
--
1.7.9.5
Re: [Qemu-devel] [PATCH v5 12/16] target-or32: Add system instructions
Hi Blue,
Thank you for review.
Is this code OK?
void HELPER(mtspr)(CPUOpenRISCState * env,
target_ulong ra, target_ulong rb, target_ulong offset)
{
#ifndef CONFIG_USER_ONLY
int spr = (ra | offset);
int idx;
switch (spr) {
case TO_SPR(0, 0): /* VR */
env->vr = rb;
break;
case TO_SPR(0, 16): /* NPC */
env->npc = rb;
break;
case TO_SPR(0, 17): /* SR */
if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^
(rb & (SR_IME | SR_DME | SR_SM))) {
tlb_flush(env, 1);
}
env->sr = rb;
env->sr |= SR_FO; /* FO is const equal to 1 */
if (env->sr & SR_DME) {
env->tlb->map_address_data = &get_phys_data;
} else {
env->tlb->map_address_data = &get_phys_nommu;
}
if (env->sr & SR_IME) {
env->tlb->map_address_code = &get_phys_code;
} else {
env->tlb->map_address_code = &get_phys_nommu;
}
break;
case TO_SPR(0, 18): /* PPC */
env->ppc = rb;
break;
case TO_SPR(0, 32): /* EPCR */
env->epcr = rb;
break;
case TO_SPR(0, 48): /* EEAR */
env->eear = rb;
break;
case TO_SPR(0, 64): /* ESR */
env->esr = rb;
break;
case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */
idx = spr - TO_SPR(1, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK);
}
env->tlb->dtlb[0][idx].mr = rb;
break;
case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */
idx = spr - TO_SPR(1, 640);
env->tlb->dtlb[0][idx].tr = rb;
break;
case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */
case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */
case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */
case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */
case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */
case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */
break;
case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */
idx = spr - TO_SPR(2, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK);
}
env->tlb->itlb[0][idx].mr = rb;
break;
case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */
idx = spr - TO_SPR(2, 640);
env->tlb->itlb[0][idx].tr = rb;
break;
case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */
case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */
case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */
case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */
case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */
case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */
break;
case TO_SPR(9, 0): /* PICMR */
cpu_openrisc_store_picmr(env, rb);
break;
case TO_SPR(9, 2): /* PICSR */
cpu_openrisc_store_picsr(env, rb);
break;
case TO_SPR(10, 0): /* TTMR */
cpu_openrisc_store_compare(env, rb);
break;
case TO_SPR(10, 1): /* TTCR */
cpu_openrisc_store_count(env, rb);
break;
default:
break;
}#endif
}
target_ulong HELPER(mfspr)(CPUOpenRISCState * env,
target_ulong rd, target_ulong ra, uint32_t offset)
{
#ifndef CONFIG_USER_ONLY
int spr = (ra | offset);
int idx;
switch (spr) {
case TO_SPR(0, 0): /* VR */
return (env->vr & SPR_VR);
case TO_SPR(0, 1): /* UPR */
return (env->upr); /* TT, DM, IM, UP present */
case TO_SPR(0, 2): /* CPUCFGR */
return (env->cpucfgr);
case TO_SPR(0, 3): /* DMMUCFGR */
return (env->dmmucfgr); /* 1Way, 64 entries */
case TO_SPR(0, 4): /* IMMUCFGR */
return (env->immucfgr);
case TO_SPR(0, 16): /* NPC */
return (env->npc);
case TO_SPR(0, 17): /* SR */
return (env->sr);
case TO_SPR(0, 18): /* PPC */
return (env->ppc);
case TO_SPR(0, 32): /* EPCR */
return (env->epcr);
case TO_SPR(0, 48): /* EEAR */
return (env->eear);
case TO_SPR(0, 64): /* ESR */
return (env->esr);
case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */
idx = spr - TO_SPR(1, 512);
return (env->tlb->dtlb[0][idx].mr);
case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */
idx = spr - TO_SPR(1, 640);
return (env->tlb->dtlb[0][idx].tr);
case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */
case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */
case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */
case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */
case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */
case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */
break;
case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */
idx = spr - TO_SPR(2, 512);
return (env->tlb->itlb[0][idx].mr);
case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */
idx = spr - TO_SPR(2, 640);
return (env->tlb->itlb[0][idx].tr);
case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */
case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */
case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */
case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */
case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */
case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */
break;
case TO_SPR(9, 0): /* PICMR */
return (env->picmr);
case TO_SPR(9, 2): /* PICSR */
return (env->picsr);
case TO_SPR(10, 0): /* TTMR */
return (env->ttmr);
case TO_SPR(10, 1): /* TTCR */
return cpu_openrisc_get_count(env);
default:
break;
}
#endif
return rd;
} case 0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
{
TCGv_i32 ti = tcg_const_i32(I16);
gen_helper_mfspr(cpu_R[rd], cpu_env, cpu_R[rd], cpu_R[ra], ti);
tcg_temp_free_i32(ti);
}
break;
case 0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
{
TCGv_i32 im = tcg_const_i32(tmp);
gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);
tcg_temp_free_i32(im);
}
break;Quoted 327 lines · Blue Swirl
Quoted 167 lines · Jia Liu
Add OpenRISC system instruction support.
Signed-off-by Jia Liu <[email protected]>---
target-openrisc/Makefile.objs | 3 +-
target-openrisc/helper.h | 4 +target-openrisc/sys_helper.c| 233 +++++++++++++++++++++++++++++++++++++++++target-openrisc/translate.c| 20 ++++4 files changed, 259 insertions(+), 1 deletion(-)create mode 100644
target-openrisc/sys_helper.ctarget-openrisc/Makefile.objs +0
-0@@ -1,3 +1,4 @@obj-$(CONFIG_SOFTMMU) += machine.o
obj-y += cpu.o excp.o intrpt.o mmu.o translate.otarget-openrisc/Makefile.objs +2
-1-obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o mmu_helper.o +obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o \ + mmu_helper.o sys_helper.otarget-openrisc/helper.h +4
-0@@ -62,4 +62,8 @@ DEF_HELPER_FLAGS_1(fl1, 0, tl, tl) /* interrupt */ DEF_HELPER_FLAGS_1(rfe, 0, void, env) +/* sys */ +DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) +DEF_HELPER_FLAGS_4(mfspr, 0, void, env, tl, tl, tl) + #include "def-helper.h"target-openrisc/sys_helper.c new file +127
-0@@ -0,0 +1,233 @@ +/* +* OpenRISC system instructions helper routines +* +* Copyright (c) 2011-2012 Jia Liu <[email protected]> +* Zhizhou Zhang <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "cpu.h" +#include "helper.h" + +#define TO_SPR (group, number) (((group) << 11) + (number)) + +void HELPER (mtspr )(CPUOpenRISCState * env, + target_ulong ra, target_ulong rb, target_ulong offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = (ra | offset); + int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->vr = rb; + break; + + case TO_SPR(0, 16): /* NPC */ + env->npc = rb; + break; + + case TO_SPR(0, 17): /* SR */ + if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ + (rb & (SR_IME | SR_DME | SR_SM))) { + tlb_flush(env, 1); + } + env->sr = rb; + env->sr |= SR_FO; /* FO is const equal to 1 */ + if (env->sr & SR_DME) { + env->tlb->map_address_data = &get_phys_data; + } else { + env->tlb->map_address_data = &get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->map_address_code = &get_phys_code; + } else { + env->tlb->map_address_code = &get_phys_nommu; + } + break; + + case TO_SPR(0, 18): /* PPC */ + env->ppc = rb; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->epcr = rb; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->eear = rb; + break; + + case TO_SPR(0, 64): /* ESR */ + env->esr = rb; + break; + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->dtlb[0][idx].mr = rb; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->tlb->dtlb[0][idx].tr = rb; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->itlb[0][idx].mr = rb; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->tlb->itlb[0][idx].tr = rb; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */ + cpu_openrisc_store_picmr(env, rb); + break; + case TO_SPR(9, 2): /* PICSR */ + cpu_openrisc_store_picsr(env, rb); + break; + case TO_SPR(10, 0): /* TTMR */ + cpu_openrisc_store_compare(env, rb); + break; + case TO_SPR(10, 1): /* TTCR */ + cpu_openrisc_store_count(env, rb); + break; + default:target-openrisc/sys_helper.c line 137
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ break; + } +#endif +} + +void HELPER (mfspr )(CPUOpenRISCState * env, + target_ulong rd, target_ulong ra, uint32_t offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = env->gpr[ra] | offset;[1]
Quoted 80 lines
target-openrisc/sys_helper.c new file +80
-0+ int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->gpr[rd] = (env->vr & SPR_VR); + break; + + case TO_SPR(0, 1): /* UPR */ + env->gpr[rd] = env->upr; /* TT, DM, IM, UP present */ + break; + + case TO_SPR(0, 2): /* CPUCFGR */ + env->gpr[rd] = env->cpucfgr; + break; + + case TO_SPR(0, 3): /* DMMUCFGR */ + env->gpr[rd] = env->dmmucfgr; /* 1Way, 64 entries */ + break; + case TO_SPR(0, 4): /* IMMUCFGR */ + env->gpr[rd] = env->immucfgr; + break; + + case TO_SPR(0, 16): /* NPC */ + env->gpr[rd] = env->npc; + break; + + case TO_SPR(0, 17): /* SR */ + env->gpr[rd] = env->sr; + break; + + case TO_SPR(0, 18): /* PPC */ + env->gpr[rd] = env->ppc; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->gpr[rd] = env->epcr; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->gpr[rd] = env->eear; + break; + + case TO_SPR(0, 64): /* ESR */ + env->gpr[rd] = env->esr; + break; + + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + env->gpr[rd] = env->tlb->dtlb[0][idx].mr; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->gpr[rd] = env->tlb->dtlb[0][idx].tr; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + env->gpr[rd] = env->tlb->itlb[0][idx].mr; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->gpr[rd] = env->tlb->itlb[0][idx].tr; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */target-openrisc/sys_helper.c line 227
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ env->gpr[rd] = env->picmr; + break; + case TO_SPR(9, 2): /* PICSR */ + env->gpr[rd] = env->picsr; + break; + case TO_SPR(10, 0): /* TTMR */ + env->gpr[rd] = env->ttmr; + break; + case TO_SPR(10, 1): /* TTCR */ + env->gpr[rd] = cpu_openrisc_get_count(env);[2]
Quoted 12 lines
target-openrisc/sys_helper.c new file +6
-0+ break; + default: + break; + } +#endif +}target-openrisc/translate.c +0
-0@@ -1241,10 +1241,30 @@ static void dec_misc(DisasContext *dc, CPUOpenRISCState *env, uint32_t insn)Quoted 7 lines
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
+ {
+ TCGv_i32 ti =tcg_const_i32(I16);
+ TCGv td =tcg_const_tl(rd);
+ TCGv ta =tcg_const_tl(ra);
+ gen_helper_mfspr(cpu_env, td, ta, ti);The helper should a return
target_ulong, so the line would becomegen_helper_mfspr(cpu_R[rd], cpu_env, td, cpu_R[ra], ti);Then the register moves inside the mfspr helper could be avoided:
[1]Quoted 1 line
+ int spr = env->gpr[ra] | offset;
int spr = ra | offset;
As an example [2]:
Quoted 1 line
+ env->gpr[rd] =
cpu_openrisc_get_count(env);return
cpu_openrisc_get_count(env);Quoted 4 lines
+ tcg_temp_free_i32(ti);
+ tcg_temp_free(td);
+ tcg_temp_free(ta);
+ }Also here you could try later to avoid to compile
sys_helper.cfor user emulator by surrounding the previous block by #ifndef CONFIG_USER_ONLY/#endif (ditto for mtspr).Quoted 11 lines
break;
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
+ {
+ TCGv_i32 im =tcg_const_i32(tmp);
+ TCGv ta =tcg_temp_new();
+ TCGv tb =tcg_temp_new();
+ tcg_gen_mov_tl(ta, cpu_R[ra]);
+ tcg_gen_mov_tl(tb, cpu_R[rb]);
+ gen_helper_mtspr(cpu_env, ta, tb, im);
Quoted 14 lines
Simply
gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);Quoted 11 lines
+ tcg_temp_free_i32(im);
+ tcg_temp_free(ta);
+ tcg_temp_free(tb);
+ }
break;case
0x34: /*l.sd*/
--
1.7.9.5
Regards,
Jia.
Re: [Qemu-devel] [PATCH v5 12/16] target-or32: Add system instructions
Quoted 103 lines · Jia Liu
Hi Blue,
Thank you for review.
Is this code OK?void HELPER(mtspr)(CPUOpenRISCState * env,
target_ulongra,target_ulongrb,target_ulongoffset) {
#ifndefCONFIG_USER_ONLY
int spr = (ra | offset);
int idx;switch (spr) {
caseTO_SPR(0, 0): /* VR */
env->vr = rb;
break;case
TO_SPR(0, 16): /* NPC */
env->npc = rb;
break;case
TO_SPR(0, 17): /* SR */
if ((env->sr& (SR_IME|SR_DME|SR_SM)) ^ (rb & (SR_IME|SR_DME|SR_SM))) {tlb_flush(env, 1);
}
env->sr = rb;
env->sr |=SR_FO; /* FO is const equal to 1 */ if (env->sr&SR_DME) {env->tlb->map_address_data=&get_phys_data; } else {
env->tlb->map_address_data =&get_phys_nommu; }if (
env->sr&SR_IME) {env->tlb->map_address_code=&get_phys_code; } else {
env->tlb->map_address_code =&get_phys_nommu; }
break;case
TO_SPR(0, 18): /* PPC */
env->ppc = rb;
break;case
TO_SPR(0, 32): /* EPCR */
env->epcr = rb;
break;case
TO_SPR(0, 48): /* EEAR */
env->eear = rb;
break;case
TO_SPR(0, 64): /* ESR */
env->esr = rb;
break;
caseTO_SPR(1, 512)...TO_SPR(1, 639): /* DTLBW0MR 0-127 */ idx = spr -TO_SPR(1, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->dtlb[0][idx].mr &TARGET_PAGE_MASK); }
env->tlb->dtlb[0][idx].mr = rb;
break;case
TO_SPR(1, 640)...TO_SPR(1, 767): /* DTLBW0TR 0-127 */ idx = spr -TO_SPR(1, 640);
env->tlb->dtlb[0][idx].tr = rb;
break;
caseTO_SPR(1, 768)...TO_SPR(1, 895): /* DTLBW1MR 0-127 */ caseTO_SPR(1, 896)...TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ caseTO_SPR(1, 1024)...TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ caseTO_SPR(1, 1152)...TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ caseTO_SPR(1, 1280)...TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ caseTO_SPR(1, 1408)...TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break;
caseTO_SPR(2, 512)...TO_SPR(2, 639): /* ITLBW0MR 0-127 */ idx = spr -TO_SPR(2, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->itlb[0][idx].mr &TARGET_PAGE_MASK); }
env->tlb->itlb[0][idx].mr = rb;
break;case
TO_SPR(2, 640)...TO_SPR(2, 767): /* ITLBW0TR 0-127 */ idx = spr -TO_SPR(2, 640); env->tlb->itlb[0][idx].tr = rb;
break;
caseTO_SPR(2, 768)...TO_SPR(2, 895): /* ITLBW1MR 0-127 */ caseTO_SPR(2, 896)...TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ caseTO_SPR(2, 1024)...TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ caseTO_SPR(2, 1152)...TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ caseTO_SPR(2, 1280)...TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ caseTO_SPR(2, 1408)...TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break;
caseTO_SPR(9, 0): /* PICMR */cpu_openrisc_store_picmr(env, rb);
break;
caseTO_SPR(9, 2): /* PICSR */cpu_openrisc_store_picsr(env, rb);
break;
caseTO_SPR(10, 0): /* TTMR */cpu_openrisc_store_compare(env, rb);
break;
Quoted 8 lines
case
TO_SPR(10, 1): /* TTCR */
cpu_openrisc_store_count(env, rb);
break;
default:
break;
}
#endif
}
OK
Quoted 11 lines
target_ulongHELPER(mfspr)(CPUOpenRISCState * env,
target_ulongrd,target_ulongra,uint32_toffset) {
#ifndefCONFIG_USER_ONLY
int spr = (ra | offset);
int idx;switch (spr) {
caseTO_SPR(0, 0): /* VR */
return (env->vr&SPR_VR);
Parentheses are not necessary.
Quoted 72 lines
case
TO_SPR(0, 1): /* UPR */
return (env->upr); /* TT, DM, IM, UP present */case
TO_SPR(0, 2): /* CPUCFGR */
return (env->cpucfgr);case
TO_SPR(0, 3): /* DMMUCFGR */
return (env->dmmucfgr); /* 1Way, 64 entries */case
TO_SPR(0, 4): /* IMMUCFGR */
return (env->immucfgr);case
TO_SPR(0, 16): /* NPC */
return (env->npc);case
TO_SPR(0, 17): /* SR */
return (env->sr);case
TO_SPR(0, 18): /* PPC */
return (env->ppc);case
TO_SPR(0, 32): /* EPCR */
return (env->epcr);case
TO_SPR(0, 48): /* EEAR */
return (env->eear);case
TO_SPR(0, 64): /* ESR */
return (env->esr);case
TO_SPR(1, 512)...TO_SPR(1, 639): /* DTLBW0MR 0-127 */ idx = spr -TO_SPR(1, 512);
return (env->tlb->dtlb[0][idx].mr);case
TO_SPR(1, 640)...TO_SPR(1, 767): /* DTLBW0TR 0-127 */ idx = spr -TO_SPR(1, 640);
return (env->tlb->dtlb[0][idx].tr);case
TO_SPR(1, 768)...TO_SPR(1, 895): /* DTLBW1MR 0-127 */ caseTO_SPR(1, 896)...TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ caseTO_SPR(1, 1024)...TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ caseTO_SPR(1, 1152)...TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ caseTO_SPR(1, 1280)...TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ caseTO_SPR(1, 1408)...TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break;case
TO_SPR(2, 512)...TO_SPR(2, 639): /* ITLBW0MR 0-127 */ idx = spr -TO_SPR(2, 512);
return (env->tlb->itlb[0][idx].mr);case
TO_SPR(2, 640)...TO_SPR(2, 767): /* ITLBW0TR 0-127 */ idx = spr -TO_SPR(2, 640);
return (env->tlb->itlb[0][idx].tr);case
TO_SPR(2, 768)...TO_SPR(2, 895): /* ITLBW1MR 0-127 */ caseTO_SPR(2, 896)...TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ caseTO_SPR(2, 1024)...TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ caseTO_SPR(2, 1152)...TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ caseTO_SPR(2, 1280)...TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ caseTO_SPR(2, 1408)...TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break;case
TO_SPR(9, 0): /* PICMR */
return (env->picmr);case
TO_SPR(9, 2): /* PICSR */
return (env->picsr);case
TO_SPR(10, 0): /* TTMR */
return (env->ttmr);
Quoted 8 lines
case
TO_SPR(10, 1): /* TTCR */
returncpu_openrisc_get_count(env);default:
break;
}
#endif
return rd;
Is this correct, maybe 0 would be a nice value for unknown SPRs, or is rd the default value?
If you later need to add tracepoints (or debug printfs) for the return value, it may be useful to structure the code like this:target_ulong ret = 0;
switch() {
case x:
ret = y;
break;
case z:
ret = 42;
break;
...
}
/* later something like trace_spr_read(ret); */
return ret;
Quoted 12 lines
}
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
{
TCGv_i32 ti =tcg_const_i32(I16);gen_helper_mfspr(cpu_R[rd], cpu_env, cpu_R[rd], cpu_R[ra], ti);tcg_temp_free_i32(ti);
}
break;
Quoted 8 lines
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11); {
TCGv_i32 im =tcg_const_i32(tmp);gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);tcg_temp_free_i32(im);
}
break;
OK
Quoted 347 lines · Blue Swirl
Quoted 327 lines · Jia Liu
Quoted 167 lines
Add OpenRISC system instruction support.
Signed-off-by Jia Liu <[email protected]>---
target-openrisc/Makefile.objs | 3 +-
target-openrisc/helper.h | 4 +target-openrisc/sys_helper.c| 233 +++++++++++++++++++++++++++++++++++++++++target-openrisc/translate.c| 20 ++++4 files changed, 259 insertions(+), 1 deletion(-)create mode 100644
target-openrisc/sys_helper.ctarget-openrisc/Makefile.objs +0
-0@@ -1,3 +1,4 @@obj-$(CONFIG_SOFTMMU) += machine.o
obj-y += cpu.o excp.o intrpt.o mmu.o translate.otarget-openrisc/Makefile.objs +2
-1-obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o mmu_helper.o +obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o \ + mmu_helper.o sys_helper.otarget-openrisc/helper.h +4
-0@@ -62,4 +62,8 @@ DEF_HELPER_FLAGS_1(fl1, 0, tl, tl) /* interrupt */ DEF_HELPER_FLAGS_1(rfe, 0, void, env) +/* sys */ +DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) +DEF_HELPER_FLAGS_4(mfspr, 0, void, env, tl, tl, tl) + #include "def-helper.h"target-openrisc/sys_helper.c new file +127
-0@@ -0,0 +1,233 @@ +/* +* OpenRISC system instructions helper routines +* +* Copyright (c) 2011-2012 Jia Liu <[email protected]> +* Zhizhou Zhang <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "cpu.h" +#include "helper.h" + +#define TO_SPR (group, number) (((group) << 11) + (number)) + +void HELPER (mtspr )(CPUOpenRISCState * env, + target_ulong ra, target_ulong rb, target_ulong offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = (ra | offset); + int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->vr = rb; + break; + + case TO_SPR(0, 16): /* NPC */ + env->npc = rb; + break; + + case TO_SPR(0, 17): /* SR */ + if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ + (rb & (SR_IME | SR_DME | SR_SM))) { + tlb_flush(env, 1); + } + env->sr = rb; + env->sr |= SR_FO; /* FO is const equal to 1 */ + if (env->sr & SR_DME) { + env->tlb->map_address_data = &get_phys_data; + } else { + env->tlb->map_address_data = &get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->map_address_code = &get_phys_code; + } else { + env->tlb->map_address_code = &get_phys_nommu; + } + break; + + case TO_SPR(0, 18): /* PPC */ + env->ppc = rb; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->epcr = rb; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->eear = rb; + break; + + case TO_SPR(0, 64): /* ESR */ + env->esr = rb; + break; + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->dtlb[0][idx].mr = rb; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->tlb->dtlb[0][idx].tr = rb; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->itlb[0][idx].mr = rb; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->tlb->itlb[0][idx].tr = rb; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */ + cpu_openrisc_store_picmr(env, rb); + break; + case TO_SPR(9, 2): /* PICSR */ + cpu_openrisc_store_picsr(env, rb); + break; + case TO_SPR(10, 0): /* TTMR */ + cpu_openrisc_store_compare(env, rb); + break; + case TO_SPR(10, 1): /* TTCR */ + cpu_openrisc_store_count(env, rb); + break; + default:target-openrisc/sys_helper.c line 137
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ break; + } +#endif +} + +void HELPER (mfspr )(CPUOpenRISCState * env, + target_ulong rd, target_ulong ra, uint32_t offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = env->gpr[ra] | offset;[1]
Quoted 80 lines
target-openrisc/sys_helper.c new file +80
-0+ int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->gpr[rd] = (env->vr & SPR_VR); + break; + + case TO_SPR(0, 1): /* UPR */ + env->gpr[rd] = env->upr; /* TT, DM, IM, UP present */ + break; + + case TO_SPR(0, 2): /* CPUCFGR */ + env->gpr[rd] = env->cpucfgr; + break; + + case TO_SPR(0, 3): /* DMMUCFGR */ + env->gpr[rd] = env->dmmucfgr; /* 1Way, 64 entries */ + break; + case TO_SPR(0, 4): /* IMMUCFGR */ + env->gpr[rd] = env->immucfgr; + break; + + case TO_SPR(0, 16): /* NPC */ + env->gpr[rd] = env->npc; + break; + + case TO_SPR(0, 17): /* SR */ + env->gpr[rd] = env->sr; + break; + + case TO_SPR(0, 18): /* PPC */ + env->gpr[rd] = env->ppc; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->gpr[rd] = env->epcr; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->gpr[rd] = env->eear; + break; + + case TO_SPR(0, 64): /* ESR */ + env->gpr[rd] = env->esr; + break; + + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + env->gpr[rd] = env->tlb->dtlb[0][idx].mr; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->gpr[rd] = env->tlb->dtlb[0][idx].tr; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + env->gpr[rd] = env->tlb->itlb[0][idx].mr; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->gpr[rd] = env->tlb->itlb[0][idx].tr; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */target-openrisc/sys_helper.c line 227
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ env->gpr[rd] = env->picmr; + break; + case TO_SPR(9, 2): /* PICSR */ + env->gpr[rd] = env->picsr; + break; + case TO_SPR(10, 0): /* TTMR */ + env->gpr[rd] = env->ttmr; + break; + case TO_SPR(10, 1): /* TTCR */ + env->gpr[rd] = cpu_openrisc_get_count(env);[2]
Quoted 12 lines
target-openrisc/sys_helper.c new file +6
-0+ break; + default: + break; + } +#endif +}target-openrisc/translate.c +0
-0@@ -1241,10 +1241,30 @@ static void dec_misc(DisasContext *dc, CPUOpenRISCState *env, uint32_t insn)Quoted 7 lines
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
+ {
+ TCGv_i32 ti =tcg_const_i32(I16);
+ TCGv td =tcg_const_tl(rd);
+ TCGv ta =tcg_const_tl(ra);
+ gen_helper_mfspr(cpu_env, td, ta, ti);The helper should a return
target_ulong, so the line would becomegen_helper_mfspr(cpu_R[rd], cpu_env, td, cpu_R[ra], ti);Then the register moves inside the mfspr helper could be avoided:
[1]Quoted 1 line
+ int spr = env->gpr[ra] | offset;
int spr = ra | offset;
As an example [2]:
Quoted 1 line
+ env->gpr[rd] =
cpu_openrisc_get_count(env);return
cpu_openrisc_get_count(env);Quoted 4 lines
+ tcg_temp_free_i32(ti);
+ tcg_temp_free(td);
+ tcg_temp_free(ta);
+ }Also here you could try later to avoid to compile
sys_helper.cfor user emulator by surrounding the previous block by #ifndef CONFIG_USER_ONLY/#endif (ditto for mtspr).Quoted 11 lines
break;
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
+ {
+ TCGv_i32 im =tcg_const_i32(tmp);
+ TCGv ta =tcg_temp_new();
+ TCGv tb =tcg_temp_new();
+ tcg_gen_mov_tl(ta, cpu_R[ra]);
+ tcg_gen_mov_tl(tb, cpu_R[rb]);
+ gen_helper_mtspr(cpu_env, ta, tb, im);Quoted 14 lines
Simply
gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);Quoted 11 lines
+ tcg_temp_free_i32(im);
+ tcg_temp_free(ta);
+ tcg_temp_free(tb);
+ }
break;case
0x34: /*l.sd*/
--
1.7.9.5Regards,
Jia.
Re: [Qemu-devel] [PATCH v5 12/16] target-or32: Add system instructions
Hi Blue,
Quoted 123 lines · Blue Swirl
Quoted 103 lines · Jia Liu
Hi Blue,
Thank you for review.
Is this code OK?void HELPER(mtspr)(CPUOpenRISCState * env,
target_ulongra,target_ulongrb,target_ulongoffset) {
#ifndefCONFIG_USER_ONLY
int spr = (ra | offset);
int idx;switch (spr) {
caseTO_SPR(0, 0): /* VR */
env->vr = rb;
break;case
TO_SPR(0, 16): /* NPC */
env->npc = rb;
break;case
TO_SPR(0, 17): /* SR */
if ((env->sr& (SR_IME|SR_DME|SR_SM)) ^ (rb & (SR_IME|SR_DME|SR_SM))) {tlb_flush(env, 1);
}
env->sr = rb;
env->sr |=SR_FO; /* FO is const equal to 1 */ if (env->sr&SR_DME) {env->tlb->map_address_data=&get_phys_data; } else {
env->tlb->map_address_data =&get_phys_nommu; }if (
env->sr&SR_IME) {env->tlb->map_address_code=&get_phys_code; } else {
env->tlb->map_address_code =&get_phys_nommu; }
break;case
TO_SPR(0, 18): /* PPC */
env->ppc = rb;
break;case
TO_SPR(0, 32): /* EPCR */
env->epcr = rb;
break;case
TO_SPR(0, 48): /* EEAR */
env->eear = rb;
break;case
TO_SPR(0, 64): /* ESR */
env->esr = rb;
break;
caseTO_SPR(1, 512)...TO_SPR(1, 639): /* DTLBW0MR 0-127 */ idx = spr -TO_SPR(1, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->dtlb[0][idx].mr &TARGET_PAGE_MASK); }
env->tlb->dtlb[0][idx].mr = rb;
break;case
TO_SPR(1, 640)...TO_SPR(1, 767): /* DTLBW0TR 0-127 */ idx = spr -TO_SPR(1, 640);
env->tlb->dtlb[0][idx].tr = rb;
break;
caseTO_SPR(1, 768)...TO_SPR(1, 895): /* DTLBW1MR 0-127 */ caseTO_SPR(1, 896)...TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ caseTO_SPR(1, 1024)...TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ caseTO_SPR(1, 1152)...TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ caseTO_SPR(1, 1280)...TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ caseTO_SPR(1, 1408)...TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break;
caseTO_SPR(2, 512)...TO_SPR(2, 639): /* ITLBW0MR 0-127 */ idx = spr -TO_SPR(2, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->itlb[0][idx].mr &TARGET_PAGE_MASK); }
env->tlb->itlb[0][idx].mr = rb;
break;case
TO_SPR(2, 640)...TO_SPR(2, 767): /* ITLBW0TR 0-127 */ idx = spr -TO_SPR(2, 640); env->tlb->itlb[0][idx].tr = rb;
break;
caseTO_SPR(2, 768)...TO_SPR(2, 895): /* ITLBW1MR 0-127 */ caseTO_SPR(2, 896)...TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ caseTO_SPR(2, 1024)...TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ caseTO_SPR(2, 1152)...TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ caseTO_SPR(2, 1280)...TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ caseTO_SPR(2, 1408)...TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break;
caseTO_SPR(9, 0): /* PICMR */cpu_openrisc_store_picmr(env, rb);
break;
caseTO_SPR(9, 2): /* PICSR */cpu_openrisc_store_picsr(env, rb);
break;
caseTO_SPR(10, 0): /* TTMR */cpu_openrisc_store_compare(env, rb);
break;Quoted 8 lines
case
TO_SPR(10, 1): /* TTCR */
cpu_openrisc_store_count(env, rb);
break;
default:
break;
}
#endif
}OK
Quoted 8 lines
target_ulongHELPER(mfspr)(CPUOpenRISCState * env,
target_ulongrd,target_ulongra,uint32_toffset) {
#ifndefCONFIG_USER_ONLY
int spr = (ra | offset);
int idx;
Quoted 6 lines
Quoted 3 lines
switch (spr) {
caseTO_SPR(0, 0): /* VR */
return (env->vr&SPR_VR);Parentheses are not necessary.
all deleted. Thanks.
Quoted 75 lines
Quoted 75 lines
case
TO_SPR(0, 1): /* UPR */
return (env->upr); /* TT, DM, IM, UP present */case
TO_SPR(0, 2): /* CPUCFGR */
return (env->cpucfgr);case
TO_SPR(0, 3): /* DMMUCFGR */
return (env->dmmucfgr); /* 1Way, 64 entries */case
TO_SPR(0, 4): /* IMMUCFGR */
return (env->immucfgr);case
TO_SPR(0, 16): /* NPC */
return (env->npc);case
TO_SPR(0, 17): /* SR */
return (env->sr);case
TO_SPR(0, 18): /* PPC */
return (env->ppc);case
TO_SPR(0, 32): /* EPCR */
return (env->epcr);case
TO_SPR(0, 48): /* EEAR */
return (env->eear);case
TO_SPR(0, 64): /* ESR */
return (env->esr);case
TO_SPR(1, 512)...TO_SPR(1, 639): /* DTLBW0MR 0-127 */ idx = spr -TO_SPR(1, 512);
return (env->tlb->dtlb[0][idx].mr);case
TO_SPR(1, 640)...TO_SPR(1, 767): /* DTLBW0TR 0-127 */ idx = spr -TO_SPR(1, 640);
return (env->tlb->dtlb[0][idx].tr);case
TO_SPR(1, 768)...TO_SPR(1, 895): /* DTLBW1MR 0-127 */ caseTO_SPR(1, 896)...TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ caseTO_SPR(1, 1024)...TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ caseTO_SPR(1, 1152)...TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ caseTO_SPR(1, 1280)...TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ caseTO_SPR(1, 1408)...TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break;case
TO_SPR(2, 512)...TO_SPR(2, 639): /* ITLBW0MR 0-127 */ idx = spr -TO_SPR(2, 512);
return (env->tlb->itlb[0][idx].mr);case
TO_SPR(2, 640)...TO_SPR(2, 767): /* ITLBW0TR 0-127 */ idx = spr -TO_SPR(2, 640);
return (env->tlb->itlb[0][idx].tr);case
TO_SPR(2, 768)...TO_SPR(2, 895): /* ITLBW1MR 0-127 */ caseTO_SPR(2, 896)...TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ caseTO_SPR(2, 1024)...TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ caseTO_SPR(2, 1152)...TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ caseTO_SPR(2, 1280)...TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ caseTO_SPR(2, 1408)...TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break;case
TO_SPR(9, 0): /* PICMR */
return (env->picmr);case
TO_SPR(9, 2): /* PICSR */
return (env->picsr);case
TO_SPR(10, 0): /* TTMR */
return (env->ttmr);case
TO_SPR(10, 1): /* TTCR */
returncpu_openrisc_get_count(env);
Quoted 9 lines
Quoted 5 lines
default:
break;
}
#endif
return rd;Is this correct, maybe 0 would be a nice value for unknown SPRs, or is rd the default value?
It is rd.
for rd is passed in, if rd unchanged, just keep it back.
But, I added a comment here, so, it now look like
/* for rd is passed in, if rd unchanged, just keep it back. */
return rd;Quoted 4 lines
If you later need to add tracepoints (or debug printfs) for the return value, it may be useful to structure the code like this:
target_ulongret = 0;
Quoted 12 lines
switch(){
case x:
ret = y;
break;
case z:
ret = 42;
break;
...
}
/* later something liketrace_spr_read(ret); */
return ret;
I've added this in a comment for the future use, thank you very much.
Quoted 370 lines
Quoted 12 lines
}
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
{
TCGv_i32 ti =tcg_const_i32(I16);gen_helper_mfspr(cpu_R[rd], cpu_env, cpu_R[rd], cpu_R[ra], ti);tcg_temp_free_i32(ti);
}
break;Quoted 8 lines
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11); {
TCGv_i32 im =tcg_const_i32(tmp);gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);tcg_temp_free_i32(im);
}
break;OK
Quoted 347 lines · Blue Swirl
Quoted 327 lines · Jia Liu
Quoted 167 lines
Add OpenRISC system instruction support.
Signed-off-by Jia Liu <[email protected]>---
target-openrisc/Makefile.objs | 3 +-
target-openrisc/helper.h | 4 +target-openrisc/sys_helper.c| 233 +++++++++++++++++++++++++++++++++++++++++target-openrisc/translate.c| 20 ++++4 files changed, 259 insertions(+), 1 deletion(-)create mode 100644
target-openrisc/sys_helper.ctarget-openrisc/Makefile.objs +0
-0@@ -1,3 +1,4 @@obj-$(CONFIG_SOFTMMU) += machine.o
obj-y += cpu.o excp.o intrpt.o mmu.o translate.otarget-openrisc/Makefile.objs +2
-1-obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o mmu_helper.o +obj-y += excp_helper.o fpu_helper.o int_helper.o intrpt_helper.o \ + mmu_helper.o sys_helper.otarget-openrisc/helper.h +4
-0@@ -62,4 +62,8 @@ DEF_HELPER_FLAGS_1(fl1, 0, tl, tl) /* interrupt */ DEF_HELPER_FLAGS_1(rfe, 0, void, env) +/* sys */ +DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) +DEF_HELPER_FLAGS_4(mfspr, 0, void, env, tl, tl, tl) + #include "def-helper.h"target-openrisc/sys_helper.c new file +127
-0@@ -0,0 +1,233 @@ +/* +* OpenRISC system instructions helper routines +* +* Copyright (c) 2011-2012 Jia Liu <[email protected]> +* Zhizhou Zhang <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "cpu.h" +#include "helper.h" + +#define TO_SPR (group, number) (((group) << 11) + (number)) + +void HELPER (mtspr )(CPUOpenRISCState * env, + target_ulong ra, target_ulong rb, target_ulong offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = (ra | offset); + int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->vr = rb; + break; + + case TO_SPR(0, 16): /* NPC */ + env->npc = rb; + break; + + case TO_SPR(0, 17): /* SR */ + if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ + (rb & (SR_IME | SR_DME | SR_SM))) { + tlb_flush(env, 1); + } + env->sr = rb; + env->sr |= SR_FO; /* FO is const equal to 1 */ + if (env->sr & SR_DME) { + env->tlb->map_address_data = &get_phys_data; + } else { + env->tlb->map_address_data = &get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->map_address_code = &get_phys_code; + } else { + env->tlb->map_address_code = &get_phys_nommu; + } + break; + + case TO_SPR(0, 18): /* PPC */ + env->ppc = rb; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->epcr = rb; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->eear = rb; + break; + + case TO_SPR(0, 64): /* ESR */ + env->esr = rb; + break; + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->dtlb[0][idx].mr = rb; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->tlb->dtlb[0][idx].tr = rb; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + if (!(rb & 1)) { + tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK); + } + env->tlb->itlb[0][idx].mr = rb; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->tlb->itlb[0][idx].tr = rb; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */ + cpu_openrisc_store_picmr(env, rb); + break; + case TO_SPR(9, 2): /* PICSR */ + cpu_openrisc_store_picsr(env, rb); + break; + case TO_SPR(10, 0): /* TTMR */ + cpu_openrisc_store_compare(env, rb); + break; + case TO_SPR(10, 1): /* TTCR */ + cpu_openrisc_store_count(env, rb); + break; + default:target-openrisc/sys_helper.c line 137
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ break; + } +#endif +} + +void HELPER (mfspr )(CPUOpenRISCState * env, + target_ulong rd, target_ulong ra, uint32_t offset) +{ +#if !defined(CONFIG_USER_ONLY ) + int spr = env->gpr[ra] | offset;[1]
Quoted 80 lines
target-openrisc/sys_helper.c new file +80
-0+ int idx; + + switch (spr) { + case TO_SPR(0, 0): /* VR */ + env->gpr[rd] = (env->vr & SPR_VR); + break; + + case TO_SPR(0, 1): /* UPR */ + env->gpr[rd] = env->upr; /* TT, DM, IM, UP present */ + break; + + case TO_SPR(0, 2): /* CPUCFGR */ + env->gpr[rd] = env->cpucfgr; + break; + + case TO_SPR(0, 3): /* DMMUCFGR */ + env->gpr[rd] = env->dmmucfgr; /* 1Way, 64 entries */ + break; + case TO_SPR(0, 4): /* IMMUCFGR */ + env->gpr[rd] = env->immucfgr; + break; + + case TO_SPR(0, 16): /* NPC */ + env->gpr[rd] = env->npc; + break; + + case TO_SPR(0, 17): /* SR */ + env->gpr[rd] = env->sr; + break; + + case TO_SPR(0, 18): /* PPC */ + env->gpr[rd] = env->ppc; + break; + + case TO_SPR(0, 32): /* EPCR */ + env->gpr[rd] = env->epcr; + break; + + case TO_SPR(0, 48): /* EEAR */ + env->gpr[rd] = env->eear; + break; + + case TO_SPR(0, 64): /* ESR */ + env->gpr[rd] = env->esr; + break; + + case TO_SPR(1, 512) ... TO_SPR(1, 639): /* DTLBW0MR 0-127 */ + idx = spr - TO_SPR(1, 512); + env->gpr[rd] = env->tlb->dtlb[0][idx].mr; + break; + + case TO_SPR(1, 640) ... TO_SPR(1, 767): /* DTLBW0TR 0-127 */ + idx = spr - TO_SPR(1, 640); + env->gpr[rd] = env->tlb->dtlb[0][idx].tr; + break; + case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ + case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ + case TO_SPR(1, 1024) ... TO_SPR(1, 1151): /* DTLBW2MR 0-127 */ + case TO_SPR(1, 1152) ... TO_SPR(1, 1279): /* DTLBW2TR 0-127 */ + case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ + case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ + break; + + case TO_SPR(2, 512) ... TO_SPR(2, 639): /* ITLBW0MR 0-127 */ + idx = spr - TO_SPR(2, 512); + env->gpr[rd] = env->tlb->itlb[0][idx].mr; + break; + + case TO_SPR(2, 640) ... TO_SPR(2, 767): /* ITLBW0TR 0-127 */ + idx = spr - TO_SPR(2, 640); + env->gpr[rd] = env->tlb->itlb[0][idx].tr; + break; + case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ + case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ + case TO_SPR(2, 1024) ... TO_SPR(2, 1151): /* ITLBW2MR 0-127 */ + case TO_SPR(2, 1152) ... TO_SPR(2, 1279): /* ITLBW2TR 0-127 */ + case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ + case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ + break; + case TO_SPR(9, 0): /* PICMR */target-openrisc/sys_helper.c line 227
Quoted 10 lines
target-openrisc/sys_helper.c new file +10
-0+ env->gpr[rd] = env->picmr; + break; + case TO_SPR(9, 2): /* PICSR */ + env->gpr[rd] = env->picsr; + break; + case TO_SPR(10, 0): /* TTMR */ + env->gpr[rd] = env->ttmr; + break; + case TO_SPR(10, 1): /* TTCR */ + env->gpr[rd] = cpu_openrisc_get_count(env);[2]
Quoted 12 lines
target-openrisc/sys_helper.c new file +6
-0+ break; + default: + break; + } +#endif +}target-openrisc/translate.c +0
-0@@ -1241,10 +1241,30 @@ static void dec_misc(DisasContext *dc, CPUOpenRISCState *env, uint32_t insn)Quoted 7 lines
case
0x2d: /*l.mfspr*/
LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
+ {
+ TCGv_i32 ti =tcg_const_i32(I16);
+ TCGv td =tcg_const_tl(rd);
+ TCGv ta =tcg_const_tl(ra);
+ gen_helper_mfspr(cpu_env, td, ta, ti);The helper should a return
target_ulong, so the line would becomegen_helper_mfspr(cpu_R[rd], cpu_env, td, cpu_R[ra], ti);Then the register moves inside the mfspr helper could be avoided:
[1]Quoted 1 line
+ int spr = env->gpr[ra] | offset;
int spr = ra | offset;
As an example [2]:
Quoted 1 line
+ env->gpr[rd] =
cpu_openrisc_get_count(env);return
cpu_openrisc_get_count(env);Quoted 4 lines
+ tcg_temp_free_i32(ti);
+ tcg_temp_free(td);
+ tcg_temp_free(ta);
+ }Also here you could try later to avoid to compile
sys_helper.cfor user emulator by surrounding the previous block by #ifndef CONFIG_USER_ONLY/#endif (ditto for mtspr).Quoted 11 lines
break;
case
0x30: /*l.mtspr*/
LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
+ {
+ TCGv_i32 im =tcg_const_i32(tmp);
+ TCGv ta =tcg_temp_new();
+ TCGv tb =tcg_temp_new();
+ tcg_gen_mov_tl(ta, cpu_R[ra]);
+ tcg_gen_mov_tl(tb, cpu_R[rb]);
+ gen_helper_mtspr(cpu_env, ta, tb, im);Quoted 14 lines
Simply
gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);Quoted 11 lines
+ tcg_temp_free_i32(im);
+ tcg_temp_free(ta);
+ tcg_temp_free(tb);
+ }
break;case
0x34: /*l.sd*/
--
1.7.9.5Regards,
Jia.
PATCH v5 13/16 target-or32: Add gdb stub support
In reply to Jia LiuAdd QEMU OpenRISC gdb stub support.
--- gdbstub.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
gdbstub.c +64 -0
@@ -1155,6 +1155,68 @@ static int cpu_gdb_write_register(CPUMIPSState *env, uint8_t *mem_buf, int n)return sizeof (target_ulong); } +#elif defined(TARGET_OPENRISC ) + +#define NUM_CORE_REGS (32 + 3) + +static int cpu_gdb_read_register (CPUOpenRISCState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +GET_REG32 (env->gpr[n]); + }else { +switch (n) { +case 32 :/* PPC */ +GET_REG32 (env->ppc); +break ; + +case 33 :/* NPC */ +GET_REG32 (env->npc); +break ; + +case 34 :/* SR */ +GET_REG32 (env->sr); +break ; + +default : +break ; + } + } +return 0 ; +} + +static int cpu_gdb_write_register (CPUOpenRISCState *env, +uint8_t *mem_buf,int n) +{ +uint32_t tmp; + +if (n >NUM_CORE_REGS ) { +return 0 ; + } + + tmp =ldl_p (mem_buf); + +if (n <32 ) { + env->gpr[n] = tmp; + }else { +switch (n) { +case 32 :/* PPC */ + env->ppc = tmp; +break ; + +case 33 :/* NPC */ + env->npc = tmp; +break ; + +case 34 :/* SR */ + env->sr = tmp; +break ; + +default : +break ; + } + } +return 4 ; +}#elif defined (TARGET_SH4 )/* Hint: Use "set architecture sh4" in GDB to see fpu registers */
@@ -1924,6 +1986,8 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) }#elif defined (TARGET_MICROBLAZE) s->c_cpu->sregs[SR_PC ] = pc; +#elif defined(TARGET_OPENRISC) + s->c_cpu->pc = pc;#elif defined (TARGET_CRIS) s->c_cpu->pc = pc;#elif defined (TARGET_ALPHA)
Signature · 1 line
1.7.9.5
PATCH v5 14/16 target-or32: Add linux syscall, signal and termbits
In reply to Jia LiuAdd linux syscall, signal and termbits.
--- linux-user/openrisc/syscall.h | 24 ++ linux-user/openrisc/syscall_nr.h | 506 +++++++++++++++++++++++++++++++++++ linux-user/openrisc/target_signal.h | 26 ++ linux-user/openrisc/termbits.h | 294 ++++++++++++++++++++ 4 files changed, 850 insertions(+) create mode 100644 linux-user/openrisc/syscall.h create mode 100644 linux-user/openrisc/syscall_nr.h create mode 100644 linux-user/openrisc/target_signal.h create mode 100644 linux-user/openrisc/termbits.h
linux-user/openrisc/syscall.h new file +24 -0
@@ -0,0 +1,24 @@ +struct target_pt_regs { +union { +struct { +/* Named registers */ +uint32_t sr;/* Stored in place of r0 */ +target_ulong sp;/* r1 */ + }; +struct { +/* Old style */ +target_ulong offset[2 ]; +target_ulong gprs[30 ]; + }; +struct { +/* New style */ +target_ulong gpr[32 ]; + }; + }; +target_ulong pc; +target_ulong orig_gpr11;/* For restarting system calls */ +uint32_t syscallno;/* Syscall number (used by strace) */ +target_ulong dummy;/* Cheap alignment fix */ +}; + +#define UNAME_MACHINE "openrisc"
linux-user/openrisc/syscall_nr.h new file +506 -0
506 lines not on this page · raw message
linux-user/openrisc/target_signal.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef TARGET_SIGNAL_H +#define TARGET_SIGNAL_H + +#include "cpu.h" + +/* this struct defines a stack used during syscall handling */ + +typedef struct target_sigaltstack { +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; +}target_stack_t ; + +/* sigaltstack controls */ +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 2048 +#define TARGET_SIGSTKSZ 8192 + +static inline abi_ulong get_sp_from_cpustate (CPUOpenRISCState *state) +{ +return state->gpr[1 ]; +} + +#endif /* TARGET_SIGNAL_H */
linux-user/openrisc/termbits.h new file +294 -0
294 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v5 15/16 target-or32: Add linux user support
In reply to Jia LiuAdd OpenRISC linux user support.
--- configure | 1 + default-configs/or32-linux-user.mak | 2 + linux-user/elfload.c | 41 +++++++ linux-user/main.c | 100 +++++++++++++++ linux-user/signal.c | 229 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 2 +- linux-user/syscall_defs.h | 40 +++++- target-openrisc/cpu.h | 12 ++ 8 files changed, 423 insertions(+), 4 deletions(-) create mode 100644 default-configs/or32-linux-user.mak
configure +1 -0
@@ -952,6 +952,7 @@ microblaze-linux-user \ microblazeel-linux-user \ mips-linux-user \ mipsel-linux-user \ +or32-linux-user \ ppc-linux-user \ ppc64-linux-user \ ppc64abi32-linux-user \
default-configs/or32-linux-user.mak new file +2 -0
@@ -0,0 +1,2 @@ +# Default configuration for or32-linux-user +
linux-user/elfload.c +41 -0
47 lines not on this page · raw message
linux-user/main.c +100 -0
118 lines not on this page · raw message
linux-user/signal.c +229 -0
235 lines not on this page · raw message
linux-user/syscall.c +1 -1
@@ -7377,7 +7377,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_sigaltstack:#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_MIPS ) || \ defined(TARGET_SPARC ) || defined(TARGET_PPC ) || defined(TARGET_ALPHA ) || \ - defined(TARGET_M68K ) || defined(TARGET_S390X ) + defined(TARGET_M68K ) || defined(TARGET_S390X ) || defined(TARGET_OPENRISC ) ret =do_sigaltstack (arg1, arg2,get_sp_from_cpustate ((CPUArchState *)cpu_env));break ;#else
linux-user/syscall_defs.h +37 -3
@@ -59,7 +59,7 @@#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SH4 ) \ || defined(TARGET_M68K ) || defined(TARGET_CRIS ) || defined(TARGET_UNICORE32 ) \ - || defined(TARGET_S390X ) + || defined(TARGET_S390X ) || defined(TARGET_OPENRISC )#define TARGET_IOC_SIZEBITS 14#define TARGET_IOC_DIRBITS 2
@@ -323,7 +323,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, ||defined (TARGET_PPC ) ||defined (TARGET_MIPS ) ||defined (TARGET_SH4 ) \ ||defined (TARGET_M68K ) ||defined (TARGET_ALPHA ) ||defined (TARGET_CRIS ) \ ||defined (TARGET_MICROBLAZE ) ||defined (TARGET_UNICORE32 ) \ - || defined(TARGET_S390X) + || defined(TARGET_S390X) || defined(TARGET_OPENRISC)#if defined(TARGET_SPARC )#define TARGET_SA_NOCLDSTOP 8u
@@ -344,6 +344,14 @@ int do_sigaction(int sig, const struct target_sigaction *act,#if !defined(TARGET_ABI_MIPSN32 ) && !defined(TARGET_ABI_MIPSN64 )#define TARGET_SA_RESTORER 0x04000000/* Only for O32 */ #endif +#elif defined(TARGET_OPENRISC ) +#define TARGET_SA_NOCLDSTOP 0x00000001 +#define TARGET_SA_NOCLDWAIT 0x00000002 +#define TARGET_SA_SIGINFO 0x00000004 +#define TARGET_SA_ONSTACK 0x08000000 +#define TARGET_SA_RESTART 0x10000000 +#define TARGET_SA_NODEFER 0x40000000 +#define TARGET_SA_RESETHAND 0x80000000#elif defined(TARGET_ALPHA )#define TARGET_SA_ONSTACK 0x00000001#define TARGET_SA_RESTART 0x00000002
@@ -448,6 +456,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,#else +/* OpenRISC Using the general signals */ #define TARGET_SIGHUP 1#define TARGET_SIGINT 2#define TARGET_SIGQUIT 3
@@ -1086,7 +1095,8 @@ struct target_winsize {#endif #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) \ - || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) + || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \ + || defined(TARGET_OPENRISC) struct target_stat { unsigned short st_dev; unsigned short __pad1;
@@ -1783,6 +1793,30 @@ struct target_stat {abi_long st_blocks; abi_ulong __unused[3]; }; +#elif defined(TARGET_OPENRISC) +struct target_stat { +abi_ulong st_dev; +abi_ulong st_ino; +abi_ulong st_nlink; + +unsigned int st_mode; +unsigned int st_uid; +unsigned int st_gid; +unsigned int __pad0; +abi_ulong st_rdev; +abi_long st_size; +abi_long st_blksize; +abi_long st_blocks;/* Number 512-byte blocks allocated. */ + +abi_ulong target_st_atime; +abi_ulong target_st_atime_nsec; +abi_ulong target_st_mtime; +abi_ulong target_st_mtime_nsec; +abi_ulong target_st_ctime; +abi_ulong target_st_ctime_nsec; + +abi_long __unused[3 ]; +};#else #error unsupported CPU#endif
target-openrisc/cpu.h +12 -0
@@ -360,11 +360,13 @@ void do_interrupt(CPUOpenRISCState *env);void openrisc_translate_init (void );int cpu_openrisc_handle_mmu_fault (CPUOpenRISCState *env,target_ulong address,int rw,int mmu_idx); +int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);#define cpu_list cpu_openrisc_list#define cpu_exec cpu_openrisc_exec#define cpu_gen_code cpu_openrisc_gen_code#define cpu_handle_mmu_fault cpu_openrisc_handle_mmu_fault +#define cpu_signal_handler cpu_openrisc_signal_handler#define CPU_SAVE_VERSION 1
@@ -396,6 +398,16 @@ static inline CPUOpenRISCState *cpu_init(const char *cpu_model)return NULL ; } +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUOpenRISCState *env,target_ulong newsp) +{ +if (newsp) { + env->gpr[1 ] = newsp; + } + env->gpr[2 ] =0 ; +} +#endif +#include "cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env,
Signature · 1 line
1.7.9.5
PATCH v5 16/16 target-or32: Add testcases
In reply to Jia LiuAdd testcases.
--- tests/tcg/openrisc/Makefile | 71 +++++++++++++++++++++++++++ tests/tcg/openrisc/test_add.c | 34 +++++++++++++ tests/tcg/openrisc/test_addc.c | 39 +++++++++++++++ tests/tcg/openrisc/test_addi.c | 31 ++++++++++++ tests/tcg/openrisc/test_addic.c | 33 +++++++++++++ tests/tcg/openrisc/test_and_or.c | 61 +++++++++++++++++++++++ tests/tcg/openrisc/test_bf.c | 46 ++++++++++++++++++ tests/tcg/openrisc/test_bnf.c | 50 +++++++++++++++++++ tests/tcg/openrisc/test_div.c | 32 ++++++++++++ tests/tcg/openrisc/test_divu.c | 32 ++++++++++++ tests/tcg/openrisc/test_extx.c | 72 +++++++++++++++++++++++++++ tests/tcg/openrisc/test_fx.c | 53 ++++++++++++++++++++ tests/tcg/openrisc/test_j.c | 26 ++++++++++ tests/tcg/openrisc/test_jal.c | 26 ++++++++++ tests/tcg/openrisc/test_lf_add.c | 39 +++++++++++++++ tests/tcg/openrisc/test_lf_div.c | 34 +++++++++++++ tests/tcg/openrisc/test_lf_eqs.c | 84 ++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_ges.c | 84 ++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_gts.c | 84 ++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_les.c | 84 ++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_lts.c | 91 ++++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_mul.c | 22 +++++++++ tests/tcg/openrisc/test_lf_nes.c | 87 +++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lf_rem.c | 32 ++++++++++++ tests/tcg/openrisc/test_lf_sub.c | 33 +++++++++++++ tests/tcg/openrisc/test_logic.c | 100 ++++++++++++++++++++++++++++++++++++++ tests/tcg/openrisc/test_lx.c | 78 +++++++++++++++++++++++++++++ tests/tcg/openrisc/test_movhi.c | 30 ++++++++++++ tests/tcg/openrisc/test_mul.c | 47 ++++++++++++++++++ tests/tcg/openrisc/test_muli.c | 47 ++++++++++++++++++ tests/tcg/openrisc/test_mulu.c | 47 ++++++++++++++++++ tests/tcg/openrisc/test_sfeq.c | 44 +++++++++++++++++ tests/tcg/openrisc/test_sfeqi.c | 39 +++++++++++++++ tests/tcg/openrisc/test_sfges.c | 44 +++++++++++++++++ tests/tcg/openrisc/test_sfgesi.c | 40 +++++++++++++++ tests/tcg/openrisc/test_sfgeu.c | 44 +++++++++++++++++ tests/tcg/openrisc/test_sfgeui.c | 41 ++++++++++++++++ tests/tcg/openrisc/test_sfgts.c | 45 +++++++++++++++++ tests/tcg/openrisc/test_sfgtsi.c | 41 ++++++++++++++++ tests/tcg/openrisc/test_sfgtu.c | 43 ++++++++++++++++ tests/tcg/openrisc/test_sfgtui.c | 42 ++++++++++++++++ tests/tcg/openrisc/test_sfles.c | 26 ++++++++++ tests/tcg/openrisc/test_sflesi.c | 39 +++++++++++++++ tests/tcg/openrisc/test_sfleu.c | 43 ++++++++++++++++ tests/tcg/openrisc/test_sfleui.c | 39 +++++++++++++++ tests/tcg/openrisc/test_sflts.c | 43 ++++++++++++++++ tests/tcg/openrisc/test_sfltsi.c | 38 +++++++++++++++ tests/tcg/openrisc/test_sfltu.c | 41 ++++++++++++++++ tests/tcg/openrisc/test_sfltui.c | 39 +++++++++++++++ tests/tcg/openrisc/test_sfne.c | 43 ++++++++++++++++ tests/tcg/openrisc/test_sfnei.c | 38 +++++++++++++++ tests/tcg/openrisc/test_sub.c | 34 +++++++++++++ 52 files changed, 2475 insertions(+) create mode 100644 tests/tcg/openrisc/Makefile create mode 100644 tests/tcg/openrisc/test_add.c create mode 100644 tests/tcg/openrisc/test_addc.c create mode 100644 tests/tcg/openrisc/test_addi.c create mode 100644 tests/tcg/openrisc/test_addic.c create mode 100644 tests/tcg/openrisc/test_and_or.c create mode 100644 tests/tcg/openrisc/test_bf.c create mode 100644 tests/tcg/openrisc/test_bnf.c create mode 100644 tests/tcg/openrisc/test_div.c create mode 100644 tests/tcg/openrisc/test_divu.c create mode 100644 tests/tcg/openrisc/test_extx.c create mode 100644 tests/tcg/openrisc/test_fx.c create mode 100644 tests/tcg/openrisc/test_j.c create mode 100644 tests/tcg/openrisc/test_jal.c create mode 100644 tests/tcg/openrisc/test_lf_add.c create mode 100644 tests/tcg/openrisc/test_lf_div.c create mode 100644 tests/tcg/openrisc/test_lf_eqs.c create mode 100644 tests/tcg/openrisc/test_lf_ges.c create mode 100644 tests/tcg/openrisc/test_lf_gts.c create mode 100644 tests/tcg/openrisc/test_lf_les.c create mode 100644 tests/tcg/openrisc/test_lf_lts.c create mode 100644 tests/tcg/openrisc/test_lf_mul.c create mode 100644 tests/tcg/openrisc/test_lf_nes.c create mode 100644 tests/tcg/openrisc/test_lf_rem.c create mode 100644 tests/tcg/openrisc/test_lf_sub.c create mode 100644 tests/tcg/openrisc/test_logic.c create mode 100644 tests/tcg/openrisc/test_lx.c create mode 100644 tests/tcg/openrisc/test_movhi.c create mode 100644 tests/tcg/openrisc/test_mul.c create mode 100644 tests/tcg/openrisc/test_muli.c create mode 100644 tests/tcg/openrisc/test_mulu.c create mode 100644 tests/tcg/openrisc/test_sfeq.c create mode 100644 tests/tcg/openrisc/test_sfeqi.c create mode 100644 tests/tcg/openrisc/test_sfges.c create mode 100644 tests/tcg/openrisc/test_sfgesi.c create mode 100644 tests/tcg/openrisc/test_sfgeu.c create mode 100644 tests/tcg/openrisc/test_sfgeui.c create mode 100644 tests/tcg/openrisc/test_sfgts.c create mode 100644 tests/tcg/openrisc/test_sfgtsi.c create mode 100644 tests/tcg/openrisc/test_sfgtu.c create mode 100644 tests/tcg/openrisc/test_sfgtui.c create mode 100644 tests/tcg/openrisc/test_sfles.c create mode 100644 tests/tcg/openrisc/test_sflesi.c create mode 100644 tests/tcg/openrisc/test_sfleu.c create mode 100644 tests/tcg/openrisc/test_sfleui.c create mode 100644 tests/tcg/openrisc/test_sflts.c create mode 100644 tests/tcg/openrisc/test_sfltsi.c create mode 100644 tests/tcg/openrisc/test_sfltu.c create mode 100644 tests/tcg/openrisc/test_sfltui.c create mode 100644 tests/tcg/openrisc/test_sfne.c create mode 100644 tests/tcg/openrisc/test_sfnei.c create mode 100644 tests/tcg/openrisc/test_sub.c
tests/tcg/openrisc/Makefile new file +71 -0
@@ -0,0 +1,71 @@ +-include ../../config-host.mak + +CROSS = or32-linux- + +SIM = qemu-or32 + +CC = $(CROSS)gcc + +TESTCASES = test_add.tst +TESTCASES = test_sub.tst +TESTCASES += test_addc.tst +TESTCASES += test_addi.tst +TESTCASES += test_addic.tst +TESTCASES += test_and_or.tst +TESTCASES += test_bf.tst +TESTCASES += test_bnf.tst +TESTCASES += test_div.tst +TESTCASES += test_divu.tst +TESTCASES += test_extx.tst +TESTCASES += test_fx.tst +TESTCASES += test_jal.tst +TESTCASES += test_j.tst +TESTCASES += test_lf_div.tst +TESTCASES += test_lf_eqs.tst +TESTCASES += test_lf_ges.tst +TESTCASES += test_lf_gts.tst +TESTCASES += test_lf_les.tst +TESTCASES += test_lf_lts.tst +TESTCASES += test_lf_mul.tst +TESTCASES += test_lf_nes.tst +TESTCASES += test_lf_rem.tst +TESTCASES += test_lf_sub.tst +TESTCASES += test_lf_add.tst +TESTCASES += test_logic.tst +TESTCASES += test_lx.tst +TESTCASES += test_movhi.tst +TESTCASES += test_mul.tst +TESTCASES += test_mulu.tst +TESTCASES += test_muli.tst +TESTCASES += test_sfeq.tst +TESTCASES += test_sfeqi.tst +TESTCASES += test_sfges.tst +TESTCASES += test_sfgesi.tst +TESTCASES += test_sfgeu.tst +TESTCASES += test_sfgeui.tst +TESTCASES += test_sfgts.tst +TESTCASES += test_sfgtsi.tst +TESTCASES += test_sfgtu.tst +TESTCASES += test_sfgtui.tst +TESTCASES += test_sfles.tst +TESTCASES += test_sflesi.tst +TESTCASES += test_sfleu.tst +TESTCASES += test_sfleui.tst +TESTCASES += test_sflts.tst +TESTCASES += test_sfltsi.tst +TESTCASES += test_sfltu.tst +TESTCASES += test_sfltui.tst +TESTCASES += test_sfne.tst +TESTCASES += test_sfnei.tst + +all: $(TESTCASES) + +%.tst: %.c + $(CC) -static $< -o $@ + + +check: $(TESTCASES) + @for case in $(TESTCASES); do $(SIM) $$case; echo $$case pass!; sleep 0.2; done + +clean: + $(RM) -rf $(TESTCASES)
tests/tcg/openrisc/test_add.c new file +34 -0
@@ -0,0 +1,34 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b; +int result; + + a =0x100 ; + b =0x100 ; + result =0x200 ; + + __asm + ("l.add %0, %0, %1\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("add error\n" ); + } + + a =0xffff ; + b =0x1 ; + result =0x10000 ; + __asm + ("l.add %0, %0, %1\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("add error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_addc.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b, c; +int result; + + b =0x01 ; + c =0xffffffff ; + result =1 ; + + __asm + ("l.addc %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); + +if (a != result) { +printf ("first addc error\n" ); + } + + b =0x01 ; + c =0xffffffff ; + result =0x80000001 ; + __asm + ("l.addc %0, %1, %2\n\t" +"l.movhi %2, 0x7fff\n\t" +"l.ori %2, %2, 0xffff\n\t" +"l.addc %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); + +if (a != result) { +printf ("addc error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_addi.c new file +31 -0
@@ -0,0 +1,31 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b; +int result; + + b =0x01 ; + result =0x00 ; + __asm + ("l.addi %0, %1, 0xffff\n\t" + :"=r" (a) + :"r" (b) + ); +if (a != result) { +printf ("addi error\n\t" ); + } + + b =0x010000 ; + result =0xffff ; + __asm + ("l.addi %0, %1, 0xffff\n\t" + :"=r" (a) + :"r" (b) + ); +if (a != result) { +printf ("addi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_addic.c new file +33 -0
@@ -0,0 +1,33 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b, c; +int result; + + a =1 ; + result =0x1 ; + + __asm + ("l.addic %0, %0, 0xffff\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("first addic error\n" ); + } + + a =0x1 ; + result =0x201 ; + __asm + ("l.addic %0, %0, 0xffff\n\t" +"l.ori %0, r0, 0x100\n\t" +"l.addic %0, %0, 0x100\n\t" + :"+r" (a) + ); + +if (a != result) { +printf ("second addic error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_and_or.c new file +61 -0
61 lines not on this page · raw message
tests/tcg/openrisc/test_bf.c new file +46 -0
46 lines not on this page · raw message
tests/tcg/openrisc/test_bnf.c new file +50 -0
50 lines not on this page · raw message
tests/tcg/openrisc/test_div.c new file +32 -0
@@ -0,0 +1,32 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b, c; +int result; + + b =0x120 ; + c =0x4 ; + result =0x48 ; + + __asm + ("l.div %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); +if (a != result) { +printf ("div error\n" ); + } + + result =0x4 ; + __asm + ("l.div %0, %1, %0\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("div error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_divu.c new file +32 -0
@@ -0,0 +1,32 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b, c; +int result; + + b =0x120 ; + c =0x4 ; + result =0x48 ; + + __asm + ("l.divu %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); +if (a != result) { +printf ("divu error\n" ); + } + + result =0x4 ; + __asm + ("l.divu %0, %1, %0\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("divu error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_extx.c new file +72 -0
72 lines not on this page · raw message
tests/tcg/openrisc/test_fx.c new file +53 -0
53 lines not on this page · raw message
tests/tcg/openrisc/test_j.c new file +26 -0
@@ -0,0 +1,26 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =2 ; + + __asm + ("l.addi %0, %0, 1\n\t" +"l.j j\n\t" +"l.nop\n\t" +"l.addi %0, %0, 1\n\t" +"l.nop\n\t" +"j:\n\t" +"l.addi %0, %0, 1\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("j error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_jal.c new file +26 -0
@@ -0,0 +1,26 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =2 ; + + __asm + ("l.addi %0, %0, 1\n\t" +"l.jal jal\n\t" +"l.nop\n\t" +"l.addi %0, %0, 1\n\t" +"l.nop\n\t" +"jal:\n\t" +"l.addi %0, %0, 1\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("jal error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_lf_add.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +float a, b; +float res2; + a =1.5 ; + b =2.5 ; + res2 =4.0 ; + + __asm + ("lf.add.s %0, %0, %1\n\t" + :"+r" (a) + :"r" (b) + ); + +if (a != res2) { +printf ("lf.add.s error, %f\n" , a); + } + +/* double c, d; +double res1; + +c = 1.5; +d = 1.5; +res1 = 3.00; + +__asm +("lf.add.d %0, %1, %2\n\t" +: "+r"(c) +: "r"(d) +); + +if ((e - res1) > 0.002) { +printf("lf.add.d error, %f\n", e - res1); +}*/ + +return 0 ; +}
tests/tcg/openrisc/test_lf_div.c new file +34 -0
@@ -0,0 +1,34 @@ +#include <stdio.h> + +int main (void ) +{ +float a, b, c; +float result; + b =1.5 ; + c =0.5 ; + result =3.0 ; + __asm + ("lf.div.s %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); +if (a != result) { +printf ("lf.div.s error\n" ); + } + +/* double a, b, c, res; + +b = 0x80000000; +c = 0x40; +result = 0x2000000; +__asm +("lf.div.d %0, %1, %2\n\t" +: "=r"(a) +: "r"(b), "r"(c) +); +if (a != result) { +printf("lf.div.d error\n"); +}*/ + +return 0 ; +}
tests/tcg/openrisc/test_lf_eqs.c new file +84 -0
84 lines not on this page · raw message
tests/tcg/openrisc/test_lf_ges.c new file +84 -0
84 lines not on this page · raw message
tests/tcg/openrisc/test_lf_gts.c new file +84 -0
84 lines not on this page · raw message
tests/tcg/openrisc/test_lf_les.c new file +84 -0
84 lines not on this page · raw message
tests/tcg/openrisc/test_lf_lts.c new file +91 -0
91 lines not on this page · raw message
tests/tcg/openrisc/test_lf_mul.c new file +22 -0
@@ -0,0 +1,22 @@ +#include <stdio.h> + +int main (void ) +{ +float a, b, c; +float result; + + b =1.5 ; + c =4.0 ; + result =6.0 ; + + __asm + ("lf.mul.s %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); +if (a != result) { +printf ("lf.mul.s error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_lf_nes.c new file +87 -0
87 lines not on this page · raw message
tests/tcg/openrisc/test_lf_rem.c new file +32 -0
@@ -0,0 +1,32 @@ +#include <stdio.h> + +int main (void ) +{ +float a, b, c; +float result; + + b =101.5 ; + c =10 ; + result =1.5 ; + +/* __asm +("lf.rem.d %0, %1, %2\n\t" +: "=r"(a) +: "r"(b), "r"(c) +); +if (a != result) { +printf("lf.rem.d error\n"); +}*/ + + __asm + ("lf.rem.s %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); + +if (a != result) { +printf ("lf.rem.s error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_lf_sub.c new file +33 -0
@@ -0,0 +1,33 @@ +#include <stdio.h> + +int main (void ) +{ +float a, b, c; +float result; + b =10.5 ; + c =1.5 ; + result =9.0 ; + __asm + ("lf.sub.s %0, %1, %2\n\t" + :"=r" (a) + :"r" (b),"r" (c) + ); +if (a != result) { +printf ("lf.sub.s error\n" ); + } + +/* b = 0x999; +c = 0x654; +result = 0x345; + +__asm +("lf.sub.d %0, %1, %2\n\t" +: "=r"(a) +: "r"(b), "r"(c) +); +if (a != result) { +printf("lf.sub.d error\n"); +}*/ + +return 0 ; +}
tests/tcg/openrisc/test_logic.c new file +100 -0
100 lines not on this page · raw message
tests/tcg/openrisc/test_lx.c new file +78 -0
78 lines not on this page · raw message
tests/tcg/openrisc/test_movhi.c new file +30 -0
@@ -0,0 +1,30 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + result =0x1222 ; + + __asm + ("l.movhi r3, 0x1222\n\t" +"l.srli %0, r3, 16\n\t" + :"=r" (a) + ); +if (a != result) { +printf ("movhi error\n" ); + } + + result =0x1111 ; + __asm + ("l.movhi r8, 0x1111\n\t" +"l.srli %0, r8, 16\n\t" + :"=r" (a) + ); +if (a != result) { +printf ("movhi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_mul.c new file +47 -0
47 lines not on this page · raw message
tests/tcg/openrisc/test_muli.c new file +47 -0
47 lines not on this page · raw message
tests/tcg/openrisc/test_mulu.c new file +47 -0
47 lines not on this page · raw message
tests/tcg/openrisc/test_sfeq.c new file +44 -0
44 lines not on this page · raw message
tests/tcg/openrisc/test_sfeqi.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =1 ; + result =2 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 0x1\n\t" +"l.sfeqi %0, 0x80\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfeqi error\n" ); + } + + a =0x7f ; + result =0x81 ; + + __asm + ("2:\n\t" +"l.addi %0, %0, 0x1\n\t" +"l.sfeqi %0, 0x80\n\t" +"l.bf 2b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfeqi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sfges.c new file +44 -0
44 lines not on this page · raw message
tests/tcg/openrisc/test_sfgesi.c new file +40 -0
@@ -0,0 +1,40 @@ +#include <stdio.h> +int main (void ) +{ +int a, b; +int result; + + a =0 ; + result =1 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sfgesi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfgesi error\n" ); + } + + a =0xff ; + b =1 ; + result =2 ; + + __asm + ("1:\n\t" +"l.sub %0, %0, %1\n\t" +"l.sfgesi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("sfgesi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sfgeu.c new file +44 -0
44 lines not on this page · raw message
tests/tcg/openrisc/test_sfgeui.c new file +41 -0
41 lines not on this page · raw message
tests/tcg/openrisc/test_sfgts.c new file +45 -0
45 lines not on this page · raw message
tests/tcg/openrisc/test_sfgtsi.c new file +41 -0
41 lines not on this page · raw message
tests/tcg/openrisc/test_sfgtu.c new file +43 -0
43 lines not on this page · raw message
tests/tcg/openrisc/test_sfgtui.c new file +42 -0
42 lines not on this page · raw message
tests/tcg/openrisc/test_sfles.c new file +26 -0
@@ -0,0 +1,26 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b; +int result; + + a =0 ; + b =3 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 4\n\t" +"l.sfles %0, %1\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("sfles error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sflesi.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 4\n\t" +"l.sflesi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sflesi error\n" ); + } + + a =0 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sflesi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sflesi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sfleu.c new file +43 -0
43 lines not on this page · raw message
tests/tcg/openrisc/test_sfleui.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 4\n\t" +"l.sfleui %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfleui error\n" ); + } + + a =0 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sfleui %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfleui error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sflts.c new file +43 -0
43 lines not on this page · raw message
tests/tcg/openrisc/test_sfltsi.c new file +38 -0
@@ -0,0 +1,38 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =4 ; + __asm + ("1:\n\t" +"l.addi %0, %0, 4\n\t" +"l.sfltsi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfltsi error\n" ); + } + + a =0 ; + result =3 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sfltsi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfltsi error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sfltu.c new file +41 -0
41 lines not on this page · raw message
tests/tcg/openrisc/test_sfltui.c new file +39 -0
@@ -0,0 +1,39 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =4 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 4\n\t" +"l.sfltsi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfltui error\n" ); + } + + a =0 ; + result =3 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sfltsi %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfltui error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sfne.c new file +43 -0
43 lines not on this page · raw message
tests/tcg/openrisc/test_sfnei.c new file +38 -0
@@ -0,0 +1,38 @@ +#include <stdio.h> + +int main (void ) +{ +int a; +int result; + + a =0 ; + result =3 ; + + __asm + ("1:\n\t" +"l.addi %0, %0, 3\n\t" +"l.sfnei %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfnei error\n" ); + } + + a =0 ; + result =3 ; + __asm + ("1:\n\t" +"l.addi %0, %0, 1\n\t" +"l.sfnei %0, 0x3\n\t" +"l.bf 1b\n\t" +"l.nop\n\t" + :"+r" (a) + ); +if (a != result) { +printf ("sfnei error\n" ); + } + +return 0 ; +}
tests/tcg/openrisc/test_sub.c new file +34 -0
@@ -0,0 +1,34 @@ +#include <stdio.h> + +int main (void ) +{ +int a, b; +int result; + + a =0x100 ; + b =0x100 ; + result =0x0 ; + + __asm + ("l.sub %0, %0, %1\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("sub error\n" ); + } + + a =0xffff ; + b =0x1 ; + result =0xfffe ; + __asm + ("l.sub %0, %0, %1\n\t" + :"+r" (a) + :"r" (b) + ); +if (a != result) { +printf ("sub error\n" ); + } + +return 0 ; +}
Signature · 1 line
1.7.9.5
Quoted 7 lines · Jia Liu
This is the OpenCores OpenRISC 1200 support for QEMU.
Full implementation of the system-model and linux-user-model support.OpenRISC 1200 is a OpenCores open source CPU,
its architecture manual can be found at
http://opencores.org/svnget,or1k?file=/trunk/docs/openrisc_arch.pdf
Quoted 8 lines
A OpenRISC Linux kernel contain initramfs for qemu-system-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLSjR3Sk5Vd3h1eDA/edit?pli=1A OpenRISC hello-world program for qemu-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLN3RSWUFNYktrU2M/edit?pli=1Signed-off-by Jia Liu <[email protected]>
I had minor comments to a few patches, others looked ready. Please still check the patches with scripts/checkpatch.pl.
Quoted 260 lines
---
Version History:
V5:
Addressed Blue's review comments:
- reimplement l.mul* l.mfspr l.add* l.sub* and more.
- shoot bugs with "--enable-debug-tcg"V4:
Addressed Max's review comments:
- fix l.div l.mac* l.mul*, and more.Addressed Richard, Wei-Ren and Andreas's review comments:
- replacetcg_temp_new_i32withtcg_temp_local_new_i32in l.div translation.Addressed Andreas's review comments:
- update to suitMakefilesystem.- add UPR CPUCFGR and MMUCFGR impelement.
- add instruction check functions.Version History:
V3:
Addressed Stefan and Andreas's review comments:
- use QEMU and OpenRISC's official name.Addressed Andreas's review comments:
- reimplement cpu QOM.
- combine target stubs and QOM implement.
- use new commit message and subject.Addressed Max's review comments:
- handle div zero exception.
- reimplement float point instructions.
- fix l.mac*, l.mul*, and more.V2:
Addressed Malc, Weiren, Andreas and Blue's review comments:
- reimplement cpu QOM.Addressed Andreas's review comments:
- reimplement machine.
- rewrite the Copyright Notice using better format.Addressed Blue and Weiren's review comments:
- compiling with AREG0 and remove global env, no dyngen-exe longer.Addressed Max, Blue and Weiren's review comments:
- handle div zero exception.
- handle illegal instruction.Addressed Blue's review comments:
- separatedo_interruptintointrpt.cformintrpt_helper.c.
- addQEMU_NORETURNtoraise_exception.
- reimplement float instrutions.
- fix type of linux syscall and termbits.
- reimplement sim board.
- use the LGPL web URL in Copyright Notice.
- reimplemt branch instructions.- split taregt stubs, QOM and machine.
V1:
- add QEMU OpenRISC support.
- well tested on x64 machine, and final tested x86 machine.Jia Liu (16):
target-or32: Add target stubs and cpu support
target-or32: Add target machine
target-or32: Add MMU support
target-or32: Add interrupt support
target-or32: Add exception support
target-or32: Add int instruction helpers
target-or32: Add float instruction helpers
target-or32: Add translation routines
target-or32: Add PIC support
target-or32: Add timer support
target-or32: Add a IIS dummy board
target-or32: Add system instructions
target-or32: Add gdb stub support
target-or32: Add linux syscall, signal and termbits
target-or32: Add linux user support
target-or32: Add testcasesarch_init.c | 2 +
arch_init.h| 1 + configure | 15 +-cpu-exec.c| 19 + default-configs/or32-linux-user.mak | 2 + default-configs/or32-softmmu.mak | 6 +elf.h| 2 +gdbstub.c| 64 ++ hw/openrisc/Makefile.objs | 3 +hw/openrisc_cpudev.h| 29 +hw/openrisc_pic.c| 78 ++hw/openrisc_sim.c| 145 +++hw/openrisc_timer.c| 160 +++linux-user/elfload.c| 41 +linux-user/main.c| 100 ++linux-user/openrisc/syscall.h| 24 +linux-user/openrisc/syscall_nr.h| 506 +++++++++linux-user/openrisc/target_signal.h| 26 +linux-user/openrisc/termbits.h| 294 +++++linux-user/signal.c| 229 ++++linux-user/syscall.c| 2 +-linux-user/syscall_defs.h| 40 +-poison.h| 1 + target-openrisc/Makefile.objs | 4 +target-openrisc/cpu.c | 240 +++++ target-openrisc/cpu.h | 445 ++++++++ target-openrisc/excp.c | 27 + target-openrisc/excp.h | 28 +target-openrisc/excp_helper.c | 27 +
target-openrisc/fpu_helper.c | 275 +++++
target-openrisc/helper.h | 69 ++
target-openrisc/int_helper.c | 51 +
target-openrisc/intrpt.c | 74 ++
target-openrisc/intrpt_helper.c | 52 +
target-openrisc/machine.c | 50 +
target-openrisc/mmu.c | 236 ++++target-openrisc/mmu_helper.c | 63 ++ target-openrisc/sys_helper.c | 233 ++++ target-openrisc/translate.c | 2036 +++++++++++++++++++++++++++++++++++ tests/tcg/openrisc/Makefile | 71 ++ tests/tcg/openrisc/test_add.c | 34 + tests/tcg/openrisc/test_addc.c | 39 + tests/tcg/openrisc/test_addi.c | 31 + tests/tcg/openrisc/test_addic.c | 33 + tests/tcg/openrisc/test_and_or.c | 61 ++ tests/tcg/openrisc/test_bf.c | 46 + tests/tcg/openrisc/test_bnf.c | 50 + tests/tcg/openrisc/test_div.c | 32 + tests/tcg/openrisc/test_divu.c | 32 + tests/tcg/openrisc/test_extx.c | 72 ++ tests/tcg/openrisc/test_fx.c | 53 + tests/tcg/openrisc/test_j.c | 26 + tests/tcg/openrisc/test_jal.c | 26 + tests/tcg/openrisc/test_lf_add.c | 39 + tests/tcg/openrisc/test_lf_div.c | 34 + tests/tcg/openrisc/test_lf_eqs.c | 84 ++ tests/tcg/openrisc/test_lf_ges.c | 84 ++ tests/tcg/openrisc/test_lf_gts.c | 84 ++ tests/tcg/openrisc/test_lf_les.c | 84 ++ tests/tcg/openrisc/test_lf_lts.c | 91 ++ tests/tcg/openrisc/test_lf_mul.c | 22 + tests/tcg/openrisc/test_lf_nes.c | 87 ++ tests/tcg/openrisc/test_lf_rem.c | 32 + tests/tcg/openrisc/test_lf_sub.c | 33 + tests/tcg/openrisc/test_logic.c | 100 ++ tests/tcg/openrisc/test_lx.c | 78 ++ tests/tcg/openrisc/test_movhi.c | 30 + tests/tcg/openrisc/test_mul.c | 47 + tests/tcg/openrisc/test_muli.c | 47 + tests/tcg/openrisc/test_mulu.c | 47 + tests/tcg/openrisc/test_sfeq.c | 44 + tests/tcg/openrisc/test_sfeqi.c | 39 + tests/tcg/openrisc/test_sfges.c | 44 + tests/tcg/openrisc/test_sfgesi.c | 40 + tests/tcg/openrisc/test_sfgeu.c | 44 + tests/tcg/openrisc/test_sfgeui.c | 41 + tests/tcg/openrisc/test_sfgts.c | 45 + tests/tcg/openrisc/test_sfgtsi.c | 41 + tests/tcg/openrisc/test_sfgtu.c | 43 + tests/tcg/openrisc/test_sfgtui.c | 42 + tests/tcg/openrisc/test_sfles.c | 26 + tests/tcg/openrisc/test_sflesi.c | 39 + tests/tcg/openrisc/test_sfleu.c | 43 + tests/tcg/openrisc/test_sfleui.c | 39 + tests/tcg/openrisc/test_sflts.c | 43 + tests/tcg/openrisc/test_sfltsi.c | 38 + tests/tcg/openrisc/test_sfltu.c | 41 + tests/tcg/openrisc/test_sfltui.c | 39 + tests/tcg/openrisc/test_sfne.c | 43 + tests/tcg/openrisc/test_sfnei.c | 38 + tests/tcg/openrisc/test_sub.c | 34 + 91 files changed, 8168 insertions(+), 6 deletions(-)create mode 100644 default-configs/or32-linux-user.mak create mode 100644 default-configs/or32-softmmu.mak create mode 100644 hw/openrisc/Makefile.objs create mode 100644
hw/openrisc_cpudev.hcreate mode 100644hw/openrisc_pic.c
create mode 100644hw/openrisc_sim.c
create mode 100644hw/openrisc_timer.c
create mode 100644linux-user/openrisc/syscall.hcreate mode 100644linux-user/openrisc/syscall_nr.hcreate mode 100644linux-user/openrisc/target_signal.hcreate mode 100644linux-user/openrisc/termbits.hcreate mode 100644 target-openrisc/Makefile.objs create mode 100644target-openrisc/cpu.ccreate mode 100644target-openrisc/cpu.hcreate mode 100644target-openrisc/excp.ccreate mode 100644target-openrisc/excp.hcreate mode 100644target-openrisc/excp_helper.ccreate mode 100644target-openrisc/fpu_helper.ccreate mode 100644target-openrisc/helper.hcreate mode 100644target-openrisc/int_helper.ccreate mode 100644target-openrisc/intrpt.ccreate mode 100644target-openrisc/intrpt_helper.ccreate mode 100644target-openrisc/machine.ccreate mode 100644target-openrisc/mmu.ccreate mode 100644target-openrisc/mmu_helper.ccreate mode 100644target-openrisc/sys_helper.ccreate mode 100644target-openrisc/translate.ccreate mode 100644 tests/tcg/openrisc/Makefile create mode 100644tests/tcg/openrisc/test_add.ccreate mode 100644tests/tcg/openrisc/test_addc.ccreate mode 100644tests/tcg/openrisc/test_addi.ccreate mode 100644tests/tcg/openrisc/test_addic.ccreate mode 100644tests/tcg/openrisc/test_and_or.ccreate mode 100644tests/tcg/openrisc/test_bf.ccreate mode 100644tests/tcg/openrisc/test_bnf.ccreate mode 100644tests/tcg/openrisc/test_div.ccreate mode 100644tests/tcg/openrisc/test_divu.ccreate mode 100644tests/tcg/openrisc/test_extx.ccreate mode 100644tests/tcg/openrisc/test_fx.ccreate mode 100644tests/tcg/openrisc/test_j.ccreate mode 100644tests/tcg/openrisc/test_jal.ccreate mode 100644tests/tcg/openrisc/test_lf_add.ccreate mode 100644tests/tcg/openrisc/test_lf_div.ccreate mode 100644tests/tcg/openrisc/test_lf_eqs.ccreate mode 100644tests/tcg/openrisc/test_lf_ges.ccreate mode 100644tests/tcg/openrisc/test_lf_gts.ccreate mode 100644tests/tcg/openrisc/test_lf_les.ccreate mode 100644tests/tcg/openrisc/test_lf_lts.ccreate mode 100644tests/tcg/openrisc/test_lf_mul.ccreate mode 100644tests/tcg/openrisc/test_lf_nes.ccreate mode 100644tests/tcg/openrisc/test_lf_rem.ccreate mode 100644tests/tcg/openrisc/test_lf_sub.ccreate mode 100644tests/tcg/openrisc/test_logic.ccreate mode 100644tests/tcg/openrisc/test_lx.ccreate mode 100644tests/tcg/openrisc/test_movhi.ccreate mode 100644tests/tcg/openrisc/test_mul.ccreate mode 100644tests/tcg/openrisc/test_muli.ccreate mode 100644tests/tcg/openrisc/test_mulu.ccreate mode 100644tests/tcg/openrisc/test_sfeq.ccreate mode 100644tests/tcg/openrisc/test_sfeqi.ccreate mode 100644tests/tcg/openrisc/test_sfges.ccreate mode 100644tests/tcg/openrisc/test_sfgesi.ccreate mode 100644tests/tcg/openrisc/test_sfgeu.ccreate mode 100644tests/tcg/openrisc/test_sfgeui.ccreate mode 100644tests/tcg/openrisc/test_sfgts.ccreate mode 100644tests/tcg/openrisc/test_sfgtsi.ccreate mode 100644tests/tcg/openrisc/test_sfgtu.ccreate mode 100644tests/tcg/openrisc/test_sfgtui.ccreate mode 100644tests/tcg/openrisc/test_sfles.ccreate mode 100644tests/tcg/openrisc/test_sflesi.ccreate mode 100644tests/tcg/openrisc/test_sfleu.ccreate mode 100644tests/tcg/openrisc/test_sfleui.ccreate mode 100644tests/tcg/openrisc/test_sflts.ccreate mode 100644tests/tcg/openrisc/test_sfltsi.ccreate mode 100644tests/tcg/openrisc/test_sfltu.ccreate mode 100644tests/tcg/openrisc/test_sfltui.ccreate mode 100644tests/tcg/openrisc/test_sfne.ccreate mode 100644tests/tcg/openrisc/test_sfnei.ccreate mode 100644tests/tcg/openrisc/test_sub.c--
1.7.9.5
Hi Blue,
Quoted 12 lines · Blue Swirl
Quoted 11 lines · Jia Liu
This is the OpenCores OpenRISC 1200 support for QEMU.
Full implementation of the system-model and linux-user-model support.OpenRISC 1200 is a OpenCores open source CPU,
its architecture manual can be found at
http://opencores.org/svnget,or1k?file=/trunk/docs/openrisc_arch.pdfA OpenRISC Linux kernel contain initramfs for qemu-system-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLSjR3Sk5Vd3h1eDA/edit?pli=1
Quoted 8 lines
Quoted 4 lines
A OpenRISC hello-world program for qemu-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLN3RSWUFNYktrU2M/edit?pli=1Signed-off-by Jia Liu <[email protected]>I had minor comments to a few patches, others looked ready. Please still check the patches with
scripts/checkpatch.pl.
I've checked the patches with scripts/checkpatch.pl.
when I run "./scripts/checkpatch.pl *.patch", it is all OK,
but when I run "./scripts/checkpatch.pl 0012-xxx.patch", 0006 and 0012 have ERROR like this:
ERROR: need consistent spacing around '*' (ctx:WxV) #99: FILE: target-openrisc/int_helper.c:53:
+target_ulong HELPER(mul32)(CPUOpenRISCState *env,
It is really weird. And, I don't know how to handle it.
Quoted 256 lines
Quoted 256 lines
---
Version History:
V5:
Addressed Blue's review comments:
- reimplement l.mul* l.mfspr l.add* l.sub* and more.
- shoot bugs with "--enable-debug-tcg"V4:
Addressed Max's review comments:
- fix l.div l.mac* l.mul*, and more.Addressed Richard, Wei-Ren and Andreas's review comments:
- replacetcg_temp_new_i32withtcg_temp_local_new_i32in l.div translation.Addressed Andreas's review comments:
- update to suitMakefilesystem.- add UPR CPUCFGR and MMUCFGR impelement.
- add instruction check functions.Version History:
V3:
Addressed Stefan and Andreas's review comments:
- use QEMU and OpenRISC's official name.Addressed Andreas's review comments:
- reimplement cpu QOM.
- combine target stubs and QOM implement.
- use new commit message and subject.Addressed Max's review comments:
- handle div zero exception.
- reimplement float point instructions.
- fix l.mac*, l.mul*, and more.V2:
Addressed Malc, Weiren, Andreas and Blue's review comments:
- reimplement cpu QOM.Addressed Andreas's review comments:
- reimplement machine.
- rewrite the Copyright Notice using better format.Addressed Blue and Weiren's review comments:
- compiling with AREG0 and remove global env, no dyngen-exe longer.Addressed Max, Blue and Weiren's review comments:
- handle div zero exception.
- handle illegal instruction.Addressed Blue's review comments:
- separatedo_interruptintointrpt.cformintrpt_helper.c.
- addQEMU_NORETURNtoraise_exception.
- reimplement float instrutions.
- fix type of linux syscall and termbits.
- reimplement sim board.
- use the LGPL web URL in Copyright Notice.
- reimplemt branch instructions.- split taregt stubs, QOM and machine.
V1:
- add QEMU OpenRISC support.
- well tested on x64 machine, and final tested x86 machine.Jia Liu (16):
target-or32: Add target stubs and cpu support
target-or32: Add target machine
target-or32: Add MMU support
target-or32: Add interrupt support
target-or32: Add exception support
target-or32: Add int instruction helpers
target-or32: Add float instruction helpers
target-or32: Add translation routines
target-or32: Add PIC support
target-or32: Add timer support
target-or32: Add a IIS dummy board
target-or32: Add system instructions
target-or32: Add gdb stub support
target-or32: Add linux syscall, signal and termbits
target-or32: Add linux user support
target-or32: Add testcasesarch_init.c | 2 +
arch_init.h| 1 + configure | 15 +-cpu-exec.c| 19 + default-configs/or32-linux-user.mak | 2 + default-configs/or32-softmmu.mak | 6 +elf.h| 2 +gdbstub.c| 64 ++ hw/openrisc/Makefile.objs | 3 +hw/openrisc_cpudev.h| 29 +hw/openrisc_pic.c| 78 ++hw/openrisc_sim.c| 145 +++hw/openrisc_timer.c| 160 +++linux-user/elfload.c| 41 +linux-user/main.c| 100 ++linux-user/openrisc/syscall.h| 24 +linux-user/openrisc/syscall_nr.h| 506 +++++++++linux-user/openrisc/target_signal.h| 26 +linux-user/openrisc/termbits.h| 294 +++++linux-user/signal.c| 229 ++++linux-user/syscall.c| 2 +-linux-user/syscall_defs.h| 40 +-poison.h| 1 + target-openrisc/Makefile.objs | 4 +target-openrisc/cpu.c | 240 +++++ target-openrisc/cpu.h | 445 ++++++++ target-openrisc/excp.c | 27 + target-openrisc/excp.h | 28 +target-openrisc/excp_helper.c | 27 +
target-openrisc/fpu_helper.c | 275 +++++
target-openrisc/helper.h | 69 ++
target-openrisc/int_helper.c | 51 +
target-openrisc/intrpt.c | 74 ++
target-openrisc/intrpt_helper.c | 52 +
target-openrisc/machine.c | 50 +
target-openrisc/mmu.c | 236 ++++target-openrisc/mmu_helper.c | 63 ++ target-openrisc/sys_helper.c | 233 ++++ target-openrisc/translate.c | 2036 +++++++++++++++++++++++++++++++++++ tests/tcg/openrisc/Makefile | 71 ++ tests/tcg/openrisc/test_add.c | 34 + tests/tcg/openrisc/test_addc.c | 39 + tests/tcg/openrisc/test_addi.c | 31 + tests/tcg/openrisc/test_addic.c | 33 + tests/tcg/openrisc/test_and_or.c | 61 ++ tests/tcg/openrisc/test_bf.c | 46 + tests/tcg/openrisc/test_bnf.c | 50 + tests/tcg/openrisc/test_div.c | 32 + tests/tcg/openrisc/test_divu.c | 32 + tests/tcg/openrisc/test_extx.c | 72 ++ tests/tcg/openrisc/test_fx.c | 53 + tests/tcg/openrisc/test_j.c | 26 + tests/tcg/openrisc/test_jal.c | 26 + tests/tcg/openrisc/test_lf_add.c | 39 + tests/tcg/openrisc/test_lf_div.c | 34 + tests/tcg/openrisc/test_lf_eqs.c | 84 ++ tests/tcg/openrisc/test_lf_ges.c | 84 ++ tests/tcg/openrisc/test_lf_gts.c | 84 ++ tests/tcg/openrisc/test_lf_les.c | 84 ++ tests/tcg/openrisc/test_lf_lts.c | 91 ++ tests/tcg/openrisc/test_lf_mul.c | 22 + tests/tcg/openrisc/test_lf_nes.c | 87 ++ tests/tcg/openrisc/test_lf_rem.c | 32 + tests/tcg/openrisc/test_lf_sub.c | 33 + tests/tcg/openrisc/test_logic.c | 100 ++ tests/tcg/openrisc/test_lx.c | 78 ++ tests/tcg/openrisc/test_movhi.c | 30 + tests/tcg/openrisc/test_mul.c | 47 + tests/tcg/openrisc/test_muli.c | 47 + tests/tcg/openrisc/test_mulu.c | 47 + tests/tcg/openrisc/test_sfeq.c | 44 + tests/tcg/openrisc/test_sfeqi.c | 39 + tests/tcg/openrisc/test_sfges.c | 44 + tests/tcg/openrisc/test_sfgesi.c | 40 + tests/tcg/openrisc/test_sfgeu.c | 44 + tests/tcg/openrisc/test_sfgeui.c | 41 + tests/tcg/openrisc/test_sfgts.c | 45 + tests/tcg/openrisc/test_sfgtsi.c | 41 + tests/tcg/openrisc/test_sfgtu.c | 43 + tests/tcg/openrisc/test_sfgtui.c | 42 + tests/tcg/openrisc/test_sfles.c | 26 + tests/tcg/openrisc/test_sflesi.c | 39 + tests/tcg/openrisc/test_sfleu.c | 43 + tests/tcg/openrisc/test_sfleui.c | 39 + tests/tcg/openrisc/test_sflts.c | 43 + tests/tcg/openrisc/test_sfltsi.c | 38 + tests/tcg/openrisc/test_sfltu.c | 41 + tests/tcg/openrisc/test_sfltui.c | 39 + tests/tcg/openrisc/test_sfne.c | 43 + tests/tcg/openrisc/test_sfnei.c | 38 + tests/tcg/openrisc/test_sub.c | 34 + 91 files changed, 8168 insertions(+), 6 deletions(-)create mode 100644 default-configs/or32-linux-user.mak create mode 100644 default-configs/or32-softmmu.mak create mode 100644 hw/openrisc/Makefile.objs create mode 100644
hw/openrisc_cpudev.hcreate mode 100644hw/openrisc_pic.c
create mode 100644hw/openrisc_sim.c
create mode 100644hw/openrisc_timer.c
create mode 100644linux-user/openrisc/syscall.hcreate mode 100644linux-user/openrisc/syscall_nr.hcreate mode 100644linux-user/openrisc/target_signal.hcreate mode 100644linux-user/openrisc/termbits.hcreate mode 100644 target-openrisc/Makefile.objs create mode 100644target-openrisc/cpu.ccreate mode 100644target-openrisc/cpu.hcreate mode 100644target-openrisc/excp.ccreate mode 100644target-openrisc/excp.hcreate mode 100644target-openrisc/excp_helper.ccreate mode 100644target-openrisc/fpu_helper.ccreate mode 100644target-openrisc/helper.hcreate mode 100644target-openrisc/int_helper.ccreate mode 100644target-openrisc/intrpt.ccreate mode 100644target-openrisc/intrpt_helper.ccreate mode 100644target-openrisc/machine.ccreate mode 100644target-openrisc/mmu.ccreate mode 100644target-openrisc/mmu_helper.ccreate mode 100644target-openrisc/sys_helper.ccreate mode 100644target-openrisc/translate.ccreate mode 100644 tests/tcg/openrisc/Makefile create mode 100644tests/tcg/openrisc/test_add.ccreate mode 100644tests/tcg/openrisc/test_addc.ccreate mode 100644tests/tcg/openrisc/test_addi.ccreate mode 100644tests/tcg/openrisc/test_addic.ccreate mode 100644tests/tcg/openrisc/test_and_or.ccreate mode 100644tests/tcg/openrisc/test_bf.ccreate mode 100644tests/tcg/openrisc/test_bnf.ccreate mode 100644tests/tcg/openrisc/test_div.ccreate mode 100644tests/tcg/openrisc/test_divu.ccreate mode 100644tests/tcg/openrisc/test_extx.ccreate mode 100644tests/tcg/openrisc/test_fx.ccreate mode 100644tests/tcg/openrisc/test_j.ccreate mode 100644tests/tcg/openrisc/test_jal.ccreate mode 100644tests/tcg/openrisc/test_lf_add.ccreate mode 100644tests/tcg/openrisc/test_lf_div.ccreate mode 100644tests/tcg/openrisc/test_lf_eqs.ccreate mode 100644tests/tcg/openrisc/test_lf_ges.ccreate mode 100644tests/tcg/openrisc/test_lf_gts.ccreate mode 100644tests/tcg/openrisc/test_lf_les.ccreate mode 100644tests/tcg/openrisc/test_lf_lts.ccreate mode 100644tests/tcg/openrisc/test_lf_mul.ccreate mode 100644tests/tcg/openrisc/test_lf_nes.ccreate mode 100644tests/tcg/openrisc/test_lf_rem.ccreate mode 100644tests/tcg/openrisc/test_lf_sub.ccreate mode 100644tests/tcg/openrisc/test_logic.ccreate mode 100644tests/tcg/openrisc/test_lx.ccreate mode 100644tests/tcg/openrisc/test_movhi.ccreate mode 100644tests/tcg/openrisc/test_mul.ccreate mode 100644tests/tcg/openrisc/test_muli.ccreate mode 100644tests/tcg/openrisc/test_mulu.ccreate mode 100644tests/tcg/openrisc/test_sfeq.ccreate mode 100644tests/tcg/openrisc/test_sfeqi.ccreate mode 100644tests/tcg/openrisc/test_sfges.ccreate mode 100644tests/tcg/openrisc/test_sfgesi.ccreate mode 100644tests/tcg/openrisc/test_sfgeu.ccreate mode 100644tests/tcg/openrisc/test_sfgeui.ccreate mode 100644tests/tcg/openrisc/test_sfgts.ccreate mode 100644tests/tcg/openrisc/test_sfgtsi.ccreate mode 100644tests/tcg/openrisc/test_sfgtu.ccreate mode 100644tests/tcg/openrisc/test_sfgtui.ccreate mode 100644tests/tcg/openrisc/test_sfles.ccreate mode 100644tests/tcg/openrisc/test_sflesi.ccreate mode 100644tests/tcg/openrisc/test_sfleu.ccreate mode 100644tests/tcg/openrisc/test_sfleui.ccreate mode 100644tests/tcg/openrisc/test_sflts.ccreate mode 100644tests/tcg/openrisc/test_sfltsi.ccreate mode 100644tests/tcg/openrisc/test_sfltu.ccreate mode 100644tests/tcg/openrisc/test_sfltui.ccreate mode 100644tests/tcg/openrisc/test_sfne.ccreate mode 100644tests/tcg/openrisc/test_sfnei.ccreate mode 100644tests/tcg/openrisc/test_sub.c
Quoted 4 lines
Quoted 4 lines
--
1.7.9.5
Regards,
Jia.
Quoted 28 lines · Jia Liu
Hi Blue,
Quoted 12 lines · Blue Swirl
Quoted 11 lines · Jia Liu
This is the OpenCores OpenRISC 1200 support for QEMU.
Full implementation of the system-model and linux-user-model support.OpenRISC 1200 is a OpenCores open source CPU,
its architecture manual can be found at
http://opencores.org/svnget,or1k?file=/trunk/docs/openrisc_arch.pdfA OpenRISC Linux kernel contain initramfs for qemu-system-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLSjR3Sk5Vd3h1eDA/edit?pli=1Quoted 8 lines
Quoted 4 lines
A OpenRISC hello-world program for qemu-or32 testing can be found at
https://docs.google.com/file/d/0BxeTrz3x0CBLN3RSWUFNYktrU2M/edit?pli=1Signed-off-by Jia Liu <[email protected]>I had minor comments to a few patches, others looked ready. Please still check the patches with
scripts/checkpatch.pl.I've checked the patches with
scripts/checkpatch.pl.when I run "
./scripts/checkpatch.pl*.patch", it is all OK,
Quoted 8 lines
but when I run "
./scripts/checkpatch.pl0012-xxx.patch", 0006 and 0012 have ERROR like this:ERROR: need consistent spacing around '*' (ctx:WxV) #99: FILE:
target-openrisc/int_helper.c:53:
+target_ulong HELPER(mul32)(CPUOpenRISCState *env,It is really weird. And, I don't know how to handle it.
It's a limitation in checkpatch.pl, it is confused by any CPUxxxState for some reason. Please just ignore these cases.
Quoted 266 lines
Quoted 258 lines
Quoted 258 lines
---
Version History:
V5:
Addressed Blue's review comments:
- reimplement l.mul* l.mfspr l.add* l.sub* and more.
- shoot bugs with "--enable-debug-tcg"V4:
Addressed Max's review comments:
- fix l.div l.mac* l.mul*, and more.Addressed Richard, Wei-Ren and Andreas's review comments:
- replacetcg_temp_new_i32withtcg_temp_local_new_i32in l.div translation.Addressed Andreas's review comments:
- update to suitMakefilesystem.- add UPR CPUCFGR and MMUCFGR impelement.
- add instruction check functions.Version History:
V3:
Addressed Stefan and Andreas's review comments:
- use QEMU and OpenRISC's official name.Addressed Andreas's review comments:
- reimplement cpu QOM.
- combine target stubs and QOM implement.
- use new commit message and subject.Addressed Max's review comments:
- handle div zero exception.
- reimplement float point instructions.
- fix l.mac*, l.mul*, and more.V2:
Addressed Malc, Weiren, Andreas and Blue's review comments:
- reimplement cpu QOM.Addressed Andreas's review comments:
- reimplement machine.
- rewrite the Copyright Notice using better format.Addressed Blue and Weiren's review comments:
- compiling with AREG0 and remove global env, no dyngen-exe longer.Addressed Max, Blue and Weiren's review comments:
- handle div zero exception.
- handle illegal instruction.Addressed Blue's review comments:
- separatedo_interruptintointrpt.cformintrpt_helper.c.
- addQEMU_NORETURNtoraise_exception.
- reimplement float instrutions.
- fix type of linux syscall and termbits.
- reimplement sim board.
- use the LGPL web URL in Copyright Notice.
- reimplemt branch instructions.- split taregt stubs, QOM and machine.
V1:
- add QEMU OpenRISC support.
- well tested on x64 machine, and final tested x86 machine.Jia Liu (16):
target-or32: Add target stubs and cpu support
target-or32: Add target machine
target-or32: Add MMU support
target-or32: Add interrupt support
target-or32: Add exception support
target-or32: Add int instruction helpers
target-or32: Add float instruction helpers
target-or32: Add translation routines
target-or32: Add PIC support
target-or32: Add timer support
target-or32: Add a IIS dummy board
target-or32: Add system instructions
target-or32: Add gdb stub support
target-or32: Add linux syscall, signal and termbits
target-or32: Add linux user support
target-or32: Add testcasesarch_init.c | 2 +
arch_init.h| 1 + configure | 15 +-cpu-exec.c| 19 + default-configs/or32-linux-user.mak | 2 + default-configs/or32-softmmu.mak | 6 +elf.h| 2 +gdbstub.c| 64 ++ hw/openrisc/Makefile.objs | 3 +hw/openrisc_cpudev.h| 29 +hw/openrisc_pic.c| 78 ++hw/openrisc_sim.c| 145 +++hw/openrisc_timer.c| 160 +++linux-user/elfload.c| 41 +linux-user/main.c| 100 ++linux-user/openrisc/syscall.h| 24 +linux-user/openrisc/syscall_nr.h| 506 +++++++++linux-user/openrisc/target_signal.h| 26 +linux-user/openrisc/termbits.h| 294 +++++linux-user/signal.c| 229 ++++linux-user/syscall.c| 2 +-linux-user/syscall_defs.h| 40 +-poison.h| 1 + target-openrisc/Makefile.objs | 4 +target-openrisc/cpu.c | 240 +++++ target-openrisc/cpu.h | 445 ++++++++ target-openrisc/excp.c | 27 + target-openrisc/excp.h | 28 +target-openrisc/excp_helper.c | 27 +
target-openrisc/fpu_helper.c | 275 +++++
target-openrisc/helper.h | 69 ++
target-openrisc/int_helper.c | 51 +
target-openrisc/intrpt.c | 74 ++
target-openrisc/intrpt_helper.c | 52 +
target-openrisc/machine.c | 50 +
target-openrisc/mmu.c | 236 ++++target-openrisc/mmu_helper.c | 63 ++ target-openrisc/sys_helper.c | 233 ++++ target-openrisc/translate.c | 2036 +++++++++++++++++++++++++++++++++++ tests/tcg/openrisc/Makefile | 71 ++ tests/tcg/openrisc/test_add.c | 34 + tests/tcg/openrisc/test_addc.c | 39 + tests/tcg/openrisc/test_addi.c | 31 + tests/tcg/openrisc/test_addic.c | 33 + tests/tcg/openrisc/test_and_or.c | 61 ++ tests/tcg/openrisc/test_bf.c | 46 + tests/tcg/openrisc/test_bnf.c | 50 + tests/tcg/openrisc/test_div.c | 32 + tests/tcg/openrisc/test_divu.c | 32 + tests/tcg/openrisc/test_extx.c | 72 ++ tests/tcg/openrisc/test_fx.c | 53 + tests/tcg/openrisc/test_j.c | 26 + tests/tcg/openrisc/test_jal.c | 26 + tests/tcg/openrisc/test_lf_add.c | 39 + tests/tcg/openrisc/test_lf_div.c | 34 + tests/tcg/openrisc/test_lf_eqs.c | 84 ++ tests/tcg/openrisc/test_lf_ges.c | 84 ++ tests/tcg/openrisc/test_lf_gts.c | 84 ++ tests/tcg/openrisc/test_lf_les.c | 84 ++ tests/tcg/openrisc/test_lf_lts.c | 91 ++ tests/tcg/openrisc/test_lf_mul.c | 22 + tests/tcg/openrisc/test_lf_nes.c | 87 ++ tests/tcg/openrisc/test_lf_rem.c | 32 + tests/tcg/openrisc/test_lf_sub.c | 33 + tests/tcg/openrisc/test_logic.c | 100 ++ tests/tcg/openrisc/test_lx.c | 78 ++ tests/tcg/openrisc/test_movhi.c | 30 + tests/tcg/openrisc/test_mul.c | 47 + tests/tcg/openrisc/test_muli.c | 47 + tests/tcg/openrisc/test_mulu.c | 47 + tests/tcg/openrisc/test_sfeq.c | 44 + tests/tcg/openrisc/test_sfeqi.c | 39 + tests/tcg/openrisc/test_sfges.c | 44 + tests/tcg/openrisc/test_sfgesi.c | 40 + tests/tcg/openrisc/test_sfgeu.c | 44 + tests/tcg/openrisc/test_sfgeui.c | 41 + tests/tcg/openrisc/test_sfgts.c | 45 + tests/tcg/openrisc/test_sfgtsi.c | 41 + tests/tcg/openrisc/test_sfgtu.c | 43 + tests/tcg/openrisc/test_sfgtui.c | 42 + tests/tcg/openrisc/test_sfles.c | 26 + tests/tcg/openrisc/test_sflesi.c | 39 + tests/tcg/openrisc/test_sfleu.c | 43 + tests/tcg/openrisc/test_sfleui.c | 39 + tests/tcg/openrisc/test_sflts.c | 43 + tests/tcg/openrisc/test_sfltsi.c | 38 + tests/tcg/openrisc/test_sfltu.c | 41 + tests/tcg/openrisc/test_sfltui.c | 39 + tests/tcg/openrisc/test_sfne.c | 43 + tests/tcg/openrisc/test_sfnei.c | 38 + tests/tcg/openrisc/test_sub.c | 34 + 91 files changed, 8168 insertions(+), 6 deletions(-)create mode 100644 default-configs/or32-linux-user.mak create mode 100644 default-configs/or32-softmmu.mak create mode 100644 hw/openrisc/Makefile.objs create mode 100644
hw/openrisc_cpudev.hcreate mode 100644hw/openrisc_pic.c
create mode 100644hw/openrisc_sim.c
create mode 100644hw/openrisc_timer.c
create mode 100644linux-user/openrisc/syscall.hcreate mode 100644linux-user/openrisc/syscall_nr.hcreate mode 100644linux-user/openrisc/target_signal.hcreate mode 100644linux-user/openrisc/termbits.hcreate mode 100644 target-openrisc/Makefile.objs create mode 100644target-openrisc/cpu.ccreate mode 100644target-openrisc/cpu.hcreate mode 100644target-openrisc/excp.ccreate mode 100644target-openrisc/excp.hcreate mode 100644target-openrisc/excp_helper.ccreate mode 100644target-openrisc/fpu_helper.ccreate mode 100644target-openrisc/helper.hcreate mode 100644target-openrisc/int_helper.ccreate mode 100644target-openrisc/intrpt.ccreate mode 100644target-openrisc/intrpt_helper.ccreate mode 100644target-openrisc/machine.ccreate mode 100644target-openrisc/mmu.ccreate mode 100644target-openrisc/mmu_helper.ccreate mode 100644target-openrisc/sys_helper.ccreate mode 100644target-openrisc/translate.ccreate mode 100644 tests/tcg/openrisc/Makefile create mode 100644tests/tcg/openrisc/test_add.ccreate mode 100644tests/tcg/openrisc/test_addc.ccreate mode 100644tests/tcg/openrisc/test_addi.ccreate mode 100644tests/tcg/openrisc/test_addic.ccreate mode 100644tests/tcg/openrisc/test_and_or.ccreate mode 100644tests/tcg/openrisc/test_bf.ccreate mode 100644tests/tcg/openrisc/test_bnf.ccreate mode 100644tests/tcg/openrisc/test_div.ccreate mode 100644tests/tcg/openrisc/test_divu.ccreate mode 100644tests/tcg/openrisc/test_extx.ccreate mode 100644tests/tcg/openrisc/test_fx.ccreate mode 100644tests/tcg/openrisc/test_j.ccreate mode 100644tests/tcg/openrisc/test_jal.ccreate mode 100644tests/tcg/openrisc/test_lf_add.ccreate mode 100644tests/tcg/openrisc/test_lf_div.ccreate mode 100644tests/tcg/openrisc/test_lf_eqs.ccreate mode 100644tests/tcg/openrisc/test_lf_ges.ccreate mode 100644tests/tcg/openrisc/test_lf_gts.ccreate mode 100644tests/tcg/openrisc/test_lf_les.ccreate mode 100644tests/tcg/openrisc/test_lf_lts.ccreate mode 100644tests/tcg/openrisc/test_lf_mul.ccreate mode 100644tests/tcg/openrisc/test_lf_nes.ccreate mode 100644tests/tcg/openrisc/test_lf_rem.ccreate mode 100644tests/tcg/openrisc/test_lf_sub.ccreate mode 100644tests/tcg/openrisc/test_logic.ccreate mode 100644tests/tcg/openrisc/test_lx.ccreate mode 100644tests/tcg/openrisc/test_movhi.ccreate mode 100644tests/tcg/openrisc/test_mul.ccreate mode 100644tests/tcg/openrisc/test_muli.ccreate mode 100644tests/tcg/openrisc/test_mulu.ccreate mode 100644tests/tcg/openrisc/test_sfeq.ccreate mode 100644tests/tcg/openrisc/test_sfeqi.ccreate mode 100644tests/tcg/openrisc/test_sfges.ccreate mode 100644tests/tcg/openrisc/test_sfgesi.ccreate mode 100644tests/tcg/openrisc/test_sfgeu.ccreate mode 100644tests/tcg/openrisc/test_sfgeui.ccreate mode 100644tests/tcg/openrisc/test_sfgts.ccreate mode 100644tests/tcg/openrisc/test_sfgtsi.ccreate mode 100644tests/tcg/openrisc/test_sfgtu.ccreate mode 100644tests/tcg/openrisc/test_sfgtui.ccreate mode 100644tests/tcg/openrisc/test_sfles.ccreate mode 100644tests/tcg/openrisc/test_sflesi.ccreate mode 100644tests/tcg/openrisc/test_sfleu.ccreate mode 100644tests/tcg/openrisc/test_sfleui.ccreate mode 100644tests/tcg/openrisc/test_sflts.ccreate mode 100644tests/tcg/openrisc/test_sfltsi.ccreate mode 100644tests/tcg/openrisc/test_sfltu.ccreate mode 100644tests/tcg/openrisc/test_sfltui.ccreate mode 100644tests/tcg/openrisc/test_sfne.ccreate mode 100644tests/tcg/openrisc/test_sfnei.ccreate mode 100644tests/tcg/openrisc/test_sub.cQuoted 4 lines
Quoted 4 lines
--
1.7.9.5Regards,
Jia.
Quoted 9 lines · Blue Swirl
Quoted 5 lines · Jia Liu
ERROR: need consistent spacing around '*' (ctx:WxV) #99: FILE:
target-openrisc/int_helper.c:53:
+target_ulong HELPER(mul32)(CPUOpenRISCState *env,It is really weird. And, I don't know how to handle it.
It's a limitation in checkpatch.pl, it is confused by any CPUxxxState for some reason. Please just ignore these cases.
I think in this case it's more likely to be the HELPER() macro that is confusing it, but yes, just ignore the error.
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Blue Swirl
Quoted 4 lines · Jia Liu
ERROR: need consistent spacing around '*' (ctx:WxV) #99: FILE:
target-openrisc/int_helper.c:53:
+target_ulong HELPER(mul32)(CPUOpenRISCState *env,
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
It is really weird. And, I don't know how to handle it.
It's a limitation in checkpatch.pl, it is confused by any CPUxxxState for some reason. Please just ignore these cases.
I think in this case it's more likely to be the
HELPER()macro that is confusing it, but yes, just ignore the error.
Should this be added to http://wiki.qemu.org/Contribute/SubmitAPatch
as an example? I remember someone else had the same problem before.
Regards,
chenwj
Signature · 5 lines
Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj