Page MenuHomeFreeBSD

loader: Add pnp functions for autoloading modules based on linker.hints
ClosedPublic

Authored by manu on Mar 7 2019, 7:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 11 2024, 8:27 AM
Unknown Object (File)
Mar 11 2024, 8:27 AM
Unknown Object (File)
Mar 11 2024, 8:27 AM
Unknown Object (File)
Mar 11 2024, 8:27 AM
Unknown Object (File)
Mar 7 2024, 10:51 PM
Unknown Object (File)
Feb 19 2024, 9:17 PM
Unknown Object (File)
Feb 17 2024, 4:36 AM
Unknown Object (File)
Jan 9 2024, 11:26 AM
Subscribers
None

Details

Summary

This adds some new commands to loader :

  • pnpmatch This takes a pnpinfo string as argument and tries to find a kernel module associated with it. -v and -d option are available and are the same as in devmatch (v is verbose, d dumps the hints).
  • pnpload This takes a pnpinfo string as argument and tries to load a kernel module associated with it.
  • pnpautoload This will attempt to load every kernel module for each buses. Each buses are probed, the probe function will generate pnpinfo string and load kernel module associated with it if it exists.

    Only simplebus for FDT system is implemented for now. Since we need the dtb and overlays to be applied before searching the tree fdt_devmatch_next will load and apply the dtb + overlays.

All the pnp parsing code comes from devmatch and is the same at 99%.

Test Plan

Tested on arm64 with a Pine64-lts board with some external patch to have a lots of module (https://github.com/evadot/freebsd/tree/loader_pnp)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

stand/common/module.c
375 ↗(On Diff #54812)

Need to check argc here ...

413 ↗(On Diff #54812)

Same here, need to check argc

Adds the bus name as argument of devmatch_search_hints and make a table of all buses name + function so we can iterate on it.

This code looks well honed, so I'm not seeing much of anything apart from one issue.
The code we duplicate is kinda tricky and ugly. If we find bugs in it, we'd have to make the changes here and in devmatch. How hard would it be to merge the two?

stand/common/module.c
1184 ↗(On Diff #56660)

This is an almost, but not quite, verbatim copy of sbin/devmatch/devmatch.c:search_hints. Is there any way we can merge the two because this code is somewhat complex...

I talked to manu on irc. I'm approving this. we can work towards merging in the fullness of time.

This revision is now accepted and ready to land.May 23 2019, 2:43 PM

multiple modules can match. we need to work that out, but it's ok if we do that in the future.

stand/common/module.c
1351 ↗(On Diff #56660)

multiple modules can match, and this just returns one of them.

This revision was automatically updated to reflect the committed changes.