Fri May 29 08:44:29 2009 UTC ()
Tidyup error handling around PDC_PIM.

CTASSERT -> KASSERT


(skrll)
diff -r1.68 -r1.69 src/sys/arch/hp700/hp700/machdep.c

cvs diff -r1.68 -r1.69 src/sys/arch/hp700/hp700/Attic/machdep.c (expand / switch to unified diff)

--- src/sys/arch/hp700/hp700/Attic/machdep.c 2009/05/29 08:39:05 1.68
+++ src/sys/arch/hp700/hp700/Attic/machdep.c 2009/05/29 08:44:29 1.69
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.68 2009/05/29 08:39:05 skrll Exp $ */ 1/* $NetBSD: machdep.c,v 1.69 2009/05/29 08:44:29 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette. 8 * by Matthew Fredette.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 50 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
51 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 51 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
57 * THE POSSIBILITY OF SUCH DAMAGE. 57 * THE POSSIBILITY OF SUCH DAMAGE.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.68 2009/05/29 08:39:05 skrll Exp $"); 61__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.69 2009/05/29 08:44:29 skrll Exp $");
62 62
63#include "opt_cputype.h" 63#include "opt_cputype.h"
64#include "opt_ddb.h" 64#include "opt_ddb.h"
65#include "opt_kgdb.h" 65#include "opt_kgdb.h"
66#include "opt_modular.h" 66#include "opt_modular.h"
67#include "opt_useleds.h" 67#include "opt_useleds.h"
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/systm.h> 70#include <sys/systm.h>
71#include <sys/signalvar.h> 71#include <sys/signalvar.h>
72#include <sys/kernel.h> 72#include <sys/kernel.h>
73#include <sys/proc.h> 73#include <sys/proc.h>
74#include <sys/buf.h> 74#include <sys/buf.h>
@@ -1646,75 +1646,77 @@ hppa_pim64_dump(int check_type) @@ -1646,75 +1646,77 @@ hppa_pim64_dump(int check_type)
1646 (unsigned long)checks->pim_check_responder); 1646 (unsigned long)checks->pim_check_responder);
1647 printf("\nSystem Requestor 0x%016lx", 1647 printf("\nSystem Requestor 0x%016lx",
1648 (unsigned long)checks->pim_check_requestor); 1648 (unsigned long)checks->pim_check_requestor);
1649 printf("\nPath Info 0x%08x", 1649 printf("\nPath Info 0x%08x",
1650 checks->pim_check_path_info); 1650 checks->pim_check_path_info);
1651 } 1651 }
1652} 1652}
1653 1653
1654void 1654void
1655hppa_machine_check(int check_type) 1655hppa_machine_check(int check_type)
1656{ 1656{
1657 int pdc_pim_type; 1657 int pdc_pim_type;
1658 const char *name; 1658 const char *name;
1659 int error; 1659 int pimerror, error;
1660 1660
1661 /* Do an fcacheall(). */ 1661 /* Do an fcacheall(). */
1662 fcacheall(); 1662 fcacheall();
1663 1663
1664 /* Dispatch on the check type. */ 1664 /* Dispatch on the check type. */
1665 switch (check_type) { 1665 switch (check_type) {
1666 case T_HPMC: 1666 case T_HPMC:
1667 name = "HPMC"; 1667 name = "HPMC";
1668 pdc_pim_type = PDC_PIM_HPMC; 1668 pdc_pim_type = PDC_PIM_HPMC;
1669 break; 1669 break;
1670 case T_LPMC: 1670 case T_LPMC:
1671 name = "LPMC"; 1671 name = "LPMC";
1672 pdc_pim_type = PDC_PIM_LPMC; 1672 pdc_pim_type = PDC_PIM_LPMC;
1673 break; 1673 break;
1674 case T_INTERRUPT: 1674 case T_INTERRUPT:
1675 name = "TOC"; 1675 name = "TOC";
1676 pdc_pim_type = PDC_PIM_TOC; 1676 pdc_pim_type = PDC_PIM_TOC;
1677 break; 1677 break;
1678 default: 1678 default:
1679 panic("unknown machine check type"); 1679 panic("unknown machine check type");
1680 /* NOTREACHED */ 1680 /* NOTREACHED */
1681 } 1681 }
1682 1682
1683 error = pdc_call((iodcio_t)pdc, 0, PDC_PIM, pdc_pim_type, 1683 pimerror = pdc_call((iodcio_t)pdc, 0, PDC_PIM, pdc_pim_type,
1684 &pdc_pim, pim_data_buffer, sizeof(pim_data_buffer)); 1684 &pdc_pim, pim_data_buffer, sizeof(pim_data_buffer));
1685 if (error < 0) 
1686 printf(" - WARNING: could not transfer PIM info (%d)", error); 
1687 1685
1688 CTASSERT(pdc_pim.count <= sizeof(pim_data_buffer)); 1686 KASSERT(pdc_pim.count <= sizeof(pim_data_buffer));
1689 1687
1690 /* 1688 /*
1691 * Reset IO and log errors. 1689 * Reset IO and log errors.
1692 * 1690 *
1693 * This seems to be needed in order to output to the console 1691 * This seems to be needed in order to output to the console
1694 * if we take a HPMC interrupt. This PDC procedure may not be 1692 * if we take a HPMC interrupt. This PDC procedure may not be
1695 * implemented by some machines. 1693 * implemented by some machines.
1696 */ 1694 */
1697 error = pdc_call((iodcio_t)pdc, 0, PDC_IO, 0, 0, 0, 0); 1695 error = pdc_call((iodcio_t)pdc, 0, PDC_IO, 0, 0, 0, 0);
1698 if (error != PDC_ERR_OK && error != PDC_ERR_NOPROC) 1696 if (error != PDC_ERR_OK && error != PDC_ERR_NOPROC)
1699 /* This seems futile if we can't print to the console. */ 1697 /* This seems futile if we can't print to the console. */
1700 panic("PDC_IO failed"); 1698 panic("PDC_IO failed");
1701 1699
1702 printf("\nmachine check: %s", name); 1700 printf("\nmachine check: %s", name);
1703 1701
1704 if (hppa_cpu_info->hci_features & HPPA_FTRS_W32B) 1702 if (pimerror < 0) {
1705 hppa_pim64_dump(check_type); 1703 printf(" - WARNING: could not transfer PIM info (%d)", pimerror);
1706 else 1704 } else {
1707 hppa_pim_dump(check_type); 1705 if (hppa_cpu_info->hci_features & HPPA_FTRS_W32B)
 1706 hppa_pim64_dump(check_type);
 1707 else
 1708 hppa_pim_dump(check_type);
 1709 }
1708 1710
1709 printf("\n"); 1711 printf("\n");
1710 1712
1711 /* If this is our first check, panic. */ 1713 /* If this is our first check, panic. */
1712 if (in_check == 0) { 1714 if (in_check == 0) {
1713 in_check = 1; 1715 in_check = 1;
1714 DELAY(250000); 1716 DELAY(250000);
1715 panic("machine check"); 1717 panic("machine check");
1716 } 1718 }
1717  1719
1718 /* Reboot the machine. */ 1720 /* Reboot the machine. */
1719 printf("Rebooting...\n"); 1721 printf("Rebooting...\n");
1720 cpu_die(); 1722 cpu_die();