Implementing Custom libtsctl Architectures
The libtsctl build system has been created in such a way that it is possible to implement a custom architecture which is not part of the tsctl source tree. This is useful because typically a piece of custom hardware is specific to a single customer, and thus it is not appropriate to distribute support for such a custom product to anyone but that customer. This section describes how to add such support.
The first step is to create the required files to support the architecture in a directory outside of the libtsctl directory. The files that will typically be needed include:
- NameArch.c for each corresponding architecture implemented, which contains the top-level declarations of all the modules needed to implement the architecture, as well as the initialization functions of all the objects and the Arch object for the class representing the architecture.
- ArchCustom.c which contains the following functions:
TS_CPU TSCustomCPUGet(char *cpuinfo);
This function is passed a buffer containing the text from /proc/cpuinfo (up to 4k bytes). The function must return CPU_CUSTOM if it detects the custom board it supports, either from the passed cpuinfo buffer, or using whatever means are necessary to detect the board. Otherwise it must return CPU_UNKNOWN.
Arch *ArchCustomInit(TS_CPU cpu);
This function is passed the CPU detected previously. If the passed value is CPU_CUSTOM, then this function must return an instance of custom architecture object it has implemented, which must be returned from the corresponding architecture specific initialization function. Otherwise it must return 0.
Arch *ArchCustomBBInit(int model);
This function is passed the base board ID detected by ArchBBInit. If the custom architecture implements support for one or more baseboards, then it must call ArchBBInit during the initialization of the top-level (CPU) architecture. This function must then use the detected model id to determine which custom base board architecture initialization function to call and return the pointer that call returns.
Note: Currently there is no support for implementing support for custom PC-104 peripherals.
- Makefile
The Makefile must specified a build rule for reaching the libtsctl library for the custom architecture. This rule must look something like this:
$(DIR)/libtscustom.a: $(addprefix $(DIR_CUSTOM)/,CustomArch.o ArchCustom.o OtherObject.o tscustom_dioctl_config.o) ar -r $@ $^
- Any other files needed to implement objects used by the architecture, or to implement utility functions used by the architecture.
After the support files are created, it is necessary to pass variables and CFLAGS to make to tell it about the custom architecture. These CFLAGS are:
-DARCH_CUSTOM
informs the build process that our custom architecture exists and implements the functions in the files specified above
The variables are:
DIR=custom_out_dir
' specifies the sub-directory to contain the intermediate and product files for the architecture. Replace "custom_out_dir" with the name of the actual directory to use.DIR_CUSTOM=custom_dir
specifies the path to the directory containing the custom files. Replace "custom_dir" with the name of the actual directory.SUPPORTED="custom"
tells the build process to compile in support for the custom architecture. If you need other architectures supported too they must be added to the list.