Linux kernel header organization

While I was reading system calls, I searched syscalls.h to find the header file in LXR. The search results puzzled me. There are a dozen syscalls.h files coming from directories under arch/_arch_name_/include/asm . Everything is in order, these are definitions specific to architecture, or something else is necessary. The question is, why do we have two different syscalls.h headers under include/linux and include/asm-generic ?

In addition, I want to know what include/linux headers are for and what include/asm-generic headers are for. How do they distinguish each other? What is the logic of having two separate header folders? How do they relate to each other?

thanks

+6
source share
2 answers

I asked this question Kernel Newbies ML . I received the following answer, which makes it clear:

Cihangir Akturk wrote:

AFAIK, the headers found in the / include / asm -generic directory are for architect independent (possibly shared between architectures) code. Most likely, you do not need to include these headers directly, instead we include these headers indirectly through the dependent architecture headers.

The OTOH directory, / include / linux is for common header files for defining interfaces between kernel components. In most situations, you will find all the kernel functionality that you need in these headers.

hi chngr.

+6
source

The headers in the arch/_arch_name_/include/asm directories depend on the specific architecture, for example, for x86, the ARM architecture. Thus, internal logic is platform dependent and highly dependent on underlying hardware. You will only include what is your platform architecture.

The headers in include/linux are generic and platform independent. They are common logic and will be divided among themselves.

+1
source

Source: https://habr.com/ru/post/911256/


All Articles