Revision cc9e98cb
b/cpu-all.h | ||
---|---|---|
865 | 865 |
uint8_t *host; |
866 | 866 |
ram_addr_t offset; |
867 | 867 |
ram_addr_t length; |
868 |
char idstr[256]; |
|
868 | 869 |
QLIST_ENTRY(RAMBlock) next; |
869 | 870 |
} RAMBlock; |
870 | 871 |
|
b/exec.c | ||
---|---|---|
36 | 36 |
#include "qemu-common.h" |
37 | 37 |
#include "tcg.h" |
38 | 38 |
#include "hw/hw.h" |
39 |
#include "hw/qdev.h" |
|
39 | 40 |
#include "osdep.h" |
40 | 41 |
#include "kvm.h" |
41 | 42 |
#include "qemu-timer.h" |
... | ... | |
2780 | 2781 |
|
2781 | 2782 |
ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) |
2782 | 2783 |
{ |
2783 |
RAMBlock *new_block; |
|
2784 |
RAMBlock *new_block, *block;
|
|
2784 | 2785 |
|
2785 | 2786 |
size = TARGET_PAGE_ALIGN(size); |
2786 |
new_block = qemu_malloc(sizeof(*new_block)); |
|
2787 |
new_block = qemu_mallocz(sizeof(*new_block)); |
|
2788 |
|
|
2789 |
if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { |
|
2790 |
char *id = dev->parent_bus->info->get_dev_path(dev); |
|
2791 |
if (id) { |
|
2792 |
snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id); |
|
2793 |
qemu_free(id); |
|
2794 |
} |
|
2795 |
} |
|
2796 |
pstrcat(new_block->idstr, sizeof(new_block->idstr), name); |
|
2797 |
|
|
2798 |
QLIST_FOREACH(block, &ram_list.blocks, next) { |
|
2799 |
if (!strcmp(block->idstr, new_block->idstr)) { |
|
2800 |
if (block->length == new_block->length) { |
|
2801 |
fprintf(stderr, "RAMBlock \"%s\" exists, assuming lack of" |
|
2802 |
"free.\n", new_block->idstr); |
|
2803 |
qemu_free(new_block); |
|
2804 |
return block->offset; |
|
2805 |
} else { |
|
2806 |
fprintf(stderr, "RAMBlock \"%s\" already registered with" |
|
2807 |
"different size, abort\n", new_block->idstr); |
|
2808 |
abort(); |
|
2809 |
} |
|
2810 |
} |
|
2811 |
} |
|
2787 | 2812 |
|
2788 | 2813 |
if (mem_path) { |
2789 | 2814 |
#if defined (__linux__) && !defined(TARGET_S390X) |
Also available in: Unified diff