Revision 5fe141fd vl.c

b/vl.c
332 332
    return 1;
333 333
}
334 334

  
335
/* return the size or -1 if error */
336
int get_image_size(const char *filename)
337
{
338
    int fd, size;
339
    fd = open(filename, O_RDONLY | O_BINARY);
340
    if (fd < 0)
341
        return -1;
342
    size = lseek(fd, 0, SEEK_END);
343
    close(fd);
344
    return size;
345
}
346

  
347
/* return the size or -1 if error */
348
int load_image(const char *filename, uint8_t *addr)
349
{
350
    int fd, size;
351
    fd = open(filename, O_RDONLY | O_BINARY);
352
    if (fd < 0)
353
        return -1;
354
    size = lseek(fd, 0, SEEK_END);
355
    lseek(fd, 0, SEEK_SET);
356
    if (read(fd, addr, size) != size) {
357
        close(fd);
358
        return -1;
359
    }
360
    close(fd);
361
    return size;
362
}
363

  
364 335
void cpu_outb(CPUState *env, int addr, int val)
365 336
{
366 337
#ifdef DEBUG_IOPORT

Also available in: Unified diff