Are "mypci_driver" typos for "mypci_cdevsw" in "FreeBSD Architecture Handbook" , page 159, section 11.1.1, line 9 & 10 ?

Benjamin Kaduk kaduk at MIT.EDU
Thu Sep 29 00:13:01 UTC 2011


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



More information about the freebsd-doc mailing list