tsc.c (92765) | tsc.c (93264) |
---|---|
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 * $FreeBSD: head/sys/i386/i386/tsc.c 92765 2002-03-20 07:51:46Z alfred $ | 37 * $FreeBSD: head/sys/i386/i386/tsc.c 93264 2002-03-27 05:39:23Z dillon $ |
38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 944 unchanged lines hidden (view full) --- 990void 991cpu_initclocks() 992{ 993 int diag; 994#ifdef APIC_IO 995 int apic_8254_trial; 996 void *clkdesc; 997#endif /* APIC_IO */ | 38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 944 unchanged lines hidden (view full) --- 990void 991cpu_initclocks() 992{ 993 int diag; 994#ifdef APIC_IO 995 int apic_8254_trial; 996 void *clkdesc; 997#endif /* APIC_IO */ |
998 register_t crit; |
|
998 999 if (statclock_disable) { 1000 /* 1001 * The stat interrupt mask is different without the 1002 * statistics clock. Also, don't set the interrupt 1003 * flag which would normally cause the RTC to generate 1004 * interrupts. 1005 */ --- 18 unchanged lines hidden (view full) --- 1024 apic_8254_intr = apic_irq(0, 0); 1025 setup_8254_mixed_mode(); 1026 } else 1027 panic("APIC_IO: Cannot route 8254 interrupt to CPU"); 1028 } 1029 1030 inthand_add("clk", apic_8254_intr, (driver_intr_t *)clkintr, NULL, 1031 INTR_TYPE_CLK | INTR_FAST, &clkdesc); | 999 1000 if (statclock_disable) { 1001 /* 1002 * The stat interrupt mask is different without the 1003 * statistics clock. Also, don't set the interrupt 1004 * flag which would normally cause the RTC to generate 1005 * interrupts. 1006 */ --- 18 unchanged lines hidden (view full) --- 1025 apic_8254_intr = apic_irq(0, 0); 1026 setup_8254_mixed_mode(); 1027 } else 1028 panic("APIC_IO: Cannot route 8254 interrupt to CPU"); 1029 } 1030 1031 inthand_add("clk", apic_8254_intr, (driver_intr_t *)clkintr, NULL, 1032 INTR_TYPE_CLK | INTR_FAST, &clkdesc); |
1033 crit = intr_disable(); |
|
1032 mtx_lock_spin(&icu_lock); 1033 INTREN(1 << apic_8254_intr); 1034 mtx_unlock_spin(&icu_lock); | 1034 mtx_lock_spin(&icu_lock); 1035 INTREN(1 << apic_8254_intr); 1036 mtx_unlock_spin(&icu_lock); |
1037 intr_restore(crit); |
|
1035 1036#else /* APIC_IO */ 1037 1038 /* 1039 * XXX Check the priority of this interrupt handler. I 1040 * couldn't find anything suitable in the BSD/OS code (grog, 1041 * 19 July 2000). 1042 */ 1043 inthand_add("clk", 0, (driver_intr_t *)clkintr, NULL, 1044 INTR_TYPE_CLK | INTR_FAST, NULL); | 1038 1039#else /* APIC_IO */ 1040 1041 /* 1042 * XXX Check the priority of this interrupt handler. I 1043 * couldn't find anything suitable in the BSD/OS code (grog, 1044 * 19 July 2000). 1045 */ 1046 inthand_add("clk", 0, (driver_intr_t *)clkintr, NULL, 1047 INTR_TYPE_CLK | INTR_FAST, NULL); |
1048 crit = intr_disable(); |
|
1045 mtx_lock_spin(&icu_lock); 1046 INTREN(IRQ0); 1047 mtx_unlock_spin(&icu_lock); | 1049 mtx_lock_spin(&icu_lock); 1050 INTREN(IRQ0); 1051 mtx_unlock_spin(&icu_lock); |
1052 intr_restore(crit); |
|
1048 1049#endif /* APIC_IO */ 1050 1051 /* Initialize RTC. */ 1052 writertc(RTC_STATUSA, rtc_statusa); 1053 writertc(RTC_STATUSB, RTCSB_24HR); 1054 1055 /* Don't bother enabling the statistics clock. */ --- 6 unchanged lines hidden (view full) --- 1062#ifdef APIC_IO 1063 if (isa_apic_irq(8) != 8) 1064 panic("APIC RTC != 8"); 1065#endif /* APIC_IO */ 1066 1067 inthand_add("rtc", 8, (driver_intr_t *)rtcintr, NULL, 1068 INTR_TYPE_CLK | INTR_FAST, NULL); 1069 | 1053 1054#endif /* APIC_IO */ 1055 1056 /* Initialize RTC. */ 1057 writertc(RTC_STATUSA, rtc_statusa); 1058 writertc(RTC_STATUSB, RTCSB_24HR); 1059 1060 /* Don't bother enabling the statistics clock. */ --- 6 unchanged lines hidden (view full) --- 1067#ifdef APIC_IO 1068 if (isa_apic_irq(8) != 8) 1069 panic("APIC RTC != 8"); 1070#endif /* APIC_IO */ 1071 1072 inthand_add("rtc", 8, (driver_intr_t *)rtcintr, NULL, 1073 INTR_TYPE_CLK | INTR_FAST, NULL); 1074 |
1075 crit = intr_disable(); |
|
1070 mtx_lock_spin(&icu_lock); 1071#ifdef APIC_IO 1072 INTREN(APIC_IRQ8); 1073#else 1074 INTREN(IRQ8); 1075#endif /* APIC_IO */ 1076 mtx_unlock_spin(&icu_lock); | 1076 mtx_lock_spin(&icu_lock); 1077#ifdef APIC_IO 1078 INTREN(APIC_IRQ8); 1079#else 1080 INTREN(IRQ8); 1081#endif /* APIC_IO */ 1082 mtx_unlock_spin(&icu_lock); |
1083 intr_restore(crit); |
|
1077 1078 writertc(RTC_STATUSB, rtc_statusb); 1079 1080#ifdef APIC_IO 1081 if (apic_8254_trial) { 1082 1083 printf("APIC_IO: Testing 8254 interrupt delivery\n"); 1084 while (read_intr_count(8) < 6) 1085 ; /* nothing */ 1086 if (read_intr_count(apic_8254_intr) < 3) { 1087 /* 1088 * The MP table is broken. 1089 * The 8254 was not connected to the specified pin 1090 * on the IO APIC. 1091 * Workaround: Limited variant of mixed mode. 1092 */ | 1084 1085 writertc(RTC_STATUSB, rtc_statusb); 1086 1087#ifdef APIC_IO 1088 if (apic_8254_trial) { 1089 1090 printf("APIC_IO: Testing 8254 interrupt delivery\n"); 1091 while (read_intr_count(8) < 6) 1092 ; /* nothing */ 1093 if (read_intr_count(apic_8254_intr) < 3) { 1094 /* 1095 * The MP table is broken. 1096 * The 8254 was not connected to the specified pin 1097 * on the IO APIC. 1098 * Workaround: Limited variant of mixed mode. 1099 */ |
1100 1101 crit = intr_disable(); |
|
1093 mtx_lock_spin(&icu_lock); 1094 INTRDIS(1 << apic_8254_intr); 1095 mtx_unlock_spin(&icu_lock); | 1102 mtx_lock_spin(&icu_lock); 1103 INTRDIS(1 << apic_8254_intr); 1104 mtx_unlock_spin(&icu_lock); |
1105 intr_restore(crit); |
|
1096 inthand_remove(clkdesc); 1097 printf("APIC_IO: Broken MP table detected: " 1098 "8254 is not connected to " 1099 "IOAPIC #%d intpin %d\n", 1100 int_to_apicintpin[apic_8254_intr].ioapic, 1101 int_to_apicintpin[apic_8254_intr].int_pin); 1102 /* 1103 * Revoke current ISA IRQ 0 assignment and --- 6 unchanged lines hidden (view full) --- 1110 revoke_apic_irq(apic_8254_intr); 1111 assign_apic_irq(0, 0, apic_8254_intr); 1112 } 1113 apic_8254_intr = apic_irq(0, 0); 1114 setup_8254_mixed_mode(); 1115 inthand_add("clk", apic_8254_intr, 1116 (driver_intr_t *)clkintr, NULL, 1117 INTR_TYPE_CLK | INTR_FAST, NULL); | 1106 inthand_remove(clkdesc); 1107 printf("APIC_IO: Broken MP table detected: " 1108 "8254 is not connected to " 1109 "IOAPIC #%d intpin %d\n", 1110 int_to_apicintpin[apic_8254_intr].ioapic, 1111 int_to_apicintpin[apic_8254_intr].int_pin); 1112 /* 1113 * Revoke current ISA IRQ 0 assignment and --- 6 unchanged lines hidden (view full) --- 1120 revoke_apic_irq(apic_8254_intr); 1121 assign_apic_irq(0, 0, apic_8254_intr); 1122 } 1123 apic_8254_intr = apic_irq(0, 0); 1124 setup_8254_mixed_mode(); 1125 inthand_add("clk", apic_8254_intr, 1126 (driver_intr_t *)clkintr, NULL, 1127 INTR_TYPE_CLK | INTR_FAST, NULL); |
1128 crit = intr_disable(); |
|
1118 mtx_lock_spin(&icu_lock); 1119 INTREN(1 << apic_8254_intr); 1120 mtx_unlock_spin(&icu_lock); | 1129 mtx_lock_spin(&icu_lock); 1130 INTREN(1 << apic_8254_intr); 1131 mtx_unlock_spin(&icu_lock); |
1132 intr_restore(crit); |
|
1121 } 1122 1123 } 1124 if (apic_int_type(0, 0) != 3 || 1125 int_to_apicintpin[apic_8254_intr].ioapic != 0 || 1126 int_to_apicintpin[apic_8254_intr].int_pin != 0) 1127 printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n", 1128 int_to_apicintpin[apic_8254_intr].ioapic, --- 185 unchanged lines hidden --- | 1133 } 1134 1135 } 1136 if (apic_int_type(0, 0) != 3 || 1137 int_to_apicintpin[apic_8254_intr].ioapic != 0 || 1138 int_to_apicintpin[apic_8254_intr].int_pin != 0) 1139 printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n", 1140 int_to_apicintpin[apic_8254_intr].ioapic, --- 185 unchanged lines hidden --- |