mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 14:58:11 +00:00
cc088f84b5
Postcopy sends RAMBlock names and offsets over the wire (since it can't rely on the order of ramaddr being the same), and it starts out with HVA fault addresses from the kernel. qemu_ram_block_from_host translates a HVA into a RAMBlock, an offset in the RAMBlock and the global ram_addr_t value. Rewrite qemu_ram_addr_from_host to use qemu_ram_block_from_host. Provide qemu_ram_get_idstr since its the actual name text sent on the wire. Backports commit 422148d3e56c3c9a07c0cf36c1e0a0b76f09c357 from qemu
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
/* By Dang Hoang Vu <dang.hvu -at- gmail.com>, 2015 */
|
|
|
|
#ifndef UC_QEMU_H
|
|
#define UC_QEMU_H
|
|
|
|
struct uc_struct;
|
|
|
|
#define OPC_BUF_SIZE 640
|
|
|
|
#include "sysemu/sysemu.h"
|
|
#include "sysemu/cpus.h"
|
|
#include "exec/cpu-common.h"
|
|
#include "exec/memory.h"
|
|
|
|
#include "qemu/thread.h"
|
|
#include "include/qom/cpu.h"
|
|
|
|
#include "vl.h"
|
|
|
|
// This two struct is originally from qemu/include/exec/cpu-all.h
|
|
// Temporarily moved here since there is circular inclusion.
|
|
struct RAMBlock {
|
|
struct MemoryRegion *mr;
|
|
uint8_t *host;
|
|
ram_addr_t offset;
|
|
ram_addr_t used_length;
|
|
ram_addr_t max_length;
|
|
void (*resized)(const char*, uint64_t length, void *host);
|
|
uint32_t flags;
|
|
char idstr[256];
|
|
/* Reads can take either the iothread or the ramlist lock.
|
|
* Writes must take both locks.
|
|
*/
|
|
QTAILQ_ENTRY(RAMBlock) next;
|
|
int fd;
|
|
};
|
|
|
|
static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
|
|
{
|
|
assert(offset < block->used_length);
|
|
assert(block->host);
|
|
return (char *)block->host + offset;
|
|
}
|
|
|
|
typedef struct {
|
|
MemoryRegion *mr;
|
|
void *buffer;
|
|
hwaddr addr;
|
|
hwaddr len;
|
|
bool in_use;
|
|
} BounceBuffer;
|
|
|
|
typedef struct RAMList {
|
|
/* Protected by the iothread lock. */
|
|
unsigned long *dirty_memory[DIRTY_MEMORY_NUM];
|
|
RAMBlock *mru_block;
|
|
QTAILQ_HEAD(, RAMBlock) blocks;
|
|
uint32_t version;
|
|
} RAMList;
|
|
|
|
#endif
|