Beispiel #1
0
static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
{
    //mz 05.2012: no RR action necessary - handled as part of ioport_write()
    ioport_write(0, address, data & 0xff);
    address = (address + 1) & IOPORTS_MASK;
    ioport_write(0, address, (data >> 8) & 0xff);
}
Beispiel #2
0
void cpu_outl(pio_addr_t addr, uint32_t val)
{
    if(val == 48)
    LOGD_AIO("%s:%s => ioport_write, index=%d, address=%d, val=%d\n", __FILE__, __func__, 2, addr, val);
    LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
    trace_cpu_out(addr, val);
    ioport_write(2, addr, val);
}
Beispiel #3
0
void cpu_outw(pio_addr_t addr, uint16_t val)
{
    if(val == 48)
    LOGD_AIO("%s:%s => ioport_write, index=%d, address=%d, val=%d\n", __FILE__, __func__, 1, addr, val);
    LOG_IOPORT("outw: %04"FMT_pioaddr" %04"PRIx16"\n", addr, val);
    trace_cpu_out(addr, val);
    ioport_write(1, addr, val);
}
Beispiel #4
0
void
TDAPA::ParportWriteData()
{
  if (ppdev_fd != -1)
    par_write_data(ppdev_fd, &par_data);
  else
    ioport_write(IOBASE, par_data);
}
Beispiel #5
0
void
TDAPA::ParportWriteCtrl()
{
  if (ppdev_fd != -1)
    par_write_ctrl(ppdev_fd, &par_ctrl);
  else
    ioport_write(IOBASE+2, par_ctrl);
}
Beispiel #6
0
static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
{
    if(data == 48)
    LOGD_AIO("%s:%s => ioport_write1, index=%d, address=%d, data=%d\n", __FILE__, __func__, 0, address, data);
    ioport_write(0, address, data & 0xff);
    address = (address + 1) & IOPORTS_MASK;
    if(data == 48)
    LOGD_AIO("%s:%s => ioport_write2, index=%d, address=%d, data=%d\n", __FILE__, __func__, 0, address, data);
    ioport_write(0, address, (data >> 8) & 0xff);
}
Beispiel #7
0
/** Write out a meter value in JSON value format.
  * \param type The metertype to read and encode
  * \param m The meter
  * \param pos The array position within the meter
  * \param into The ioport to use
  */
void jsoncodec_dump_val (metertype_t type, meter *m, int pos, ioport *into) {
    if (m->count > SZ_EMPTY_VAL) return;
    if (m->count == SZ_EMPTY_VAL) {
        if (pos>0) return;
        switch (type) {
            case MTYPE_INT:
                ioport_write (into, "0", 1);
                break;
            
            case MTYPE_FRAC:
                ioport_write (into, "0.0", 3);
                break;
            
            default:
                ioport_write (into, "\"\"", 2);
                break;
        }
        return;
    }
    
    char buf[1024];
    switch (type) {
        case MTYPE_INT:
            sprintf (buf, "%llu", m->d.u64[pos]);
            break;
        
        case MTYPE_FRAC:
            sprintf (buf, "%.3f", m->d.frac[pos]);
            break;
        
        case MTYPE_STR:
            sprintf (buf, "\"%s\"", m->d.str[pos].str);
            break;
            
        default:
            buf[0] = '\0';
            break;
    }
    ioport_write (into, buf, strlen (buf));
}
Beispiel #8
0
void
TDAPA::ParportSetDir(int dir)
{
  if (dir)
    par_ctrl |= PARPORT_CONTROL_DIRECTION;
  else
    par_ctrl &= ~PARPORT_CONTROL_DIRECTION;

  if (ppdev_fd != -1) {
#ifdef par_set_dir
    par_set_dir(ppdev_fd, &dir);
#else
    par_write_ctrl(ppdev_fd, &par_ctrl);
#endif
  } else
    ioport_write(IOBASE+2, par_ctrl);
}
Beispiel #9
0
/** Dumps a meter with a path element */
void jsoncodec_dump_pathval (meter *m, int pos, ioport *into, int ind) {
    meter *mm = m;
    char buf[1024];
    if (ind) {
        ioport_write (into, "    {", 5);
    }
    else {
        ioport_write (into, "{", 1);
    }
    while (mm) {
        nodeid2str (mm->id & MMASK_NAME, buf);
        ioport_write (into, "\"", 1);
        ioport_write (into, buf, strlen(buf));
        ioport_write (into, "\":",2);
        jsoncodec_dump_val (mm->id & MMASK_TYPE, mm, pos, into);
        mm = meter_next_sibling (mm);
        if (mm) ioport_write (into, ",", 1);
    }
    ioport_write (into, "}", 1);
}
Beispiel #10
0
void cpu_outl(pio_addr_t addr, uint32_t val)
{
    LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
    trace_cpu_out(addr, val);
    ioport_write(2, addr, val);
}
Beispiel #11
0
void cpu_outw(pio_addr_t addr, uint16_t val)
{
    LOG_IOPORT("outw: %04"FMT_pioaddr" %04"PRIx16"\n", addr, val);
    trace_cpu_out(addr, val);
    ioport_write(1, addr, val);
}
Beispiel #12
0
void cpu_outb(pio_addr_t addr, uint8_t val)
{
    LOG_IOPORT("outb: %04"FMT_pioaddr" %02"PRIx8"\n", addr, val);
    trace_cpu_out(addr, val);
    ioport_write(0, addr, val);
}
Beispiel #13
0
/** Write out a host's state as JSON data.
  * \param h The host object
  * \param into ioport to use
  */
int jsoncodec_encode_host (ioport *into, host *h) {
    char buffer[256];
    uint64_t pathbuffer[128];
    int paths = 0;
    uint64_t pathmask = 0;
    meter *m = h->first;
    int i;
    int first=1;
    int dobrk = 0;
    ioport_write (into, "{\n", 2);
    while (m) {
        pathmask = idhaspath (m->id);
        if (pathmask) {
            dobrk = 0;
            for (i=0; i<paths; ++i) {
                if (pathbuffer[i] == (m->id & pathmask)) {
                    dobrk = 1;
                    break;
                }
            }
            if (dobrk) {
                m = m->next;
                continue;
            }
            if (paths>127) return 1;
            pathbuffer[paths++] = (m->id & pathmask);
        }
        
        if (first) first=0;
        else ioport_write (into, ",\n", 2);
        ioport_write (into, "  \"", 3);

        if (pathmask) {
            id2str (m->id & pathmask, buffer);
            ioport_write (into, buffer, strlen(buffer));
            ioport_write (into, "\":", 2);
            if (m->count == SZ_EMPTY_VAL) {
                ioport_write (into, "null",4);
            }
            else if (m->count == SZ_EMPTY_ARRAY) {
                ioport_write (into, "[]",2);
            }
            else {
                if (m->count > 0) {
                    ioport_write (into, "[\n", 2);
                }
            
                for (i=0; (i==0)||(i<m->count); ++i) {
                    if (i) ioport_write (into, ",\n", 2);
                    jsoncodec_dump_pathval (m,i,into,(m->count ? 1 : 0));
                }
            
                if (m->count > 0) {
                    ioport_write (into, "\n  ]", 4);
                }
            }
        }
        else {
            id2str (m->id, buffer);
            ioport_write (into, buffer, strlen(buffer));
            ioport_write (into, "\":", 2);
            if (m->count == SZ_EMPTY_VAL) {
                ioport_write (into, "null", 4);
            }
            else if (m->count == SZ_EMPTY_ARRAY) {
                ioport_write (into, "[]", 2);
            }
            else {
                if (m->count > 0) {
                    ioport_write (into, "[", 1);
                }
                for (i=0; (i==0)||(i<m->count); ++i) {
                    jsoncodec_dump_val (m->id & MMASK_TYPE, m, i, into);
                    if ((i+1)<m->count) ioport_write (into, ",",1);
                }
                if (m->count > 0) {
                    ioport_write (into, "]", 1);
                }
            }
        }
        m=m->next;
    }
    ioport_write (into,"\n}\n",3);
    return 0;
}
Beispiel #14
0
static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
{
    ioport_write(0, address, data & 0xff);
    address = (address + 1) & IOPORTS_MASK;
    ioport_write(0, address, (data >> 8) & 0xff);
}