From owner-freebsd-scsi Tue Sep 5 2:56:35 2000 Delivered-To: freebsd-scsi@freebsd.org Received: from hotmail.com (f241.pav1.hotmail.com [64.4.31.241]) by hub.freebsd.org (Postfix) with ESMTP id D3E8637B422 for ; Tue, 5 Sep 2000 02:56:28 -0700 (PDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 5 Sep 2000 02:56:28 -0700 Received: from 61.151.185.78 by pv1fd.pav1.hotmail.msn.com with HTTP; Tue, 05 Sep 2000 09:56:28 GMT X-Originating-IP: [61.151.185.78] From: "bsdnewbie bsdnewbie" To: freebsd-scsi@FreeBSD.org Subject: _Problem of KLD Date: Tue, 05 Sep 2000 17:56:28 CST Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 05 Sep 2000 09:56:28.0662 (UTC) FILETIME=[8F93B160:01C0171F] Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I write a driver for a pci scsi card. In order to make my driver easy for debugging, I write it as a loadable module. But it can not work well, so I compile it into kernel and things get better. The problem is: why the loadable module can not work as it compiled in to the kernel. (described as follows:) I write my program by referring "aic7xxx.c" My program: /* * Attach all the sub-devices we can find */ int foo_attach(struct foo_softc *foo) { ... bus_setup_intr(...); devq = cam_simq_alloc(SCB_MAX); sim = cam_sim_alloc(foo_action, foo_poll, "foo", foo, foo->unit, 1, SCB_MAX, devq); xpt_bus_register(sim, bus_id); xpt_create_path(&path, /*periph*/NULL, cam_sim_path(sim), CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); ... } 1) When I use "kldload foo.ko", the function foo_action will be called with the "ccb->ccb_h.func_code == XPT_PATH_INQ" only one time. And no function will be called by system any more. 2) When I compile this module into kernel, the function foo_action will be called with the func_code in order: XPT_PATH_INQ XPT_PATH_INQ XPT_PATH_INQ XPT_RESET_BUS XPT_PATH_INQ XPT_PATH_INQ XPT_PATH_INQ XPT_SCSI_IO detail log of situation 1: /kernel: foo: -> foo_pci_attach /kernel: foo: <-> foo_setup /kernel: foo: <-> foo_alloc /kernel: foo: <-> foo_reset /kernel: foo: <-> foo_init /kernel: foo: -> foo_attach /kernel: (noperiph:foo0:0:-1:-1): xpt_compile_path /kernel: (noperiph:foo0:0:-1:-1): xpt_setup_ccb /kernel: (noperiph:foo0:0:-1:-1): xpt_action /kernel: foo: -> foo_action /kernel: (noperiph:foo0:0:-1:-1): foo_action /kernel: foo: XPT_PATH_INQ /kernel: (noperiph:foo0:0:-1:-1): xpt_done /kernel: foo: <- foo_action /kernel: (xpt0:xpt0:0:-1:-1): xpt_async /kernel: (noperiph:foo0:0:-1:-1): xpt_release_path /kernel: (noperiph:foo0:0:-1:-1): xpt_compile_path /kernel: (noperiph:foo0:0:-1:-1): xpt_setup_ccb /kernel: (noperiph:foo0:0:-1:-1): xpt_action /kernel: foo: <- foo_attach /kernel: foo: <- foo_pci_attach detail log of 2: (displayed by dmesg) Copyright (c) 1992-2000 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 4.1-RELEASE #4: Tue Sep 5 15:27:11 CST 2000 bsdnewbie@TPA.MyHome.com:/usr/src/sys/compile/NEW2 Timecounter "i8254" frequency 1193182 Hz CPU: Pentium III/Pentium III Xeon/Celeron (666.45-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0x683 Stepping = 3 Features=0x383f9ff real memory = 134217728 (131072K bytes) config> di pcic0 config> di sn0 config> di lnc0 config> di le0 config> di ie0 config> di fe0 config> di cs0 config> di bt0 config> di aic0 config> di aha0 config> di adv0 config> q avail memory = 126468096 (123504K bytes) Preloaded elf kernel "kernel" at 0xc03fd000. Preloaded userconfig_script "/boot/kernel.conf" at 0xc03fd09c. Pentium Pro MTRR support enabled md0: Malloc disk npx0: on motherboard npx0: INT 16 interface pcib0: on motherboard pci0: on pcib0 pcib2: at device 1.0 on pci0 pci1: on pcib2 pci1: at 0.0 irq 11 isab0: at device 7.0 on pci0 isa0: on isab0 atapci0: port 0xd000-0xd00f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 ata1: at 0x170 irq 15 on atapci0 uhci0: port 0xd400-0xd41f irq 10 at device 7.2 on pc i0 usb0: on uhci0 usb0: USB revision 1.0 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered uhub0: port 1 power on failed, IOERROR uhub0: port 2 power on failed, IOERROR xl0: <3Com 3c905B-TX Fast Etherlink XL> port 0xd800-0xd87f mem 0xea020000-0xea02 007f irq 12 at device 10.0 on pci0 xl0: Ethernet address: 00:10:5a:75:79:6a miibus0: on xl0 xlphy0: <3Com internal media interface> on miibus0 xlphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto foo0: port 0xec00-0xec3f,0xe800-0xe803,0xe400-0xe407,0xe000-0xe003 ,0xdc00-0xdc07 mem 0xea000000-0xea01ffff irq 9 at device 11.0 on pci0 foo: -> foo_pci_attach foo: <-> foo_setup foo: <-> foo_alloc foo: <-> foo_reset foo: <-> foo_init foo: -> foo_attach foo: -> foo_action foo: XPT_PATH_INQ foo: <- foo_action foo: <- foo_attach foo: <- foo_pci_attach pcib1: on motherboard pci2: on pcib1 fdc0: at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0 fdc0: FIFO enabled, 8 bytes threshold fd0: <1440-KB 3.5" drive> on fdc0 drive 0 atkbdc0: at port 0x60,0x64 on isa0 atkbd0: flags 0x1 irq 1 on atkbdc0 kbd0 at atkbd0 vga0: at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 sc0: at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 sio0: type 16550A sio1 at port 0x2f8-0x2ff irq 3 on isa0 sio1: type 16550A ppc0: at port 0x378-0x37f irq 7 on isa0 ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode ppi0: on ppbus0 lpt0: on ppbus0 lpt0: Interrupt-driven port plip0: on ppbus0 ad0: 14649MB [29765/16/63] at ata0-master using UDMA66 acd0: CDROM at ata1-master using PIO4 (noperiph:foo0:0:-1:-1): xpt_compile_path (noperiph:foo0:0:-1:-1): xpt_setup_ccb (noperiph:foo0:0:-1:-1): xpt_action foo: -> foo_action (noperiph:foo0:0:-1:-1): foo_action foo: XPT_PATH_INQ (noperiph:foo0:0:-1:-1): xpt_done foo: <- foo_action (noperiph:foo0:0:-1:-1): xpt_release_path Waiting 15 seconds for SCSI devices to settle (xpt0:foo0:0:-1:-1): xpt_compile_path (xpt0:foo0:0:-1:-1): xpt_setup_ccb (xpt0:foo0:0:-1:-1): xpt_action foo: -> foo_action (xpt0:foo0:0:-1:-1): foo_action foo: XPT_PATH_INQ (xpt0:foo0:0:-1:-1): xpt_done foo: <- foo_action (xpt0:foo0:0:-1:-1): xpt_setup_ccb (xpt0:foo0:0:-1:-1): xpt_action foo: -> foo_action (xpt0:foo0:0:-1:-1): foo_action foo: XPT_RESET_BUS foo: <-> foo_reset (xpt0:foo0:0:-1:-1): xpt_done foo: <- foo_action (xpt0:foo0:0:-1:-1): xpt_finishconfig (xpt0:foo0:0:-1:-1): xpt_action (xpt0:foo0:0:-1:-1): xpt_scan_bus (xpt0:foo0:0:-1:-1): xpt_setup_ccb (xpt0:foo0:0:-1:-1): xpt_action foo: -> foo_action (xpt0:foo0:0:-1:-1): foo_action foo: XPT_PATH_INQ (xpt0:foo0:0:-1:-1): xpt_done foo: <- foo_action (xpt0:foo0:0:1:0): xpt_compile_path (xpt0:foo0:0:1:0): xpt_setup_ccb (xpt0:foo0:0:1:0): xpt_action (xpt0:foo0:0:1:0): xpt_scan_lun (xpt0:foo0:0:1:0): xpt_setup_ccb (xpt0:foo0:0:1:0): xpt_action foo: -> foo_action (xpt0:foo0:0:1:0): foo_action foo: XPT_PATH_INQ (xpt0:foo0:0:1:0): xpt_done foo: <- foo_action (probe0:foo0:0:1:0): xpt_compile_path (probe0:foo0:0:1:0): xpt_setup_ccb (probe0:foo0:0:1:0): xpt_action (probe0:foo0:0:1:0): xpt_setup_ccb (probe0:foo0:0:1:0): xpt_action (probe0:foo0:0:1:0): xpt_setup_ccb (probe0:foo0:0:1:0): xpt_action foo: -> foo_action (probe0:foo0:0:1:0): foo_action foo: XPT_PATH_INQ (probe0:foo0:0:1:0): xpt_done foo: <- foo_action (probe0:foo0:0:1:0): xpt_schedule (probe0:foo0:0:1:0): xpt_setup_ccb (probe0:foo0:0:1:0): probestart (probe0:foo0:0:1:0): xpt_action (probe0:foo0:0:1:0): . CDB: 12 0 0 0 24 0 foo: -> foo_action (probe0:foo0:0:1:0): foo_action foo: XPT_SCSI_IO (probe0:foo0:0:1:0): xpt_done foo: <- foo_action (probe0:foo0:0:1:0): camisr(probe0:foo0:0:1:0): probedone (xpt0:foo0:0:1:0): xpt_done (probe0:foo0:0:1:0): xpt_free_path (probe0:foo0:0:1:0): xpt_release_path (xpt0:foo0:0:1:0): camisr(xpt0:foo0:0:1:0): xpt_scan_bus (xpt0:foo0:0:1:0): xpt_setup_ccb (xpt0:foo0:0:1:0): xpt_action (xpt0:foo0:0:1:0): xpt_free_path (xpt0:foo0:0:1:0): xpt_release_path (xpt0:foo0:0:-1:-1): xpt_done (xpt0:foo0:0:-1:-1): camisr(xpt0:foo0:0:-1:-1): xpt_finishconfig (xpt0:foo0:0:-1:-1): xpt_free_path (xpt0:foo0:0:-1:-1): xpt_release_path (noperiph:xpt0:0:-1:-1): xpt_compile_path (noperiph:xpt0:0:-1:-1): xpt_setup_ccb (noperiph:xpt0:0:-1:-1): xpt_action (noperiph:xpt0:0:-1:-1): xpt_free_path (noperiph:xpt0:0:-1:-1): xpt_release_path (noperiph:xpt0:0:-1:-1): xpt_compile_path (noperiph:xpt0:0:-1:-1): xpt_setup_ccb (noperiph:xpt0:0:-1:-1): xpt_action (noperiph:xpt0:0:-1:-1): xpt_free_path (noperiph:xpt0:0:-1:-1): xpt_release_path (noperiph:xpt0:0:-1:-1): xpt_compile_path (noperiph:xpt0:0:-1:-1): xpt_setup_ccb (noperiph:xpt0:0:-1:-1): xpt_action (noperiph:xpt0:0:-1:-1): xpt_free_path (noperiph:xpt0:0:-1:-1): xpt_release_path (noperiph:xpt0:0:-1:-1): xpt_compile_path (noperiph:xpt0:0:-1:-1): xpt_setup_ccb (noperiph:xpt0:0:-1:-1): xpt_action (noperiph:xpt0:0:-1:-1): xpt_free_path (noperiph:xpt0:0:-1:-1): xpt_release_path Mounting root from ufs:/dev/ad0s2a I wanna to know why 1) and 2) runs in different way? How can I made 1) run just as that of 2)? I notice that in the source code of FreeBSD 4.1, aha is writen as a loadable module while ahc is writen to compiled into the kernel, why? Thanks in Advance, Best Regards, bsdnewbie Sep 5, 2k _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message