|

楼主 |
发表于 2009-2-3 21:24:38
|
显示全部楼层
Post by dxqwx1;1943555
这个系统能安装linux驱动吗?
因为版权的原因,驱动模块没刻意追求和linux驱动的二进制或者api兼容,但是却提供了类似的api接口,所以linux驱动稍微修改编译后即可在这个系统运行,和linux不同的是netbas能实际运行c++编码的驱动.
驱动其实也支持freebsd/麒麟操作系统驱动架构,bsd操作系统的驱动修改后编译即可运行。
下面是一个简单的netbas驱动源代码:
hello.c
/*
** NetbasOS 可安装模块测试
** 2005-3-5
*/
#include <drv/drv.h>
static tid_t id1;
static tid_t id2;
void thread1(void *arg)
{
kprintf("thread1 run ...\n");
while (1)
{
//kprintf("thread1 run loops ...\n");
kprintf("%s sleep 2 sec...\n",arg);
thread_wait(current_thread(), 2000);
schedule();
}
}
void thread_test()
{
id = new_kernel_thread("thread1", thread1,"[thread1 args]");
kprintf("create thread %d ok\n",id);
id = new_kernel_thread("thread2", thread1,"[thread2 args]");
kprintf("create thread %d ok\n",id);
}
/*dll entry*/
int dll_main(char **argv)
{
puts("Hello world, module Runing!\n");
thread_test();
return 0;
}
int dll_destroy()
{
kprintf("dll_destroy called!\n");
thread_exit_byid(id1,NULL);
thread_exit_byid(id2,NULL);
return 0;
}
编译:
i386-elf-gcc -nostdinc -nostdlib -I/drv/include -c hello.c -o hello.sys |
|