| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /* kernel/time.c
- *
- * Copyright (C) 2021, 2022 intirain.
- *
- * This file is part of evx.
- *
- * evx is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evx is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evx. If not, see <https://www.gnu.org/licenses/>
- */
- #include <kernel/init.h>
- #include <kernel/module.h>
- #include <kernel/time.h>
- #include <kernel/kmlog.h>
- #include <arch/time.h>
- #include <config.h>
- #include <sys/types.h>
- struct ktime kernel_startup_time;
- struct timezone timezone;
- int __init time_init(void) {
- timezone.utcplus = CONFIG_TIMEZONE;
- read_hw_clock(&kernel_startup_time);
- show_time(&kernel_startup_time);
- return 0;
- }
- void show_time(struct ktime *tm) {
- show_time_tz(tm, &timezone);
- }
- void show_time_tz(struct ktime *tts, struct timezone *tz) {
- struct ktime tm = *tts;
- tm.hour += tz->utcplus;
- if (tm.hour >= 24) {
- tm.hour -= 24;
- tm.day++;
- /* I said, I've no interest in doing these
- * BORING but necessary things. Just leave them here. */
- }
- kmlog(KERN_INFO "%d-%d-%d %d:%d:%d (UTC %c%d)\n",
- tm.year, tm.month, tm.day,
- tm.hour, tm.min, tm.sec,
- tz->utcplus > 0 ? '+' : '-', tz->utcplus);
- }
- kernel_init(time_init);
|