From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 28 16:50:43 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 065E416A41F for ; Mon, 28 Nov 2005 16:50:43 +0000 (GMT) (envelope-from fierykylin@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CC0743D64 for ; Mon, 28 Nov 2005 16:50:42 +0000 (GMT) (envelope-from fierykylin@gmail.com) Received: by xproxy.gmail.com with SMTP id t12so1012890wxc for ; Mon, 28 Nov 2005 08:50:42 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=KpgisXRfbtoHR39yE7GJVt8jWNRlBU82lpX498fvPcL62K0B/wWAHfuG8lENP252pxarXpGqQUzHvC+BmXBHla1GLXiv4YL62wVuLnyxuvA0Sbi00GIr/ta+2RJrVWTkbliBCLofao1WJSyrZg6nEXeUL8MJzh4syATO29i6CVk= Received: by 10.70.38.9 with SMTP id l9mr26511wxl; Mon, 28 Nov 2005 08:50:41 -0800 (PST) Received: by 10.70.18.16 with HTTP; Mon, 28 Nov 2005 08:50:41 -0800 (PST) Message-ID: <87ab37ab0511280850y1bca554n1da9b11c321be34b@mail.gmail.com> Date: Tue, 29 Nov 2005 00:50:41 +0800 From: kylin To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: puzzle about the pci_add_child X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2005 16:50:43 -0000 i am reading the pci code of freeBSD 53 ,and come to the puzzle of pci_add_child. 1 why should we =3D09pci_cfg_save(dinfo->cfg.dev, dinfo, 0); after we hav= e already fill the cfg in pci_read_device ? 2 what 's the purpose of the function couple pci_cfg_save(dinfo->cfg.dev, dinfo, 0); pci_cfg_restore(dinfo->cfg.dev, dinfo) below is the function ,thank u pci_add_child(device_t bus, struct pci_devinfo *dinfo) { device_t pcib; pcib =3D device_get_parent(bus); dinfo->cfg.dev =3D device_add_child(bus, NULL, -1);//NULLmeans no devclass to create // for pci bus refers to pci device node device_set_ivars(dinfo->cfg.dev, dinfo); pci_cfg_save(dinfo->cfg.dev, dinfo, 0);//for what read and write? pci_cfg_restore(dinfo->cfg.dev, dinfo);//not store ,but REstore ,power rela= ted pci_add_resources(pcib, bus, dinfo->cfg.dev);//see resource are bridge rela= ted pci_print_verbose(dinfo); ... } -- we who r about to die,salute u!