Home | History | Annotate | Line # | Download | only in config
TODO revision 1.13
      1   1.5  uebayasi o Call module as module.
      2   1.5  uebayasi 
      3   1.5  uebayasi   Until now, everything is called as attribute.  Separate module from it:
      4   1.5  uebayasi 
      5   1.5  uebayasi 	- Module is a collection of code (*.[cSo]), and provides a function.
      6   1.5  uebayasi 	  Module can depend on other modules.
      7   1.5  uebayasi 
      8   1.5  uebayasi 	- Attribute provides metadata for modules.  One module can have
      9   1.5  uebayasi 	  multiple attributes.  Attribute doesn't generate a module (*.o,
     10   1.5  uebayasi 	  *.ko).
     11   1.5  uebayasi 
     12   1.1  uebayasi o Emit everything (ioconf.*, Makefile, ...) per-attribute.
     13   1.1  uebayasi 
     14   1.9  uebayasi   config(9) related metadata (cfdriver, cfattach, cfdata, ...) should be
     15   1.9  uebayasi   collected using linker.  Create ELF sections like
     16   1.9  uebayasi   .{rodata,data}.config.{cfdriver,cfattach,cfdata}.  Provide reference
     17   1.9  uebayasi   symbols (e.g. cfdriverinit[]) using linker script.  Sort entries by name
     18   1.9  uebayasi   to lookup entries by binary search in kernel.
     19   1.9  uebayasi 
     20   1.1  uebayasi o Generate modular(9) related information.  Especially module dependency.
     21   1.1  uebayasi 
     22   1.9  uebayasi   At this moment modular(9) modules hardcode dependency in *.c using the
     23   1.9  uebayasi   MODULE() macro:
     24   1.9  uebayasi 
     25   1.9  uebayasi 	MODULE(MODULE_CLASS_DRIVER, hdaudio, "pci");
     26   1.9  uebayasi 
     27   1.9  uebayasi   This information already exists in config(5) definitions (files.*).
     28   1.9  uebayasi   Extend config(5) to be able to specify module's class.
     29   1.9  uebayasi 
     30   1.9  uebayasi   Ideally these module metadata are kept somewhere in ELF headers, so that
     31   1.9  uebayasi   loaders (e.g. boot(8)) can easily read.  One idea is to abuse DYNAMIC
     32   1.9  uebayasi   sections to record dependency, as shared library does.  (Feasibility
     33   1.9  uebayasi   unknown.)
     34   1.9  uebayasi 
     35   1.1  uebayasi o Rename "interface attribute" to "bus".
     36   1.1  uebayasi 
     37   1.1  uebayasi   Instead of
     38   1.1  uebayasi 
     39   1.1  uebayasi 	define	audiobus {}
     40   1.1  uebayasi 	attach	audio at audiobus
     41   1.1  uebayasi 
     42   1.1  uebayasi   Do like this
     43   1.1  uebayasi 
     44   1.1  uebayasi 	defbus	audiobus {}
     45   1.1  uebayasi 	attach	audio at audiobus
     46   1.1  uebayasi 
     47   1.8  uebayasi o Retire "attach foo at bar with foo_bar.c"
     48   1.8  uebayasi 
     49   1.8  uebayasi   Most of these should be rewritten by defining a common interface attribute
     50   1.8  uebayasi   "foobus", instead of writing multiple attachments.  com(4), ld(4), ehci(4)
     51   1.8  uebayasi   are typical examples.  For ehci(4), EHCI-capable controller drivers implement
     52   1.8  uebayasi   "ehcibus" interface, like:
     53   1.8  uebayasi 
     54   1.8  uebayasi 	defne	ehcibus {}
     55   1.8  uebayasi 	device	imxehci: ehcibus
     56   1.8  uebayasi 
     57   1.8  uebayasi   These drivers' attach functions call config_found() to attach ehci(4) via
     58   1.8  uebayasi   the "ehcibus" interface attribute, instead of calling ehci_init() directly.
     59   1.8  uebayasi   Same for com(4) (com_attach_subr()) and ld(4) (ldattach()).
     60   1.8  uebayasi 
     61   1.1  uebayasi o Sort objects in more reasonable order.
     62   1.1  uebayasi 
     63   1.1  uebayasi   Put machdep.ko in the lowest address.  uvm.ko and kern.ko follow.
     64   1.1  uebayasi 
     65   1.1  uebayasi   Kill alphabetical sort (${OBJS:O} in sys/conf/Makefile.inc.kern.
     66   1.1  uebayasi 
     67   1.1  uebayasi   Use ldscript.  Do like this
     68   1.1  uebayasi 
     69   1.1  uebayasi 	.text :
     70   1.1  uebayasi 	AT (ADDR(.text) & 0x0fffffff)
     71   1.1  uebayasi 	{
     72   1.1  uebayasi 	  *(.text.machdep.locore.entry)
     73   1.1  uebayasi 	  *(.text.machdep.locore)
     74   1.1  uebayasi 	  *(.text.machdep)
     75   1.1  uebayasi 	  *(.text)
     76   1.1  uebayasi 	  *(.text.*)
     77   1.1  uebayasi 	  :
     78   1.1  uebayasi 
     79   1.1  uebayasi   Kill linker definitions in sys/conf/Makefile.inc.kern.
     80   1.2  uebayasi 
     81   1.3       wiz o Differentiate "options" and "flags"/"params".
     82   1.2  uebayasi 
     83   1.3       wiz   "options" enables features by adding *.c files (via attributes).
     84   1.2  uebayasi 
     85   1.2  uebayasi   "flags" and "params" are to change contents of *.c files.  These don't add
     86   1.3       wiz   *.c files to the result kernel, or don't build attributes (modules).
     87   1.2  uebayasi 
     88   1.2  uebayasi o Make flags/params per attributes (modules).
     89   1.2  uebayasi 
     90   1.2  uebayasi   Basically flags and params are cpp(1) #define's generated in opt_*.h.  Make
     91   1.2  uebayasi   them local to one attributes (modules).  Flags/params which affects files
     92   1.2  uebayasi   across attributes (modules) are possible, but should be discouraged.
     93   1.2  uebayasi 
     94   1.2  uebayasi o Generate things only by definitions.
     95   1.2  uebayasi 
     96   1.2  uebayasi   In the ideal dynamically modular world, "selection" will be done not at
     97   1.2  uebayasi   compile time but at runtime.  Users select their wanted modules, by
     98   1.2  uebayasi   dynamically loading them.
     99   1.2  uebayasi 
    100   1.2  uebayasi   This means that the system provides all choices; that is, build all modules
    101   1.2  uebayasi   in the source tree.  Necessary information is defined in the "definition"
    102   1.2  uebayasi   part.
    103   1.2  uebayasi 
    104   1.2  uebayasi o Split cfdata.
    105   1.2  uebayasi 
    106   1.8  uebayasi   cfdata is a set of pattern matching rules to enable devices at runtime device
    107   1.3       wiz   auto-configuration.  It is pure data and can (should) be generated separately
    108   1.2  uebayasi   from the code.
    109   1.4       apb 
    110   1.4       apb o Allow easier adding and removing of options.
    111   1.4       apb 
    112   1.4       apb   It should be possible to add or remove options, flags, etc.,
    113   1.4       apb   without regard to whether or not they are already defined.
    114   1.4       apb   For example, a configuration like this:
    115   1.4       apb 
    116   1.4       apb 	include GENERIC
    117   1.4       apb 	options FOO
    118   1.4       apb 	no options BAR
    119   1.4       apb 
    120   1.4       apb   should work regardless of whether or not options FOO and/or
    121   1.4       apb   options BAR were defined in GENERIC.  It should not give
    122   1.4       apb   errors like "options BAR was already defined" or "options FOO
    123   1.4       apb   was not defined".
    124   1.4       apb 
    125   1.5  uebayasi o Introduce "class".
    126   1.5  uebayasi 
    127   1.7       wiz   Every module should be classified as at least one class, as modular(9)
    128   1.7       wiz   modules already do.  For example, file systems are marked as "vfs", network
    129   1.5  uebayasi   protocols are "netproto".
    130   1.5  uebayasi 
    131   1.5  uebayasi   Consider to merge "devclass" into "class".
    132   1.5  uebayasi 
    133   1.5  uebayasi   For syntax clarity, class names could be used as a keyword to select the
    134   1.5  uebayasi   class's instance module:
    135   1.5  uebayasi 
    136   1.5  uebayasi 	# Define net80211 module as netproto class
    137   1.5  uebayasi 	class netproto
    138   1.5  uebayasi 	define net80211: netproto
    139   1.5  uebayasi 
    140   1.5  uebayasi 	# Select net80211 to be builtin
    141   1.5  uebayasi 	netproto net80211
    142   1.5  uebayasi 
    143   1.5  uebayasi   Accordingly device/attach selection syntax should be revisited.
    144   1.5  uebayasi 
    145   1.6  uebayasi o Support kernel constructor/destructor (.kctors/.kdtors)
    146   1.5  uebayasi 
    147   1.5  uebayasi   Initialization and finalization should be called via constructors and
    148   1.5  uebayasi   destructors.  Don't hardcode those sequences as sys/kern/init_main.c:main()
    149   1.5  uebayasi   does.
    150   1.5  uebayasi 
    151   1.6  uebayasi   The order of .kctors/.kdtors is resolved by dependency.  The difference from
    152   1.5  uebayasi   userland is that in kernel depended ones are located in lower addresses;
    153   1.5  uebayasi   "machdep" module is the lowest.  Thus the lowest entry in .ctors must be
    154   1.5  uebayasi   executed the first.
    155   1.5  uebayasi 
    156   1.6  uebayasi   The .kctors/.kdtors entries are executed by kernel's main() function, unlike
    157   1.6  uebayasi   userland where start code executes .ctors/.dtors before main().  The hardcoded
    158   1.6  uebayasi   sequence of various subsystem initializations in init_main.c:main() will be
    159   1.7       wiz   replaced by an array of .kctors invocations, and #ifdef's there will be gone.
    160   1.6  uebayasi 
    161  1.12  uebayasi o Hide link-set in the final kernel.
    162   1.5  uebayasi 
    163  1.12  uebayasi   Link-set is used to collect references (pointers) at link time.  It relys on
    164  1.12  uebayasi   the ld(1) behavior that it automatically generates `__start_X' and `__stop_X'
    165  1.12  uebayasi   symbols for the section `X' to reduce coding.
    166  1.12  uebayasi 
    167  1.12  uebayasi   Don't allow kernel subsystems create random ELF sections.
    168  1.12  uebayasi 
    169  1.12  uebayasi   Pre-define all the available link-set names and pre-generate a linker script
    170  1.12  uebayasi   to merge them into .rodata.
    171  1.12  uebayasi 
    172  1.12  uebayasi   (For modular(9) modules, `link_set_modules' is looked up by kernel loader.
    173  1.12  uebayasi   Provide only it.)
    174  1.12  uebayasi 
    175  1.12  uebayasi   Provide a way for 3rd party modules to declare extra link-set.
    176   1.6  uebayasi 
    177   1.6  uebayasi o Shared kernel objects.
    178   1.6  uebayasi 
    179   1.7       wiz   Since NetBSD has not established a clear kernel ABI, every single kernel
    180   1.6  uebayasi   has to build all the objects by their own.  As a result, similar kernels
    181   1.6  uebayasi   (e.g. evbarm kernels) repeatedly compile similar objects, that is waste of
    182   1.6  uebayasi   energy & space.
    183   1.6  uebayasi 
    184   1.6  uebayasi   Share them if possible.  For evb* ports, ideally everything except machdep.ko
    185   1.6  uebayasi   should be shared.
    186   1.6  uebayasi 
    187   1.6  uebayasi   While leaving optimizations as options (CPU specific optimizations, inlined
    188   1.6  uebayasi   bus_space(9) operations, etc.) for users, the official binaries build
    189   1.6  uebayasi   provided by TNF should be as portable as possible.
    190  1.10  uebayasi 
    191  1.10  uebayasi o Control ELF sections using linker script.
    192  1.10  uebayasi 
    193  1.10  uebayasi   Now kernel is linked and built directly from object files (*.o).  Each port
    194  1.10  uebayasi   has an MD linker script, which does everything needed to be done at link
    195  1.10  uebayasi   time.  As a result, they do from MI alignment restriction (read_mostly,
    196  1.10  uebayasi   cacheline_aligned) to load address specification for external boot loaders.
    197  1.10  uebayasi 
    198  1.10  uebayasi   Make this into multiple stages to make linkage more structural.  Especially,
    199  1.11  uebayasi   reserve the final link for purely MD purpose.  Note that in modular build,
    200  1.11  uebayasi   *.ko are shared between build of kernel and modular(9) modules (*.kmod).
    201  1.10  uebayasi 
    202  1.10  uebayasi 	Monolithic build:
    203  1.10  uebayasi 		     *.o  ---> netbsd.ko	Generic MI linkage
    204  1.10  uebayasi 		netbsd.ko ---> netbsd.ro	Kernel MI linkage
    205  1.10  uebayasi 		netbsd.ro ---> netbsd		Kernel MD linkage
    206  1.10  uebayasi 
    207  1.10  uebayasi 	Modular build (kernel):
    208  1.10  uebayasi 		     *.o  --->      *.ko	Generic + Per-module MI linkage
    209  1.10  uebayasi 		     *.ko ---> netbsd.ro	Kernel MI linkage
    210  1.10  uebayasi 		netbsd.ro ---> netbsd		Kernel MD linkage
    211  1.10  uebayasi 
    212  1.10  uebayasi 	Modular build (module):
    213  1.10  uebayasi 		     *.o  --->      *.ko	Generic + Per-module MI linkage
    214  1.10  uebayasi 		     *.ko --->      *.ro	Modular MI linkage
    215  1.10  uebayasi 		     *.ro --->      *.kmod	Modular MD linkage
    216  1.10  uebayasi 
    217  1.10  uebayasi   Genric MI linkage is for processing MI linkage that can be applied generally.
    218  1.10  uebayasi   Data section alignment (.data.read_mostly and .data.cacheline_aligned) is
    219  1.10  uebayasi   processed here.
    220  1.10  uebayasi 
    221  1.10  uebayasi   Per-module MI linkage is for modules that want some ordering.  For example,
    222  1.10  uebayasi   machdep.ko wants to put entry code at the top of .text and .data.
    223  1.10  uebayasi 
    224  1.10  uebayasi   Kernel MI linkage is for collecting kernel global section data, that is what
    225  1.10  uebayasi   link-set is used for now.  Once they are collected and symbols to the ranges
    226  1.10  uebayasi   are assigned, those sections are merged into the pre-existing sections
    227  1.10  uebayasi   (.rodata) because link-set sections in "netbsd" will never be interpreted by
    228  1.10  uebayasi   external loaders.
    229  1.10  uebayasi 
    230  1.10  uebayasi   Kernel MD linkage is used purely for MD purposes, that is, how kernels are
    231  1.10  uebayasi   loaded by external loaders.  It might be possible that one kernel relocatable
    232  1.10  uebayasi   (netbsd.ro) is linked into multiple final kernel image (netbsd) for diferent
    233  1.10  uebayasi   load addresses.
    234  1.10  uebayasi 
    235  1.11  uebayasi   Modular MI linkage is to prepare a module to be loadable as modular(9).  This
    236  1.11  uebayasi   may add some extra sections and/or symbols.
    237  1.11  uebayasi 
    238  1.11  uebayasi   Modular MD linkage is again for pure MD purposes like kernel MD linkage.
    239  1.11  uebayasi   Adjustment and/or optimization may be done.
    240  1.11  uebayasi 
    241  1.11  uebayasi   Kernel and modular MI linkages may change behavior depending on existence
    242  1.11  uebayasi   of debug information.  In the future .symtab will be copied using linker
    243  1.11  uebayasi   during this stage.
    244  1.13  uebayasi 
    245  1.13  uebayasi o Redesign swapnetbsd.c (root/swap device specification)
    246  1.13  uebayasi 
    247  1.13  uebayasi   Don't build a whole kernel only to specify root/swap devices.
    248  1.13  uebayasi 
    249  1.13  uebayasi   Make these parameter re-configurable afterwards.
    250