linux 驅動程式 3/e書上的範例

我們生活周遭存在太多太多的 embedded system ,過去 embedded system 有專屬的 OS,現在 linux 也可以應用在嵌入式環境,不過本版將廣泛討論所有嵌入式系統不只 linux 喔,歡迎有這方面經驗或有興趣的朋友一同進來討論。

版主: chester

linux 驅動程式 3/e書上的範例

文章shihyu » 週五 9月 08, 2006 10:48 pm

代碼: 選擇全部
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
        printk(KERN_ALERT "Hello, world\n");
        return 0;
}
static void hello_exit(void)
{

        printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);



這是linux 驅動程式 3/e 中的範例 ....
我用gcc 直接編譯不可以編譯成功 .. 請問要編譯這是不是需要安裝什麼模組之類的???

謝謝
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

Re: linux 驅動程式 3/e書上的範例

文章shogun1234 » 週六 9月 09, 2006 2:42 am

shihyu 寫:
代碼: 選擇全部
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
        printk(KERN_ALERT "Hello, world\n");
        return 0;
}
static void hello_exit(void)
{

        printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);



這是linux 驅動程式 3/e 中的範例 ....
我用gcc 直接編譯不可以編譯成功 .. 請問要編譯這是不是需要安裝什麼模組之類的???

謝謝


Kernel modules programming is a bit different from the application programming does. You can take a look at illustration on the TLDP document - http://www.tldp.org/LDP/lkmpg/2.6/html/index.html

Below is the sample Makefile required
代碼: 選擇全部
obj-m := dev_ex.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean



have fun; )
shogun1234
可愛的小學生
可愛的小學生
 
文章: 53
註冊時間: 週三 1月 08, 2003 3:04 pm

Re: linux 驅動程式 3/e書上的範例

文章訪客 » 週六 9月 09, 2006 10:18 am

請加上 #include <linux/kernel.h> 試看看, 因為 printk 放上 kernel.h 裡宣告.

另, 如果你的 kernel 版本比書上的版本還舊, 有可能在後面的章節, 在使用 remap_pfn_range 時無法編譯(我的是 2.6.8), 較早期的 kernel 是使用 remap_page_range, 一種方式是 patch, 之前用 google 有找到過, 另一種方法是更新 kernel 版本.
訪客
 

Re: linux 驅動程式 3/e書上的範例

文章訪客 » 週六 9月 09, 2006 10:21 am

Sorry, 版本變表情符號了.
是 2. 6. 8
訪客
 

文章shihyu » 週六 9月 09, 2006 1:51 pm

代碼: 選擇全部

/usr/include/linux/nodemask.h: In function '__nodes_weight':
/usr/include/linux/nodemask.h:201: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:201: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:206: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_shift_right':
/usr/include/linux/nodemask.h:209: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'n' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:214: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_shift_left':
/usr/include/linux/nodemask.h:217: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'n' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:224: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__first_node':
/usr/include/linux/nodemask.h:226: error: syntax error before 'int'
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:230: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__next_node':
/usr/include/linux/nodemask.h:232: error: syntax error before 'int'
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:248: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__first_unset_node':
/usr/include/linux/nodemask.h:250: error: syntax error before 'int'
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:283: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodemask_scnprintf':
/usr/include/linux/nodemask.h:285: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:291: error: syntax error before 'nodemask_t'
/usr/include/linux/nodemask.h: In function '__nodemask_parse':
/usr/include/linux/nodemask.h:293: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:299: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodelist_scnprintf':
/usr/include/linux/nodemask.h:301: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:305: error: syntax error before 'nodemask_t'
/usr/include/linux/nodemask.h: In function '__nodelist_parse':
/usr/include/linux/nodemask.h:307: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:307: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:307: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:326: error: syntax error before 'node_online_map'
/usr/include/linux/nodemask.h:327: error: syntax error before 'node_possible_map'
In file included from /usr/include/asm/mmu.h:8,
                 from /usr/include/linux/sched.h:23,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/mmu.h:13: error: field 'sem' has incomplete type
In file included from /usr/include/asm-i486/cputime.h:4,
                 from /usr/include/asm/cputime.h:8,
                 from /usr/include/linux/sched.h:24,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-generic/cputime.h:23: error: syntax error before 'cputime64_t'
In file included from /usr/include/asm/fixmap.h:8,
                 from /usr/include/asm-i486/smp.h:16,
                 from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/fixmap.h:81: error: 'FIX_ACPI_PAGES' undeclared here (not in a function)
/usr/include/asm-i486/fixmap.h:96: error: syntax error before 'pgprot_t'
In file included from /usr/include/asm/mpspec.h:8,
                 from /usr/include/asm-i486/smp.h:18,
                 from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/mpspec.h:6:25: error: mach_mpspec.h: 沒有此一檔案或目錄
In file included from /usr/include/asm/mpspec.h:8,
                 from /usr/include/asm-i486/smp.h:18,
                 from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/mpspec.h:8: error: 'MAX_MP_BUSSES' undeclared here (not in a function)
/usr/include/asm-i486/mpspec.h:22: error: 'MAX_IRQ_SOURCES' undeclared here (not in a function)
/usr/include/asm-i486/mpspec.h:30: error: syntax error before 'id'
/usr/include/asm-i486/mpspec.h:31: error: syntax error before 'address'
/usr/include/asm-i486/mpspec.h:32: error: syntax error before 'id'
/usr/include/asm-i486/mpspec.h:33: error: syntax error before 'bus_irq'
/usr/include/asm-i486/mpspec.h:35: error: syntax error before 'gsi'
/usr/include/asm-i486/mpspec.h:42: error: variably modified 'mask' at file scope
In file included from /usr/include/asm/io_apic.h:8,
                 from /usr/include/asm-i486/smp.h:20,
                 from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/io_apic.h:64: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:66: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:72: error: syntax error before '}' token
/usr/include/asm-i486/io_apic.h:75: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:77: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:83: error: syntax error before '}' token
/usr/include/asm-i486/io_apic.h:86: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:88: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:92: error: syntax error before '}' token
/usr/include/asm-i486/io_apic.h:95: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:97: error: syntax error before 'u32'
/usr/include/asm-i486/io_apic.h:100: error: syntax error before '}' token
In file included from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/smp.h:37: error: syntax error before 'cpu_sibling_map'
/usr/include/asm-i486/smp.h:38: error: syntax error before 'cpu_core_map'
/usr/include/asm-i486/smp.h:49: error: syntax error before 'x86_cpu_to_apicid'
/usr/include/asm-i486/smp.h:63: error: syntax error before 'cpu_callout_map'
/usr/include/asm-i486/smp.h:64: error: syntax error before 'cpu_callin_map'
In file included from /usr/include/asm/smp.h:8,
                 from /usr/include/linux/smp.h:19,
                 from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/smp.h:78:26: error: mach_apicdef.h: 沒有此一檔案或目錄
In file included from /usr/include/linux/sched.h:26,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/linux/smp.h: In function 'on_each_cpu':
/usr/include/linux/smp.h:67: error: invalid type argument of '->'
/usr/include/linux/smp.h:70: error: invalid type argument of '->'
/usr/include/linux/smp.h:70: error: 'TIF_NEED_RESCHED' undeclared (first use in this function)
In file included from /usr/include/asm/signal.h:8,
                 from /usr/include/linux/signal.h:6,
                 from /usr/include/linux/sched.h:28,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/asm-i486/signal.h: At top level:
/usr/include/asm-i486/signal.h:30: error: conflicting types for 'sigset_t'
/usr/include/sys/select.h:38: error: previous declaration of 'sigset_t' was here
In file included from /usr/include/linux/sched.h:32,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/linux/completion.h:15: error: syntax error before 'wait_queue_head_t'
/usr/include/linux/completion.h: In function 'init_completion':
/usr/include/linux/completion.h:26: error: dereferencing pointer to incomplete type
/usr/include/linux/completion.h:27: error: dereferencing pointer to incomplete type
In file included from /usr/include/linux/sched.h:33,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/linux/pid.h: At top level:
/usr/include/linux/pid.h:17: error: field 'pid_chain' has incomplete type
/usr/include/linux/pid.h:19: error: field 'pid_list' has incomplete type
In file included from /usr/include/linux/sched.h:36,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/linux/seccomp.h: In function 'secure_computing':
/usr/include/linux/seccomp.h:18: error: 'TIF_SECCOMP' undeclared (first use in this function)
/usr/include/linux/seccomp.h: In function 'has_secure_computing':
/usr/include/linux/seccomp.h:24: error: 'TIF_SECCOMP' undeclared (first use in this function)
In file included from /usr/include/linux/sched.h:104,
                 from /usr/include/linux/module.h:10,
                 from ldd.c:4:
/usr/include/linux/timer.h: At top level:
/usr/include/linux/timer.h:12: error: field 'entry' has incomplete type
In file included from ldd.c:4:
/usr/include/linux/module.h:50: error: field 'attr' has incomplete type
/usr/include/linux/module.h:61: error: field 'kobj' has incomplete type
/usr/include/linux/module.h:226: error: field 'grp' has incomplete type
/usr/include/linux/module.h:237: error: field 'list' has incomplete type
ldd.c: In function 'hello_init':
ldd.c:9: error: 'KERN_ALERT' undeclared (first use in this function)
ldd.c:9: error: syntax error before string constant
ldd.c: In function 'hello_exit':
ldd.c:15: error: 'KERN_ALERT' undeclared (first use in this function)
ldd.c:15: error: syntax error before string constant



加上#include <linux/kernel.h> 還是跟之前一樣出現一堆錯誤 , 因為我不太懂驅動程式是怎樣 , 錯誤訊息我也搞不清楚??

知道的朋友可以教一下是哪邊有問題??

謝謝
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

文章訪客 » 週六 9月 09, 2006 3:17 pm

是用 make.

你可參考 shogun1234 回覆的內容, 在你的原始碼同一目錄下, 建立 Makefile, 然後用 make 編譯.

在後面的 Compiling Modules 有提到喔.
訪客
 

文章shihyu » 週六 9月 09, 2006 8:04 pm

恩~~

我把 書上程式碼 vim dev_ex.c //命名 dev_ex.c 這樣對嗎??
因為shogun1234 中的 make 是dev_ex.o 所以我命名dev_ex.c

下面是我執行步驟 及錯誤訊息

debian:~# vim dev_ex.c
debian:~# vim makefile
debian:~# make all

make -C /lib/modules/2.6.8-2-386/build M=/root modules
make: *** /lib/modules/2.6.8-2-386/build: 沒有此一檔案或目錄. Stop.
make: *** [all] Error 2
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

文章訪客 » 週六 9月 09, 2006 8:31 pm

確定一下是否有 build 這個檔案.
它是連結到你的 kernel 原始碼所在目錄, 如果沒有的話, 你需要安裝對應於目前使用的 kernel 版本的原始碼, 如果是以 deb 方式安裝, 沒記錯的話, 壓縮檔就放在 /usr/src, 解壓縮放在 /usr/src 目錄下, 比如說是 /usr/src/kernel-source-2.6.8, 你可以在 -C 參數後直接指向 /usr/src/kernel-source-2.6.8, 一般會建議建立一個檔名 linux 連結到解壓縮後的那個目錄, -C 參數後指向 /usr/src/linux 即可.
訪客
 

文章shihyu » 週六 9月 09, 2006 10:25 pm

請問哪邊可以下載到原始碼???
還有kernel 版本的原始碼是要下載我系統版本一樣??
我看了 我 /usr/src/ 裡面是空的

謝謝
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

文章shihyu » 週六 9月 09, 2006 10:46 pm

我下載kernel-source-2.6.8 後解壓縮
把檔名改成 資料夾linux

obj-m := dev_ex.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean


改成

obj-m := dev_ex.o
all:
make -C /usr/src/linux

clean:
make -C /usr/src/linux


-----------------------------------------------------------
又出現下面錯誤


代碼: 選擇全部

make -C /usr/src/linux
make[1]: Entering directory `/usr/src/linux'
Makefile:415: .config: 沒有此一檔案或目錄
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  SYMLINK include/asm -> include/asm-i386
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/split-include
  HOSTCC  scripts/basic/docproc
  SHIPPED scripts/kconfig/zconf.tab.h
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/mconf.o
scripts/kconfig/mconf.c:91: error: static declaration of 'current_menu' follows  non-static declaration
scripts/kconfig/lkc.h:63: error: previous declaration of 'current_menu' was here
make[3]: *** [scripts/kconfig/mconf.o] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** [include/linux/autoconf.h] Error 2
make[1]: Leaving directory `/usr/src/linux'
make: *** [all] Error 2





下面是書上說法

你可以用 insmod 和 rmmod 工具來測試這個模區塊. 注意只有超級用戶(root)可以加載和卸載模區塊.

% make
make[1]: Entering directory `/usr/src/linux-2.6.10'
CC [M] /home/ldd3/src/misc-modules/hello.o
Building modules, stage 2.
MODPOST
CC /home/ldd3/src/misc-modules/hello.mod.o
LD [M] /home/ldd3/src/misc-modules/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.10'
% su
root# insmod ./hello.ko
Hello, world
root# rmmod hello
Goodbye cruel world
root#
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

文章訪客 » 週日 9月 10, 2006 9:59 am

剛下載解壓縮後是沒有 .config 這個檔案的, 在 /usr/src/linux 目錄下, 執行 make oldconfig 或 make xconfig套用目前的 config, 在 /boot 下可找到目前 kernel 使用的 config.
若用 make xconfig 須事先安裝相關的套件, 這部份可查詢 build kernel 相關文章.

M=$(shell pwd) modules 還是要加喔.
訪客
 

文章shihyu » 週日 9月 10, 2006 1:57 pm

我用make menuconfig ... 但裡面選項很多我用預設的
是不是要編譯書上驅程式程式碼前要先 "核心的編譯與安裝"??

是不是使用下面三個指令進行核心編譯

[root@linux linux-2.6.14.2]# make clean
# 將以前曾經進行過的 *.o 檔案刪除掉,這樣比較不會產生新舊版本的誤差!
[root@linux linux-2.6.14.2]# make bzImage
# 製作出核心檔案!這個重要!過程很長啊!而且那個是大寫的 I 喔!
[root@linux linux-2.6.14.2]# make modules
# 製作出模組相關的檔案!


之後就可以編譯書上驅動程式代碼??

obj-m := dev_ex.o

all:
make -C /usr/src/linux M=$(PWD) modules

clean:
make -C /usr/src/linux M=$(PWD) clean

變成這樣就可以make all 嗎??

謝謝
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am

文章訪客 » 週日 9月 10, 2006 4:21 pm

若你使用的是 debian 官方 kernel 版本, 僅需下載相對應之 kernel 版本的原始碼, 引用 /boot 目錄下的 config 檔案存為 .config即可, 不需另行編譯 kernel.
訪客
 

文章訪客 » 週一 9月 11, 2006 3:35 pm

不好意思, 還有另一種不需下載原始碼的方法, 直接安裝目前使用的 kernel 所對應的 kernel-headers.

make -C /lib/modules/`uname -r`/build M=`pwd` modules
訪客
 

文章shihyu » 週一 9月 11, 2006 6:45 pm

我剛剛編譯出的訊息

代碼: 選擇全部
debian:~# make all
make -C /usr/src/linux M=/root modules
make[1]: Entering directory `/usr/src/linux'

  WARNING: Symbol version dump /usr/src/linux/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST
make[1]: Leaving directory `/usr/src/linux'



有多出這兩檔案 Module.symvers & .tmp_versions
這樣算是編譯成功嗎??

===================================

我改用下面方式去編譯這方法是我google 搜尋到
請問我用 gcc -D__KERNEL__ -DMODULE hello.c

會出現下面一常串錯誤訊息 , 是我參數下錯嗎??還是少下??

代碼: 選擇全部
 from /usr/include/linux/rcupdate.h:41,
                 from /usr/include/linux/pid.h:4,
                 from /usr/include/linux/sched.h:33,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/slab.h:61: error: syntax error before 'size_t'
/usr/include/linux/slab.h:62: error: 'kmem_cache_create' declared as function returning a function
/usr/include/linux/slab.h:63: error: syntax error before 'void'
/usr/include/linux/slab.h:71: error: syntax error before 'size'
/usr/include/linux/slab.h:75: error: syntax error before 'size_t'
/usr/include/linux/slab.h:78: error: syntax error before '}' token
/usr/include/linux/slab.h:79: error: array type has incomplete element type
/usr/include/linux/slab.h:81: error: syntax error before 'gfp_t'
/usr/include/linux/slab.h:90: error: syntax error before 'size'
/usr/include/linux/slab.h: In function 'kmalloc':
/usr/include/linux/slab.h:92: error: 'size' undeclared (first use in this function)
In file included from /usr/include/linux/percpu.h:4,
                 from /usr/include/linux/rcupdate.h:41,
                 from /usr/include/linux/pid.h:4,
                 from /usr/include/linux/sched.h:33,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/slab.h:106: error: 'flags' undeclared (first use in this function)
/usr/include/linux/slab.h: At top level:
/usr/include/linux/slab.h:113: error: syntax error before 'gfp_t'
/usr/include/linux/slab.h:115: error: syntax error before 'size'
/usr/include/linux/slab.h: In function 'kzalloc':
/usr/include/linux/slab.h:117: error: 'size' undeclared (first use in this function)
In file included from /usr/include/linux/percpu.h:4,
                 from /usr/include/linux/rcupdate.h:41,
                 from /usr/include/linux/pid.h:4,
                 from /usr/include/linux/sched.h:33,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/slab.h:131: error: 'flags' undeclared (first use in this function)
/usr/include/linux/slab.h: At top level:
/usr/include/linux/slab.h:144: error: syntax error before 'n'
/usr/include/linux/slab.h: In function 'kcalloc':
/usr/include/linux/slab.h:146: error: 'n' undeclared (first use in this function)
/usr/include/linux/slab.h:146: error: 'size' undeclared (first use in this function)
/usr/include/linux/slab.h:148: error: 'flags' undeclared (first use in this function)
/usr/include/linux/slab.h: At top level:
/usr/include/linux/slab.h:163: error: syntax error before 'size'
/usr/include/linux/slab.h: In function 'kmalloc_node':
/usr/include/linux/slab.h:165: error: 'size' undeclared (first use in this function)
/usr/include/linux/slab.h:165: error: 'flags' undeclared (first use in this function)
In file included from /usr/include/linux/rcupdate.h:41,
                 from /usr/include/linux/pid.h:4,
                 from /usr/include/linux/sched.h:33,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/percpu.h: At top level:
/usr/include/linux/percpu.h:35: error: syntax error before 'size'
In file included from /usr/include/linux/sched.h:108,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/resource.h:22: error: field 'ru_utime' has incomplete type
/usr/include/linux/resource.h:23: error: field 'ru_stime' has incomplete type
In file included from /usr/include/linux/hrtimer.h:19,
                 from /usr/include/linux/sched.h:110,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/ktime.h:202: error: parameter 1 ('ts') has incomplete type
/usr/include/linux/ktime.h:215: error: parameter 1 ('tv') has incomplete type
/usr/include/linux/ktime.h:229: error: return type is an incomplete type
/usr/include/linux/ktime.h: In function 'ktime_to_timespec':
/usr/include/linux/ktime.h:230: error: unknown field 'tv_sec' specified in initializer
/usr/include/linux/ktime.h:230: error: 'time_t' undeclared (first use in this function)
/usr/include/linux/ktime.h:230: error: syntax error before 'kt'
/usr/include/linux/ktime.h:231: error: unknown field 'tv_nsec' specified in initializer
/usr/include/linux/ktime.h: At top level:
/usr/include/linux/ktime.h:242: error: return type is an incomplete type
/usr/include/linux/ktime.h: In function 'ktime_to_timeval':
/usr/include/linux/ktime.h:244: error: unknown field 'tv_sec' specified in initializer
/usr/include/linux/ktime.h:244: error: 'time_t' undeclared (first use in this function)
/usr/include/linux/ktime.h:244: error: syntax error before 'kt'
/usr/include/linux/ktime.h:245: error: unknown field 'tv_usec' specified in initializer
/usr/include/linux/ktime.h:245: error: 'suseconds_t' undeclared (first use in this function)
In file included from /usr/include/linux/sched.h:110,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/hrtimer.h: At top level:
/usr/include/linux/hrtimer.h:88: error: syntax error before 'clockid_t'
/usr/include/linux/hrtimer.h:97: error: syntax error before '}' token
/usr/include/linux/hrtimer.h:109: error: syntax error before 'clockid_t'
/usr/include/linux/hrtimer.h:122: error: syntax error before 'which_clock'
/usr/include/linux/hrtimer.h:141: error: syntax error before 'clockid'
In file included from /usr/include/linux/sched.h:245,
                 from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/aio.h:94: error: syntax error before 'ssize_t'
/usr/include/linux/aio.h:104: error: syntax error before 'ki_pos'
/usr/include/linux/aio.h:109: error: syntax error before 'ki_nbytes'
/usr/include/linux/aio.h:111: error: syntax error before 'ki_left'
/usr/include/linux/aio.h:118: error: syntax error before '}' token
/usr/include/linux/aio.h:199: error: syntax error before 'wait_on_sync_kiocb'
/usr/include/linux/aio.h: In function 'list_kiocb':
/usr/include/linux/aio.h:243: error: dereferencing pointer to incomplete type
/usr/include/linux/aio.h:243: error: invalid use of undefined type 'struct kiocb'
In file included from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:407: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:409: error: syntax error before 'session'
/usr/include/linux/sched.h:452: error: syntax error before '}' token
/usr/include/linux/sched.h:512: error: syntax error before 'uid_t'
/usr/include/linux/sched.h:651: error: syntax error before 'gid_t'
/usr/include/linux/sched.h:653: error: syntax error before '*' token
/usr/include/linux/sched.h:654: error: syntax error before '}' token
/usr/include/linux/sched.h:674: error: syntax error before 'gid_t'
/usr/include/linux/sched.h:746: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:783: error: syntax error before 'uid'
/usr/include/linux/sched.h:784: error: syntax error before 'gid'
/usr/include/linux/sched.h:787: error: syntax error before ':' token
/usr/include/linux/sched.h:820: error: syntax error before 'sas_ss_size'
/usr/include/linux/sched.h:854: error: syntax error before '*' token
/usr/include/linux/sched.h:891: error: syntax error before '}' token
/usr/include/linux/sched.h:893: error: syntax error before 'process_group'
/usr/include/linux/sched.h: In function 'process_group':
/usr/include/linux/sched.h:895: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'pid_alive':
/usr/include/linux/sched.h:908: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'put_task_struct':
/usr/include/linux/sched.h:918: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1045: error: syntax error before 'session'
/usr/include/linux/sched.h:1046: error: syntax error before 'session'
/usr/include/linux/sched.h: In function 'get_uid':
/usr/include/linux/sched.h:1052: error: dereferencing pointer to incomplete type
In file included from /usr/include/linux/module.h:10,
                 from hello.c:5:
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1080: error: syntax error before 'siginfo_t'
/usr/include/linux/sched.h:1082: error: syntax error before 'siginfo_t'
/usr/include/linux/sched.h: In function 'dequeue_signal_lock':
/usr/include/linux/sched.h:1087: error: 'tsk' undeclared (first use in this function)
/usr/include/linux/sched.h:1088: error: 'mask' undeclared (first use in this function)
/usr/include/linux/sched.h:1088: error: 'info' undeclared (first use in this function)
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1102: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:1103: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:1104: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:1105: error: syntax error before 'pid_t'
/usr/include/linux/sched.h:1111: error: syntax error before 'int'
/usr/include/linux/sched.h:1112: error: syntax error before 'int'
/usr/include/linux/sched.h:1118: error: syntax error before '*' token
/usr/include/linux/sched.h: In function 'on_sig_stack':
/usr/include/linux/sched.h:1134: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1134: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'sas_ss_flags':
/usr/include/linux/sched.h:1139: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'next_thread':
/usr/include/linux/sched.h:1215: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1215: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1215: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1215: error: invalid use of incomplete typedef 'task_t'
/usr/include/linux/sched.h: In function 'thread_group_empty':
/usr/include/linux/sched.h:1221: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'task_lock':
/usr/include/linux/sched.h:1238: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'task_unlock':
/usr/include/linux/sched.h:1243: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'unlock_task_sighand':
/usr/include/linux/sched.h:1252: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'setup_thread_stack':
/usr/include/linux/sched.h:1262: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1262: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1263: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'end_of_stack':
/usr/include/linux/sched.h:1268: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'set_tsk_thread_flag':
/usr/include/linux/sched.h:1278: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'clear_tsk_thread_flag':
/usr/include/linux/sched.h:1283: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_and_set_tsk_thread_flag':
/usr/include/linux/sched.h:1288: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_and_clear_tsk_thread_flag':
/usr/include/linux/sched.h:1293: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_tsk_thread_flag':
/usr/include/linux/sched.h:1298: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'task_cpu':
/usr/include/linux/sched.h:1369: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'set_task_cpu':
/usr/include/linux/sched.h:1374: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1401: error: syntax error before 'pid'
/usr/include/linux/sched.h:1402: error: syntax error before 'pid'
/usr/include/linux/sched.h: In function 'frozen':
/usr/include/linux/sched.h:1412: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'freezing':
/usr/include/linux/sched.h:1420: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'freeze':
/usr/include/linux/sched.h:1429: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'thaw_process':
/usr/include/linux/sched.h:1438: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'frozen_process':
/usr/include/linux/sched.h:1450: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:1450: error: dereferencing pointer to incomplete type
In file included from /usr/include/linux/module.h:13,
                 from hello.c:5:
/usr/include/linux/stat.h: At top level:
/usr/include/linux/stat.h:61: error: syntax error before 'dev_t'
/usr/include/linux/stat.h:62: error: conflicting types for 'mode'
/usr/include/linux/ipc.h:66: error: previous declaration of 'mode' was here
/usr/include/linux/stat.h:64: error: syntax error before 'uid'
/usr/include/linux/stat.h:65: error: syntax error before 'gid'
/usr/include/linux/stat.h:66: error: syntax error before 'rdev'
/usr/include/linux/stat.h:67: error: syntax error before 'size'
/usr/include/linux/stat.h:72: error: conflicting types for 'blocks'
/usr/include/linux/sched.h:653: error: previous declaration of 'blocks' was here
/usr/include/linux/stat.h:73: error: syntax error before '}' token
In file included from /usr/include/linux/kobject.h:22,
                 from /usr/include/linux/module.h:19,
                 from hello.c:5:
/usr/include/linux/sysfs.h:21: error: syntax error before 'mode_t'
/usr/include/linux/sysfs.h:54: error: field 'attr' has incomplete type
/usr/include/linux/sysfs.h:55: error: syntax error before 'size_t'
/usr/include/linux/sysfs.h:57: error: syntax error before '*' token
/usr/include/linux/sysfs.h:57: error: syntax error before 'loff_t'
/usr/include/linux/sysfs.h:57: error: 'ssize_t' declared as function returning a function
/usr/include/linux/sysfs.h:58: error: syntax error before '*' token
/usr/include/linux/sysfs.h:58: error: syntax error before 'loff_t'
/usr/include/linux/sysfs.h:58: error: 'ssize_t' declared as function returning a function
/usr/include/linux/sysfs.h:61: error: syntax error before '}' token
/usr/include/linux/sysfs.h:64: error: syntax error before 'ssize_t'
/usr/include/linux/sysfs.h:65: error: syntax error before '*' token
/usr/include/linux/sysfs.h:65: error: syntax error before 'size_t'
/usr/include/linux/sysfs.h:65: error: 'ssize_t' declared as function returning a function
/usr/include/linux/sysfs.h:105: error: syntax error before 'mode_t'
In file included from /usr/include/linux/module.h:19,
                 from hello.c:5:
/usr/include/linux/kobject.h:254: error: field 'attr' has incomplete type
/usr/include/linux/kobject.h:255: error: syntax error before 'ssize_t'
/usr/include/linux/kobject.h:256: error: syntax error before '*' token
/usr/include/linux/kobject.h:256: error: syntax error before 'size_t'
/usr/include/linux/kobject.h:256: error: 'ssize_t' declared as function returning a function
In file included from hello.c:5:
/usr/include/linux/module.h:50: error: field 'attr' has incomplete type
/usr/include/linux/module.h:51: error: syntax error before 'ssize_t'
/usr/include/linux/module.h:52: error: syntax error before '*' token
/usr/include/linux/module.h:53: error: syntax error before 'size_t'
/usr/include/linux/module.h:53: error: 'ssize_t' declared as function returning a function
/usr/include/linux/module.h:57: error: syntax error before '}' token
/usr/include/linux/module.h:223: error: field 'mattr' has incomplete type




謝謝
shihyu
懵懂的國中生
懵懂的國中生
 
文章: 184
註冊時間: 週四 11月 03, 2005 11:51 am


回到 embedded system

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron