📄 sysinit.c
字号:
/***********************************************************************/
/* AdjustSysVars: Make any run-time adjustments necessary to the */
/* system variables */
/* */
/* NOTE: This should be called after the system variables have */
/* been "finalized" by reading from parameter storage and */
/* possibly being changed by the startup dialog */
/* */
/***********************************************************************/
static void AdjustSysVars(void)
{
#if (!SC_PSOS && !SC_PSOSM)
if (SysVars.DebugMode == DBG_AP)
{
#if SC_STARTUP_DIALOG
Print("Configured to run application, but pSOS+ not "
"present, so setting to stand-alone pROBE+\n");
#endif
SysVars.DebugMode = DBG_SA;
}
#endif
#if !(SC_PNA || SC_PNET)
if (SysVars.DebugMode == DBG_XN)
{
#if SC_STARTUP_DIALOG
Print("Operating mode was remote debug/networked, "
"but pNA not present\n");
Print("Setting pROBE+ mode to standalone!\n");
#endif
SysVars.DebugMode = DBG_SA;
}
#endif
#if !SC_RBUG_PORT
if (SysVars.DebugMode == DBG_XS)
{
#if SC_STARTUP_DIALOG
Print("Operating mode was remote debug/Serial, but "
"SC_RBUG_PORT is not set.\n");
Print("Setting pROBE+ mode to standalone!\n");
#endif
SysVars.DebugMode = DBG_SA;
}
#endif
#if !BSP_LAN1
if (SysVars.Lan1)
{
#if SC_STARTUP_DIALOG
Print("LAN interface requested, but BSP does not "
"support it\n");
#endif
SysVars.Lan1 = 0;
}
#endif
}
/***********************************************************************/
/* BuildConfigTables: Build the component configuration tables, using */
/* information from the system variables (SysVars). */
/* */
/* INPUT: FreeMemPtr - Pointer to first byte of available memory */
/* */
/***********************************************************************/
static UCHAR *BuildConfigTables(UCHAR *FreeMemPtr)
{
#if (SC_BOOT_ROM == YES)
oldanchor = (void *)0;
#else /* SC_BOOT_ROM */
oldanchor = rom_anchor;
#endif /* SC_BOOT_ROM */
/*---------------------------------------------------------------------*/
/* This is where the component's configuration functions are called */
/*---------------------------------------------------------------------*/
#if SC_PROBE
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = ProbeSetup(FreeMemPtr, &NodeCfg);
#endif
/*---------------------------------------------------------------------*/
/* Perform any BSP specific configuration functions. */
/* This should be done prior to calling PnaSetup & PnetSetup. */
/*---------------------------------------------------------------------*/
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = (UCHAR *)BspSetup(FreeMemPtr, &NodeCfg);
#if SC_PNA
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PnaSetup(FreeMemPtr, &NodeCfg);
#endif
#if ((!SC_PNA) && (SC_PNET))
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PnetSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PREPC
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PrepcSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PHILE
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PhileSetup(FreeMemPtr, &NodeCfg);
#endif
#if (SC_PRPC || SC_PSE_PRPC)
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PrpcSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PLM
FreeMemPtr = PlmSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PX
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PxSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PSE
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PseSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_PMONT
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PmontSetup(FreeMemPtr, &NodeCfg);
#endif
#if SC_POSIX
FreeMemPtr = PosixSetup(FreeMemPtr, &NodeCfg);
#endif
#if (SC_PSOS || SC_PSOSM)
/*-----------------------------------------------------------------*/
/* PsosSetup() must be called after all other Setup functions. */
/* */
/* If pSOS+ has been configured into the system, the FreeMemPtr is */
/* now part of pSOS+ region zero! So it can't be used to allocate */
/* any more memory after this. */
/*-----------------------------------------------------------------*/
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = PsosSetup(FreeMemPtr, &NodeCfg);
#endif
/*---------------------------------------------------------------------*/
/* Finally, finish up node configuration table and set node anchor to */
/* point to it. */
/*---------------------------------------------------------------------*/
NodeCfg.cputype = BspCpuType();
#if (BSP_FPU == YES)
NodeCfg.cputype |= 0x100;
#endif
#if (BSP_MMU == YES)
NodeCfg.cputype |= 0x200;
#endif
anchor = &NodeCfg;
#if (SC_BOOT_ROM == YES)
rom_anchor = &NodeCfg;
#endif /* SC_BOOT_ROM */
return(FreeMemPtr);
}
/***********************************************************************/
/* SysInit: Initialize system variables, conduct startup dialog */
/* if configured, and set up component configuration */
/* tables. */
/* */
/* NOTE: Interrupts are assumed to be disabled upon entry to */
/* this routine. */
/* */
/***********************************************************************/
void SysInit(void)
{
ULONG csum, magic,rc;
ULONG storage_update=FALSE;
UCHAR *FreeMemPtr, *LastByte;
#if BSP_NEW_SERIAL
ULONG error_flag
int i;
#endif
#if (SC_SD_PARAMETERS == SYS_CONF)
UCHAR DebugModeSv;
#endif
EXCResetInitialize();
/*---------------------------------------------------------------------*/
/* */
/*---------------------------------------------------------------------*/
/* Initialize the system variables. If SC_SD_PARAMETERS is STORAGE, */
/* we will attempt to read the variables from the parameter storage */
/* area. The parameter storage area is formatted as follows: */
/* */
/* | | */
/* |===========================| (lowest addr in parameter */
/* | "Magic #" (4 bytes) | storage area) */
/* |===========================| */
/* | SysVars checksum (4 bytes)| */
/* |---------------------------| */
/* | SysVars | */
/* |===========================| */
/* | BspVars checksum (4 bytes)| */
/* |---------------------------| */
/* | BspVars | */
/* |===========================| */
/* | AppVars checksum (4 bytes)| */
/* |---------------------------| */
/* | AppVars | */
/* |===========================| */
/* | | */
/* */
/* BspVars is only present if BSP_PARMS is non-zero (bsp.h) */
/* AppVars is only present if SC_APP_PARMS is non-zero (sys_conf.h) */
/* */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Check that the parameters will fit. "60" is the size of SysVars. */
/*---------------------------------------------------------------------*/
#if ((60 + BSP_PARMS + SC_APP_PARMS + 16) > 256)
#error "Too many parameters to fit in parameter storage area"
#endif
StorageRead(sizeof(NVVars), 0, &NVVars);
magic = NVVars.magic;
csum = NVVars.SysVars_CheckSum;
if ((csum != CheckSum(&SysVars, sizeof(SysVars))) || (magic != MAGIC))
{
storage_update = TRUE;
SysVars = SysVarsDefaults;
}
#if (SC_SD_PARAMETERS == SYS_CONF)
DebugModeSv = SysVars.DebugMode;
SysVars = SysVarsDefaults;
SysVars.DebugMode = DebugModeSv;
#endif
#if (SC_SD_DEBUG_MODE != STORAGE)
SysVars.DebugMode = SC_SD_DEBUG_MODE;
#endif
if ((SysVars.DebugMode > 4) || (SysVars.DebugMode < 1))
SysVars.DebugMode = 1;
#if BSP_PARMS
csum = NVVars.BspVars_CheckSum;
if ((csum != CheckSum(BspVars, BSP_PARMS)) || (magic != MAGIC))
{
storage_update = TRUE;
BspGetdefaults(BspVars);
}
#if (SC_SD_PARAMETERS == SYS_CONF)
BspGetdefaults(BspVars);
#endif
#endif
#if SC_APP_PARMS
csum = NVVars.AppVars_CheckSum;
if ((csum != CheckSum(AppVars, SC_APP_PARMS)) || (magic != MAGIC))
{
storage_update = TRUE;
AppGetdefaults(AppVars);
}
#if (SC_SD_PARAMETERS == SYS_CONF)
AppGetdefaults(AppVars);
#endif
#endif
/*---------------------------------------------------------------------*/
/* Initialize the polled serial driver so we can use Print() to print */
/* messages out. The polled serial driver will also be needed for the */
/* configuration dialog if it is configured. */
/*---------------------------------------------------------------------*/
#if !BSP_NEW_SERIAL
Delay100ms();
SerialSetup(SysVars.DefBaud, PROBE_CON_SER_PORT, SC_RBUG_PORT);
SerialPollInit();
SerialPollOn();
Delay100ms();
#else
SysBaud = SysVars.DefBaud;
SysConsole = SC_APP_CONSOLE;
#endif
/*---------------------------------------------------------------------*/
/* The memory starting at "FreeMemStart" is available for allocation. */
/* Call any high-level drivers that are configured so they can grab */
/* some of this memory if they need it. This technique allows us to */
/* build systems in which the drivers use different numbers of buffers */
/* without having to re-compile the drivers. */
/*---------------------------------------------------------------------*/
FreeMemPtr = FreeMemStart;
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
#if SC_RAM_SIZE
LastByte = (UCHAR *)(SC_RAM_SIZE + BSP_RAM_BASE - 1);
#else
LastByte = (UCHAR *)(RamSize() + (ULONG)BSP_RAM_BASE - 1UL);
#endif
#if BSP_NEW_SERIAL
/*-----------------------------------------------------------------*/
/* Set the variables ProbeCon and ProbeHst to pe used by dipi */
/* driver. */
/*-----------------------------------------------------------------*/
ProbeCon = PROBE_CON_SER_PORT;
ProbeHst = SC_RBUG_PORT;
/*-----------------------------------------------------------------*/
/* Initialize the General Serial Messaage block manager */
/*-----------------------------------------------------------------*/
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = GSblkSetup(FreeMemPtr, (ULONG)LastByte, &error_flag);
/*-----------------------------------------------------------------*/
/* Initialize the lower serial driver. */
/*-----------------------------------------------------------------*/
SerialInit();
/*-----------------------------------------------------------------*/
/* Set up the "non pSOS serial ports" variables. */
/*-----------------------------------------------------------------*/
NumNon_pSOSChan = SC_NumNon_pSOSChan;
i = 0;
#if PROBE_CON_SER_PORT != 0
Non_pSOSChan[i++] = PROBE_CON_SER_PORT;
#endif
#if SC_RBUG_PORT != 0
Non_pSOSChan[i++] = SC_RBUG_PORT;
#endif
if (NumNon_pSOSChan < i)
NumNon_pSOSChan = i;
#endif
#if !BSP_NEW_SERIAL && BSP_PARALLEL
FreeMemPtr = (UCHAR *)ALIGN((ULONG)FreeMemPtr, 4);
FreeMemPtr = GSblkSetup(FreeMemPtr, (ULONG)LastByte, &error_flag);
#endif
# if BSP_NEW_SERIAL
ProbeIOInit();
# endif
/*---------------------------------------------------------------------*/
/* If GSblkSetup returned error, Print out the error message. */
/*---------------------------------------------------------------------*/
# if (BSP_NEW_SERIAL || BSP_PARALLEL)
if (error_flag)
{
while(1)
{
ULONG i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -