int bytes_read = 0;
while (count > 0) {
- int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+ int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
addr_t host_addr;
int bytes_read = 0;
while (count > 0) {
- int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+ int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
addr_t host_addr;
return bytes_read;
}
+ /*
+ PrintDebug("Trying to read %d bytes\n", bytes_to_copy);
+ PrintDebug("Dist to page edge=%d\n", dist_to_pg_edge);
+ PrintDebug("PAGE_ADDR=0x%x\n", PAGE_ADDR(cursor));
+ PrintDebug("guest_pa=0x%x\n", guest_pa);
+ */
+
memcpy(dest + bytes_read, (void*)host_addr, bytes_to_copy);
bytes_read += bytes_to_copy;
count -= bytes_to_copy;
- cursor += bytes_to_copy;
+ cursor += bytes_to_copy;
}
return bytes_read;
int bytes_written = 0;
while (count > 0) {
- int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+ int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
addr_t host_addr;
return bytes_written;
}
+
memcpy((void*)host_addr, src + bytes_written, bytes_to_copy);
-
+
bytes_written += bytes_to_copy;
count -= bytes_to_copy;
cursor += bytes_to_copy;