📄 board.c
字号:
/* @(#) pSOSystem MIPS/V2.5.0: bsps/lsi4101/src/board.c (&U&) 4.10 99/02/11 13:04:35 */
/***********************************************************************/
/* */
/* MODULE: bsps/lsi4101/src/board.c */
/* DATE: 99/02/11 */
/* PURPOSE: Board specific routines for board initialization. */
/* */
/*---------------------------------------------------------------------*/
/* */
/* Copyright 1991 - 1999, Integrated Systems, Inc. */
/* ALL RIGHTS RESERVED */
/* */
/* Permission is hereby granted to licensees of Integrated Systems, */
/* Inc. products to use or abstract this computer program for the */
/* sole purpose of implementing a product based on Integrated */
/* Systems, Inc. products. No other rights to reproduce, use, */
/* or disseminate this computer program, whether in part or in */
/* whole, are granted. */
/* */
/* Integrated Systems, Inc. makes no representation or warranties */
/* with respect to the performance of this computer program, and */
/* specifically disclaims any responsibility for any damages, */
/* special or consequential, connected with the use of this program. */
/* */
/*---------------------------------------------------------------------*/
/* */
/* */
/* */
/***********************************************************************/
#include "bsp.h"
#include <bspfuncs.h>
#include "board.h"
#include <psos.h>
#include <configs.h>
#include <disi.h>
#include "dp83932.h"
/*---------------------------------------------------------------------*/
/* Symbol Definitions */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* General Definitions */
/*---------------------------------------------------------------------*/
void (*pSOSIEnter)(); /* Func Ptr for pSOS I_ENTER */
void (*pSOSIReturn)(); /* Func Ptr for pSOS I_RETURN*/
void (*pMontIEnter)(); /* Func Ptr for pMont I_ENTER */
void (*pMontIReturn)(); /* Func Ptr for pMont I_RETURN*/
/*---------------------------------------------------------------------*/
/* Data Structures for Serial Multiplexor */
/*---------------------------------------------------------------------*/
extern void M68681Init();
extern long M68681Open();
extern long M68681Send();
extern long M68681Ioctl();
extern long M68681Close();
/*---------------------------------------------------------------------*/
/* Global Variables */
/*---------------------------------------------------------------------*/
static jmp_buf fault_buf;
volatile ULONG lastip;
/*---------------------------------------------------------------------*/
/* External Declarations */
/*---------------------------------------------------------------------*/
extern reg_t *jmpBufPtr;
extern unsigned char FreeMemStart[];
extern unsigned long cpu_type;
extern unsigned long memsize;
unsigned long PmontBaudRate;
/***********************************************************************/
/* InitBoard: Initialize the LSI4101 */
/* */
/* INPUTS: NONE */
/* */
/***********************************************************************/
void InitBoard(void)
{
/*---------------------------------------------------------------------*/
/* Set up the default exception handlers. */
/*---------------------------------------------------------------------*/
vectorSetup();
/*---------------------------------------------------------------------*/
/* Initialize all the ISR handler table to a null dummy ISR handler. */
/*---------------------------------------------------------------------*/
IsrInit();
/*---------------------------------------------------------------------*/
/* Clear pSOS & pMONT entry and exit function pointers just to be sure */
/*---------------------------------------------------------------------*/
pSOSIEnter = (void (*)()) 0;
pSOSIReturn = (void (*)()) 0;
pMontIEnter = (void (*)()) 0;
pMontIReturn = (void (*)()) 0;
}
/***********************************************************************/
/* FlushInvalidateCaches: Flush data in the data cache from Address */
/* to Address+Size and invalidate it in the */
/* instruction cache */
/* */
/* INPUTS: unsigned long Address */
/* unsigned long Size */
/* */
/***********************************************************************/
void FlushInvalidateCaches(ULONG Address, ULONG Size)
{
/*--------------------------------------------------------------*/
/* The R4101 processor implements a write-through cache. There- */
/* fore, we can be sure that memory is up to date and there is */
/* nothing to flush (except the write buffer). However, we do */
/* have to invalidate all instruction cache entries correspon- */
/* ding to the given address range in case code has been modi- */
/* fied (e.g. a breakpoint was set or removed): */
/*--------------------------------------------------------------*/
SysInvalidateICache((void *) Address, Size);
wbflush();
}
/***********************************************************************/
/* BspCpuType: Return processor-type code. */
/* or with 0x400 which indicates this BSP supports */
/* 16bit ISA */
/* */
/* RETURNS: processor type (see bspfuncs.h) */
/* */
/***********************************************************************/
unsigned long BspCpuType(void)
{
return((cpu_type | 0x400)); /* This BSP supports 16bit ISA */
}
/***********************************************************************/
/* BspRamBase: Return the starting address of the board's RAM, */
/* as seen by the processor. */
/* */
/* RETURNS: DRAM base address. */
/* */
/***********************************************************************/
ULONG BspRamBase(void)
{
return(BSP_RAM_BASE);
}
/***********************************************************************/
/* GetRamSize: Estimate the size of onboard RAM */
/* */
/* RETURNS: RAM size in bytes */
/* */
/***********************************************************************/
#define PGSIZE (4*1024)
#define PGOFSET (PGSIZE-1)
#define PATTERN1 0xbeefdead
#define PATTERN2 0xdeadbeef
ULONG GetRamSize(void)
{
volatile unsigned long *ip,temp,temp1;
volatile register unsigned long junk=0;
if (bsp_setjmp(fault_buf)) /* we get here in case of exception */
{
jmpBufPtr = 0;
if(lastip < K0_TO_K1(BD_DRAM_ADDR))
return(BD_SRAM_SIZE); /* Fix for bug in SRAM PAL logic. */
else
return (K1_TO_PHYS(lastip));
}
else
{
/*
** Look for end of memory.
*/
for(ip = (unsigned long *)K0_TO_K1((unsigned long)(FreeMemStart + PGSIZE) & ~PGOFSET);;ip += PGSIZE/sizeof(*ip))
{
lastip = (unsigned long) ip;
temp1 = *ip; /* save current memory contents */
*ip = 0; /* write will not cause an exception */
junk += *ip; /* read will ... */
temp = *(ip + 4); /* save current memory contents */
*(ip + 4) = PATTERN1; /* write pattern into memory */
*ip = 0; /* make sure the previous write */
junk = *ip; /* gets into memory */
junk = *(ip + 4); /* read memory back */
*ip = temp1; /* restore what was in before */
*(ip + 4) = temp;
if (junk != PATTERN1) /* if not equal, it's no RAM */
{
jmpBufPtr = 0;
return (K1_TO_PHYS(lastip));
}
}
}
}
/***********************************************************************/
/* RamSize: Get the size of onboard DRAM */
/* */
/* RETURNS: DRAM size in bytes */
/* */
/***********************************************************************/
ULONG RamSize(void)
{
return memsize;
}
/***********************************************************************/
/* SysInitFail: Report a system initalization failure */
/* */
/* INPUTS: pointer to a character string that contains error */
/* string. */
/* */
/* RETURNS: NEVER RETURNS */
/* OUTPUTS: continually prints a error string */
/* NOTE(S): */
/* This function is called during system startup from */
/* files in the configs/std directory when an */
/* unrecoverable error occurs. */
/* */
/***********************************************************************/
void SysInitFail(const char *string)
{
const char *ptr;
long i;
/*ProbeIOInit();*/
for (;;)
{
ptr = string;
while (*ptr)
/*ProbeConout(*ptr++);*/
/*ProbeConout('\n');*/
/*ProbeConout('\r');*/
for (i = 1; i <= 10; i++)
Delay100ms();
}
}
/***********************************************************************/
/* */
/* BoardSysStartCO: Called during pSOS+ startup. Can be used to clear */
/* the BOARD specific structures and device structures*/
/* */
/* INPUT: none */
/* OUTPUT: none */
/* RETURNS: none */
/* */
/***********************************************************************/
void BoardSysStartCO(void)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -