From nobody Wed Sep 21 09:59:59 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MXYmw1wqQz4cwRn; Wed, 21 Sep 2022 10:00:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MXYmw1P1lz3jDF; Wed, 21 Sep 2022 10:00:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663754400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=idbEtpi2w+nGw7aw7cJacIg2fJusRqEcbstA1g+i8Aw=; b=pQf2OQBfoh6H3Q2n6ksA8ARfQPpVFqV3kHN3pp3MGhCnkHfbO9cxvr/E8nHj+KRfaHh0tg Xu7dFRX9d5fyev5U8898bRTlhKNQgAeUz+JTShaUQreQ3s5c+xQqW761vLF4IACAVdy/IR ow6y23iOG3LJkskMjODPy5OINX+UUKD0cY65lWHpyjLpEDKMzo4kr4Mx2ypEWvm014zOx9 EmY3LuqEMP0ZKbWm/NgbL0hO8ElvaeDFpXIUEcYc98mWgx91FXxPkGMmZLkuVlWxYXAuPg gzdlLMTcU6R9eNPRtNGH3O+9N5TpOTjHLAl8rxF/ajCS1DPAEg9S9I2p7ef92g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MXYmw0Hf4z12H7; Wed, 21 Sep 2022 10:00:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28L9xxv3089483; Wed, 21 Sep 2022 09:59:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28L9xxfJ089482; Wed, 21 Sep 2022 09:59:59 GMT (envelope-from git) Date: Wed, 21 Sep 2022 09:59:59 GMT Message-Id: <202209210959.28L9xxfJ089482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 9526031cd560 - main - Create macros for the Arm timer IRQ indexes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9526031cd5606fe590ef69224d0db1af1603dcfe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663754400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=idbEtpi2w+nGw7aw7cJacIg2fJusRqEcbstA1g+i8Aw=; b=Qj7IsTi4jFAeuO2k3XsvfSwBVIFtj8Ur2/vObTYIJ1k2w2lJA4fKWR07mbT1DRepqMax5b SsHMp0VmHcDgnNKIHSeABCglxpxn7QZ751ttUQ4IZoGyYiY5OO4lJ4t1s9gMXoimGtZYLP aAh07yc8WZzrOIr5AZopM+hWh8gB8IfE3dfHjbc4zR2+IsdILIupawGwF+/rnBQ5D/p2+t Kprk41ANFu6op8+uuNcmSvn/P3ZTjro0WJAm86oSEFrl4tcQeLqcydyDbDEBMpa37lanGG TGCVtyrwluEJojrVgssxzfIFhuG02TlwCiEMEj+mneRFYSmuo9xxUOKSuMwBzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663754400; a=rsa-sha256; cv=none; b=EPZG7u7ZXV4/b8mcjBR5uM8FSALcaYlu/IipqzwTJj26/edtLZ/9CZSLyG1OdZ+TneAKb6 RBbArW+UT0KoU5Opeg0K1D5yKMCD7chojvRLNcdAjLCPlv6Qy/gJoVhDtlCpBXOkXOtlDw oOlfElMDzcydGl64qq3Oiz+Bo/OILBTWIVBit0ajniEXDhRZGyB7Pbasz8AMVyy0+9sHjr i7OBDuhr5EdSf76B17t8S4zjJSVtbgPZSXa66eAre51N87rM0J7Ak7RyYltWmjwqQtij/c yC/Am51sPwUnSr2E0YLUeMEbWc8DpjUV3MJQEWWDgL72q8Ez9aAaTLV2Hze4bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=9526031cd5606fe590ef69224d0db1af1603dcfe commit 9526031cd5606fe590ef69224d0db1af1603dcfe Author: Andrew Turner AuthorDate: 2022-09-14 16:29:29 +0000 Commit: Andrew Turner CommitDate: 2022-09-21 09:59:08 +0000 Create macros for the Arm timer IRQ indexes Rather than hard coding these values use a macro to document which interrupt is being used. Reviewed by: emaste Obtained from: https://github.com/FreeBSD-UPB/freebsd-src (earlier version) Sponsored by: Innovate UK Sponsored by: The FreeBSD Foundation Sponsored by: University Politehnica of Bucharest Differential Revision: https://reviews.freebsd.org/D36600 --- sys/arm/arm/generic_timer.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c index ebaadd5f38a8..aabcfd138012 100644 --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -78,6 +78,12 @@ __FBSDID("$FreeBSD$"); #include #endif +#define GT_PHYS_SECURE 0 +#define GT_PHYS_NONSECURE 1 +#define GT_VIRT 2 +#define GT_HYP 3 +#define GT_IRQ_COUNT 4 + #define GT_CTRL_ENABLE (1 << 0) #define GT_CTRL_INT_MASK (1 << 1) #define GT_CTRL_INT_STAT (1 << 2) @@ -93,8 +99,8 @@ __FBSDID("$FreeBSD$"); #define GT_CNTKCTL_PL0PCTEN (1 << 0) /* PL0 CNTPCT and CNTFRQ access */ struct arm_tmr_softc { - struct resource *res[4]; - void *ihl[4]; + struct resource *res[GT_IRQ_COUNT]; + void *ihl[GT_IRQ_COUNT]; uint64_t (*get_cntxct)(bool); uint32_t clkfreq; struct eventtimer et; @@ -104,10 +110,10 @@ struct arm_tmr_softc { static struct arm_tmr_softc *arm_tmr_sc = NULL; static struct resource_spec timer_spec[] = { - { SYS_RES_IRQ, 0, RF_ACTIVE }, /* Secure */ - { SYS_RES_IRQ, 1, RF_ACTIVE }, /* Non-secure */ - { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL }, /* Virt */ - { SYS_RES_IRQ, 3, RF_ACTIVE | RF_OPTIONAL }, /* Hyp */ + { SYS_RES_IRQ, GT_PHYS_SECURE, RF_ACTIVE }, + { SYS_RES_IRQ, GT_PHYS_NONSECURE, RF_ACTIVE }, + { SYS_RES_IRQ, GT_VIRT, RF_ACTIVE | RF_OPTIONAL }, + { SYS_RES_IRQ, GT_HYP, RF_ACTIVE | RF_OPTIONAL }, { -1, 0 } }; @@ -412,9 +418,12 @@ arm_tmr_acpi_identify(driver_t *driver, device_t parent) goto out; } - arm_tmr_acpi_add_irq(parent, dev, 0, gtdt->SecureEl1Interrupt); - arm_tmr_acpi_add_irq(parent, dev, 1, gtdt->NonSecureEl1Interrupt); - arm_tmr_acpi_add_irq(parent, dev, 2, gtdt->VirtualTimerInterrupt); + arm_tmr_acpi_add_irq(parent, dev, GT_PHYS_SECURE, + gtdt->SecureEl1Interrupt); + arm_tmr_acpi_add_irq(parent, dev, GT_PHYS_NONSECURE, + gtdt->NonSecureEl1Interrupt); + arm_tmr_acpi_add_irq(parent, dev, GT_VIRT, + gtdt->VirtualTimerInterrupt); out: acpi_unmap_table(gtdt); @@ -480,17 +489,17 @@ arm_tmr_attach(device_t dev) #ifdef __aarch64__ /* Use the virtual timer if we have one. */ - if (sc->res[2] != NULL) { + if (sc->res[GT_VIRT] != NULL) { sc->physical = false; - first_timer = 2; - last_timer = 2; + first_timer = GT_VIRT; + last_timer = GT_VIRT; } else #endif /* Otherwise set up the secure and non-secure physical timers. */ { sc->physical = true; - first_timer = 0; - last_timer = 1; + first_timer = GT_PHYS_SECURE; + last_timer = GT_PHYS_NONSECURE; } arm_tmr_sc = sc; @@ -509,7 +518,7 @@ arm_tmr_attach(device_t dev) } /* Disable the virtual timer until we are ready */ - if (sc->res[2] != NULL) + if (sc->res[GT_VIRT] != NULL) arm_tmr_disable(false); /* And the physical */ if (sc->physical)