1 | The following changes since commit ad1b4ec39caa5b3f17cbd8160283a03a3dcfe2ae: | 1 | target-arm queue: mostly aspeed changes from Cédric. |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/input-20180515-pull-request' into staging (2018-05-15 12:50:06 +0100) | 3 | thanks |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit 85182c96de61f0b600bbe834d5a23e713162e892: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190912a' into staging (2019-09-13 14:37:48 +0100) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180515 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190913 |
8 | 13 | ||
9 | for you to fetch changes up to ae7651804748c6b479d5ae09aeac4edb9c44f76e: | 14 | for you to fetch changes up to 27a296fce9821e3608d537756cffa6e43a46df3b: |
10 | 15 | ||
11 | tcg: Optionally log FPU state in TCG -d cpu logging (2018-05-15 14:58:44 +0100) | 16 | qemu-ga: Convert invocation documentation to rST (2019-09-13 16:05:01 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | target-arm queue: | 19 | target-arm queue: |
15 | * Fix coverity nit in int_to_float code | 20 | * aspeed: add a GPIO controller to the SoC |
16 | * Don't set Invalid for float-to-int(MAXINT) | 21 | * aspeed: Various refactorings |
17 | * Fix fp_status_f16 tininess before rounding | 22 | * aspeed: Improve DMA controller modelling |
18 | * Add various missing insns from the v8.2-FP16 extension | 23 | * atomic_template: fix indentation in GEN_ATOMIC_HELPER |
19 | * Fix sqrt_f16 exception raising | 24 | * qemu-ga: Convert invocation documentation to rST |
20 | * sdcard: Correct CRC16 offset in sd_function_switch() | ||
21 | * tcg: Optionally log FPU state in TCG -d cpu logging | ||
22 | 25 | ||
23 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
24 | Alex Bennée (5): | 27 | Christian Svensson (1): |
25 | fpu/softfloat: int_to_float ensure r fully initialised | 28 | aspeed/smc: Calculate checksum on normal DMA |
26 | target/arm: Implement FCMP for fp16 | ||
27 | target/arm: Implement FCSEL for fp16 | ||
28 | target/arm: Implement FMOV (immediate) for fp16 | ||
29 | target/arm: Fix sqrt_f16 exception raising | ||
30 | 29 | ||
31 | Peter Maydell (3): | 30 | Cédric Le Goater (7): |
32 | fpu/softfloat: Don't set Invalid for float-to-int(MAXINT) | 31 | aspeed: Remove unused SoC definitions |
33 | target/arm: Fix fp_status_f16 tininess before rounding | 32 | aspeed: Use consistent typenames |
34 | tcg: Optionally log FPU state in TCG -d cpu logging | 33 | aspeed/smc: Add support for DMAs |
34 | aspeed/smc: Add DMA calibration settings | ||
35 | aspeed/smc: Inject errors in DMA checksum | ||
36 | aspeed/scu: Introduce per-SoC SCU types | ||
37 | aspeed/scu: Introduce a aspeed_scu_get_apb_freq() routine | ||
35 | 38 | ||
36 | Philippe Mathieu-Daudé (1): | 39 | Emilio G. Cota (1): |
37 | sdcard: Correct CRC16 offset in sd_function_switch() | 40 | atomic_template: fix indentation in GEN_ATOMIC_HELPER |
38 | 41 | ||
39 | Richard Henderson (7): | 42 | Peter Maydell (1): |
40 | target/arm: Implement FMOV (general) for fp16 | 43 | qemu-ga: Convert invocation documentation to rST |
41 | target/arm: Early exit after unallocated_encoding in disas_fp_int_conv | ||
42 | target/arm: Implement FCVT (scalar, integer) for fp16 | ||
43 | target/arm: Implement FCVT (scalar, fixed-point) for fp16 | ||
44 | target/arm: Introduce and use read_fp_hreg | ||
45 | target/arm: Implement FP data-processing (2 source) for fp16 | ||
46 | target/arm: Implement FP data-processing (3 source) for fp16 | ||
47 | 44 | ||
48 | include/qemu/log.h | 1 + | 45 | Rashmica Gupta (2): |
49 | target/arm/helper-a64.h | 2 + | 46 | hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500 |
50 | target/arm/helper.h | 6 + | 47 | aspeed: add a GPIO controller to the SoC |
51 | accel/tcg/cpu-exec.c | 9 +- | ||
52 | fpu/softfloat.c | 6 +- | ||
53 | hw/sd/sd.c | 2 +- | ||
54 | target/arm/cpu.c | 2 + | ||
55 | target/arm/helper-a64.c | 10 ++ | ||
56 | target/arm/helper.c | 38 +++- | ||
57 | target/arm/translate-a64.c | 421 ++++++++++++++++++++++++++++++++++++++------- | ||
58 | util/log.c | 2 + | ||
59 | 11 files changed, 428 insertions(+), 71 deletions(-) | ||
60 | 48 | ||
49 | Makefile | 24 +- | ||
50 | hw/gpio/Makefile.objs | 1 + | ||
51 | accel/tcg/atomic_template.h | 2 +- | ||
52 | include/hw/arm/aspeed_soc.h | 4 +- | ||
53 | include/hw/gpio/aspeed_gpio.h | 100 +++++ | ||
54 | include/hw/misc/aspeed_scu.h | 21 +- | ||
55 | include/hw/ssi/aspeed_smc.h | 7 + | ||
56 | hw/arm/aspeed.c | 2 + | ||
57 | hw/arm/aspeed_soc.c | 63 ++- | ||
58 | hw/gpio/aspeed_gpio.c | 884 ++++++++++++++++++++++++++++++++++++++++++ | ||
59 | hw/misc/aspeed_scu.c | 102 ++--- | ||
60 | hw/ssi/aspeed_smc.c | 335 +++++++++++++++- | ||
61 | hw/timer/aspeed_timer.c | 3 +- | ||
62 | MAINTAINERS | 2 +- | ||
63 | docs/conf.py | 18 +- | ||
64 | docs/interop/conf.py | 7 + | ||
65 | docs/interop/index.rst | 1 + | ||
66 | docs/interop/qemu-ga.rst | 133 +++++++ | ||
67 | qemu-doc.texi | 5 - | ||
68 | qemu-ga.texi | 137 ------- | ||
69 | 20 files changed, 1585 insertions(+), 266 deletions(-) | ||
70 | create mode 100644 include/hw/gpio/aspeed_gpio.h | ||
71 | create mode 100644 hw/gpio/aspeed_gpio.c | ||
72 | create mode 100644 docs/interop/qemu-ga.rst | ||
73 | delete mode 100644 qemu-ga.texi | ||
74 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Rashmica Gupta <rashmica.g@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | We are meant to explicitly pass fpst, not cpu_env. | 3 | GPIO pins are arranged in groups of 8 pins labeled A,B,..,Y,Z,AA,AB,AC. |
4 | (Note that the ast2400 controller only goes up to group AB). | ||
5 | A set has four groups (except set AC which only has one) and is | ||
6 | referred to by the groups it is composed of (eg ABCD,EFGH,...,YZAAAB). | ||
7 | Each set is accessed and controlled by a bank of 14 registers. | ||
4 | 8 | ||
5 | Cc: qemu-stable@nongnu.org | 9 | These registers operate on a per pin level where each bit in the register |
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 10 | corresponds to a pin, except for the command source registers. The command |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | source registers operate on a per group level where bits 24, 16, 8 and 0 |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | correspond to each group in the set. |
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 13 | |
10 | Message-id: 20180512003217.9105-12-richard.henderson@linaro.org | 14 | eg. registers for set ABCD: |
15 | |D7...D0|C7...C0|B7...B0|A7...A0| <- GPIOs | ||
16 | |31...24|23...16|15....8|7.....0| <- bit position | ||
17 | |||
18 | Note that there are a couple of groups that only have 4 pins. | ||
19 | |||
20 | There are two ways that this model deviates from the behaviour of the | ||
21 | actual controller: | ||
22 | (1) The only control source driving the GPIO pins in the model is the ARM | ||
23 | model (as there currently aren't models for the LPC or Coprocessor). | ||
24 | |||
25 | (2) None of the registers in the model are reset tolerant (needs | ||
26 | integration with the watchdog). | ||
27 | |||
28 | Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
29 | Tested-by: Andrew Jeffery <andrew@aj.id.au> | ||
30 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
31 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
32 | Message-id: 20190904070506.1052-2-clg@kaod.org | ||
33 | [clg: fixed missing header files | ||
34 | made use of HWADDR_PRIx to fix compilation on windows ] | ||
35 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 36 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 37 | --- |
13 | target/arm/translate-a64.c | 3 ++- | 38 | hw/gpio/Makefile.objs | 1 + |
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | 39 | include/hw/gpio/aspeed_gpio.h | 100 ++++ |
40 | hw/gpio/aspeed_gpio.c | 884 ++++++++++++++++++++++++++++++++++ | ||
41 | 3 files changed, 985 insertions(+) | ||
42 | create mode 100644 include/hw/gpio/aspeed_gpio.h | ||
43 | create mode 100644 hw/gpio/aspeed_gpio.c | ||
15 | 44 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 45 | diff --git a/hw/gpio/Makefile.objs b/hw/gpio/Makefile.objs |
17 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 47 | --- a/hw/gpio/Makefile.objs |
19 | +++ b/target/arm/translate-a64.c | 48 | +++ b/hw/gpio/Makefile.objs |
20 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | 49 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_OMAP) += omap_gpio.o |
21 | tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); | 50 | obj-$(CONFIG_IMX) += imx_gpio.o |
22 | break; | 51 | obj-$(CONFIG_RASPI) += bcm2835_gpio.o |
23 | case 0x3: /* FSQRT */ | 52 | obj-$(CONFIG_NRF51_SOC) += nrf51_gpio.o |
24 | - gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env); | 53 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_gpio.o |
25 | + fpst = get_fpstatus_ptr(true); | 54 | diff --git a/include/hw/gpio/aspeed_gpio.h b/include/hw/gpio/aspeed_gpio.h |
26 | + gen_helper_sqrt_f16(tcg_res, tcg_op, fpst); | 55 | new file mode 100644 |
27 | break; | 56 | index XXXXXXX..XXXXXXX |
28 | case 0x8: /* FRINTN */ | 57 | --- /dev/null |
29 | case 0x9: /* FRINTP */ | 58 | +++ b/include/hw/gpio/aspeed_gpio.h |
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | +/* | ||
61 | + * ASPEED GPIO Controller | ||
62 | + * | ||
63 | + * Copyright (C) 2017-2018 IBM Corp. | ||
64 | + * | ||
65 | + * This code is licensed under the GPL version 2 or later. See | ||
66 | + * the COPYING file in the top-level directory. | ||
67 | + */ | ||
68 | + | ||
69 | +#ifndef ASPEED_GPIO_H | ||
70 | +#define ASPEED_GPIO_H | ||
71 | + | ||
72 | +#include "hw/sysbus.h" | ||
73 | + | ||
74 | +#define TYPE_ASPEED_GPIO "aspeed.gpio" | ||
75 | +#define ASPEED_GPIO(obj) OBJECT_CHECK(AspeedGPIOState, (obj), TYPE_ASPEED_GPIO) | ||
76 | +#define ASPEED_GPIO_CLASS(klass) \ | ||
77 | + OBJECT_CLASS_CHECK(AspeedGPIOClass, (klass), TYPE_ASPEED_GPIO) | ||
78 | +#define ASPEED_GPIO_GET_CLASS(obj) \ | ||
79 | + OBJECT_GET_CLASS(AspeedGPIOClass, (obj), TYPE_ASPEED_GPIO) | ||
80 | + | ||
81 | +#define ASPEED_GPIO_MAX_NR_SETS 8 | ||
82 | +#define ASPEED_REGS_PER_BANK 14 | ||
83 | +#define ASPEED_GPIO_MAX_NR_REGS (ASPEED_REGS_PER_BANK * ASPEED_GPIO_MAX_NR_SETS) | ||
84 | +#define ASPEED_GPIO_NR_PINS 228 | ||
85 | +#define ASPEED_GROUPS_PER_SET 4 | ||
86 | +#define ASPEED_GPIO_NR_DEBOUNCE_REGS 3 | ||
87 | +#define ASPEED_CHARS_PER_GROUP_LABEL 4 | ||
88 | + | ||
89 | +typedef struct GPIOSets GPIOSets; | ||
90 | + | ||
91 | +typedef struct GPIOSetProperties { | ||
92 | + uint32_t input; | ||
93 | + uint32_t output; | ||
94 | + char group_label[ASPEED_GROUPS_PER_SET][ASPEED_CHARS_PER_GROUP_LABEL]; | ||
95 | +} GPIOSetProperties; | ||
96 | + | ||
97 | +enum GPIORegType { | ||
98 | + gpio_not_a_reg, | ||
99 | + gpio_reg_data_value, | ||
100 | + gpio_reg_direction, | ||
101 | + gpio_reg_int_enable, | ||
102 | + gpio_reg_int_sens_0, | ||
103 | + gpio_reg_int_sens_1, | ||
104 | + gpio_reg_int_sens_2, | ||
105 | + gpio_reg_int_status, | ||
106 | + gpio_reg_reset_tolerant, | ||
107 | + gpio_reg_debounce_1, | ||
108 | + gpio_reg_debounce_2, | ||
109 | + gpio_reg_cmd_source_0, | ||
110 | + gpio_reg_cmd_source_1, | ||
111 | + gpio_reg_data_read, | ||
112 | + gpio_reg_input_mask, | ||
113 | +}; | ||
114 | + | ||
115 | +typedef struct AspeedGPIOReg { | ||
116 | + uint16_t set_idx; | ||
117 | + enum GPIORegType type; | ||
118 | + } AspeedGPIOReg; | ||
119 | + | ||
120 | +typedef struct AspeedGPIOClass { | ||
121 | + SysBusDevice parent_obj; | ||
122 | + const GPIOSetProperties *props; | ||
123 | + uint32_t nr_gpio_pins; | ||
124 | + uint32_t nr_gpio_sets; | ||
125 | + uint32_t gap; | ||
126 | + const AspeedGPIOReg *reg_table; | ||
127 | +} AspeedGPIOClass; | ||
128 | + | ||
129 | +typedef struct AspeedGPIOState { | ||
130 | + /* <private> */ | ||
131 | + SysBusDevice parent; | ||
132 | + | ||
133 | + /*< public >*/ | ||
134 | + MemoryRegion iomem; | ||
135 | + int pending; | ||
136 | + qemu_irq irq; | ||
137 | + qemu_irq gpios[ASPEED_GPIO_NR_PINS]; | ||
138 | + | ||
139 | +/* Parallel GPIO Registers */ | ||
140 | + uint32_t debounce_regs[ASPEED_GPIO_NR_DEBOUNCE_REGS]; | ||
141 | + struct GPIOSets { | ||
142 | + uint32_t data_value; /* Reflects pin values */ | ||
143 | + uint32_t data_read; /* Contains last value written to data value */ | ||
144 | + uint32_t direction; | ||
145 | + uint32_t int_enable; | ||
146 | + uint32_t int_sens_0; | ||
147 | + uint32_t int_sens_1; | ||
148 | + uint32_t int_sens_2; | ||
149 | + uint32_t int_status; | ||
150 | + uint32_t reset_tol; | ||
151 | + uint32_t cmd_source_0; | ||
152 | + uint32_t cmd_source_1; | ||
153 | + uint32_t debounce_1; | ||
154 | + uint32_t debounce_2; | ||
155 | + uint32_t input_mask; | ||
156 | + } sets[ASPEED_GPIO_MAX_NR_SETS]; | ||
157 | +} AspeedGPIOState; | ||
158 | + | ||
159 | +#endif /* _ASPEED_GPIO_H_ */ | ||
160 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | ||
161 | new file mode 100644 | ||
162 | index XXXXXXX..XXXXXXX | ||
163 | --- /dev/null | ||
164 | +++ b/hw/gpio/aspeed_gpio.c | ||
165 | @@ -XXX,XX +XXX,XX @@ | ||
166 | +/* | ||
167 | + * ASPEED GPIO Controller | ||
168 | + * | ||
169 | + * Copyright (C) 2017-2019 IBM Corp. | ||
170 | + * | ||
171 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
172 | + */ | ||
173 | + | ||
174 | +#include <assert.h> | ||
175 | + | ||
176 | +#include "qemu/osdep.h" | ||
177 | +#include "qemu/host-utils.h" | ||
178 | +#include "qemu/log.h" | ||
179 | +#include "hw/gpio/aspeed_gpio.h" | ||
180 | +#include "include/hw/misc/aspeed_scu.h" | ||
181 | +#include "qapi/error.h" | ||
182 | +#include "qapi/visitor.h" | ||
183 | +#include "hw/irq.h" | ||
184 | +#include "migration/vmstate.h" | ||
185 | + | ||
186 | +#define GPIOS_PER_REG 32 | ||
187 | +#define GPIOS_PER_SET GPIOS_PER_REG | ||
188 | +#define GPIO_PIN_GAP_SIZE 4 | ||
189 | +#define GPIOS_PER_GROUP 8 | ||
190 | +#define GPIO_GROUP_SHIFT 3 | ||
191 | + | ||
192 | +/* GPIO Source Types */ | ||
193 | +#define ASPEED_CMD_SRC_MASK 0x01010101 | ||
194 | +#define ASPEED_SOURCE_ARM 0 | ||
195 | +#define ASPEED_SOURCE_LPC 1 | ||
196 | +#define ASPEED_SOURCE_COPROCESSOR 2 | ||
197 | +#define ASPEED_SOURCE_RESERVED 3 | ||
198 | + | ||
199 | +/* GPIO Interrupt Triggers */ | ||
200 | +/* | ||
201 | + * For each set of gpios there are three sensitivity registers that control | ||
202 | + * the interrupt trigger mode. | ||
203 | + * | ||
204 | + * | 2 | 1 | 0 | trigger mode | ||
205 | + * ----------------------------- | ||
206 | + * | 0 | 0 | 0 | falling-edge | ||
207 | + * | 0 | 0 | 1 | rising-edge | ||
208 | + * | 0 | 1 | 0 | level-low | ||
209 | + * | 0 | 1 | 1 | level-high | ||
210 | + * | 1 | X | X | dual-edge | ||
211 | + */ | ||
212 | +#define ASPEED_FALLING_EDGE 0 | ||
213 | +#define ASPEED_RISING_EDGE 1 | ||
214 | +#define ASPEED_LEVEL_LOW 2 | ||
215 | +#define ASPEED_LEVEL_HIGH 3 | ||
216 | +#define ASPEED_DUAL_EDGE 4 | ||
217 | + | ||
218 | +/* GPIO Register Address Offsets */ | ||
219 | +#define GPIO_ABCD_DATA_VALUE (0x000 >> 2) | ||
220 | +#define GPIO_ABCD_DIRECTION (0x004 >> 2) | ||
221 | +#define GPIO_ABCD_INT_ENABLE (0x008 >> 2) | ||
222 | +#define GPIO_ABCD_INT_SENS_0 (0x00C >> 2) | ||
223 | +#define GPIO_ABCD_INT_SENS_1 (0x010 >> 2) | ||
224 | +#define GPIO_ABCD_INT_SENS_2 (0x014 >> 2) | ||
225 | +#define GPIO_ABCD_INT_STATUS (0x018 >> 2) | ||
226 | +#define GPIO_ABCD_RESET_TOLERANT (0x01C >> 2) | ||
227 | +#define GPIO_EFGH_DATA_VALUE (0x020 >> 2) | ||
228 | +#define GPIO_EFGH_DIRECTION (0x024 >> 2) | ||
229 | +#define GPIO_EFGH_INT_ENABLE (0x028 >> 2) | ||
230 | +#define GPIO_EFGH_INT_SENS_0 (0x02C >> 2) | ||
231 | +#define GPIO_EFGH_INT_SENS_1 (0x030 >> 2) | ||
232 | +#define GPIO_EFGH_INT_SENS_2 (0x034 >> 2) | ||
233 | +#define GPIO_EFGH_INT_STATUS (0x038 >> 2) | ||
234 | +#define GPIO_EFGH_RESET_TOLERANT (0x03C >> 2) | ||
235 | +#define GPIO_ABCD_DEBOUNCE_1 (0x040 >> 2) | ||
236 | +#define GPIO_ABCD_DEBOUNCE_2 (0x044 >> 2) | ||
237 | +#define GPIO_EFGH_DEBOUNCE_1 (0x048 >> 2) | ||
238 | +#define GPIO_EFGH_DEBOUNCE_2 (0x04C >> 2) | ||
239 | +#define GPIO_DEBOUNCE_TIME_1 (0x050 >> 2) | ||
240 | +#define GPIO_DEBOUNCE_TIME_2 (0x054 >> 2) | ||
241 | +#define GPIO_DEBOUNCE_TIME_3 (0x058 >> 2) | ||
242 | +#define GPIO_ABCD_COMMAND_SRC_0 (0x060 >> 2) | ||
243 | +#define GPIO_ABCD_COMMAND_SRC_1 (0x064 >> 2) | ||
244 | +#define GPIO_EFGH_COMMAND_SRC_0 (0x068 >> 2) | ||
245 | +#define GPIO_EFGH_COMMAND_SRC_1 (0x06C >> 2) | ||
246 | +#define GPIO_IJKL_DATA_VALUE (0x070 >> 2) | ||
247 | +#define GPIO_IJKL_DIRECTION (0x074 >> 2) | ||
248 | +#define GPIO_MNOP_DATA_VALUE (0x078 >> 2) | ||
249 | +#define GPIO_MNOP_DIRECTION (0x07C >> 2) | ||
250 | +#define GPIO_QRST_DATA_VALUE (0x080 >> 2) | ||
251 | +#define GPIO_QRST_DIRECTION (0x084 >> 2) | ||
252 | +#define GPIO_UVWX_DATA_VALUE (0x088 >> 2) | ||
253 | +#define GPIO_UVWX_DIRECTION (0x08C >> 2) | ||
254 | +#define GPIO_IJKL_COMMAND_SRC_0 (0x090 >> 2) | ||
255 | +#define GPIO_IJKL_COMMAND_SRC_1 (0x094 >> 2) | ||
256 | +#define GPIO_IJKL_INT_ENABLE (0x098 >> 2) | ||
257 | +#define GPIO_IJKL_INT_SENS_0 (0x09C >> 2) | ||
258 | +#define GPIO_IJKL_INT_SENS_1 (0x0A0 >> 2) | ||
259 | +#define GPIO_IJKL_INT_SENS_2 (0x0A4 >> 2) | ||
260 | +#define GPIO_IJKL_INT_STATUS (0x0A8 >> 2) | ||
261 | +#define GPIO_IJKL_RESET_TOLERANT (0x0AC >> 2) | ||
262 | +#define GPIO_IJKL_DEBOUNCE_1 (0x0B0 >> 2) | ||
263 | +#define GPIO_IJKL_DEBOUNCE_2 (0x0B4 >> 2) | ||
264 | +#define GPIO_IJKL_INPUT_MASK (0x0B8 >> 2) | ||
265 | +#define GPIO_ABCD_DATA_READ (0x0C0 >> 2) | ||
266 | +#define GPIO_EFGH_DATA_READ (0x0C4 >> 2) | ||
267 | +#define GPIO_IJKL_DATA_READ (0x0C8 >> 2) | ||
268 | +#define GPIO_MNOP_DATA_READ (0x0CC >> 2) | ||
269 | +#define GPIO_QRST_DATA_READ (0x0D0 >> 2) | ||
270 | +#define GPIO_UVWX_DATA_READ (0x0D4 >> 2) | ||
271 | +#define GPIO_YZAAAB_DATA_READ (0x0D8 >> 2) | ||
272 | +#define GPIO_AC_DATA_READ (0x0DC >> 2) | ||
273 | +#define GPIO_MNOP_COMMAND_SRC_0 (0x0E0 >> 2) | ||
274 | +#define GPIO_MNOP_COMMAND_SRC_1 (0x0E4 >> 2) | ||
275 | +#define GPIO_MNOP_INT_ENABLE (0x0E8 >> 2) | ||
276 | +#define GPIO_MNOP_INT_SENS_0 (0x0EC >> 2) | ||
277 | +#define GPIO_MNOP_INT_SENS_1 (0x0F0 >> 2) | ||
278 | +#define GPIO_MNOP_INT_SENS_2 (0x0F4 >> 2) | ||
279 | +#define GPIO_MNOP_INT_STATUS (0x0F8 >> 2) | ||
280 | +#define GPIO_MNOP_RESET_TOLERANT (0x0FC >> 2) | ||
281 | +#define GPIO_MNOP_DEBOUNCE_1 (0x100 >> 2) | ||
282 | +#define GPIO_MNOP_DEBOUNCE_2 (0x104 >> 2) | ||
283 | +#define GPIO_MNOP_INPUT_MASK (0x108 >> 2) | ||
284 | +#define GPIO_QRST_COMMAND_SRC_0 (0x110 >> 2) | ||
285 | +#define GPIO_QRST_COMMAND_SRC_1 (0x114 >> 2) | ||
286 | +#define GPIO_QRST_INT_ENABLE (0x118 >> 2) | ||
287 | +#define GPIO_QRST_INT_SENS_0 (0x11C >> 2) | ||
288 | +#define GPIO_QRST_INT_SENS_1 (0x120 >> 2) | ||
289 | +#define GPIO_QRST_INT_SENS_2 (0x124 >> 2) | ||
290 | +#define GPIO_QRST_INT_STATUS (0x128 >> 2) | ||
291 | +#define GPIO_QRST_RESET_TOLERANT (0x12C >> 2) | ||
292 | +#define GPIO_QRST_DEBOUNCE_1 (0x130 >> 2) | ||
293 | +#define GPIO_QRST_DEBOUNCE_2 (0x134 >> 2) | ||
294 | +#define GPIO_QRST_INPUT_MASK (0x138 >> 2) | ||
295 | +#define GPIO_UVWX_COMMAND_SRC_0 (0x140 >> 2) | ||
296 | +#define GPIO_UVWX_COMMAND_SRC_1 (0x144 >> 2) | ||
297 | +#define GPIO_UVWX_INT_ENABLE (0x148 >> 2) | ||
298 | +#define GPIO_UVWX_INT_SENS_0 (0x14C >> 2) | ||
299 | +#define GPIO_UVWX_INT_SENS_1 (0x150 >> 2) | ||
300 | +#define GPIO_UVWX_INT_SENS_2 (0x154 >> 2) | ||
301 | +#define GPIO_UVWX_INT_STATUS (0x158 >> 2) | ||
302 | +#define GPIO_UVWX_RESET_TOLERANT (0x15C >> 2) | ||
303 | +#define GPIO_UVWX_DEBOUNCE_1 (0x160 >> 2) | ||
304 | +#define GPIO_UVWX_DEBOUNCE_2 (0x164 >> 2) | ||
305 | +#define GPIO_UVWX_INPUT_MASK (0x168 >> 2) | ||
306 | +#define GPIO_YZAAAB_COMMAND_SRC_0 (0x170 >> 2) | ||
307 | +#define GPIO_YZAAAB_COMMAND_SRC_1 (0x174 >> 2) | ||
308 | +#define GPIO_YZAAAB_INT_ENABLE (0x178 >> 2) | ||
309 | +#define GPIO_YZAAAB_INT_SENS_0 (0x17C >> 2) | ||
310 | +#define GPIO_YZAAAB_INT_SENS_1 (0x180 >> 2) | ||
311 | +#define GPIO_YZAAAB_INT_SENS_2 (0x184 >> 2) | ||
312 | +#define GPIO_YZAAAB_INT_STATUS (0x188 >> 2) | ||
313 | +#define GPIO_YZAAAB_RESET_TOLERANT (0x18C >> 2) | ||
314 | +#define GPIO_YZAAAB_DEBOUNCE_1 (0x190 >> 2) | ||
315 | +#define GPIO_YZAAAB_DEBOUNCE_2 (0x194 >> 2) | ||
316 | +#define GPIO_YZAAAB_INPUT_MASK (0x198 >> 2) | ||
317 | +#define GPIO_AC_COMMAND_SRC_0 (0x1A0 >> 2) | ||
318 | +#define GPIO_AC_COMMAND_SRC_1 (0x1A4 >> 2) | ||
319 | +#define GPIO_AC_INT_ENABLE (0x1A8 >> 2) | ||
320 | +#define GPIO_AC_INT_SENS_0 (0x1AC >> 2) | ||
321 | +#define GPIO_AC_INT_SENS_1 (0x1B0 >> 2) | ||
322 | +#define GPIO_AC_INT_SENS_2 (0x1B4 >> 2) | ||
323 | +#define GPIO_AC_INT_STATUS (0x1B8 >> 2) | ||
324 | +#define GPIO_AC_RESET_TOLERANT (0x1BC >> 2) | ||
325 | +#define GPIO_AC_DEBOUNCE_1 (0x1C0 >> 2) | ||
326 | +#define GPIO_AC_DEBOUNCE_2 (0x1C4 >> 2) | ||
327 | +#define GPIO_AC_INPUT_MASK (0x1C8 >> 2) | ||
328 | +#define GPIO_ABCD_INPUT_MASK (0x1D0 >> 2) | ||
329 | +#define GPIO_EFGH_INPUT_MASK (0x1D4 >> 2) | ||
330 | +#define GPIO_YZAAAB_DATA_VALUE (0x1E0 >> 2) | ||
331 | +#define GPIO_YZAAAB_DIRECTION (0x1E4 >> 2) | ||
332 | +#define GPIO_AC_DATA_VALUE (0x1E8 >> 2) | ||
333 | +#define GPIO_AC_DIRECTION (0x1EC >> 2) | ||
334 | +#define GPIO_3_6V_MEM_SIZE 0x1F0 | ||
335 | +#define GPIO_3_6V_REG_ARRAY_SIZE (GPIO_3_6V_MEM_SIZE >> 2) | ||
336 | + | ||
337 | +static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | ||
338 | +{ | ||
339 | + uint32_t falling_edge = 0, rising_edge = 0; | ||
340 | + uint32_t int_trigger = extract32(regs->int_sens_0, gpio, 1) | ||
341 | + | extract32(regs->int_sens_1, gpio, 1) << 1 | ||
342 | + | extract32(regs->int_sens_2, gpio, 1) << 2; | ||
343 | + uint32_t gpio_curr_high = extract32(regs->data_value, gpio, 1); | ||
344 | + uint32_t gpio_int_enabled = extract32(regs->int_enable, gpio, 1); | ||
345 | + | ||
346 | + if (!gpio_int_enabled) { | ||
347 | + return 0; | ||
348 | + } | ||
349 | + | ||
350 | + /* Detect edges */ | ||
351 | + if (gpio_curr_high && !gpio_prev_high) { | ||
352 | + rising_edge = 1; | ||
353 | + } else if (!gpio_curr_high && gpio_prev_high) { | ||
354 | + falling_edge = 1; | ||
355 | + } | ||
356 | + | ||
357 | + if (((int_trigger == ASPEED_FALLING_EDGE) && falling_edge) || | ||
358 | + ((int_trigger == ASPEED_RISING_EDGE) && rising_edge) || | ||
359 | + ((int_trigger == ASPEED_LEVEL_LOW) && !gpio_curr_high) || | ||
360 | + ((int_trigger == ASPEED_LEVEL_HIGH) && gpio_curr_high) || | ||
361 | + ((int_trigger >= ASPEED_DUAL_EDGE) && (rising_edge || falling_edge))) | ||
362 | + { | ||
363 | + regs->int_status = deposit32(regs->int_status, gpio, 1, 1); | ||
364 | + return 1; | ||
365 | + } | ||
366 | + return 0; | ||
367 | +} | ||
368 | + | ||
369 | +#define nested_struct_index(ta, pa, m, tb, pb) \ | ||
370 | + (pb - ((tb *)(((char *)pa) + offsetof(ta, m)))) | ||
371 | + | ||
372 | +static ptrdiff_t aspeed_gpio_set_idx(AspeedGPIOState *s, GPIOSets *regs) | ||
373 | +{ | ||
374 | + return nested_struct_index(AspeedGPIOState, s, sets, GPIOSets, regs); | ||
375 | +} | ||
376 | + | ||
377 | +static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs, | ||
378 | + uint32_t value) | ||
379 | +{ | ||
380 | + uint32_t input_mask = regs->input_mask; | ||
381 | + uint32_t direction = regs->direction; | ||
382 | + uint32_t old = regs->data_value; | ||
383 | + uint32_t new = value; | ||
384 | + uint32_t diff; | ||
385 | + int gpio; | ||
386 | + | ||
387 | + diff = old ^ new; | ||
388 | + if (diff) { | ||
389 | + for (gpio = 0; gpio < GPIOS_PER_REG; gpio++) { | ||
390 | + uint32_t mask = 1 << gpio; | ||
391 | + | ||
392 | + /* If the gpio needs to be updated... */ | ||
393 | + if (!(diff & mask)) { | ||
394 | + continue; | ||
395 | + } | ||
396 | + | ||
397 | + /* ...and we're output or not input-masked... */ | ||
398 | + if (!(direction & mask) && (input_mask & mask)) { | ||
399 | + continue; | ||
400 | + } | ||
401 | + | ||
402 | + /* ...then update the state. */ | ||
403 | + if (mask & new) { | ||
404 | + regs->data_value |= mask; | ||
405 | + } else { | ||
406 | + regs->data_value &= ~mask; | ||
407 | + } | ||
408 | + | ||
409 | + /* If the gpio is set to output... */ | ||
410 | + if (direction & mask) { | ||
411 | + /* ...trigger the line-state IRQ */ | ||
412 | + ptrdiff_t set = aspeed_gpio_set_idx(s, regs); | ||
413 | + size_t offset = set * GPIOS_PER_SET + gpio; | ||
414 | + qemu_set_irq(s->gpios[offset], !!(new & mask)); | ||
415 | + } else { | ||
416 | + /* ...otherwise if we meet the line's current IRQ policy... */ | ||
417 | + if (aspeed_evaluate_irq(regs, old & mask, gpio)) { | ||
418 | + /* ...trigger the VIC IRQ */ | ||
419 | + s->pending++; | ||
420 | + } | ||
421 | + } | ||
422 | + } | ||
423 | + } | ||
424 | + qemu_set_irq(s->irq, !!(s->pending)); | ||
425 | +} | ||
426 | + | ||
427 | +static uint32_t aspeed_adjust_pin(AspeedGPIOState *s, uint32_t pin) | ||
428 | +{ | ||
429 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
430 | + /* | ||
431 | + * The 2500 has a 4 pin gap in group AB and the 2400 has a 4 pin | ||
432 | + * gap in group Y (and only four pins in AB but this is the last group so | ||
433 | + * it doesn't matter). | ||
434 | + */ | ||
435 | + if (agc->gap && pin >= agc->gap) { | ||
436 | + pin += GPIO_PIN_GAP_SIZE; | ||
437 | + } | ||
438 | + | ||
439 | + return pin; | ||
440 | +} | ||
441 | + | ||
442 | +static bool aspeed_gpio_get_pin_level(AspeedGPIOState *s, uint32_t set_idx, | ||
443 | + uint32_t pin) | ||
444 | +{ | ||
445 | + uint32_t reg_val; | ||
446 | + uint32_t pin_mask = 1 << pin; | ||
447 | + | ||
448 | + reg_val = s->sets[set_idx].data_value; | ||
449 | + | ||
450 | + return !!(reg_val & pin_mask); | ||
451 | +} | ||
452 | + | ||
453 | +static void aspeed_gpio_set_pin_level(AspeedGPIOState *s, uint32_t set_idx, | ||
454 | + uint32_t pin, bool level) | ||
455 | +{ | ||
456 | + uint32_t value = s->sets[set_idx].data_value; | ||
457 | + uint32_t pin_mask = 1 << pin; | ||
458 | + | ||
459 | + if (level) { | ||
460 | + value |= pin_mask; | ||
461 | + } else { | ||
462 | + value &= !pin_mask; | ||
463 | + } | ||
464 | + | ||
465 | + aspeed_gpio_update(s, &s->sets[set_idx], value); | ||
466 | +} | ||
467 | + | ||
468 | +/* | ||
469 | + * | src_1 | src_2 | source | | ||
470 | + * |-----------------------------| | ||
471 | + * | 0 | 0 | ARM | | ||
472 | + * | 0 | 1 | LPC | | ||
473 | + * | 1 | 0 | Coprocessor| | ||
474 | + * | 1 | 1 | Reserved | | ||
475 | + * | ||
476 | + * Once the source of a set is programmed, corresponding bits in the | ||
477 | + * data_value, direction, interrupt [enable, sens[0-2]], reset_tol and | ||
478 | + * debounce registers can only be written by the source. | ||
479 | + * | ||
480 | + * Source is ARM by default | ||
481 | + * only bits 24, 16, 8, and 0 can be set | ||
482 | + * | ||
483 | + * we don't currently have a model for the LPC or Coprocessor | ||
484 | + */ | ||
485 | +static uint32_t update_value_control_source(GPIOSets *regs, uint32_t old_value, | ||
486 | + uint32_t value) | ||
487 | +{ | ||
488 | + int i; | ||
489 | + int cmd_source; | ||
490 | + | ||
491 | + /* assume the source is always ARM for now */ | ||
492 | + int source = ASPEED_SOURCE_ARM; | ||
493 | + | ||
494 | + uint32_t new_value = 0; | ||
495 | + | ||
496 | + /* for each group in set */ | ||
497 | + for (i = 0; i < GPIOS_PER_REG; i += GPIOS_PER_GROUP) { | ||
498 | + cmd_source = extract32(regs->cmd_source_0, i, 1) | ||
499 | + | (extract32(regs->cmd_source_1, i, 1) << 1); | ||
500 | + | ||
501 | + if (source == cmd_source) { | ||
502 | + new_value |= (0xff << i) & value; | ||
503 | + } else { | ||
504 | + new_value |= (0xff << i) & old_value; | ||
505 | + } | ||
506 | + } | ||
507 | + return new_value; | ||
508 | +} | ||
509 | + | ||
510 | +static const AspeedGPIOReg aspeed_3_6v_gpios[GPIO_3_6V_REG_ARRAY_SIZE] = { | ||
511 | + /* Set ABCD */ | ||
512 | + [GPIO_ABCD_DATA_VALUE] = { 0, gpio_reg_data_value }, | ||
513 | + [GPIO_ABCD_DIRECTION] = { 0, gpio_reg_direction }, | ||
514 | + [GPIO_ABCD_INT_ENABLE] = { 0, gpio_reg_int_enable }, | ||
515 | + [GPIO_ABCD_INT_SENS_0] = { 0, gpio_reg_int_sens_0 }, | ||
516 | + [GPIO_ABCD_INT_SENS_1] = { 0, gpio_reg_int_sens_1 }, | ||
517 | + [GPIO_ABCD_INT_SENS_2] = { 0, gpio_reg_int_sens_2 }, | ||
518 | + [GPIO_ABCD_INT_STATUS] = { 0, gpio_reg_int_status }, | ||
519 | + [GPIO_ABCD_RESET_TOLERANT] = { 0, gpio_reg_reset_tolerant }, | ||
520 | + [GPIO_ABCD_DEBOUNCE_1] = { 0, gpio_reg_debounce_1 }, | ||
521 | + [GPIO_ABCD_DEBOUNCE_2] = { 0, gpio_reg_debounce_2 }, | ||
522 | + [GPIO_ABCD_COMMAND_SRC_0] = { 0, gpio_reg_cmd_source_0 }, | ||
523 | + [GPIO_ABCD_COMMAND_SRC_1] = { 0, gpio_reg_cmd_source_1 }, | ||
524 | + [GPIO_ABCD_DATA_READ] = { 0, gpio_reg_data_read }, | ||
525 | + [GPIO_ABCD_INPUT_MASK] = { 0, gpio_reg_input_mask }, | ||
526 | + /* Set EFGH */ | ||
527 | + [GPIO_EFGH_DATA_VALUE] = { 1, gpio_reg_data_value }, | ||
528 | + [GPIO_EFGH_DIRECTION] = { 1, gpio_reg_direction }, | ||
529 | + [GPIO_EFGH_INT_ENABLE] = { 1, gpio_reg_int_enable }, | ||
530 | + [GPIO_EFGH_INT_SENS_0] = { 1, gpio_reg_int_sens_0 }, | ||
531 | + [GPIO_EFGH_INT_SENS_1] = { 1, gpio_reg_int_sens_1 }, | ||
532 | + [GPIO_EFGH_INT_SENS_2] = { 1, gpio_reg_int_sens_2 }, | ||
533 | + [GPIO_EFGH_INT_STATUS] = { 1, gpio_reg_int_status }, | ||
534 | + [GPIO_EFGH_RESET_TOLERANT] = { 1, gpio_reg_reset_tolerant }, | ||
535 | + [GPIO_EFGH_DEBOUNCE_1] = { 1, gpio_reg_debounce_1 }, | ||
536 | + [GPIO_EFGH_DEBOUNCE_2] = { 1, gpio_reg_debounce_2 }, | ||
537 | + [GPIO_EFGH_COMMAND_SRC_0] = { 1, gpio_reg_cmd_source_0 }, | ||
538 | + [GPIO_EFGH_COMMAND_SRC_1] = { 1, gpio_reg_cmd_source_1 }, | ||
539 | + [GPIO_EFGH_DATA_READ] = { 1, gpio_reg_data_read }, | ||
540 | + [GPIO_EFGH_INPUT_MASK] = { 1, gpio_reg_input_mask }, | ||
541 | + /* Set IJKL */ | ||
542 | + [GPIO_IJKL_DATA_VALUE] = { 2, gpio_reg_data_value }, | ||
543 | + [GPIO_IJKL_DIRECTION] = { 2, gpio_reg_direction }, | ||
544 | + [GPIO_IJKL_INT_ENABLE] = { 2, gpio_reg_int_enable }, | ||
545 | + [GPIO_IJKL_INT_SENS_0] = { 2, gpio_reg_int_sens_0 }, | ||
546 | + [GPIO_IJKL_INT_SENS_1] = { 2, gpio_reg_int_sens_1 }, | ||
547 | + [GPIO_IJKL_INT_SENS_2] = { 2, gpio_reg_int_sens_2 }, | ||
548 | + [GPIO_IJKL_INT_STATUS] = { 2, gpio_reg_int_status }, | ||
549 | + [GPIO_IJKL_RESET_TOLERANT] = { 2, gpio_reg_reset_tolerant }, | ||
550 | + [GPIO_IJKL_DEBOUNCE_1] = { 2, gpio_reg_debounce_1 }, | ||
551 | + [GPIO_IJKL_DEBOUNCE_2] = { 2, gpio_reg_debounce_2 }, | ||
552 | + [GPIO_IJKL_COMMAND_SRC_0] = { 2, gpio_reg_cmd_source_0 }, | ||
553 | + [GPIO_IJKL_COMMAND_SRC_1] = { 2, gpio_reg_cmd_source_1 }, | ||
554 | + [GPIO_IJKL_DATA_READ] = { 2, gpio_reg_data_read }, | ||
555 | + [GPIO_IJKL_INPUT_MASK] = { 2, gpio_reg_input_mask }, | ||
556 | + /* Set MNOP */ | ||
557 | + [GPIO_MNOP_DATA_VALUE] = { 3, gpio_reg_data_value }, | ||
558 | + [GPIO_MNOP_DIRECTION] = { 3, gpio_reg_direction }, | ||
559 | + [GPIO_MNOP_INT_ENABLE] = { 3, gpio_reg_int_enable }, | ||
560 | + [GPIO_MNOP_INT_SENS_0] = { 3, gpio_reg_int_sens_0 }, | ||
561 | + [GPIO_MNOP_INT_SENS_1] = { 3, gpio_reg_int_sens_1 }, | ||
562 | + [GPIO_MNOP_INT_SENS_2] = { 3, gpio_reg_int_sens_2 }, | ||
563 | + [GPIO_MNOP_INT_STATUS] = { 3, gpio_reg_int_status }, | ||
564 | + [GPIO_MNOP_RESET_TOLERANT] = { 3, gpio_reg_reset_tolerant }, | ||
565 | + [GPIO_MNOP_DEBOUNCE_1] = { 3, gpio_reg_debounce_1 }, | ||
566 | + [GPIO_MNOP_DEBOUNCE_2] = { 3, gpio_reg_debounce_2 }, | ||
567 | + [GPIO_MNOP_COMMAND_SRC_0] = { 3, gpio_reg_cmd_source_0 }, | ||
568 | + [GPIO_MNOP_COMMAND_SRC_1] = { 3, gpio_reg_cmd_source_1 }, | ||
569 | + [GPIO_MNOP_DATA_READ] = { 3, gpio_reg_data_read }, | ||
570 | + [GPIO_MNOP_INPUT_MASK] = { 3, gpio_reg_input_mask }, | ||
571 | + /* Set QRST */ | ||
572 | + [GPIO_QRST_DATA_VALUE] = { 4, gpio_reg_data_value }, | ||
573 | + [GPIO_QRST_DIRECTION] = { 4, gpio_reg_direction }, | ||
574 | + [GPIO_QRST_INT_ENABLE] = { 4, gpio_reg_int_enable }, | ||
575 | + [GPIO_QRST_INT_SENS_0] = { 4, gpio_reg_int_sens_0 }, | ||
576 | + [GPIO_QRST_INT_SENS_1] = { 4, gpio_reg_int_sens_1 }, | ||
577 | + [GPIO_QRST_INT_SENS_2] = { 4, gpio_reg_int_sens_2 }, | ||
578 | + [GPIO_QRST_INT_STATUS] = { 4, gpio_reg_int_status }, | ||
579 | + [GPIO_QRST_RESET_TOLERANT] = { 4, gpio_reg_reset_tolerant }, | ||
580 | + [GPIO_QRST_DEBOUNCE_1] = { 4, gpio_reg_debounce_1 }, | ||
581 | + [GPIO_QRST_DEBOUNCE_2] = { 4, gpio_reg_debounce_2 }, | ||
582 | + [GPIO_QRST_COMMAND_SRC_0] = { 4, gpio_reg_cmd_source_0 }, | ||
583 | + [GPIO_QRST_COMMAND_SRC_1] = { 4, gpio_reg_cmd_source_1 }, | ||
584 | + [GPIO_QRST_DATA_READ] = { 4, gpio_reg_data_read }, | ||
585 | + [GPIO_QRST_INPUT_MASK] = { 4, gpio_reg_input_mask }, | ||
586 | + /* Set UVWX */ | ||
587 | + [GPIO_UVWX_DATA_VALUE] = { 5, gpio_reg_data_value }, | ||
588 | + [GPIO_UVWX_DIRECTION] = { 5, gpio_reg_direction }, | ||
589 | + [GPIO_UVWX_INT_ENABLE] = { 5, gpio_reg_int_enable }, | ||
590 | + [GPIO_UVWX_INT_SENS_0] = { 5, gpio_reg_int_sens_0 }, | ||
591 | + [GPIO_UVWX_INT_SENS_1] = { 5, gpio_reg_int_sens_1 }, | ||
592 | + [GPIO_UVWX_INT_SENS_2] = { 5, gpio_reg_int_sens_2 }, | ||
593 | + [GPIO_UVWX_INT_STATUS] = { 5, gpio_reg_int_status }, | ||
594 | + [GPIO_UVWX_RESET_TOLERANT] = { 5, gpio_reg_reset_tolerant }, | ||
595 | + [GPIO_UVWX_DEBOUNCE_1] = { 5, gpio_reg_debounce_1 }, | ||
596 | + [GPIO_UVWX_DEBOUNCE_2] = { 5, gpio_reg_debounce_2 }, | ||
597 | + [GPIO_UVWX_COMMAND_SRC_0] = { 5, gpio_reg_cmd_source_0 }, | ||
598 | + [GPIO_UVWX_COMMAND_SRC_1] = { 5, gpio_reg_cmd_source_1 }, | ||
599 | + [GPIO_UVWX_DATA_READ] = { 5, gpio_reg_data_read }, | ||
600 | + [GPIO_UVWX_INPUT_MASK] = { 5, gpio_reg_input_mask }, | ||
601 | + /* Set YZAAAB */ | ||
602 | + [GPIO_YZAAAB_DATA_VALUE] = { 6, gpio_reg_data_value }, | ||
603 | + [GPIO_YZAAAB_DIRECTION] = { 6, gpio_reg_direction }, | ||
604 | + [GPIO_YZAAAB_INT_ENABLE] = { 6, gpio_reg_int_enable }, | ||
605 | + [GPIO_YZAAAB_INT_SENS_0] = { 6, gpio_reg_int_sens_0 }, | ||
606 | + [GPIO_YZAAAB_INT_SENS_1] = { 6, gpio_reg_int_sens_1 }, | ||
607 | + [GPIO_YZAAAB_INT_SENS_2] = { 6, gpio_reg_int_sens_2 }, | ||
608 | + [GPIO_YZAAAB_INT_STATUS] = { 6, gpio_reg_int_status }, | ||
609 | + [GPIO_YZAAAB_RESET_TOLERANT] = { 6, gpio_reg_reset_tolerant }, | ||
610 | + [GPIO_YZAAAB_DEBOUNCE_1] = { 6, gpio_reg_debounce_1 }, | ||
611 | + [GPIO_YZAAAB_DEBOUNCE_2] = { 6, gpio_reg_debounce_2 }, | ||
612 | + [GPIO_YZAAAB_COMMAND_SRC_0] = { 6, gpio_reg_cmd_source_0 }, | ||
613 | + [GPIO_YZAAAB_COMMAND_SRC_1] = { 6, gpio_reg_cmd_source_1 }, | ||
614 | + [GPIO_YZAAAB_DATA_READ] = { 6, gpio_reg_data_read }, | ||
615 | + [GPIO_YZAAAB_INPUT_MASK] = { 6, gpio_reg_input_mask }, | ||
616 | + /* Set AC (ast2500 only) */ | ||
617 | + [GPIO_AC_DATA_VALUE] = { 7, gpio_reg_data_value }, | ||
618 | + [GPIO_AC_DIRECTION] = { 7, gpio_reg_direction }, | ||
619 | + [GPIO_AC_INT_ENABLE] = { 7, gpio_reg_int_enable }, | ||
620 | + [GPIO_AC_INT_SENS_0] = { 7, gpio_reg_int_sens_0 }, | ||
621 | + [GPIO_AC_INT_SENS_1] = { 7, gpio_reg_int_sens_1 }, | ||
622 | + [GPIO_AC_INT_SENS_2] = { 7, gpio_reg_int_sens_2 }, | ||
623 | + [GPIO_AC_INT_STATUS] = { 7, gpio_reg_int_status }, | ||
624 | + [GPIO_AC_RESET_TOLERANT] = { 7, gpio_reg_reset_tolerant }, | ||
625 | + [GPIO_AC_DEBOUNCE_1] = { 7, gpio_reg_debounce_1 }, | ||
626 | + [GPIO_AC_DEBOUNCE_2] = { 7, gpio_reg_debounce_2 }, | ||
627 | + [GPIO_AC_COMMAND_SRC_0] = { 7, gpio_reg_cmd_source_0 }, | ||
628 | + [GPIO_AC_COMMAND_SRC_1] = { 7, gpio_reg_cmd_source_1 }, | ||
629 | + [GPIO_AC_DATA_READ] = { 7, gpio_reg_data_read }, | ||
630 | + [GPIO_AC_INPUT_MASK] = { 7, gpio_reg_input_mask }, | ||
631 | +}; | ||
632 | + | ||
633 | +static uint64_t aspeed_gpio_read(void *opaque, hwaddr offset, uint32_t size) | ||
634 | +{ | ||
635 | + AspeedGPIOState *s = ASPEED_GPIO(opaque); | ||
636 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
637 | + uint64_t idx = -1; | ||
638 | + const AspeedGPIOReg *reg; | ||
639 | + GPIOSets *set; | ||
640 | + | ||
641 | + idx = offset >> 2; | ||
642 | + if (idx >= GPIO_DEBOUNCE_TIME_1 && idx <= GPIO_DEBOUNCE_TIME_3) { | ||
643 | + idx -= GPIO_DEBOUNCE_TIME_1; | ||
644 | + return (uint64_t) s->debounce_regs[idx]; | ||
645 | + } | ||
646 | + | ||
647 | + reg = &agc->reg_table[idx]; | ||
648 | + if (reg->set_idx >= agc->nr_gpio_sets) { | ||
649 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no getter for offset 0x%" | ||
650 | + HWADDR_PRIx"\n", __func__, offset); | ||
651 | + return 0; | ||
652 | + } | ||
653 | + | ||
654 | + set = &s->sets[reg->set_idx]; | ||
655 | + switch (reg->type) { | ||
656 | + case gpio_reg_data_value: | ||
657 | + return set->data_value; | ||
658 | + case gpio_reg_direction: | ||
659 | + return set->direction; | ||
660 | + case gpio_reg_int_enable: | ||
661 | + return set->int_enable; | ||
662 | + case gpio_reg_int_sens_0: | ||
663 | + return set->int_sens_0; | ||
664 | + case gpio_reg_int_sens_1: | ||
665 | + return set->int_sens_1; | ||
666 | + case gpio_reg_int_sens_2: | ||
667 | + return set->int_sens_2; | ||
668 | + case gpio_reg_int_status: | ||
669 | + return set->int_status; | ||
670 | + case gpio_reg_reset_tolerant: | ||
671 | + return set->reset_tol; | ||
672 | + case gpio_reg_debounce_1: | ||
673 | + return set->debounce_1; | ||
674 | + case gpio_reg_debounce_2: | ||
675 | + return set->debounce_2; | ||
676 | + case gpio_reg_cmd_source_0: | ||
677 | + return set->cmd_source_0; | ||
678 | + case gpio_reg_cmd_source_1: | ||
679 | + return set->cmd_source_1; | ||
680 | + case gpio_reg_data_read: | ||
681 | + return set->data_read; | ||
682 | + case gpio_reg_input_mask: | ||
683 | + return set->input_mask; | ||
684 | + default: | ||
685 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no getter for offset 0x%" | ||
686 | + HWADDR_PRIx"\n", __func__, offset); | ||
687 | + return 0; | ||
688 | + }; | ||
689 | +} | ||
690 | + | ||
691 | +static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data, | ||
692 | + uint32_t size) | ||
693 | +{ | ||
694 | + AspeedGPIOState *s = ASPEED_GPIO(opaque); | ||
695 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
696 | + const GPIOSetProperties *props; | ||
697 | + uint64_t idx = -1; | ||
698 | + const AspeedGPIOReg *reg; | ||
699 | + GPIOSets *set; | ||
700 | + uint32_t cleared; | ||
701 | + | ||
702 | + idx = offset >> 2; | ||
703 | + if (idx >= GPIO_DEBOUNCE_TIME_1 && idx <= GPIO_DEBOUNCE_TIME_3) { | ||
704 | + idx -= GPIO_DEBOUNCE_TIME_1; | ||
705 | + s->debounce_regs[idx] = (uint32_t) data; | ||
706 | + return; | ||
707 | + } | ||
708 | + | ||
709 | + reg = &agc->reg_table[idx]; | ||
710 | + if (reg->set_idx >= agc->nr_gpio_sets) { | ||
711 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no setter for offset 0x%" | ||
712 | + HWADDR_PRIx"\n", __func__, offset); | ||
713 | + return; | ||
714 | + } | ||
715 | + | ||
716 | + set = &s->sets[reg->set_idx]; | ||
717 | + props = &agc->props[reg->set_idx]; | ||
718 | + | ||
719 | + switch (reg->type) { | ||
720 | + case gpio_reg_data_value: | ||
721 | + data &= props->output; | ||
722 | + data = update_value_control_source(set, set->data_value, data); | ||
723 | + set->data_read = data; | ||
724 | + aspeed_gpio_update(s, set, data); | ||
725 | + return; | ||
726 | + case gpio_reg_direction: | ||
727 | + /* | ||
728 | + * where data is the value attempted to be written to the pin: | ||
729 | + * pin type | input mask | output mask | expected value | ||
730 | + * ------------------------------------------------------------ | ||
731 | + * bidirectional | 1 | 1 | data | ||
732 | + * input only | 1 | 0 | 0 | ||
733 | + * output only | 0 | 1 | 1 | ||
734 | + * no pin / gap | 0 | 0 | 0 | ||
735 | + * | ||
736 | + * which is captured by: | ||
737 | + * data = ( data | ~input) & output; | ||
738 | + */ | ||
739 | + data = (data | ~props->input) & props->output; | ||
740 | + set->direction = update_value_control_source(set, set->direction, data); | ||
741 | + break; | ||
742 | + case gpio_reg_int_enable: | ||
743 | + set->int_enable = update_value_control_source(set, set->int_enable, | ||
744 | + data); | ||
745 | + break; | ||
746 | + case gpio_reg_int_sens_0: | ||
747 | + set->int_sens_0 = update_value_control_source(set, set->int_sens_0, | ||
748 | + data); | ||
749 | + break; | ||
750 | + case gpio_reg_int_sens_1: | ||
751 | + set->int_sens_1 = update_value_control_source(set, set->int_sens_1, | ||
752 | + data); | ||
753 | + break; | ||
754 | + case gpio_reg_int_sens_2: | ||
755 | + set->int_sens_2 = update_value_control_source(set, set->int_sens_2, | ||
756 | + data); | ||
757 | + break; | ||
758 | + case gpio_reg_int_status: | ||
759 | + cleared = ctpop32(data & set->int_status); | ||
760 | + if (s->pending && cleared) { | ||
761 | + assert(s->pending >= cleared); | ||
762 | + s->pending -= cleared; | ||
763 | + } | ||
764 | + set->int_status &= ~data; | ||
765 | + break; | ||
766 | + case gpio_reg_reset_tolerant: | ||
767 | + set->reset_tol = update_value_control_source(set, set->reset_tol, | ||
768 | + data); | ||
769 | + return; | ||
770 | + case gpio_reg_debounce_1: | ||
771 | + set->debounce_1 = update_value_control_source(set, set->debounce_1, | ||
772 | + data); | ||
773 | + return; | ||
774 | + case gpio_reg_debounce_2: | ||
775 | + set->debounce_2 = update_value_control_source(set, set->debounce_2, | ||
776 | + data); | ||
777 | + return; | ||
778 | + case gpio_reg_cmd_source_0: | ||
779 | + set->cmd_source_0 = data & ASPEED_CMD_SRC_MASK; | ||
780 | + return; | ||
781 | + case gpio_reg_cmd_source_1: | ||
782 | + set->cmd_source_1 = data & ASPEED_CMD_SRC_MASK; | ||
783 | + return; | ||
784 | + case gpio_reg_data_read: | ||
785 | + /* Read only register */ | ||
786 | + return; | ||
787 | + case gpio_reg_input_mask: | ||
788 | + /* | ||
789 | + * feeds into interrupt generation | ||
790 | + * 0: read from data value reg will be updated | ||
791 | + * 1: read from data value reg will not be updated | ||
792 | + */ | ||
793 | + set->input_mask = data & props->input; | ||
794 | + break; | ||
795 | + default: | ||
796 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no setter for offset 0x%" | ||
797 | + HWADDR_PRIx"\n", __func__, offset); | ||
798 | + return; | ||
799 | + } | ||
800 | + aspeed_gpio_update(s, set, set->data_value); | ||
801 | + return; | ||
802 | +} | ||
803 | + | ||
804 | +static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx) | ||
805 | +{ | ||
806 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
807 | + int set_idx, g_idx = *group_idx; | ||
808 | + | ||
809 | + for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) { | ||
810 | + const GPIOSetProperties *set_props = &agc->props[set_idx]; | ||
811 | + for (g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) { | ||
812 | + if (!strncmp(group, set_props->group_label[g_idx], strlen(group))) { | ||
813 | + *group_idx = g_idx; | ||
814 | + return set_idx; | ||
815 | + } | ||
816 | + } | ||
817 | + } | ||
818 | + return -1; | ||
819 | +} | ||
820 | + | ||
821 | +static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name, | ||
822 | + void *opaque, Error **errp) | ||
823 | +{ | ||
824 | + int pin = 0xfff; | ||
825 | + bool level = true; | ||
826 | + char group[3]; | ||
827 | + AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
828 | + int set_idx, group_idx = 0; | ||
829 | + | ||
830 | + if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
831 | + error_setg(errp, "%s: error reading %s", __func__, name); | ||
832 | + return; | ||
833 | + } | ||
834 | + set_idx = get_set_idx(s, group, &group_idx); | ||
835 | + if (set_idx == -1) { | ||
836 | + error_setg(errp, "%s: invalid group %s", __func__, group); | ||
837 | + return; | ||
838 | + } | ||
839 | + pin = pin + group_idx * GPIOS_PER_GROUP; | ||
840 | + level = aspeed_gpio_get_pin_level(s, set_idx, pin); | ||
841 | + visit_type_bool(v, name, &level, errp); | ||
842 | +} | ||
843 | + | ||
844 | +static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, | ||
845 | + void *opaque, Error **errp) | ||
846 | +{ | ||
847 | + Error *local_err = NULL; | ||
848 | + bool level; | ||
849 | + int pin = 0xfff; | ||
850 | + char group[3]; | ||
851 | + AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
852 | + int set_idx, group_idx = 0; | ||
853 | + | ||
854 | + visit_type_bool(v, name, &level, &local_err); | ||
855 | + if (local_err) { | ||
856 | + error_propagate(errp, local_err); | ||
857 | + return; | ||
858 | + } | ||
859 | + if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
860 | + error_setg(errp, "%s: error reading %s", __func__, name); | ||
861 | + return; | ||
862 | + } | ||
863 | + set_idx = get_set_idx(s, group, &group_idx); | ||
864 | + if (set_idx == -1) { | ||
865 | + error_setg(errp, "%s: invalid group %s", __func__, group); | ||
866 | + return; | ||
867 | + } | ||
868 | + pin = pin + group_idx * GPIOS_PER_GROUP; | ||
869 | + aspeed_gpio_set_pin_level(s, set_idx, pin, level); | ||
870 | +} | ||
871 | + | ||
872 | +/****************** Setup functions ******************/ | ||
873 | +static const GPIOSetProperties ast2400_set_props[] = { | ||
874 | + [0] = {0xffffffff, 0xffffffff, {"A", "B", "C", "D"} }, | ||
875 | + [1] = {0xffffffff, 0xffffffff, {"E", "F", "G", "H"} }, | ||
876 | + [2] = {0xffffffff, 0xffffffff, {"I", "J", "K", "L"} }, | ||
877 | + [3] = {0xffffffff, 0xffffffff, {"M", "N", "O", "P"} }, | ||
878 | + [4] = {0xffffffff, 0xffffffff, {"Q", "R", "S", "T"} }, | ||
879 | + [5] = {0xffffffff, 0x0000ffff, {"U", "V", "W", "X"} }, | ||
880 | + [6] = {0x0000000f, 0x0fffff0f, {"Y", "Z", "AA", "AB"} }, | ||
881 | +}; | ||
882 | + | ||
883 | +static const GPIOSetProperties ast2500_set_props[] = { | ||
884 | + [0] = {0xffffffff, 0xffffffff, {"A", "B", "C", "D"} }, | ||
885 | + [1] = {0xffffffff, 0xffffffff, {"E", "F", "G", "H"} }, | ||
886 | + [2] = {0xffffffff, 0xffffffff, {"I", "J", "K", "L"} }, | ||
887 | + [3] = {0xffffffff, 0xffffffff, {"M", "N", "O", "P"} }, | ||
888 | + [4] = {0xffffffff, 0xffffffff, {"Q", "R", "S", "T"} }, | ||
889 | + [5] = {0xffffffff, 0x0000ffff, {"U", "V", "W", "X"} }, | ||
890 | + [6] = {0xffffff0f, 0x0fffff0f, {"Y", "Z", "AA", "AB"} }, | ||
891 | + [7] = {0x000000ff, 0x000000ff, {"AC"} }, | ||
892 | +}; | ||
893 | + | ||
894 | +static const MemoryRegionOps aspeed_gpio_ops = { | ||
895 | + .read = aspeed_gpio_read, | ||
896 | + .write = aspeed_gpio_write, | ||
897 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
898 | + .valid.min_access_size = 4, | ||
899 | + .valid.max_access_size = 4, | ||
900 | +}; | ||
901 | + | ||
902 | +static void aspeed_gpio_reset(DeviceState *dev) | ||
903 | +{ | ||
904 | + AspeedGPIOState *s = ASPEED_GPIO(dev); | ||
905 | + | ||
906 | + /* TODO: respect the reset tolerance registers */ | ||
907 | + memset(s->sets, 0, sizeof(s->sets)); | ||
908 | +} | ||
909 | + | ||
910 | +static void aspeed_gpio_realize(DeviceState *dev, Error **errp) | ||
911 | +{ | ||
912 | + AspeedGPIOState *s = ASPEED_GPIO(dev); | ||
913 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
914 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
915 | + int pin; | ||
916 | + | ||
917 | + /* Interrupt parent line */ | ||
918 | + sysbus_init_irq(sbd, &s->irq); | ||
919 | + | ||
920 | + /* Individual GPIOs */ | ||
921 | + for (pin = 0; pin < agc->nr_gpio_pins; pin++) { | ||
922 | + sysbus_init_irq(sbd, &s->gpios[pin]); | ||
923 | + } | ||
924 | + | ||
925 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, | ||
926 | + TYPE_ASPEED_GPIO, GPIO_3_6V_MEM_SIZE); | ||
927 | + | ||
928 | + sysbus_init_mmio(sbd, &s->iomem); | ||
929 | +} | ||
930 | + | ||
931 | +static void aspeed_gpio_init(Object *obj) | ||
932 | +{ | ||
933 | + AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
934 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
935 | + int pin; | ||
936 | + | ||
937 | + for (pin = 0; pin < agc->nr_gpio_pins; pin++) { | ||
938 | + char *name; | ||
939 | + int set_idx = pin / GPIOS_PER_SET; | ||
940 | + int pin_idx = aspeed_adjust_pin(s, pin) - (set_idx * GPIOS_PER_SET); | ||
941 | + int group_idx = pin_idx >> GPIO_GROUP_SHIFT; | ||
942 | + const GPIOSetProperties *props = &agc->props[set_idx]; | ||
943 | + | ||
944 | + name = g_strdup_printf("gpio%s%d", props->group_label[group_idx], | ||
945 | + pin_idx % GPIOS_PER_GROUP); | ||
946 | + object_property_add(obj, name, "bool", aspeed_gpio_get_pin, | ||
947 | + aspeed_gpio_set_pin, NULL, NULL, NULL); | ||
948 | + } | ||
949 | +} | ||
950 | + | ||
951 | +static const VMStateDescription vmstate_gpio_regs = { | ||
952 | + .name = TYPE_ASPEED_GPIO"/regs", | ||
953 | + .version_id = 1, | ||
954 | + .minimum_version_id = 1, | ||
955 | + .fields = (VMStateField[]) { | ||
956 | + VMSTATE_UINT32(data_value, GPIOSets), | ||
957 | + VMSTATE_UINT32(data_read, GPIOSets), | ||
958 | + VMSTATE_UINT32(direction, GPIOSets), | ||
959 | + VMSTATE_UINT32(int_enable, GPIOSets), | ||
960 | + VMSTATE_UINT32(int_sens_0, GPIOSets), | ||
961 | + VMSTATE_UINT32(int_sens_1, GPIOSets), | ||
962 | + VMSTATE_UINT32(int_sens_2, GPIOSets), | ||
963 | + VMSTATE_UINT32(int_status, GPIOSets), | ||
964 | + VMSTATE_UINT32(reset_tol, GPIOSets), | ||
965 | + VMSTATE_UINT32(cmd_source_0, GPIOSets), | ||
966 | + VMSTATE_UINT32(cmd_source_1, GPIOSets), | ||
967 | + VMSTATE_UINT32(debounce_1, GPIOSets), | ||
968 | + VMSTATE_UINT32(debounce_2, GPIOSets), | ||
969 | + VMSTATE_UINT32(input_mask, GPIOSets), | ||
970 | + VMSTATE_END_OF_LIST(), | ||
971 | + } | ||
972 | +}; | ||
973 | + | ||
974 | +static const VMStateDescription vmstate_aspeed_gpio = { | ||
975 | + .name = TYPE_ASPEED_GPIO, | ||
976 | + .version_id = 1, | ||
977 | + .minimum_version_id = 1, | ||
978 | + .fields = (VMStateField[]) { | ||
979 | + VMSTATE_STRUCT_ARRAY(sets, AspeedGPIOState, ASPEED_GPIO_MAX_NR_SETS, | ||
980 | + 1, vmstate_gpio_regs, GPIOSets), | ||
981 | + VMSTATE_UINT32_ARRAY(debounce_regs, AspeedGPIOState, | ||
982 | + ASPEED_GPIO_NR_DEBOUNCE_REGS), | ||
983 | + VMSTATE_END_OF_LIST(), | ||
984 | + } | ||
985 | +}; | ||
986 | + | ||
987 | +static void aspeed_gpio_class_init(ObjectClass *klass, void *data) | ||
988 | +{ | ||
989 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
990 | + | ||
991 | + dc->realize = aspeed_gpio_realize; | ||
992 | + dc->reset = aspeed_gpio_reset; | ||
993 | + dc->desc = "Aspeed GPIO Controller"; | ||
994 | + dc->vmsd = &vmstate_aspeed_gpio; | ||
995 | +} | ||
996 | + | ||
997 | +static void aspeed_gpio_ast2400_class_init(ObjectClass *klass, void *data) | ||
998 | +{ | ||
999 | + AspeedGPIOClass *agc = ASPEED_GPIO_CLASS(klass); | ||
1000 | + | ||
1001 | + agc->props = ast2400_set_props; | ||
1002 | + agc->nr_gpio_pins = 216; | ||
1003 | + agc->nr_gpio_sets = 7; | ||
1004 | + agc->gap = 196; | ||
1005 | + agc->reg_table = aspeed_3_6v_gpios; | ||
1006 | +} | ||
1007 | + | ||
1008 | +static void aspeed_gpio_2500_class_init(ObjectClass *klass, void *data) | ||
1009 | +{ | ||
1010 | + AspeedGPIOClass *agc = ASPEED_GPIO_CLASS(klass); | ||
1011 | + | ||
1012 | + agc->props = ast2500_set_props; | ||
1013 | + agc->nr_gpio_pins = 228; | ||
1014 | + agc->nr_gpio_sets = 8; | ||
1015 | + agc->gap = 220; | ||
1016 | + agc->reg_table = aspeed_3_6v_gpios; | ||
1017 | +} | ||
1018 | + | ||
1019 | +static const TypeInfo aspeed_gpio_info = { | ||
1020 | + .name = TYPE_ASPEED_GPIO, | ||
1021 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1022 | + .instance_size = sizeof(AspeedGPIOState), | ||
1023 | + .class_size = sizeof(AspeedGPIOClass), | ||
1024 | + .class_init = aspeed_gpio_class_init, | ||
1025 | + .abstract = true, | ||
1026 | +}; | ||
1027 | + | ||
1028 | +static const TypeInfo aspeed_gpio_ast2400_info = { | ||
1029 | + .name = TYPE_ASPEED_GPIO "-ast2400", | ||
1030 | + .parent = TYPE_ASPEED_GPIO, | ||
1031 | + .class_init = aspeed_gpio_ast2400_class_init, | ||
1032 | + .instance_init = aspeed_gpio_init, | ||
1033 | +}; | ||
1034 | + | ||
1035 | +static const TypeInfo aspeed_gpio_ast2500_info = { | ||
1036 | + .name = TYPE_ASPEED_GPIO "-ast2500", | ||
1037 | + .parent = TYPE_ASPEED_GPIO, | ||
1038 | + .class_init = aspeed_gpio_2500_class_init, | ||
1039 | + .instance_init = aspeed_gpio_init, | ||
1040 | +}; | ||
1041 | + | ||
1042 | +static void aspeed_gpio_register_types(void) | ||
1043 | +{ | ||
1044 | + type_register_static(&aspeed_gpio_info); | ||
1045 | + type_register_static(&aspeed_gpio_ast2400_info); | ||
1046 | + type_register_static(&aspeed_gpio_ast2500_info); | ||
1047 | +} | ||
1048 | + | ||
1049 | +type_init(aspeed_gpio_register_types); | ||
30 | -- | 1050 | -- |
31 | 2.17.0 | 1051 | 2.20.1 |
32 | 1052 | ||
33 | 1053 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Rashmica Gupta <rashmica.g@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | These were missed out from the rest of the half-precision work. | 3 | Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> |
4 | 4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
5 | Cc: qemu-stable@nongnu.org | 5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Message-id: 20190904070506.1052-3-clg@kaod.org |
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180512003217.9105-10-richard.henderson@linaro.org | ||
11 | [rth: Fix erroneous check vs type] | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 8 | --- |
15 | target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------ | 9 | include/hw/arm/aspeed_soc.h | 3 +++ |
16 | 1 file changed, 25 insertions(+), 6 deletions(-) | 10 | hw/arm/aspeed_soc.c | 17 +++++++++++++++++ |
11 | 2 files changed, 20 insertions(+) | ||
17 | 12 | ||
18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate-a64.c | 15 | --- a/include/hw/arm/aspeed_soc.h |
21 | +++ b/target/arm/translate-a64.c | 16 | +++ b/include/hw/arm/aspeed_soc.h |
22 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ |
23 | unsigned int mos, type, rm, cond, rn, rd; | 18 | #include "hw/watchdog/wdt_aspeed.h" |
24 | TCGv_i64 t_true, t_false, t_zero; | 19 | #include "hw/net/ftgmac100.h" |
25 | DisasCompare64 c; | 20 | #include "target/arm/cpu.h" |
26 | + TCGMemOp sz; | 21 | +#include "hw/gpio/aspeed_gpio.h" |
27 | 22 | ||
28 | mos = extract32(insn, 29, 3); | 23 | #define ASPEED_SPIS_NUM 2 |
29 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | 24 | #define ASPEED_WDTS_NUM 3 |
30 | + type = extract32(insn, 22, 2); | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
31 | rm = extract32(insn, 16, 5); | 26 | AspeedSDMCState sdmc; |
32 | cond = extract32(insn, 12, 4); | 27 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; |
33 | rn = extract32(insn, 5, 5); | 28 | FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; |
34 | rd = extract32(insn, 0, 5); | 29 | + AspeedGPIOState gpio; |
35 | 30 | } AspeedSoCState; | |
36 | - if (mos || type > 1) { | 31 | |
37 | + if (mos) { | 32 | #define TYPE_ASPEED_SOC "aspeed-soc" |
38 | + unallocated_encoding(s); | 33 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
34 | int spis_num; | ||
35 | const char *fmc_typename; | ||
36 | const char **spi_typename; | ||
37 | + const char *gpio_typename; | ||
38 | int wdts_num; | ||
39 | const int *irqmap; | ||
40 | const hwaddr *memmap; | ||
41 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/aspeed_soc.c | ||
44 | +++ b/hw/arm/aspeed_soc.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
46 | .spis_num = 1, | ||
47 | .fmc_typename = "aspeed.smc.fmc", | ||
48 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
49 | + .gpio_typename = "aspeed.gpio-ast2400", | ||
50 | .wdts_num = 2, | ||
51 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
52 | .memmap = aspeed_soc_ast2400_memmap, | ||
53 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
54 | .spis_num = 1, | ||
55 | .fmc_typename = "aspeed.smc.fmc", | ||
56 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
57 | + .gpio_typename = "aspeed.gpio-ast2400", | ||
58 | .wdts_num = 2, | ||
59 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
60 | .memmap = aspeed_soc_ast2400_memmap, | ||
61 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
62 | .spis_num = 1, | ||
63 | .fmc_typename = "aspeed.smc.fmc", | ||
64 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
65 | + .gpio_typename = "aspeed.gpio-ast2400", | ||
66 | .wdts_num = 2, | ||
67 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
68 | .memmap = aspeed_soc_ast2400_memmap, | ||
69 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
70 | .spis_num = 2, | ||
71 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
72 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
73 | + .gpio_typename = "aspeed.gpio-ast2500", | ||
74 | .wdts_num = 3, | ||
75 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
76 | .memmap = aspeed_soc_ast2500_memmap, | ||
77 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
78 | |||
79 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
80 | TYPE_ASPEED_XDMA); | ||
81 | + | ||
82 | + sysbus_init_child_obj(obj, "gpio", OBJECT(&s->gpio), sizeof(s->gpio), | ||
83 | + sc->info->gpio_typename); | ||
84 | } | ||
85 | |||
86 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
87 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
88 | sc->info->memmap[ASPEED_XDMA]); | ||
89 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, | ||
90 | aspeed_soc_get_irq(s, ASPEED_XDMA)); | ||
91 | + | ||
92 | + /* GPIO */ | ||
93 | + object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); | ||
94 | + if (err) { | ||
95 | + error_propagate(errp, err); | ||
39 | + return; | 96 | + return; |
40 | + } | 97 | + } |
41 | + | 98 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->info->memmap[ASPEED_GPIO]); |
42 | + switch (type) { | 99 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, |
43 | + case 0: | 100 | + aspeed_soc_get_irq(s, ASPEED_GPIO)); |
44 | + sz = MO_32; | 101 | } |
45 | + break; | 102 | static Property aspeed_soc_properties[] = { |
46 | + case 1: | 103 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), |
47 | + sz = MO_64; | ||
48 | + break; | ||
49 | + case 3: | ||
50 | + sz = MO_16; | ||
51 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
52 | + break; | ||
53 | + } | ||
54 | + /* fallthru */ | ||
55 | + default: | ||
56 | unallocated_encoding(s); | ||
57 | return; | ||
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | - /* Zero extend sreg inputs to 64 bits now. */ | ||
64 | + /* Zero extend sreg & hreg inputs to 64 bits now. */ | ||
65 | t_true = tcg_temp_new_i64(); | ||
66 | t_false = tcg_temp_new_i64(); | ||
67 | - read_vec_element(s, t_true, rn, 0, type ? MO_64 : MO_32); | ||
68 | - read_vec_element(s, t_false, rm, 0, type ? MO_64 : MO_32); | ||
69 | + read_vec_element(s, t_true, rn, 0, sz); | ||
70 | + read_vec_element(s, t_false, rm, 0, sz); | ||
71 | |||
72 | a64_test_cc(&c, cond); | ||
73 | t_zero = tcg_const_i64(0); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
75 | tcg_temp_free_i64(t_false); | ||
76 | a64_free_cc(&c); | ||
77 | |||
78 | - /* Note that sregs write back zeros to the high bits, | ||
79 | + /* Note that sregs & hregs write back zeros to the high bits, | ||
80 | and we've already done the zero-extension. */ | ||
81 | write_fp_dreg(s, rd, t_true); | ||
82 | tcg_temp_free_i64(t_true); | ||
83 | -- | 104 | -- |
84 | 2.17.0 | 105 | 2.20.1 |
85 | 106 | ||
86 | 107 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Adding the fp16 moves to/from general registers. | 3 | There are no QEMU Aspeed machines using the SoCs "ast2400-a0" or |
4 | "ast2400". | ||
4 | 5 | ||
5 | Cc: qemu-stable@nongnu.org | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20190904070506.1052-4-clg@kaod.org |
7 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Message-id: 20180512003217.9105-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 21 +++++++++++++++++++++ | 11 | hw/arm/aspeed_soc.c | 26 -------------------------- |
13 | 1 file changed, 21 insertions(+) | 12 | 1 file changed, 26 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 16 | --- a/hw/arm/aspeed_soc.c |
18 | +++ b/target/arm/translate-a64.c | 17 | +++ b/hw/arm/aspeed_soc.c |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | 18 | @@ -XXX,XX +XXX,XX @@ static const char *aspeed_soc_ast2500_typenames[] = { |
20 | tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd)); | 19 | |
21 | clear_vec_high(s, true, rd); | 20 | static const AspeedSoCInfo aspeed_socs[] = { |
22 | break; | 21 | { |
23 | + case 3: | 22 | - .name = "ast2400-a0", |
24 | + /* 16 bit */ | 23 | - .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
25 | + tmp = tcg_temp_new_i64(); | 24 | - .silicon_rev = AST2400_A0_SILICON_REV, |
26 | + tcg_gen_ext16u_i64(tmp, tcg_rn); | 25 | - .sram_size = 0x8000, |
27 | + write_fp_dreg(s, rd, tmp); | 26 | - .spis_num = 1, |
28 | + tcg_temp_free_i64(tmp); | 27 | - .fmc_typename = "aspeed.smc.fmc", |
29 | + break; | 28 | - .spi_typename = aspeed_soc_ast2400_typenames, |
30 | + default: | 29 | - .gpio_typename = "aspeed.gpio-ast2400", |
31 | + g_assert_not_reached(); | 30 | - .wdts_num = 2, |
32 | } | 31 | - .irqmap = aspeed_soc_ast2400_irqmap, |
33 | } else { | 32 | - .memmap = aspeed_soc_ast2400_memmap, |
34 | TCGv_i64 tcg_rd = cpu_reg(s, rd); | 33 | - .num_cpus = 1, |
35 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | 34 | - }, { |
36 | /* 64 bits from top half */ | 35 | .name = "ast2400-a1", |
37 | tcg_gen_ld_i64(tcg_rd, cpu_env, fp_reg_hi_offset(s, rn)); | 36 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
38 | break; | 37 | .silicon_rev = AST2400_A1_SILICON_REV, |
39 | + case 3: | 38 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { |
40 | + /* 16 bit */ | 39 | .irqmap = aspeed_soc_ast2400_irqmap, |
41 | + tcg_gen_ld16u_i64(tcg_rd, cpu_env, fp_reg_offset(s, rn, MO_16)); | 40 | .memmap = aspeed_soc_ast2400_memmap, |
42 | + break; | 41 | .num_cpus = 1, |
43 | + default: | 42 | - }, { |
44 | + g_assert_not_reached(); | 43 | - .name = "ast2400", |
45 | } | 44 | - .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
46 | } | 45 | - .silicon_rev = AST2400_A0_SILICON_REV, |
47 | } | 46 | - .sram_size = 0x8000, |
48 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 47 | - .spis_num = 1, |
49 | case 0xa: /* 64 bit */ | 48 | - .fmc_typename = "aspeed.smc.fmc", |
50 | case 0xd: /* 64 bit to top half of quad */ | 49 | - .spi_typename = aspeed_soc_ast2400_typenames, |
51 | break; | 50 | - .gpio_typename = "aspeed.gpio-ast2400", |
52 | + case 0x6: /* 16-bit float, 32-bit int */ | 51 | - .wdts_num = 2, |
53 | + case 0xe: /* 16-bit float, 64-bit int */ | 52 | - .irqmap = aspeed_soc_ast2400_irqmap, |
54 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 53 | - .memmap = aspeed_soc_ast2400_memmap, |
55 | + break; | 54 | - .num_cpus = 1, |
56 | + } | 55 | }, { |
57 | + /* fallthru */ | 56 | .name = "ast2500-a1", |
58 | default: | 57 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), |
59 | /* all other sf/type/rmode combinations are invalid */ | ||
60 | unallocated_encoding(s); | ||
61 | -- | 58 | -- |
62 | 2.17.0 | 59 | 2.20.1 |
63 | 60 | ||
64 | 61 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Per the Physical Layer Simplified Spec. "4.3.10.4 Switch Function Status": | 3 | Improve the naming of the different controller models to ease their |
4 | generation when initializing the SoC. The rename of the SMC types is | ||
5 | breaking migration compatibility. | ||
4 | 6 | ||
5 | The block length is predefined to 512 bits | 7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | 8 | Message-id: 20190904070506.1052-5-clg@kaod.org | |
7 | and "4.10.2 SD Status": | ||
8 | |||
9 | The SD Status contains status bits that are related to the SD Memory Card | ||
10 | proprietary features and may be used for future application-specific usage. | ||
11 | The size of the SD Status is one data block of 512 bit. The content of this | ||
12 | register is transmitted to the Host over the DAT bus along with a 16-bit CRC. | ||
13 | |||
14 | Thus the 16-bit CRC goes at offset 64. | ||
15 | |||
16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20180509060104.4458-3-f4bug@amsat.org | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 11 | --- |
21 | hw/sd/sd.c | 2 +- | 12 | include/hw/arm/aspeed_soc.h | 3 --- |
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | hw/arm/aspeed_soc.c | 25 ++++++++++++------------- |
14 | hw/ssi/aspeed_smc.c | 12 ++++++------ | ||
15 | 3 files changed, 18 insertions(+), 22 deletions(-) | ||
23 | 16 | ||
24 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/sd/sd.c | 19 | --- a/include/hw/arm/aspeed_soc.h |
27 | +++ b/hw/sd/sd.c | 20 | +++ b/include/hw/arm/aspeed_soc.h |
28 | @@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg) | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
29 | sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); | 22 | uint32_t silicon_rev; |
23 | uint64_t sram_size; | ||
24 | int spis_num; | ||
25 | - const char *fmc_typename; | ||
26 | - const char **spi_typename; | ||
27 | - const char *gpio_typename; | ||
28 | int wdts_num; | ||
29 | const int *irqmap; | ||
30 | const hwaddr *memmap; | ||
31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/aspeed_soc.c | ||
34 | +++ b/hw/arm/aspeed_soc.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
36 | |||
37 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
38 | |||
39 | -static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; | ||
40 | -static const char *aspeed_soc_ast2500_typenames[] = { | ||
41 | - "aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" }; | ||
42 | - | ||
43 | static const AspeedSoCInfo aspeed_socs[] = { | ||
44 | { | ||
45 | .name = "ast2400-a1", | ||
46 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
47 | .silicon_rev = AST2400_A1_SILICON_REV, | ||
48 | .sram_size = 0x8000, | ||
49 | .spis_num = 1, | ||
50 | - .fmc_typename = "aspeed.smc.fmc", | ||
51 | - .spi_typename = aspeed_soc_ast2400_typenames, | ||
52 | - .gpio_typename = "aspeed.gpio-ast2400", | ||
53 | .wdts_num = 2, | ||
54 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
55 | .memmap = aspeed_soc_ast2400_memmap, | ||
56 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
57 | .silicon_rev = AST2500_A1_SILICON_REV, | ||
58 | .sram_size = 0x9000, | ||
59 | .spis_num = 2, | ||
60 | - .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
61 | - .spi_typename = aspeed_soc_ast2500_typenames, | ||
62 | - .gpio_typename = "aspeed.gpio-ast2500", | ||
63 | .wdts_num = 3, | ||
64 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
65 | .memmap = aspeed_soc_ast2500_memmap, | ||
66 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
67 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
68 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
69 | int i; | ||
70 | + char socname[8]; | ||
71 | + char typename[64]; | ||
72 | + | ||
73 | + if (sscanf(sc->info->name, "%7s", socname) != 1) { | ||
74 | + g_assert_not_reached(); | ||
75 | + } | ||
76 | |||
77 | for (i = 0; i < sc->info->num_cpus; i++) { | ||
78 | object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]), | ||
79 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
80 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | ||
81 | TYPE_ASPEED_I2C); | ||
82 | |||
83 | + snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname); | ||
84 | sysbus_init_child_obj(obj, "fmc", OBJECT(&s->fmc), sizeof(s->fmc), | ||
85 | - sc->info->fmc_typename); | ||
86 | + typename); | ||
87 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
88 | &error_abort); | ||
89 | |||
90 | for (i = 0; i < sc->info->spis_num; i++) { | ||
91 | + snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
92 | sysbus_init_child_obj(obj, "spi[*]", OBJECT(&s->spi[i]), | ||
93 | - sizeof(s->spi[i]), sc->info->spi_typename[i]); | ||
94 | + sizeof(s->spi[i]), typename); | ||
30 | } | 95 | } |
31 | memset(&sd->data[17], 0, 47); | 96 | |
32 | - stw_be_p(sd->data + 65, sd_crc16(sd->data, 64)); | 97 | sysbus_init_child_obj(obj, "sdmc", OBJECT(&s->sdmc), sizeof(s->sdmc), |
33 | + stw_be_p(sd->data + 64, sd_crc16(sd->data, 64)); | 98 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
99 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
100 | TYPE_ASPEED_XDMA); | ||
101 | |||
102 | + snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname); | ||
103 | sysbus_init_child_obj(obj, "gpio", OBJECT(&s->gpio), sizeof(s->gpio), | ||
104 | - sc->info->gpio_typename); | ||
105 | + typename); | ||
34 | } | 106 | } |
35 | 107 | ||
36 | static inline bool sd_wp_addr(SDState *sd, uint64_t addr) | 108 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
109 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/hw/ssi/aspeed_smc.c | ||
112 | +++ b/hw/ssi/aspeed_smc.c | ||
113 | @@ -XXX,XX +XXX,XX @@ static const AspeedSegments aspeed_segments_ast2500_spi2[] = { | ||
114 | |||
115 | static const AspeedSMCController controllers[] = { | ||
116 | { | ||
117 | - .name = "aspeed.smc.smc", | ||
118 | + .name = "aspeed.smc-ast2400", | ||
119 | .r_conf = R_CONF, | ||
120 | .r_ce_ctrl = R_CE_CTRL, | ||
121 | .r_ctrl0 = R_CTRL0, | ||
122 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
123 | .has_dma = false, | ||
124 | .nregs = ASPEED_SMC_R_SMC_MAX, | ||
125 | }, { | ||
126 | - .name = "aspeed.smc.fmc", | ||
127 | + .name = "aspeed.fmc-ast2400", | ||
128 | .r_conf = R_CONF, | ||
129 | .r_ce_ctrl = R_CE_CTRL, | ||
130 | .r_ctrl0 = R_CTRL0, | ||
131 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
132 | .has_dma = true, | ||
133 | .nregs = ASPEED_SMC_R_MAX, | ||
134 | }, { | ||
135 | - .name = "aspeed.smc.spi", | ||
136 | + .name = "aspeed.spi1-ast2400", | ||
137 | .r_conf = R_SPI_CONF, | ||
138 | .r_ce_ctrl = 0xff, | ||
139 | .r_ctrl0 = R_SPI_CTRL0, | ||
140 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
141 | .has_dma = false, | ||
142 | .nregs = ASPEED_SMC_R_SPI_MAX, | ||
143 | }, { | ||
144 | - .name = "aspeed.smc.ast2500-fmc", | ||
145 | + .name = "aspeed.fmc-ast2500", | ||
146 | .r_conf = R_CONF, | ||
147 | .r_ce_ctrl = R_CE_CTRL, | ||
148 | .r_ctrl0 = R_CTRL0, | ||
149 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
150 | .has_dma = true, | ||
151 | .nregs = ASPEED_SMC_R_MAX, | ||
152 | }, { | ||
153 | - .name = "aspeed.smc.ast2500-spi1", | ||
154 | + .name = "aspeed.spi1-ast2500", | ||
155 | .r_conf = R_CONF, | ||
156 | .r_ce_ctrl = R_CE_CTRL, | ||
157 | .r_ctrl0 = R_CTRL0, | ||
158 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
159 | .has_dma = false, | ||
160 | .nregs = ASPEED_SMC_R_MAX, | ||
161 | }, { | ||
162 | - .name = "aspeed.smc.ast2500-spi2", | ||
163 | + .name = "aspeed.spi2-ast2500", | ||
164 | .r_conf = R_CONF, | ||
165 | .r_ce_ctrl = R_CE_CTRL, | ||
166 | .r_ctrl0 = R_CTRL0, | ||
37 | -- | 167 | -- |
38 | 2.17.0 | 168 | 2.20.1 |
39 | 169 | ||
40 | 170 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | 3 | The FMC controller on the Aspeed SoCs support DMA to access the flash |
4 | modules. It can operate in a normal mode, to copy to or from the flash | ||
5 | module mapping window, or in a checksum calculation mode, to evaluate | ||
6 | the best clock settings for reads. | ||
7 | |||
8 | The model introduces two custom address spaces for DMAs: one for the | ||
9 | AHB window of the FMC flash devices and one for the DRAM. The latter | ||
10 | is populated using a "dram" link set from the machine with the RAM | ||
11 | container region. | ||
12 | |||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Acked-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190904070506.1052-6-clg@kaod.org | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Message-id: 20180512003217.9105-6-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 18 | --- |
10 | target/arm/translate-a64.c | 30 ++++++++++++++---------------- | 19 | include/hw/ssi/aspeed_smc.h | 6 + |
11 | 1 file changed, 14 insertions(+), 16 deletions(-) | 20 | hw/arm/aspeed.c | 2 + |
12 | 21 | hw/arm/aspeed_soc.c | 2 + | |
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 22 | hw/ssi/aspeed_smc.c | 222 +++++++++++++++++++++++++++++++++++- |
23 | 4 files changed, 226 insertions(+), 6 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 27 | --- a/include/hw/ssi/aspeed_smc.h |
16 | +++ b/target/arm/translate-a64.c | 28 | +++ b/include/hw/ssi/aspeed_smc.h |
17 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) | 29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCController { |
18 | return v; | 30 | hwaddr flash_window_base; |
31 | uint32_t flash_window_size; | ||
32 | bool has_dma; | ||
33 | + hwaddr dma_flash_mask; | ||
34 | + hwaddr dma_dram_mask; | ||
35 | uint32_t nregs; | ||
36 | } AspeedSMCController; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { | ||
39 | /* for DMA support */ | ||
40 | uint64_t sdram_base; | ||
41 | |||
42 | + AddressSpace flash_as; | ||
43 | + MemoryRegion *dram_mr; | ||
44 | + AddressSpace dram_as; | ||
45 | + | ||
46 | AspeedSMCFlash *flashes; | ||
47 | |||
48 | uint8_t snoop_index; | ||
49 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/aspeed.c | ||
52 | +++ b/hw/arm/aspeed.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
54 | &error_abort); | ||
55 | object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", | ||
56 | &error_abort); | ||
57 | + object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container), | ||
58 | + "dram", &error_abort); | ||
59 | if (machine->kernel_filename) { | ||
60 | /* | ||
61 | * When booting with a -kernel command line there is no u-boot | ||
62 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/arm/aspeed_soc.c | ||
65 | +++ b/hw/arm/aspeed_soc.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
67 | typename); | ||
68 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
69 | &error_abort); | ||
70 | + object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | ||
71 | + &error_abort); | ||
72 | |||
73 | for (i = 0; i < sc->info->spis_num; i++) { | ||
74 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
75 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/ssi/aspeed_smc.c | ||
78 | +++ b/hw/ssi/aspeed_smc.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | #include "qemu/log.h" | ||
81 | #include "qemu/module.h" | ||
82 | #include "qemu/error-report.h" | ||
83 | +#include "qapi/error.h" | ||
84 | +#include "exec/address-spaces.h" | ||
85 | |||
86 | #include "hw/irq.h" | ||
87 | #include "hw/qdev-properties.h" | ||
88 | @@ -XXX,XX +XXX,XX @@ | ||
89 | #define DMA_CTRL_FREQ_SHIFT 4 | ||
90 | #define DMA_CTRL_MODE (1 << 3) | ||
91 | #define DMA_CTRL_CKSUM (1 << 2) | ||
92 | -#define DMA_CTRL_DIR (1 << 1) | ||
93 | -#define DMA_CTRL_EN (1 << 0) | ||
94 | +#define DMA_CTRL_WRITE (1 << 1) | ||
95 | +#define DMA_CTRL_ENABLE (1 << 0) | ||
96 | |||
97 | /* DMA Flash Side Address */ | ||
98 | #define R_DMA_FLASH_ADDR (0x84 / 4) | ||
99 | @@ -XXX,XX +XXX,XX @@ | ||
100 | #define ASPEED_SOC_SPI_FLASH_BASE 0x30000000 | ||
101 | #define ASPEED_SOC_SPI2_FLASH_BASE 0x38000000 | ||
102 | |||
103 | +/* | ||
104 | + * DMA DRAM addresses should be 4 bytes aligned and the valid address | ||
105 | + * range is 0x40000000 - 0x5FFFFFFF (AST2400) | ||
106 | + * 0x80000000 - 0xBFFFFFFF (AST2500) | ||
107 | + * | ||
108 | + * DMA flash addresses should be 4 bytes aligned and the valid address | ||
109 | + * range is 0x20000000 - 0x2FFFFFFF. | ||
110 | + * | ||
111 | + * DMA length is from 4 bytes to 32MB | ||
112 | + * 0: 4 bytes | ||
113 | + * 0x7FFFFF: 32M bytes | ||
114 | + */ | ||
115 | +#define DMA_DRAM_ADDR(s, val) ((s)->sdram_base | \ | ||
116 | + ((val) & (s)->ctrl->dma_dram_mask)) | ||
117 | +#define DMA_FLASH_ADDR(s, val) ((s)->ctrl->flash_window_base | \ | ||
118 | + ((val) & (s)->ctrl->dma_flash_mask)) | ||
119 | +#define DMA_LENGTH(val) ((val) & 0x01FFFFFC) | ||
120 | + | ||
121 | /* Flash opcodes. */ | ||
122 | #define SPI_OP_READ 0x03 /* Read data bytes (low frequency) */ | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
125 | .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE, | ||
126 | .flash_window_size = 0x10000000, | ||
127 | .has_dma = true, | ||
128 | + .dma_flash_mask = 0x0FFFFFFC, | ||
129 | + .dma_dram_mask = 0x1FFFFFFC, | ||
130 | .nregs = ASPEED_SMC_R_MAX, | ||
131 | }, { | ||
132 | .name = "aspeed.spi1-ast2400", | ||
133 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
134 | .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE, | ||
135 | .flash_window_size = 0x10000000, | ||
136 | .has_dma = true, | ||
137 | + .dma_flash_mask = 0x0FFFFFFC, | ||
138 | + .dma_dram_mask = 0x3FFFFFFC, | ||
139 | .nregs = ASPEED_SMC_R_MAX, | ||
140 | }, { | ||
141 | .name = "aspeed.spi1-ast2500", | ||
142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_reset(DeviceState *d) | ||
143 | |||
144 | memset(s->regs, 0, sizeof s->regs); | ||
145 | |||
146 | - /* Pretend DMA is done (u-boot initialization) */ | ||
147 | - s->regs[R_INTR_CTRL] = INTR_CTRL_DMA_STATUS; | ||
148 | - | ||
149 | /* Unselect all slaves */ | ||
150 | for (i = 0; i < s->num_cs; ++i) { | ||
151 | s->regs[s->r_ctrl0 + i] |= CTRL_CE_STOP_ACTIVE; | ||
152 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
153 | addr == s->r_ce_ctrl || | ||
154 | addr == R_INTR_CTRL || | ||
155 | addr == R_DUMMY_DATA || | ||
156 | + (s->ctrl->has_dma && addr == R_DMA_CTRL) || | ||
157 | + (s->ctrl->has_dma && addr == R_DMA_FLASH_ADDR) || | ||
158 | + (s->ctrl->has_dma && addr == R_DMA_DRAM_ADDR) || | ||
159 | + (s->ctrl->has_dma && addr == R_DMA_LEN) || | ||
160 | + (s->ctrl->has_dma && addr == R_DMA_CHECKSUM) || | ||
161 | (addr >= R_SEG_ADDR0 && addr < R_SEG_ADDR0 + s->ctrl->max_slaves) || | ||
162 | (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->ctrl->max_slaves)) { | ||
163 | return s->regs[addr]; | ||
164 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
165 | } | ||
19 | } | 166 | } |
20 | 167 | ||
21 | +static TCGv_i32 read_fp_hreg(DisasContext *s, int reg) | 168 | +/* |
22 | +{ | 169 | + * Accumulate the result of the reads to provide a checksum that will |
23 | + TCGv_i32 v = tcg_temp_new_i32(); | 170 | + * be used to validate the read timing settings. |
24 | + | 171 | + */ |
25 | + tcg_gen_ld16u_i32(v, cpu_env, fp_reg_offset(s, reg, MO_16)); | 172 | +static void aspeed_smc_dma_checksum(AspeedSMCState *s) |
26 | + return v; | 173 | +{ |
27 | +} | 174 | + MemTxResult result; |
28 | + | 175 | + uint32_t data; |
29 | /* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64). | 176 | + |
30 | * If SVE is not enabled, then there are only 128 bits in the vector. | 177 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_WRITE) { |
31 | */ | 178 | + qemu_log_mask(LOG_GUEST_ERROR, |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 179 | + "%s: invalid direction for DMA checksum\n", __func__); |
33 | static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | 180 | + return; |
181 | + } | ||
182 | + | ||
183 | + while (s->regs[R_DMA_LEN]) { | ||
184 | + data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
185 | + MEMTXATTRS_UNSPECIFIED, &result); | ||
186 | + if (result != MEMTX_OK) { | ||
187 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash read failed @%08x\n", | ||
188 | + __func__, s->regs[R_DMA_FLASH_ADDR]); | ||
189 | + return; | ||
190 | + } | ||
191 | + | ||
192 | + /* | ||
193 | + * When the DMA is on-going, the DMA registers are updated | ||
194 | + * with the current working addresses and length. | ||
195 | + */ | ||
196 | + s->regs[R_DMA_CHECKSUM] += data; | ||
197 | + s->regs[R_DMA_FLASH_ADDR] += 4; | ||
198 | + s->regs[R_DMA_LEN] -= 4; | ||
199 | + } | ||
200 | +} | ||
201 | + | ||
202 | +static void aspeed_smc_dma_rw(AspeedSMCState *s) | ||
203 | +{ | ||
204 | + MemTxResult result; | ||
205 | + uint32_t data; | ||
206 | + | ||
207 | + while (s->regs[R_DMA_LEN]) { | ||
208 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_WRITE) { | ||
209 | + data = address_space_ldl_le(&s->dram_as, s->regs[R_DMA_DRAM_ADDR], | ||
210 | + MEMTXATTRS_UNSPECIFIED, &result); | ||
211 | + if (result != MEMTX_OK) { | ||
212 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM read failed @%08x\n", | ||
213 | + __func__, s->regs[R_DMA_DRAM_ADDR]); | ||
214 | + return; | ||
215 | + } | ||
216 | + | ||
217 | + address_space_stl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
218 | + data, MEMTXATTRS_UNSPECIFIED, &result); | ||
219 | + if (result != MEMTX_OK) { | ||
220 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash write failed @%08x\n", | ||
221 | + __func__, s->regs[R_DMA_FLASH_ADDR]); | ||
222 | + return; | ||
223 | + } | ||
224 | + } else { | ||
225 | + data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
226 | + MEMTXATTRS_UNSPECIFIED, &result); | ||
227 | + if (result != MEMTX_OK) { | ||
228 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash read failed @%08x\n", | ||
229 | + __func__, s->regs[R_DMA_FLASH_ADDR]); | ||
230 | + return; | ||
231 | + } | ||
232 | + | ||
233 | + address_space_stl_le(&s->dram_as, s->regs[R_DMA_DRAM_ADDR], | ||
234 | + data, MEMTXATTRS_UNSPECIFIED, &result); | ||
235 | + if (result != MEMTX_OK) { | ||
236 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM write failed @%08x\n", | ||
237 | + __func__, s->regs[R_DMA_DRAM_ADDR]); | ||
238 | + return; | ||
239 | + } | ||
240 | + } | ||
241 | + | ||
242 | + /* | ||
243 | + * When the DMA is on-going, the DMA registers are updated | ||
244 | + * with the current working addresses and length. | ||
245 | + */ | ||
246 | + s->regs[R_DMA_FLASH_ADDR] += 4; | ||
247 | + s->regs[R_DMA_DRAM_ADDR] += 4; | ||
248 | + s->regs[R_DMA_LEN] -= 4; | ||
249 | + } | ||
250 | +} | ||
251 | + | ||
252 | +static void aspeed_smc_dma_stop(AspeedSMCState *s) | ||
253 | +{ | ||
254 | + /* | ||
255 | + * When the DMA is disabled, INTR_CTRL_DMA_STATUS=0 means the | ||
256 | + * engine is idle | ||
257 | + */ | ||
258 | + s->regs[R_INTR_CTRL] &= ~INTR_CTRL_DMA_STATUS; | ||
259 | + s->regs[R_DMA_CHECKSUM] = 0; | ||
260 | + | ||
261 | + /* | ||
262 | + * Lower the DMA irq in any case. The IRQ control register could | ||
263 | + * have been cleared before disabling the DMA. | ||
264 | + */ | ||
265 | + qemu_irq_lower(s->irq); | ||
266 | +} | ||
267 | + | ||
268 | +/* | ||
269 | + * When INTR_CTRL_DMA_STATUS=1, the DMA has completed and a new DMA | ||
270 | + * can start even if the result of the previous was not collected. | ||
271 | + */ | ||
272 | +static bool aspeed_smc_dma_in_progress(AspeedSMCState *s) | ||
273 | +{ | ||
274 | + return s->regs[R_DMA_CTRL] & DMA_CTRL_ENABLE && | ||
275 | + !(s->regs[R_INTR_CTRL] & INTR_CTRL_DMA_STATUS); | ||
276 | +} | ||
277 | + | ||
278 | +static void aspeed_smc_dma_done(AspeedSMCState *s) | ||
279 | +{ | ||
280 | + s->regs[R_INTR_CTRL] |= INTR_CTRL_DMA_STATUS; | ||
281 | + if (s->regs[R_INTR_CTRL] & INTR_CTRL_DMA_EN) { | ||
282 | + qemu_irq_raise(s->irq); | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +static void aspeed_smc_dma_ctrl(AspeedSMCState *s, uint64_t dma_ctrl) | ||
287 | +{ | ||
288 | + if (!(dma_ctrl & DMA_CTRL_ENABLE)) { | ||
289 | + s->regs[R_DMA_CTRL] = dma_ctrl; | ||
290 | + | ||
291 | + aspeed_smc_dma_stop(s); | ||
292 | + return; | ||
293 | + } | ||
294 | + | ||
295 | + if (aspeed_smc_dma_in_progress(s)) { | ||
296 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA in progress\n", __func__); | ||
297 | + return; | ||
298 | + } | ||
299 | + | ||
300 | + s->regs[R_DMA_CTRL] = dma_ctrl; | ||
301 | + | ||
302 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_CKSUM) { | ||
303 | + aspeed_smc_dma_checksum(s); | ||
304 | + } else { | ||
305 | + aspeed_smc_dma_rw(s); | ||
306 | + } | ||
307 | + | ||
308 | + aspeed_smc_dma_done(s); | ||
309 | +} | ||
310 | + | ||
311 | static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, | ||
312 | unsigned int size) | ||
34 | { | 313 | { |
35 | TCGv_ptr fpst = NULL; | 314 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, |
36 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); | 315 | } |
37 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); | 316 | } else if (addr == R_DUMMY_DATA) { |
38 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | 317 | s->regs[addr] = value & 0xff; |
39 | 318 | + } else if (addr == R_INTR_CTRL) { | |
40 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); | 319 | + s->regs[addr] = value; |
41 | - | 320 | + } else if (s->ctrl->has_dma && addr == R_DMA_CTRL) { |
42 | switch (opcode) { | 321 | + aspeed_smc_dma_ctrl(s, value); |
43 | case 0x0: /* FMOV */ | 322 | + } else if (s->ctrl->has_dma && addr == R_DMA_DRAM_ADDR) { |
44 | tcg_gen_mov_i32(tcg_res, tcg_op); | 323 | + s->regs[addr] = DMA_DRAM_ADDR(s, value); |
45 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) | 324 | + } else if (s->ctrl->has_dma && addr == R_DMA_FLASH_ADDR) { |
46 | tcg_temp_free_i64(tcg_op2); | 325 | + s->regs[addr] = DMA_FLASH_ADDR(s, value); |
47 | tcg_temp_free_i64(tcg_res); | 326 | + } else if (s->ctrl->has_dma && addr == R_DMA_LEN) { |
327 | + s->regs[addr] = DMA_LENGTH(value); | ||
48 | } else { | 328 | } else { |
49 | - TCGv_i32 tcg_op1 = tcg_temp_new_i32(); | 329 | qemu_log_mask(LOG_UNIMP, "%s: not implemented: 0x%" HWADDR_PRIx "\n", |
50 | - TCGv_i32 tcg_op2 = tcg_temp_new_i32(); | 330 | __func__, addr); |
51 | + TCGv_i32 tcg_op1 = read_fp_hreg(s, rn); | 331 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_smc_ops = { |
52 | + TCGv_i32 tcg_op2 = read_fp_hreg(s, rm); | 332 | .valid.unaligned = true, |
53 | TCGv_i64 tcg_res = tcg_temp_new_i64(); | 333 | }; |
54 | 334 | ||
55 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); | 335 | + |
56 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | 336 | +/* |
57 | - | 337 | + * Initialize the custom address spaces for DMAs |
58 | gen_helper_neon_mull_s16(tcg_res, tcg_op1, tcg_op2); | 338 | + */ |
59 | gen_helper_neon_addl_saturate_s32(tcg_res, cpu_env, tcg_res, tcg_res); | 339 | +static void aspeed_smc_dma_setup(AspeedSMCState *s, Error **errp) |
60 | 340 | +{ | |
61 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, | 341 | + char *name; |
62 | 342 | + | |
63 | fpst = get_fpstatus_ptr(true); | 343 | + if (!s->dram_mr) { |
64 | 344 | + error_setg(errp, TYPE_ASPEED_SMC ": 'dram' link not set"); | |
65 | - tcg_op1 = tcg_temp_new_i32(); | 345 | + return; |
66 | - tcg_op2 = tcg_temp_new_i32(); | 346 | + } |
67 | + tcg_op1 = read_fp_hreg(s, rn); | 347 | + |
68 | + tcg_op2 = read_fp_hreg(s, rm); | 348 | + name = g_strdup_printf("%s-dma-flash", s->ctrl->name); |
69 | tcg_res = tcg_temp_new_i32(); | 349 | + address_space_init(&s->flash_as, &s->mmio_flash, name); |
70 | 350 | + g_free(name); | |
71 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); | 351 | + |
72 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | 352 | + name = g_strdup_printf("%s-dma-dram", s->ctrl->name); |
73 | - | 353 | + address_space_init(&s->dram_as, s->dram_mr, name); |
74 | switch (fpopcode) { | 354 | + g_free(name); |
75 | case 0x03: /* FMULX */ | 355 | +} |
76 | gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); | 356 | + |
77 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) | 357 | static void aspeed_smc_realize(DeviceState *dev, Error **errp) |
358 | { | ||
359 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
360 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp) | ||
361 | s->num_cs = s->ctrl->max_slaves; | ||
78 | } | 362 | } |
79 | 363 | ||
80 | if (is_scalar) { | 364 | + /* DMA irq. Keep it first for the initialization in the SoC */ |
81 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); | 365 | + sysbus_init_irq(sbd, &s->irq); |
82 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); | 366 | + |
83 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | 367 | s->spi = ssi_create_bus(dev, "spi"); |
84 | 368 | ||
85 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); | 369 | /* Setup cs_lines for slaves */ |
86 | - | 370 | - sysbus_init_irq(sbd, &s->irq); |
87 | switch (fpop) { | 371 | s->cs_lines = g_new0(qemu_irq, s->num_cs); |
88 | case 0x1a: /* FCVTNS */ | 372 | ssi_auto_connect_slaves(dev, s->cs_lines, s->spi); |
89 | case 0x1b: /* FCVTMS */ | 373 | |
374 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp) | ||
375 | memory_region_add_subregion(&s->mmio_flash, offset, &fl->mmio); | ||
376 | offset += fl->size; | ||
377 | } | ||
378 | + | ||
379 | + /* DMA support */ | ||
380 | + if (s->ctrl->has_dma) { | ||
381 | + aspeed_smc_dma_setup(s, errp); | ||
382 | + } | ||
383 | } | ||
384 | |||
385 | static const VMStateDescription vmstate_aspeed_smc = { | ||
386 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { | ||
387 | static Property aspeed_smc_properties[] = { | ||
388 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), | ||
389 | DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), | ||
390 | + DEFINE_PROP_LINK("dram", AspeedSMCState, dram_mr, | ||
391 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
392 | DEFINE_PROP_END_OF_LIST(), | ||
393 | }; | ||
394 | |||
90 | -- | 395 | -- |
91 | 2.17.0 | 396 | 2.20.1 |
92 | 397 | ||
93 | 398 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | We missed all of the scalar fp16 fma operations. | 3 | When doing calibration, the SPI clock rate in the CE0 Control Register |
4 | and the read delay cycles in the Read Timing Compensation Register are | ||
5 | set using bit[11:4] of the DMA Control Register. | ||
4 | 6 | ||
5 | Cc: qemu-stable@nongnu.org | 7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Acked-by: Joel Stanley <joel@jms.id.au> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 10 | Message-id: 20190904070506.1052-7-clg@kaod.org |
9 | Message-id: 20180512003217.9105-8-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++ | 13 | hw/ssi/aspeed_smc.c | 64 ++++++++++++++++++++++++++++++++++++++++++++- |
13 | 1 file changed, 48 insertions(+) | 14 | 1 file changed, 63 insertions(+), 1 deletion(-) |
14 | 15 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 16 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 18 | --- a/hw/ssi/aspeed_smc.c |
18 | +++ b/target/arm/translate-a64.c | 19 | +++ b/hw/ssi/aspeed_smc.c |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1, | 20 | @@ -XXX,XX +XXX,XX @@ |
20 | tcg_temp_free_i64(tcg_res); | 21 | #define CTRL_CMD_MASK 0xff |
22 | #define CTRL_DUMMY_HIGH_SHIFT 14 | ||
23 | #define CTRL_AST2400_SPI_4BYTE (1 << 13) | ||
24 | +#define CE_CTRL_CLOCK_FREQ_SHIFT 8 | ||
25 | +#define CE_CTRL_CLOCK_FREQ_MASK 0xf | ||
26 | +#define CE_CTRL_CLOCK_FREQ(div) \ | ||
27 | + (((div) & CE_CTRL_CLOCK_FREQ_MASK) << CE_CTRL_CLOCK_FREQ_SHIFT) | ||
28 | #define CTRL_DUMMY_LOW_SHIFT 6 /* 2 bits [7:6] */ | ||
29 | #define CTRL_CE_STOP_ACTIVE (1 << 2) | ||
30 | #define CTRL_CMD_MODE_MASK 0x3 | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | #define DMA_CTRL_DELAY_SHIFT 8 | ||
33 | #define DMA_CTRL_FREQ_MASK 0xf | ||
34 | #define DMA_CTRL_FREQ_SHIFT 4 | ||
35 | -#define DMA_CTRL_MODE (1 << 3) | ||
36 | +#define DMA_CTRL_CALIB (1 << 3) | ||
37 | #define DMA_CTRL_CKSUM (1 << 2) | ||
38 | #define DMA_CTRL_WRITE (1 << 1) | ||
39 | #define DMA_CTRL_ENABLE (1 << 0) | ||
40 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
41 | } | ||
21 | } | 42 | } |
22 | 43 | ||
23 | +/* Floating-point data-processing (3 source) - half precision */ | 44 | +static uint8_t aspeed_smc_hclk_divisor(uint8_t hclk_mask) |
24 | +static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1, | ||
25 | + int rd, int rn, int rm, int ra) | ||
26 | +{ | 45 | +{ |
27 | + TCGv_i32 tcg_op1, tcg_op2, tcg_op3; | 46 | + /* HCLK/1 .. HCLK/16 */ |
28 | + TCGv_i32 tcg_res = tcg_temp_new_i32(); | 47 | + const uint8_t hclk_divisors[] = { |
29 | + TCGv_ptr fpst = get_fpstatus_ptr(true); | 48 | + 15, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 0 |
49 | + }; | ||
50 | + int i; | ||
30 | + | 51 | + |
31 | + tcg_op1 = read_fp_hreg(s, rn); | 52 | + for (i = 0; i < ARRAY_SIZE(hclk_divisors); i++) { |
32 | + tcg_op2 = read_fp_hreg(s, rm); | 53 | + if (hclk_mask == hclk_divisors[i]) { |
33 | + tcg_op3 = read_fp_hreg(s, ra); | 54 | + return i + 1; |
34 | + | 55 | + } |
35 | + /* These are fused multiply-add, and must be done as one | ||
36 | + * floating point operation with no rounding between the | ||
37 | + * multiplication and addition steps. | ||
38 | + * NB that doing the negations here as separate steps is | ||
39 | + * correct : an input NaN should come out with its sign bit | ||
40 | + * flipped if it is a negated-input. | ||
41 | + */ | ||
42 | + if (o1 == true) { | ||
43 | + tcg_gen_xori_i32(tcg_op3, tcg_op3, 0x8000); | ||
44 | + } | 56 | + } |
45 | + | 57 | + |
46 | + if (o0 != o1) { | 58 | + qemu_log_mask(LOG_GUEST_ERROR, "invalid HCLK mask %x", hclk_mask); |
47 | + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); | 59 | + return 0; |
60 | +} | ||
61 | + | ||
62 | +/* | ||
63 | + * When doing calibration, the SPI clock rate in the CE0 Control | ||
64 | + * Register and the read delay cycles in the Read Timing Compensation | ||
65 | + * Register are set using bit[11:4] of the DMA Control Register. | ||
66 | + */ | ||
67 | +static void aspeed_smc_dma_calibration(AspeedSMCState *s) | ||
68 | +{ | ||
69 | + uint8_t delay = | ||
70 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_DELAY_SHIFT) & DMA_CTRL_DELAY_MASK; | ||
71 | + uint8_t hclk_mask = | ||
72 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_FREQ_SHIFT) & DMA_CTRL_FREQ_MASK; | ||
73 | + uint8_t hclk_div = aspeed_smc_hclk_divisor(hclk_mask); | ||
74 | + uint32_t hclk_shift = (hclk_div - 1) << 2; | ||
75 | + uint8_t cs; | ||
76 | + | ||
77 | + /* | ||
78 | + * The Read Timing Compensation Register values apply to all CS on | ||
79 | + * the SPI bus and only HCLK/1 - HCLK/5 can have tunable delays | ||
80 | + */ | ||
81 | + if (hclk_div && hclk_div < 6) { | ||
82 | + s->regs[s->r_timings] &= ~(0xf << hclk_shift); | ||
83 | + s->regs[s->r_timings] |= delay << hclk_shift; | ||
48 | + } | 84 | + } |
49 | + | 85 | + |
50 | + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_op3, fpst); | 86 | + /* |
51 | + | 87 | + * TODO: compute the CS from the DMA address and the segment |
52 | + write_fp_sreg(s, rd, tcg_res); | 88 | + * registers. This is not really a problem for now because the |
53 | + | 89 | + * Timing Register values apply to all CS and software uses CS0 to |
54 | + tcg_temp_free_ptr(fpst); | 90 | + * do calibration. |
55 | + tcg_temp_free_i32(tcg_op1); | 91 | + */ |
56 | + tcg_temp_free_i32(tcg_op2); | 92 | + cs = 0; |
57 | + tcg_temp_free_i32(tcg_op3); | 93 | + s->regs[s->r_ctrl0 + cs] &= |
58 | + tcg_temp_free_i32(tcg_res); | 94 | + ~(CE_CTRL_CLOCK_FREQ_MASK << CE_CTRL_CLOCK_FREQ_SHIFT); |
95 | + s->regs[s->r_ctrl0 + cs] |= CE_CTRL_CLOCK_FREQ(hclk_div); | ||
59 | +} | 96 | +} |
60 | + | 97 | + |
61 | /* Floating point data-processing (3 source) | 98 | /* |
62 | * 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0 | 99 | * Accumulate the result of the reads to provide a checksum that will |
63 | * +---+---+---+-----------+------+----+------+----+------+------+------+ | 100 | * be used to validate the read timing settings. |
64 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) | 101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_checksum(AspeedSMCState *s) |
65 | } | 102 | return; |
66 | handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); | ||
67 | break; | ||
68 | + case 3: | ||
69 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
70 | + unallocated_encoding(s); | ||
71 | + return; | ||
72 | + } | ||
73 | + if (!fp_access_check(s)) { | ||
74 | + return; | ||
75 | + } | ||
76 | + handle_fp_3src_half(s, o0, o1, rd, rn, rm, ra); | ||
77 | + break; | ||
78 | default: | ||
79 | unallocated_encoding(s); | ||
80 | } | 103 | } |
104 | |||
105 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_CALIB) { | ||
106 | + aspeed_smc_dma_calibration(s); | ||
107 | + } | ||
108 | + | ||
109 | while (s->regs[R_DMA_LEN]) { | ||
110 | data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
111 | MEMTXATTRS_UNSPECIFIED, &result); | ||
81 | -- | 112 | -- |
82 | 2.17.0 | 113 | 2.20.1 |
83 | 114 | ||
84 | 115 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | We missed all of the scalar fp16 binary operations. | 3 | Emulate read errors in the DMA Checksum Register for high frequencies |
4 | and optimistic settings of the Read Timing Compensation Register. This | ||
5 | will help in tuning the SPI timing calibration algorithm. Errors are | ||
6 | only injected when the property "inject_failure" is set to true as | ||
7 | suggested by Philippe. | ||
4 | 8 | ||
5 | Cc: qemu-stable@nongnu.org | 9 | The values below are those to expect from the first flash device of |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | the FMC controller of a palmetto-bmc machine. |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 12 | Cc: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Message-id: 20180512003217.9105-7-richard.henderson@linaro.org | 13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190904070506.1052-8-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 17 | --- |
12 | target/arm/translate-a64.c | 65 ++++++++++++++++++++++++++++++++++++++ | 18 | include/hw/ssi/aspeed_smc.h | 1 + |
13 | 1 file changed, 65 insertions(+) | 19 | hw/ssi/aspeed_smc.c | 36 ++++++++++++++++++++++++++++++++++++ |
20 | 2 files changed, 37 insertions(+) | ||
14 | 21 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 22 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 24 | --- a/include/hw/ssi/aspeed_smc.h |
18 | +++ b/target/arm/translate-a64.c | 25 | +++ b/include/hw/ssi/aspeed_smc.h |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode, | 26 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { |
20 | tcg_temp_free_i64(tcg_res); | 27 | |
28 | uint32_t num_cs; | ||
29 | qemu_irq *cs_lines; | ||
30 | + bool inject_failure; | ||
31 | |||
32 | SSIBus *spi; | ||
33 | |||
34 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/ssi/aspeed_smc.c | ||
37 | +++ b/hw/ssi/aspeed_smc.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_calibration(AspeedSMCState *s) | ||
39 | s->regs[s->r_ctrl0 + cs] |= CE_CTRL_CLOCK_FREQ(hclk_div); | ||
21 | } | 40 | } |
22 | 41 | ||
23 | +/* Floating-point data-processing (2 source) - half precision */ | 42 | +/* |
24 | +static void handle_fp_2src_half(DisasContext *s, int opcode, | 43 | + * Emulate read errors in the DMA Checksum Register for high |
25 | + int rd, int rn, int rm) | 44 | + * frequencies and optimistic settings of the Read Timing Compensation |
45 | + * Register. This will help in tuning the SPI timing calibration | ||
46 | + * algorithm. | ||
47 | + */ | ||
48 | +static bool aspeed_smc_inject_read_failure(AspeedSMCState *s) | ||
26 | +{ | 49 | +{ |
27 | + TCGv_i32 tcg_op1; | 50 | + uint8_t delay = |
28 | + TCGv_i32 tcg_op2; | 51 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_DELAY_SHIFT) & DMA_CTRL_DELAY_MASK; |
29 | + TCGv_i32 tcg_res; | 52 | + uint8_t hclk_mask = |
30 | + TCGv_ptr fpst; | 53 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_FREQ_SHIFT) & DMA_CTRL_FREQ_MASK; |
31 | + | 54 | + |
32 | + tcg_res = tcg_temp_new_i32(); | 55 | + /* |
33 | + fpst = get_fpstatus_ptr(true); | 56 | + * Typical values of a palmetto-bmc machine. |
34 | + tcg_op1 = read_fp_hreg(s, rn); | 57 | + */ |
35 | + tcg_op2 = read_fp_hreg(s, rm); | 58 | + switch (aspeed_smc_hclk_divisor(hclk_mask)) { |
36 | + | 59 | + case 4 ... 16: |
37 | + switch (opcode) { | 60 | + return false; |
38 | + case 0x0: /* FMUL */ | 61 | + case 3: /* at least one HCLK cycle delay */ |
39 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | 62 | + return (delay & 0x7) < 1; |
40 | + break; | 63 | + case 2: /* at least two HCLK cycle delay */ |
41 | + case 0x1: /* FDIV */ | 64 | + return (delay & 0x7) < 2; |
42 | + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); | 65 | + case 1: /* (> 100MHz) is above the max freq of the controller */ |
43 | + break; | 66 | + return true; |
44 | + case 0x2: /* FADD */ | ||
45 | + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
46 | + break; | ||
47 | + case 0x3: /* FSUB */ | ||
48 | + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
49 | + break; | ||
50 | + case 0x4: /* FMAX */ | ||
51 | + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
52 | + break; | ||
53 | + case 0x5: /* FMIN */ | ||
54 | + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
55 | + break; | ||
56 | + case 0x6: /* FMAXNM */ | ||
57 | + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
58 | + break; | ||
59 | + case 0x7: /* FMINNM */ | ||
60 | + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
61 | + break; | ||
62 | + case 0x8: /* FNMUL */ | ||
63 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
64 | + tcg_gen_xori_i32(tcg_res, tcg_res, 0x8000); | ||
65 | + break; | ||
66 | + default: | 67 | + default: |
67 | + g_assert_not_reached(); | 68 | + g_assert_not_reached(); |
68 | + } | 69 | + } |
69 | + | ||
70 | + write_fp_sreg(s, rd, tcg_res); | ||
71 | + | ||
72 | + tcg_temp_free_ptr(fpst); | ||
73 | + tcg_temp_free_i32(tcg_op1); | ||
74 | + tcg_temp_free_i32(tcg_op2); | ||
75 | + tcg_temp_free_i32(tcg_res); | ||
76 | +} | 70 | +} |
77 | + | 71 | + |
78 | /* Floating point data-processing (2 source) | 72 | /* |
79 | * 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0 | 73 | * Accumulate the result of the reads to provide a checksum that will |
80 | * +---+---+---+-----------+------+---+------+--------+-----+------+------+ | 74 | * be used to validate the read timing settings. |
81 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) | 75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_checksum(AspeedSMCState *s) |
82 | } | 76 | s->regs[R_DMA_FLASH_ADDR] += 4; |
83 | handle_fp_2src_double(s, opcode, rd, rn, rm); | 77 | s->regs[R_DMA_LEN] -= 4; |
84 | break; | ||
85 | + case 3: | ||
86 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
87 | + unallocated_encoding(s); | ||
88 | + return; | ||
89 | + } | ||
90 | + if (!fp_access_check(s)) { | ||
91 | + return; | ||
92 | + } | ||
93 | + handle_fp_2src_half(s, opcode, rd, rn, rm); | ||
94 | + break; | ||
95 | default: | ||
96 | unallocated_encoding(s); | ||
97 | } | 78 | } |
79 | + | ||
80 | + if (s->inject_failure && aspeed_smc_inject_read_failure(s)) { | ||
81 | + s->regs[R_DMA_CHECKSUM] = 0xbadc0de; | ||
82 | + } | ||
83 | + | ||
84 | } | ||
85 | |||
86 | static void aspeed_smc_dma_rw(AspeedSMCState *s) | ||
87 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { | ||
88 | |||
89 | static Property aspeed_smc_properties[] = { | ||
90 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), | ||
91 | + DEFINE_PROP_BOOL("inject-failure", AspeedSMCState, inject_failure, false), | ||
92 | DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), | ||
93 | DEFINE_PROP_LINK("dram", AspeedSMCState, dram_mr, | ||
94 | TYPE_MEMORY_REGION, MemoryRegion *), | ||
98 | -- | 95 | -- |
99 | 2.17.0 | 96 | 2.20.1 |
100 | 97 | ||
101 | 98 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Christian Svensson <bluecmd@google.com> |
---|---|---|---|
2 | 2 | ||
3 | These where missed out from the rest of the half-precision work. | 3 | This patch adds the missing checksum calculation on normal DMA transfer. |
4 | According to the datasheet this is how the SMC should behave. | ||
4 | 5 | ||
5 | Cc: qemu-stable@nongnu.org | 6 | Verified on AST1250 that the hardware matches the behaviour. |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | |
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Christian Svensson <bluecmd@google.com> |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
10 | Message-id: 20180512003217.9105-9-richard.henderson@linaro.org | 11 | Message-id: 20190904070506.1052-9-clg@kaod.org |
11 | [rth: Diagnose lack of FP16 before fp_access_check] | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | target/arm/helper-a64.h | 2 + | 14 | hw/ssi/aspeed_smc.c | 1 + |
16 | target/arm/helper-a64.c | 10 +++++ | 15 | 1 file changed, 1 insertion(+) |
17 | target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++-------- | ||
18 | 3 files changed, 83 insertions(+), 17 deletions(-) | ||
19 | 16 | ||
20 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper-a64.h | 19 | --- a/hw/ssi/aspeed_smc.c |
23 | +++ b/target/arm/helper-a64.h | 20 | +++ b/hw/ssi/aspeed_smc.c |
24 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_rw(AspeedSMCState *s) |
25 | DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) | 22 | s->regs[R_DMA_FLASH_ADDR] += 4; |
26 | DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) | 23 | s->regs[R_DMA_DRAM_ADDR] += 4; |
27 | DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) | 24 | s->regs[R_DMA_LEN] -= 4; |
28 | +DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) | 25 | + s->regs[R_DMA_CHECKSUM] += data; |
29 | +DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) | ||
30 | DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | ||
31 | DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr) | ||
32 | DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr) | ||
33 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/helper-a64.c | ||
36 | +++ b/target/arm/helper-a64.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | ||
38 | return flags; | ||
39 | } | ||
40 | |||
41 | +uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | ||
42 | +{ | ||
43 | + return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | ||
44 | +} | ||
45 | + | ||
46 | +uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | ||
47 | +{ | ||
48 | + return float_rel_to_flags(float16_compare(x, y, fp_status)); | ||
49 | +} | ||
50 | + | ||
51 | uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status) | ||
52 | { | ||
53 | return float_rel_to_flags(float32_compare_quiet(x, y, fp_status)); | ||
54 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/translate-a64.c | ||
57 | +++ b/target/arm/translate-a64.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) | ||
59 | } | 26 | } |
60 | } | 27 | } |
61 | 28 | ||
62 | -static void handle_fp_compare(DisasContext *s, bool is_double, | ||
63 | +static void handle_fp_compare(DisasContext *s, int size, | ||
64 | unsigned int rn, unsigned int rm, | ||
65 | bool cmp_with_zero, bool signal_all_nans) | ||
66 | { | ||
67 | TCGv_i64 tcg_flags = tcg_temp_new_i64(); | ||
68 | - TCGv_ptr fpst = get_fpstatus_ptr(false); | ||
69 | + TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16); | ||
70 | |||
71 | - if (is_double) { | ||
72 | + if (size == MO_64) { | ||
73 | TCGv_i64 tcg_vn, tcg_vm; | ||
74 | |||
75 | tcg_vn = read_fp_dreg(s, rn); | ||
76 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | ||
77 | tcg_temp_free_i64(tcg_vn); | ||
78 | tcg_temp_free_i64(tcg_vm); | ||
79 | } else { | ||
80 | - TCGv_i32 tcg_vn, tcg_vm; | ||
81 | + TCGv_i32 tcg_vn = tcg_temp_new_i32(); | ||
82 | + TCGv_i32 tcg_vm = tcg_temp_new_i32(); | ||
83 | |||
84 | - tcg_vn = read_fp_sreg(s, rn); | ||
85 | + read_vec_element_i32(s, tcg_vn, rn, 0, size); | ||
86 | if (cmp_with_zero) { | ||
87 | - tcg_vm = tcg_const_i32(0); | ||
88 | + tcg_gen_movi_i32(tcg_vm, 0); | ||
89 | } else { | ||
90 | - tcg_vm = read_fp_sreg(s, rm); | ||
91 | + read_vec_element_i32(s, tcg_vm, rm, 0, size); | ||
92 | } | ||
93 | - if (signal_all_nans) { | ||
94 | - gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
95 | - } else { | ||
96 | - gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
97 | + | ||
98 | + switch (size) { | ||
99 | + case MO_32: | ||
100 | + if (signal_all_nans) { | ||
101 | + gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
102 | + } else { | ||
103 | + gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
104 | + } | ||
105 | + break; | ||
106 | + case MO_16: | ||
107 | + if (signal_all_nans) { | ||
108 | + gen_helper_vfp_cmpeh_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
109 | + } else { | ||
110 | + gen_helper_vfp_cmph_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
111 | + } | ||
112 | + break; | ||
113 | + default: | ||
114 | + g_assert_not_reached(); | ||
115 | } | ||
116 | + | ||
117 | tcg_temp_free_i32(tcg_vn); | ||
118 | tcg_temp_free_i32(tcg_vm); | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | ||
121 | static void disas_fp_compare(DisasContext *s, uint32_t insn) | ||
122 | { | ||
123 | unsigned int mos, type, rm, op, rn, opc, op2r; | ||
124 | + int size; | ||
125 | |||
126 | mos = extract32(insn, 29, 3); | ||
127 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | ||
128 | + type = extract32(insn, 22, 2); | ||
129 | rm = extract32(insn, 16, 5); | ||
130 | op = extract32(insn, 14, 2); | ||
131 | rn = extract32(insn, 5, 5); | ||
132 | opc = extract32(insn, 3, 2); | ||
133 | op2r = extract32(insn, 0, 3); | ||
134 | |||
135 | - if (mos || op || op2r || type > 1) { | ||
136 | + if (mos || op || op2r) { | ||
137 | + unallocated_encoding(s); | ||
138 | + return; | ||
139 | + } | ||
140 | + | ||
141 | + switch (type) { | ||
142 | + case 0: | ||
143 | + size = MO_32; | ||
144 | + break; | ||
145 | + case 1: | ||
146 | + size = MO_64; | ||
147 | + break; | ||
148 | + case 3: | ||
149 | + size = MO_16; | ||
150 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
151 | + break; | ||
152 | + } | ||
153 | + /* fallthru */ | ||
154 | + default: | ||
155 | unallocated_encoding(s); | ||
156 | return; | ||
157 | } | ||
158 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | - handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2); | ||
163 | + handle_fp_compare(s, size, rn, rm, opc & 1, opc & 2); | ||
164 | } | ||
165 | |||
166 | /* Floating point conditional compare | ||
167 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | ||
168 | unsigned int mos, type, rm, cond, rn, op, nzcv; | ||
169 | TCGv_i64 tcg_flags; | ||
170 | TCGLabel *label_continue = NULL; | ||
171 | + int size; | ||
172 | |||
173 | mos = extract32(insn, 29, 3); | ||
174 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | ||
175 | + type = extract32(insn, 22, 2); | ||
176 | rm = extract32(insn, 16, 5); | ||
177 | cond = extract32(insn, 12, 4); | ||
178 | rn = extract32(insn, 5, 5); | ||
179 | op = extract32(insn, 4, 1); | ||
180 | nzcv = extract32(insn, 0, 4); | ||
181 | |||
182 | - if (mos || type > 1) { | ||
183 | + if (mos) { | ||
184 | + unallocated_encoding(s); | ||
185 | + return; | ||
186 | + } | ||
187 | + | ||
188 | + switch (type) { | ||
189 | + case 0: | ||
190 | + size = MO_32; | ||
191 | + break; | ||
192 | + case 1: | ||
193 | + size = MO_64; | ||
194 | + break; | ||
195 | + case 3: | ||
196 | + size = MO_16; | ||
197 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
198 | + break; | ||
199 | + } | ||
200 | + /* fallthru */ | ||
201 | + default: | ||
202 | unallocated_encoding(s); | ||
203 | return; | ||
204 | } | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | ||
206 | gen_set_label(label_match); | ||
207 | } | ||
208 | |||
209 | - handle_fp_compare(s, type, rn, rm, false, op); | ||
210 | + handle_fp_compare(s, size, rn, rm, false, op); | ||
211 | |||
212 | if (cond < 0x0e) { | ||
213 | gen_set_label(label_continue); | ||
214 | -- | 29 | -- |
215 | 2.17.0 | 30 | 2.20.1 |
216 | 31 | ||
217 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | 3 | and use a class AspeedSCUClass to define each SoC characteristics. |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Message-id: 20190904070506.1052-10-clg@kaod.org |
7 | Message-id: 20180512003217.9105-4-richard.henderson@linaro.org | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | target/arm/helper.h | 6 +++ | 10 | include/hw/misc/aspeed_scu.h | 15 +++++++ |
11 | target/arm/helper.c | 38 ++++++++++++++- | 11 | hw/arm/aspeed_soc.c | 3 +- |
12 | target/arm/translate-a64.c | 96 +++++++++++++++++++++++++++++++------- | 12 | hw/misc/aspeed_scu.c | 83 ++++++++++++++++++++---------------- |
13 | 3 files changed, 122 insertions(+), 18 deletions(-) | 13 | 3 files changed, 64 insertions(+), 37 deletions(-) |
14 | 14 | ||
15 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.h | 17 | --- a/include/hw/misc/aspeed_scu.h |
18 | +++ b/target/arm/helper.h | 18 | +++ b/include/hw/misc/aspeed_scu.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ |
20 | DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) | 20 | |
21 | DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr) | 21 | #define TYPE_ASPEED_SCU "aspeed.scu" |
22 | DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr) | 22 | #define ASPEED_SCU(obj) OBJECT_CHECK(AspeedSCUState, (obj), TYPE_ASPEED_SCU) |
23 | +DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) | 23 | +#define TYPE_ASPEED_2400_SCU TYPE_ASPEED_SCU "-ast2400" |
24 | +DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) | 24 | +#define TYPE_ASPEED_2500_SCU TYPE_ASPEED_SCU "-ast2500" |
25 | +DEF_HELPER_3(vfp_touqh, i64, f16, i32, ptr) | 25 | |
26 | +DEF_HELPER_3(vfp_tosqh, i64, f16, i32, ptr) | 26 | #define ASPEED_SCU_NR_REGS (0x1A8 >> 2) |
27 | DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) | 27 | |
28 | DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { |
29 | DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) | 29 | |
30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) | 30 | extern bool is_supported_silicon_rev(uint32_t silicon_rev); |
31 | DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) | 31 | |
32 | DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr) | 32 | +#define ASPEED_SCU_CLASS(klass) \ |
33 | DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) | 33 | + OBJECT_CLASS_CHECK(AspeedSCUClass, (klass), TYPE_ASPEED_SCU) |
34 | +DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr) | 34 | +#define ASPEED_SCU_GET_CLASS(obj) \ |
35 | +DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) | 35 | + OBJECT_GET_CLASS(AspeedSCUClass, (obj), TYPE_ASPEED_SCU) |
36 | 36 | + | |
37 | DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) | 37 | +typedef struct AspeedSCUClass { |
38 | DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) | 38 | + SysBusDeviceClass parent_class; |
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 39 | + |
40 | + const uint32_t *resets; | ||
41 | + uint32_t (*calc_hpll)(AspeedSCUState *s); | ||
42 | + uint32_t apb_divider; | ||
43 | +} AspeedSCUClass; | ||
44 | + | ||
45 | #define ASPEED_SCU_PROT_KEY 0x1688A8A8 | ||
46 | |||
47 | /* | ||
48 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/helper.c | 50 | --- a/hw/arm/aspeed_soc.c |
42 | +++ b/target/arm/helper.c | 51 | +++ b/hw/arm/aspeed_soc.c |
43 | @@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) | 52 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
44 | #undef VFP_CONV_FIX_A64 | 53 | &error_abort, NULL); |
45 | 54 | } | |
46 | /* Conversion to/from f16 can overflow to infinity before/after scaling. | 55 | |
47 | - * Therefore we convert to f64 (which does not round), scale, | 56 | + snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname); |
48 | - * and then convert f64 to f16 (which may round). | 57 | sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu), |
49 | + * Therefore we convert to f64, scale, and then convert f64 to f16; or | 58 | - TYPE_ASPEED_SCU); |
50 | + * vice versa for conversion to integer. | 59 | + typename); |
51 | + * | 60 | qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev", |
52 | + * For 16- and 32-bit integers, the conversion to f64 never rounds. | 61 | sc->info->silicon_rev); |
53 | + * For 64-bit integers, any integer that would cause rounding will also | 62 | object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu), |
54 | + * overflow to f16 infinity, so there is no double rounding problem. | 63 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c |
55 | */ | 64 | index XXXXXXX..XXXXXXX 100644 |
56 | 65 | --- a/hw/misc/aspeed_scu.c | |
57 | static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | 66 | +++ b/hw/misc/aspeed_scu.c |
58 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | 67 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_get_random(void) |
59 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | 68 | |
60 | } | 69 | static void aspeed_scu_set_apb_freq(AspeedSCUState *s) |
61 | 70 | { | |
62 | +float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | 71 | - uint32_t apb_divider; |
72 | - | ||
73 | - switch (s->silicon_rev) { | ||
74 | - case AST2400_A0_SILICON_REV: | ||
75 | - case AST2400_A1_SILICON_REV: | ||
76 | - apb_divider = 2; | ||
77 | - break; | ||
78 | - case AST2500_A0_SILICON_REV: | ||
79 | - case AST2500_A1_SILICON_REV: | ||
80 | - apb_divider = 4; | ||
81 | - break; | ||
82 | - default: | ||
83 | - g_assert_not_reached(); | ||
84 | - } | ||
85 | + AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(s); | ||
86 | |||
87 | s->apb_freq = s->hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) | ||
88 | - / apb_divider; | ||
89 | + / asc->apb_divider; | ||
90 | } | ||
91 | |||
92 | static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size) | ||
93 | @@ -XXX,XX +XXX,XX @@ static const uint32_t hpll_ast2400_freqs[][4] = { | ||
94 | { 400, 375, 350, 425 }, /* 25MHz */ | ||
95 | }; | ||
96 | |||
97 | -static uint32_t aspeed_scu_calc_hpll_ast2400(AspeedSCUState *s) | ||
98 | +static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) | ||
99 | { | ||
100 | uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
101 | uint8_t freq_select; | ||
102 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_calc_hpll_ast2400(AspeedSCUState *s) | ||
103 | return hpll_ast2400_freqs[clk_25m_in][freq_select] * 1000000; | ||
104 | } | ||
105 | |||
106 | -static uint32_t aspeed_scu_calc_hpll_ast2500(AspeedSCUState *s) | ||
107 | +static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) | ||
108 | { | ||
109 | uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
110 | uint32_t multiplier = 1; | ||
111 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_calc_hpll_ast2500(AspeedSCUState *s) | ||
112 | static void aspeed_scu_reset(DeviceState *dev) | ||
113 | { | ||
114 | AspeedSCUState *s = ASPEED_SCU(dev); | ||
115 | - const uint32_t *reset; | ||
116 | - uint32_t (*calc_hpll)(AspeedSCUState *s); | ||
117 | + AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(dev); | ||
118 | |||
119 | - switch (s->silicon_rev) { | ||
120 | - case AST2400_A0_SILICON_REV: | ||
121 | - case AST2400_A1_SILICON_REV: | ||
122 | - reset = ast2400_a0_resets; | ||
123 | - calc_hpll = aspeed_scu_calc_hpll_ast2400; | ||
124 | - break; | ||
125 | - case AST2500_A0_SILICON_REV: | ||
126 | - case AST2500_A1_SILICON_REV: | ||
127 | - reset = ast2500_a1_resets; | ||
128 | - calc_hpll = aspeed_scu_calc_hpll_ast2500; | ||
129 | - break; | ||
130 | - default: | ||
131 | - g_assert_not_reached(); | ||
132 | - } | ||
133 | - | ||
134 | - memcpy(s->regs, reset, sizeof(s->regs)); | ||
135 | + memcpy(s->regs, asc->resets, sizeof(s->regs)); | ||
136 | s->regs[SILICON_REV] = s->silicon_rev; | ||
137 | s->regs[HW_STRAP1] = s->hw_strap1; | ||
138 | s->regs[HW_STRAP2] = s->hw_strap2; | ||
139 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_reset(DeviceState *dev) | ||
140 | * All registers are set. Now compute the frequencies of the main clocks | ||
141 | */ | ||
142 | s->clkin = aspeed_scu_get_clkin(s); | ||
143 | - s->hpll = calc_hpll(s); | ||
144 | + s->hpll = asc->calc_hpll(s); | ||
145 | aspeed_scu_set_apb_freq(s); | ||
146 | } | ||
147 | |||
148 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_scu_info = { | ||
149 | .parent = TYPE_SYS_BUS_DEVICE, | ||
150 | .instance_size = sizeof(AspeedSCUState), | ||
151 | .class_init = aspeed_scu_class_init, | ||
152 | + .class_size = sizeof(AspeedSCUClass), | ||
153 | + .abstract = true, | ||
154 | +}; | ||
155 | + | ||
156 | +static void aspeed_2400_scu_class_init(ObjectClass *klass, void *data) | ||
63 | +{ | 157 | +{ |
64 | + return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | 158 | + DeviceClass *dc = DEVICE_CLASS(klass); |
159 | + AspeedSCUClass *asc = ASPEED_SCU_CLASS(klass); | ||
160 | + | ||
161 | + dc->desc = "ASPEED 2400 System Control Unit"; | ||
162 | + asc->resets = ast2400_a0_resets; | ||
163 | + asc->calc_hpll = aspeed_2400_scu_calc_hpll; | ||
164 | + asc->apb_divider = 2; | ||
65 | +} | 165 | +} |
66 | + | 166 | + |
67 | +float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | 167 | +static const TypeInfo aspeed_2400_scu_info = { |
168 | + .name = TYPE_ASPEED_2400_SCU, | ||
169 | + .parent = TYPE_ASPEED_SCU, | ||
170 | + .instance_size = sizeof(AspeedSCUState), | ||
171 | + .class_init = aspeed_2400_scu_class_init, | ||
172 | +}; | ||
173 | + | ||
174 | +static void aspeed_2500_scu_class_init(ObjectClass *klass, void *data) | ||
68 | +{ | 175 | +{ |
69 | + return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | 176 | + DeviceClass *dc = DEVICE_CLASS(klass); |
177 | + AspeedSCUClass *asc = ASPEED_SCU_CLASS(klass); | ||
178 | + | ||
179 | + dc->desc = "ASPEED 2500 System Control Unit"; | ||
180 | + asc->resets = ast2500_a1_resets; | ||
181 | + asc->calc_hpll = aspeed_2500_scu_calc_hpll; | ||
182 | + asc->apb_divider = 4; | ||
70 | +} | 183 | +} |
71 | + | 184 | + |
72 | static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | 185 | +static const TypeInfo aspeed_2500_scu_info = { |
73 | { | 186 | + .name = TYPE_ASPEED_2500_SCU, |
74 | if (unlikely(float16_is_any_nan(f))) { | 187 | + .parent = TYPE_ASPEED_SCU, |
75 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | 188 | + .instance_size = sizeof(AspeedSCUState), |
76 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | 189 | + .class_init = aspeed_2500_scu_class_init, |
77 | } | 190 | }; |
78 | 191 | ||
79 | +uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | 192 | static void aspeed_scu_register_types(void) |
80 | +{ | 193 | { |
81 | + return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | 194 | type_register_static(&aspeed_scu_info); |
82 | +} | 195 | + type_register_static(&aspeed_2400_scu_info); |
83 | + | 196 | + type_register_static(&aspeed_2500_scu_info); |
84 | +uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | 197 | } |
85 | +{ | 198 | |
86 | + return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | 199 | type_init(aspeed_scu_register_types); |
87 | +} | ||
88 | + | ||
89 | +uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
90 | +{ | ||
91 | + return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
92 | +} | ||
93 | + | ||
94 | +uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
95 | +{ | ||
96 | + return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
97 | +} | ||
98 | + | ||
99 | /* Set the current fp rounding mode and return the old one. | ||
100 | * The argument is a softfloat float_round_ value. | ||
101 | */ | ||
102 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/translate-a64.c | ||
105 | +++ b/target/arm/translate-a64.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
107 | bool itof, int rmode, int scale, int sf, int type) | ||
108 | { | ||
109 | bool is_signed = !(opcode & 1); | ||
110 | - bool is_double = type; | ||
111 | TCGv_ptr tcg_fpstatus; | ||
112 | - TCGv_i32 tcg_shift; | ||
113 | + TCGv_i32 tcg_shift, tcg_single; | ||
114 | + TCGv_i64 tcg_double; | ||
115 | |||
116 | - tcg_fpstatus = get_fpstatus_ptr(false); | ||
117 | + tcg_fpstatus = get_fpstatus_ptr(type == 3); | ||
118 | |||
119 | tcg_shift = tcg_const_i32(64 - scale); | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
122 | tcg_int = tcg_extend; | ||
123 | } | ||
124 | |||
125 | - if (is_double) { | ||
126 | - TCGv_i64 tcg_double = tcg_temp_new_i64(); | ||
127 | + switch (type) { | ||
128 | + case 1: /* float64 */ | ||
129 | + tcg_double = tcg_temp_new_i64(); | ||
130 | if (is_signed) { | ||
131 | gen_helper_vfp_sqtod(tcg_double, tcg_int, | ||
132 | tcg_shift, tcg_fpstatus); | ||
133 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
134 | } | ||
135 | write_fp_dreg(s, rd, tcg_double); | ||
136 | tcg_temp_free_i64(tcg_double); | ||
137 | - } else { | ||
138 | - TCGv_i32 tcg_single = tcg_temp_new_i32(); | ||
139 | + break; | ||
140 | + | ||
141 | + case 0: /* float32 */ | ||
142 | + tcg_single = tcg_temp_new_i32(); | ||
143 | if (is_signed) { | ||
144 | gen_helper_vfp_sqtos(tcg_single, tcg_int, | ||
145 | tcg_shift, tcg_fpstatus); | ||
146 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
147 | } | ||
148 | write_fp_sreg(s, rd, tcg_single); | ||
149 | tcg_temp_free_i32(tcg_single); | ||
150 | + break; | ||
151 | + | ||
152 | + case 3: /* float16 */ | ||
153 | + tcg_single = tcg_temp_new_i32(); | ||
154 | + if (is_signed) { | ||
155 | + gen_helper_vfp_sqtoh(tcg_single, tcg_int, | ||
156 | + tcg_shift, tcg_fpstatus); | ||
157 | + } else { | ||
158 | + gen_helper_vfp_uqtoh(tcg_single, tcg_int, | ||
159 | + tcg_shift, tcg_fpstatus); | ||
160 | + } | ||
161 | + write_fp_sreg(s, rd, tcg_single); | ||
162 | + tcg_temp_free_i32(tcg_single); | ||
163 | + break; | ||
164 | + | ||
165 | + default: | ||
166 | + g_assert_not_reached(); | ||
167 | } | ||
168 | } else { | ||
169 | TCGv_i64 tcg_int = cpu_reg(s, rd); | ||
170 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
171 | |||
172 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
173 | |||
174 | - if (is_double) { | ||
175 | - TCGv_i64 tcg_double = read_fp_dreg(s, rn); | ||
176 | + switch (type) { | ||
177 | + case 1: /* float64 */ | ||
178 | + tcg_double = read_fp_dreg(s, rn); | ||
179 | if (is_signed) { | ||
180 | if (!sf) { | ||
181 | gen_helper_vfp_tosld(tcg_int, tcg_double, | ||
182 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
183 | tcg_shift, tcg_fpstatus); | ||
184 | } | ||
185 | } | ||
186 | + if (!sf) { | ||
187 | + tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
188 | + } | ||
189 | tcg_temp_free_i64(tcg_double); | ||
190 | - } else { | ||
191 | - TCGv_i32 tcg_single = read_fp_sreg(s, rn); | ||
192 | + break; | ||
193 | + | ||
194 | + case 0: /* float32 */ | ||
195 | + tcg_single = read_fp_sreg(s, rn); | ||
196 | if (sf) { | ||
197 | if (is_signed) { | ||
198 | gen_helper_vfp_tosqs(tcg_int, tcg_single, | ||
199 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
200 | tcg_temp_free_i32(tcg_dest); | ||
201 | } | ||
202 | tcg_temp_free_i32(tcg_single); | ||
203 | + break; | ||
204 | + | ||
205 | + case 3: /* float16 */ | ||
206 | + tcg_single = read_fp_sreg(s, rn); | ||
207 | + if (sf) { | ||
208 | + if (is_signed) { | ||
209 | + gen_helper_vfp_tosqh(tcg_int, tcg_single, | ||
210 | + tcg_shift, tcg_fpstatus); | ||
211 | + } else { | ||
212 | + gen_helper_vfp_touqh(tcg_int, tcg_single, | ||
213 | + tcg_shift, tcg_fpstatus); | ||
214 | + } | ||
215 | + } else { | ||
216 | + TCGv_i32 tcg_dest = tcg_temp_new_i32(); | ||
217 | + if (is_signed) { | ||
218 | + gen_helper_vfp_toslh(tcg_dest, tcg_single, | ||
219 | + tcg_shift, tcg_fpstatus); | ||
220 | + } else { | ||
221 | + gen_helper_vfp_toulh(tcg_dest, tcg_single, | ||
222 | + tcg_shift, tcg_fpstatus); | ||
223 | + } | ||
224 | + tcg_gen_extu_i32_i64(tcg_int, tcg_dest); | ||
225 | + tcg_temp_free_i32(tcg_dest); | ||
226 | + } | ||
227 | + tcg_temp_free_i32(tcg_single); | ||
228 | + break; | ||
229 | + | ||
230 | + default: | ||
231 | + g_assert_not_reached(); | ||
232 | } | ||
233 | |||
234 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
235 | tcg_temp_free_i32(tcg_rmode); | ||
236 | - | ||
237 | - if (!sf) { | ||
238 | - tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
239 | - } | ||
240 | } | ||
241 | |||
242 | tcg_temp_free_ptr(tcg_fpstatus); | ||
243 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | ||
244 | /* actual FP conversions */ | ||
245 | bool itof = extract32(opcode, 1, 1); | ||
246 | |||
247 | - if (type > 1 || (rmode != 0 && opcode > 1)) { | ||
248 | + if (rmode != 0 && opcode > 1) { | ||
249 | + unallocated_encoding(s); | ||
250 | + return; | ||
251 | + } | ||
252 | + switch (type) { | ||
253 | + case 0: /* float32 */ | ||
254 | + case 1: /* float64 */ | ||
255 | + break; | ||
256 | + case 3: /* float16 */ | ||
257 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
258 | + break; | ||
259 | + } | ||
260 | + /* fallthru */ | ||
261 | + default: | ||
262 | unallocated_encoding(s); | ||
263 | return; | ||
264 | } | ||
265 | -- | 200 | -- |
266 | 2.17.0 | 201 | 2.20.1 |
267 | 202 | ||
268 | 203 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | No sense in emitting code after the exception. | 3 | The APB frequency can be calculated directly when needed from the |
4 | HPLL_PARAM and CLK_SEL register values. This removes useless state in | ||
5 | the model. | ||
4 | 6 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Message-id: 20190904070506.1052-11-clg@kaod.org |
7 | Message-id: 20180512003217.9105-3-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/translate-a64.c | 2 +- | 12 | include/hw/misc/aspeed_scu.h | 8 +++----- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | hw/misc/aspeed_scu.c | 25 +++++++++---------------- |
14 | hw/timer/aspeed_timer.c | 3 ++- | ||
15 | 3 files changed, 14 insertions(+), 22 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 19 | --- a/include/hw/misc/aspeed_scu.h |
17 | +++ b/target/arm/translate-a64.c | 20 | +++ b/include/hw/misc/aspeed_scu.h |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { |
19 | default: | 22 | uint32_t hw_strap1; |
20 | /* all other sf/type/rmode combinations are invalid */ | 23 | uint32_t hw_strap2; |
21 | unallocated_encoding(s); | 24 | uint32_t hw_prot_key; |
22 | - break; | 25 | - |
23 | + return; | 26 | - uint32_t clkin; |
27 | - uint32_t hpll; | ||
28 | - uint32_t apb_freq; | ||
29 | } AspeedSCUState; | ||
30 | |||
31 | #define AST2400_A0_SILICON_REV 0x02000303U | ||
32 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUClass { | ||
33 | SysBusDeviceClass parent_class; | ||
34 | |||
35 | const uint32_t *resets; | ||
36 | - uint32_t (*calc_hpll)(AspeedSCUState *s); | ||
37 | + uint32_t (*calc_hpll)(AspeedSCUState *s, uint32_t hpll_reg); | ||
38 | uint32_t apb_divider; | ||
39 | } AspeedSCUClass; | ||
40 | |||
41 | #define ASPEED_SCU_PROT_KEY 0x1688A8A8 | ||
42 | |||
43 | +uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s); | ||
44 | + | ||
45 | /* | ||
46 | * Extracted from Aspeed SDK v00.03.21. Fixes and extra definitions | ||
47 | * were added. | ||
48 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/misc/aspeed_scu.c | ||
51 | +++ b/hw/misc/aspeed_scu.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_get_random(void) | ||
53 | return num; | ||
54 | } | ||
55 | |||
56 | -static void aspeed_scu_set_apb_freq(AspeedSCUState *s) | ||
57 | +uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s) | ||
58 | { | ||
59 | AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(s); | ||
60 | + uint32_t hpll = asc->calc_hpll(s, s->regs[HPLL_PARAM]); | ||
61 | |||
62 | - s->apb_freq = s->hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) | ||
63 | + return hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) | ||
64 | / asc->apb_divider; | ||
65 | } | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
68 | return; | ||
69 | case CLK_SEL: | ||
70 | s->regs[reg] = data; | ||
71 | - aspeed_scu_set_apb_freq(s); | ||
72 | break; | ||
73 | case HW_STRAP1: | ||
74 | if (ASPEED_IS_AST2500(s->regs[SILICON_REV])) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static const uint32_t hpll_ast2400_freqs[][4] = { | ||
76 | { 400, 375, 350, 425 }, /* 25MHz */ | ||
77 | }; | ||
78 | |||
79 | -static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) | ||
80 | +static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s, uint32_t hpll_reg) | ||
81 | { | ||
82 | - uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
83 | uint8_t freq_select; | ||
84 | bool clk_25m_in; | ||
85 | + uint32_t clkin = aspeed_scu_get_clkin(s); | ||
86 | |||
87 | if (hpll_reg & SCU_AST2400_H_PLL_OFF) { | ||
88 | return 0; | ||
89 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) | ||
90 | multiplier = (2 - od) * ((n + 2) / (d + 1)); | ||
24 | } | 91 | } |
25 | 92 | ||
26 | if (!fp_access_check(s)) { | 93 | - return s->clkin * multiplier; |
94 | + return clkin * multiplier; | ||
95 | } | ||
96 | |||
97 | /* HW strapping */ | ||
98 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) | ||
99 | return hpll_ast2400_freqs[clk_25m_in][freq_select] * 1000000; | ||
100 | } | ||
101 | |||
102 | -static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) | ||
103 | +static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s, uint32_t hpll_reg) | ||
104 | { | ||
105 | - uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
106 | uint32_t multiplier = 1; | ||
107 | + uint32_t clkin = aspeed_scu_get_clkin(s); | ||
108 | |||
109 | if (hpll_reg & SCU_H_PLL_OFF) { | ||
110 | return 0; | ||
111 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) | ||
112 | multiplier = ((m + 1) / (n + 1)) / (p + 1); | ||
113 | } | ||
114 | |||
115 | - return s->clkin * multiplier; | ||
116 | + return clkin * multiplier; | ||
117 | } | ||
118 | |||
119 | static void aspeed_scu_reset(DeviceState *dev) | ||
120 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_reset(DeviceState *dev) | ||
121 | s->regs[HW_STRAP1] = s->hw_strap1; | ||
122 | s->regs[HW_STRAP2] = s->hw_strap2; | ||
123 | s->regs[PROT_KEY] = s->hw_prot_key; | ||
124 | - | ||
125 | - /* | ||
126 | - * All registers are set. Now compute the frequencies of the main clocks | ||
127 | - */ | ||
128 | - s->clkin = aspeed_scu_get_clkin(s); | ||
129 | - s->hpll = asc->calc_hpll(s); | ||
130 | - aspeed_scu_set_apb_freq(s); | ||
131 | } | ||
132 | |||
133 | static uint32_t aspeed_silicon_revs[] = { | ||
134 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/hw/timer/aspeed_timer.c | ||
137 | +++ b/hw/timer/aspeed_timer.c | ||
138 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t calculate_rate(struct AspeedTimer *t) | ||
139 | { | ||
140 | AspeedTimerCtrlState *s = timer_to_ctrl(t); | ||
141 | |||
142 | - return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ : s->scu->apb_freq; | ||
143 | + return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ : | ||
144 | + aspeed_scu_get_apb_freq(s->scu); | ||
145 | } | ||
146 | |||
147 | static inline uint32_t calculate_ticks(struct AspeedTimer *t, uint64_t now_ns) | ||
27 | -- | 148 | -- |
28 | 2.17.0 | 149 | 2.20.1 |
29 | 150 | ||
30 | 151 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: "Emilio G. Cota" <cota@braap.org> |
---|---|---|---|
2 | 2 | ||
3 | Reported by Coverity (CID1390635). We ensure this for uint_to_float | 3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
4 | later on so we might as well mirror that. | 4 | Signed-off-by: Emilio G. Cota <cota@braap.org> |
5 | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | fpu/softfloat.c | 2 +- | 9 | accel/tcg/atomic_template.h | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 11 | ||
14 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | 12 | diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/fpu/softfloat.c | 14 | --- a/accel/tcg/atomic_template.h |
17 | +++ b/fpu/softfloat.c | 15 | +++ b/accel/tcg/atomic_template.h |
18 | @@ -XXX,XX +XXX,XX @@ FLOAT_TO_UINT(64, 64) | 16 | @@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, |
19 | 17 | ||
20 | static FloatParts int_to_float(int64_t a, float_status *status) | 18 | #define GEN_ATOMIC_HELPER(X) \ |
21 | { | 19 | ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ |
22 | - FloatParts r; | 20 | - ABI_TYPE val EXTRA_ARGS) \ |
23 | + FloatParts r = {}; | 21 | + ABI_TYPE val EXTRA_ARGS) \ |
24 | if (a == 0) { | 22 | { \ |
25 | r.cls = float_class_zero; | 23 | ATOMIC_MMU_DECLS; \ |
26 | r.sign = false; | 24 | DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ |
27 | -- | 25 | -- |
28 | 2.17.0 | 26 | 2.20.1 |
29 | 27 | ||
30 | 28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In float-to-integer conversion, if the floating point input | ||
2 | converts exactly to the largest or smallest integer that | ||
3 | fits in to the result type, this is not an overflow. | ||
4 | In this situation we were producing the correct result value, | ||
5 | but were incorrectly setting the Invalid flag. | ||
6 | For example for Arm A64, "FCVTAS w0, d0" on an input of | ||
7 | 0x41dfffffffc00000 should produce 0x7fffffff and set no flags. | ||
8 | 1 | ||
9 | Fix the boundary case to take the right half of the if() | ||
10 | statements. | ||
11 | |||
12 | This fixes a regression from 2.11 introduced by the softfloat | ||
13 | refactoring. | ||
14 | |||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Fixes: ab52f973a50 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20180510140141.12120-1-peter.maydell@linaro.org | ||
20 | --- | ||
21 | fpu/softfloat.c | 4 ++-- | ||
22 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
23 | |||
24 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/fpu/softfloat.c | ||
27 | +++ b/fpu/softfloat.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, | ||
29 | r = UINT64_MAX; | ||
30 | } | ||
31 | if (p.sign) { | ||
32 | - if (r < -(uint64_t) min) { | ||
33 | + if (r <= -(uint64_t) min) { | ||
34 | return -r; | ||
35 | } else { | ||
36 | s->float_exception_flags = orig_flags | float_flag_invalid; | ||
37 | return min; | ||
38 | } | ||
39 | } else { | ||
40 | - if (r < max) { | ||
41 | + if (r <= max) { | ||
42 | return r; | ||
43 | } else { | ||
44 | s->float_exception_flags = orig_flags | float_flag_invalid; | ||
45 | -- | ||
46 | 2.17.0 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In commit d81ce0ef2c4f105 we added an extra float_status field | ||
2 | fp_status_fp16 for Arm, but forgot to initialize it correctly | ||
3 | by setting it to float_tininess_before_rounding. This currently | ||
4 | will only cause problems for the new V8_FP16 feature, since the | ||
5 | float-to-float conversion code doesn't use it yet. The effect | ||
6 | would be that we failed to set the Underflow IEEE exception flag | ||
7 | in all the cases where we should. | ||
8 | 1 | ||
9 | Add the missing initialization. | ||
10 | |||
11 | Fixes: d81ce0ef2c4f105 | ||
12 | Cc: qemu-stable@nongnu.org | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Message-id: 20180512004311.9299-16-richard.henderson@linaro.org | ||
17 | --- | ||
18 | target/arm/cpu.c | 2 ++ | ||
19 | 1 file changed, 2 insertions(+) | ||
20 | |||
21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/cpu.c | ||
24 | +++ b/target/arm/cpu.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
26 | &env->vfp.fp_status); | ||
27 | set_float_detect_tininess(float_tininess_before_rounding, | ||
28 | &env->vfp.standard_fp_status); | ||
29 | + set_float_detect_tininess(float_tininess_before_rounding, | ||
30 | + &env->vfp.fp_status_f16); | ||
31 | #ifndef CONFIG_USER_ONLY | ||
32 | if (kvm_enabled()) { | ||
33 | kvm_arm_reset_vcpu(cpu); | ||
34 | -- | ||
35 | 2.17.0 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Cc: qemu-stable@nongnu.org | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Message-id: 20180512003217.9105-5-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.c | 17 +++++++++++++++-- | ||
11 | 1 file changed, 15 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-a64.c | ||
16 | +++ b/target/arm/translate-a64.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) | ||
18 | bool sf = extract32(insn, 31, 1); | ||
19 | bool itof; | ||
20 | |||
21 | - if (sbit || (type > 1) | ||
22 | - || (!sf && scale < 32)) { | ||
23 | + if (sbit || (!sf && scale < 32)) { | ||
24 | + unallocated_encoding(s); | ||
25 | + return; | ||
26 | + } | ||
27 | + | ||
28 | + switch (type) { | ||
29 | + case 0: /* float32 */ | ||
30 | + case 1: /* float64 */ | ||
31 | + break; | ||
32 | + case 3: /* float16 */ | ||
33 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
34 | + break; | ||
35 | + } | ||
36 | + /* fallthru */ | ||
37 | + default: | ||
38 | unallocated_encoding(s); | ||
39 | return; | ||
40 | } | ||
41 | -- | ||
42 | 2.17.0 | ||
43 | |||
44 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | All the hard work is already done by vfp_expand_imm, we just need to | ||
4 | make sure we pick up the correct size. | ||
5 | |||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20180512003217.9105-11-richard.henderson@linaro.org | ||
12 | [rth: Merge unallocated_encoding check with TCGMemOp conversion.] | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/translate-a64.c | 20 +++++++++++++++++--- | ||
17 | 1 file changed, 17 insertions(+), 3 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/translate-a64.c | ||
22 | +++ b/target/arm/translate-a64.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | ||
24 | { | ||
25 | int rd = extract32(insn, 0, 5); | ||
26 | int imm8 = extract32(insn, 13, 8); | ||
27 | - int is_double = extract32(insn, 22, 2); | ||
28 | + int type = extract32(insn, 22, 2); | ||
29 | uint64_t imm; | ||
30 | TCGv_i64 tcg_res; | ||
31 | + TCGMemOp sz; | ||
32 | |||
33 | - if (is_double > 1) { | ||
34 | + switch (type) { | ||
35 | + case 0: | ||
36 | + sz = MO_32; | ||
37 | + break; | ||
38 | + case 1: | ||
39 | + sz = MO_64; | ||
40 | + break; | ||
41 | + case 3: | ||
42 | + sz = MO_16; | ||
43 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
44 | + break; | ||
45 | + } | ||
46 | + /* fallthru */ | ||
47 | + default: | ||
48 | unallocated_encoding(s); | ||
49 | return; | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | - imm = vfp_expand_imm(MO_32 + is_double, imm8); | ||
56 | + imm = vfp_expand_imm(sz, imm8); | ||
57 | |||
58 | tcg_res = tcg_const_i64(imm); | ||
59 | write_fp_dreg(s, rd, tcg_res); | ||
60 | -- | ||
61 | 2.17.0 | ||
62 | |||
63 | diff view generated by jsdifflib |
1 | Usually the logging of the CPU state produced by -d cpu is sufficient | 1 | The qemu-ga documentation is currently in qemu-ga.texi in |
---|---|---|---|
2 | to diagnose problems, but sometimes you want to see the state of | 2 | Texinfo format, which we present to the user as: |
3 | the floating point registers as well. We don't want to enable that | 3 | * a qemu-ga manpage |
4 | by default as it adds a lot of extra data to the log; instead, | 4 | * a section of the main qemu-doc HTML documentation |
5 | allow it to be optionally enabled via -d fpu. | 5 | |
6 | Convert the documentation to rST format, and present it to | ||
7 | the user as: | ||
8 | * a qemu-ga manpage | ||
9 | * part of the interop/ Sphinx manual | ||
6 | 10 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> |
9 | Message-id: 20180510130024.31678-1-peter.maydell@linaro.org | 13 | Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com> |
14 | Message-id: 20190905131040.8350-1-peter.maydell@linaro.org | ||
10 | --- | 15 | --- |
11 | include/qemu/log.h | 1 + | 16 | Makefile | 24 ++++--- |
12 | accel/tcg/cpu-exec.c | 9 ++++++--- | 17 | MAINTAINERS | 2 +- |
13 | util/log.c | 2 ++ | 18 | docs/conf.py | 18 ++--- |
14 | 3 files changed, 9 insertions(+), 3 deletions(-) | 19 | docs/interop/conf.py | 7 ++ |
20 | docs/interop/index.rst | 1 + | ||
21 | docs/interop/qemu-ga.rst | 133 +++++++++++++++++++++++++++++++++++++ | ||
22 | qemu-doc.texi | 5 -- | ||
23 | qemu-ga.texi | 137 --------------------------------------- | ||
24 | 8 files changed, 166 insertions(+), 161 deletions(-) | ||
25 | create mode 100644 docs/interop/qemu-ga.rst | ||
26 | delete mode 100644 qemu-ga.texi | ||
15 | 27 | ||
16 | diff --git a/include/qemu/log.h b/include/qemu/log.h | 28 | diff --git a/Makefile b/Makefile |
17 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/qemu/log.h | 30 | --- a/Makefile |
19 | +++ b/include/qemu/log.h | 31 | +++ b/Makefile |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool qemu_log_separate(void) | 32 | @@ -XXX,XX +XXX,XX @@ endif |
21 | #define CPU_LOG_PAGE (1 << 14) | 33 | endif |
22 | /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ | 34 | |
23 | #define CPU_LOG_TB_OP_IND (1 << 16) | 35 | ifdef BUILD_DOCS |
24 | +#define CPU_LOG_TB_FPU (1 << 17) | 36 | -DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 |
25 | 37 | +DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 docs/interop/qemu-ga.8 | |
26 | /* Lock output for a series of related logs. Since this is not needed | 38 | DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7 |
27 | * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we | 39 | DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7 |
28 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | 40 | DOCS+=docs/qemu-block-drivers.7 |
29 | index XXXXXXX..XXXXXXX 100644 | 41 | @@ -XXX,XX +XXX,XX @@ DESCS= |
30 | --- a/accel/tcg/cpu-exec.c | 42 | endif |
31 | +++ b/accel/tcg/cpu-exec.c | 43 | |
32 | @@ -XXX,XX +XXX,XX @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) | 44 | # Note that we manually filter-out the non-Sphinx documentation which |
33 | if (qemu_loglevel_mask(CPU_LOG_TB_CPU) | 45 | -# is currently built into the docs/interop directory in the build tree. |
34 | && qemu_log_in_addr_range(itb->pc)) { | 46 | +# is currently built into the docs/interop directory in the build tree, |
35 | qemu_log_lock(); | 47 | +# and also any sphinx-built manpages. |
36 | + int flags = 0; | 48 | define install-manual = |
37 | + if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { | 49 | for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done |
38 | + flags |= CPU_DUMP_FPU; | 50 | -for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done |
39 | + } | 51 | +for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done |
40 | #if defined(TARGET_I386) | 52 | endef |
41 | - log_cpu_state(cpu, CPU_DUMP_CCOP); | 53 | |
42 | -#else | 54 | # Note that we deliberately do not install the "devel" manual: it is |
43 | - log_cpu_state(cpu, 0); | 55 | @@ -XXX,XX +XXX,XX @@ ifdef CONFIG_TRACE_SYSTEMTAP |
44 | + flags |= CPU_DUMP_CCOP; | 56 | $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1" |
45 | #endif | 57 | endif |
46 | + log_cpu_state(cpu, flags); | 58 | ifneq (,$(findstring qemu-ga,$(TOOLS))) |
47 | qemu_log_unlock(); | 59 | - $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8" |
48 | } | 60 | + $(INSTALL_DATA) docs/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8" |
49 | #endif /* DEBUG_DISAS */ | 61 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)" |
50 | diff --git a/util/log.c b/util/log.c | 62 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)" |
51 | index XXXXXXX..XXXXXXX 100644 | 63 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7" |
52 | --- a/util/log.c | 64 | @@ -XXX,XX +XXX,XX @@ docs/version.texi: $(SRC_PATH)/VERSION config-host.mak |
53 | +++ b/util/log.c | 65 | sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html $(MANUAL_BUILDDIR)/interop/index.html $(MANUAL_BUILDDIR)/specs/index.html |
54 | @@ -XXX,XX +XXX,XX @@ const QEMULogItem qemu_log_items[] = { | 66 | |
55 | "show trace before each executed TB (lots of logs)" }, | 67 | # Canned command to build a single manual |
56 | { CPU_LOG_TB_CPU, "cpu", | 68 | -build-manual = $(call quiet-command,sphinx-build $(if $(V),,-q) -W -n -b html -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
57 | "show CPU registers before entering a TB (lots of logs)" }, | 69 | +# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man') |
58 | + { CPU_LOG_TB_FPU, "fpu", | 70 | +build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" sphinx-build $(if $(V),,-q) -W -n -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
59 | + "include FPU registers in the 'cpu' logging" }, | 71 | # We assume all RST files in the manual's directory are used in it |
60 | { CPU_LOG_MMU, "mmu", | 72 | manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py |
61 | "log MMU-related activities" }, | 73 | |
62 | { CPU_LOG_PCALL, "pcall", | 74 | $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel) |
75 | - $(call build-manual,devel) | ||
76 | + $(call build-manual,devel,html) | ||
77 | |||
78 | $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop) | ||
79 | - $(call build-manual,interop) | ||
80 | + $(call build-manual,interop,html) | ||
81 | |||
82 | $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs) | ||
83 | - $(call build-manual,specs) | ||
84 | + $(call build-manual,specs,html) | ||
85 | + | ||
86 | +$(MANUAL_BUILDDIR)/interop/qemu-ga.8: $(call manual-deps,interop) | ||
87 | + $(call build-manual,interop,man) | ||
88 | |||
89 | qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool | ||
90 | $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@") | ||
91 | @@ -XXX,XX +XXX,XX @@ qemu.1: qemu-option-trace.texi | ||
92 | qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi | ||
93 | fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi | ||
94 | qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi | ||
95 | -qemu-ga.8: qemu-ga.texi | ||
96 | docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi | ||
97 | docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi | ||
98 | scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi | ||
99 | @@ -XXX,XX +XXX,XX @@ txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt | ||
100 | qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \ | ||
101 | qemu-img.texi qemu-nbd.texi qemu-options.texi \ | ||
102 | qemu-tech.texi qemu-option-trace.texi \ | ||
103 | - qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \ | ||
104 | + qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi \ | ||
105 | qemu-monitor-info.texi docs/qemu-block-drivers.texi \ | ||
106 | docs/qemu-cpu-models.texi docs/security.texi | ||
107 | |||
108 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/MAINTAINERS | ||
111 | +++ b/MAINTAINERS | ||
112 | @@ -XXX,XX +XXX,XX @@ QEMU Guest Agent | ||
113 | M: Michael Roth <mdroth@linux.vnet.ibm.com> | ||
114 | S: Maintained | ||
115 | F: qga/ | ||
116 | -F: qemu-ga.texi | ||
117 | +F: docs/interop/qemu-ga.rst | ||
118 | F: scripts/qemu-guest-agent/ | ||
119 | F: tests/test-qga.c | ||
120 | F: docs/interop/qemu-ga-ref.texi | ||
121 | diff --git a/docs/conf.py b/docs/conf.py | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/docs/conf.py | ||
124 | +++ b/docs/conf.py | ||
125 | @@ -XXX,XX +XXX,XX @@ todo_include_todos = False | ||
126 | # with "option::" in the document being processed. Turn that off. | ||
127 | suppress_warnings = ["ref.option"] | ||
128 | |||
129 | +# The rst_epilog fragment is effectively included in every rST file. | ||
130 | +# We use it to define substitutions based on build config that | ||
131 | +# can then be used in the documentation. The fallback if the | ||
132 | +# environment variable is not set is for the benefit of readthedocs | ||
133 | +# style document building; our Makefile always sets the variable. | ||
134 | +confdir = os.getenv('CONFDIR', "/etc/qemu") | ||
135 | +rst_epilog = ".. |CONFDIR| replace:: ``" + confdir + "``\n" | ||
136 | + | ||
137 | # -- Options for HTML output ---------------------------------------------- | ||
138 | |||
139 | # The theme to use for HTML and HTML Help pages. See the documentation for | ||
140 | @@ -XXX,XX +XXX,XX @@ latex_documents = [ | ||
141 | |||
142 | |||
143 | # -- Options for manual page output --------------------------------------- | ||
144 | - | ||
145 | -# One entry per manual page. List of tuples | ||
146 | -# (source start file, name, description, authors, manual section). | ||
147 | -man_pages = [ | ||
148 | - (master_doc, 'qemu', u'QEMU Documentation', | ||
149 | - [author], 1) | ||
150 | -] | ||
151 | - | ||
152 | +# Individual manual/conf.py can override this to create man pages | ||
153 | +man_pages = [] | ||
154 | |||
155 | # -- Options for Texinfo output ------------------------------------------- | ||
156 | |||
157 | diff --git a/docs/interop/conf.py b/docs/interop/conf.py | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/docs/interop/conf.py | ||
160 | +++ b/docs/interop/conf.py | ||
161 | @@ -XXX,XX +XXX,XX @@ exec(compile(open(parent_config, "rb").read(), parent_config, 'exec')) | ||
162 | # This slightly misuses the 'description', but is the best way to get | ||
163 | # the manual title to appear in the sidebar. | ||
164 | html_theme_options['description'] = u'System Emulation Management and Interoperability Guide' | ||
165 | + | ||
166 | +# One entry per manual page. List of tuples | ||
167 | +# (source start file, name, description, authors, manual section). | ||
168 | +man_pages = [ | ||
169 | + ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent', | ||
170 | + ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8) | ||
171 | +] | ||
172 | diff --git a/docs/interop/index.rst b/docs/interop/index.rst | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/docs/interop/index.rst | ||
175 | +++ b/docs/interop/index.rst | ||
176 | @@ -XXX,XX +XXX,XX @@ Contents: | ||
177 | bitmaps | ||
178 | live-block-operations | ||
179 | pr-helper | ||
180 | + qemu-ga | ||
181 | vhost-user | ||
182 | vhost-user-gpu | ||
183 | diff --git a/docs/interop/qemu-ga.rst b/docs/interop/qemu-ga.rst | ||
184 | new file mode 100644 | ||
185 | index XXXXXXX..XXXXXXX | ||
186 | --- /dev/null | ||
187 | +++ b/docs/interop/qemu-ga.rst | ||
188 | @@ -XXX,XX +XXX,XX @@ | ||
189 | +QEMU Guest Agent | ||
190 | +================ | ||
191 | + | ||
192 | +Synopsis | ||
193 | +-------- | ||
194 | + | ||
195 | +**qemu-ga** [*OPTIONS*] | ||
196 | + | ||
197 | +Description | ||
198 | +----------- | ||
199 | + | ||
200 | +The QEMU Guest Agent is a daemon intended to be run within virtual | ||
201 | +machines. It allows the hypervisor host to perform various operations | ||
202 | +in the guest, such as: | ||
203 | + | ||
204 | +- get information from the guest | ||
205 | +- set the guest's system time | ||
206 | +- read/write a file | ||
207 | +- sync and freeze the filesystems | ||
208 | +- suspend the guest | ||
209 | +- reconfigure guest local processors | ||
210 | +- set user's password | ||
211 | +- ... | ||
212 | + | ||
213 | +qemu-ga will read a system configuration file on startup (located at | ||
214 | +|CONFDIR|\ ``/qemu-ga.conf`` by default), then parse remaining | ||
215 | +configuration options on the command line. For the same key, the last | ||
216 | +option wins, but the lists accumulate (see below for configuration | ||
217 | +file format). | ||
218 | + | ||
219 | +Options | ||
220 | +------- | ||
221 | + | ||
222 | +.. program:: qemu-ga | ||
223 | + | ||
224 | +.. option:: -m, --method=METHOD | ||
225 | + | ||
226 | + Transport method: one of ``unix-listen``, ``virtio-serial``, or | ||
227 | + ``isa-serial`` (``virtio-serial`` is the default). | ||
228 | + | ||
229 | +.. option:: -p, --path=PATH | ||
230 | + | ||
231 | + Device/socket path (the default for virtio-serial is | ||
232 | + ``/dev/virtio-ports/org.qemu.guest_agent.0``, | ||
233 | + the default for isa-serial is ``/dev/ttyS0``) | ||
234 | + | ||
235 | +.. option:: -l, --logfile=PATH | ||
236 | + | ||
237 | + Set log file path (default is stderr). | ||
238 | + | ||
239 | +.. option:: -f, --pidfile=PATH | ||
240 | + | ||
241 | + Specify pid file (default is ``/var/run/qemu-ga.pid``). | ||
242 | + | ||
243 | +.. option:: -F, --fsfreeze-hook=PATH | ||
244 | + | ||
245 | + Enable fsfreeze hook. Accepts an optional argument that specifies | ||
246 | + script to run on freeze/thaw. Script will be called with | ||
247 | + 'freeze'/'thaw' arguments accordingly (default is | ||
248 | + |CONFDIR|\ ``/fsfreeze-hook``). If using -F with an argument, do | ||
249 | + not follow -F with a space (for example: | ||
250 | + ``-F/var/run/fsfreezehook.sh``). | ||
251 | + | ||
252 | +.. option:: -t, --statedir=PATH | ||
253 | + | ||
254 | + Specify the directory to store state information (absolute paths only, | ||
255 | + default is ``/var/run``). | ||
256 | + | ||
257 | +.. option:: -v, --verbose | ||
258 | + | ||
259 | + Log extra debugging information. | ||
260 | + | ||
261 | +.. option:: -V, --version | ||
262 | + | ||
263 | + Print version information and exit. | ||
264 | + | ||
265 | +.. option:: -d, --daemon | ||
266 | + | ||
267 | + Daemonize after startup (detach from terminal). | ||
268 | + | ||
269 | +.. option:: -b, --blacklist=LIST | ||
270 | + | ||
271 | + Comma-separated list of RPCs to disable (no spaces, ``?`` to list | ||
272 | + available RPCs). | ||
273 | + | ||
274 | +.. option:: -D, --dump-conf | ||
275 | + | ||
276 | + Dump the configuration in a format compatible with ``qemu-ga.conf`` | ||
277 | + and exit. | ||
278 | + | ||
279 | +.. option:: -h, --help | ||
280 | + | ||
281 | + Display this help and exit. | ||
282 | + | ||
283 | +Files | ||
284 | +----- | ||
285 | + | ||
286 | + | ||
287 | +The syntax of the ``qemu-ga.conf`` configuration file follows the | ||
288 | +Desktop Entry Specification, here is a quick summary: it consists of | ||
289 | +groups of key-value pairs, interspersed with comments. | ||
290 | + | ||
291 | +:: | ||
292 | + | ||
293 | + # qemu-ga configuration sample | ||
294 | + [general] | ||
295 | + daemonize = 0 | ||
296 | + pidfile = /var/run/qemu-ga.pid | ||
297 | + verbose = 0 | ||
298 | + method = virtio-serial | ||
299 | + path = /dev/virtio-ports/org.qemu.guest_agent.0 | ||
300 | + statedir = /var/run | ||
301 | + | ||
302 | +The list of keys follows the command line options: | ||
303 | + | ||
304 | +============= =========== | ||
305 | +Key Key type | ||
306 | +============= =========== | ||
307 | +daemon boolean | ||
308 | +method string | ||
309 | +path string | ||
310 | +logfile string | ||
311 | +pidfile string | ||
312 | +fsfreeze-hook string | ||
313 | +statedir string | ||
314 | +verbose boolean | ||
315 | +blacklist string list | ||
316 | +============= =========== | ||
317 | + | ||
318 | +See also | ||
319 | +-------- | ||
320 | + | ||
321 | +:manpage:`qemu(1)` | ||
322 | diff --git a/qemu-doc.texi b/qemu-doc.texi | ||
323 | index XXXXXXX..XXXXXXX 100644 | ||
324 | --- a/qemu-doc.texi | ||
325 | +++ b/qemu-doc.texi | ||
326 | @@ -XXX,XX +XXX,XX @@ so should only be used with trusted guest OS. | ||
327 | |||
328 | @c man end | ||
329 | |||
330 | -@node QEMU Guest Agent | ||
331 | -@chapter QEMU Guest Agent invocation | ||
332 | - | ||
333 | -@include qemu-ga.texi | ||
334 | - | ||
335 | @node QEMU User space emulator | ||
336 | @chapter QEMU User space emulator | ||
337 | |||
338 | diff --git a/qemu-ga.texi b/qemu-ga.texi | ||
339 | deleted file mode 100644 | ||
340 | index XXXXXXX..XXXXXXX | ||
341 | --- a/qemu-ga.texi | ||
342 | +++ /dev/null | ||
343 | @@ -XXX,XX +XXX,XX @@ | ||
344 | -@example | ||
345 | -@c man begin SYNOPSIS | ||
346 | -@command{qemu-ga} [@var{OPTIONS}] | ||
347 | -@c man end | ||
348 | -@end example | ||
349 | - | ||
350 | -@c man begin DESCRIPTION | ||
351 | - | ||
352 | -The QEMU Guest Agent is a daemon intended to be run within virtual | ||
353 | -machines. It allows the hypervisor host to perform various operations | ||
354 | -in the guest, such as: | ||
355 | - | ||
356 | -@itemize | ||
357 | -@item | ||
358 | -get information from the guest | ||
359 | -@item | ||
360 | -set the guest's system time | ||
361 | -@item | ||
362 | -read/write a file | ||
363 | -@item | ||
364 | -sync and freeze the filesystems | ||
365 | -@item | ||
366 | -suspend the guest | ||
367 | -@item | ||
368 | -reconfigure guest local processors | ||
369 | -@item | ||
370 | -set user's password | ||
371 | -@item | ||
372 | -... | ||
373 | -@end itemize | ||
374 | - | ||
375 | -qemu-ga will read a system configuration file on startup (located at | ||
376 | -@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining | ||
377 | -configuration options on the command line. For the same key, the last | ||
378 | -option wins, but the lists accumulate (see below for configuration | ||
379 | -file format). | ||
380 | - | ||
381 | -@c man end | ||
382 | - | ||
383 | -@c man begin OPTIONS | ||
384 | -@table @option | ||
385 | -@item -m, --method=@var{method} | ||
386 | - Transport method: one of @samp{unix-listen}, @samp{virtio-serial}, or | ||
387 | - @samp{isa-serial} (@samp{virtio-serial} is the default). | ||
388 | - | ||
389 | -@item -p, --path=@var{path} | ||
390 | - Device/socket path (the default for virtio-serial is | ||
391 | - @samp{/dev/virtio-ports/org.qemu.guest_agent.0}, | ||
392 | - the default for isa-serial is @samp{/dev/ttyS0}) | ||
393 | - | ||
394 | -@item -l, --logfile=@var{path} | ||
395 | - Set log file path (default is stderr). | ||
396 | - | ||
397 | -@item -f, --pidfile=@var{path} | ||
398 | - Specify pid file (default is @samp{/var/run/qemu-ga.pid}). | ||
399 | - | ||
400 | -@item -F, --fsfreeze-hook=@var{path} | ||
401 | - Enable fsfreeze hook. Accepts an optional argument that specifies | ||
402 | - script to run on freeze/thaw. Script will be called with | ||
403 | - 'freeze'/'thaw' arguments accordingly (default is | ||
404 | - @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do | ||
405 | - not follow -F with a space (for example: | ||
406 | - @samp{-F/var/run/fsfreezehook.sh}). | ||
407 | - | ||
408 | -@item -t, --statedir=@var{path} | ||
409 | - Specify the directory to store state information (absolute paths only, | ||
410 | - default is @samp{/var/run}). | ||
411 | - | ||
412 | -@item -v, --verbose | ||
413 | - Log extra debugging information. | ||
414 | - | ||
415 | -@item -V, --version | ||
416 | - Print version information and exit. | ||
417 | - | ||
418 | -@item -d, --daemon | ||
419 | - Daemonize after startup (detach from terminal). | ||
420 | - | ||
421 | -@item -b, --blacklist=@var{list} | ||
422 | - Comma-separated list of RPCs to disable (no spaces, @samp{?} to list | ||
423 | - available RPCs). | ||
424 | - | ||
425 | -@item -D, --dump-conf | ||
426 | - Dump the configuration in a format compatible with @file{qemu-ga.conf} | ||
427 | - and exit. | ||
428 | - | ||
429 | -@item -h, --help | ||
430 | - Display this help and exit. | ||
431 | -@end table | ||
432 | - | ||
433 | -@c man end | ||
434 | - | ||
435 | -@c man begin FILES | ||
436 | - | ||
437 | -The syntax of the @file{qemu-ga.conf} configuration file follows the | ||
438 | -Desktop Entry Specification, here is a quick summary: it consists of | ||
439 | -groups of key-value pairs, interspersed with comments. | ||
440 | - | ||
441 | -@example | ||
442 | -# qemu-ga configuration sample | ||
443 | -[general] | ||
444 | -daemonize = 0 | ||
445 | -pidfile = /var/run/qemu-ga.pid | ||
446 | -verbose = 0 | ||
447 | -method = virtio-serial | ||
448 | -path = /dev/virtio-ports/org.qemu.guest_agent.0 | ||
449 | -statedir = /var/run | ||
450 | -@end example | ||
451 | - | ||
452 | -The list of keys follows the command line options: | ||
453 | -@table @option | ||
454 | -@item daemon= boolean | ||
455 | -@item method= string | ||
456 | -@item path= string | ||
457 | -@item logfile= string | ||
458 | -@item pidfile= string | ||
459 | -@item fsfreeze-hook= string | ||
460 | -@item statedir= string | ||
461 | -@item verbose= boolean | ||
462 | -@item blacklist= string list | ||
463 | -@end table | ||
464 | - | ||
465 | -@c man end | ||
466 | - | ||
467 | -@ignore | ||
468 | - | ||
469 | -@setfilename qemu-ga | ||
470 | -@settitle QEMU Guest Agent | ||
471 | - | ||
472 | -@c man begin AUTHOR | ||
473 | -Michael Roth <mdroth@linux.vnet.ibm.com> | ||
474 | -@c man end | ||
475 | - | ||
476 | -@c man begin SEEALSO | ||
477 | -qemu(1) | ||
478 | -@c man end | ||
479 | - | ||
480 | -@end ignore | ||
63 | -- | 481 | -- |
64 | 2.17.0 | 482 | 2.20.1 |
65 | 483 | ||
66 | 484 | diff view generated by jsdifflib |