From: kettenis Date: Sun, 30 Apr 2023 17:24:24 +0000 (+0000) Subject: Remove the EFI RTC implementation on amd64. Since all amd64 systems we X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dc48ee408f2bc27bf37f128a55abe6361e70b5e3;p=openbsd Remove the EFI RTC implementation on amd64. Since all amd64 systems we know have a MC146818A compatible RTC this code isn't actually used. But there are systems that have a buggy EFI implementation that blows up when we call the GetTime runtime service to check whether the RTC functionality is implemented. ok mlarkin@, dlg@ --- diff --git a/sys/arch/amd64/amd64/efi_machdep.c b/sys/arch/amd64/amd64/efi_machdep.c index a5f4563ce7d..97be06b224b 100644 --- a/sys/arch/amd64/amd64/efi_machdep.c +++ b/sys/arch/amd64/amd64/efi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efi_machdep.c,v 1.5 2023/01/14 12:11:10 kettenis Exp $ */ +/* $OpenBSD: efi_machdep.c,v 1.6 2023/04/30 17:24:24 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis @@ -40,8 +40,6 @@ const struct cfattach efi_ca = { }; void efi_map_runtime(struct efi_softc *); -int efi_gettime(struct todr_chip_handle *, struct timeval *); -int efi_settime(struct todr_chip_handle *, struct timeval *); label_t efi_jmpbuf; @@ -67,8 +65,6 @@ efi_attach(struct device *parent, struct device *self, void *aux) uint64_t system_table; bus_space_handle_t memh; EFI_SYSTEM_TABLE *st; - EFI_TIME time; - EFI_STATUS status; uint16_t major, minor; int i; @@ -121,25 +117,6 @@ efi_attach(struct device *parent, struct device *self, void *aux) printf(" rev 0x%x\n", st->FirmwareRevision); } efi_leave(sc); - - if (efi_enter_check(sc)) - return; - status = sc->sc_rs->GetTime(&time, NULL); - efi_leave(sc); - if (status != EFI_SUCCESS) - return; - - /* - * EDK II implementations provide an implementation of - * GetTime() that returns a fixed compiled-in time on hardware - * without a (supported) RTC. So only use this interface as a - * last resort. - */ - sc->sc_todr.cookie = sc; - sc->sc_todr.todr_gettime = efi_gettime; - sc->sc_todr.todr_settime = efi_settime; - sc->sc_todr.todr_quality = -1000; - todr_attach(&sc->sc_todr); } void @@ -243,65 +220,3 @@ efi_leave(struct efi_softc *sc) lcr3(sc->sc_cr3); intr_restore(sc->sc_psw); } - -int -efi_gettime(struct todr_chip_handle *handle, struct timeval *tv) -{ - struct efi_softc *sc = handle->cookie; - struct clock_ymdhms dt; - EFI_TIME time; - EFI_STATUS status; - - if (efi_enter_check(sc)) - return EFAULT; - status = sc->sc_rs->GetTime(&time, NULL); - efi_leave(sc); - if (status != EFI_SUCCESS) - return EIO; - - dt.dt_year = time.Year; - dt.dt_mon = time.Month; - dt.dt_day = time.Day; - dt.dt_hour = time.Hour; - dt.dt_min = time.Minute; - dt.dt_sec = time.Second; - - if (dt.dt_sec > 59 || dt.dt_min > 59 || dt.dt_hour > 23 || - dt.dt_day > 31 || dt.dt_day == 0 || - dt.dt_mon > 12 || dt.dt_mon == 0 || - dt.dt_year < POSIX_BASE_YEAR) - return EINVAL; - - tv->tv_sec = clock_ymdhms_to_secs(&dt); - tv->tv_usec = 0; - return 0; -} - -int -efi_settime(struct todr_chip_handle *handle, struct timeval *tv) -{ - struct efi_softc *sc = handle->cookie; - struct clock_ymdhms dt; - EFI_TIME time; - EFI_STATUS status; - - clock_secs_to_ymdhms(tv->tv_sec, &dt); - - time.Year = dt.dt_year; - time.Month = dt.dt_mon; - time.Day = dt.dt_day; - time.Hour = dt.dt_hour; - time.Minute = dt.dt_min; - time.Second = dt.dt_sec; - time.Nanosecond = 0; - time.TimeZone = 0; - time.Daylight = 0; - - if (efi_enter_check(sc)) - return EFAULT; - status = sc->sc_rs->SetTime(&time); - efi_leave(sc); - if (status != EFI_SUCCESS) - return EIO; - return 0; -}