From owner-svn-src-stable@FreeBSD.ORG Fri Nov 1 06:56:29 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4114ED11; Fri, 1 Nov 2013 06:56:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2126B2320; Fri, 1 Nov 2013 06:56:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rA16uS5l062960; Fri, 1 Nov 2013 06:56:28 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rA16uSf5062959; Fri, 1 Nov 2013 06:56:28 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201311010656.rA16uSf5062959@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Nov 2013 06:56:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r257496 - stable/9/sys/x86/x86 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Nov 2013 06:56:29 -0000 Author: kib Date: Fri Nov 1 06:56:28 2013 New Revision: 257496 URL: http://svnweb.freebsd.org/changeset/base/257496 Log: MFC r257069: Add ddb 'show ioapic' and 'show all ioapics' commands. Modified: stable/9/sys/x86/x86/io_apic.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/x86/x86/io_apic.c ============================================================================== --- stable/9/sys/x86/x86/io_apic.c Fri Nov 1 06:33:17 2013 (r257495) +++ stable/9/sys/x86/x86/io_apic.c Fri Nov 1 06:56:28 2013 (r257496) @@ -922,3 +922,99 @@ DEFINE_CLASS_0(apic, apic_driver, apic_m static devclass_t apic_devclass; DRIVER_MODULE(apic, nexus, apic_driver, apic_devclass, 0, 0); + +#include "opt_ddb.h" + +#ifdef DDB +#include + +static const char * +ioapic_delivery_mode(uint32_t mode) +{ + + switch (mode) { + case IOART_DELFIXED: + return ("fixed"); + case IOART_DELLOPRI: + return ("lowestpri"); + case IOART_DELSMI: + return ("SMI"); + case IOART_DELRSV1: + return ("rsrvd1"); + case IOART_DELNMI: + return ("NMI"); + case IOART_DELINIT: + return ("INIT"); + case IOART_DELRSV2: + return ("rsrvd2"); + case IOART_DELEXINT: + return ("ExtINT"); + default: + return (""); + } +} + +static u_int +db_ioapic_read(volatile ioapic_t *apic, int reg) +{ + + apic->ioregsel = reg; + return (apic->iowin); +} + +static void +db_show_ioapic_one(volatile ioapic_t *io_addr) +{ + uint32_t r, lo, hi; + int mre, i; + + r = db_ioapic_read(io_addr, IOAPIC_VER); + mre = (r & IOART_VER_MAXREDIR) >> MAXREDIRSHIFT; + db_printf("Id 0x%08x Ver 0x%02x MRE %d\n", + db_ioapic_read(io_addr, IOAPIC_ID), r & IOART_VER_VERSION, mre); + for (i = 0; i < mre; i++) { + lo = db_ioapic_read(io_addr, IOAPIC_REDTBL_LO(i)); + hi = db_ioapic_read(io_addr, IOAPIC_REDTBL_HI(i)); + db_printf(" pin %d Dest %s/%x %smasked Trig %s RemoteIRR %d " + "Polarity %s Status %s DeliveryMode %s Vec %d\n", i, + (lo & IOART_DESTMOD) == IOART_DESTLOG ? "log" : "phy", + (hi & IOART_DEST) >> 24, + (lo & IOART_INTMASK) == IOART_INTMSET ? "" : "not", + (lo & IOART_TRGRMOD) == IOART_TRGRLVL ? "lvl" : "edge", + (lo & IOART_REM_IRR) == IOART_REM_IRR ? 1 : 0, + (lo & IOART_INTPOL) == IOART_INTALO ? "low" : "high", + (lo & IOART_DELIVS) == IOART_DELIVS ? "pend" : "idle", + ioapic_delivery_mode(lo & IOART_DELMOD), + (lo & IOART_INTVEC)); + } +} + +DB_SHOW_COMMAND(ioapic, db_show_ioapic) +{ + struct ioapic *ioapic; + int idx, i; + + if (!have_addr) { + db_printf("usage: show ioapic index\n"); + return; + } + + idx = (int)addr; + i = 0; + STAILQ_FOREACH(ioapic, &ioapic_list, io_next) { + if (idx == i) { + db_show_ioapic_one(ioapic->io_addr); + break; + } + i++; + } +} + +DB_SHOW_ALL_COMMAND(ioapics, db_show_all_ioapics) +{ + struct ioapic *ioapic; + + STAILQ_FOREACH(ioapic, &ioapic_list, io_next) + db_show_ioapic_one(ioapic->io_addr); +} +#endif