From: casmac <climber.cui@qq.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: Implement standard file operation with QEMU
Date: Fri, 17 Jul 2020 23:18:00 +0800 [thread overview]
Message-ID: <tencent_DF5BA7114FBBA837DEBE64515ABC7CB27809@qq.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5221 bytes --]
Hello Phil,
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
Are you suggesting that this is done by TCG helpers?
best regards,
xiaolei
------------------ Original ------------------
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>;
Date: Thu, Jul 16, 2020 03:57 PM
To: "casmac"<climber.cui@qq.com>;"qemu-devel"<qemu-devel@nongnu.org>;"Alex Bennée"<alex.bennee@linaro.org>;"Laurent Vivier"<lvivier@redhat.com>;"Marc-André Lureau"<marcandre.lureau@redhat.com>;
Subject: Re: Implement standard file operation with QEMU
Hi Xiaolei,
+Laurent (user-mode)
+Alex (semihosting)
+Marc-André (chardev)
On 7/16/20 2:51 AM, casmac wrote:
> Hi all,
> I am trying to implment standard file operation (stdio) with QEMU for
> DSP architecture. The manufacture (TI) provides a runtime library that
> support posix standard IO, but it left the device level implmentation as
> hook function calls, like in the library source , it contains
> add_device() function, and write(),read(),open() are not implemented:
>
> int add_device(char *name,
> unsigned flags,
> int (*dopen) (const char *path, unsigned flags, int
> foo),
> int (*dclose) (int fno),
> int (*dread) (int fno, char *buf, unsigned count),
> int (*dwrite) (int fno, const char *buf, unsigned
> count),
> fpos_t (*dlseek) (int fno, fpos_t offset, int origin),
> int (*dunlink)(const char *path),
> int (*drename)(const char *old_name, const char
> *new_name))
> {
> _DEVICE *dt;
>
> strncpy(dt->name,name,8);
> dt->name[8] = '\0';
> dt->flags = flags;
> dt->OPEN = dopen;
> dt->CLOSE = dclose;
> dt->READ = dread;
> dt->WRITE = dwrite;
> dt->LSEEK = dlseek;
> dt->UNLINK = dunlink;
> dt->RENAME = drename;
> }
>
> int write(int fildes,
> const char *bufptr,
> unsigned cnt)
> {
>
> /*------------------------------------------------------------------------*/
> /* CALL FUNCTION FROM DEVICE TABLE TO PERFORM WRITE FOR THIS
> DEVICE/FILE */
>
> /*------------------------------------------------------------------------*/
> return (*(_stream[fildes]->WRITE)) (fildes,bufptr,cnt);
> }
>
> Then, how can we use this runtime library together with QEMu to
> implement full-stack file oerations? I really appreaciate any advice.
Trying to understand...
Are you trying to ask "how to implement semihosting for my
qemu-user-tidsp fork"?
Have a look at "hw/semihosting/console.h" and the implementation
(so far only ARM) of qemu_semihosting_console_[in/out].
This might help to plug read/write. Using other stream than
stdin/stdout is not supported (but you can add support) so
open/lseek/close/rename/unlink are not considered.
(for QEMU 'console' is the stdin/stdout subset of stdio).
You can redirect semihosted files with any host chardev,
this is done in qemu_semihosting_connect_chardevs().
You might also have a look at the functions declared in
"hw/semihosting/semihost.h" and how the different TCG helpers
use them.
Regards,
Phil.
[-- Attachment #2: Type: text/html, Size: 5827 bytes --]
next reply other threads:[~2020-07-17 15:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 15:18 casmac [this message]
2020-07-17 15:43 ` Implement standard file operation with QEMU Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2020-07-16 0:51 casmac
2020-07-16 7:57 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_DF5BA7114FBBA837DEBE64515ABC7CB27809@qq.com \
--to=climber.cui@qq.com \
--cc=alex.bennee@linaro.org \
--cc=f4bug@amsat.org \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).