qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alessandro Corradi" <ale.corradi@gmail.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Creating a simple
Date: Mon, 12 Jun 2006 10:07:28 +0200	[thread overview]
Message-ID: <b921df970606120107g26bee575g8e9cc20e4b8afd3@mail.gmail.com> (raw)

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

Hi all,

I'm trying to write a simple virtual hardware for QEMU. This hw must only
return the value 0 every time I read at 0x6f8 address.
It looks like simple but I'm not sure... this is what I do...
I wrote a file in hw dir called hwfitt.c and implements hwfitt_ioport_read
and *hwfitt_init functions.
In hwfitt_ioport_read must be a function that implements the hardware read
control right?
I take for instance parallel.c code and I write hwfitt function call in
files where parallel's function are called (pc.c vl.c  vl.h) and modified
make file. I didn't implement hwupdate_update_irq as in parallel code. Is an
error?
This is my hwfitt.c code. Can you support me?

Thanks

Alessandro

#include "vl.h"

#define HW_STS_READY    0x10
#define HW_STS_BUSY    0x80

#define HW_CTR_INIT    0x01

struct HwFittState {
    uint8_t data;
    uint8_t status;
    uint8_t control;
    int irq;
    int irq_pending;
    CharDriverState *chr;
    int hw_driver;
};

/*static void hwupdate_update_irq(ParallelState *s)
{
    if (s->irq_pending)
        pic_set_irq(s->irq, 1);
    else
        pic_set_irq(s->irq, 0);
}*/

static uint32_t hwfitt_ioport_read(void *opaque, uint32_t addr) {
    HwFittState *s = opaque;
    uint32_t ret= 0xff;

    addr &= 7;
    switch(addr) {
    case 0:
        if(s->hw_driver) {
            s->data=0;
        }
        ret = s->data;
        break;
    case 1:
        if(s->hw_driver) {
            ret=s->status;
        }
        break;
    case 2:
        if(s->hw_driver) {
            s->control=0x10;
        }
        ret = s->control;
        break;
    }
#ifdef DEBUG_PARALLEL
    printf("hwfitt: read addr=0x%02x val=0x%02x\n", addr, ret);
#endif
    return ret;
}

HwFittState *hwfitt_init(int base, int irq, CharDriverState *chr){
    HwFittState *s;

    s=qemu_mallocz(sizeof(HwFittState));
    s->chr = chr;
    s->hw_driver = 1;
    s->irq = irq;
    s->data = 1;
    s->status = HW_STS_READY;
    s->status |= HW_STS_BUSY;
    s->control = HW_CTR_INIT;

    register_ioport_read(base, 8, 1, hwfitt_ioport_read, s);
    return s;
}

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

                 reply	other threads:[~2006-06-12  8:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=b921df970606120107g26bee575g8e9cc20e4b8afd3@mail.gmail.com \
    --to=ale.corradi@gmail.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).