hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ
[qemu.git] / include / hw / timer / armv7m_systick.h
1 /*
2 * ARMv7M SysTick timer
3 *
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
6 * Copyright (c) 2017 Linaro Ltd
7 * Written by Peter Maydell
8 *
9 * This code is licensed under the GPL (version 2 or later).
10 */
11
12 #ifndef HW_TIMER_ARMV7M_SYSTICK_H
13 #define HW_TIMER_ARMV7M_SYSTICK_H
14
15 #include "hw/sysbus.h"
16
17 #define TYPE_SYSTICK "armv7m_systick"
18
19 #define SYSTICK(obj) OBJECT_CHECK(SysTickState, (obj), TYPE_SYSTICK)
20
21 typedef struct SysTickState {
22 /*< private >*/
23 SysBusDevice parent_obj;
24 /*< public >*/
25
26 uint32_t control;
27 uint32_t reload;
28 int64_t tick;
29 QEMUTimer *timer;
30 MemoryRegion iomem;
31 qemu_irq irq;
32 } SysTickState;
33
34 /*
35 * Multiplication factor to convert from system clock ticks to qemu timer
36 * ticks. This should be set (by board code, usually) to a value
37 * equal to NANOSECONDS_PER_SECOND / frq, where frq is the clock frequency
38 * in Hz of the CPU.
39 *
40 * This value is used by the systick device when it is running in
41 * its "use the CPU clock" mode (ie when SYST_CSR.CLKSOURCE == 1) to
42 * set how fast the timer should tick.
43 *
44 * TODO: we should refactor this so that rather than using a global
45 * we use a device property or something similar. This is complicated
46 * because (a) the property would need to be plumbed through from the
47 * board code down through various layers to the systick device
48 * and (b) the property needs to be modifiable after realize, because
49 * the stellaris board uses this to implement the behaviour where the
50 * guest can reprogram the PLL registers to downclock the CPU, and the
51 * systick device needs to react accordingly. Possibly this should
52 * be deferred until we have a good API for modelling clock trees.
53 */
54 extern int system_clock_scale;
55
56 #endif