Revision 7267c094 hw/onenand.c
b/hw/onenand.c | ||
---|---|---|
186 | 186 |
const uint8_t *sp = (const uint8_t *) src; |
187 | 187 |
uint8_t *dp = 0; |
188 | 188 |
if (s->bdrv_cur) { |
189 |
dp = qemu_malloc(size);
|
|
189 |
dp = g_malloc(size);
|
|
190 | 190 |
if (!dp || bdrv_read(s->bdrv_cur, sec, dp, secn) < 0) { |
191 | 191 |
result = 1; |
192 | 192 |
} |
... | ... | |
207 | 207 |
} |
208 | 208 |
} |
209 | 209 |
if (dp && s->bdrv_cur) { |
210 |
qemu_free(dp);
|
|
210 |
g_free(dp);
|
|
211 | 211 |
} |
212 | 212 |
} |
213 | 213 |
|
... | ... | |
239 | 239 |
const uint8_t *sp = (const uint8_t *) src; |
240 | 240 |
uint8_t *dp = 0, *dpp = 0; |
241 | 241 |
if (s->bdrv_cur) { |
242 |
dp = qemu_malloc(512);
|
|
242 |
dp = g_malloc(512);
|
|
243 | 243 |
if (!dp || bdrv_read(s->bdrv_cur, |
244 | 244 |
s->secs_cur + (sec >> 5), |
245 | 245 |
dp, 1) < 0) { |
... | ... | |
265 | 265 |
} |
266 | 266 |
} |
267 | 267 |
if (dp) { |
268 |
qemu_free(dp);
|
|
268 |
g_free(dp);
|
|
269 | 269 |
} |
270 | 270 |
} |
271 | 271 |
return result; |
... | ... | |
274 | 274 |
static inline int onenand_erase(OneNANDState *s, int sec, int num) |
275 | 275 |
{ |
276 | 276 |
uint8_t *blankbuf, *tmpbuf; |
277 |
blankbuf = qemu_malloc(512);
|
|
277 |
blankbuf = g_malloc(512);
|
|
278 | 278 |
if (!blankbuf) { |
279 | 279 |
return 1; |
280 | 280 |
} |
281 |
tmpbuf = qemu_malloc(512);
|
|
281 |
tmpbuf = g_malloc(512);
|
|
282 | 282 |
if (!tmpbuf) { |
283 |
qemu_free(blankbuf);
|
|
283 |
g_free(blankbuf);
|
|
284 | 284 |
return 1; |
285 | 285 |
} |
286 | 286 |
memset(blankbuf, 0xff, 512); |
... | ... | |
307 | 307 |
} |
308 | 308 |
} |
309 | 309 |
|
310 |
qemu_free(tmpbuf);
|
|
311 |
qemu_free(blankbuf);
|
|
310 |
g_free(tmpbuf);
|
|
311 |
g_free(blankbuf);
|
|
312 | 312 |
return 0; |
313 | 313 |
|
314 | 314 |
fail: |
315 |
qemu_free(tmpbuf);
|
|
316 |
qemu_free(blankbuf);
|
|
315 |
g_free(tmpbuf);
|
|
316 |
g_free(blankbuf);
|
|
317 | 317 |
return 1; |
318 | 318 |
} |
319 | 319 |
|
... | ... | |
700 | 700 |
uint16_t man_id, uint16_t dev_id, uint16_t ver_id, |
701 | 701 |
int regshift, qemu_irq irq) |
702 | 702 |
{ |
703 |
OneNANDState *s = (OneNANDState *) qemu_mallocz(sizeof(*s));
|
|
703 |
OneNANDState *s = (OneNANDState *) g_malloc0(sizeof(*s));
|
|
704 | 704 |
uint32_t size = 1 << (24 + ((dev_id >> 4) & 7)); |
705 | 705 |
void *ram; |
706 | 706 |
|
... | ... | |
712 | 712 |
s->id.ver = ver_id; |
713 | 713 |
s->blocks = size >> BLOCK_SHIFT; |
714 | 714 |
s->secs = size >> 9; |
715 |
s->blockwp = qemu_malloc(s->blocks);
|
|
715 |
s->blockwp = g_malloc(s->blocks);
|
|
716 | 716 |
s->density_mask = (dev_id & 0x08) ? (1 << (6 + ((dev_id >> 4) & 7))) : 0; |
717 | 717 |
s->iomemtype = cpu_register_io_memory(onenand_readfn, |
718 | 718 |
onenand_writefn, s, DEVICE_NATIVE_ENDIAN); |
719 | 719 |
s->bdrv = bdrv; |
720 | 720 |
if (!s->bdrv) { |
721 |
s->image = memset(qemu_malloc(size + (size >> 5)),
|
|
721 |
s->image = memset(g_malloc(size + (size >> 5)),
|
|
722 | 722 |
0xff, size + (size >> 5)); |
723 | 723 |
} |
724 |
s->otp = memset(qemu_malloc((64 + 2) << PAGE_SHIFT),
|
|
724 |
s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),
|
|
725 | 725 |
0xff, (64 + 2) << PAGE_SHIFT); |
726 | 726 |
s->ram = qemu_ram_alloc(NULL, "onenand.ram", 0xc000 << s->shift); |
727 | 727 |
ram = qemu_get_ram_ptr(s->ram); |
Also available in: Unified diff