From owner-freebsd-current@FreeBSD.ORG Tue May 2 11:05:49 2006 Return-Path: X-Original-To: Freebsd-current@freebsd.org Delivered-To: Freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E565916A425 for ; Tue, 2 May 2006 11:05:49 +0000 (UTC) (envelope-from rmgls@wanadoo.fr) Received: from smtp18.wanadoo.fr (smtp18.wanadoo.fr [193.252.22.126]) by mx1.FreeBSD.org (Postfix) with ESMTP id 259BE43D69 for ; Tue, 2 May 2006 11:05:44 +0000 (GMT) (envelope-from rmgls@wanadoo.fr) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1809.wanadoo.fr (SMTP Server) with ESMTP id E78DD700009B for ; Tue, 2 May 2006 13:05:42 +0200 (CEST) Received: from wanadoo.fr (ARouen-252-1-140-192.w86-215.abo.wanadoo.fr [86.215.75.192]) by mwinf1809.wanadoo.fr (SMTP Server) with ESMTP id D120B7000093 for ; Tue, 2 May 2006 13:05:42 +0200 (CEST) X-ME-UUID: 20060502110542856.D120B7000093@mwinf1809.wanadoo.fr To: Freebsd-current@freebsd.org From: rmgls@wanadoo.fr Date: Tue, 02 May 2006 13:05:38 +0200 Sender: rmgls@wanadoo.fr Message-Id: <20060502110542.D120B7000093@mwinf1809.wanadoo.fr> Cc: Subject: debug_firmware patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 May 2006 11:05:50 -0000 On Monday 01 May 2006 00:20, Max Laier wrote: > Here is a small patch to build a "debug.firmware" sysctl. Should give: > "iwi_bss/300/191142" for the latest firmware from net/iwi-firmware-kmod > Any comments on the patch? Will commit shortly otherwise. ... Hi, A minor side effect of the patch: if defined before X_load="YES" (say ucom, and uplcom), in loader.conf, prevents X_loading: no cuaU nor ttyU present; No problem if defined after. Best regards, | mlaier@freebsd.org Raoul rmgls@wanadoo.Fr Index: subr_firmware.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/store/mlaier/fcvs/src/sys/kern/subr_firmware.c,v retrieving revision 1.1 diff -u -r1.1 subr_firmware.c =2D-- subr_firmware.c 29 Jan 2006 02:52:41 -0000 1.1 +++ subr_firmware.c 30 Apr 2006 22:11:05 -0000 @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -41,6 +43,8 @@ #include #include +static int sysctl_debug_firmware(SYSCTL_HANDLER_ARGS); +#define FIRMWARE_MAX 30 static char *name_unload = "UNLOADING"; static struct firmware firmware_table[FIRMWARE_MAX]; @@ -48,6 +52,49 @@ struct mtx firmware_mtx; MTX_SYSINIT(firmware, &firmware_mtx, "firmware table", MTX_DEF); +static int +sysctl_debug_firmware(SYSCTL_HANDLER_ARGS) +{ + struct firmware *fp; + struct sbuf sb; + int error, i, count = 0; + + for (i = 0; i < FIRMWARE_MAX; i++) { + fp = &firmware_table[i]; + if (fp->name != NULL) + count++; + } + + if (count == 0) + return (sysctl_handle_string(oidp, "NONE", 5, req)); + + sbuf_new(&sb, NULL, count * 32 + 2, SBUF_FIXEDLEN); + + sbuf_printf(&sb, "\n"); + + mtx_lock(&firmware_mtx); + for (i = 0; i < FIRMWARE_MAX; i++) { + fp = &firmware_table[i]; + if (fp->name != NULL) { + if (count-- <= 0) + sbuf_printf(&sb, "...\n"); + else + sbuf_printf(&sb, "\t%16s/%u/%zi\n", fp->name, + fp->version, fp->datasize); + } + } + mtx_unlock(&firmware_mtx); + + sbuf_trim(&sb); + sbuf_finish(&sb); + error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); + sbuf_delete(&sb); + + return (error); +} +SYSCTL_OID(_debug, OID_AUTO, firmware, CTLTYPE_STRING|CTLFLAG_RD, NULL, 0, + sysctl_debug_firmware, "A", "Loaded firmware images"); + /* * Register a firmware image with the specified name. The * image name must not already be registered. If this is a