Deleted Added
full compact
atrtc.c (27696) atrtc.c (28487)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
37 * $Id: clock.c,v 1.97 1997/07/22 20:12:04 fsmp Exp $
37 * $Id: clock.c,v 1.8 1997/08/21 04:51:12 smp Exp smp $
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written

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

61#ifdef CLK_CALIBRATION_LOOP
62#include <machine/cons.h>
63#endif
64#include <machine/cpu.h>
65#include <machine/frame.h>
66#include <machine/ipl.h>
67#ifdef APIC_IO
68#include <machine/smp.h>
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written

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

61#ifdef CLK_CALIBRATION_LOOP
62#include <machine/cons.h>
63#endif
64#include <machine/cpu.h>
65#include <machine/frame.h>
66#include <machine/ipl.h>
67#ifdef APIC_IO
68#include <machine/smp.h>
69#include <machine/smptests.h> /** NEW_STRATEGY (,SMP_TIMER_NC) */
70#endif /* APIC_IO */
71
72#include <i386/isa/icu.h>
73#include <i386/isa/isa.h>
74#include <i386/isa/rtc.h>
75#include <i386/isa/timerreg.h>
76
69#endif /* APIC_IO */
70
71#include <i386/isa/icu.h>
72#include <i386/isa/isa.h>
73#include <i386/isa/rtc.h>
74#include <i386/isa/timerreg.h>
75
76#include <i386/isa/intr_machdep.h>
77#include <sys/interrupt.h>
78
77/*
78 * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
79 * can use a simple formula for leap years.
80 */
81#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
82#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
83
84#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))

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

854 /* Setting stathz to nonzero early helps avoid races. */
855 stathz = RTC_NOPROFRATE;
856 profhz = RTC_PROFRATE;
857 }
858
859 /* Finish initializing 8253 timer 0. */
860#ifdef APIC_IO
861
79/*
80 * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
81 * can use a simple formula for leap years.
82 */
83#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
84#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
85
86#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))

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

856 /* Setting stathz to nonzero early helps avoid races. */
857 stathz = RTC_NOPROFRATE;
858 profhz = RTC_PROFRATE;
859 }
860
861 /* Finish initializing 8253 timer 0. */
862#ifdef APIC_IO
863
862#ifdef NEW_STRATEGY
863#ifdef SMP_TIMER_NC
864#error 'options SMP_TIMER_NC' no longer used, remove & reconfig.
865#endif /** XXX SMP_TIMER_NC */
866
867 /* 1st look for ExtInt on pin 0 */
868 if (apic_int_type(0, 0) == 3) {
869 /*
870 * Allow 8254 timer to INTerrupt 8259:
871 * re-initialize master 8259:
872 * reset; prog 4 bytes, single ICU, edge triggered
873 */
874 outb(IO_ICU1, 0x13);

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

892 /* XXX if (bootverbose) */
893 printf("APIC_IO: routing 8254 via pin 2\n");
894 }
895
896 /* better write that 8254 INT discover code... */
897 else
898 panic("neither pin 0 or pin 2 works for 8254");
899
864 /* 1st look for ExtInt on pin 0 */
865 if (apic_int_type(0, 0) == 3) {
866 /*
867 * Allow 8254 timer to INTerrupt 8259:
868 * re-initialize master 8259:
869 * reset; prog 4 bytes, single ICU, edge triggered
870 */
871 outb(IO_ICU1, 0x13);

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

889 /* XXX if (bootverbose) */
890 printf("APIC_IO: routing 8254 via pin 2\n");
891 }
892
893 /* better write that 8254 INT discover code... */
894 else
895 panic("neither pin 0 or pin 2 works for 8254");
896
900#else /** NEW_STRATEGY */
901
902 /* 8254 is traditionally on ISA IRQ0 */
903#if defined(SMP_TIMER_NC)
904 x = -1;
905#else
906 x = isa_apic_pin(0);
907#endif /** XXX SMP_TIMER_NC */
908
909 if (x < 0) {
910 /* bummer, attempt to redirect thru the 8259 */
911 if (bootverbose)
912 printf("APIC missing 8254 connection\n");
913
914 /* allow 8254 timer to INTerrupt 8259 */
915 x = inb(IO_ICU1 + 1); /* current mask in 8259 */
916 x &= ~1; /* clear 8254 timer mask */
917 outb(IO_ICU1 + 1, x); /* write new mask */
918
919 /* program IO APIC for type 3 INT on INT0 */
920 if (ext_int_setup(0, 0) < 0)
921 panic("8254 redirect impossible!");
922 x = 0; /* 8259 is on 0 */
923 }
924
925#endif /** NEW_STRATEGY */
926
927 /* setup the vectors */
928 vec[x] = (u_int)vec8254;
929 Xintr8254 = (u_int)ivectors[x];
930 mask8254 = (1 << x);
931
932 register_intr(/* irq */ x, /* XXX id */ 0, /* flags */ 0,
933 /* XXX */ (inthand2_t *)clkintr, &clk_imask,
934 /* unit */ 0);

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

961 diag = rtcin(RTC_DIAG);
962 if (diag != 0)
963 printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
964
965#ifdef APIC_IO
966 if (isa_apic_pin(8) != 8)
967 panic("APIC RTC != 8");
968#endif /* APIC_IO */
897 /* setup the vectors */
898 vec[x] = (u_int)vec8254;
899 Xintr8254 = (u_int)ivectors[x];
900 mask8254 = (1 << x);
901
902 register_intr(/* irq */ x, /* XXX id */ 0, /* flags */ 0,
903 /* XXX */ (inthand2_t *)clkintr, &clk_imask,
904 /* unit */ 0);

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

931 diag = rtcin(RTC_DIAG);
932 if (diag != 0)
933 printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
934
935#ifdef APIC_IO
936 if (isa_apic_pin(8) != 8)
937 panic("APIC RTC != 8");
938#endif /* APIC_IO */
939
969 register_intr(/* irq */ 8, /* XXX id */ 1, /* flags */ 0,
970 /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
971 /* unit */ 0);
940 register_intr(/* irq */ 8, /* XXX id */ 1, /* flags */ 0,
941 /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
942 /* unit */ 0);
943
972#ifdef APIC_IO
973 INTREN(APIC_IRQ8);
974#else
975 INTREN(IRQ8);
976#endif /* APIC_IO */
977
978 writertc(RTC_STATUSB, rtc_statusb);
979}

--- 77 unchanged lines hidden ---
944#ifdef APIC_IO
945 INTREN(APIC_IRQ8);
946#else
947 INTREN(IRQ8);
948#endif /* APIC_IO */
949
950 writertc(RTC_STATUSB, rtc_statusb);
951}

--- 77 unchanged lines hidden ---