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)
Sat, Nov 30, 5:58 PM
Unknown Object (File)
Sun, Nov 24, 8:35 AM
Unknown Object (File)
Nov 16 2024, 2:36 AM
Unknown Object (File)
Nov 14 2024, 12:25 PM
Unknown Object (File)
Nov 6 2024, 7:34 PM
Unknown Object (File)
Sep 30 2024, 11:22 AM
Unknown Object (File)
Sep 17 2024, 7:47 AM
Unknown Object (File)
Sep 1 2024, 10:35 PM
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 Skipped
Unit
Tests Skipped

Event Timeline

stand/common/module.c
375

Need to check argc here ...

413

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

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

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

This revision was automatically updated to reflect the committed changes.