int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = dst_addr;

    size_t want, did;



    while (nbytes) {

	want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;

	did = read(fd, buf, want);

	if (did != want) break;



	cpu_physical_memory_write_rom(dst_addr, buf, did);

	dst_addr += did;

	nbytes -= did;

    }

    return dst_addr - dst_begin;

}

int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = dst_addr;

    size_t want, did;



    while (nbytes) {

	want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;

	did = read(fd, buf, want);

	if (did != want) break;



	cpu_physical_memory_write_rom(dst_addr, buf, did);

	dst_addr += did;

	nbytes -= did;

    }

    return dst_addr - dst_begin;

}

int FUNC_0(int VAR_0, target_phys_addr_t VAR_1, size_t VAR_2)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = VAR_1;

    size_t want, did;



    while (VAR_2) {

	want = VAR_2 > sizeof(buf) ? sizeof(buf) : VAR_2;

	did = read(VAR_0, buf, want);

	if (did != want) break;



	cpu_physical_memory_write_rom(VAR_1, buf, did);

	VAR_1 += did;

	VAR_2 -= did;

    }

    return VAR_1 - dst_begin;

}

int FUNC_0(int VAR_0, target_phys_addr_t VAR_1, size_t VAR_2)
{ uint8_t buf[4096]; target_phys_addr_t dst_begin = VAR_1; size_t want, did; while (VAR_2) { want = VAR_2 > sizeof(buf) ? sizeof(buf) : VAR_2; did = read(VAR_0, buf, want); if (did != want) break; cpu_physical_memory_write_rom(VAR_1, buf, did); VAR_1 += did; VAR_2 -= did; } return VAR_1 - dst_begin; }