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

📄 tgt_machdep.c

📁 MIPS处理器的bootloader,龙芯就是用的修改过的PMON2
💻 C
字号:
/*	$Id: tgt_machdep.c,v 1.3 2001/12/11 18:01:13 pefo Exp $ *//* * Copyright (c) 2000 Opsycon AB  (www.opsycon.se) * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com) *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed for Rtmx, Inc by *	Opsycon Open System Consulting AB, Sweden. * 4. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */#include <sys/types.h>#include <stdio.h>#include <setjmp.h>#include <termio.h>#include <string.h>#include <time.h>#include <machine/cpu.h>#include <machine/pio.h>#include <include/palomarii.h>#include <pmon/dev/cpc700.h>#include <pmon/dev/cpc700_iic.h>#include <pmon.h>extern int ns16550 __P((int, char *, int, int));extern char hwethadr[6];int md_pipefreq = 0;int md_cpufreq = 0;ConfigEntry	ConfigTable[] ={	{ (char *)REAR_COM_BASE_ADDR, 0, ns16550, 256, B9600 },	{ (char *)CPC700_UART0RBR, 0, ns16550, 256, B9600 },	{ (char *)FRONT_COM_BASE_ADDR, 0, ns16550, 256, B9600 },	{ 0 }};unsigned long _filebase;static void _probe_frequencies __P((void));void tgt_rtinit(void);/* *  This function makes inital HW setup for debugger and *  returns the apropriate setting for the status register. */register_ttgt_enable(int machtype){	/* XXX Do any HW specific setup */	return(PSL_IR|PSL_DR|PSL_FP|PSL_RI|PSL_ME|PSL_FE_DFLT);}/* *  Print out any target specific logo */voidtgt_logo(){    printf("\n");    printf("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\n");    printf("[[[            [[[[   [[[[[[[[[[   [[[[            [[[[   [[[[[[[  [[\n");    printf("[[   [[[[[[[[   [[[    [[[[[[[[    [[[   [[[[[[[[   [[[    [[[[[[  [[\n");    printf("[[  [[[[[[[[[[  [[[  [  [[[[[[  [  [[[  [[[[[[[[[[  [[[  [  [[[[[  [[\n");    printf("[[  [[[[[[[[[[  [[[  [[  [[[[  [[  [[[  [[[[[[[[[[  [[[  [[  [[[[  [[\n");    printf("[[   [[[[[[[[   [[[  [[[  [[  [[[  [[[  [[[[[[[[[[  [[[  [[[  [[[  [[\n");    printf("[[             [[[[  [[[[    [[[[  [[[  [[[[[[[[[[  [[[  [[[[  [[  [[\n");    printf("[[  [[[[[[[[[[[[[[[  [[[[[  [[[[[  [[[  [[[[[[[[[[  [[[  [[[[[  [  [[\n");    printf("[[  [[[[[[[[[[[[[[[  [[[[[[[[[[[[  [[[  [[[[[[[[[[  [[[  [[[[[[    [[\n");    printf("[[  [[[[[[[[[[[[[[[  [[[[[[[[[[[[  [[[   [[[[[[[[   [[[  [[[[[[[   [[\n");    printf("[[  [[[[[[[[[[[[[[[  [[[[[[[[[[[[  [[[[            [[[[  [[[[[[[[  [[\n");    printf("[[[[[[[2000][[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\n");}/* *  Target dependent version printout. *  Printout available target version information. */voidtgt_cmd_vers(){    /*	printf("Board revision level: %c.\n", in8(PLD_BAR) + 'A'); */}static void_probe_frequencies(){extern void loopforameg __P((void));#if 0	int i, timeout, sec, cur, cnt;#endif	SBD_DISPLAY ("FREQ", CHKPNT_FREQ);#if 0	md_pipefreq = 200000000;	/* Defaults */#else        /* Set default to 400MHz */	md_pipefreq = 400000000;	/* Defaults */#endif        	md_cpufreq = 66000000;#if 0	/*	 * Select correct clock frequency source and 24Hr mode.	 */	clkwrite(MC_REGA, (clkread(MC_REGA) & 0x80) | MC_BASE_32_KHz | MC_RATE_2);	/*	 * Do the next twice for two reasons. First make sure we run from	 * cache. Second make sure synched on second update. (Pun intended!)	 */	for(i = 2;  i != 0; i--) {		cnt = get_count();		timeout = 10000000;		sec = clkread(MC_SEC); 		do {			timeout--;			cur = clkread(MC_SEC);		} while(timeout != 0 && cur == sec);		cnt = get_count() - cnt;		if(timeout == 0) {			clk_invalid = 1;			return;		/* Get out if clock is not running */		}	}	/*	 *  Calculate the external bus clock frequency.	 */	md_cpufreq = (cnt + 100000) / 100000;	md_cpufreq *= 400000;	/*	 *  Calculate the cpu pipeline frequency.	 */	for(i = 2;  i != 0; i--) {		cnt = get_count();		loopforameg();		cnt = get_count() - cnt;	}	md_pipefreq = (md_cpufreq / cnt + 1) / 4;	md_pipefreq *= 1000000;#endif	}/* *   Returns the CPU pipelie clock frequency */inttgt_pipefreq(){	if(md_pipefreq == 0) {		_probe_frequencies();	}	return(md_pipefreq);}/* *   Returns the external clock frequency, usually the bus clock */inttgt_cpufreq(){	if(md_cpufreq == 0) {		_probe_frequencies();	}	return(md_cpufreq);}/* *  Print out any target specific memory information */voidtgt_memprint(){	if(tgt_gettime() == -1) {		printf("\nWARN! Date invalid, use 'date' to set time!\n");	}}voidtgt_machprint(){	printf("BSP Copyright 2001, IP Unplugged Inc.\n");#if 0	printf("CPU PowerPC %s @", md_cpuname());#else        printf("CPU PowerPC 750 @");#endif        } /* *  Return a suitable address for the client stack. *  Usually top of RAM memory. */register_ttgt_clienttos(){	return((memorysize & ~7) - 64);}/* *  Network stuff. */voidtgt_netinit(){}inttgt_ethaddr(char *p){	bcopy((void *)&hwethadr, p, 6);	return(0);}voidtgt_netreset(){}/* *  Simple display function to display a 4 char string or code. *  Called during startup to display progress on any feasible *  display before any serial port have been initialized. */voidtgt_display(char *msg, int x){	/* Have simple serial port driver */	tgt_putchar(msg[0]);	tgt_putchar(msg[1]);	tgt_putchar(msg[2]);	tgt_putchar(msg[3]);	tgt_putchar('\r');	tgt_putchar('\n');}voidtgt_poll(){	/* No target devices to poll */}voidclrhndlrs(){}inttgt_getmachtype(){	return(md_cputype());}/* *  Create stubs if network is not compiled in */#ifdef INETvoidtgt_netpoll(){	splx(splhigh());}#elsegsignal(jmp_buf jb, int	sig){	if(jb != NULL) {		longjmp(jb, 1);	}}netopen()	{ return -1;}netread()	{ return -1;}netwrite()	{ return -1;}netclose()	{ return -1;}netlseek()	{ return -1;}netioctl()	{ return -1;}void netpoll()	{}unsigned long__time(){	return(tgt_gettime));}#endif /*INET*/

⌨️ 快捷键说明

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