TODO revision 1.9
1o Call module as module.
2
3  Until now, everything is called as attribute.  Separate module from it:
4
5	- Module is a collection of code (*.[cSo]), and provides a function.
6	  Module can depend on other modules.
7
8	- Attribute provides metadata for modules.  One module can have
9	  multiple attributes.  Attribute doesn't generate a module (*.o,
10	  *.ko).
11
12o Emit everything (ioconf.*, Makefile, ...) per-attribute.
13
14  config(9) related metadata (cfdriver, cfattach, cfdata, ...) should be
15  collected using linker.  Create ELF sections like
16  .{rodata,data}.config.{cfdriver,cfattach,cfdata}.  Provide reference
17  symbols (e.g. cfdriverinit[]) using linker script.  Sort entries by name
18  to lookup entries by binary search in kernel.
19
20o Generate modular(9) related information.  Especially module dependency.
21
22  At this moment modular(9) modules hardcode dependency in *.c using the
23  MODULE() macro:
24
25	MODULE(MODULE_CLASS_DRIVER, hdaudio, "pci");
26
27  This information already exists in config(5) definitions (files.*).
28  Extend config(5) to be able to specify module's class.
29
30  Ideally these module metadata are kept somewhere in ELF headers, so that
31  loaders (e.g. boot(8)) can easily read.  One idea is to abuse DYNAMIC
32  sections to record dependency, as shared library does.  (Feasibility
33  unknown.)
34
35o Rename "interface attribute" to "bus".
36
37  Instead of
38
39	define	audiobus {}
40	attach	audio at audiobus
41
42  Do like this
43
44	defbus	audiobus {}
45	attach	audio at audiobus
46
47o Retire "attach foo at bar with foo_bar.c"
48
49  Most of these should be rewritten by defining a common interface attribute
50  "foobus", instead of writing multiple attachments.  com(4), ld(4), ehci(4)
51  are typical examples.  For ehci(4), EHCI-capable controller drivers implement
52  "ehcibus" interface, like:
53
54	defne	ehcibus {}
55	device	imxehci: ehcibus
56
57  These drivers' attach functions call config_found() to attach ehci(4) via
58  the "ehcibus" interface attribute, instead of calling ehci_init() directly.
59  Same for com(4) (com_attach_subr()) and ld(4) (ldattach()).
60
61o Sort objects in more reasonable order.
62
63  Put machdep.ko in the lowest address.  uvm.ko and kern.ko follow.
64
65  Kill alphabetical sort (${OBJS:O} in sys/conf/Makefile.inc.kern.
66
67  Use ldscript.  Do like this
68
69	.text :
70	AT (ADDR(.text) & 0x0fffffff)
71	{
72	  *(.text.machdep.locore.entry)
73	  *(.text.machdep.locore)
74	  *(.text.machdep)
75	  *(.text)
76	  *(.text.*)
77	  :
78
79  Kill linker definitions in sys/conf/Makefile.inc.kern.
80
81o Differentiate "options" and "flags"/"params".
82
83  "options" enables features by adding *.c files (via attributes).
84
85  "flags" and "params" are to change contents of *.c files.  These don't add
86  *.c files to the result kernel, or don't build attributes (modules).
87
88o Make flags/params per attributes (modules).
89
90  Basically flags and params are cpp(1) #define's generated in opt_*.h.  Make
91  them local to one attributes (modules).  Flags/params which affects files
92  across attributes (modules) are possible, but should be discouraged.
93
94o Generate things only by definitions.
95
96  In the ideal dynamically modular world, "selection" will be done not at
97  compile time but at runtime.  Users select their wanted modules, by
98  dynamically loading them.
99
100  This means that the system provides all choices; that is, build all modules
101  in the source tree.  Necessary information is defined in the "definition"
102  part.
103
104o Split cfdata.
105
106  cfdata is a set of pattern matching rules to enable devices at runtime device
107  auto-configuration.  It is pure data and can (should) be generated separately
108  from the code.
109
110o Allow easier adding and removing of options.
111
112  It should be possible to add or remove options, flags, etc.,
113  without regard to whether or not they are already defined.
114  For example, a configuration like this:
115
116	include GENERIC
117	options FOO
118	no options BAR
119
120  should work regardless of whether or not options FOO and/or
121  options BAR were defined in GENERIC.  It should not give
122  errors like "options BAR was already defined" or "options FOO
123  was not defined".
124
125o Introduce "class".
126
127  Every module should be classified as at least one class, as modular(9)
128  modules already do.  For example, file systems are marked as "vfs", network
129  protocols are "netproto".
130
131  Consider to merge "devclass" into "class".
132
133  For syntax clarity, class names could be used as a keyword to select the
134  class's instance module:
135
136	# Define net80211 module as netproto class
137	class netproto
138	define net80211: netproto
139
140	# Select net80211 to be builtin
141	netproto net80211
142
143  Accordingly device/attach selection syntax should be revisited.
144
145o Support kernel constructor/destructor (.kctors/.kdtors)
146
147  Initialization and finalization should be called via constructors and
148  destructors.  Don't hardcode those sequences as sys/kern/init_main.c:main()
149  does.
150
151  The order of .kctors/.kdtors is resolved by dependency.  The difference from
152  userland is that in kernel depended ones are located in lower addresses;
153  "machdep" module is the lowest.  Thus the lowest entry in .ctors must be
154  executed the first.
155
156  The .kctors/.kdtors entries are executed by kernel's main() function, unlike
157  userland where start code executes .ctors/.dtors before main().  The hardcoded
158  sequence of various subsystem initializations in init_main.c:main() will be
159  replaced by an array of .kctors invocations, and #ifdef's there will be gone.
160
161o Replace linkset.
162
163  Don't allow kernel subsystems create random ELF sections (with potentially
164  long names) in the final kernel.  To collect some data in statically linked
165  modules, creating intermediate sections (e.g. .data.linkset.sysctl) and
166  exporting the start/end symbols (e.g. _data_linkset_sysctl_{start,end})
167  using linker script should be fine.
168
169  Dynamically loaded modules have to register those entries via constructors
170  (functions).  This means that dynamically loaded modules are flexible but
171  come with overhead.
172
173o Shared kernel objects.
174
175  Since NetBSD has not established a clear kernel ABI, every single kernel
176  has to build all the objects by their own.  As a result, similar kernels
177  (e.g. evbarm kernels) repeatedly compile similar objects, that is waste of
178  energy & space.
179
180  Share them if possible.  For evb* ports, ideally everything except machdep.ko
181  should be shared.
182
183  While leaving optimizations as options (CPU specific optimizations, inlined
184  bus_space(9) operations, etc.) for users, the official binaries build
185  provided by TNF should be as portable as possible.
186