原创 CONFIG_KALLSYMS_ALL

內核配置 在2.6內核中,爲了更好地調試內核,引入了kallsyms。kallsyms抽取了內核用到的所有函數地址(全局的、靜態的)和非棧數據變量地址,生成一個數據塊,作爲只讀數據鏈接進kernel image,相當於內核中存了一

原创 結構體的最後定義一個大小爲0 的數組

有很多結構體的最後都定義了一個大小爲0 的數組,如drivers/oprofile/cpu_buffer.h中 struct op_sample { unsigned long eip; unsig

原创 linux自旋鎖spin_lock

spin_lock與spin_lock_irq與spin_lock_irqsave spin_lock與spin_lock_irq兩者差別在於是否調用local_irq_disable()函數, 即是否禁止本地中斷。 spin_l

原创 PCI子系統(一) - 協議

協議來自PCI Express Base Specification Revision 3.0 7.1 PCI Express Configuration Mechanisms PCI Compatible Configura

原创 DMA(四) - DMA_API_DEBUG

DMA_API_DEBUG 爲了debug驅動程序及發現使用DMA-API時的bug,檢測代碼可以編譯到kernel中,它們可以告訴開發 者那些違規行爲。如果你的體系結構支持,你可以選擇編譯選項“Enable debugging

原创 鏈接腳本

這樣就把foor(), bar()這兩個函數給放在了最終elf文件裏的.out_name這個section。 __attribute__((section(".sec_name"))) void foo(void) __attr

原创 內核current指針

通過current指針獲取當前進程信息 current其實一個struct task_struct指針,指向當前進程 struct task_struct *task又是struct thread_info的一個成員變量。 thr

原创 字節對齊

lk/include/compiler.h #define __ALIGNED(x) __attribute__((aligned(x))) #define __PACKED __attribute__((packed)) __

原创 systemctl

systemctl是一個systemd工具,Systemd是一個系統管理守護進程、工具和庫的集合 systemd作爲父守護進程運行(PID = 1) systemd與init進程的區別 它與init進程的主要差別如下。 (1)默認

原创 UAC

Descriptors Bus 003 Device 019: ID 0d8c:0132 C-Media Electronics, Inc. Device Descriptor: bLength

原创 MFC動態鏈接庫創建與調用

在MFC中生成DLL 在頭文件中 extern "C" _declspec(dllexport) int Min1(int x,int y,int z); 在實現文件中 /*找出x,y,z中的最小整數*/ extern "C"

原创 insmod/lsmod/modinfo/modprobe/depmod工具使用

insmod lsmod modinfo insmod一個模塊的時候出現問題: Invalid module format 通過modinfo查看模塊信息,發現模塊的vermagic與內核的版本是不匹配的。 第一種解決辦法是使

原创 藍牙

藍牙 藍牙分爲經典藍牙(class bluetooth)和低功耗藍牙(bluetooth low energy) 經典藍牙的缺點是比較耗電。後來,諾基亞發明了一種可以降低功耗的藍牙通信方式。2010年出臺的藍牙4.0把這種通信方式規範

原创 IEC60958和IEC61937

BMC編碼 IEC 60958在傳輸數據時使用雙相符號編碼(Biphase Mark Code),簡稱BMC,屬於一種相位調製(phase modulation)的編碼方法,是將時鐘訊號和數據訊號混合在一起傳輸的編碼方法。下圖是BMC

原创 smbus與i2c區別

The I²C bus and the smbus are popular 2-wire buses that are essentially compatible with each other. 運行頻率 先以運作頻率來說,I2C