Date: Wed, 28 Sep 2011 20:12:56 -0400 (EDT) From: Benjamin Kaduk <kaduk@MIT.EDU> To: Liu Wang <liuw@supermicro.com> Cc: "freebsd-doc@freebsd.org" <freebsd-doc@freebsd.org> Subject: Re: Are "mypci_driver" typos for "mypci_cdevsw" in "FreeBSD Architecture Handbook" , page 159, section 11.1.1, line 9 & 10 ? Message-ID: <alpine.GSO.1.10.1109282006390.882@multics.mit.edu> In-Reply-To: <09F85D53A2F0C547BF5E05E214DB880A23C81FCB3C@MAIL5.supermicro.com> References: <09F85D53A2F0C547BF5E05E214DB880A23C81FCB3C@MAIL5.supermicro.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 28 Sep 2011, Liu Wang wrote: > Are "mypci_driver" typos for "mypci_cdevsw" in "FreeBSD Architecture > Handbook" , page 159, section 11.1.1, line 9 & 10 ? The architecture handbook has not been well-loved over the past few years, and is not exactly authoritative on very much at the moment. A look at other uses of the DEFINE_CLASS_0 and DRIVER_MODULE macros (e.g. dev/pci/pci_pci.c) and consulting fxr.watson.org seems to indicate that these arguments should not be existing symbols: 103 DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc)); 104 DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0); FXR does not see "pcib_driver" as a symbol. Indeed, looking at the macro implementation reveals that this argument is used to define a new symbol as part of the macro expansion: #define DEFINE_CLASS_0(name, classvar, methods, size) \ \ struct kobj_class classvar = { \ #name, methods, size, NULL \ } #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \ BUS_PASS_DEFAULT) #define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ \ static struct driver_module_data name##_##busname##_driver_mod = { \ evh, arg, \ #busname, \ (kobj_class_t) &driver, \ &devclass, \ pass \ }; \ \ static moduledata_t name##_##busname##_mod = { \ #busname "/" #name, \ driver_module_handler, \ &name##_##busname##_driver_mod \ }; \ DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ SI_SUB_DRIVERS, SI_ORDER_MIDDLE) So, given that mypci_cdevsw is already declared, the answer to your question is "no". -Ben Kaduk
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.GSO.1.10.1109282006390.882>