summaryrefslogtreecommitdiff
path: root/sys/arch/powerpc/mac/adb_direct.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2001-05-29 01:20:45 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2001-05-29 01:20:45 +0000
commite07e9948e3071a8a12d05a1f9c284544f8955ad4 (patch)
treec384e011682b55a469a59e9448ece7cff2be5d2b /sys/arch/powerpc/mac/adb_direct.c
parentf10250830efbc5629cd45e21caff60f08b8158e1 (diff)
Hardware clock support, via adb.
This reduces the dependancy on openfirmware somewhat. Since Openfirmware is not actually used for anything, it is no longer necessary to configure it. so several lines of useless dmesg are now gone. This does not have clock setting code enabled yet. All of the code is in place, but needs further testing before it is trusted. I wish Apple would store UTC not localtime in the hardware clock, besides the fact that the clock base is 1904. Need to keep the clock sane for dual boot machines.
Diffstat (limited to 'sys/arch/powerpc/mac/adb_direct.c')
-rw-r--r--sys/arch/powerpc/mac/adb_direct.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/sys/arch/powerpc/mac/adb_direct.c b/sys/arch/powerpc/mac/adb_direct.c
index bfe6dec1b77..edf3d7909c8 100644
--- a/sys/arch/powerpc/mac/adb_direct.c
+++ b/sys/arch/powerpc/mac/adb_direct.c
@@ -1896,11 +1896,13 @@ adb_read_date_time(unsigned long *time)
{
u_char output[ADB_MAX_MSG_LENGTH];
int result;
+ int retcode;
volatile int flag = 0;
switch (adbHardware) {
case ADB_HW_II:
- return -1;
+ retcode = -1;
+ break;
case ADB_HW_IISI:
output[0] = 0x02; /* 2 byte message */
@@ -1908,18 +1910,22 @@ adb_read_date_time(unsigned long *time)
output[2] = 0x03; /* read date/time */
result = send_adb_IIsi((u_char *)output, (u_char *)output,
(void *)adb_op_comprout, (int *)&flag, (int)0);
- if (result != 0) /* exit if not sent */
- return -1;
+ if (result != 0) { /* exit if not sent */
+ retcode = -1;
+ break;
+ }
while (0 == flag) /* wait for result */
;
*time = (long)(*(long *)(output + 1));
- return 0;
+ retcode = 0;
+ break;
case ADB_HW_PB:
pm_read_date_time(time);
- return 0;
+ retcode = 0;
+ break;
case ADB_HW_CUDA:
output[0] = 0x02; /* 2 byte message */
@@ -1927,19 +1933,31 @@ adb_read_date_time(unsigned long *time)
output[2] = 0x03; /* read date/time */
result = send_adb_cuda((u_char *)output, (u_char *)output,
(void *)adb_op_comprout, (void *)&flag, (int)0);
- if (result != 0) /* exit if not sent */
- return -1;
+ if (result != 0) { /* exit if not sent */
+ retcode = -1;
+ break;
+ }
while (0 == flag) /* wait for result */
;
memcpy(time, output + 1, 4);
- return 0;
+ retcode = 0;
+ break;
case ADB_HW_UNKNOWN:
default:
- return -1;
+ retcode = -1;
+ break;
+ }
+ if (retcode == 0) {
+#define DIFF19041970 2082844800
+ *time -= DIFF19041970;
+
+ } else {
+ *time = 0;
}
+ return retcode;
}
/* caller should really use machine-independant version: setPramTime */
@@ -1951,6 +1969,7 @@ adb_set_date_time(unsigned long time)
int result;
volatile int flag = 0;
+ time += DIFF19041970;
switch (adbHardware) {
case ADB_HW_CUDA: