From nobody Thu Jan 13 23:24:23 2022 X-Original-To: dev-commits-src-main@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 6D94819635B4; Thu, 13 Jan 2022 23:24:24 +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 4JZgVw1pzFz3Pck; Thu, 13 Jan 2022 23:24:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642116264; 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=9Lnjp71k4ZWsAt3BzGxl1IvKE5KB9515KwasZFFekBA=; b=DZxIII4hMlbcs8qaIZM4GeKpfp8oci/j3lnYAPuEHr9BDgqIHqPNdnJ93YJLRKiVK99kWM NwE1nwvziBbJPqDnKIAXNb7HOx/ZAZjXe44GijrT+awEKq25dnBLRcDWDbPXwkWUZjq8vy dYnlYYBZ/H0SVzuiqrjy6onDpxNxPquBKgvtf1jx43WOVvBhQjDScytqGfMOXwKSJ4xGZA UvEFKpi/86dlIGMTccE0B31xehbxa+jJbPiOnb0kszGZVXO7FCp1hPnl0t5+VG4kGuMkKl be6z7QF4rIUSCJXrynddiWkkTKwsrqUJwOgdj+eSNHWet60U2dGimEgyrh43cw== 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 C0829116A; Thu, 13 Jan 2022 23:24:23 +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 20DNONf7090926; Thu, 13 Jan 2022 23:24:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20DNONU7090925; Thu, 13 Jan 2022 23:24:23 GMT (envelope-from git) Date: Thu, 13 Jan 2022 23:24:23 GMT Message-Id: <202201132324.20DNONU7090925@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: e1ef6c0ef256 - main - atrtc: reads Century field from FADT table List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e1ef6c0ef256f797d629b9490db3f0034b28ae43 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642116264; 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=9Lnjp71k4ZWsAt3BzGxl1IvKE5KB9515KwasZFFekBA=; b=BVvBjmMPtU+4ZyzXbmEsPNaJmK1XCPFD6H2BjeHGEWsxRkcmbpG1tW7I/5T0h0zBrg8CbS DNZ9G4hhpNOOIMjbo6+24v60l5BjMS2yvHOvp8PQQOm9b+AEhvTlEyhOYtsMRI9HjKyqbC DLY1NMXoPw2YQXmH6/r0Gko23GNhqRG3HzXYN8A6J+EDXyHDBhchMCdTXgRaXCeluJl3Qu +Fl4d19enb/n+K77p7T1eF96dl2mBSOlnxsdl87uCH7VpbbOdKIwsfT2yjflR2bXxI1HB8 sQaXMT4/HmXyR1wFesevFl+eNVogLHAwtGMIL5D8vQUesjq0YbTmxLPkEZpnJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642116264; a=rsa-sha256; cv=none; b=KzPe44db49SEa+FeMpRmR14erWge0eQfzVW0Zbfvy04m2yzutvD4YgjMkyMWbrzQW6uFG7 PrANQ6m4i4+Q1AyIPkm5BWddNQ7xKnR+y1A902TEnpsESeInEQjeei5tj7mZo1ILo2AGu5 GIqOVJ8Tl80Q8VqZOQa8JgeTcyanVXY7BGx0hgF0sNHcB7X4ctKQ4suZ95RXiCWlvCAJGR gF2eTQ/rVIji6VwAu00/Df4kGkEUvOmmh2+b0XJ/ifToYAHzVnE2Le7ozEKwIC8iYoNRL7 SoiFsYNcwG/mAzfK5QWnhLw+aXl8TQw/2/FF6WslDaP45dp8+f3LCZdxx0T9aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=e1ef6c0ef256f797d629b9490db3f0034b28ae43 commit e1ef6c0ef256f797d629b9490db3f0034b28ae43 Author: Austin Zhang AuthorDate: 2022-01-13 17:13:25 +0000 Commit: Eric van Gyzen CommitDate: 2022-01-13 17:24:00 +0000 atrtc: reads Century field from FADT table The ACPI spec describes the FADT->Century field as: The RTC CMOS RAM index to the century of data value (hundred and thousand year decimals). If this field contains a zero, then the RTC centenary feature is not supported. If this field has a non-zero value, then this field contains an index into RTC RAM space that OSPM can use to program the centenary field. Use this field to decide whether to program the CENTURY register of the CMOS RTC device. Reviewed by: akumar3@isilon.com, dab, vangyzen MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D33667 MFC after: 1 week Sponsored by: Dell EMC Isilon --- sys/x86/isa/atrtc.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/sys/x86/isa/atrtc.c b/sys/x86/isa/atrtc.c index cad8015435d0..aff838c53851 100644 --- a/sys/x86/isa/atrtc.c +++ b/sys/x86/isa/atrtc.c @@ -79,6 +79,7 @@ MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc_time", MTX_DEF); int atrtcclock_disable = 0; +static int rtc_century = 0; static int rtc_reg = -1; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusb = RTCSB_24HR; @@ -420,6 +421,31 @@ atrtc_acpi_disabled(void) #endif } +static int +rtc_acpi_century_get(void) +{ +#ifdef DEV_ACPI + ACPI_TABLE_FADT *fadt; + vm_paddr_t physaddr; + int century; + + physaddr = acpi_find_table(ACPI_SIG_FADT); + if (physaddr == 0) + return (0); + + fadt = acpi_map_table(physaddr, ACPI_SIG_FADT); + if (fadt == NULL) + return (0); + + century = fadt->Century; + acpi_unmap_table(fadt); + + return (century); +#else + return (0); +#endif +} + static int atrtc_probe(device_t dev) { @@ -435,6 +461,7 @@ atrtc_probe(device_t dev) device_set_desc(dev, "AT realtime clock"); return (BUS_PROBE_LOW_PRIORITY); } + rtc_century = rtc_acpi_century_get(); return (result); } @@ -548,9 +575,8 @@ atrtc_settime(device_t dev __unused, struct timespec *ts) rtcout_locked(RTC_DAY, bct.day); rtcout_locked(RTC_MONTH, bct.mon); rtcout_locked(RTC_YEAR, bct.year & 0xff); -#ifdef USE_RTC_CENTURY - rtcout_locked(RTC_CENTURY, bct.year >> 8); -#endif + if (rtc_century) + rtcout_locked(rtc_century, bct.year >> 8); /* * Re-enable RTC updates and interrupts. @@ -592,9 +618,8 @@ atrtc_gettime(device_t dev, struct timespec *ts) bct.day = rtcin_locked(RTC_DAY); bct.mon = rtcin_locked(RTC_MONTH); bct.year = rtcin_locked(RTC_YEAR); -#ifdef USE_RTC_CENTURY - bct.year |= rtcin_locked(RTC_CENTURY) << 8; -#endif + if (rtc_century) + bct.year |= rtcin_locked(rtc_century) << 8; mtx_unlock_spin(&atrtc_lock); mtx_unlock(&atrtc_time_lock); /* dow is unused in timespec conversion and we have no nsec info. */