target/mips: Clean up handling of CP0 register 25
[qemu/ar7.git] / backends / hostmem-ram.c
blob6aab8d3a7317136f4c7ce824d9689677c7a9956b
1 /*
2 * QEMU Host Memory Backend
4 * Copyright (C) 2013-2014 Red Hat Inc
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "sysemu/hostmem.h"
15 #include "qapi/error.h"
16 #include "qemu/module.h"
17 #include "qom/object_interfaces.h"
19 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
21 static void
22 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
24 char *name;
26 if (!backend->size) {
27 error_setg(errp, "can't create backend with size 0");
28 return;
31 name = host_memory_backend_get_name(backend);
32 memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
33 backend->size, backend->share, errp);
34 g_free(name);
37 static void
38 ram_backend_class_init(ObjectClass *oc, void *data)
40 HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
42 bc->alloc = ram_backend_memory_alloc;
45 static const TypeInfo ram_backend_info = {
46 .name = TYPE_MEMORY_BACKEND_RAM,
47 .parent = TYPE_MEMORY_BACKEND,
48 .class_init = ram_backend_class_init,
51 static void register_types(void)
53 type_register_static(&ram_backend_info);
56 type_init(register_types);