Take a look at the fw_update(1) man page. This tool automates firmware acquisition for many devices where their licensing does not permit packaging firmware with the OS.

The RAMDISK kernel's install and upgrade scripts normally set this to run at first boot after install or upgrade. Of course, if you don't have a working network interface on first boot, it won't do much for you.

Here's the two lines in /usr/src/distrib/miniroot/install.sub that do this: