漫谈Linux龙芯及其软件开发
《漫谈Linux龙芯及其软件开发》由会员分享,可在线阅读,更多相关《漫谈Linux龙芯及其软件开发(22页珍藏版)》请在装配图网上搜索。
1、软件硬件操作系统CPUDOS,WindowsLinux,UnixX86,IA64MIPS,ARMX86LinuxDOSWindowsFreeBSDX86IA64PowerPC龙芯Linuxint 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*emuls;char*diskimages=NULL;int n_diskimage
2、s=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,out of memoryn);exit(1);/*Allocate space for a simple emul setup:*/n_emuls=1;
3、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);srandom(tv.tv_sec getpid()tv.tv_usec);/*Print startup message:*/debug(GXemul);debug(Copyright(C)2003-200
4、6 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,diskimagesi);/*Simple initialization,from command line arguments:*/if(n_emuls 0)/*Make sure that there are no configuratio
5、n 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 or more emulations using configuration files.Not both.n);exit(1);/*Initialize one emul:*/emul_simple_init(emuls0);/*Initialize emulations from
6、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;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_a
7、llow_slaves(1);/*Destroy the temporary emuls0,since it will be overwritten:*/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/or-e yy,to
8、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);/*Run all emulations:*/emul_run(emuls,n_emuls);/*Deinitialize everything:*/console_deinit();for
9、(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 commandnline,or start one or more emulations using configuration files.Not both.n);exi
10、t(1);emul_simple_init(emuls0);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_emuls=1)emul_destroy(emuls
11、0);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 boot an emulated DECstation 5000/200 with a
12、 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(n_emuls 0)for(i=1;iargc;i+)if(argvi0=)fprintf(stderr,You can either
13、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 tmpstr50;char*s=argvi+1;if(strlen(s)=0&i+1 argc&argvi+10!=)i+;s=argvi;n_emuls+;emuls=realloc(emu
14、ls,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(n_emuls=0)fprintf(stderr,No emulations defined.Maybe you f
15、orgot 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_are_needed(1);emul_run(emuls,n_emuls);console_deinit();for(i=0;imachines0-ma
16、chine_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 commandnline,or start one or more emulations using configuration files.Not both.n);exit(1);emul_simple_i
17、nit(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)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
18、);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 disk image.n,progname);exit(1);device_set_exit
19、_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=)fprintf(stderr,You can either start one emulation with one machine directly f
20、rom 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;n_emuls+;emuls=realloc(emuls,sizeof(struct emul*)*n_emuls);if(emuls=NULL)fprintf(stderr,out of memoryn
21、);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/or-e yy,to specifynthe machine type.For example:nn%s-e
22、 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_type=MACHINE_NONE)n_emuls-;else for(i=0;imachines0,diskimagesi);if(n_e
23、muls 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(struct emul*)*n_emuls);console_allow_slaves(1);if(n_emuls=1)emul_destroy(emuls0);emulsn_emuls-1=emul_create_from_configfil
24、e(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-machine_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
25、(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_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_s
26、laves_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)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(
27、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_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
28、(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_slaves(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;in_emuls;i+)emul_
29、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_diskimages);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);/模拟机器销毁 return 0;/返回是不是很简单?
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。