diff options
-rwxr-xr-x | hyra-build.sh | 1 | ||||
-rw-r--r-- | sys/arch/amd64/isa/mc1468.c | 15 | ||||
-rw-r--r-- | sys/fs/ctlfs.c | 20 | ||||
-rw-r--r-- | sys/include/sys/time.h | 3 | ||||
-rw-r--r-- | usr.bin/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/date/Makefile (renamed from usr.bin/time/Makefile) | 2 | ||||
-rw-r--r-- | usr.bin/date/date.c (renamed from usr.bin/time/time.c) | 39 | ||||
-rw-r--r-- | usr.bin/mrow/mrow.c | 3 | ||||
-rw-r--r-- | usr.bin/osh/osh.c | 2 |
9 files changed, 60 insertions, 27 deletions
diff --git a/hyra-build.sh b/hyra-build.sh index d8903c8..caa6e45 100755 --- a/hyra-build.sh +++ b/hyra-build.sh @@ -153,7 +153,6 @@ result() { then hard_clean # XXX: For safety echo "Installer is at ./Hyra-install.iso" - echo "!!WARNING!!: Installer is _automatic_" echo "!!NOTE!!: OSMORA is not responsible for incidental data loss" else echo "Boot image is at ./Hyra.iso" diff --git a/sys/arch/amd64/isa/mc1468.c b/sys/arch/amd64/isa/mc1468.c index f1421a4..531751b 100644 --- a/sys/arch/amd64/isa/mc1468.c +++ b/sys/arch/amd64/isa/mc1468.c @@ -82,6 +82,12 @@ mc1468_updating(void) static bool mc1468_date_synced(struct date *a, struct date *b) { + if (a->year != b->year) + return false; + if (a->month != b->month) + return false; + if (a->day != b->day) + return false; if (a->sec != b->sec) return false; if (a->min != b->min) @@ -100,6 +106,9 @@ mc1468_date_synced(struct date *a, struct date *b) static void mc1468_bcd_conv(struct date *dp) { + dp->year = (dp->year & 0x0F) + ((dp->year / 16) * 10); + dp->month = (dp->month & 0x0F) + ((dp->month / 16) * 10); + dp->day = (dp->day & 0x0F) + ((dp->day / 16) * 10); dp->sec = (dp->sec & 0x0F) + ((dp->sec / 16) * 10); dp->min = (dp->min & 0x0F) + ((dp->min / 16) * 10); dp->hour = (dp->hour & 0x0F) + (((dp->hour & 0x70) / 16) * 10); @@ -117,6 +126,9 @@ mc1468_bcd_conv(struct date *dp) static void __mc1468_get_time(struct date *dp) { + dp->year = mc1468_read(0x09); + dp->month = mc1468_read(0x08); + dp->day = mc1468_read(0x07); dp->sec = mc1468_read(0x00); dp->min = mc1468_read(0x02); dp->hour = mc1468_read(0x04); @@ -144,6 +156,9 @@ mc1468_get_date(struct date *dp) md_pause(); } __mc1468_get_time(&date_last); + date_cur.year = date_last.year; + date_cur.month = date_last.month; + date_cur.day = date_last.day; date_cur.sec = date_last.sec; date_cur.min = date_last.min; date_cur.hour = date_last.hour; diff --git a/sys/fs/ctlfs.c b/sys/fs/ctlfs.c index efbf448..64d3a1a 100644 --- a/sys/fs/ctlfs.c +++ b/sys/fs/ctlfs.c @@ -371,25 +371,7 @@ ctlfs_read(struct vnode *vp, struct sio_txn *sio) static int ctlfs_reclaim(struct vnode *vp) { - struct ctlfs_hdr *hp; - - if (vp->data == NULL) { - return 0; - } - - /* Ensure the magic is correct */ - hp = vp->data; - switch (hp->magic) { - case CTLFS_NODE_MAG: - case CTLFS_ENTRY_MAG: - dynfree(hp->name); - break; - default: - pr_error("reclaim: bad magic in vp\n"); - break; - } - - dynfree(vp->data); + vp->data = NULL; return 0; } diff --git a/sys/include/sys/time.h b/sys/include/sys/time.h index 8563fc7..ce66885 100644 --- a/sys/include/sys/time.h +++ b/sys/include/sys/time.h @@ -46,6 +46,9 @@ struct timespec { }; struct date { + uint16_t year; + uint8_t month; + uint8_t day; uint8_t sec; uint8_t min; uint8_t hour; diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 8b22b73..9b241d8 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -9,7 +9,7 @@ all: make -C kmsg/ $(ARGS) make -C fetch/ $(ARGS) make -C kfgwm/ $(ARGS) - make -C time/ $(ARGS) + make -C date/ $(ARGS) make -C mex/ $(ARGS) make -C beep/ $(ARGS) make -C mrow/ $(ARGS) diff --git a/usr.bin/time/Makefile b/usr.bin/date/Makefile index 9ac98b4..09ff299 100644 --- a/usr.bin/time/Makefile +++ b/usr.bin/date/Makefile @@ -2,5 +2,5 @@ include user.mk CFILES = $(shell find . -name "*.c") -$(ROOT)/base/usr/bin/time: +$(ROOT)/base/usr/bin/date: gcc $(CFILES) -Iinclude/ -o $@ $(INTERNAL_CFLAGS) diff --git a/usr.bin/time/time.c b/usr.bin/date/date.c index 2f3b11f..a47e3eb 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/date/date.c @@ -28,14 +28,34 @@ */ #include <sys/time.h> +#include <sys/cdefs.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> +#define MONTHS_PER_YEAR 12 +#define DAYS_PER_WEEK 7 + +/* Months of the year */ +static const char *montab[] = { + "Jan", "Feb", "Mar", + "Apr", "May", "Jun", + "Jul", "Aug", "Sep", + "Oct", "Nov", "Dec" +}; + +/* Days of the week */ +static const char *daytab[] = { + "Sat", "Sun", "Mon", + "Tue", "Wed", "Thu", + "Fri" +}; + int main(void) { - char date_str[16]; + const char *day, *month; + char date_str[32]; struct date d; int rtc_fd; @@ -46,8 +66,21 @@ main(void) read(rtc_fd, &d, sizeof(d)); close(rtc_fd); - snprintf(date_str, sizeof(date_str), "%02d:%02d:%02d\n", - d.hour, d.min, d.sec); + /* This should not happen */ + if (__unlikely(d.month > MONTHS_PER_YEAR)) { + printf("got bad month %d from RTC\n", d.month); + return -1; + } + if (__unlikely(d.month == 0 || d.day == 0)) { + printf("got zero month/day from RTC\n"); + return -1; + } + + day = daytab[d.day % DAYS_PER_WEEK]; + month = montab[d.month - 1]; + + snprintf(date_str, sizeof(date_str), "%s %s %d %02d:%02d:%02d\n", + day, month, d.day, d.hour, d.min, d.sec); fputs(date_str, stdout); return 0; } diff --git a/usr.bin/mrow/mrow.c b/usr.bin/mrow/mrow.c index ac4ee0d..ea9594a 100644 --- a/usr.bin/mrow/mrow.c +++ b/usr.bin/mrow/mrow.c @@ -36,6 +36,7 @@ #include <stdio.h> #include <time.h> #include <stdlib.h> +#include <stdbool.h> #define IS_ASCII(C) ((C) > 0 && (C) < 127) @@ -45,7 +46,7 @@ #define SPRITE_WIDTH 20 #define SPRITE_HEIGHT 20 -#define MAX_MOUSE_SPEED 3 +#define MAX_MOUSE_SPEED 2 #define MIN_MOUSE_SPEED 1 #define PLAYER_SPEED 30 diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index db8865d..efb159e 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -55,7 +55,7 @@ "fetch - System information\n" \ "kfg - Start up kfgwm\n" \ "bell - Toggle backspace bell\n" \ - "time - Get the current time\n" \ + "date - Get the current date\n" \ "clear - Clear the screen\n" \ "exit - Exit the shell" |