📄 monitor.c
字号:
dwPCISharedRAMBase = 0x00000000;
dwRIOContigRAMSize = 16 * 0x100000;
WriteOutput("Initializing RIO memory to PCI Base Address 0x%x\n", dwPCISharedRAMBase);
/* Set the base address for the shared RAM, and close all other accesses */
/* through the bridge. */
bRAMAccessWidth = 4;
bRAMTestPhase = 0;
if (TestRAMRegion( pRIO, bRAMTestPhase, bRAMAccessWidth,
dwPCISharedRAMBase, 4096, dwRIOContigRAMSize/2 - 4096 )) {
DbgPrintf( "TestMemory() - ERROR: Bank 1 Call To TestRAMRegion() Failed\n" );
return 1;
}
WriteOutput("RIO Memory initialized at Address 0xB0000000. Size %d\n", dwRIOContigRAMSize);
#if 0
if (InitI960( pRIO, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
0xFFFFFFFF, 0x00000000, dwPCISharedRAMBase )) {
DbgPrintf( "DetectRIORAM() - ERROR: Call To InitI960() Failed\n" );
return 1;
}
#endif 0
}
}
/* End of Commands Related to PCI */
/******************************************************************************
* Function: Command_Go
* Input: int expected_args: Number of arguments required by this command
* int argc: Actual number of arguments passed.
* unsigned *argv: Pointer to the arguments.
* Output: None.
*****************************************************************************/
void Command_Go(unsigned sub_command, unsigned expected_argc, unsigned argc, unsigned *argv)
{
unsigned char *dst;
func_ptr_t run;
WriteDbgOutput(DEB_FLOW, ("+Command_Go(expected_argc=%d, argc=%d, argv=0x%x)\n", expected_argc, argc, argv));
if(argc != expected_argc) {
WriteOutput("Command_Go called with invalid number of arguments (%d).\n", argc);
return;
}
dst = (unsigned char *)argv[0];
WriteOutput("jumping to address 0x%x...\n", dst);
run = (func_ptr_t) dst;
(*run) ();
}
// DownloadSreFile will download an SRE file.
// if pport == 1, it will download from the parallel port.
// else it will download from the serial port.
// returns the start address or -1 on error
unsigned DownloadSreFile(int pport) {
unsigned char buf[100];
int term = 0, adrsize = 0, datasize = 0;
int cursor = 0;
int i;
char type;
char c;
unsigned lineCount, loadErrorCount;
char *loadError;
unsigned char *start, *low, *high, *adr, *datastart;
register unsigned checksum;
int bytes_on_line;
int first_data = 1; // First data record from the Srec file.
start = (unsigned char *) -1;
WriteOutput("\r\nDownloading SRE file thru %s port...\r\n", (pport == 1 ? "parallel" : "serial"));
loadError = "";
loadErrorCount = lineCount = 0;
low = (unsigned char *)0xf0000000;
high = (unsigned char *)0x00000000;
while (1)
{
cursor = 0;
// OutputFormatString("Reading Srec line...");
// OEMStartSerialInput();
c = gc (pport);
while( c != 'S' )
{
if (c == '>')
{
return (unsigned)start;
}
if ((c >= '0' && c <='9') || ( c >='A' && c <='F'))
{
// OutputFormatString("Warning: Missed lines Error. Got char: %c(%d), expected: S, lineCount=%d\r\n", c, c, lineCount);
term = 1;
}
c = gc(pport);
}
if(term)
{
loadError = "Missed lines";
loadErrorCount++;
term = 0;
}
// By this time "S" has been parsed. now comes 1, 2, 3 etc. eg S3
type = gc (pport);
checksum = buf[cursor++] = bytes_on_line = getbyte (pport);
for (i = 0; i < bytes_on_line; i++)
{
checksum += buf[cursor++] = getbyte (pport);
}
// OEMStopSerialInput();
lineCount++;
// OutputFormatString("done\r\n");
switch (type)
{
case '0':
case '5':
/* Ignore header records */
continue;
case '1':
/* Two byte address */
adrsize = 2;
break;
case '2':
adrsize = 3;
break;
case '3':
adrsize = 4;
break;
case '7':
adrsize = 4;
term = 1;
break;
case '8':
adrsize = 3;
term = 1;
break;
case '9':
adrsize = 2;
term = 1;
break;
default:
loadErrorCount++;
continue;
} // end switch
adr = 0;
for (i = 0; i < adrsize; i++)
{
adr = (ADDR) (((unsigned) adr << 8) | buf[i + 1]);
}
// print the current address to Alpha LEDs
// Print the current address after every 10 lines.
if(!(lineCount % 10)){
ToStr((unsigned)adr, ledstr);
Write_LED_Data(ledstr, (unsigned)adr);
}
#if 0
adr += offset;
#endif
datasize = cursor - adrsize - 2;
datastart = buf + adrsize + 1;
if ((checksum & 0xff) != 0xff)
{
int tmpl;
loadError = "Checksum error";
loadErrorCount++;
OutputFormatString("Warning: Checksum Error. Checksum=%X, expected=0xFF, Line %d, adr=%X\r\n", checksum, lineCount, adr);
// Print this line.
OutputFormatString("Corrupt line was :-\r\n");
for(tmpl = 0; tmpl <= datasize; tmpl++) {
OutputFormatString(" %B", datastart[tmpl]);
}
OutputFormatString("\r\n");
continue;
}
if (term)
{
if(loadErrorCount)
{
WriteOutput("\nWARNING !!! \n\n There were %d errors\n%s\n",loadErrorCount, loadError);
}
start = adr;
#if 0
set_pc (start);
#endif
goto quit;
}
if (datasize)
{
if ((adr + (datasize - 1)) > high)
high = adr + datasize - 1;
if (adr < low)
low = adr;
#if 0
if (veronly)
{
for (i = 0; i < datasize; i++)
{
int val = adr[i];
if (val != datastart[i])
{
adr = adr + i;
mon_printf (">\nVerify error at %p, in memory 0x%x in file 0x%x\n",
adr, val, datastart[i]);
return;
}
}
}
else // finally copy data to new location
#endif
// Check out whether it is a Flash image or a RAM image.
if(first_data) {
// If it is a Flash image, it would be linked to Address greater
// Than Area 2
if( ((unsigned)adr & 0x0FFFFFFF) < 0x0C000000) {
to_flash = 1;
OutputString("Image going to FLASH.\r\n");
to_flash = 1;
} else {
OutputString("Image going to RAM.\r\n");
to_flash = 0;
}
first_data = 0;
}
// timer_delay(1); // Delay 2 seconds.
// If it is a RAM image, write data to appropriate location in RAM,
// Else write to RAM Buffer located at ulRamBufStart.
if(to_flash) {
adr = (unsigned char *)(ulRamBufStart + ((unsigned)adr & 0x0FFFFFFF));
}
{
for (i = 0; i < datasize; i++)
adr[i] = datastart[i];
}
}
} // while (1)
quit:
if(pport) {
/* Try reading a dummy value at the end from the parallel port. Else
* it gets stuck at 99 % */
c = gc(pport);
}
WriteOutput (" %d lines loaded, %x errors\r\n", lineCount, loadErrorCount);
WriteOutput ("Image location, : %x - %x, start : %x\r\n", low, high, start);
#if ((SH_PLATFORM == PLATFORM_ASPEN)||(SH_PLATFORM==PLATFORM_BIGSUR))
// Now if it was a Flash image, program the Flash
if(to_flash) {
unsigned i;
unsigned flash_low, flash_high;
OutputFormatString("Programming Flash...\r\n");
OEMFlashWriteBegin(0, (unsigned)high & 0x0FFFFFFF);
// Align low and high.
flash_low = (unsigned)low & 0x0FFFFFFC;
flash_high = ((unsigned)high + 3) & 0x0FFFFFFC;
for(i = flash_low; i <= flash_high; i+=4) {
OEMFlashWrite( (i), *(volatile unsigned *) (ulRamBufStart + i) );
}
}
#endif ((SH_PLATFORM == PLATFORM_ASPEN)||(SH_PLATFORM==PLATFORM_BIGSUR))
return (unsigned)start;
}
/*****************************************************************************
Function: Command_Register
Synopsis: Used to read/modify the value of a register.
****************************************************************************/
void Command_Register(void)
{
char *regname, *token;
int write; /* Read or Write the register. */
unsigned val=0;
regname = StrTok(NULL, DELIM_STR);
if(regname == NULL) {
WriteOutput("No register specified for r command...\n");
return;
}
token = StrTok(NULL, DELIM_STR);
if(token != NULL) {
write = 1;
val = ToHex(token);
WriteDbgOutput(DEB_INFO, ("Writing 0x%x to %s\n", val, regname));
}
else {
write = 0;
WriteDbgOutput(DEB_INFO, ("Reading %s\n", regname));
}
if(!StrICmp(regname, "sr")) {
if(write)
set_sr(val);
else
val = get_sr();
}
else {
WriteOutput("Illegal register name %s\n", regname);
return;
}
if(!write) {
WriteOutput("%s = 0x%X\n", regname, val);
}
}
#ifdef TEST_KBD
// #define HD64465_BASE 0xA4C00000
#define SMSCR (HD64465_BASE + 0)
#define SCONFR (HD64465_BASE + 2)
#define KBD_BASE (HD64465_BASE + 0xDC00)
#define KBCSR (KBD_BASE + 0)
#define KBISR (KBD_BASE + 4)
#define MSCSR (KBD_BASE + 10)
#define MSISR (KBD_BASE + 14)
void Command_KbdMouseInit(void) {
#if ((SH_PLATFORM == PLATFORM_ASPEN)||(SH_PLATFORM==PLATFORM_BIGSUR))
*(volatile unsigned *)0xB8000000 |= 0x02000040;
*(volatile unsigned short *)SMSCR = 0x1bff;
*(volatile unsigned short *)SCONFR = 1700;
*(volatile unsigned short *)KBCSR = 0x8000;
*(volatile unsigned short *)MSCSR = 0x8000;
/* Clear any existing interrupt */
*(volatile unsigned short *)KBISR = 0x0001;
*(volatile unsigned short *)MSISR = 0x0001;
#endif ((SH_PLATFORM == PLATFORM_ASPEN)||(SH_PLATFORM==PLATFORM_BIGSUR))
}
#define INTR_MASK (*(volatile unsigned short *)0xA6000000) /* Interrupt Mask Register */
#define INTR_STAT (*(volatile unsigned short *)0xA6000002) /* Interrupt Status Register */
#define KBD_INTR 0x00000001 /* Keybd on IKAP1 */
#define MOUSE_INTR 0x00000002 /* Mouse on IKAP2 */
#define KBD_DATA (*(volatile unsigned char *)0xA3E40000)
#define KBD_STAT (*(volatile unsigned char *)0xA3E40008)
#if 0
/*****************************************************************************
* Function: KbdMouseInit
* Initialize the keyboard and mouse.
*****************************************************************************/
int KbdMouseInit(void)
{
unsigned short mask;
/* Unmask interrupts on keyboard mouse in the status register. */
WriteDbgOutput(DEB_KBD, ("+KbdMouseInit. initial mask = 0x%x\n", INTR_MASK));
INTR_MASK &= ~(KBD_INTR | MOUSE_INTR);
WriteDbgOutput(DEB_KBD, ("-KbdMouseInit. new mask = 0x%x\n", INTR_MASK));
KbdMouseInterruptEnable();
return 0;
}
#endif 0
int KbdMouseInterruptEnable()
{
unsigned char stat;
WriteDbgOutput(DEB_KBD, ("+Enabling keyboard/mouse interrupts. \n"));
// The optimizer just reuses KBD_STAT from a register on the second call
// ignoring that it is a volatile value.
// To remove that, i need to read stat first.
#if 1
stat = KBD_STAT; while(KBD_STAT & 0x02);
KBD_STAT = 0x60;
stat = KBD_STAT; while(KBD_STAT & 0x02);
KBD_DATA = 0x07;
#else
stat = KBD_STAT;
while(0x02 & stat)
stat = KBD_STAT;
KBD_STAT = 0x60;
stat = KBD_STAT;
while(0x02 & stat)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -