📄 tgt_machdep.c
字号:
/* $Id: tgt_machdep.c,v 1.3 2002/11/16 18:01:37 pefo Exp $ *//* * Copyright (c) 2000 Opsycon AB (www.opsycon.se) * Copyright (c) 2000 Rtmx, Inc (www.rtmx.com) * Copyright (c) 2002 Patrik Lindergren (www.lindergren.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 by Patrik Lindergren. * 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 <pmon/dev/mpc107reg.h>#include <sys/dev/pci/pcivar.h>#include <powerpc.h>#include <pmon.h>#include <pmon/netio/netio.h>#include <pmon/dev/ns16550.h>extern void put_hex_word __P((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 }, { (char *)COM2_BASE_ADDR, 0, ns16550, 256, B9600, COM2_FREQ }, { 0 }};unsigned long _filebase;static void _probe_frequencies __P((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);}#ifdef HAVE_LOGO/* * 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");}#endif /* HAVE_LOGO *//* * Target dependent version printout. * Printout available target version information. */voidtgt_cmd_vers(){}static void_probe_frequencies(){#if 0 unsigned char dccr_b; SBD_DISPLAY ("FREQ", CHKPNT_FREQ); dccr_b = inb(CPCI680_DCCR_B); switch(DCCR_B_FAST_BUSFREQ(dccr_b)) { case 0: md_cpufreq = 66000000; /* Reserved in manual */ break; case 1: md_cpufreq = 100000000; break; case 2: md_cpufreq = 83000000; break; case 3: md_cpufreq = 66000000; break; }#else md_cpufreq = 100000000;#endif md_pipefreq = md_getpipefreq(md_cpufreq); if(md_pipefreq == -1) { printf("Serius problem incorrect pipe freq!!!\n"); } }/* * 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(){#if 0 extern int monarch_mode;#endif int flashSize; int cacheSpeed; char *cacheSize; unsigned char dccr_a; printf("BSP Copyright 2002, Patrik Lindergren.\n"); dccr_a = inb(CPCI680_DCCR_A); cacheSpeed = 200; flashSize = 32; switch(DCCR_A_L2SIZE(dccr_a)) { case 0: cacheSize = "2 MB"; break; case 1: cacheSize = "Not Used"; break; case 2: cacheSize = "1 MB"; break; case 3: cacheSize = "512 KB"; break; } printf("Board: PowerCoreCPCI-680, Rev. %d\n", 1);#if 0 printf("L2 Cache Speed %d MHz, L2 Cache Size %s\n", cacheSpeed, cacheSize);#endif#if 0 if(monarch_mode == 1) printf("Board set to Monarch Mode\n");#endif 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());}#elseint 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(){}#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!!! */ outb(MPC107_PCI_ISA_IO_BASE + 0x4c, 0x08); while(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -