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

📄 dialog.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的操作系统pSOS。包括全部源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************//*                                                                     *//*   MODULE:  dialog.c   1.3                                                *//*   DATE:    17:57:12 - 97/12/05                                                *//*   PURPOSE: Startup configuration dialog                             *//*                                                                     *//*---------------------------------------------------------------------*//*                                                                     *//*          Copyright 1991 - 1995, 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 "sys_conf.h"void Dialog (void);#if SC_STARTUP_DIALOG#include "bsp.h"#include <bspfuncs.h>#include <apdialog.h>#include <sysvars.h>#include <version.h>#include <stdarg.h>#include <pna.h>/*---------------------------------------------------------------------*//* General Definitions                                                 *//*---------------------------------------------------------------------*/#define UCHAR   unsigned char#define USHORT  unsigned short#define ULONG   unsigned long#define TRUE 1#define FALSE 0#if BSP_PARMSextern UCHAR BspVars[BSP_PARMS];#endif#if SC_APP_PARMSextern UCHAR AppVars[SC_APP_PARMS];#endifextern struct SD_parms SysVars;/*---------------------------------------------------------------------*//* Prototypes of External Functions                                    *//*---------------------------------------------------------------------*/extern void Prompt(char *, PARM_TYPE, void *);#if BSP_NEW_SERIAL    #define SerialPollConsts ProbeConsts    #define SerialPollConin ProbeConin    extern ULONG SerialPollConsts(ULONG);    extern UCHAR SerialPollConin(void);#endif/*---------------------------------------------------------------------*//* Prototypes of Local Functions                                       *//*---------------------------------------------------------------------*/static void PrintLan1Params(void);static void PrintNismParams(UCHAR *NodeNrPrinted);#if (BSP_SMEM && SC_PNA)static void GetSmemParams(UCHAR *GotNodeNr);#endif/***********************************************************************//*        copy: Copy memory                                            *//*                                                                     *//*      INPUTS: dstp = pointer to destination                          *//*              srcp = pointer to source                               *//*              str_len = number of bytes to copy                      *//*                                                                     *//***********************************************************************/static void copy(void *dstp, void *srcp, long str_len){char *dst, *src;dst = (char *)dstp;src = (char *)srcp;while (str_len--)   *dst++ = *src++;}/***********************************************************************//* SysVarsPrint: Print out the current values of SysVars               *//*                                                                     *//***********************************************************************/static void SysVarsPrint(void){#if SC_PNAUCHAR SmNodeDisplayed;#endifchar *ptr, AppName[80];#ifdef SC_APP_NAME    copy(AppName, SC_APP_NAME, 80);#else    copy(AppName, "Application", 80);#endifprintf("----------------------------------------------------------------"      "----------\n");/*---------------------------------------------------------------------*//* Print out the operating mode (SysVars.DebugMode)                    *//*---------------------------------------------------------------------*/#if SC_PROBEprintf("STARTUP MODE:\n");switch(SysVars.DebugMode)    {    case DBG_SA:        printf("  Boot into pROBE+ standalone mode\n");        break;    case DBG_XS:        printf("  Boot into pROBE+ and wait for host debugger via a"              " serial connection\n");        break;#if SC_PNA    case DBG_XN:        printf("  Boot into pROBE+ and wait for host debugger via a"         " network connection\n");        break;#endif#if (SC_PSOS || SC_PSOSM)    case DBG_AP:        printf("  Run the %s\n", AppName);        break;#endif    default:        printf("  Unsupported debug mode\n");        break;    }#elseSysVars.DebugMode = DBG_AP;   /* without pROBE, there's really only one choice... */#endif/*---------------------------------------------------------------------*//* Print out the networking-related parameters                         *//*---------------------------------------------------------------------*/#if SC_PNA    printf("NETWORK INTERFACE PARAMETERS:\n");    SmNodeDisplayed = 0;#   if BSP_LAN1        PrintLan1Params();#   endif#   if BSP_SMEM        PrintNismParams(&SmNodeDisplayed);#   endif#   if (!BSP_LAN1 && !BSP_SMEM)        printf("  (Board has no network interfaces)\n");#   endif    if (SysVars.DefGtwyIP)        printf("  IP address of default gateway to other networks is %I\n",              SysVars.DefGtwyIP);#endif/*---------------------------------------------------------------------*//* Print out the multi-processing (pSOS+m) parameters                  *//*---------------------------------------------------------------------*/#if BSP_SMEMprintf("\MULTIPROCESSING PARAMETERS:\n");if (SysVars.Kism)    {    printf("  This will be node %d in a %d-node pSOS+m system\n",          SysVars.SmNode, SysVars.Kism);    printf("  KI directory will be at bus address 0x%x \n",          SysVars.KismDiraddr);    }else    printf("  This board is currently configured as a single "          "processor system\n");#endif/*---------------------------------------------------------------------*//* Print out the hardware-specific parameters                          *//*---------------------------------------------------------------------*/printf("HARDWARE PARAMETERS:\n");printf("  Serial channels will use a baud rate of %d\n", SysVars.DefBaud);#if BSP_VME    printf("  This board's memory will reside at 0x%x on the VME bus\n",          SysVars.VmeBaseAddr);#endif#if BSP_PARMS    BspPrint(BspVars, (void *)Print);#endif/*---------------------------------------------------------------------*//* Print out application-specific parameters                           *//*---------------------------------------------------------------------*/#if SC_APP_PARMS    if (SysVars.DebugMode == DBG_AP)        {        ptr = AppName;        while (*ptr)       /* Convert application name to upper case */            {            if ((*ptr >= 'a') && (*ptr <= 'z'))                *ptr = *ptr - 0x20;            ptr++;            }        printf("%s PARAMETERS:\n", AppName);        AppPrint(AppVars, Print);        }#endifprintf("  After board is reset, startup code will wait %d seconds\n",      SysVars.StartupDelay);printf("----------------------------------------------------------------"      "----------\n");}/***********************************************************************//* PrintLan1Params: Print the current value of LAN-related system      *//*                  variables                                          *//*                                                                     *//*        NOTE: Prints the following members of SysVars: Lan1,         *//*              Lan1IP, Lan1SubnetMask                                 *//*                                                                     *//***********************************************************************/#if BSP_LAN1static void PrintLan1Params(void){if (SysVars.Lan1)    {    if (SysVars.Lan1IP == 0)        printf("  LAN IP address will be obtained from RARP \n");    else        printf("  IP address on LAN is %I\n", SysVars.Lan1IP);    if (SysVars.Lan1SubnetMask)        printf("  LAN interface's subnet mask is 0x%x\n",              SysVars.Lan1SubnetMask);    }else    printf("  LAN interface is disabled\n");}#endif/***********************************************************************//* PrintNismParams: Print the current value of SMNI-related system     *//*                  variables                                          *//*                                                                     *//*      INPUTS: *NodeNrPrinted = TRUE if node nr has been displayed    *//*               already                                               *//*                                                                     *//*     OUTPUTS: *NodeNrPrinted = set to TRUE if this routine           *//*               displays the node number.                             *//*        NOTE: Prints the following members of SysVars: Nism,         *//*              NismIP, NismSubnetMask, NismDiraddr.  Also (maybe)     *//*              SmNode.                                                *//*                                                                     *//***********************************************************************/#if BSP_SMEMstatic void PrintNismParams(UCHAR *NodeNrPrinted){if (SysVars.Nism)    {    printf("  IP address on shared memory is %I\n", SysVars.NismIP);    if (SysVars.NismSubnetMask)        printf("  Shared memory interface's subnet mask is 0x%x\n",              SysVars.NismSubnetMask);    printf("  Bus address of SMNI directory is 0x%x\n", SysVars.NismDiraddr);    if (*NodeNrPrinted == 0)        {        printf("  This is node number %d in the shared memory system\n",              SysVars.SmNode);        *NodeNrPrinted = 1;        }    }else    printf("  Shared memory interface is disabled\n");}#endif/***********************************************************************//*    snmsk_ok: Determine whether a subnet mask is valid               *//*                                                                     *//*      INPUTS: ip = IP address of interface                           *//*              snmsk = Subnet mask to check                           *//*                                                                     *//*     RETURNS: TRUE if subnet mask is valid, FALSE if not             *//*       NOTES: To be valid, subnet mask must meet the following       *//*              conditions:                                            *//*                1) All bits which are set must be to the left of     *//*                   all bits which are clear.                         *//*                2) If bits are set, they must cover all of the       *//*                   "host" bits in the network address.               *//*                3) 0 is considered a valid subnet mask.              *//*                                                                     *//***********************************************************************/#if SC_PNAstatic UCHAR snmsk_ok(ULONG ip, ULONG snmsk){int bitpos;int nr_onebits;/*---------------------------------------------------------------------*//* Subnet mask of 0 is OK                                              *//*---------------------------------------------------------------------*/if (snmsk == 0) return 1;/*---------------------------------------------------------------------*//* Check that all bits which are set are higher-order than those which *//* aren't set.  In other words, all 1 bits must come before all of the *//* 0 bits.                                                             *//*---------------------------------------------------------------------*/bitpos = 31;nr_onebits = 0;while ((bitpos >= 0) && (((snmsk >> bitpos) & 1) == 1))    {    bitpos--;    nr_onebits++;    }while ((bitpos >= 0) && (((snmsk >> bitpos) & 1) == 0))    bitpos--;if (bitpos != -1) return 0;/*---------------------------------------------------------------------*//* Finally, check that the subnet mask is correct for the class of     *//* network that "ip" belongs to.                                       *//*---------------------------------------------------------------------*/if (IN_CLASSC(ip) && (nr_onebits < 24)) return 0;if (IN_CLASSB(ip) && (nr_onebits < 16)) return 0;if (IN_CLASSA(ip) && (nr_onebits <  8)) return 0;return 1;}#endif/***********************************************************************//* GetLan1Params: Get the parameters for the LAN interface             *//*                                                                     *//*     OUTPUTS:  SysVars.Lan1, SysVars.Lan1IP, and                     *//*               SysVars.Lan1SubnetMask are updated                    *//*                                                                     *//***********************************************************************/#if (SC_PNA && BSP_LAN1)static void GetLan1Params(void){UCHAR ans, ErrFlag;/*---------------------------------------------------------------------*//* Find out if they want a LAN interface at all.                       *//*---------------------------------------------------------------------*/Prompt("Do you want a LAN interface? ", FLAG, &(SysVars.Lan1));/*---------------------------------------------------------------------*//* LAN IP address                                                      *//*---------------------------------------------------------------------*/if (SysVars.Lan1)    Prompt("This board's LAN IP address(0.0.0.0 = RARP)?",           IP, &(SysVars.Lan1IP));/*---------------------------------------------------------------------*//* LAN Subnet mask                                                     *//*---------------------------------------------------------------------*/if (SysVars.Lan1)    {    ans = 'N';    if (SysVars.Lan1SubnetMask == 0)        Prompt("Use a subnet mask for the LAN interface? ", CHAR, &ans);    else        ans = 'Y';    if ((ans == 'Y') || (ans == 'y'))        {        do            {            Prompt("Subnet mask for LAN (0 for none)?",              HEX, &(SysVars.Lan1SubnetMask));            ErrFlag = FALSE;            if (!snmsk_ok(SysVars.Lan1IP, SysVars.Lan1SubnetMask))                {                printf("That is not a valid subnet mask\a\n");

⌨️ 快捷键说明

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