qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: casmac <climber.cui@qq.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: Implement standard file operation with QEMU
Date: Thu, 16 Jul 2020 08:51:53 +0800	[thread overview]
Message-ID: <tencent_BF749AEC7484FAFD4D5356B065C6679BF705@qq.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2903 bytes --]

Hi all,
&nbsp; 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&nbsp; add_device() function, and write(),read(),open() are not implemented:



int add_device(char&nbsp;&nbsp;&nbsp; &nbsp; *name,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; unsigned &nbsp; flags,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*dopen)&nbsp; (const char *path, unsigned flags, int foo),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*dclose) (int fno),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*dread)&nbsp; (int fno, char *buf, unsigned count),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*dwrite) (int fno, const char *buf, unsigned count),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; fpos_t&nbsp;&nbsp; &nbsp; (*dlseek) (int fno, fpos_t offset, int origin),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*dunlink)(const char *path),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; int&nbsp;&nbsp;&nbsp; &nbsp; (*drename)(const char *old_name, const char *new_name))
{
&nbsp;&nbsp; _DEVICE *dt;

&nbsp;&nbsp; strncpy(dt-&gt;name,name,8);
&nbsp;&nbsp; dt-&gt;name[8] = '\0';
&nbsp;&nbsp; dt-&gt;flags &nbsp; = flags;
&nbsp;&nbsp; dt-&gt;OPEN&nbsp; &nbsp; = dopen;
&nbsp;&nbsp; dt-&gt;CLOSE &nbsp; = dclose;
&nbsp;&nbsp; dt-&gt;READ&nbsp; &nbsp; = dread;
&nbsp;&nbsp; dt-&gt;WRITE &nbsp; = dwrite;
&nbsp;&nbsp; dt-&gt;LSEEK &nbsp; = dlseek;
&nbsp;&nbsp; dt-&gt;UNLINK&nbsp; = dunlink;
&nbsp;&nbsp; dt-&gt;RENAME&nbsp; = drename;
}


int write(int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; fildes,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; const char &nbsp; *bufptr,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; unsigned&nbsp;&nbsp;&nbsp; &nbsp; cnt)
{
&nbsp;&nbsp; /*------------------------------------------------------------------------*/
&nbsp;&nbsp; /* CALL FUNCTION FROM DEVICE TABLE TO PERFORM WRITE FOR THIS DEVICE/FILE&nbsp; */
&nbsp;&nbsp; /*------------------------------------------------------------------------*/
&nbsp;&nbsp; return (*(_stream[fildes]-&gt;WRITE)) (fildes,bufptr,cnt);
}



&nbsp;&nbsp; Then, how can we use this runtime library together with QEMu to implement full-stack file oerations?&nbsp; I  really appreaciate any advice.


&nbsp; Thanks.
regards,
xiaolei

[-- Attachment #2: Type: text/html, Size: 3143 bytes --]

             reply	other threads:[~2020-07-16  0:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  0:51 casmac [this message]
2020-07-16  7:57 ` Implement standard file operation with QEMU Philippe Mathieu-Daudé
  -- strict thread matches above, loose matches on Subject: below --
2020-07-17 15:18 casmac
2020-07-17 15:43 ` Peter Maydell

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_BF749AEC7484FAFD4D5356B065C6679BF705@qq.com \
    --to=climber.cui@qq.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).