xref: /openbmc/qemu/hw/core/null-machine.c (revision 709395f8)
1 /*
2  * Empty machine
3  *
4  * Copyright IBM, Corp. 2012
5  *
6  * Authors:
7  *  Anthony Liguori   <aliguori@us.ibm.com>
8  *
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.
11  *
12  */
13 
14 #include "qemu/osdep.h"
15 #include "qemu-common.h"
16 #include "qemu/error-report.h"
17 #include "hw/hw.h"
18 #include "hw/boards.h"
19 #include "sysemu/sysemu.h"
20 #include "exec/address-spaces.h"
21 #include "qom/cpu.h"
22 
23 static void machine_none_init(MachineState *mch)
24 {
25     CPUState *cpu = NULL;
26 
27     /* Initialize CPU (if user asked for it) */
28     if (mch->cpu_type) {
29         cpu = cpu_create(mch->cpu_type);
30         if (!cpu) {
31             error_report("Unable to initialize CPU");
32             exit(1);
33         }
34     }
35 
36     /* RAM at address zero */
37     if (mch->ram_size) {
38         MemoryRegion *ram = g_new(MemoryRegion, 1);
39 
40         memory_region_allocate_system_memory(ram, NULL, "ram", mch->ram_size);
41         memory_region_add_subregion(get_system_memory(), 0, ram);
42     }
43 
44     if (mch->kernel_filename) {
45         error_report("The -kernel parameter is not supported "
46                      "(use the generic 'loader' device instead).");
47         exit(1);
48     }
49 }
50 
51 static void machine_none_machine_init(MachineClass *mc)
52 {
53     mc->desc = "empty machine";
54     mc->init = machine_none_init;
55     mc->max_cpus = 1;
56     mc->default_ram_size = 0;
57 }
58 
59 DEFINE_MACHINE("none", machine_none_machine_init)
60