Shuffle some adapter kernel code into a separate source file