HomeFreeBSD

Add eventhandler notifications for newbus device attach/detach.

Description

Add eventhandler notifications for newbus device attach/detach.

The detach case is slightly complicated by the fact that some in-kernel
consumers may want to know before a device detaches (so they can release
related resources, stop using the device, etc), but the detach can fail. So
there are pre- and post-detach notifications for those consumers who need to
handle all cases.

A couple salient comments from the review, they amount to some helpful
documentation about these events, but there's currently no good place for
such documentation...

Note that in the current newbus locking model, DETACH_BEGIN and
DETACH_COMPLETE/FAILED sequence of event handler invocation might interweave
with other attach/detach events arbitrarily. The handlers should be prepared
for such situations.

Also should note that detach may be called after the parent bus knows the
hardware has left the building. In-kernel consumers have to be prepared to
cope with this race.

Differential Revision: https://reviews.freebsd.org/D12557