xref: /netbsd-src/usr.bin/config/TODO (revision 077d1c0f365db1f9f0315d24fd965951eb1d90f2)
1c5c18c90Suebayasio Call module as module.
2c5c18c90Suebayasi
3c5c18c90Suebayasi  Until now, everything is called as attribute.  Separate module from it:
4c5c18c90Suebayasi
5c5c18c90Suebayasi	- Module is a collection of code (*.[cSo]), and provides a function.
6c5c18c90Suebayasi	  Module can depend on other modules.
7c5c18c90Suebayasi
8c5c18c90Suebayasi	- Attribute provides metadata for modules.  One module can have
9c5c18c90Suebayasi	  multiple attributes.  Attribute doesn't generate a module (*.o,
10c5c18c90Suebayasi	  *.ko).
11c5c18c90Suebayasi
12eac891b9Suebayasio Emit everything (ioconf.*, Makefile, ...) per-attribute.
13eac891b9Suebayasi
146c852b28Suebayasi  config(9) related metadata (cfdriver, cfattach, cfdata, ...) should be
156c852b28Suebayasi  collected using linker.  Create ELF sections like
166c852b28Suebayasi  .{rodata,data}.config.{cfdriver,cfattach,cfdata}.  Provide reference
176c852b28Suebayasi  symbols (e.g. cfdriverinit[]) using linker script.  Sort entries by name
186c852b28Suebayasi  to lookup entries by binary search in kernel.
196c852b28Suebayasi
20eac891b9Suebayasio Generate modular(9) related information.  Especially module dependency.
21eac891b9Suebayasi
226c852b28Suebayasi  At this moment modular(9) modules hardcode dependency in *.c using the
236c852b28Suebayasi  MODULE() macro:
246c852b28Suebayasi
256c852b28Suebayasi	MODULE(MODULE_CLASS_DRIVER, hdaudio, "pci");
266c852b28Suebayasi
276c852b28Suebayasi  This information already exists in config(5) definitions (files.*).
286c852b28Suebayasi  Extend config(5) to be able to specify module's class.
296c852b28Suebayasi
306c852b28Suebayasi  Ideally these module metadata are kept somewhere in ELF headers, so that
316c852b28Suebayasi  loaders (e.g. boot(8)) can easily read.  One idea is to abuse DYNAMIC
326c852b28Suebayasi  sections to record dependency, as shared library does.  (Feasibility
336c852b28Suebayasi  unknown.)
346c852b28Suebayasi
35eac891b9Suebayasio Rename "interface attribute" to "bus".
36eac891b9Suebayasi
37eac891b9Suebayasi  Instead of
38eac891b9Suebayasi
39eac891b9Suebayasi	define	audiobus {}
40eac891b9Suebayasi	attach	audio at audiobus
41eac891b9Suebayasi
42eac891b9Suebayasi  Do like this
43eac891b9Suebayasi
44eac891b9Suebayasi	defbus	audiobus {}
45eac891b9Suebayasi	attach	audio at audiobus
46eac891b9Suebayasi
47e29416eeSuebayasi  Always provide xxxbusprint() (and xxxbussubmatch if multiple children).
48e29416eeSuebayasi  Extend struct cfiattrdata like:
49e29416eeSuebayasi
50e29416eeSuebayasi	struct cfiattrdata {
51e29416eeSuebayasi		const char *ci_name;
52e29416eeSuebayasi		cfprint_t ci_print;
53e29416eeSuebayasi		cfsubmatch_t ci_submatch;
54e29416eeSuebayasi		int ci_loclen;
55e29416eeSuebayasi		const struct cflocdesc ci_locdesc[];
56e29416eeSuebayasi	};
57e29416eeSuebayasi
58e29416eeSuebayasio Simplify child configuration API
59e29416eeSuebayasi
60e29416eeSuebayasi  With said struct cfiattrdata extension, config_found*() can omit
61e29416eeSuebayasi  print/submatch args.  If the found child is known (e.g., "pcibus" creating
62e29416eeSuebayasi  "pci"):
63e29416eeSuebayasi
64c59f84eaSuebayasi	config_found(self, "pcibus");
65e29416eeSuebayasi
66e29416eeSuebayasi  If finding unknown children (e.g. "pci" finding pci devices):
67e29416eeSuebayasi
68e29416eeSuebayasi	config_find(self, "pci", locs, aux);
69e29416eeSuebayasi
70c62ce263Suebayasio Retire "attach foo at bar with foo_bar.c"
71c62ce263Suebayasi
72c62ce263Suebayasi  Most of these should be rewritten by defining a common interface attribute
73c62ce263Suebayasi  "foobus", instead of writing multiple attachments.  com(4), ld(4), ehci(4)
74c62ce263Suebayasi  are typical examples.  For ehci(4), EHCI-capable controller drivers implement
75c62ce263Suebayasi  "ehcibus" interface, like:
76c62ce263Suebayasi
777991f5a7Sandvar	define	ehcibus {}
78c62ce263Suebayasi	device	imxehci: ehcibus
79c62ce263Suebayasi
80c62ce263Suebayasi  These drivers' attach functions call config_found() to attach ehci(4) via
81c62ce263Suebayasi  the "ehcibus" interface attribute, instead of calling ehci_init() directly.
82c62ce263Suebayasi  Same for com(4) (com_attach_subr()) and ld(4) (ldattach()).
83c62ce263Suebayasi
84eac891b9Suebayasio Sort objects in more reasonable order.
85eac891b9Suebayasi
86eac891b9Suebayasi  Put machdep.ko in the lowest address.  uvm.ko and kern.ko follow.
87eac891b9Suebayasi
88eac891b9Suebayasi  Kill alphabetical sort (${OBJS:O} in sys/conf/Makefile.inc.kern.
89eac891b9Suebayasi
90eac891b9Suebayasi  Use ldscript.  Do like this
91eac891b9Suebayasi
92eac891b9Suebayasi	.text :
93eac891b9Suebayasi	AT (ADDR(.text) & 0x0fffffff)
94eac891b9Suebayasi	{
95eac891b9Suebayasi	  *(.text.machdep.locore.entry)
96eac891b9Suebayasi	  *(.text.machdep.locore)
97eac891b9Suebayasi	  *(.text.machdep)
98eac891b9Suebayasi	  *(.text)
99eac891b9Suebayasi	  *(.text.*)
100eac891b9Suebayasi	  :
101eac891b9Suebayasi
102eac891b9Suebayasi  Kill linker definitions in sys/conf/Makefile.inc.kern.
1030819fb14Suebayasi
104891aaa4dSwizo Differentiate "options" and "flags"/"params".
1050819fb14Suebayasi
106891aaa4dSwiz  "options" enables features by adding *.c files (via attributes).
1070819fb14Suebayasi
1080819fb14Suebayasi  "flags" and "params" are to change contents of *.c files.  These don't add
109891aaa4dSwiz  *.c files to the result kernel, or don't build attributes (modules).
1100819fb14Suebayasi
1110819fb14Suebayasio Make flags/params per attributes (modules).
1120819fb14Suebayasi
1130819fb14Suebayasi  Basically flags and params are cpp(1) #define's generated in opt_*.h.  Make
1140819fb14Suebayasi  them local to one attributes (modules).  Flags/params which affects files
1150819fb14Suebayasi  across attributes (modules) are possible, but should be discouraged.
1160819fb14Suebayasi
1170819fb14Suebayasio Generate things only by definitions.
1180819fb14Suebayasi
1190819fb14Suebayasi  In the ideal dynamically modular world, "selection" will be done not at
1200819fb14Suebayasi  compile time but at runtime.  Users select their wanted modules, by
1210819fb14Suebayasi  dynamically loading them.
1220819fb14Suebayasi
1230819fb14Suebayasi  This means that the system provides all choices; that is, build all modules
1240819fb14Suebayasi  in the source tree.  Necessary information is defined in the "definition"
1250819fb14Suebayasi  part.
1260819fb14Suebayasi
1270819fb14Suebayasio Split cfdata.
1280819fb14Suebayasi
129c62ce263Suebayasi  cfdata is a set of pattern matching rules to enable devices at runtime device
130891aaa4dSwiz  auto-configuration.  It is pure data and can (should) be generated separately
1310819fb14Suebayasi  from the code.
132e010c720Sapb
133e010c720Sapbo Allow easier adding and removing of options.
134e010c720Sapb
135e010c720Sapb  It should be possible to add or remove options, flags, etc.,
136e010c720Sapb  without regard to whether or not they are already defined.
137e010c720Sapb  For example, a configuration like this:
138e010c720Sapb
139e010c720Sapb	include GENERIC
140e010c720Sapb	options FOO
141e010c720Sapb	no options BAR
142e010c720Sapb
143e010c720Sapb  should work regardless of whether or not options FOO and/or
144e010c720Sapb  options BAR were defined in GENERIC.  It should not give
145e010c720Sapb  errors like "options BAR was already defined" or "options FOO
146e010c720Sapb  was not defined".
147e010c720Sapb
148c5c18c90Suebayasio Introduce "class".
149c5c18c90Suebayasi
15075f5ef0dSwiz  Every module should be classified as at least one class, as modular(9)
151c5c18c90Suebayasi  modules already do.  For example, file systems are marked as "vfs", network
152c5c18c90Suebayasi  protocols are "netproto".
153c5c18c90Suebayasi
154c5c18c90Suebayasi  Consider to merge "devclass" into "class".
155c5c18c90Suebayasi
156c5c18c90Suebayasi  For syntax clarity, class names could be used as a keyword to select the
157c5c18c90Suebayasi  class's instance module:
158c5c18c90Suebayasi
159c5c18c90Suebayasi	# Define net80211 module as netproto class
160c5c18c90Suebayasi	class netproto
161c5c18c90Suebayasi	define net80211: netproto
162c5c18c90Suebayasi
163c5c18c90Suebayasi	# Select net80211 to be builtin
164c5c18c90Suebayasi	netproto net80211
165c5c18c90Suebayasi
166c5c18c90Suebayasi  Accordingly device/attach selection syntax should be revisited.
167c5c18c90Suebayasi
168bd3d598fSuebayasio Support kernel constructor/destructor (.kctors/.kdtors)
169c5c18c90Suebayasi
170c5c18c90Suebayasi  Initialization and finalization should be called via constructors and
171c5c18c90Suebayasi  destructors.  Don't hardcode those sequences as sys/kern/init_main.c:main()
172c5c18c90Suebayasi  does.
173c5c18c90Suebayasi
174bd3d598fSuebayasi  The order of .kctors/.kdtors is resolved by dependency.  The difference from
175c5c18c90Suebayasi  userland is that in kernel depended ones are located in lower addresses;
176c5c18c90Suebayasi  "machdep" module is the lowest.  Thus the lowest entry in .ctors must be
177c5c18c90Suebayasi  executed the first.
178c5c18c90Suebayasi
179bd3d598fSuebayasi  The .kctors/.kdtors entries are executed by kernel's main() function, unlike
180bd3d598fSuebayasi  userland where start code executes .ctors/.dtors before main().  The hardcoded
181bd3d598fSuebayasi  sequence of various subsystem initializations in init_main.c:main() will be
18275f5ef0dSwiz  replaced by an array of .kctors invocations, and #ifdef's there will be gone.
183bd3d598fSuebayasi
1842f06dcafSuebayasio Hide link-set in the final kernel.
185c5c18c90Suebayasi
1862f06dcafSuebayasi  Link-set is used to collect references (pointers) at link time.  It relys on
1872f06dcafSuebayasi  the ld(1) behavior that it automatically generates `__start_X' and `__stop_X'
1882f06dcafSuebayasi  symbols for the section `X' to reduce coding.
189c5c18c90Suebayasi
1902f06dcafSuebayasi  Don't allow kernel subsystems create random ELF sections.
1912f06dcafSuebayasi
1922f06dcafSuebayasi  Pre-define all the available link-set names and pre-generate a linker script
1932f06dcafSuebayasi  to merge them into .rodata.
1942f06dcafSuebayasi
1952f06dcafSuebayasi  (For modular(9) modules, `link_set_modules' is looked up by kernel loader.
1962f06dcafSuebayasi  Provide only it.)
1972f06dcafSuebayasi
1982f06dcafSuebayasi  Provide a way for 3rd party modules to declare extra link-set.
199bd3d598fSuebayasi
200bd3d598fSuebayasio Shared kernel objects.
201bd3d598fSuebayasi
20275f5ef0dSwiz  Since NetBSD has not established a clear kernel ABI, every single kernel
203bd3d598fSuebayasi  has to build all the objects by their own.  As a result, similar kernels
204bd3d598fSuebayasi  (e.g. evbarm kernels) repeatedly compile similar objects, that is waste of
205bd3d598fSuebayasi  energy & space.
206bd3d598fSuebayasi
207bd3d598fSuebayasi  Share them if possible.  For evb* ports, ideally everything except machdep.ko
208bd3d598fSuebayasi  should be shared.
209bd3d598fSuebayasi
210bd3d598fSuebayasi  While leaving optimizations as options (CPU specific optimizations, inlined
211bd3d598fSuebayasi  bus_space(9) operations, etc.) for users, the official binaries build
212bd3d598fSuebayasi  provided by TNF should be as portable as possible.
213701e371cSuebayasi
2141e1f20e1Suebayasio Always use explicit kernel linker script.
2151e1f20e1Suebayasi
2161e1f20e1Suebayasi  ld(1) has an option -T <ldscript> to use a given linker script.  If not
2171e1f20e1Suebayasi  specified, a default, built-in linker script, mainly meant for userland
2181e1f20e1Suebayasi  programs, is used.
2191e1f20e1Suebayasi
2201e1f20e1Suebayasi  Currently m68k, sh3, and vax don't have kernel linker scripts.  These work
2211e1f20e1Suebayasi  because these have no constraints about page boundary; they map and access
2221e1f20e1Suebayasi  kernel .text/.data in the same way.
2231e1f20e1Suebayasi
2240e43d38dSuebayasio Pass input files to ${LD} via linker script.
2250e43d38dSuebayasi
2260e43d38dSuebayasi  Instead of passing input files on command-line, output "INPUT(xxx.o)"
2270e43d38dSuebayasi  commands, and include it from generated linker scripts.
2280e43d38dSuebayasi
229e1ddff40Suebayasio Directly generate `*.d' files.
2300e43d38dSuebayasi
2310e43d38dSuebayasi  Output source/object files in raw texts instead of `Makefile'.  Generate
2320e43d38dSuebayasi  `*.d' (make(1) depend) files.  make(1) knows which object files are to be
2330e43d38dSuebayasi  compiled.  With "INPUT(xxx.o)" linker scripts, either generated `Makefile'
2340e43d38dSuebayasi  or `Makefile.kern.inc' don't need to keep source/object files in variables.
2350e43d38dSuebayasi
236701e371cSuebayasio Control ELF sections using linker script.
237701e371cSuebayasi
238701e371cSuebayasi  Now kernel is linked and built directly from object files (*.o).  Each port
239701e371cSuebayasi  has an MD linker script, which does everything needed to be done at link
240701e371cSuebayasi  time.  As a result, they do from MI alignment restriction (read_mostly,
241701e371cSuebayasi  cacheline_aligned) to load address specification for external boot loaders.
242701e371cSuebayasi
243701e371cSuebayasi  Make this into multiple stages to make linkage more structural.  Especially,
24428fcb3ecSuebayasi  reserve the final link for purely MD purpose.  Note that in modular build,
24528fcb3ecSuebayasi  *.ko are shared between build of kernel and modular(9) modules (*.kmod).
246701e371cSuebayasi
247701e371cSuebayasi	Monolithic build:
248701e371cSuebayasi		     *.o  ---> netbsd.ko	Generic MI linkage
249701e371cSuebayasi		netbsd.ko ---> netbsd.ro	Kernel MI linkage
250701e371cSuebayasi		netbsd.ro ---> netbsd		Kernel MD linkage
251701e371cSuebayasi
252701e371cSuebayasi	Modular build (kernel):
253701e371cSuebayasi		     *.o  --->      *.ko	Generic + Per-module MI linkage
254701e371cSuebayasi		     *.ko ---> netbsd.ro	Kernel MI linkage
255701e371cSuebayasi		netbsd.ro ---> netbsd		Kernel MD linkage
256701e371cSuebayasi
257701e371cSuebayasi	Modular build (module):
258701e371cSuebayasi		     *.o  --->      *.ko	Generic + Per-module MI linkage
259701e371cSuebayasi		     *.ko --->      *.ro	Modular MI linkage
260701e371cSuebayasi		     *.ro --->      *.kmod	Modular MD linkage
261701e371cSuebayasi
26280e58ff0Swiz  Generic MI linkage is for processing MI linkage that can be applied generally.
263701e371cSuebayasi  Data section alignment (.data.read_mostly and .data.cacheline_aligned) is
264701e371cSuebayasi  processed here.
265701e371cSuebayasi
266701e371cSuebayasi  Per-module MI linkage is for modules that want some ordering.  For example,
267701e371cSuebayasi  machdep.ko wants to put entry code at the top of .text and .data.
268701e371cSuebayasi
269701e371cSuebayasi  Kernel MI linkage is for collecting kernel global section data, that is what
270701e371cSuebayasi  link-set is used for now.  Once they are collected and symbols to the ranges
271701e371cSuebayasi  are assigned, those sections are merged into the pre-existing sections
272701e371cSuebayasi  (.rodata) because link-set sections in "netbsd" will never be interpreted by
273701e371cSuebayasi  external loaders.
274701e371cSuebayasi
275701e371cSuebayasi  Kernel MD linkage is used purely for MD purposes, that is, how kernels are
276701e371cSuebayasi  loaded by external loaders.  It might be possible that one kernel relocatable
277*077d1c0fSandvar  (netbsd.ro) is linked into multiple final kernel image (netbsd) for different
278701e371cSuebayasi  load addresses.
279701e371cSuebayasi
28028fcb3ecSuebayasi  Modular MI linkage is to prepare a module to be loadable as modular(9).  This
28128fcb3ecSuebayasi  may add some extra sections and/or symbols.
28228fcb3ecSuebayasi
28328fcb3ecSuebayasi  Modular MD linkage is again for pure MD purposes like kernel MD linkage.
28428fcb3ecSuebayasi  Adjustment and/or optimization may be done.
28528fcb3ecSuebayasi
28628fcb3ecSuebayasi  Kernel and modular MI linkages may change behavior depending on existence
28728fcb3ecSuebayasi  of debug information.  In the future .symtab will be copied using linker
28828fcb3ecSuebayasi  during this stage.
28979fcd6c2Suebayasi
2905e9af25bSuebayasio Fix db_symtab copying (COPY_SYMTAB)
2915e9af25bSuebayasi
2925e9af25bSuebayasi  o Collect all objects and create a relocatable (netbsd.ro).  At this point,
2935e9af25bSuebayasi    the number of symbols is known.
2945e9af25bSuebayasi
2955e9af25bSuebayasi  o Relink and allocate .rodata.symtab with the calculated size of .symtab.
2965e9af25bSuebayasi    Linker recalculates symbol addresses.
2975e9af25bSuebayasi
2985e9af25bSuebayasi  o Embed the .symtab into .rodata.symtab.
2995e9af25bSuebayasi
3005e9af25bSuebayasi  o Link the final netbsd ELF.
3015e9af25bSuebayasi
3025e9af25bSuebayasi  The make(1) rule (dependency graph) should be identical with/without
3035e9af25bSuebayasi  COPY_SYMTAB.  Kill .ifdef COPY_SYMTAB from $S/conf/Makefile.kern.inc.
3045e9af25bSuebayasi
3059c743328Suebayasio Preprocess and generate linker scripts dynamically.
3069c743328Suebayasi
3079c743328Suebayasi  Include opt_xxx.h and replace some constant values (e.g. COHERENCY_UNIT,
3089c743328Suebayasi  PAGE_SIZE, KERNEL_BASE_PHYS, KERNEL_BASE_VIRT, ...) with cpp(1).
3099c743328Suebayasi
3109c743328Suebayasi  Don't unnecessarily define symbols.  Don't use sed(1).
3119c743328Suebayasi
3129c743328Suebayasio Clean up linker scripts.
3139c743328Suebayasi
3149c743328Suebayasi  o Don't specify OUTPUT_FORMAT()/OUTPUT_ARCH()
3159c743328Suebayasi
3169c743328Suebayasi    These are basically set in compilers/linkers.  If non-default ABI is used,
3179c743328Suebayasi    command-line arguments should be specified.
3189c743328Suebayasi
3199c743328Suebayasi  o Remove .rel/.rela handlings.
3209c743328Suebayasi
3219c743328Suebayasi    These are set in relocatable objects, and handled by dynamic linkers.
3227991f5a7Sandvar    Totally irrelevant for kernels.
3239c743328Suebayasi
3249c743328Suebayasi  o Clean up debug section handlings.
3259c743328Suebayasi
3269c743328Suebayasi  o Document (section boundary) symbols set in linker scripts.
3279c743328Suebayasi
3289c743328Suebayasi    There must be a reason why symbols are defined and exported.
3299c743328Suebayasi
3309c743328Suebayasi    PROVIDE() is to define internal symbols.
3319c743328Suebayasi
3329c743328Suebayasi  o Clean up load addresses.
3339c743328Suebayasi
3349c743328Suebayasi  o Program headers.
3359c743328Suebayasi
3369c743328Suebayasi  o According to matt@, .ARM.extab/.ARM.exidx sections are no longer needed.
3379c743328Suebayasi
33879fcd6c2Suebayasio Redesign swapnetbsd.c (root/swap device specification)
33979fcd6c2Suebayasi
34079fcd6c2Suebayasi  Don't build a whole kernel only to specify root/swap devices.
34179fcd6c2Suebayasi
34279fcd6c2Suebayasi  Make these parameter re-configurable afterwards.
34373810e5dSuebayasi
34473810e5dSuebayasio Namespace.
34573810e5dSuebayasi
34673810e5dSuebayasi  Investigate namespace of attributes/modules/options.  Figure out the hidden
34773810e5dSuebayasi  design about these, document it, then re-design it.
34873810e5dSuebayasi
34973810e5dSuebayasi  At this moment, all of them share the single "selecttab", which means their
35073810e5dSuebayasi  namespaces are common, but they also have respective tables (attrtab,
35173810e5dSuebayasi  opttab, etc.).
35273810e5dSuebayasi
35373810e5dSuebayasi  Selecting an option (addoption()), that is also a module name, works only if
35473810e5dSuebayasi  the module doesn't depend on anything, because addoption() doesn't select
35573810e5dSuebayasi  module and its dependencies (selectattr()).  In other words, an option is
35673810e5dSuebayasi  only safely converted to a module (define), only if it doesn't depend on
35773810e5dSuebayasi  anything.  (One example is DDB.)
3583dbb1947Suebayasi
3593dbb1947Suebayasio Convert pseudo(dev) attach functions to take (void) (== kernel ctors).
3603dbb1947Suebayasi
3613dbb1947Suebayasi  The pseudo attach function was originally designed to take `int n' as
3623dbb1947Suebayasi  the number of instances of the pseudo device.  Now most of pseudo
3633dbb1947Suebayasi  devices have been converted to be `cloneable', meaning that their
3643dbb1947Suebayasi  instances are dynamically allocated at run-time, because guessing how
3653dbb1947Suebayasi  much instances are needed for users at compile time is almost impossible.
3663dbb1947Suebayasi  Restricting such a pure software resource at compile time is senseless,
3673dbb1947Suebayasi  considering that the rest of the world is dynamic.
3683dbb1947Suebayasi
3693dbb1947Suebayasi  If pseudo attach functions once become (void), config(1) no longer
3703dbb1947Suebayasi  has to generate iteration to call those functions, by making them part
3713dbb1947Suebayasi  of kernel constructors, that are a list of (void) functions.
3723dbb1947Suebayasi
3733dbb1947Suebayasi  Some pseudo devices may have dependency/ordering problems, because
3743dbb1947Suebayasi  pseudo attach functions have no choice when to be called.  This could
3753dbb1947Suebayasi  be solved by converting to kctors, where functions are called in order
3763dbb1947Suebayasi  by dependency.
377b0e637a9Spgoyette
378b0e637a9Spgoyetteo Enhance ioconf behavior for pseudo-devices
379b0e637a9Spgoyette
380b0e637a9Spgoyette  See "bin/48571: config(1) ioconf is insufficient for pseudo-devices" for
381b0e637a9Spgoyette  more details.  In a nutshell, it would be "useful" for config to emit
382b0e637a9Spgoyette  the necessary stuff in the generated ioconf.[ch] to enable use of
383b0e637a9Spgoyette  config_{init,fini}_component() for attaching and detaching pseudodev's.
384b0e637a9Spgoyette
385b0e637a9Spgoyette  Currently, you need to manually construct your own data structures, and
386b0e637a9Spgoyette  manually "attach" them, one at a time.  This leads to duplication of
387b0e637a9Spgoyette  code (where multiple drivers contain the same basic logic), and doesn't
388b0e637a9Spgoyette  necessarily handle all of the "frobbing" of the kernel lists.
3897722a652Suebayasi
39014880f9aSuebayasio Don't use -Ttext ${TEXTADDR}.
39114880f9aSuebayasi
39214880f9aSuebayasi  Although ld(1)'s `-Ttext ${TEXTADDR}' is an easy way to specify the virtual
39314880f9aSuebayasi  base address of .text at link time, it needs to change command-line; in
39414880f9aSuebayasi  kernel build, Makefile needs to change to reflect kernel's configuration.
3957991f5a7Sandvar  It is simpler to reflect kernel configuration using linker script via assym.h.
39614880f9aSuebayasi
3977722a652Suebayasio Convert ${DIAGNOSTIC} and ${DEBUG} as flags (defflag).
3987722a652Suebayasi
3997722a652Suebayasi  Probably generate opt_diagnostic.h/opt_debug.h and include them in
4007722a652Suebayasi  sys/param.h.
4017722a652Suebayasi
4027722a652Suebayasio Strictly define DIAGNOSTIC.
4037722a652Suebayasi
4047722a652Suebayasi  It is possible to make DIAGNOSTIC kernel and modules binary-compatible with
4057991f5a7Sandvar  non-DIAGNOSTIC ones.  In that case, debug type information should match
4067722a652Suebayasi  theoretically (not confirmed).
4071e1f20e1Suebayasi
408a72d45f1Suebayasio Use suffix rules.
409a72d45f1Suebayasi
410a72d45f1Suebayasi  Build objects following suffix rules.  Source files are defined as relative to
411a72d45f1Suebayasi  $S (e.g. sys/kern/init_main.c) and objects are generated in the corresponding
412a72d45f1Suebayasi  subdirectories under kernel build directories (e.g.
413a72d45f1Suebayasi  .../compile/GENERIC/sys/kern/init_main.o).  Dig subdirectories from within
414a72d45f1Suebayasi  config(1).
415a72d45f1Suebayasi
416a72d45f1Suebayasi  Debugging (-g) and profiling (-pg) objects could be generated with *.go/*.po
417a72d45f1Suebayasi  suffixes as userland libraries do.  Maybe something similar for
418a72d45f1Suebayasi  DIAGNOSTIC/DEBUG.
419a72d45f1Suebayasi
420a72d45f1Suebayasi  genassym(1) definitions will be split into per-source instead of the single
4217991f5a7Sandvar  assym.h.  Dependencies are corrected and some of mysterious dependencies on
422a72d45f1Suebayasi  `Makefile' in sys/conf/Makefile.kern.inc can go away.
423a72d45f1Suebayasi
4241e1f20e1Suebayasio Define genassym(1) symbols per file.
4251e1f20e1Suebayasi
4261e1f20e1Suebayasi  Have each file define symbols that have to be generated by genassym(1) so
4271e1f20e1Suebayasi  that more accurate dependency is reflected.
4281e1f20e1Suebayasi
4291e1f20e1Suebayasi  For example, if foo.S needs some symbols, it defines them in foo.assym,
4301e1f20e1Suebayasi  declaring that foo.S depends on foo.assym.h, and includes foo.assym.h.
4311e1f20e1Suebayasi  foo.assym.h is generated by following the suffix rule of .assym -> .assym.h.
4321e1f20e1Suebayasi  When one header is updated, only related *.assym.h files are regenerated,
4331e1f20e1Suebayasi  instead of rebuilding all MD/*.S files that depend on the global, single
4341e1f20e1Suebayasi  assym.h.
4350e43d38dSuebayasi
4360e43d38dSuebayasio Support library.
4370e43d38dSuebayasi
4380e43d38dSuebayasi  Provide a consistent way to build library either as .o or .a.
4390e43d38dSuebayasi
440ba0b12dbSuebayasi  Build libraries in sub-make.  Don't include library makefiles.  Don't
441ba0b12dbSuebayasi  pollute search path (.PATH).  libkern does too much.
442ba0b12dbSuebayasi
4430e43d38dSuebayasio Accept `.a' suffix.
4440e43d38dSuebayasi
4450e43d38dSuebayasi  Make "file" command accept `.a' suffix.  Handle it the same way as `.o'.
446fe281df7Suebayasi
447fe281df7Suebayasio Clean up ${MD_OBJS} and friends in Makefile.${MACHINE}.
448fe281df7Suebayasi
449fe281df7Suebayasi  Don't use ${MD_OBJS}, ${MD_LIBS}, ${MD_SFILES}, and ${MD_CFILES}.
450fe281df7Suebayasi
4517991f5a7Sandvar  List files in config(5)'s "file".  Override build rules only when necessary.
452fe281df7Suebayasi
453fe281df7Suebayasi  Rely on the fact that config(1) parses files.${MACHINE} first, outputs
454fe281df7Suebayasi  files in the order it parses files.* (actually include depth), and
455fe281df7Suebayasi  `Makefile.kern.inc' preserve file order to pass to ${LD}.
4566639db6cSuebayasi
4576639db6cSuebayasio Clean up CTF-related rules.
4586639db6cSuebayasi
4596639db6cSuebayasi  Don't overwrite compile/link rules conditionally by existence of
4606639db6cSuebayasi  ${CTFCONVERT}/${CTFMERGE}.  Give a separate suffix (*.ctfo) and define its
4616639db6cSuebayasi  rules (.c -> .ctfo).
462e1ddff40Suebayasi
463e1ddff40Suebayasio Consider using cpp -MD instead of ${MKDEP}.
464e1ddff40Suebayasi
465e1ddff40Suebayasio Make "make depend" mandatory.
466e1ddff40Suebayasi
467e1ddff40Suebayasi  Automatically execute "make depend".
468