Initialization calls in Linux

There are many initialization calls in Linux kernel and these initcalls are grouped by functionality into separate subsections in Linux-2.6.18, such as “core_initcall(ksysfs_init)” and “arch_initcall(au1xxx_platform_init)”.

Both “core_initcall” and “arch_initcall” are macros which are defined in linux-2.6.18/include/linux/init.h. The following shows the definition when these are built in kernel (not in module):

#define __define_initcall(level,fn) /

       static initcall_t __initcall_##fn __attribute_used__ /

       __attribute__((__section__(".initcall" level ".init"))) = fn

 

#define core_initcall(fn)        __define_initcall("1",fn)

#define postcore_initcall(fn)         __define_initcall("2",fn)

#define arch_initcall(fn)        __define_initcall("3",fn)

#define subsys_initcall(fn)            __define_initcall("4",fn)

#define fs_initcall(fn)                  __define_initcall("5",fn)

#define device_initcall(fn)            __define_initcall("6",fn)

#define late_initcall(fn)         __define_initcall("7",fn)

 

#define __initcall(fn) device_initcall(fn)

From these, we can find that all initcalls declared with these initcall macros will be linked to “.initcall” section.

In linux kernel link file for MIPS (linux-2.6.18/arch/mips/kennel/vmlinux.lds.S), we can find “.initcall” section is linked like this:

  __initcall_start = .;

  .initcall.init : {

       *(.initcall1.init)

       *(.initcall2.init)

       *(.initcall3.init)

       *(.initcall4.init)

       *(.initcall5.init)

       *(.initcall6.init)

       *(.initcall7.init)

  }

  __initcall_end = .;

So all initcalls functions is saved in the memory range between __initcall_start and __initcall_end.

All these initcalls will be called in do_initcalls() which is implemented in linux-2.6.18/init/main.c and it is called by “init” thread when booting up Linux kernel. These initcalls are called like this:

static void __init do_initcalls(void)

{

       initcall_t *call;

       int count = preempt_count();

 

       for (call = __initcall_start; call < __initcall_end; call++) {

              char *msg = NULL;

              char msgbuf[40];

              int result;

 

              …

 

              result = (*call)();

 

              …

              }

       }

 

       /* Make sure there is no pending stuff from the initcall sequence */

       flush_scheduled_work();

}

From the code we can find we get the initcall function pointer with “__initcall_start” and “__initcall_end” which is defined in linux link file vmlinux.lds.S.

### TSPI in Linux Environment In the context of secure computing within a Linux environment, the Trusted Service Provider Interface (TSPI) plays an essential role as part of the Trusted Computing Group's standards to facilitate security operations and management. The interface allows applications to interact with trusted platform modules (TPMs), which are hardware-based security tokens embedded into computers[^1]. The primary function of TSPI is enabling communication between software components that require cryptographic services or other trust-related functions provided by TPMs. This includes tasks such as key generation, storage protection, attestation processes, sealing/unsealing data based on specific conditions set forth during encryption/decryption activities. For developers working under GNU/Linux distributions who wish to leverage these capabilities through programming interfaces like C/C++, Python libraries exist specifically designed around interfacing directly with TPM chips via TSPI calls[^2]. ```c #include <tspi.h> // Example code snippet showing initialization process using TSS API. TSS_RESULT rc; TSS_HCONTEXT hContext; rc = Tspi_Context_Create(&hContext); if (rc != TSS_SUCCESS){ printf("Error creating context\n"); } ``` To work effectively with TSPI on Linux systems, one must ensure proper installation and configuration of relevant packages including `trousers`, which serves as middleware implementing much-needed functionality required when dealing with TPM devices at lower levels while abstracting away complex details from higher-level application logic[^3].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值