qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Creating a simple
@ 2006-06-12  8:07 Alessandro Corradi
  0 siblings, 0 replies; only message in thread
From: Alessandro Corradi @ 2006-06-12  8:07 UTC (permalink / raw)
  To: qemu-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-12  8:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-12  8:07 [Qemu-devel] Creating a simple Alessandro Corradi

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).