⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install.c

📁 mips架构的bootloader,99左右的版本 但源代码现在没人更新了
💻 C
📖 第 1 页 / 共 5 页
字号:
printf("\n");for (i=0;targList[i].name;i++) printf("%d. %s\n",i+1,targList[i].name);printf("\n");printf("Enter your selection [1-%d] (%s) > ",i,def);while (1) {	Gets(buf);	printf("\n");	if (buf[0] == 0) strcpy(buf,def);	r = 0;	sscanf(buf,"%d",&r);	if (r >= 1 && r <= i) break;	printf("BAD INPUT, reenter your selection > ");	}(* targList[r-1].func)();if (strequ(ethernet,"YES")) {	strcpy(etherhwaddr,ETHERNET_HW_ADDRESS);	strcpy(etheripaddr,ETHERNET_IP_ADDRESS);	}if (fileExists("optfpem")) fpem = "OPT";else if (fileExists("fpem")) fpem = "STD";#ifdef MSDOSif (lststr(cpu,"LR64360")) dlecho = "lfeed";#endifstrcpy(hostport,"tty0");defRecords = "SREC";}/**************************************************************  dlmodeCfg(cmd)*/VOID dlmodeCfg(cmd)int cmd;{int r;if (cmd) {	bufprt("Download mode: ");	if (strequ(hostport,"tty0")) bufprt("Single-port");	else if (strequ(hostport,"ethernet")) bufprt("Ethernet");	else bufprt("Two-port");	return;	}printf("You can download to PMON using a number of techniques.\n");printf("\n");printf("1. Single-port mode (using tip or a terminal emulator)\n");printf("2. Dual-port mode (using edown)\n");if (strequ(ethernet,"YES")) printf("3. Ethernet (using tftp)\n");printf("\n");printf("Select default download technique [1-n] (%s) > ",def);while (1) {	Gets(buf);	printf("\n");	if (buf[0] == 0) strcpy(buf,def);	r = 0;	sscanf(buf,"%d",&r);	switch (r) {	    case 1 :		strcpy(hostport,"tty0");		defRecords = "SREC";		if (lststr(cpu,"LR64360")) dlecho = "lfeed";		dlproto = "NONE";		break;	    case 2 :		strcpy(hostport,"tty1");		dlproto = "EtxAck";		break;	    case 3 :		if (strequ(ethernet,"YES")) {			strcpy(hostport,"ethernet");			dlproto = "EtxAck";			break;			}		/* else fall through */	    default :		printf("BAD input, please reenter your selection > ");		continue;		break;		}	break;	}}/**************************************************************  endianDef(cmd)*/VOID endianDef(cmd)int cmd;{if (cmd) {	sprintf(tmp,"Default Endian: %s",defEndian);	bufprt(tmp);	return;	}if (! strchr(endian,' ')) {	printf("Only one endianness selected, return to continue > ");	Gets(buf);	return;	}if (strequ(defEndian,"Big")) def = "1";else if (strequ(defEndian,"Little")) def = "2";else printf("install: error 902\n");defEndian = 0;printf("The pmcc command can be used to build programs with either big or\n");printf("little byte ordering. This can be selected via the -EB and -EL\n");printf("options, but it may be more convenient to set the default to\n");printf("refect the ordering that you will normally use.\n");printf("\n");printf("1. Big Endian\n");printf("2. Little Endian\n");printf("\n");printf("Select a byte ordering [1 2] (%s) > ",def);while (1) {	Gets(buf);	printf("\n");	if (strempty(buf)) strcpy(buf,def);	if (strequ(buf,"1"))  defEndian = "Big";	else if (strequ(buf,"2"))  defEndian = "Little";	if (defEndian) break;	printf("BAD input, please reenter your selection > ");	}}/**************************************************************  endianCfg(cmd)*	specifies which versions of PMON will be built.*/VOID endianCfg(cmd)int cmd;{char *av[10],def[8];int ac,i,err;if (cmd) {	sprintf(tmp,"Endian support: %s",endian);	bufprt(tmp);	return;	}*def = 0;if (strstr(endian,"Big")) strcat(def,"1 ");if (strstr(endian,"Little")) strcat(def,"2 ");if (*def) def[strlen(def)-1] = 0; /* kill trailing space */*endian = 0;printf("This package can be used to build binaries for execution on big- or\n");printf("little-endian target systems. You may select both options.\n");printf("\n");printf("1. Big Endian\n");printf("2. Little Endian\n");printf("\n");printf("Select one target type [1 2] (%s) > ",def);while (1) {	err = 0;	Gets(buf);	printf("\n");	if (strempty(buf)) strcpy(buf,def);	ac = argvize(av,buf);	for (i=0;i<ac;i++) {		if (strequ(av[i],"1")) {			if (strstr(endian,"Big")) err = 1;			strcat(endian,"Big ");			}		else if (strequ(av[i],"2")) {			if (strstr(endian,"Little")) err = 1;			strcat(endian,"Little ");			}		else err = 1;		}	if (*endian) endian[strlen(endian)-1] = 0; /* kill trailing space */	if (strstr(endian,"Big") && strstr(endian,"Little")) /* 970515 */ ;	else if (strequ(endian,"Big")) defEndian = "Big";	else if (strequ(endian,"Little")) defEndian = "Little";	else printf("install: error 985\n");	if (err == 0) break;	printf("BAD INPUT, reenter your selection > ");	}if (lststr(cpu,"LR64360") && strstr(endian,"Little"))	printf("Warning: the ATMizer-1 only operates in Big Endian mode\n");if (lststr(cpu,"LR64363") && strstr(endian,"Little"))	printf("Warning: the ATMizer-2 only operates in Big Endian mode\n");#if 0 /* 4011 supports big and little */if (lststr(cpu,"LR4010") && strstr(endian,"Big"))	printf("Warning: the 4010 only operates in Little Endian mode\n");#endif}/**************************************************************  doInstall()*           Now implement the selections*/doInstall(){char CLEAN_DIRS[80],PMON_TARG[80],LIB_TARG[80];char MON_TARG[80],LIB_ONLY[80];char cpppath[400];int  i;int  umsk = 0777;char cwdstr[CWDSZ+2];char tmp[80],*s,*d,*p,*cwd;*cpppath = 0;if (COMP_ROOT[0] == 0) {	printf("COMP_ROOT unknown, exiting\n");	exit(1);	}/* get the cwd. This must work for csh, sh, automount, and MSDOS */cwd = getenv("cwd"); /* csh */if (!cwd) {	cwd = getenv("PWD"); /* sh */	if (!cwd) {		getcwd(cwdstr,CWDSZ); /* catch all */		cwd = cwdstr;		}	}printf("Please confirm your current path [%s] > ",cwd);Gets(buf);if (buf[0] != 0) {        strcpy(cwdstr,buf);        cwd = cwdstr;        }if (fileExists("defines.mk")) {	printf("Saving existing defines.mk in defines.old.\n");	unlink("defines.old");	rename("defines.mk","defines.old");	}else printf("Creating defines.mk.\n");dfp = fopen("defines.mk","w");if (dfp == 0) {	fprintf(stderr,"can't open defines.mk\n");	exit(1);	}*targets = 0;if (strstr(endian,"Big")) strcat(targets," BG BO");if (strstr(endian,"Little")) strcat(targets," LG LO");/* set BUILD & CLEAN DIRS, also PMON & LIB TARG */strcpy(LIB_ONLY,"TOOLSd");CLEAN_DIRS[0] = 0;PMON_TARG[0] = 0;MON_TARG[0] = 0;LIB_TARG[0] = 0;FPEM_DIR = "lib";if (strequ(fpem,"STD")) {	strcat(LIB_ONLY," FPEMd");	strcat(CLEAN_DIRS," FPEMd");	FPEM_DIR = "fpem";	}if (strequ(fpem,"OPT")) {	strcat(LIB_ONLY," OPTFPEMd");	strcat(CLEAN_DIRS," OPTFPEMd");	FPEM_DIR = "optfpem";	}if (*clib_rev) {	strcat(LIB_ONLY," LIBd");	strcat(CLEAN_DIRS," LIBd");	if (strstr(endian,"Big")) {		MKDIR("lib/bo",umsk);		strcat(LIB_TARG," BOd");		}	if (strstr(endian,"Little")) {		MKDIR("lib/lo",umsk);		strcat(LIB_TARG," LOd");		}	if (MIPSTOOLS) {		strcat(LIB_ONLY," LIBSAd");		strcat(CLEAN_DIRS," LIBSAd");		if (strstr(endian,"Big")) MKDIR("libsa/bo",umsk);		if (strstr(endian,"Little")) MKDIR("libsa/lo",umsk);		if (*pmon_rev || *imon_rev) {			if (strstr(endian,"Big")) MKDIR("libsa/bg",umsk); 			if (strstr(endian,"Little")) MKDIR("libsa/lg",umsk); 			}		}	}if (*mon_rev) {	strcat(CLEAN_DIRS," MONd");	}if (*imon_rev) {	strcat(CLEAN_DIRS," IMONd BSPSd");	if (strstr(endian,"Big")) {		if (!strstr(PMON_TARG,"BGd")) strcat(PMON_TARG," BGd");		MKDIR("imon/bg",umsk);		if (!strstr(MON_TARG,"BGd")) strcat(MON_TARG," BGd");		MKDIR("mon/bg",umsk);		if (!strstr(LIB_TARG,"BGd")) strcat(LIB_TARG," BGd");		MKDIR("lib/bg",umsk);		}	if (strstr(endian,"Little")) {		if (!strstr(PMON_TARG,"LGd")) strcat(PMON_TARG," LGd");		MKDIR("imon/lg",umsk);		if (!strstr(MON_TARG,"LGd")) strcat(MON_TARG," LGd");		MKDIR("mon/lg",umsk);		if (!strstr(LIB_TARG,"LGd")) strcat(LIB_TARG," LGd");		MKDIR("lib/lg",umsk);		}	}if (*pmon_rev) {	strcat(CLEAN_DIRS," PMONd");	if (strstr(endian,"Big")) {		if (!strstr(PMON_TARG,"BGd")) strcat(PMON_TARG," BGd");		MKDIR("pmon/bg",umsk);		if (!strstr(MON_TARG,"BGd")) strcat(MON_TARG," BGd");		MKDIR("mon/bg",umsk);		if (!strstr(LIB_TARG,"BGd")) strcat(LIB_TARG," BGd");		MKDIR("lib/bg",umsk);		}	if (strstr(endian,"Little")) {		if (!strstr(PMON_TARG,"LGd")) strcat(PMON_TARG," LGd");		MKDIR("pmon/lg",umsk);		if (!strstr(MON_TARG,"LGd")) strcat(MON_TARG," LGd");		MKDIR("mon/lg",umsk);		if (!strstr(LIB_TARG,"LGd")) strcat(LIB_TARG," LGd");		MKDIR("lib/lg",umsk);		}	strcat(CLEAN_DIRS," EXAMPLESd");	MKDIR("examples/pmon",umsk);	MKDIR("examples/stand",umsk);	MKDIR("examples/rom",umsk);	MKDIR("examples/xpmon",umsk);	MKDIR("examples/xstand",umsk);	}for (i=0;defines[i];i++) fprintf(dfp,"%s\n",defines[i]);fprintf(dfp,"LIB_ONLY = %s\n",LIB_ONLY);fprintf(dfp,"CLEAN_DIRS = %s\n",CLEAN_DIRS);if (*PMON_TARG != 0) fprintf(dfp,"PMON_TARG = %s\n",PMON_TARG);if (*MON_TARG != 0) fprintf(dfp,"MON_TARG = %s\n",MON_TARG);fprintf(dfp,"LIB_TARG = %s\n",LIB_TARG);fprintf(dfp,"ALL_TARG = %s\n",ALL_TARG);fprintf(dfp,"FPEM_DIR = %s\n",FPEM_DIR);fprintf(dfp,"FTEXT = %s\n",ftext);fprintf(dfp,"FDATA = %s\n",fdata);if (strequ(defEndian,"Big")) fprintf(dfp,"EDIR = bg\n");if (strequ(defEndian,"Little")) fprintf(dfp,"EDIR = lg\n");if (strstr(LIB_ONLY,"FPEM")) {	if (strstr(LIB_TARG,"BG")) {		sprintf(tmp,"%s/bg",FPEM_DIR);		MKDIR(tmp,umsk); 		}	if (strstr(LIB_TARG,"BO")) {		sprintf(tmp,"%s/bo",FPEM_DIR);		MKDIR(tmp,umsk); 		}	if (strstr(LIB_TARG,"LG")) {		sprintf(tmp,"%s/lg",FPEM_DIR);		MKDIR(tmp,umsk); 		}	if (strstr(LIB_TARG,"LO")) {		sprintf(tmp,"%s/lo",FPEM_DIR);		MKDIR(tmp,umsk); 		}	}#if 0 /* 970317 */for (s=cwd,d=tmp;*s;) {	if (*s == '/') *d++ = '\\';	*d++ = *s++;	}*d = 0;fprintf(dfp,"SEDPAT = %s\n",tmp);#endif#ifdef MSDOS /* ================= MSDOS ================== */fprintf(dfp,"MAKE = nmake /nologo\n");fprintf(dfp,"EXE = .exe\n");fprintf(dfp,"O = bj\n");fprintf(dfp,"RMF = rm-f\n");fprintf(dfp,"CC = cl /w /nologo /DMSDOS\n");fprintf(dfp,"HOSTCCEXTRA = /link /stack:8192\n");fprintf(dfp,"TOOLOBJS = $(CFILES:.c=.exe)\n");fprintf(dfp,"RMFOBJS = mklist -O ../files.mk . ASFILES CFILES|rm-f -f-\n");unlink("setenv.bat");sfp = fopen("setenv.bat","w");if (sfp == 0) {	fprintf(stderr,"can't open setenv.bat\n");	exit(1);	}fprintf(sfp,"@echo off\n");fprintf(sfp,"echo Connecting with pmcc version %s using %s tools\n",							pkg_rev,tools);if (win95) fprintf(sfp,"echo path \"%%path%%\" > unsetenv.bat\n");else fprintf(sfp,"echo path %%path%% > unsetenv.bat\n");unlink("source.csh");cfp = fopen("source.csh","w");if (cfp == 0) {	fprintf(stderr,"can't open source.csh\n");	exit(1);	}fprintf(cfp,"# This file is compatible with the Hamilton Csh (www.hamiltonlabs.com)\n");fprintf(cfp,"echo \"Connecting with pmcc version %s using %s tools\"\n",							pkg_rev,tools);if (strequ(tools,"BSODOS")) {	/* setenv.bat */	fprintf(sfp,"set LSIPKG=%s\n",cwd);	fprintf(sfp,"set BSO_TASKING=%s\n",COMP_ROOT);	if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin386;%s/bin;%s/tools\n",					COMP_ROOT,COMP_ROOT,cwd);	else fprintf(sfp,"path %%path%%;%s/bin386;%s/bin;%s/tools\n",					COMP_ROOT,COMP_ROOT,cwd);	/* source.csh */	fprintf(cfp,"setenv LSIPKG %s\n",cwd);	fprintf(cfp,"setenv BSO_TASKING %s\n",COMP_ROOT);	fprintf(cfp,"set PATH=\"$PATH;%s/bin386;%s/bin;%s/tools\"\n",					COMP_ROOT,COMP_ROOT,cwd);	/* create defines.mk */	fprintf(dfp,"# tools type BSODOS\n");	fprintf(dfp,"TOOLSET = BSODOS\n");	fprintf(dfp,"PMCC = bso.c\n");	fprintf(dfp,"OPTLEV = -O\n");	fprintf(dfp,"\n");	}else if (strequ(tools,"ALGDOS")) { /* sde2 */	/* setenv.bat */	fprintf(sfp,"set LSIPKG=%s\n",cwd);	if (strstr(targets,"BG")) {	 fprintf(sfp,"set COMPILER_PATH=%s/libeb;%s/bin\n",COMP_ROOT,COMP_ROOT);	 fprintf(sfp,"set LIBRARY_PATH=%s/libeb\n",COMP_ROOT);	 if (toolrev < 20000) fprintf(sfp,"set GNUTARGET=elf-big\n");	 else fprintf(sfp,"set GNUTARGET=elf32-bigmips\n");	 }	else {	 fprintf(sfp,"set COMPILER_PATH=%s/libel;%s/bin\n",COMP_ROOT,COMP_ROOT);	 fprintf(sfp,"set LIBRARY_PATH=%s/libel\n",COMP_ROOT);	 if (toolrev < 20000) fprintf(sfp,"set GNUTARGET=elf-little\n");	 else fprintf(sfp,"set GNUTARGET=elf32-littlemips\n");	 }	if (!getenv("TMPDIR")) { /* 970927 */		fprintf(sfp,"set TMPDIR=/tmp\n");		if (!fileExists("/tmp")) MKDIR("/tmp",umsk);		}	fprintf(sfp,"set GO32TMP=/tmp\n");	fprintf(sfp,"set GO32=2r1\n"); /* merge stdout and stderr */	if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin;%s/tools\n", COMP_ROOT,cwd);	else fprintf(sfp,"path %%path%%;%s/bin;%s/tools\n", COMP_ROOT,cwd);	/* source.csh */	fprintf(cfp,"setenv LSIPKG %s\n",cwd);	if (strstr(targets,"BG")) {	 fprintf(cfp,"setenv COMPILER_PATH '%s/libeb;%s/bin'\n",COMP_ROOT,COMP_ROOT);	 fprintf(cfp,"setenv LIBRARY_PATH %s/libeb\n",COMP_ROOT);	 fprintf(cfp,"setenv GNUTARGET elf32-bigmips\n");	 }	else {	 fprintf(cfp,"setenv COMPILER_PATH '%s/libel;%s/bin'\n",COMP_ROOT,COMP_ROOT);	 fprintf(cfp,"setenv LIBRARY_PATH %s/libel\n",COMP_ROOT);	 fprintf(cfp,"setenv GNUTARGET elf32-littlemips\n");	 }	if (!getenv("TMPDIR")) { /* 970927 */		fprintf(cfp,"setenv TMPDIR=/tmp\n");		if (!fileExists("/tmp")) MKDIR("/tmp",umsk);		}	fprintf(cfp,"setenv GO32TMP /tmp\n");	fprintf(cfp,"setenv GO32 2r1\n"); /* merge stdout and stderr */	fprintf(cfp,"set PATH=\"$PATH;%s/bin;%s/tools\"\n", COMP_ROOT,cwd);	/* create defines.mk */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -