Deleted Added
full compact
time.c (55342) time.c (68358)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/boot/pc98/libpc98/time.c 55342 2000-01-03 15:43:52Z nyan $
26 * $FreeBSD: head/sys/boot/pc98/libpc98/time.c 68358 2000-11-05 12:35:41Z nyan $
27 */
28
29#include <stand.h>
30#include <btxv86.h>
31#ifdef PC98
32#include <machine/cpufunc.h>
33#endif
27 */
28
29#include <stand.h>
30#include <btxv86.h>
31#ifdef PC98
32#include <machine/cpufunc.h>
33#endif
34#include "bootstrap.h"
35#include "libi386.h"
34
35/*
36 * Return the time in seconds since the beginning of the day.
37 *
38 * If we pass midnight, don't wrap back to 0.
39 *
40 * XXX uses undocumented BCD support from libstand.
41 */
42
43time_t
44time(time_t *t)
45{
46 static time_t lasttime, now;
36
37/*
38 * Return the time in seconds since the beginning of the day.
39 *
40 * If we pass midnight, don't wrap back to 0.
41 *
42 * XXX uses undocumented BCD support from libstand.
43 */
44
45time_t
46time(time_t *t)
47{
48 static time_t lasttime, now;
47 int hr, min, sec;
49 int hr, minute, sec;
48
49#ifdef PC98
50 unsigned char bios_time[6];
51#endif
52
53 v86.ctl = 0;
54#ifdef PC98
55 v86.addr = 0x1c; /* int 0x1c, function 0 */
56 v86.eax = 0x0000;
57 v86.es = VTOPSEG(bios_time);
58 v86.ebx = VTOPOFF(bios_time);
59#else
60 v86.addr = 0x1a; /* int 0x1a, function 2 */
61 v86.eax = 0x0200;
62#endif
63 v86int();
64
65#ifdef PC98
66 hr = bcd2bin(bios_time[3]);
50
51#ifdef PC98
52 unsigned char bios_time[6];
53#endif
54
55 v86.ctl = 0;
56#ifdef PC98
57 v86.addr = 0x1c; /* int 0x1c, function 0 */
58 v86.eax = 0x0000;
59 v86.es = VTOPSEG(bios_time);
60 v86.ebx = VTOPOFF(bios_time);
61#else
62 v86.addr = 0x1a; /* int 0x1a, function 2 */
63 v86.eax = 0x0200;
64#endif
65 v86int();
66
67#ifdef PC98
68 hr = bcd2bin(bios_time[3]);
67 min = bcd2bin(bios_time[4]);
69 minute = bcd2bin(bios_time[4]);
68 sec = bcd2bin(bios_time[5]);
69#else
70 hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */
70 sec = bcd2bin(bios_time[5]);
71#else
72 hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */
71 min = bcd2bin(v86.ecx & 0xff); /* minute in %cl */
73 minute = bcd2bin(v86.ecx & 0xff); /* minute in %cl */
72 sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */
73#endif
74
74 sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */
75#endif
76
75 now = hr * 3600 + min * 60 + sec;
77 now = hr * 3600 + minute * 60 + sec;
76 if (now < lasttime)
77 now += 24 * 3600;
78 lasttime = now;
79
80 if (t != NULL)
81 *t = now;
82 return(now);
83}

--- 25 unchanged lines hidden ---
78 if (now < lasttime)
79 now += 24 * 3600;
80 lasttime = now;
81
82 if (t != NULL)
83 *t = now;
84 return(now);
85}

--- 25 unchanged lines hidden ---