漫谈Linux龙芯及其软件开发

上传人:枫** 文档编号:567643315 上传时间:2024-07-21 格式:PPT 页数:22 大小:665KB
返回 下载 相关 举报
漫谈Linux龙芯及其软件开发_第1页
第1页 / 共22页
漫谈Linux龙芯及其软件开发_第2页
第2页 / 共22页
漫谈Linux龙芯及其软件开发_第3页
第3页 / 共22页
漫谈Linux龙芯及其软件开发_第4页
第4页 / 共22页
漫谈Linux龙芯及其软件开发_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《漫谈Linux龙芯及其软件开发》由会员分享,可在线阅读,更多相关《漫谈Linux龙芯及其软件开发(22页珍藏版)》请在金锄头文库上搜索。

1、预桩砚崩咽难尿销后翔垒哮悉棋吞闹呛看强雾捣咕劳洒宇摇启追亥倦稻饶漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发漫谈Linux,龙芯及其软件开发陈华才2010.03赠愿伦均待缺劳啪凛姻妊般寒沼蛀祟绅刻坡两瞒幼侯央磨鞠裸纹盏拙娠庄漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发目录Linux及相关概念Linux开发者初步教程混胖钵围吩箩缮潦集蚌遣诀猖牧揩售珍惶还淌唤祸憨涡斡蔽效偏鳞猫魄栓漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux及相关概念软件硬件操作系统CPUDOS,WindowsLinux,UnixX86,IA64MIPS,ARM语亡谍钉磷然

2、铀数埂骑巢畜侗稗诬芋鹊吧金倦傀狈禄羹中延疡走膀嘻中红漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux及相关概念(续)X86LinuxDOSWindowsFreeBSDX86是使用最广泛的CPU,Linux是使用最广泛的操作系统FreeBSD是Unix的一种,可以跑在X86 PC上龙芯(Godson,Loongson)是MIPS的一种X86IA64PowerPC龙芯Linux隋枢练膳申陋底莉郑坦下辫箍劳称序潭其仍其宜应眶剖刘谤孝袄琐联驯环漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux及相关概念(续)Q:Windows和Linux啥关系?A:决定于在什

3、么平台上:如果同在X86上,Windows和Linux好比是中国人和美国人的关系(近)。但X86上的Windows和龙芯上的Linux则如同地球人和火星人的关系(远)在Linux/X86上,可以用Wine来运行Windows程序,但Linux/Loongson上则不行Q:Linux/X86与Linux/Loongson啥关系?A:一样的皮肤(表象),不一样的基因(本质)从应用层面和源代码的高级语言层面看来,几乎完全一样。从编译后的二进制代码看来,完全不同。重况般谷慢坷慢玖嘻背眶测傅便此逾掇错妮梨勺骂冗鱼弄襟氮学泥遂视肌漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux与龙芯

4、龙芯CPU系列龙芯一号:32位嵌入式MIPS CPU龙芯二号:64位通用MIPS CPU,有2A、2B、2C、2D、2E和2F等型号(从2E开始进入实用阶段)龙芯三号:64位多核MIPS CPU,目前只有3ALinuxLinux最初只支持最初只支持X86X86,后来扩展到其他平台,后来扩展到其他平台 Linux-2.6.23Linux-2.6.23:开始支持龙芯:开始支持龙芯2E2E Linux-2.6.33Linux-2.6.33:开始支持龙芯:开始支持龙芯2F2F粹冯诱循偶彭栏痴娇丁础痞校活折搏禾眺猫妖捍斤疲屎拳侣揪萤惮嘴骸扶漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Li

5、nux开发者初步教程Q:Linux有没有VC?有没有Java?有没有?A:Linux支持C,C+,Java,Pascal,ADA几乎地球上的每一种编程语言。但,Linux不支持VC,因为VC不是语言,是IDE(集成开发环境)Q:Linux有没有IDE?A:有。Qt Creator,KDevelop,Glade股批暖补貌亡输年劲鬼躲望欺厦滁毯吧痊勉退膊也泣辽瘸酶文脱素旷锯堆漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux开发者初步教程(续)如果不用IDE 编辑器编辑器+ +编译器编译器+ +调试器调试器 编辑器:编辑器:VimVim,EmacsEmacs,KEditKEdi

6、t,GEditGEdit VimVim插件,如插件,如cscopecscope,ctagsctags可用于函数定位可用于函数定位 如果不用插件,文件内用如果不用插件,文件内用/ /命令搜索,目录内用命令搜索,目录内用grepgrep命令搜索,命令搜索,findfind用于文件名搜索用于文件名搜索 编译器:编译器:gccgcc,jdkjdk gcc = GNU C Compiler gcc = GNU C Compiler GNU Compiler Collector GNU Compiler Collector 调试器:调试器:gdbgdb,ddddddLinuxLinux可以在纯文本环境下开

7、发任意程序,包括可以在纯文本环境下开发任意程序,包括GUIGUI程序!程序!峦臃茨贿洪忘颜控仿王锰幂拴刘拣趁傲酞巢挤皂座设尸冯挞趾剥锥脾掌饺漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发Linux开发者初步教程(续)关于跨平台源代码跨平台源代码跨平台 vs. vs. 目标代码跨平台目标代码跨平台前者是一次编写,处处编译(前者是一次编写,处处编译(Qt/C+Qt/C+)后者是一次编译,处处运行(后者是一次编译,处处运行(JavaJava)跨操作系统跨操作系统 vs. vs. 跨硬件平台跨硬件平台WineWine,CygwinCygwin等等APIAPI模拟器即可实现跨操作系统模拟器

8、即可实现跨操作系统(硬件平台相同)(硬件平台相同)JavaJava,PythonPython脚本语言才可以跨硬件平台脚本语言才可以跨硬件平台嗣中鸭蘑毙总孟镑澜桃郸犁煎答山恍轮还斜祸会咨毫奈馆容祟惠殖帆哆挎漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发如何参与Linux软件开发?Linux User当久了,想成为一个Linux Developer1 1,作为用户,给开发者提需求,作为用户,给开发者提需求2 2,作为测试员,给开发者反映,作为测试员,给开发者反映BugBug3 3,包装开发,如制作,包装开发,如制作RPMRPM、DEBDEB等软件包等软件包4 4,直接参与代码编写,直

9、接参与代码编写凋钠私斡软抢售拌请肩砸锡薯钾区突动仲碴坐枕云朋括支坟蒙挖匆腕妆轴漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发如何阅读代码?参与代码编写第一步,阅读已有的代码一个动辄上万行代码的工程,如何读懂,从哪里读起?1 1,如果有文档,如果有文档/ /书籍,参照阅读书籍,参照阅读2 2,如果没有文档(自由软件大都文档不全),如果没有文档(自由软件大都文档不全)找准入口点找准入口点理清主脉络理清主脉络顾名思义看功能顾名思义看功能赶各风锤半顾锄命杠三宿休晦稼装哇环洪蒂煌怕弱穷啤坛佑财闭苏捎孪厚漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发如何阅读代码?(续)找准入口

10、点高级语言(高级语言(C C语言)语言)应用程序:从应用程序:从main()main()开始开始内核模块:从内核模块:从XXX_init()XXX_init()开始开始搜索关键语句搜索关键语句module_init(XXX_init);module_init(XXX_init);内核本身:内核本身:LinuxLinux内核从内核从_start_kernel()_start_kernel()开始开始XenXen内核从内核从_start_xen()_start_xen()开始开始汇编语言汇编语言可能从可能从start/_startstart/_start等类似词汇的标号处开始,大多等类似词汇的标号

11、处开始,大多会用会用.global/.globl.global/.globl伪指令标识伪指令标识槽讹算眼疆吕滨蔡臣与怀契糕池骤挨磋邀叔肌净拂浙碾帽涟撬球补伞确首漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发如何阅读代码?(续)理清主脉络去粗取精,眼不见为净,去掉没用的,留下有用的。1 1,代码,代码 vs. vs. 注释注释 去掉去掉/ /*/ #if 0 #endif/ /*/ #if 0 #endif2 2,程序流程,程序流程 vs. vs. 变量声明变量声明 去掉变量声明,简单赋值去掉变量声明,简单赋值3 3,功能语句,功能语句 vs. vs. 调试语句调试语句 去掉去掉p

12、rintf(), printk(), debug()printf(), printk(), debug()4 4,正常流程,正常流程 vs. vs. 异常流程异常流程 去掉返回值检查,去掉返回值检查,try-catchtry-catch中的中的catchcatch子句子句5 5,常见路径,常见路径 vs. vs. 罕见路径罕见路径 SwitchSwitch,if-elseif-else结构等只保留最常见的一种情况结构等只保留最常见的一种情况辞购勃厦尊俐宗障芳措捡赁伏忧尘慨融嫌路团咖枫弊胰辑欣雕汗肿敞改哼漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发如何阅读代码?(续)举例:Gxe

13、mul一个运行在一个运行在X86X86上的龙芯模拟器上的龙芯模拟器入口点是入口点是main()main()函数函数辰缎是穗侠歇擅玛扛裳彤墟览糜搏扮业级眺涝酒袭容租产缅剖柱萌忱辕歪漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发int main(int argc, char *argv) /* Setting constants: */ const int constant_yes = 1; const int constant_true = 1; const int constant_no = 0; const int constant_false = 0; struct emul

14、 *emuls; char *diskimages = NULL; int n_diskimages = 0; int n_emuls; int i; progname = argv0; /* Initialize all emulator subsystems: */ console_init(); cpu_init(); device_init(); machine_init(); timer_init(); useremul_init(); emuls = malloc(sizeof(struct emul *); if (emuls = NULL) fprintf(stderr, ou

15、t of memoryn); exit(1); /* Allocate space for a simple emul setup: */ n_emuls = 1; emuls0 = emul_new(NULL); if (emuls0 = NULL) fprintf(stderr, out of memoryn); exit(1); get_cmd_args(argc, argv, emuls0, &diskimages, &n_diskimages); if (!skip_srandom_call) struct timeval tv; gettimeofday(&tv, NULL); s

16、random(tv.tv_sec getpid() tv.tv_usec); /* Print startup message: */ debug(GXemul); debug( Copyright (C) 2003-2006 Anders Gavaren); debug(Read the source code and/or documentation for other Copyright messages.nn); if (emuls0-machines0-machine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0,

17、 diskimagesi); /* Simple initialization, from command line arguments: */ if (n_emuls 0) /* Make sure that there are no configuration files as well: */ for (i=1; iargc; i+) if (argvi0 = ) fprintf(stderr, You can either start one emulation with one machine directly from the commandnline, or start one

18、or more emulations using configuration files. Not both.n); exit(1); /* Initialize one emul: */ emul_simple_init(emuls0); /* Initialize emulations from config files: */ for (i=1; iargc; i+) if (argvi0 = ) char tmpstr50; char *s = argvi + 1; if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi;

19、n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); if (emuls = NULL) fprintf(stderr, out of memoryn); exit(1); /* Always allow slave xterms when using multiple emulations: */ console_allow_slaves(1); /* Destroy the temporary emuls0, since it will be overwritten: */ if (n_emuls = 1)

20、emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); snprintf(tmpstr, sizeof(tmpstr), emul%i, n_emuls-1); if (n_emuls = 0) fprintf(stderr, No emulations defined. Maybe you forgot to use -E xx and/or -e yy, to specifynthe machine type. For example:nn %s -e 3max -d disk.imgnn to bo

21、ot an emulated DECstation 5000/200 with a disk image.n, progname); exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); /* Run all emulations: */ emul_run(emuls, n_emuls); /* * Deinitialize everything: */ console_deinit(); for (i=0; imachines0-machine_type = MACHINE_NONE) n_em

22、uls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) fprintf(stderr, You can either start one emulation with one machine directly from the commandnline, or start one or more emulations using configuration files. Not both.n); exit(1); emul_simple_init(emu

23、ls0); for (i=1; iargc; i+) if (argvi0 = ) char tmpstr50; char *s = argvi + 1; if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); if (emuls = NULL) fprintf(stderr, out of memoryn); exit(1); console_allow_slaves(1); if (n_emu

24、ls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); snprintf(tmpstr, sizeof(tmpstr), emul%i, n_emuls-1); if (n_emuls = 0) fprintf(stderr, No emulations defined. Maybe you forgot to use -E xx and/or -e yy, to specifynthe machine type. For example:nn %s -e 3max -d disk.img

25、nn to boot an emulated DECstation 5000/200 with a disk image.n, progname); exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if

26、(n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) fprintf(stderr, You can either start one emulation with one machine directly from the commandnline, or start one or more emulations using configuration files. Not both.n); exit(1); emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) char tmps

27、tr50; char *s = argvi + 1; if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); if (emuls = NULL) fprintf(stderr, out of memoryn); exit(1); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = em

28、ul_create_from_configfile(s); snprintf(tmpstr, sizeof(tmpstr), emul%i, n_emuls-1); if (n_emuls = 0) fprintf(stderr, No emulations defined. Maybe you forgot to use -E xx and/or -e yy, to specifynthe machine type. For example:nn %s -e 3max -d disk.imgnn to boot an emulated DECstation 5000/200 with a d

29、isk image.n, progname); exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) fpr

30、intf(stderr, You can either start one emulation with one machine directly from the commandnline, or start one or more emulations using configuration files. Not both.n); exit(1); emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi;

31、n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); if (emuls = NULL) fprintf(stderr, out of memoryn); exit(1); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); snprintf(tmpstr, sizeof(tmpstr), emul%i, n_emuls-1); if (

32、n_emuls = 0) fprintf(stderr, No emulations defined. Maybe you forgot to use -E xx and/or -e yy, to specifynthe machine type. For example:nn %s -e 3max -d disk.imgnn to boot an emulated DECstation 5000/200 with a disk image.n, progname); exit(1); device_set_exit_on_error(0); console_warn_if_slaves_ar

33、e_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) fprintf(stderr, You can either start one emulation with one machine directly from the comm

34、andnline, or start one or more emulations using configuration files. Not both.n); exit(1); emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); if (emuls = NULL) f

35、printf(stderr, out of memoryn); exit(1); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); snprintf(tmpstr, sizeof(tmpstr), emul%i, n_emuls-1); if (n_emuls = 0) fprintf(stderr, No emulations defined. Maybe you forgot to use -E xx and/o

36、r -e yy, to specifynthe machine type. For example:nn %s -e 3max -d disk.imgnn to boot an emulated DECstation 5000/200 with a disk image.n, progname); exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machine_t

37、ype = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) exit(1); emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struc

38、t emul *) * n_emuls); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); if (n_emuls = 0) exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machi

39、ne_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) for (i=1; iargc; i+) if (argvi0 = ) exit(1); emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(s

40、truct emul *) * n_emuls); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); if (n_emuls = 0) exit(1); device_set_exit_on_error(0); console_warn_if_slaves_are_needed(1); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-m

41、achine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) emul_simple_init(emuls0); for (i=1; iargc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); console_allow_s

42、laves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0-machine_type = MACHINE_NONE) n_emuls -; else for (i=0; imachines0, diskimagesi); if (n_emuls 0) emul_simple_init(emuls0); for (i=1; iar

43、gc; i+) if (argvi0 = ) if (strlen(s) = 0 & i+1 argc & argvi+10 != ) i+; s = argvi; n_emuls +; emuls = realloc(emuls, sizeof(struct emul *) * n_emuls); console_allow_slaves(1); if (n_emuls = 1) emul_destroy(emuls0); emulsn_emuls - 1 = emul_create_from_configfile(s); emul_run(emuls, n_emuls); console_

44、deinit(); for (i=0; in_emuls; i+) emul_destroy(emulsi); return 0;int main(int argc, char *argv) console_init(); cpu_init(); device_init(); machine_init(); timer_init(); useremul_init(); emuls = malloc(sizeof(struct emul *); emuls0 = emul_new(NULL); get_cmd_args(argc, argv, emuls0, &diskimages, &n_di

45、skimages); for (i=0; imachines0, diskimagesi); if (n_emuls 0) emul_simple_init(emuls0); emul_run(emuls, n_emuls); console_deinit(); for (i=0; imachines0, diskimagesi); /给机器添加磁盘 emul_simple_init(emuls0); /模拟机器初始化 emul_run(emuls, n_emuls); /运行模拟机器 console_deinit(); /控制台销毁 emul_destroy(emulsi); /模拟机器销毁

46、 return 0; /返回是不是很简单?菜罚烫蹿畦家戮席脚捏履许壹疮扔呀奔蝎捐俯减焦告坛股好剿烩擅肚晋注漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发几点看法学习Linux 仇视Windows存在的就是合理的,Windows有其优点仇视微软是一种病态 Linus TorvaldsLinux要吸收Windows的优点学习学习Linux Linux 抛弃抛弃WindowsWindows 各取所需,要什么用什么各取所需,要什么用什么 和谐共处,双系统并不丢人和谐共处,双系统并不丢人学习学习Linux Linux 抛弃抛弃GUIGUI 爱美之心人皆有之,爱美之心人皆有之,KDE/GnomeKDE/Gnome有功无罪有功无罪 命令行不是拿来炫耀的,而是给人多一种选择命令行不是拿来炫耀的,而是给人多一种选择学习学习Linux Linux 人云亦云人云亦云 真正的高手大都低调,哗众取宠的大都是半吊子真正的高手大都低调,哗众取宠的大都是半吊子 谁用谁知道,没有调查就没有发言权谁用谁知道,没有调查就没有发言权幕九亚冰其栏随荣次雏氓伴接启掇服涎歌肝契大先立欠治咒痪匪黑苯循硝漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发谢谢!欢迎提问湃掳篷扣猿掩贺嚼挚赃颂涛界觅凉颤丑樱迫太沉些轮丰烩疽斧抚厅验快忿漫谈Linux龙芯及其软件开发漫谈Linux龙芯及其软件开发

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 资格认证/考试 > 自考

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号