diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index b6e810605..794e9a993 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -185,7 +185,7 @@ lspci_mod_CFLAGS = $(COMMON_CFLAGS)
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
-datetime_mod_SOURCES = lib/i386/datetime.c
+datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index 4ee334325..5481cf1f7 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -122,7 +122,7 @@ lspci_mod_CFLAGS = $(COMMON_CFLAGS)
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
-datetime_mod_SOURCES = lib/i386/datetime.c
+datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index 598e46043..baba84939 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -306,7 +306,7 @@ pxecmd_mod_CFLAGS = $(COMMON_CFLAGS)
pxecmd_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
-datetime_mod_SOURCES = lib/i386/datetime.c
+datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
diff --git a/conf/mips-yeeloong.rmk b/conf/mips-yeeloong.rmk
index d28194ebc..4257bba74 100644
--- a/conf/mips-yeeloong.rmk
+++ b/conf/mips-yeeloong.rmk
@@ -48,6 +48,25 @@ mmap_mod_CFLAGS = $(COMMON_CFLAGS)
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
+# For datetime.mod
+pkglib_MODULES += datetime.mod
+datetime_mod_SOURCES = lib/cmos_datetime.c
+datetime_mod_CFLAGS = $(COMMON_CFLAGS)
+datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For date.mod
+pkglib_MODULES += date.mod
+date_mod_SOURCES = commands/date.c
+date_mod_CFLAGS = $(COMMON_CFLAGS)
+date_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For datehook.mod
+pkglib_MODULES += datehook.mod
+datehook_mod_SOURCES = hook/datehook.c
+datehook_mod_CFLAGS = $(COMMON_CFLAGS)
+datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in
diff --git a/include/grub/cmos.h b/include/grub/cmos.h
new file mode 100644
index 000000000..f508e3bf6
--- /dev/null
+++ b/include/grub/cmos.h
@@ -0,0 +1,72 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB 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.
+ *
+ * GRUB 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 GRUB. If not, see .
+ */
+
+#ifndef GRUB_CMOS_H
+#define GRUB_CMOS_H 1
+
+#include
+#include
+#include
+
+#define GRUB_CMOS_INDEX_SECOND 0
+#define GRUB_CMOS_INDEX_SECOND_ALARM 1
+#define GRUB_CMOS_INDEX_MINUTE 2
+#define GRUB_CMOS_INDEX_MINUTE_ALARM 3
+#define GRUB_CMOS_INDEX_HOUR 4
+#define GRUB_CMOS_INDEX_HOUR_ALARM 5
+#define GRUB_CMOS_INDEX_DAY_OF_WEEK 6
+#define GRUB_CMOS_INDEX_DAY_OF_MONTH 7
+#define GRUB_CMOS_INDEX_MONTH 8
+#define GRUB_CMOS_INDEX_YEAR 9
+
+#define GRUB_CMOS_INDEX_STATUS_A 0xA
+#define GRUB_CMOS_INDEX_STATUS_B 0xB
+#define GRUB_CMOS_INDEX_STATUS_C 0xC
+#define GRUB_CMOS_INDEX_STATUS_D 0xD
+
+#define GRUB_CMOS_STATUS_B_DAYLIGHT 1
+#define GRUB_CMOS_STATUS_B_24HOUR 2
+#define GRUB_CMOS_STATUS_B_BINARY 4
+
+static inline grub_uint8_t
+grub_bcd_to_num (grub_uint8_t a)
+{
+ return ((a >> 4) * 10 + (a & 0xF));
+}
+
+static inline grub_uint8_t
+grub_num_to_bcd (grub_uint8_t a)
+{
+ return (((a / 10) << 4) + (a % 10));
+}
+
+static inline grub_uint8_t
+grub_cmos_read (grub_uint8_t index)
+{
+ grub_outb (index, GRUB_CMOS_ADDR_REG);
+ return grub_inb (GRUB_CMOS_DATA_REG);
+}
+
+static inline void
+grub_cmos_write (grub_uint8_t index, grub_uint8_t value)
+{
+ grub_outb (index, GRUB_CMOS_ADDR_REG);
+ grub_outb (value, GRUB_CMOS_DATA_REG);
+}
+
+#endif /* GRUB_CMOS_H */
diff --git a/include/grub/i386/cmos.h b/include/grub/i386/cmos.h
index 1c0530dba..8b1fa3586 100644
--- a/include/grub/i386/cmos.h
+++ b/include/grub/i386/cmos.h
@@ -20,55 +20,9 @@
#define GRUB_CPU_CMOS_H 1
#include
-#include
+#include
#define GRUB_CMOS_ADDR_REG 0x70
#define GRUB_CMOS_DATA_REG 0x71
-#define GRUB_CMOS_INDEX_SECOND 0
-#define GRUB_CMOS_INDEX_SECOND_ALARM 1
-#define GRUB_CMOS_INDEX_MINUTE 2
-#define GRUB_CMOS_INDEX_MINUTE_ALARM 3
-#define GRUB_CMOS_INDEX_HOUR 4
-#define GRUB_CMOS_INDEX_HOUR_ALARM 5
-#define GRUB_CMOS_INDEX_DAY_OF_WEEK 6
-#define GRUB_CMOS_INDEX_DAY_OF_MONTH 7
-#define GRUB_CMOS_INDEX_MONTH 8
-#define GRUB_CMOS_INDEX_YEAR 9
-
-#define GRUB_CMOS_INDEX_STATUS_A 0xA
-#define GRUB_CMOS_INDEX_STATUS_B 0xB
-#define GRUB_CMOS_INDEX_STATUS_C 0xC
-#define GRUB_CMOS_INDEX_STATUS_D 0xD
-
-#define GRUB_CMOS_STATUS_B_DAYLIGHT 1
-#define GRUB_CMOS_STATUS_B_24HOUR 2
-#define GRUB_CMOS_STATUS_B_BINARY 4
-
-static inline grub_uint8_t
-grub_bcd_to_num (grub_uint8_t a)
-{
- return ((a >> 4) * 10 + (a & 0xF));
-}
-
-static inline grub_uint8_t
-grub_num_to_bcd (grub_uint8_t a)
-{
- return (((a / 10) << 4) + (a % 10));
-}
-
-static inline grub_uint8_t
-grub_cmos_read (grub_uint8_t index)
-{
- grub_outb (index, GRUB_CMOS_ADDR_REG);
- return grub_inb (GRUB_CMOS_DATA_REG);
-}
-
-static inline void
-grub_cmos_write (grub_uint8_t index, grub_uint8_t value)
-{
- grub_outb (index, GRUB_CMOS_ADDR_REG);
- grub_outb (value, GRUB_CMOS_DATA_REG);
-}
-
#endif /* GRUB_CPU_CMOS_H */
diff --git a/include/grub/mips/cmos.h b/include/grub/mips/cmos.h
new file mode 100644
index 000000000..79a7a4c1b
--- /dev/null
+++ b/include/grub/mips/cmos.h
@@ -0,0 +1 @@
+#include
diff --git a/include/grub/mips/yeeloong/cmos.h b/include/grub/mips/yeeloong/cmos.h
new file mode 100644
index 000000000..f2a32d736
--- /dev/null
+++ b/include/grub/mips/yeeloong/cmos.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB 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.
+ *
+ * GRUB 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 GRUB. If not, see .
+ */
+
+#ifndef GRUB_CPU_CMOS_H
+#define GRUB_CPU_CMOS_H 1
+
+#include
+#include
+
+#define GRUB_CMOS_ADDR_REG 0xbfd00070
+#define GRUB_CMOS_DATA_REG 0xbfd00071
+
+#endif /* GRUB_CPU_CMOS_H */
diff --git a/lib/i386/datetime.c b/lib/cmos_datetime.c
similarity index 95%
rename from lib/i386/datetime.c
rename to lib/cmos_datetime.c
index 63858ed03..8db60b48c 100644
--- a/lib/i386/datetime.c
+++ b/lib/cmos_datetime.c
@@ -1,7 +1,7 @@
-/* kern/i386/datetime.c - x86 CMOS datetime function.
+/* kern/cmos_datetime.c - CMOS datetime function.
*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2008 Free Software Foundation, Inc.
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
*/
#include
-#include
+#include
grub_err_t
grub_get_datetime (struct grub_datetime *datetime)