Qemu atags passing in register.

2012-02-06 Thread d...@ucore.info
Hi,

I'm doing some tricks with Linux kernel and I'm dependent on
bootloader atags passing.

On PandaBoard the u-boot is always passing DTF/Atags pointer in r2
register, and I'm kind of depending on it. I need to emulate this
behavior by -initrd qemu's argument. However it seems that
qemu-system-arm zeros the registers on the start, and places atags in
some hardcoded memory address no matter what.

Is this behaviour really OK? Isn't r2 register a proper way to pass
atags on ARM platform? If so, would you merge into mainline a patch
that implement this? I could write it, but I don't want end-users of
my work to have to patch and compile Qemu manually.

Please CC me, I'm not following actively these mailinglists.

Regards,
-- 
Dawid Ciężarkiewicz

___
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain


Re: Qemu atags passing in register.

2012-02-06 Thread d...@ucore.info
On Mon, Feb 6, 2012 at 5:35 PM, Peter Maydell  wrote:
> No, qemu will correctly pass the atags in r2 if it is booting a linux
> kernel (ie if you pass it a non ELF file via the -kernel argument).
> Otherwise we wouldn't be able to boot Linux.
> How are you starting qemu ?

Well it's a bit complex:

sudo "$QEMU" -daemonize -no-quit -pidfile "$PIDFILE" $* \
-serial telnet:localhost:${SERIAL_PORT_BASE},server,nowait,ipv4 
\
-serial telnet:localhost:$(($SERIAL_PORT_BASE + 
1)),server,nowait,ipv4 \
-serial telnet:localhost:$(($SERIAL_PORT_BASE + 
2)),server,nowait,ipv4 \
-serial telnet:localhost:$(($SERIAL_PORT_BASE + 
3)),server,nowait,ipv4 \
$QEMU_LOCAL_ARCH_ARGS \
-net nic -net
tap,script="$ROOT/tools/qemu-ifup,downscript=$ROOT/tools/qemu-ifdown"
\
-gdb tcp:127.0.0.1:${GDB_PORT},server,ipv4 \
-monitor telnet:127.0.0.1:${MONITOR_PORT},server,ipv4,nowait  \
-kernel "$FINAL_IMAGE"  \
$QEMU_ARCH_ARGS -S || {
if [ -f "$PIDFILE" ]; then
sudo rm -f "$PIDFILE"
fi
exit 1
}

FINAL_IMAGE is elf or uImage (tried both), the uImage is supposed to work.
-initrd along with -sd and some architecture specific arguments are
passed in QEMU_ARCH_ARGS

When I'm attaching gdb and doing "info registers" I get 0x0 in all
registers except PC.

I've analyzed the source, added some printfs and the image is
correctly detected as Linux.

In the sourcode (current release) I couldn't find any place where any
register except PC is being modified.

I've found some comments about some Linux header file that no longer
exists and the code suggest that atags data is put into some
pre-defined memory location, with no pointer being passed in r2.


-- 
Dawid Ciężarkiewicz

___
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain


Re: Qemu atags passing in register.

2012-02-06 Thread d...@ucore.info
On Mon, Feb 6, 2012 at 6:48 PM, d...@ucore.info  wrote:
> In the sourcode (current release) I couldn't find any place where any
> register except PC is being modified.

While looking for some data to paste here, I've notice that the
pointers should be set by "the smallest bootlader in the world". I
wasn't expecting it and checked status of the registers right after
emulation start.

I now see that registers are OK if I step 4 times in gdb.

Please disregard my email.

Regards,
-- 
Dawid Ciężarkiewicz

___
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain