0

我正在使用 Android NDK 将 kexec 构建为外部内核模块。我知道我的所有环境变量都设置正确。

该模块基于来自 android 论坛的代码,该论坛基于 linux 通常会构建到内核中的 kexec.c。最终目标是通过在第一个内核之后加载第二个内核来绕过锁定的引导加载程序。

我遇到了多个错误,很可能都与 .h 文件中的内容有关。我的 C 技能真的很生疏,但这里有几个错误:

make -C /media/disk/android/kernel/omap3 M=/media/disk/android/kexec modules
make[1]: Entering directory `/media/disk/android/kernel/omap3'
  CC [M]  /media/disk/android/kexec/kexec.o
/media/disk/android/kexec/kexec.c:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/media/disk/android/kexec/kexec.c:55: error: 'VMCOREINFO_BYTES' undeclared here (not in a function)
/media/disk/android/kexec/kexec.c:56: error: 'VMCOREINFO_NOTE_SIZE' undeclared here (not in a function)
/media/disk/android/kexec/kexec.c:115: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c:115: warning: its scope is only this definition or declaration, 
    which is probably not what you want
/media/disk/android/kexec/kexec.c:118: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c:122: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c: In function 'do_kimage_alloc':
/media/disk/android/kexec/kexec.c:131: error: dereferencing pointer to incomplete type

无论如何,有问题的片段在下面,还有以下链接到 kexec.c 和 kexec.h 的粘贴完整源代码。

谢谢!

MODULE_LICENSE("GPL");

/* Syscall table */
void **sys_call_table;

/* original and new reboot syscall */
asmlinkage long (*original_reboot)(int magic1, int magic2, unsigned int cmd, void __user *arg);
extern asmlinkage long reboot(int magic1, int magic2, unsigned int cmd, void __user *arg);

/* Per cpu memory for storing cpu states in case of system crash. */
note_buf_t *crash_notes;

/* vmcoreinfo stuff */
unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
size_t vmcoreinfo_size;
size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);

/* Location of the reserved area for the crash kernel */
struct resource crashk_res = {
    .name  = "Crash kernel",
    .start = 0,
    .end   = 0,
    .flags = IORESOURCE_BUSY | IORESOURCE_MEM
};
4

1 回答 1

1

尝试定义CONFIG_KEXEC. 如果没有此定义,kexec.h则不包括所有相关定义,这反过来又会导致您收到至少一些错误消息。

为此,您可以添加-DCONFIG_KEXECCFLAGS任何适当的环境变量,或者只需编辑Makefile.

于 2012-04-19T12:37:31.803 回答