Nios II generic board config and semihosting
v7 cover Nios II generic board config and semihosting
This is the seventh version of the patch series last posted here:
http://lists.nongnu.org/archive/html/qemu-devel/2019-03/msg06255.html
Changes since v6:
- Fixed block comment formatting for QEMU style.
- Fixed fixme for interrupt handler (now added to libgloss BSP).
- Added link to libgloss semihosting documentation.
Sandra Loosemore (2):
Add generic Nios II board.
Add Nios II semihosting support.
default-configs/nios2-softmmu.mak | 1 + hw/nios2/Kconfig | 4 + hw/nios2/Makefile.objs | 1 + hw/nios2/boot.c | 18 +- hw/nios2/generic_nommu.c | 105 +++++++++ qemu-options.hx | 8 +- target/nios2/Makefile.objs | 2 +- target/nios2/cpu.h | 4 +- target/nios2/helper.c | 13 ++ target/nios2/nios2-semi.c | 455 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 599 insertions(+), 12 deletions(-) create mode 100644 hw/nios2/generic_nommu.c create mode 100644 target/nios2/nios2-semi.c
Signature · 1 line
2.8.1
PATCH v7 1/2 Add generic Nios II board.
This patch adds support for a generic MMU-less Nios II board that can be used e.g. for bare-metal compiler testing with the linker script and startup code provided by libgloss. Nios II booting is also tweaked so that bare-metal binaries start executing in RAM starting at 0x00000000, rather than an alias at 0xc0000000, which allows features such as unwinding to work when binaries are linked to start at the beginning of the address space.
The generic_nommu.c parts are based on code by Andrew Jenner, which was in turn based on code by Marek Vasut.
Originally by Marek Vasut and Andrew Jenner.
--- default-configs/nios2-softmmu.mak | 1 + hw/nios2/Kconfig | 4 ++ hw/nios2/Makefile.objs | 1 + hw/nios2/boot.c | 18 ++++--- hw/nios2/generic_nommu.c | 105 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 hw/nios2/generic_nommu.c
default-configs/nios2-softmmu.mak +1 -0
@@ -3,3 +3,4 @@ # Boards: # CONFIG_NIOS2_10M50=y +CONFIG_NIOS2_GENERIC_NOMMU=y
hw/nios2/Kconfig +4 -0
@@ -4,5 +4,9 @@ config NIOS2_10M50 select SERIAL select ALTERA_TIMER +config NIOS2_GENERIC_NOMMU + bool + select NIOS2 + config NIOS2 bool
hw/nios2/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ obj-y = boot.o cpu_pic.o obj-$(CONFIG_NIOS2_10M50) += 10m50_devboard.o +obj-$(CONFIG_NIOS2_GENERIC_NOMMU) += generic_nommu.o
hw/nios2/boot.c +12 -6
@@ -138,7 +138,6 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,if (kernel_filename) {int kernel_size, fdt_size;uint64_t entry, low, high; -uint32_t base32;int big_endian =0 ;#ifdef TARGET_WORDS_BIGENDIAN
@@ -149,17 +148,24 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base, kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , &entry, &low, &high, big_endian,EM_ALTERA_NIOS2 ,0 ,0 ); - base32 = entry; -if (base32 ==0xc0000000 ) { +if ((uint32_t )entry ==0xc0000000 ) { +/* +* The Nios II processor reference guide documents that the +* kernel is placed at virtual memory address 0xc0000000, +* and we've got something that points there. Reload it +* and adjust the entry to get the address in physical RAM. +*/ kernel_size =load_elf (kernel_filename,NULL , translate_kernel_address,NULL , &entry,NULL ,NULL , big_endian,EM_ALTERA_NIOS2 ,0 ,0 ); + boot_info.bootstrap_pc = ddr_base +0xc0000000 + + (entry &0x07ffffff ); + }else { +/* Use the entry point in the ELF image. */ + boot_info.bootstrap_pc = (uint32_t )entry; } -/* Always boot into physical ram. */ - boot_info.bootstrap_pc = ddr_base +0xc0000000 + (entry &0x07ffffff ); -/* If it wasn't an ELF image, try an u-boot image. */ if (kernel_size <0 ) {hwaddr uentry, loadaddr =LOAD_UIMAGE_LOADADDR_INVALID ;
hw/nios2/generic_nommu.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.8.1
Re: [Qemu-devel] [PATCH v7 1/2] Add generic Nios II board.
Quoted 12 lines · Sandra Loosemore
This patch adds support for a generic MMU-less Nios II board that can be used e.g. for bare-metal compiler testing with the linker script and startup code provided by libgloss. Nios II booting is also tweaked so that bare-metal binaries start executing in RAM starting at
0x00000000, rather than an alias at0xc0000000, which allows features such as unwinding to work when binaries are linked to start at the beginning of the address space.The
generic_nommu.cparts are based on code by Andrew Jenner, which was in turn based on code by Marek Vasut.
Quoted 7 lines
Originally by Marek Vasut and Andrew Jenner.
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>Signed-off-by Andrew Jenner <[email protected]>Signed-off-by Marek Vasut <[email protected]>---
thanks
-- PMM
PATCH v7 2/2 Add Nios II semihosting support.
In reply to Sandra LoosemoreThis patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
--- qemu-options.hx | 8 +- target/nios2/Makefile.objs | 2 +- target/nios2/cpu.h | 4 +- target/nios2/helper.c | 13 ++ target/nios2/nios2-semi.c | 455 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 476 insertions(+), 6 deletions(-) create mode 100644 target/nios2/nios2-semi.c
qemu-options.hx +4 -4
@@ -3968,21 +3968,21 @@ ETEXI DEF("semihosting", 0, QEMU_OPTION_semihosting, "-semihosting semihosting mode\n", QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 | - QEMU_ARCH_MIPS) + QEMU_ARCH_MIPS | QEMU_ARCH_NIOS2) STEXI @item -semihosting @findex -semihosting -Enable semihosting mode (ARM, M68K, Xtensa, MIPS only). +Enable semihosting mode (ARM, M68K, Xtensa, MIPS, Nios II only). ETEXI DEF("semihosting-config", HAS_ARG, QEMU_OPTION_semihosting_config, "-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]\n" \ " semihosting configuration\n", QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 | -QEMU_ARCH_MIPS) +QEMU_ARCH_MIPS | QEMU_ARCH_NIOS2) STEXI @item -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]] @findex -semihosting-config -Enable and configure semihosting (ARM, M68K, Xtensa, MIPS only). +Enable and configure semihosting (ARM, M68K, Xtensa, MIPS, Nios II only). @table @option @item target=@code{native|gdb|auto} Defines where the semihosting calls will be addressed, to QEMU (@code{native})
target/nios2/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -obj-y += translate.o op_helper.o helper.o cpu.o mmu.o +obj-y += translate.o op_helper.o helper.o cpu.o mmu.o nios2-semi.o obj-$(CONFIG_SOFTMMU) += monitor.o $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
target/nios2/cpu.h +3 -1
@@ -141,7 +141,7 @@ typedef struct Nios2CPUClass {#define R_PC 64/* Exceptions */ -#define EXCP_BREAK -1 +#define EXCP_BREAK 0x1000#define EXCP_RESET 0#define EXCP_PRESET 1#define EXCP_IRQ 2
@@ -223,6 +223,8 @@ void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,qemu_irq *nios2_cpu_pic_init (Nios2CPU *cpu);void nios2_check_interrupts (CPUNios2State *env); +void do_nios2_semihosting (CPUNios2State *env); +#define TARGET_PHYS_ADDR_SPACE_BITS 32#ifdef CONFIG_USER_ONLY # define TARGET_VIRT_ADDR_SPACE_BITS 31
target/nios2/helper.c +13 -0
@@ -23,8 +23,10 @@#include "cpu.h" #include "qemu/host-utils.h" #include "exec/exec-all.h" +#include "exec/cpu_ldst.h" #include "exec/log.h" #include "exec/helper-proto.h" +#include "exec/semihost.h" #if defined(CONFIG_USER_ONLY )
@@ -169,6 +171,17 @@ void nios2_cpu_do_interrupt(CPUState *cs)break ;case EXCP_BREAK : +qemu_log_mask (CPU_LOG_INT ,"BREAK exception at pc=%x\n" , + env->regs[R_PC ]); +/* The semihosting instruction is "break 1". */ +if (semihosting_enabled () && +cpu_ldl_code (env, env->regs[R_PC ]) ==0x003da07a ) { +qemu_log_mask (CPU_LOG_INT ,"Entering semihosting\n" ); + env->regs[R_PC ] +=4 ; +do_nios2_semihosting (env); +break ; + } +if ((env->regs[CR_STATUS ] &CR_STATUS_EH ) ==0 ) { env->regs[CR_BSTATUS ] = env->regs[CR_STATUS ]; env->regs[R_BA ] = env->regs[R_PC ] +4 ;
target/nios2/nios2-semi.c new file +455 -0
455 lines not on this page · raw message
Signature · 1 line
2.8.1
Re: [Qemu-devel] [PATCH v7 2/2] Add Nios II semihosting support.
Quoted 7 lines · Sandra Loosemore
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>
I gave a reviewed-by tag for this patch in v6 -- has something changed in v7 that made that no longer able to carry across?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v7 2/2] Add Nios II semihosting support.
Quoted 11 lines · Peter Maydell
Quoted 7 lines · Sandra Loosemore
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>I gave a reviewed-by tag for this patch in v6 -- has something changed in v7 that made that no longer able to carry across?
I fixed the formatting problems you asked me to address. What else am I supposed to do? I don't understand what you mean about the tag.
-Sandra
Re: [Qemu-devel] [PATCH v7 2/2] Add Nios II semihosting support.
Quoted 8 lines · Sandra Loosemore
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Sandra Loosemore
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>I gave a reviewed-by tag for this patch in v6 -- has something changed in v7 that made that no longer able to carry across?
I fixed the formatting problems you asked me to address. What else am I supposed to do? I don't understand what you mean about the tag.
If somebody provides you with a Reviewed-by tag and you submit a fresh version of the patchset then you should include that tag in your commit message; that records that the patch has been reviewed so that people know it doesn't need to be looked at again.
https://wiki.qemu.org/Contribute/SubmitAPatch#Proper_use_of_Reviewed-by:_tags_can_aid_review
thanks
-- PMM
Re: [Qemu-devel] [PATCH v7 2/2] Add Nios II semihosting support.
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Sandra Loosemore
Quoted 11 lines · Peter Maydell
Quoted 7 lines · Sandra Loosemore
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>I gave a reviewed-by tag for this patch in v6 -- has something changed in v7 that made that no longer able to carry across?
Quoted 8 lines
Quoted 2 lines
I fixed the formatting problems you asked me to address. What else am I supposed to do? I don't understand what you mean about the tag.
If somebody provides you with a Reviewed-by tag and you submit a fresh version of the patchset then you should include that tag in your commit message; that records that the patch has been reviewed so that people know it doesn't need to be looked at again.
https://wiki.qemu.org/Contribute/SubmitAPatch#Proper_use_of_Reviewed-by:_tags_can_aid_review
Hmmm, OK; I missed that. So do I need to resubmit the patches just to add that tag?
-Sandra
Peter Maydell
Reviewed-byRe: [Qemu-devel] [PATCH v7 2/2] Add Nios II semihosting support.
Quoted 20 lines · Sandra Loosemore
Quoted 18 lines · Peter Maydell
Quoted 16 lines · Sandra Loosemore
Quoted 11 lines · Peter Maydell
Quoted 7 lines · Sandra Loosemore
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources.
Signed-off-by Sandra Loosemore <[email protected]>Signed-off-by Julian Brown <[email protected]>I gave a reviewed-by tag for this patch in v6 -- has something changed in v7 that made that no longer able to carry across?
I fixed the formatting problems you asked me to address. What else am I supposed to do? I don't understand what you mean about the tag.
Quoted 8 lines
Quoted 5 lines
If somebody provides you with a Reviewed-by tag and you submit a fresh version of the patchset then you should include that tag in your commit message; that records that the patch has been reviewed so that people know it doesn't need to be looked at again.
https://wiki.qemu.org/Contribute/SubmitAPatch#Proper_use_of_Reviewed-by:_tags_can_aid_reviewHmmm, OK; I missed that. So do I need to resubmit the patches just to add that tag?
No, not at this point. I'll just add one here:
which should cause the automated tooling to pick it up when it gets applied to somebody's tree for a pullreq.
thanks
-- PMM
Quoted 4 lines · Sandra Loosemore
This is the seventh version of the patch series last posted here:
http://lists.nongnu.org/archive/html/qemu-devel/2019-03/msg06255.html
Quoted 8 lines
Changes since v6:
- Fixed block comment formatting for QEMU style.
- Fixed fixme for interrupt handler (now added to libgloss BSP).
- Added link to libgloss semihosting documentation.Sandra Loosemore (2):
Add generic Nios II board.
Add Nios II semihosting support.
Since Nios II doesn't have anybody actively handling pull requests for it right now, I've applied these patches directly to master -- thanks!
-- PMM
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Sandra Loosemore
This is the seventh version of the patch series last posted here:
http://lists.nongnu.org/archive/html/qemu-devel/2019-03/msg06255.htmlChanges since v6:
- Fixed block comment formatting for QEMU style.
- Fixed fixme for interrupt handler (now added to libgloss BSP).
- Added link to libgloss semihosting documentation.
Quoted 7 lines
Quoted 3 lines
Sandra Loosemore (2):
Add generic Nios II board.
Add Nios II semihosting support.Since Nios II doesn't have anybody actively handling pull requests for it right now, I've applied these patches directly to master -- thanks!
Thank you for taking care of this!
-Sandra