Kernel callout start and end macros

Updated: May 06, 2022

The build process recognizes that the code between CALLOUT_START and CALLOUT_END is a kernel callout that needs to be saved to a safe place in memory.

At the start of the source code (below the copyright boilerplate text and the comments), kernel callout source code has one of the following:
#include "callout.ah"
or:
.include "callout.ah"

The assembly syntax determines whether the callout uses #include or .include.

The included file defines the following macros:

CALLOUT_START

The CALLOUT_START macro marks the start of a kernel callout. Its three parameters are:

  1. Name of the kernel callout routine.
  2. Address of a four-byte variable that contains the amount of read/write storage needed by the callout (see Allocating read/write storage in this chapter).
  3. Address of a patcher routine, or 0 (zero) if no patching is needed (see Patching the kernel callout code in this chapter).
CALLOUT_END
The CALLOUT_END macro marks the end of the kernel callout routine. It takes one argument, which must be the same as the first argument in the preceding CALLOUT_START macro.

If this code is the only version of the kernel callout available, or if the discovery process selects this routine to be used by the kernel, the startup library copies the code between CALLOUT_START and CALLOUT_END to a safe place in memory. In this memory location, the code will be available to the kernel after the memory that was allocated for the startup code has been overwritten.

The syntax of the two macros depends on the assembly used in the source code. The following examples are two common versions (this code and all assembly code in this document uses GNU Assembler (GAS) syntax):
CALLOUT_START(timer_load_8254, 0, 0)
CALLOUT_END(timer_load_8254)
and:
CALLOUT_START timer_load_8254, 0, 0
CALLOUT_END timer_load_8254

Keep whatever syntax is used in the file you started from, and replace the sections of code from the original file with code that works with your hardware.