From 377fa66e5e306b9656fd180ae72d9c9ee5503311 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Thu, 4 Oct 2001 15:26:05 +0000 Subject: Use EFI (or some reasonable simulation) to read the RTC. --- sys/ia64/ia64/eficlock.c | 98 ++++++++++++++++++++++++++++++++++++++ sys/ia64/ia64/sscclock.c | 121 ----------------------------------------------- 2 files changed, 98 insertions(+), 121 deletions(-) create mode 100644 sys/ia64/ia64/eficlock.c delete mode 100644 sys/ia64/ia64/sscclock.c (limited to 'sys') diff --git a/sys/ia64/ia64/eficlock.c b/sys/ia64/ia64/eficlock.c new file mode 100644 index 000000000000..bf1054928386 --- /dev/null +++ b/sys/ia64/ia64/eficlock.c @@ -0,0 +1,98 @@ +/*- + * Copyright (c) 2000 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include + +#include +#include + +static void +eficlock_init(kobj_t dev) +{ +} + +/* + * Get the time of day, based on the clock's value and/or the base value. + */ +static void +eficlock_get(kobj_t dev, time_t base, struct clocktime *ct) +{ + EFI_TIME time; + + ia64_efi_runtime->GetTime(&time, 0); + + ct->sec = time.Second; + ct->min = time.Minute; + ct->hour = time.Hour; + ct->dow = 0; /* XXX not used */ + ct->day = time.Day; + ct->mon = time.Month; + ct->year = time.Year - 1900; +} + +/* + * Reset the TODR based on the time value. + */ +static void +eficlock_set(kobj_t dev, struct clocktime *ct) +{ + printf("eficlock: TODR not set\n"); +} + +static int +eficlock_getsecs(kobj_t dev, int *secp) +{ + return ETIMEDOUT; +} + +static device_method_t eficlock_methods[] = { + /* clock interface */ + DEVMETHOD(clock_init, eficlock_init), + DEVMETHOD(clock_get, eficlock_get), + DEVMETHOD(clock_set, eficlock_set), + DEVMETHOD(clock_getsecs, eficlock_getsecs), + + { 0, 0 } +}; + +DEFINE_CLASS(eficlock, eficlock_methods, sizeof(struct kobj)); + +static void +eficlock_create(void *arg) +{ + kobj_t clock; + clock = (kobj_t) + kobj_create(&eficlock_class, M_TEMP, M_NOWAIT); + clockattach(clock); +} + +SYSINIT(eficlock, SI_SUB_DRIVERS,SI_ORDER_MIDDLE, eficlock_create, NULL); diff --git a/sys/ia64/ia64/sscclock.c b/sys/ia64/ia64/sscclock.c deleted file mode 100644 index f25b5f3a2aff..000000000000 --- a/sys/ia64/ia64/sscclock.c +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * Copyright (c) 2000 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include - -#include - -struct ssc_time { - int year; - int month; - int day; - int hour; - int minute; - int second; - int msec; - int wday; -}; - -#define SSC_GET_RTC 65 - -static u_int64_t -ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) -{ - register u_int64_t ret0 __asm("r8"); - - __asm __volatile("mov r15=%1\n\t" - "break 0x80001" - : "=r"(ret0) - : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3)); - return ret0; -} - -static void -sscclock_init(device_t dev) -{ -} - -/* - * Get the time of day, based on the clock's value and/or the base value. - */ -static void -sscclock_get(device_t dev, time_t base, struct clocktime *ct) -{ - struct ssc_time time; - - ssc(ia64_tpa((vm_offset_t) &time), 0, 0, 0, SSC_GET_RTC); - - ct->sec = time.second; - ct->min = time.minute; - ct->hour = time.hour; - ct->dow = time.wday; - ct->day = time.day; - ct->mon = time.month + 1; - ct->year = time.year; -} - -/* - * Reset the TODR based on the time value. - */ -static void -sscclock_set(device_t dev, struct clocktime *ct) -{ - printf("sscclock: TODR not set\n"); -} - -static int -sscclock_getsecs(device_t dev, int *secp) -{ - return ETIMEDOUT; -} - -static device_method_t sscclock_methods[] = { - /* clock interface */ - DEVMETHOD(clock_init, sscclock_init), - DEVMETHOD(clock_get, sscclock_get), - DEVMETHOD(clock_set, sscclock_set), - DEVMETHOD(clock_getsecs, sscclock_getsecs), - - { 0, 0 } -}; - -DEFINE_CLASS(sscclock, sscclock_methods, sizeof(struct kobj)); - -static void -sscclock_create(void *arg) -{ - device_t clock = (device_t) - kobj_create(&sscclock_class, M_TEMP, M_NOWAIT); - clockattach(clock); -} - -SYSINIT(sscdev, SI_SUB_DRIVERS,SI_ORDER_MIDDLE, sscclock_create, NULL); -- cgit v1.3