Move RAMBlock to ram_addr.h

Moves it back into qemu's includes.
This commit is contained in:
Lioncash 2018-02-20 08:35:41 -05:00
parent cbc56b3ceb
commit cdd4003ce9
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 29 additions and 23 deletions

View file

@ -17,30 +17,8 @@ struct uc_struct;
#include "vl.h"
// This two struct is originally from qemu/include/exec/cpu-all.h
// These two structs are 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.
*/
QLIST_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;

View file

@ -24,6 +24,34 @@
#ifndef CONFIG_USER_ONLY
#include "hw/xen/xen.h"
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.
*/
QLIST_ENTRY(RAMBlock) next;
int fd;
};
static inline bool offset_in_ramblock(RAMBlock *b, ram_addr_t offset)
{
return (b && b->host && offset < b->used_length) ? true : false;
}
static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
{
assert(offset < block->used_length);
assert(block->host);
return (char *)block->host + offset;
}
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
MemoryRegion *mr, Error **errp);
ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr, Error **errp);