]> git.proxmox.com Git - mirror_qemu.git/blame - hw/core/null-machine.c
hw/core/null-machine: Add the possibility to instantiate a CPU and RAM
[mirror_qemu.git] / hw / core / null-machine.c
CommitLineData
b4a738bf
AL
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
18c86e2b 14#include "qemu/osdep.h"
b4a738bf 15#include "qemu-common.h"
3964ec6c 16#include "qemu/error-report.h"
b4a738bf
AL
17#include "hw/hw.h"
18#include "hw/boards.h"
3964ec6c
TH
19#include "sysemu/sysemu.h"
20#include "exec/address-spaces.h"
21#include "cpu.h"
b4a738bf 22
3964ec6c 23static void machine_none_init(MachineState *mch)
b4a738bf 24{
3964ec6c
TH
25 CPUState *cpu = NULL;
26
27 /* Initialize CPU (if a model has been specified) */
28 if (mch->cpu_model) {
29 cpu = cpu_init(mch->cpu_model);
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 }
b4a738bf
AL
43}
44
e264d29d 45static void machine_none_machine_init(MachineClass *mc)
b4a738bf 46{
e264d29d
EH
47 mc->desc = "empty machine";
48 mc->init = machine_none_init;
3964ec6c
TH
49 mc->max_cpus = 1;
50 mc->default_ram_size = 0;
b4a738bf
AL
51}
52
e264d29d 53DEFINE_MACHINE("none", machine_none_machine_init)