]> git.proxmox.com Git - mirror_qemu.git/blame - hw/arm/stm32vldiscovery.c
hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize
[mirror_qemu.git] / hw / arm / stm32vldiscovery.c
CommitLineData
2ac2410c
AI
1/*
2 * ST STM32VLDISCOVERY machine
3 *
4 * Copyright (c) 2021 Alexandre Iooss <erdnaxe@crans.org>
5 * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26#include "qemu/osdep.h"
27#include "qapi/error.h"
28#include "hw/boards.h"
29#include "hw/qdev-properties.h"
30#include "qemu/error-report.h"
31#include "hw/arm/stm32f100_soc.h"
32#include "hw/arm/boot.h"
33
34/* stm32vldiscovery implementation is derived from netduinoplus2 */
35
36/* Main SYSCLK frequency in Hz (24MHz) */
37#define SYSCLK_FRQ 24000000ULL
38
39static void stm32vldiscovery_init(MachineState *machine)
40{
41 DeviceState *dev;
42
43 /*
44 * TODO: ideally we would model the SoC RCC and let it handle
45 * system_clock_scale, including its ability to define different
46 * possible SYSCLK sources.
47 */
48 system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
49
50 dev = qdev_new(TYPE_STM32F100_SOC);
51 qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3"));
52 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
53
54 armv7m_load_kernel(ARM_CPU(first_cpu),
55 machine->kernel_filename,
56 FLASH_SIZE);
57}
58
59static void stm32vldiscovery_machine_init(MachineClass *mc)
60{
61 mc->desc = "ST STM32VLDISCOVERY (Cortex-M3)";
62 mc->init = stm32vldiscovery_init;
63}
64
65DEFINE_MACHINE("stm32vldiscovery", stm32vldiscovery_machine_init)
66