Linux编译SDK时报错

CPU模块为 :海光AMD
操作系统为:统信UOS

1、 error: unknown type name ‘mm_segment_t’; did you mean ‘apm_event_t’?
static inline void set_fs(mm_segment_t fs)

$ vim /lib/modules/$(uname -r)/build/arch/x86/include/asm/uaccess.h

添加头文件

#include <asm/processor.h>

2、 error: dereferencing pointer to incomplete type ‘struct task_struct’
current->thread.addr_limit = fs;

$ vim /lib/modules/$(uname -r)/build/arch/x86/include/asm/uaccess.h

添加头文件

#include <linux/sched.h>

3、 error: passing argument 1 of ‘kthread_create_on_node’ from incompatible pointer type
kport_monitor_task = kthread_run(_Hal_PortMonitorThread, NULL, “portmonitor”);

找到_Hal_PortMonitorThread函数定义的地方改为

static int _Hal_PortMonitorThread(void *data)
{
	...
}

4、error: implicit declaration of function ‘pci_enable_msi_exact’; did you mean ‘pci_enable_msix_exact’

将pci_enable_msix_exact修改成pci_enable_msix_range,参数也要相应修改

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0))
        ret = pci_enable_msix_range(dal_dev, NULL, msi_num, msi_num)

5、implicit declaration of function ‘copy_from_user’;
implicit declaration of function ‘copy_to_user’

#include <linux/uaccess.h>

6、error: implicit declaration of function ‘init_timer’

#if (LINUX_VERSION_CODE  < KERNEL_VERSION(4,14,0))
    init_timer(&dev->getIntrTimer);
    dev->getIntrTimer.data = (unsigned long) dev;
    dev->getIntrTimer.function = GetIntrTimerCallback;
    /* ... */
    add_timer(&dev->getIntrTimer);
#else
    timer_setup(&dev->getIntrTimer, GetIntrTimerCallback, 0);
    /* the third argument may include TIMER_* flags */
    /* ... */
#endif


#if (LINUX_VERSION_CODE  < KERNEL_VERSION(4,14,0))
void GetIntrTimerCallback(unsigned long devAddr)
{
    myDevice *dev = (myDevice *) devAddr;
#else
void GetIntrTimerCallback(struct timer_list *t)
{
    myDevice *dev = from_timer(dev, t, getIntrTimer);
#endif
    /* Do something with "dev" */
}
posted @ 2022-11-30 14:45  h云淡风轻  阅读(454)  评论(0)    收藏  举报  来源