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