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

📄 tgt_machdep.c

📁 MIPS处理器的bootloader,龙芯就是用的修改过的PMON2
💻 C
字号:
/*	$Id: tgt_machdep.c,v 1.10 2002/11/16 18:01:35 pefo Exp $ *//* * Copyright (c) 2000 Opsycon AB  (www.opsycon.se) * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com) * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.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. *	This product includes software developed for Patrik Lindergren, by *	ipUnplugged 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 <pmon/dev/mc146818reg.h>#include <sys/dev/pci/pcivar.h>#include <powerpc.h>#include <pmon.h>#include <pmon/netio/netio.h>#include <pmon/dev/ns16550.h>#ifdef POCONO#include <pmon/custom/IPU/Pocono/pocono.h>#endif /* POCONO */extern void put_hex_word(int);extern unsigned char hwethadr[6];int md_pipefreq = 0;int md_cpufreq = 0;ConfigEntry	ConfigTable[] ={	{ (char *)COM1_BASE_ADDR, 0, ns16550, 256, B9600, COM1_FREQ },	{ 0 }};unsigned long _filebase;static void _probe_frequencies(void);extern void configure(void);extern void config_init(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(){}static void_probe_frequencies(){	unsigned int cfg;	static char pllratio[16] =		/* 0   1   2   3   4   5    6   7   8   9  10  11  12  13  14  15 */	/*7400*/{ 90, 75, 70,  1, 20, 65,  25, 45, 30, 55, 40, 50, 80, 60, 35, 0 };	int i;	SBD_DISPLAY ("FREQ", CHKPNT_FREQ);	GETHID1(i);		/* Get PLL info */ 	i = (i >> 28) & 0x0f;	md_pipefreq = (md_cpufreq / 10) * pllratio[i];;	cfg = inl(CONFIG_REGISTER) & CFG_REG_MASK;	md_cpufreq = CFG_REG_MEMBUS_SPEED(cfg) ? 100000000 : 83000000;}/* *   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(){#ifdef PMON_PCISUPPORT	extern int monarch_mode;#endif /* PMON_PCISUPPORT */	unsigned int cfg;	int flashSize;	int cacheSpeed;	char *cacheSize;		printf("BSP Copyright 2001, IP Unplugged Inc.\n");	cfg = inl(CONFIG_REGISTER) & CFG_REG_MASK;        switch(CFG_REG_L2SPEED(cfg)) {	case 0:		cacheSpeed = 133;		break;	case 1:		cacheSpeed = 150;		break;	case 2:		cacheSpeed = 166;		break;	case 3:		cacheSpeed = 175;		break;	case 4:		cacheSpeed = 200;		break;	case 5:		cacheSpeed = 233;		break;	case 6:		cacheSpeed = 266;		break;	case 7:		cacheSpeed = 300;		break;	}	        switch(CFG_REG_FLASHSIZE(cfg)) {	case 0:		flashSize = 32;		break;	case 1:		flashSize = 64;		break;	}        switch(CFG_REG_L2SIZE(cfg)) {	case 0:		cacheSize = "Not Used";		break;	case 1:		cacheSize = "256 KB";		break;	case 2:		cacheSize = "512 KB";		break;	case 3:		cacheSize = "1 MB";		break;	}	printf("Board: PowerPMC250, Rev. %d, Flash Size %d MB\n", CFG_REG_REV(cfg), flashSize);	printf("L2 Cache Speed %d MHz, L2 Cache Size %s\n", cacheSpeed, cacheSize);#ifdef PMON_PCISUPPORT	if(monarch_mode == 1)		printf("Board set to Monarch Mode\n");#endif /* PMON_PCISUPPORT */	printf("CPU PowerPC %s @", md_cpuname());} /* *  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(':');	tgt_putchar(' ');	put_hex_word(x);	tgt_putchar('\r');	tgt_putchar('\n');}voidclrhndlrs(){}inttgt_getmachtype(){	return(md_cputype());}/* *  Create stubs if network is not compiled in */#ifdef INETvoidtgt_netpoll(){	splx(splhigh());}#else#if 0voidgsignal(jmp_buf jb, int	sig){	if(jb != NULL) {		longjmp(jb, 1);	}}#endifint netopen(const char *a, int b){	return -1;}int netread(int a, void *b, int c){	return -1;}int netwrite(int a, const void *b, int c){	return -1;}int netclose(int a){	return -1;}long netlseek(int a, long b, int c){	return -1;}int netioctl(int a, int b, void *c){	return -1;}void netpoll(void){}voidtgt_netpoll(){}#if 0unsigned long__time(){	return(tgt_gettime());}#endif#endif /*INET*//* *  Put all machine dependent initialization here. This call *  is done after console has been initialized so it's safe *  to output configuration and debug information with printf. */voidtgt_devconfig(){        _pci_devinit(1);	/* PCI device initialization */        config_init();        configure();}voidtgt_devinit(){        _pci_businit(1);	/* PCI bus initialization */}voidtgt_machreset(){	tgt_netreset();}voidtgt_reboot(){	/* XXX: Todo!!! */	while(1);}

⌨️ 快捷键说明

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