Peter,

I ended up using the first technique for VersatilePB and works just fine.

Now I want to be able "power off" a qemu-system-i386 and I was wondering
what you might suggest? I'm hoping there might be something "easy".

-- Wink

On Mon, Oct 19, 2015 at 1:49 PM Wink Saville <w...@saville.com> wrote:

> THANKS, I'll give those things a try!
>
> On Mon, Oct 19, 2015, 1:46 PM Peter Maydell <peter.mayd...@linaro.org>
> wrote:
>
>> On 19 October 2015 at 20:30, Wink Saville <w...@saville.com> wrote:
>> > I would like to use qemu in a test environment where I give a "kernel"
>> image
>> > to qmeu have it execute it and then when complete have qemu exit.
>> Currently
>> > when
>> > executing:
>> >
>> >   $ qemu-system-arm -M versatilepb -m 128M -nographic -kernel test.bin
>> >   ...
>> >   Hi
>> >   $
>> >
>> > After test.bin prints "Hi" via the "Uart in VersatilePB" I have to
>> > interactively press ctrl-a then press 'x' to have it return to the
>> command
>> > prompt. Is there a way for test.bin to cause qemu to exit without
>> having to
>> > type commands in the terminal.
>>
>> That depends on the machine you're using (in this case versatilepb).
>> Basically if the guest binary tells the emulated hardware "please
>> power down" via whatever that hardware's mechanism is, then QEMU
>> will exit. For versatilepb there isn't any way to do that, but you
>> can use QEMU's "-no-reboot" option (which turns resets into power
>> downs) and then tell the emulated hardware to do a reset. For info
>> on how to do a reset on the versatilepb board see the h/w docs:
>> http://infocenter.arm.com/help/topic/com.arm.doc.dui0224i/Caccifgi.html
>> You need to write to SYS_LOCKCTL to unlock the register and then
>> to SYS_RESETCTL to actually request the reset.
>>
>> Other options you can use:
>>  * an ARM-specific option is to use the -semihosting command line
>> option, and then you can use the semihosting ABI to exit.
>> You need to do an angel_SWIreason_ReportException:
>>
>> http://infocenter.arm.com/help/topic/com.arm.doc.dui0471l/pge1358787050566.html
>> (which is to say, set r0 to 0x18, r1 to 0x20026 and do a
>> swi 0x123456 in ARM mode or swi 0xab (Thumb mode) or
>> bkpt 0xab (M profile).
>> Semihosting also lets you conveniently output to the terminal,
>> read files or look at the command line, so it's handy for
>> writing test cases.
>>
>>  * use the 'expect' utility to script up the "make QEMU exit
>> when it's printed the result" handling. It's generally nicer
>> to avoid this, but as a last resort it's nice to have: a
>> handful of lines of expect scripting are sufficient to do
>> basic "start this program, then exit when some string appears
>> in its output" control.
>>
>> PS: you might prefer '-display none' over '-nographic';
>> that gives you the serial output to standard output, but
>> doesn't do the 'monitor on alternate screen, ctrl-a <whatever>'
>> behaviour. You can just ctrl-c to exit qemu then.
>> Basically -nographic is a magic combination of a bunch
>> of options and sometimes you only want one of them.
>>
>> thanks
>> -- PMM
>>
>

Reply via email to