From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 20 05:49:47 2004 Return-Path: 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 CF56E16A4CE for ; Fri, 20 Aug 2004 05:49:47 +0000 (GMT) Received: from axe-inc.co.jp (axegw.axe-inc.co.jp [61.199.217.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 319CA43D5E for ; Fri, 20 Aug 2004 05:49:47 +0000 (GMT) (envelope-from takawata@axe-inc.co.jp) Received: from localhost (localhost [127.0.0.1]) by axe-inc.co.jp (8.9.3+3.2W/3.7W) with SMTP id OAA02607; Fri, 20 Aug 2004 14:49:44 +0900 (JST) Message-Id: <200408200549.OAA02607@axe-inc.co.jp> X-Authentication-Warning: axegw.axe-inc.co.jp: localhost [127.0.0.1] didn't use HELO protocol To: takawata@jp.freebsd.org From: takawata@jp.freebsd.org In-reply-to: Your message of "Fri, 20 Aug 2004 07:01:13 +0300." <41257789.70508@OTEL.net> Date: Fri, 20 Aug 2004 14:49:44 +0900 Sender: takawata@axe-inc.co.jp cc: freebsd-hackers@freebsd.org Subject: Re: How can I fake a device ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2004 05:49:48 -0000 In message <41257789.70508@OTEL.net>, Iasen Kostov wrote: > Hi, >I want to know is there a way to call *_probe (for device driver) with >fake (PCI) device that does not exists in the system ? >First of all a cant find how "struct device" is declared (i've searched >even the compile/ dir) and second I think that I'll need to intercept >pci_get_vendor and pci_get_device funcs with my own which should detect >the fake device and thus will return vandor/device that I need to fake. >I realy don't need anything else except _probe ... I have never tried such but grimpsed the PCI framework, I propose the following, though I don't imagine why you want to do so: Your driver have to contain DEVICE_IDENTIFY method that calls device_add_child to allocate device_t object. Then you allocate 'struct pci_devinfo' and initialize pci_devinfo as you like. And you have to make your driver as a module. Then a device object will show up on the device tree on your system. You may want to have a look at pci_add_children@/sys/dev/pci/pci.c