* [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. @ 2015-06-30 5:02 Serge Vakulenko 2015-06-30 14:10 ` Leon Alrae 0 siblings, 1 reply; 8+ messages in thread From: Serge Vakulenko @ 2015-06-30 5:02 UTC (permalink / raw) To: qemu-devel; +Cc: Leon Alrae, Aurelien Jarno Signed-off-by: Serge Vakulenko <serge@vak.ru> --- target-mips/op_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 2a9ddff..1b7caeb 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -22,6 +22,7 @@ #include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "sysemu/kvm.h" +#include "sysemu/sysemu.h" #ifndef CONFIG_USER_ONLY static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) { CPUState *cs = CPU(mips_env_get_cpu(env)); +#ifndef CONFIG_USER_ONLY + if (!(env->CP0_Status & (1 << CP0St_IE))) { + /* WAIT instruction with interrupts disabled - halt the simulation. */ + qemu_system_shutdown_request(); + } +#endif cs->halted = 1; cpu_reset_interrupt(cs, CPU_INTERRUPT_WAKE); helper_raise_exception(env, EXCP_HLT); -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-06-30 5:02 [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled Serge Vakulenko @ 2015-06-30 14:10 ` Leon Alrae 2015-06-30 18:08 ` Peter Crosthwaite 0 siblings, 1 reply; 8+ messages in thread From: Leon Alrae @ 2015-06-30 14:10 UTC (permalink / raw) To: Serge Vakulenko, qemu-devel; +Cc: Aurelien Jarno Hi Serge, On 30/06/2015 06:02, Serge Vakulenko wrote: > Signed-off-by: Serge Vakulenko <serge@vak.ru> > --- > target-mips/op_helper.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c > index 2a9ddff..1b7caeb 100644 > --- a/target-mips/op_helper.c > +++ b/target-mips/op_helper.c > @@ -22,6 +22,7 @@ > #include "exec/helper-proto.h" > #include "exec/cpu_ldst.h" > #include "sysemu/kvm.h" > +#include "sysemu/sysemu.h" > > #ifndef CONFIG_USER_ONLY > static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); > @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) > { > CPUState *cs = CPU(mips_env_get_cpu(env)); > > +#ifndef CONFIG_USER_ONLY > + if (!(env->CP0_Status & (1 << CP0St_IE))) { > + /* WAIT instruction with interrupts disabled - halt the simulation. */ > + qemu_system_shutdown_request(); > + } > +#endif Why do you want to stop the simulation, wouldn't it be beneficial to leave it running? For debugging for example, the user would be still able to inspect the state, that could help to find a clue why CPU got suspended forever. Also, if we take into account implementations (currently not supported in QEMU) where CPU can be woken up by a disabled interrupt (the Config7.WII bit in P5600 for example), then this won't be correct. Thanks, Leon ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-06-30 14:10 ` Leon Alrae @ 2015-06-30 18:08 ` Peter Crosthwaite 2015-07-01 1:57 ` Serge Vakulenko 0 siblings, 1 reply; 8+ messages in thread From: Peter Crosthwaite @ 2015-06-30 18:08 UTC (permalink / raw) To: Leon Alrae Cc: Serge Vakulenko, Aurelien Jarno, qemu-devel@nongnu.org Developers On Tue, Jun 30, 2015 at 7:10 AM, Leon Alrae <leon.alrae@imgtec.com> wrote: > Hi Serge, > > On 30/06/2015 06:02, Serge Vakulenko wrote: >> Signed-off-by: Serge Vakulenko <serge@vak.ru> >> --- >> target-mips/op_helper.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c >> index 2a9ddff..1b7caeb 100644 >> --- a/target-mips/op_helper.c >> +++ b/target-mips/op_helper.c >> @@ -22,6 +22,7 @@ >> #include "exec/helper-proto.h" >> #include "exec/cpu_ldst.h" >> #include "sysemu/kvm.h" >> +#include "sysemu/sysemu.h" >> >> #ifndef CONFIG_USER_ONLY >> static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); >> @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) >> { >> CPUState *cs = CPU(mips_env_get_cpu(env)); >> >> +#ifndef CONFIG_USER_ONLY >> + if (!(env->CP0_Status & (1 << CP0St_IE))) { >> + /* WAIT instruction with interrupts disabled - halt the simulation. */ >> + qemu_system_shutdown_request(); >> + } >> +#endif > > Why do you want to stop the simulation, wouldn't it be beneficial to leave it > running? For debugging for example, the user would be still able to inspect > the state, that could help to find a clue why CPU got suspended forever. > In theory, there may also be other actors in the system. Even if the CPU is in a never-going-to-come-back-to-life state, other-things may still be happening. This would be best as some sort of core feature to detect total-inaction of the system. That is, there are no delayed events pending (timed events and AIOs) and the CPUs are halted. Then this would be a user option to stop the system on reaching the machine-inactive state and it would be applicable beyond mips. Regards, Peter > Also, if we take into account implementations (currently not supported in > QEMU) where CPU can be woken up by a disabled interrupt (the Config7.WII bit > in P5600 for example), then this won't be correct. > > Thanks, > Leon > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-06-30 18:08 ` Peter Crosthwaite @ 2015-07-01 1:57 ` Serge Vakulenko 2015-07-01 2:21 ` Peter Crosthwaite 2015-07-09 16:29 ` Christopher Covington 0 siblings, 2 replies; 8+ messages in thread From: Serge Vakulenko @ 2015-07-01 1:57 UTC (permalink / raw) To: Peter Crosthwaite Cc: Leon Alrae, qemu-devel@nongnu.org Developers, Aurelien Jarno Hi Peter and Leon, With a bit of thinking, I agree, that the question of session termination on WAIT instruction is quite complicated in case of multi-core system, background i/o activity, mipsR6 core etc. So I'm going to find another solution for the task. What I essentially want here is to stop the simulator when the target Unix system is halted, like: $ /usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mx7-max32 -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel unix.hex -sd sdcard.img Board: chipKIT Max32 Processor: M4K RAM size: 128 kbytes Load file: 'boot-max32.hex', 6720 bytes Load file: 'unix.hex', 144992 bytes Card0 image 'sdcard.img', 102888 kbytes [...] 2.11 BSD UNIX (pic32) (console) login: root Password: Welcome to RetroBSD! erase, kill ^U, intr ^C # halt killing processes... done syncing disks... done halted $ _ <-- QEMU terminated On BSD, the halt command uses reboot(RB_HALT) system call to terminate the operating system. It essentially results in an endless loop on wait instruction with interrupts disabled., like "for(;;) { asm("wait"); }". For pic32 it makes little sense to continue simulation in this case. Fortunately, I've found a solution which does not require modification of generic code. Everything can be done in the platform-specific part. Thanks, --Serge 2015-06-30 11:08 GMT-07:00 Peter Crosthwaite <peter.crosthwaite@xilinx.com>: > On Tue, Jun 30, 2015 at 7:10 AM, Leon Alrae <leon.alrae@imgtec.com> wrote: >> Hi Serge, >> >> On 30/06/2015 06:02, Serge Vakulenko wrote: >>> Signed-off-by: Serge Vakulenko <serge@vak.ru> >>> --- >>> target-mips/op_helper.c | 7 +++++++ >>> 1 file changed, 7 insertions(+) >>> >>> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c >>> index 2a9ddff..1b7caeb 100644 >>> --- a/target-mips/op_helper.c >>> +++ b/target-mips/op_helper.c >>> @@ -22,6 +22,7 @@ >>> #include "exec/helper-proto.h" >>> #include "exec/cpu_ldst.h" >>> #include "sysemu/kvm.h" >>> +#include "sysemu/sysemu.h" >>> >>> #ifndef CONFIG_USER_ONLY >>> static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); >>> @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) >>> { >>> CPUState *cs = CPU(mips_env_get_cpu(env)); >>> >>> +#ifndef CONFIG_USER_ONLY >>> + if (!(env->CP0_Status & (1 << CP0St_IE))) { >>> + /* WAIT instruction with interrupts disabled - halt the simulation. */ >>> + qemu_system_shutdown_request(); >>> + } >>> +#endif >> >> Why do you want to stop the simulation, wouldn't it be beneficial to leave it >> running? For debugging for example, the user would be still able to inspect >> the state, that could help to find a clue why CPU got suspended forever. >> > > In theory, there may also be other actors in the system. Even if the > CPU is in a never-going-to-come-back-to-life state, other-things may > still be happening. This would be best as some sort of core feature to > detect total-inaction of the system. That is, there are no delayed > events pending (timed events and AIOs) and the CPUs are halted. Then > this would be a user option to stop the system on reaching the > machine-inactive state and it would be applicable beyond mips. > > Regards, > Peter > >> Also, if we take into account implementations (currently not supported in >> QEMU) where CPU can be woken up by a disabled interrupt (the Config7.WII bit >> in P5600 for example), then this won't be correct. >> >> Thanks, >> Leon >> >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-07-01 1:57 ` Serge Vakulenko @ 2015-07-01 2:21 ` Peter Crosthwaite 2015-07-01 20:30 ` Serge Vakulenko 2015-07-09 16:29 ` Christopher Covington 1 sibling, 1 reply; 8+ messages in thread From: Peter Crosthwaite @ 2015-07-01 2:21 UTC (permalink / raw) To: Serge Vakulenko Cc: Leon Alrae, qemu-devel@nongnu.org Developers, Aurelien Jarno On Tue, Jun 30, 2015 at 6:57 PM, Serge Vakulenko <serge@vak.ru> wrote: > Hi Peter and Leon, > > With a bit of thinking, I agree, that the question of session > termination on WAIT instruction is quite complicated in case of > multi-core system, background i/o activity, mipsR6 core etc. So I'm > going to find another solution for the task. What I essentially want > here is to stop the simulator when the target Unix system is halted, > like: > > $ /usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mx7-max32 > -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel > unix.hex -sd sdcard.img > Board: chipKIT Max32 > Processor: M4K > RAM size: 128 kbytes > Load file: 'boot-max32.hex', 6720 bytes > Load file: 'unix.hex', 144992 bytes > Card0 image 'sdcard.img', 102888 kbytes > [...] > 2.11 BSD UNIX (pic32) (console) > > login: root > Password: > Welcome to RetroBSD! > erase, kill ^U, intr ^C > # halt > killing processes... done > syncing disks... done > halted > $ _ <-- QEMU terminated > > On BSD, the halt command uses reboot(RB_HALT) system call to terminate > the operating system. It essentially results in an endless loop on > wait instruction with interrupts disabled., like "for(;;) { > asm("wait"); }". For pic32 it makes little sense to continue > simulation in this case. > What about releasing the hung state from a debugger? I think this auto-exit behavior should be optional and not a default. > Fortunately, I've found a solution which does not require modification > of generic code. Everything can be done in the platform-specific part. > But I think your desire is for a generic feature - stopping emulation on a hung state. Regards, Peter > Thanks, > --Serge > > > 2015-06-30 11:08 GMT-07:00 Peter Crosthwaite <peter.crosthwaite@xilinx.com>: >> On Tue, Jun 30, 2015 at 7:10 AM, Leon Alrae <leon.alrae@imgtec.com> wrote: >>> Hi Serge, >>> >>> On 30/06/2015 06:02, Serge Vakulenko wrote: >>>> Signed-off-by: Serge Vakulenko <serge@vak.ru> >>>> --- >>>> target-mips/op_helper.c | 7 +++++++ >>>> 1 file changed, 7 insertions(+) >>>> >>>> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c >>>> index 2a9ddff..1b7caeb 100644 >>>> --- a/target-mips/op_helper.c >>>> +++ b/target-mips/op_helper.c >>>> @@ -22,6 +22,7 @@ >>>> #include "exec/helper-proto.h" >>>> #include "exec/cpu_ldst.h" >>>> #include "sysemu/kvm.h" >>>> +#include "sysemu/sysemu.h" >>>> >>>> #ifndef CONFIG_USER_ONLY >>>> static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); >>>> @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) >>>> { >>>> CPUState *cs = CPU(mips_env_get_cpu(env)); >>>> >>>> +#ifndef CONFIG_USER_ONLY >>>> + if (!(env->CP0_Status & (1 << CP0St_IE))) { >>>> + /* WAIT instruction with interrupts disabled - halt the simulation. */ >>>> + qemu_system_shutdown_request(); >>>> + } >>>> +#endif >>> >>> Why do you want to stop the simulation, wouldn't it be beneficial to leave it >>> running? For debugging for example, the user would be still able to inspect >>> the state, that could help to find a clue why CPU got suspended forever. >>> >> >> In theory, there may also be other actors in the system. Even if the >> CPU is in a never-going-to-come-back-to-life state, other-things may >> still be happening. This would be best as some sort of core feature to >> detect total-inaction of the system. That is, there are no delayed >> events pending (timed events and AIOs) and the CPUs are halted. Then >> this would be a user option to stop the system on reaching the >> machine-inactive state and it would be applicable beyond mips. >> >> Regards, >> Peter >> >>> Also, if we take into account implementations (currently not supported in >>> QEMU) where CPU can be woken up by a disabled interrupt (the Config7.WII bit >>> in P5600 for example), then this won't be correct. >>> >>> Thanks, >>> Leon >>> >>> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-07-01 2:21 ` Peter Crosthwaite @ 2015-07-01 20:30 ` Serge Vakulenko 0 siblings, 0 replies; 8+ messages in thread From: Serge Vakulenko @ 2015-07-01 20:30 UTC (permalink / raw) To: Peter Crosthwaite Cc: Leon Alrae, qemu-devel@nongnu.org Developers, Aurelien Jarno Hi Peter, 2015-06-30 19:21 GMT-07:00 Peter Crosthwaite <peter.crosthwaite@xilinx.com>: > On Tue, Jun 30, 2015 at 6:57 PM, Serge Vakulenko <serge@vak.ru> wrote: >> Hi Peter and Leon, >> >> With a bit of thinking, I agree, that the question of session >> termination on WAIT instruction is quite complicated in case of >> multi-core system, background i/o activity, mipsR6 core etc. So I'm >> going to find another solution for the task. What I essentially want >> here is to stop the simulator when the target Unix system is halted, >> like: >> >> $ /usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mx7-max32 >> -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel >> unix.hex -sd sdcard.img >> Board: chipKIT Max32 >> Processor: M4K >> RAM size: 128 kbytes >> Load file: 'boot-max32.hex', 6720 bytes >> Load file: 'unix.hex', 144992 bytes >> Card0 image 'sdcard.img', 102888 kbytes >> [...] >> 2.11 BSD UNIX (pic32) (console) >> >> login: root >> Password: >> Welcome to RetroBSD! >> erase, kill ^U, intr ^C >> # halt >> killing processes... done >> syncing disks... done >> halted >> $ _ <-- QEMU terminated >> >> On BSD, the halt command uses reboot(RB_HALT) system call to terminate >> the operating system. It essentially results in an endless loop on >> wait instruction with interrupts disabled., like "for(;;) { >> asm("wait"); }". For pic32 it makes little sense to continue >> simulation in this case. >> > > What about releasing the hung state from a debugger? I think this > auto-exit behavior should be optional and not a default. It's definitely possible from a debugger, I agree. But for simple sessions like above with monitor disabled and no debugger attached, It would still be nice to terminate simulation cleanly end easily. >> Fortunately, I've found a solution which does not require modification >> of generic code. Everything can be done in the platform-specific part. >> > > But I think your desire is for a generic feature - stopping emulation > on a hung state. Seems like it's a non-trivial task to properly detect hung state in a generic case. Though it's easy for simple single-core microcontroller systems. In v2 patch set I've modified the code to use cc->cpu_exec_exit() callback to terminate the session. Like this: /* * This function is called when the processor is stopped * on WAIT instruction, waiting for external interrupt. */ static void pic32_exec_exit(CPUState *cs) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; if (cs->halted && !(env->CP0_Status & (1 << CP0St_IE))) { /* WAIT instruction with interrupts disabled - halt the simulation. */ qemu_system_shutdown_request(); } } Best wishes, --Serge > Regards, > Peter > >> Thanks, >> --Serge >> >> >> 2015-06-30 11:08 GMT-07:00 Peter Crosthwaite <peter.crosthwaite@xilinx.com>: >>> On Tue, Jun 30, 2015 at 7:10 AM, Leon Alrae <leon.alrae@imgtec.com> wrote: >>>> Hi Serge, >>>> >>>> On 30/06/2015 06:02, Serge Vakulenko wrote: >>>>> Signed-off-by: Serge Vakulenko <serge@vak.ru> >>>>> --- >>>>> target-mips/op_helper.c | 7 +++++++ >>>>> 1 file changed, 7 insertions(+) >>>>> >>>>> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c >>>>> index 2a9ddff..1b7caeb 100644 >>>>> --- a/target-mips/op_helper.c >>>>> +++ b/target-mips/op_helper.c >>>>> @@ -22,6 +22,7 @@ >>>>> #include "exec/helper-proto.h" >>>>> #include "exec/cpu_ldst.h" >>>>> #include "sysemu/kvm.h" >>>>> +#include "sysemu/sysemu.h" >>>>> >>>>> #ifndef CONFIG_USER_ONLY >>>>> static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global); >>>>> @@ -2235,6 +2236,12 @@ void helper_wait(CPUMIPSState *env) >>>>> { >>>>> CPUState *cs = CPU(mips_env_get_cpu(env)); >>>>> >>>>> +#ifndef CONFIG_USER_ONLY >>>>> + if (!(env->CP0_Status & (1 << CP0St_IE))) { >>>>> + /* WAIT instruction with interrupts disabled - halt the simulation. */ >>>>> + qemu_system_shutdown_request(); >>>>> + } >>>>> +#endif >>>> >>>> Why do you want to stop the simulation, wouldn't it be beneficial to leave it >>>> running? For debugging for example, the user would be still able to inspect >>>> the state, that could help to find a clue why CPU got suspended forever. >>>> >>> >>> In theory, there may also be other actors in the system. Even if the >>> CPU is in a never-going-to-come-back-to-life state, other-things may >>> still be happening. This would be best as some sort of core feature to >>> detect total-inaction of the system. That is, there are no delayed >>> events pending (timed events and AIOs) and the CPUs are halted. Then >>> this would be a user option to stop the system on reaching the >>> machine-inactive state and it would be applicable beyond mips. >>> >>> Regards, >>> Peter >>> >>>> Also, if we take into account implementations (currently not supported in >>>> QEMU) where CPU can be woken up by a disabled interrupt (the Config7.WII bit >>>> in P5600 for example), then this won't be correct. >>>> >>>> Thanks, >>>> Leon >>>> >>>> >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-07-01 1:57 ` Serge Vakulenko 2015-07-01 2:21 ` Peter Crosthwaite @ 2015-07-09 16:29 ` Christopher Covington 2015-07-11 5:35 ` Serge Vakulenko 1 sibling, 1 reply; 8+ messages in thread From: Christopher Covington @ 2015-07-09 16:29 UTC (permalink / raw) To: Serge Vakulenko, Peter Crosthwaite Cc: Leon Alrae, qemu-devel@nongnu.org Developers, Aurelien Jarno On 06/30/2015 09:57 PM, Serge Vakulenko wrote: > Hi Peter and Leon, > > With a bit of thinking, I agree, that the question of session > termination on WAIT instruction is quite complicated in case of > multi-core system, background i/o activity, mipsR6 core etc. So I'm > going to find another solution for the task. What I essentially want > here is to stop the simulator when the target Unix system is halted, > like: > > $ /usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mx7-max32 > -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel > unix.hex -sd sdcard.img > Board: chipKIT Max32 > Processor: M4K > RAM size: 128 kbytes > Load file: 'boot-max32.hex', 6720 bytes > Load file: 'unix.hex', 144992 bytes > Card0 image 'sdcard.img', 102888 kbytes > [...] > 2.11 BSD UNIX (pic32) (console) > > login: root > Password: > Welcome to RetroBSD! > erase, kill ^U, intr ^C > # halt > killing processes... done > syncing disks... done > halted > $ _ <-- QEMU terminated > > On BSD, the halt command uses reboot(RB_HALT) system call to terminate > the operating system. It essentially results in an endless loop on > wait instruction with interrupts disabled., like "for(;;) { > asm("wait"); }". For pic32 it makes little sense to continue > simulation in this case. > > Fortunately, I've found a solution which does not require modification > of generic code. Everything can be done in the platform-specific part. Why doesn't the OS do more than busy-loop in halt()? For example poke a memory-mapped register, or make a firmware or semihosting call? Chris -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled. 2015-07-09 16:29 ` Christopher Covington @ 2015-07-11 5:35 ` Serge Vakulenko 0 siblings, 0 replies; 8+ messages in thread From: Serge Vakulenko @ 2015-07-11 5:35 UTC (permalink / raw) To: Christopher Covington Cc: Peter Crosthwaite, Leon Alrae, qemu-devel@nongnu.org Developers, Aurelien Jarno 2015-07-09 9:29 GMT-07:00 Christopher Covington <cov@codeaurora.org>: > On 06/30/2015 09:57 PM, Serge Vakulenko wrote: >> >> $ /usr/local/qemu-mips/bin/qemu-system-mipsel -M pic32mx7-max32 >> -nographic -monitor none -serial stdio -bios boot-max32.hex -kernel >> unix.hex -sd sdcard.img >> Board: chipKIT Max32 >> Processor: M4K >> RAM size: 128 kbytes >> Load file: 'boot-max32.hex', 6720 bytes >> Load file: 'unix.hex', 144992 bytes >> Card0 image 'sdcard.img', 102888 kbytes >> [...] >> 2.11 BSD UNIX (pic32) (console) >> >> login: root >> Password: >> Welcome to RetroBSD! >> erase, kill ^U, intr ^C >> # halt >> killing processes... done >> syncing disks... done >> halted >> $ _ <-- QEMU terminated >> >> On BSD, the halt command uses reboot(RB_HALT) system call to terminate >> the operating system. It essentially results in an endless loop on >> wait instruction with interrupts disabled., like "for(;;) { >> asm("wait"); }". For pic32 it makes little sense to continue >> simulation in this case. >> >> Fortunately, I've found a solution which does not require modification >> of generic code. Everything can be done in the platform-specific part. > > Why doesn't the OS do more than busy-loop in halt()? For example poke a > memory-mapped register, or make a firmware or semihosting call? Typically, halt instruction, i.e. reboot(RB_HALT) system call is used by administrator to stop the device before shutting the power off. All the activity is stopped before the busy-loop. It makes little sense to do anything but wait in a loop. There is no firmware to call on pic32 microcontroller. No semihosting is assumed: this is a final kernel binary, intended to be programmed into the flash memory of a microcontroller. Regards, --Serge > Chris > > -- > Qualcomm Innovation Center, Inc. > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-07-11 5:35 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-06-30 5:02 [Qemu-devel] [PATCH pic32 2/7] Stop simulation when processor is suspended forever by WAIT instruction with interrupts disabled Serge Vakulenko 2015-06-30 14:10 ` Leon Alrae 2015-06-30 18:08 ` Peter Crosthwaite 2015-07-01 1:57 ` Serge Vakulenko 2015-07-01 2:21 ` Peter Crosthwaite 2015-07-01 20:30 ` Serge Vakulenko 2015-07-09 16:29 ` Christopher Covington 2015-07-11 5:35 ` Serge Vakulenko
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.