[<<][c][>>][..]
Sat Jun 6 12:22:21 CEST 2015

mem_write_lazy

struct mem_write_lazy {
    uint32_t addr;
    uint32_t n;
    union {
        uint8_t byte[4];
        uint32_t word;
    } data;
};

static void mem_write_lazy_init(struct mem_write_lazy *m, uint32_t addr) {
    m->addr = addr;
    m->n = 0;
}
static void mem_write_lazy_flush(struct mem_write_lazy *m) {
    if (((m->addr & 3) == 3) && (m->n == 4)) {
        mem_write32(m->addr, m->data->word);
    }
    else {
        for(int i=0; i<m->n; i++) {
            mem_write32(m->addr+i, m->data->buf[i]);
        }
    }
    m->addr += m->n;
    m->n = 0;
}
static void mem_write_lazy_byte(struct mem_write_lazy *m, uint32_t val) {
    ...
}




[Reply][About]
[<<][c][>>][..]