qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implement standard file operation with QEMU


From: Peter Maydell
Subject: Re: Implement standard file operation with QEMU
Date: Fri, 17 Jul 2020 16:43:09 +0100

On Fri, 17 Jul 2020 at 16:28, casmac <climber.cui@qq.com> wrote:
>    What I want to realize is to be able to call standard file operations 
> (open, read, write etc) in the application program, and execute such programs 
> in QEMU. But I am building under system mode.
>    TI provide copilation toolchain and a library that provide partial 
> functionality from libc. I am hoping to use TI's toolkit to generate object 
> code which contains calls to hook functions, and then use QEMU's host I/O 
> implementation to realize low-level file operation. For example:
>     _stream[fildes]->WRITE  <---hook to ---> qemu_semihosting_console_outs

If the QEMU guest architecture you're using supports
semihosting (eg arm, mips, lm32, m68k, niso2, xtensa), then
you can use it to implement that kind of guest-libc
functionality. What you need to do is entirely in the guest
code: the implementation of the hook function for write
would need to invoke the correct semihosting call.
(For instance on Arm this is "put the arguments into the
correct guest registers/in-memory structures, then invoke
the right SVC instruction".)

If the guest architecture you're using does not have a
semihosting ABI, then you would need to define one, which
is a moderate amount of work and also requires some agreement
about what that ABI definition should look like (eg for
risc-v we asked the risc-v folks to write up a basic
spec document so that everybody implementing semihosting
was working to the same set of requirements).

The other usual way to implement the low-level hook
functions would be for them to talk to emulated devices:
eg a write-to-console function could be implemented to send
the string to a UART device.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]