|
随着Linux2.6的发布,由于2.6内核做了教的改动,各个设备的驱动程序在不同程度上要 bKMLinux联盟 进行改写。为了方便各位Linux爱好者我把自己整理的这分文档share出来。该文当列举 bKMLinux联盟 了2.6内核同以前版本的绝大多数变化,可惜的是由于时间和精力有限没有详细列出各个 bKMLinux联盟 函数的用法。 bKMLinux联盟 特别声明:该文档中的内容来自http:/lwn.net,该网也上也有各个函数的较为详细的 bKMLinux联盟 说明可供各位参考。如果需要该文档的word版的朋友, 请mail到weiriver@sohu.com索 bKMLinux联盟 取。 bKMLinux联盟 bKMLinux联盟 1、 使用新的入口 bKMLinux联盟 必须包含 <linux/init.h> bKMLinux联盟 module_init(your_init_func); bKMLinux联盟 module_exit(your_exit_func); bKMLinux联盟 老版本:int init_module(void); bKMLinux联盟 void cleanup_module(voi); bKMLinux联盟 2.4中两种都可以用,对如后面的入口函数不必要显示包含任何头文件。 bKMLinux联盟 2、 GPL bKMLinux联盟 MODULE_LICENSE("Dual BSD/GPL"); bKMLinux联盟 老版本:MODULE_LICENSE("GPL"); bKMLinux联盟 3、 模块参数 bKMLinux联盟 必须显式包含<linux/moduleparam.h> bKMLinux联盟 module_param(name, type, perm); bKMLinux联盟 module_param_named(name, value, type, perm); bKMLinux联盟 参数定义 bKMLinux联盟 module_param_string(name, string, len, perm); bKMLinux联盟 module_param_array(name, type, num, perm); bKMLinux联盟 老版本:MODULE_PARM(variable,type); bKMLinux联盟 MODULE_PARM_DESC(variable,type); bKMLinux联盟 4、 模块别名 bKMLinux联盟 MODULE_ALIAS("alias-name"); bKMLinux联盟 这是新增的,在老版本中需在/etc/modules.conf配置,现在在代码中就可以实现。 bKMLinux联盟 5、 模块计数 bKMLinux联盟 int try_module_get(&module); bKMLinux联盟 module_put(); bKMLinux联盟 老版本:MOD_INC_USE_COUNT 和 MOD_DEC_USE_COUNT bKMLinux联盟 6、 符号导出 bKMLinux联盟 只有显示的导出符号才能被其他模块使用,默认不导出所有的符号,不必使用EXPORT_NO bKMLinux联盟 _SYMBOLS bKMLinux联盟 老板本:默认导出所有的符号,除非使用EXPORT_NO_SYMBOLS bKMLinux联盟 7、 内核版本检查 bKMLinux联盟 需要在多个文件中包含<linux/module.h>时,不必定义__NO_VERSION__ bKMLinux联盟 老版本:在多个文件中包含<linux/module.h>时,除在主文件外的其他文件中必须定义_ bKMLinux联盟 _NO_VERSION__,防止版本重复定义。 bKMLinux联盟 8、 设备号 bKMLinux联盟 kdev_t被废除不可用,新的dev_t拓展到了32位,12位主设备号,20位次设备号。 bKMLinux联盟 unsigned int iminor(struct inode *inode); bKMLinux联盟 unsigned int imajor(struct inode *inode); bKMLinux联盟 老版本:8位主设备号,8位次设备号 bKMLinux联盟 int MAJOR(kdev_t dev); bKMLinux联盟 int MINOR(kdev_t dev); bKMLinux联盟 9、 内存分配头文件变更 bKMLinux联盟 所有的内存分配函数包含在头文件<linux/slab.h>,而原来的<linux/malloc.h>不存在 bKMLinux联盟 老版本:内存分配函数包含在头文件<linux/malloc.h> bKMLinux联盟 10、 结构体的初试化 bKMLinux联盟 gcc开始采用ANSI C的struct结构体的初始化形式: bKMLinux联盟 static struct some_structure = { bKMLinux联盟 .field1 = value, bKMLinux联盟 .field2 = value, bKMLinux联盟 .. bKMLinux联盟 }; bKMLinux联盟 老版本:非标准的初试化形式 bKMLinux联盟 static struct some_structure = { bKMLinux联盟 field1: value, bKMLinux联盟 field2: value, bKMLinux联盟 .. bKMLinux联盟 }; bKMLinux联盟 11、 用户模式帮助器 bKMLinux联盟 int call_usermodehelper(char *path, char **argv, char **envp, bKMLinux联盟 int wait); bKMLinux联盟 新增wait参数 bKMLinux联盟 12、 request_module() bKMLinux联盟 request_module("foo-device-%d", number); bKMLinux联盟 老版本: bKMLinux联盟 char module_name[32]; bKMLinux联盟 printf(module_name, "foo-device-%d", number); bKMLinux联盟 request_module(module_name); bKMLinux联盟 13、 dev_t引发的字符设备的变化 bKMLinux联盟 1、取主次设备号为 bKMLinux联盟 unsigned iminor(struct inode *inode); bKMLinux联盟 unsigned imajor(struct inode *inode); bKMLinux联盟 2、老的register_chrdev()用法没变,保持向后兼容,但不能访问设备号大于256的设备 bKMLinux联盟 。 bKMLinux联盟 3、新的接口为 bKMLinux联盟 a)注册字符设备范围 bKMLinux联盟 int register_chrdev_region(dev_t from, unsigned count, char *name); bKMLinux联盟 b)动态申请主设备号 bKMLinux联盟 int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, char bKMLinux联盟 *name); bKMLinux联盟 看了这两个函数郁闷吧^_^!怎么和file_operations结构联系起来啊?别急! bKMLinux联盟 c)包含 <linux/cdev.h>,利用struct cdev和file_operations连接 bKMLinux联盟 struct cdev *cdev_alloc(void); bKMLinux联盟 void cdev_init(struct cdev *cdev, struct file_operations *fops); bKMLinux联盟 int cdev_add(struct cdev *cdev, dev_t dev, unsigned count); bKMLinux联盟 (分别为,申请cdev结构,和fops连接,将设备加入到系统中!好复杂啊!) bKMLinux联盟 d)void cdev_del(struct cdev *cdev); bKMLinux联盟 只有在cdev_add执行成功才可运行。 bKMLinux联盟 e)辅助函数 bKMLinux联盟 kobject_put(&cdev->kobj); bKMLinux联盟 struct kobject *cdev_get(struct cdev *cdev); bKMLinux联盟 void cdev_put(struct cdev *cdev); bKMLinux联盟 这一部分变化和新增的/sys/dev有一定的关联。 bKMLinux联盟 14、 新增对/proc的访问操作 bKMLinux联盟 <linux/seq_file.h> bKMLinux联盟 以前的/proc中只能得到string, seq_file操作能得到如long等多种数据。 bKMLinux联盟 相关函数: bKMLinux联盟 static struct seq_operations 必须实现这个类似file_operations得数据中得各个成 bKMLinux联盟 员函数。 bKMLinux联盟 seq_printf(); bKMLinux联盟 int seq_putc(struct seq_file *m, char c); bKMLinux联盟 int seq_puts(struct seq_file *m, const char *s); bKMLinux联盟 int seq_escape(struct seq_file *m, const char *s, const char *esc); bKMLinux联盟 int seq_path(struct seq_file *m, struct vfsmount *mnt, bKMLinux联盟 struct dentry *dentry, char *esc); bKMLinux联盟 seq_open(file, &ct_seq_ops); bKMLinux联盟 等等 bKMLinux联盟 15、 底层内存分配 bKMLinux联盟 1、<linux/malloc.h>头文件改为<linux/slab.h> bKMLinux联盟 2、分配标志GFP_BUFFER被取消,取而代之的是GFP_NOIO 和 GFP_NOFS bKMLinux联盟 3、新增__GFP_REPEAT,__GFP_NOFAIL,__GFP_NORETRY分配标志 bKMLinux联盟 4、页面分配函数alloc_pages(),get_free_page()被包含在<linux/gfp.h>中 bKMLinux联盟 5、对NUMA系统新增了几个函数: bKMLinux联盟 a) struct page *alloc_pages_node(int node_id, bKMLinux联盟 unsigned int gfp_mask, bKMLinux联盟 unsigned int order); bKMLinux联盟 b) void free_hot_page(struct page *page); bKMLinux联盟 c) void free_cold_page(struct page *page); bKMLinux联盟 6、 新增Memory pools bKMLinux联盟 <linux/mempool.h> bKMLinux联盟 mempool_t *mempool_create(int min_nr, bKMLinux联盟 mempool_alloc_t *alloc_fn, bKMLinux联盟 mempool_free_t *free_fn, bKMLinux联盟 void *pool_data); bKMLinux联盟 void *mempool_alloc(mempool_t *pool, int gfp_mask); bKMLinux联盟 void mempool_free(void *element, mempool_t *pool); bKMLinux联盟 int mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask); bKMLinux联盟 16、 per-CPU变量 bKMLinux联盟 get_cpu_var(); bKMLinux联盟 put_cpu_var(); bKMLinux联盟 void *alloc_percpu(type); bKMLinux联盟 void free_percpu(const void *); bKMLinux联盟 per_cpu_ptr(void *ptr, int cpu) bKMLinux联盟 get_cpu_ptr(ptr) bKMLinux联盟 put_cpu_ptr(ptr) bKMLinux联盟 老版本使用 bKMLinux联盟 DEFINE_PER_CPU(type, name); bKMLinux联盟 EXPORT_PER_CPU_SYMBOL(name); bKMLinux联盟 EXPORT_PER_CPU_SYMBOL_GPL(name); bKMLinux联盟 DECLARE_PER_CPU(type, name); bKMLinux联盟 DEFINE_PER_CPU(int, mypcint); bKMLinux联盟 2.6内核采用了可剥夺得调度方式这些宏都不安全。 bKMLinux联盟 17、 内核时间变化 bKMLinux联盟 1、现在的各个平台的HZ为 bKMLinux联盟 Alpha: 1024/1200; ARM: 100/128/200/1000; CRIS: 100; i386: 1000; IA-64: bKMLinux联盟 1024; M68K: 100; M68K-nommu: 50-1000; MIPS: 100/128/1000; MIPS64: 100; bKMLinux联盟 PA-RISC: 100/1000; PowerPC32: 100; PowerPC64: 1000; S/390: 100; SPARC32: bKMLinux联盟 100; SPARC64: 100; SuperH: 100/1000; UML: 100; v850: 24-100; x86-64: 1000. bKMLinux联盟 2、由于HZ的变化,原来的jiffies计数器很快就溢出了,引入了新的计数器jiffies_64 bKMLinux联盟 3、#include <linux/jiffies.h> bKMLinux联盟 u64 my_time = get_jiffies_64(); bKMLinux联盟 4、新的时间结构增加了纳秒成员变量 bKMLinux联盟 struct timespec current_kernel_time(void); bKMLinux联盟 5、他的timer函数没变,新增 bKMLinux联盟 void add_timer_on(struct timer_list *timer, int cpu); bKMLinux联盟 6、新增纳秒级延时函数 bKMLinux联盟 ndelay(); bKMLinux联盟 7、POSIX clocks 参考kernel/posix-timers.c bKMLinux联盟 18、 工作队列(workqueue) bKMLinux联盟 1、任务队列(task queue )接口函数都被取消,新增了workqueue接口函数 bKMLinux联盟 struct workqueue_struct *create_workqueue(const char *name); bKMLinux联盟 DECLARE_WORK(name, void (*function)(void *), void *data); bKMLinux联盟 INIT_WORK(struct work_struct *work, bKMLinux联盟 void (*function)(void *), void *data); bKMLinux联盟 PREPARE_WORK(struct work_struct *work, bKMLinux联盟 void (*function)(void *), void *data); bKMLinux联盟 2、申明struct work_struct结构 bKMLinux联盟 int queue_work(struct workqueue_struct *queue, bKMLinux联盟 struct work_struct *work); bKMLinux联盟 int queue_delayed_work(struct workqueue_struct *queue, bKMLinux联盟 struct work_struct *work, bKMLinux联盟 unsigned long delay); bKMLinux联盟 int cancel_delayed_work(struct work_struct *work); bKMLinux联盟 void flush_workqueue(struct workqueue_struct *queue); bKMLinux联盟 void destroy_workqueue(struct workqueue_struct *queue); bKMLinux联盟 int schedule_work(struct work_struct *work); bKMLinux联盟 int schedule_delayed_work(struct work_struct *work, unsigned long bKMLinux联盟 delay); bKMLinux联盟 19、 新增创建VFS的"libfs" bKMLinux联盟 libfs给创建一个新的文件系统提供了大量的API. bKMLinux联盟 主要是对struct file_system_type的实现。 bKMLinux联盟 参考源代码: bKMLinux联盟 drivers/hotplug/pci_hotplug_core.c bKMLinux联盟 drivers/usb/core/inode.c bKMLinux联盟 drivers/oprofile/oprofilefs.c bKMLinux联盟 fs/ramfs/inode.c bKMLinux联盟 fs/nfsd/nfsctl.c (simple_fill_super() example) bKMLinux联盟 20、 DMA的变化 bKMLinux联盟 未变化的有: bKMLinux联盟 void *pci_alloc_consistent(struct pci_dev *dev, size_t size, bKMLinux联盟 dma_addr_t *dma_handle); bKMLinux联盟 void pci_free_consistent(struct pci_dev *dev, size_t size, bKMLinux联盟 void *cpu_addr, dma_addr_t dma_handle); bKMLinux联盟 变化的有: bKMLinux联盟 1、 void *dma_alloc_coherent(struct device *dev, size_t size, bKMLinux联盟 dma_addr_t *dma_handle, int flag); bKMLinux联盟 void dma_free_coherent(struct device *dev, size_t size, bKMLinux联盟 void *cpu_addr, dma_addr_t dma_handle); bKMLinux联盟 2、列举了映射方向: bKMLinux联盟 enum dma_data_direction { bKMLinux联盟 DMA_BIDIRECTIONAL = 0, bKMLinux联盟 DMA_TO_DEVICE = 1, bKMLinux联盟 DMA_FROM_DEVICE = 2, bKMLinux联盟 DMA_NONE = 3, bKMLinux联盟 }; bKMLinux联盟 3、单映射 bKMLinux联盟 dma_addr_t dma_map_single(struct device *dev, void *addr, bKMLinux联盟 size_t size, bKMLinux联盟 enum dma_data_direction direction); bKMLinux联盟 void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, bKMLinux联盟 size_t size, bKMLinux联盟 enum dma_data_direction direction); bKMLinux联盟 4、页面映射 bKMLinux联盟 dma_addr_t dma_map_page(struct device *dev, struct page *page, bKMLinux联盟 unsigned long offset, size_t size, bKMLinux联盟 enum dma_data_direction direction); bKMLinux联盟 void dma_unmap_page(struct device *dev, dma_addr_t dma_addr, bKMLinux联盟 size_t size, bKMLinux联盟 enum dma_data_direction direction); bKMLinux联盟 5、有关scatter/gather的函数: bKMLinux联盟 int dma_map_sg(struct device *dev, struct scatterlist *sg, bKMLinux联盟 int nents, enum dma_data_direction direction); bKMLinux联盟 void dma_unmap_sg(struct device *dev, struct scatterlist *sg, bKMLinux联盟 int nhwentries, enum dma_data_direction direction); bKMLinux联盟 6、非一致性映射(Noncoherent DMA mappings) bKMLinux联盟 void *dma_alloc_noncoherent(struct device *dev, size_t size, bKMLinux联盟 dma_addr_t *dma_handle, int flag); bKMLinux联盟 void dma_sync_single_range(struct device *dev, dma_addr_t dma_handle, bKMLinux联盟 unsigned long offset, size_t size, bKMLinux联盟 enum dma_data_direction direction); bKMLinux联盟 void dma_free_noncoherent(struct device *dev, size_t size, bKMLinux联盟 void *cpu_addr, dma_addr_t dma_handle); bKMLinux联盟 7、DAC (double address cycle) bKMLinux联盟 int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask); bKMLinux联盟 void pci_dac_dma_sync_single(struct pci_dev *dev, bKMLinux联盟 dma64_addr_t dma_addr, bKMLinux联盟 size_t len, int direction); bKMLinux联盟 21、 互斥 bKMLinux联盟 新增seqlock主要用于: bKMLinux联盟 1、少量的数据保护 bKMLinux联盟 2、数据比较简单(没有指针),并且使用频率很高 bKMLinux联盟 3、对不产生任何副作用的数据的访问 bKMLinux联盟 4、访问时写者不被饿死 bKMLinux联盟 <linux/seqlock.h> bKMLinux联盟 初始化 bKMLinux联盟 seqlock_t lock1 = SEQLOCK_UNLOCKED; bKMLinux联盟 或seqlock_t lock2; seqlock_init(&lock2); bKMLinux联盟 void write_seqlock(seqlock_t *sl); bKMLinux联盟 void write_sequnlock(seqlock_t *sl); bKMLinux联盟 int write_tryseqlock(seqlock_t *sl); bKMLinux联盟 void write_seqlock_irqsave(seqlock_t *sl, long flags); bKMLinux联盟 void write_sequnlock_irqrestore(seqlock_t *sl, long flags); bKMLinux联盟 void write_seqlock_irq(seqlock_t *sl); bKMLinux联盟 void write_sequnlock_irq(seqlock_t *sl); bKMLinux联盟 void write_seqlock_bh(seqlock_t *sl); bKMLinux联盟 void write_sequnlock_bh(seqlock_t *sl); bKMLinux联盟 unsigned int read_seqbegin(seqlock_t *sl); bKMLinux联盟 int read_seqretry(seqlock_t *sl, unsigned int iv); bKMLinux联盟 unsigned int read_seqbegin_irqsave(seqlock_t *sl, long flags); bKMLinux联盟 int read_seqretry_irqrestore(seqlock_t *sl, unsigned int iv, long bKMLinux联盟 flags); bKMLinux联盟 22、 内核可剥夺 bKMLinux联盟 <linux/preempt.h> bKMLinux联盟 preempt_disable(); bKMLinux联盟 preempt_enable_no_resched(); bKMLinux联盟 preempt_enable_noresched(); bKMLinux联盟 preempt_check_resched(); bKMLinux联盟 23、 眠和唤醒 bKMLinux联盟 1、原来的函数可用,新增下列函数: bKMLinux联盟 prepare_to_wait_exclusive(); bKMLinux联盟 prepare_to_wait(); bKMLinux联盟 2、等待队列的变化 bKMLinux联盟 typedef int (*wait_queue_func_t)(wait_queue_t *wait, bKMLinux联盟 unsigned mode, int sync); bKMLinux联盟 void init_waitqueue_func_entry(wait_queue_t *queue, bKMLinux联盟 wait_queue_func_t func); bKMLinux联盟 24、 新增完成事件(completion events) bKMLinux联盟 <linux/completion.h> bKMLinux联盟 init_completion(&my_comp); bKMLinux联盟 void wait_for_completion(struct completion *comp); bKMLinux联盟 void complete(struct completion *comp); bKMLinux联盟 void complete_all(struct completion *comp); bKMLinux联盟 25、 RCU(Read-copy-update) bKMLinux联盟 rcu_read_lock(); bKMLinux联盟 void call_rcu(struct rcu_head *head, void (*func)(void *arg), bKMLinux联盟 void *arg); bKMLinux联盟 26、 中断处理 bKMLinux联盟 1、中断处理有返回值了。 bKMLinux联盟 IRQ_RETVAL(handled); bKMLinux联盟 2、cli(), sti(), save_flags(), 和 restore_flags()不再有效,应该使用local_save bKMLinux联盟 _flags() 或local_irq_disable()。 bKMLinux联盟 3、synchronize_irq()函数有改动 bKMLinux联盟 4、新增int can_request_irq(unsigned int irq, unsigned long flags); bKMLinux联盟 5、 request_irq() 和free_irq() 从 <linux/sched.h>改到了 <linux/interrupt.h> bKMLinux联盟 27、 异步I/O(AIO) bKMLinux联盟 <linux/aio.h> bKMLinux联盟 ssize_t (*aio_read) (struct kiocb *iocb, char __user *buffer, bKMLinux联盟 size_t count, loff_t pos); bKMLinux联盟 ssize_t (*aio_write) (struct kiocb *iocb, const char __user *buffer, bKMLinux联盟 size_t count, loff_t pos); bKMLinux联盟 int (*aio_fsync) (struct kiocb *, int datasync); bKMLinux联盟 新增到了file_operation结构中。 bKMLinux联盟 is_sync_kiocb(struct kiocb *iocb); bKMLinux联盟 int aio_complete(struct kiocb *iocb, long res, long res2); bKMLinux联盟 28、 网络驱动 bKMLinux联盟 1、struct net_device *alloc_netdev(int sizeof_priv, const char *name, bKMLinux联盟 void (*setup)(struct net_device *)); bKMLinux联盟 struct net_device *alloc_etherdev(int sizeof_priv); bKMLinux联盟 2、新增NAPI(New API) bKMLinux联盟 void netif_rx_schedule(struct net_device *dev); bKMLinux联盟 void netif_rx_complete(struct net_device *dev); bKMLinux联盟 int netif_rx_ni(struct sk_buff *skb); bKMLinux联盟 (老版本为netif_rx()) bKMLinux联盟 29、 USB驱动 bKMLinux联盟 老版本struct usb_driver取消了,新的结构体为 bKMLinux联盟 struct usb_class_driver { bKMLinux联盟 char *name; bKMLinux联盟 struct file_operations *fops; bKMLinux联盟 mode_t mode; bKMLinux联盟 int minor_base; bKMLinux联盟 }; bKMLinux联盟 int usb_submit_urb(struct urb *urb, int mem_flags); bKMLinux联盟 int (*probe) (struct usb_interface *intf, bKMLinux联盟 const struct usb_device_id *id); bKMLinux联盟 30、 block I/O 层 bKMLinux联盟 这一部分做的改动最大。不祥叙。 bKMLinux联盟 31、 mmap() bKMLinux联盟 int remap_page_range(struct vm_area_struct *vma, unsigned long from, bKMLinux联盟 unsigned long to, unsigned long size, bKMLinux联盟 pgprot_t prot); bKMLinux联盟 int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, bKMLinux联盟 unsigned long to, unsigned long size, bKMLinux联盟 pgprot_t prot); bKMLinux联盟 struct page *(*nopage)(struct vm_area_struct *area, bKMLinux联盟 unsigned long address, bKMLinux联盟 int *type); bKMLinux联盟 int (*populate)(struct vm_area_struct *area, unsigned long address, bKMLinux联盟 unsigned long len, pgprot_t prot, unsigned long pgoff, bKMLinux联盟 int nonblock); bKMLinux联盟 int install_page(struct mm_struct *mm, struct vm_area_struct *vma, bKMLinux联盟 unsigned long addr, struct page *page, bKMLinux联盟 pgprot_t prot); bKMLinux联盟 struct page *vmalloc_to_page(void *address); bKMLinux联盟 32、 零拷贝块I/O(Zero-copy block I/O) bKMLinux联盟 struct bio *bio_map_user(struct block_device *bdev, bKMLinux联盟 unsigned long uaddr, bKMLinux联盟 unsigned int len, bKMLinux联盟 int write_to_vm); bKMLinux联盟 void bio_unmap_user(struct bio *bio, int write_to_vm); bKMLinux联盟 int get_user_pages(struct task_struct *task, bKMLinux联盟 struct mm_struct *mm, bKMLinux联盟 unsigned long start, bKMLinux联盟 int len, bKMLinux联盟 int write, bKMLinux联盟 int force, bKMLinux联盟 struct page **pages, bKMLinux联盟 struct vm_area_struct **vmas); bKMLinux联盟 33、 高端内存操作kmaps bKMLinux联盟 void *kmap_atomic(struct page *page, enum km_type type); bKMLinux联盟 void kunmap_atomic(void *address, enum km_type type); bKMLinux联盟 struct page *kmap_atomic_to_page(void *address); bKMLinux联盟 老版本:kmap() 和 kunmap()。 bKMLinux联盟 34、 驱动模型 bKMLinux联盟 主要用于设备管理。 bKMLinux联盟 1、 sysfs bKMLinux联盟 2、 Kobjects 推荐文章: bKMLinux联盟 http:/www-900.ibm.com/developerWorks/cn/linux/kernel/l-kernel26/index.shtml bKMLinux联盟 http:/www-900.ibm.com/developerWorks/cn/linux/l-inside/index.shtml bKMLinux联盟
2.6里不需要再定义“__KERNEL__”和“MODULE”了。 bKMLinux联盟 用下面的Makefile文件编译: bKMLinux联盟 bKMLinux联盟
| 代码: | bKMLinux联盟 obj-m := hello.o bKMLinux联盟 bKMLinux联盟 KDIR := /lib/modules/$(shell uname -r)/build bKMLinux联盟 PWD := $(shell pwd) bKMLinux联盟 default: bKMLinux联盟 $(MAKE) -C $(KDIR) M=$(PWD) modules |
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论 |
|