Deleted Added
full compact
pcrtc.c (92793) pcrtc.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/pc98/cbus/pcrtc.c 92793 2002-03-20 12:22:31Z kato $
37 * $FreeBSD: head/sys/pc98/cbus/pcrtc.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

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

1326{
1327#ifndef PC98
1328 int diag;
1329#endif
1330#ifdef APIC_IO
1331 int apic_8254_trial;
1332 void *clkdesc;
1333#endif /* APIC_IO */
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written

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

1326{
1327#ifndef PC98
1328 int diag;
1329#endif
1330#ifdef APIC_IO
1331 int apic_8254_trial;
1332 void *clkdesc;
1333#endif /* APIC_IO */
1334 register_t crit;
1334
1335#ifndef PC98
1336 if (statclock_disable) {
1337 /*
1338 * The stat interrupt mask is different without the
1339 * statistics clock. Also, don't set the interrupt
1340 * flag which would normally cause the RTC to generate
1341 * interrupts.

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

1362 apic_8254_intr = apic_irq(0, 0);
1363 setup_8254_mixed_mode();
1364 } else
1365 panic("APIC_IO: Cannot route 8254 interrupt to CPU");
1366 }
1367
1368 inthand_add("clk", apic_8254_intr, (driver_intr_t *)clkintr, NULL,
1369 INTR_TYPE_CLK | INTR_FAST, &clkdesc);
1335
1336#ifndef PC98
1337 if (statclock_disable) {
1338 /*
1339 * The stat interrupt mask is different without the
1340 * statistics clock. Also, don't set the interrupt
1341 * flag which would normally cause the RTC to generate
1342 * interrupts.

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

1363 apic_8254_intr = apic_irq(0, 0);
1364 setup_8254_mixed_mode();
1365 } else
1366 panic("APIC_IO: Cannot route 8254 interrupt to CPU");
1367 }
1368
1369 inthand_add("clk", apic_8254_intr, (driver_intr_t *)clkintr, NULL,
1370 INTR_TYPE_CLK | INTR_FAST, &clkdesc);
1371 crit = intr_disable();
1370 mtx_lock_spin(&icu_lock);
1371 INTREN(1 << apic_8254_intr);
1372 mtx_unlock_spin(&icu_lock);
1372 mtx_lock_spin(&icu_lock);
1373 INTREN(1 << apic_8254_intr);
1374 mtx_unlock_spin(&icu_lock);
1375 intr_restore(crit);
1373
1374#else /* APIC_IO */
1375
1376 /*
1377 * XXX Check the priority of this interrupt handler. I
1378 * couldn't find anything suitable in the BSD/OS code (grog,
1379 * 19 July 2000).
1380 */
1381 inthand_add("clk", 0, (driver_intr_t *)clkintr, NULL,
1382 INTR_TYPE_CLK | INTR_FAST, NULL);
1376
1377#else /* APIC_IO */
1378
1379 /*
1380 * XXX Check the priority of this interrupt handler. I
1381 * couldn't find anything suitable in the BSD/OS code (grog,
1382 * 19 July 2000).
1383 */
1384 inthand_add("clk", 0, (driver_intr_t *)clkintr, NULL,
1385 INTR_TYPE_CLK | INTR_FAST, NULL);
1386 crit = intr_disable();
1383 mtx_lock_spin(&icu_lock);
1384 INTREN(IRQ0);
1385 mtx_unlock_spin(&icu_lock);
1387 mtx_lock_spin(&icu_lock);
1388 INTREN(IRQ0);
1389 mtx_unlock_spin(&icu_lock);
1390 intr_restore(crit);
1386
1387#endif /* APIC_IO */
1388
1389#ifndef PC98
1390 /* Initialize RTC. */
1391 writertc(RTC_STATUSA, rtc_statusa);
1392 writertc(RTC_STATUSB, RTCSB_24HR);
1393

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

1403#ifdef APIC_IO
1404 if (isa_apic_irq(8) != 8)
1405 panic("APIC RTC != 8");
1406#endif /* APIC_IO */
1407
1408 inthand_add("rtc", 8, (driver_intr_t *)rtcintr, NULL,
1409 INTR_TYPE_CLK | INTR_FAST, NULL);
1410
1391
1392#endif /* APIC_IO */
1393
1394#ifndef PC98
1395 /* Initialize RTC. */
1396 writertc(RTC_STATUSA, rtc_statusa);
1397 writertc(RTC_STATUSB, RTCSB_24HR);
1398

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

1408#ifdef APIC_IO
1409 if (isa_apic_irq(8) != 8)
1410 panic("APIC RTC != 8");
1411#endif /* APIC_IO */
1412
1413 inthand_add("rtc", 8, (driver_intr_t *)rtcintr, NULL,
1414 INTR_TYPE_CLK | INTR_FAST, NULL);
1415
1416 crit = intr_disable();
1411 mtx_lock_spin(&icu_lock);
1412#ifdef APIC_IO
1413 INTREN(APIC_IRQ8);
1414#else
1415 INTREN(IRQ8);
1416#endif /* APIC_IO */
1417 mtx_unlock_spin(&icu_lock);
1417 mtx_lock_spin(&icu_lock);
1418#ifdef APIC_IO
1419 INTREN(APIC_IRQ8);
1420#else
1421 INTREN(IRQ8);
1422#endif /* APIC_IO */
1423 mtx_unlock_spin(&icu_lock);
1424 intr_restore(crit);
1418
1419 writertc(RTC_STATUSB, rtc_statusb);
1420#endif /* PC98 */
1421
1422#ifdef APIC_IO
1423 if (apic_8254_trial) {
1424
1425 printf("APIC_IO: Testing 8254 interrupt delivery\n");
1426 while (read_intr_count(8) < 6)
1427 ; /* nothing */
1428 if (read_intr_count(apic_8254_intr) < 3) {
1429 /*
1430 * The MP table is broken.
1431 * The 8254 was not connected to the specified pin
1432 * on the IO APIC.
1433 * Workaround: Limited variant of mixed mode.
1434 */
1425
1426 writertc(RTC_STATUSB, rtc_statusb);
1427#endif /* PC98 */
1428
1429#ifdef APIC_IO
1430 if (apic_8254_trial) {
1431
1432 printf("APIC_IO: Testing 8254 interrupt delivery\n");
1433 while (read_intr_count(8) < 6)
1434 ; /* nothing */
1435 if (read_intr_count(apic_8254_intr) < 3) {
1436 /*
1437 * The MP table is broken.
1438 * The 8254 was not connected to the specified pin
1439 * on the IO APIC.
1440 * Workaround: Limited variant of mixed mode.
1441 */
1442 crit = intr_disable();
1435 mtx_lock_spin(&icu_lock);
1436 INTRDIS(1 << apic_8254_intr);
1437 mtx_unlock_spin(&icu_lock);
1443 mtx_lock_spin(&icu_lock);
1444 INTRDIS(1 << apic_8254_intr);
1445 mtx_unlock_spin(&icu_lock);
1446 intr_restore(crit);
1438 inthand_remove(clkdesc);
1439 printf("APIC_IO: Broken MP table detected: "
1440 "8254 is not connected to "
1441 "IOAPIC #%d intpin %d\n",
1442 int_to_apicintpin[apic_8254_intr].ioapic,
1443 int_to_apicintpin[apic_8254_intr].int_pin);
1444 /*
1445 * Revoke current ISA IRQ 0 assignment and

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

1452 revoke_apic_irq(apic_8254_intr);
1453 assign_apic_irq(0, 0, apic_8254_intr);
1454 }
1455 apic_8254_intr = apic_irq(0, 0);
1456 setup_8254_mixed_mode();
1457 inthand_add("clk", apic_8254_intr,
1458 (driver_intr_t *)clkintr, NULL,
1459 INTR_TYPE_CLK | INTR_FAST, NULL);
1447 inthand_remove(clkdesc);
1448 printf("APIC_IO: Broken MP table detected: "
1449 "8254 is not connected to "
1450 "IOAPIC #%d intpin %d\n",
1451 int_to_apicintpin[apic_8254_intr].ioapic,
1452 int_to_apicintpin[apic_8254_intr].int_pin);
1453 /*
1454 * Revoke current ISA IRQ 0 assignment and

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

1461 revoke_apic_irq(apic_8254_intr);
1462 assign_apic_irq(0, 0, apic_8254_intr);
1463 }
1464 apic_8254_intr = apic_irq(0, 0);
1465 setup_8254_mixed_mode();
1466 inthand_add("clk", apic_8254_intr,
1467 (driver_intr_t *)clkintr, NULL,
1468 INTR_TYPE_CLK | INTR_FAST, NULL);
1469 crit = intr_disable();
1460 mtx_lock_spin(&icu_lock);
1461 INTREN(1 << apic_8254_intr);
1462 mtx_unlock_spin(&icu_lock);
1470 mtx_lock_spin(&icu_lock);
1471 INTREN(1 << apic_8254_intr);
1472 mtx_unlock_spin(&icu_lock);
1473 intr_restore(crit);
1463 }
1464
1465 }
1466 if (apic_int_type(0, 0) != 3 ||
1467 int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
1468 int_to_apicintpin[apic_8254_intr].int_pin != 0)
1469 printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
1470 int_to_apicintpin[apic_8254_intr].ioapic,

--- 196 unchanged lines hidden ---
1474 }
1475
1476 }
1477 if (apic_int_type(0, 0) != 3 ||
1478 int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
1479 int_to_apicintpin[apic_8254_intr].int_pin != 0)
1480 printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
1481 int_to_apicintpin[apic_8254_intr].ioapic,

--- 196 unchanged lines hidden ---