Linux核心大講堂之裝置驅動的基石驅動模型 7

2021-06-26 19:39:38 字數 2184 閱讀 6448

**

**:無為和尚的linux核心大講堂系列。

終於快講完了,這一節其實就是讓上節我們所說的四大天王露下小臉。原始碼分析請自行完成吧。我建議大家可以試著先看一下**,如果能看懂,那就把我寫的那破玩意刪掉,自已實現一遍,如果不能看懂,那馬上回過去從第一小節重新看過,耐心,一定要有耐心,沒耐心,啥都完了。帖上原碼:

makefile:

obj-m+=wwhs_bus.o

kerneldir=/opt/kernel/linux-2.6.38/linux-2.6.38.5

pwd:=$(shell pwd)

all:

make -c $(kerneldir) m=$(pwd) modules

clean: 

rm -rf *.o* *.ko* *.mod.c *.cmd *.symvers .tmp_versions .*.cmd

wwhs_public.h:

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#define wwhs_dbg(dbgbuf) printk(kern_err"wwhs:%s/n",dbgbuf);

#include "../wwhs_public.h"

#define wwhs_major 83

void wwhs_release(struct device *dev)

struct device wwhs_bus = ;

static struct device wwhs_dev = ;

static int wwhs_bus_match(struct device *dev, struct device_driver *drv)

static int wwhs_bus_probe(struct device *dev)

static struct bus_type wwhs_bus_type = ;

static struct class *wwhs_class;

static int wwhs_bus_register()

static void wwhs_bus_unregister()

static int wwhs_class_register(void)

printk(kern_err"wwhs: class create success/n");

return 0; }

static void wwhs_class_unregister()

static int wwhs_device_register(struct device *dev)

static void wwhs_device_unregister(struct device *wwhs_dev)

static struct device_driver wwhs_drv = ;

static wwhs_drv_probe(struct device *dev)

static wwhs_drv_remove(struct device *dev)

static int wwhs_driver_register(struct device_driver *wwhs_driver)

static void wwhs_driver_unregister(struct device_driver *wwhs_driver)

static int __init wwhs_init()

static void __exit wwhs_exit()

module_init(wwhs_init);

module_exit(wwhs_exit);

module_author("wwhs");

module_description("wwhs_bus test");

module_license("gpl");

上面就是四大天王小露一下臉,至此,驅動模型的分析要告一段落了。如果根著看了的朋友,我相信肯定是有所收穫的。謝謝各位。你們的支援是我前進的動力。^_^

初窺Linux 之 最全命令大講堂

博主幻想階段 1.你有沒有過開發linux專案時,命令敲到一半,腦子突然就瓦特了?2.開啟linux發行版系統時,正要查詢某個檔案,哎我去,那啥啥啥命令是啥?3.是不是遠端伺服器的時候,面對黑白介面卻什麼也敲不出?ls 展示出當前路徑 目錄 下所有的檔案 資料夾 ctrl shift 放大終端字型 ...

PLC通訊原理探秘 大講堂幕後彩蛋之擱淺

之一 plc通訊原理探秘 大講堂幕後彩蛋之序言 之二 plc通訊原理探秘 大講堂幕後彩蛋之初探 之三 plc通訊原理探秘 大講堂幕後彩蛋之失敗 之四 plc通訊原理探秘 大講堂幕後彩蛋之曙光 之五 plc通訊原理探秘 大講堂幕後彩蛋之黑暗 之六 plc通訊原理探秘 大講堂幕後彩蛋之破局 之七 plc...

十八哥公益PHP大講堂之0921流程控制語句筆記

一,幾種流程控制語句 1,順序控制語句 2,分支語句 if.else.switch 3,迴圈語句 for,while,do.while 二,什麼順序控制語句 順序控制語句就是 一行一行的往下執行 例如 echo 這是乙個順序控制語句 echo 如果執行這句 在順序控制語句中,只會一行一行的執行,不會...