[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/36] hw/arm/stellaris: Replace magic numbers by definitions
From: |
Peter Maydell |
Subject: |
[PULL 10/36] hw/arm/stellaris: Replace magic numbers by definitions |
Date: |
Tue, 28 Jan 2025 20:12:48 +0000 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Add definitions for the number of controllers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20250110160204.74997-5-philmd@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/stellaris.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 4df02138ac5..dd342b17d2a 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -49,6 +49,11 @@
#define NUM_IRQ_LINES 64
#define NUM_PRIO_BITS 3
+#define NUM_GPIO 7
+#define NUM_UART 4
+#define NUM_GPTM 4
+#define NUM_I2C 2
+
typedef const struct {
const char *name;
uint32_t did0;
@@ -989,12 +994,12 @@ static const stellaris_board_info stellaris_boards[] = {
static void stellaris_init(MachineState *ms, stellaris_board_info *board)
{
- static const int uart_irq[] = {5, 6, 33, 34};
- static const int timer_irq[] = {19, 21, 23, 35};
- static const uint32_t gpio_addr[7] =
+ static const int uart_irq[NUM_UART] = {5, 6, 33, 34};
+ static const int timer_irq[NUM_GPTM] = {19, 21, 23, 35};
+ static const uint32_t gpio_addr[NUM_GPIO] =
{ 0x40004000, 0x40005000, 0x40006000, 0x40007000,
0x40024000, 0x40025000, 0x40026000};
- static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31};
+ static const int gpio_irq[NUM_GPIO] = {0, 1, 2, 3, 4, 30, 31};
/* Memory map of SoC devices, from
* Stellaris LM3S6965 Microcontroller Data Sheet (rev I)
@@ -1030,9 +1035,9 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
*/
Object *soc_container;
- DeviceState *gpio_dev[7], *armv7m, *nvic;
- qemu_irq gpio_in[7][8];
- qemu_irq gpio_out[7][8];
+ DeviceState *gpio_dev[NUM_GPIO], *armv7m, *nvic;
+ qemu_irq gpio_in[NUM_GPIO][8];
+ qemu_irq gpio_out[NUM_GPIO][8];
qemu_irq adc;
int sram_size;
int flash_size;
@@ -1124,7 +1129,7 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
} else {
adc = NULL;
}
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < NUM_GPTM; i++) {
if (board->dc2 & (0x10000 << i)) {
SysBusDevice *sbd;
@@ -1158,7 +1163,7 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
}
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < NUM_GPIO; i++) {
if (board->dc4 & (1 << i)) {
gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i],
qdev_get_gpio_in(nvic,
@@ -1179,7 +1184,7 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
}
}
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < NUM_UART; i++) {
if (board->dc2 & (1 << i)) {
SysBusDevice *sbd;
--
2.34.1
- [PULL 01/36] hw/arm/nrf51: Rename ARMv7MState 'cpu' -> 'armv7m', (continued)
- [PULL 01/36] hw/arm/nrf51: Rename ARMv7MState 'cpu' -> 'armv7m', Peter Maydell, 2025/01/28
- [PULL 02/36] hw/arm/stellaris: Add 'armv7m' local variable, Peter Maydell, 2025/01/28
- [PULL 03/36] hw/arm/v7m: Remove use of &first_cpu in machine_init(), Peter Maydell, 2025/01/28
- [PULL 04/36] hw/char/imx_serial: Fix reset value of UFCR register, Peter Maydell, 2025/01/28
- [PULL 08/36] hw/arm/stellaris: Constify read-only arrays, Peter Maydell, 2025/01/28
- [PULL 05/36] hw/char/imx_serial: Update all state before restarting ageing timer, Peter Maydell, 2025/01/28
- [PULL 06/36] hw/pci-host/designware: Expose MSI IRQ, Peter Maydell, 2025/01/28
- [PULL 07/36] hw/arm/stellaris: Link each board schematic, Peter Maydell, 2025/01/28
- [PULL 09/36] hw/arm/stellaris: Remove incorrect unimplemented i2c-0 at 0x40002000, Peter Maydell, 2025/01/28
- [PULL 11/36] hw/arm/stellaris: Use DEVCAP macro to access DeviceCapability registers, Peter Maydell, 2025/01/28
- [PULL 10/36] hw/arm/stellaris: Replace magic numbers by definitions,
Peter Maydell <=
- [PULL 12/36] hw/arm/stellaris: Map both I2C controllers, Peter Maydell, 2025/01/28
- [PULL 14/36] target/arm: arm_reset_sve_state() should set FPSR, not FPCR, Peter Maydell, 2025/01/28
- [PULL 13/36] tests/functional: Add a test for the arm microbit machine, Peter Maydell, 2025/01/28
- [PULL 15/36] target/arm: Use FPSR_ constants in vfp_exceptbits_from_host(), Peter Maydell, 2025/01/28
- [PULL 16/36] target/arm: Use uint32_t in vfp_exceptbits_from_host(), Peter Maydell, 2025/01/28
- [PULL 17/36] target/arm: Define new fp_status_a32 and fp_status_a64, Peter Maydell, 2025/01/28
- [PULL 19/36] target/arm: Use fp_status_a64 or fp_status_a32 in is_ebf(), Peter Maydell, 2025/01/28
- [PULL 18/36] target/arm: Use vfp.fp_status_a64 in A64-only helper functions, Peter Maydell, 2025/01/28
- [PULL 22/36] target/arm: Use FPST_A32 in A32 decoder, Peter Maydell, 2025/01/28
- [PULL 20/36] target/arm: Use fp_status_a32 in vjvct helper, Peter Maydell, 2025/01/28