static void nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t value) { ds1225y_t *NVRAM = opaque; int64_t pos; pos = addr - NVRAM->mem_base; if (ds1225y_set_to_mode(NVRAM, writemode, "wb")) { qemu_fseek(NVRAM->file, pos, SEEK_SET); qemu_put_byte(NVRAM->file, (int)value); } }
static void wav_destroy (void *opaque) { WAVState *wav = opaque; uint8_t rlen[4]; uint8_t dlen[4]; uint32_t datalen = wav->bytes; uint32_t rifflen = datalen + 36; if (wav->f) { le_store (rlen, rifflen, 4); le_store (dlen, datalen, 4); qemu_fseek (wav->f, 4, SEEK_SET); qemu_put_buffer (wav->f, rlen, 4); qemu_fseek (wav->f, 32, SEEK_CUR); qemu_put_buffer (wav->f, dlen, 4); qemu_fclose (wav->f); } g_free (wav->path); }
static uint32_t nvram_readb (void *opaque, target_phys_addr_t addr) { ds1225y_t *NVRAM = opaque; int64_t pos; pos = addr - NVRAM->mem_base; if (addr >= NVRAM->capacity) addr -= NVRAM->capacity; if (!ds1225y_set_to_mode(NVRAM, readmode, "rb")) return 0; qemu_fseek(NVRAM->file, pos, SEEK_SET); return (uint32_t)qemu_get_byte(NVRAM->file); }
static void nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t val) { ds1225y_t *s = opaque; #ifdef DEBUG_NVRAM printf("nvram: write 0x%x at " TARGET_FMT_lx "\n", val, addr); #endif s->contents[addr] = val & 0xff; if (s->file) { qemu_fseek(s->file, addr, SEEK_SET); qemu_put_byte(s->file, (int)val); qemu_fflush(s->file); } }