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

📄 dm_edit.c

📁 优龙YLP270开发板 光盘自带的BIOS和实验例程源码 强烈推荐
💻 C
📖 第 1 页 / 共 4 页
字号:
/******************************************************************************
**
**  COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
**  This software as well as the software described in it is furnished under 
**  license and may only be used or copied in accordance with the terms of the 
**  license. The information in this file is furnished for informational use 
**  only, is subject to change without notice, and should not be construed as 
**  a commitment by Intel Corporation. Intel Corporation assumes no 
**  responsibility or liability for any errors or inaccuracies that may appear 
**  in this document or any software that may be provided in association with 
**  this document. 
**  Except as permitted by such license, no part of this document may be 
**  reproduced, stored in a retrieval system, or transmitted in any form or by 
**  any means without the express written consent of Intel Corporation. 
**
**  FILENAME:       dm_edit.c
**
**  PURPOSE:        This file contains the Diagnostic Manager memory editor.
**
**  LAST MODIFIED:  $Modtime: 7/17/03 1:01p $
******************************************************************************/

/*
*******************************************************************************
*   HEADER FILES
*******************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "systypes.h"
#include "dm_debug.h"
#include "dm_edit.h"
//#include "globals.h"
#include "cotulla.h"
//#include "UCB1400_Touch.h"
#include "xsuart.h"
#include "DM_Serialinout.h"
#include "stdinout.h"
#include "intelFlashAPI.h"
#include "intelFlash.h"

/*
*******************************************************************************
*   EXTERNAL DECLARATION
*******************************************************************************
*/
extern BOOL gMenuEnabled;

/*
*******************************************************************************
*   LOCAL DEFINITIONS
*******************************************************************************
*/
static void searchMemory(BOOL forward);
static void memoryDump(void);
static UINT32 getMemValue(void);
static UINT32 GetHex(UINT places, UCHAR entryPos);
static UINT32 GetDecimal(UINT places, UCHAR entryPos);
static PUINT32 viewAddrP = 0;
static UINT32 writeValue = 0;
static UINT32 dumpLength = 64;
static UINT32 fillLength = 0;
static PCHAR srcAddrP = 0;
static PCHAR destAddrP = 0;
static UINT32 copyLength = 0;
static UINT32 compareLength = 0;
static PUINT32 searchAddrP = 0;
static UINT32 searchValue = 0;
static UINT32 searchLength = 1024*1024;
static UINT32 memoryWidth = 32;
static Intel_Flash_ContextT * flashCtxP = NULL;

/*
*******************************************************************************
*
* FUNCTION:
*    GetParameters
*
* DESCRIPTION:
*    This routine parses the input string to determine the parameters.
*
* INPUT PARAMETERS:
*    LAN91C96_ContextT *ctxP - Pointer to the LAN91C96 Device Context Structure.
*    PCHAR arg - Pointer to device parameters.
*
*              ":MEMEDIT.VIEW,50400000^M" - Display memory at 0x50400000
* 
*              ":MEMEDIT.HIGHER^M" - Display next higher address region
*
*              ":MEMEDIT.LOWER^M" - Display next lower address region
*
*              ":MEMEDIT.WRITE,50400000,33333333^M" - Write the value 0x33333333
*              into location 0x50400000.
*
*              ":MEMEDIT.FILL,50400000,00100000,33333333^M" - Write the value
*              0x33333333 into locations 0x50400000 to 504FFFFF.
*
*              ":MEMEDIT.COPY,50400000,60400000,00100000^M" - Copy the memory
*              block 0x50400000 - 0x50500000 to 0x60400000 - 0x60500000.
*
*              ":MEMEDIT.COMPARE,50400000,60400000,00100000^M" - Compare the memory
*              block 0x50400000 - 0x50500000 to 0x60400000 - 0x60500000.
*
*              ":MEMEDIT.LENGTH,00000100^M" - Set display region length to
*              0x00000100.
*
*              ":MEMEDIT.SEARCH,50400000,33333333^M" - Search memory for the
*              value 0x33333333.
*
*              ":MEMEDIT.SEARCHHIGHER^M" - Search next higher address region.
*
*              ":MEMEDIT.SEARCHLOWER^M" - Search next lower address region.
*
*              ":MEMEDIT.SEARCHLENGTH,00100000" - Search a 0x00100000 memory
*              region.
*
*              ":MEMEDIT.WIDTH,32^M" - Set memory width to 8-bit, 16-bit or
*              32-bit.
*
* RETURNS:
*    TRUE - success.
*    FALSE - failure.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    sscanf, DM_ErrPrintf, LOGERROR, DM_DbgPrintf
*
* CALLED BY:
*    LAN91C96_SetMAMAddress
*
* PROTOTYPE:
*    static BOOL GetParameters(LAN91C96_ContextT *ctxP, PCHAR arg);
*
*******************************************************************************
*/
static
BOOL GetParameters(PCHAR arg, FunctionT func)
{
    // Assume user input required.
    BOOL flag = TRUE;

    if (arg == NULL)
    {
        flag = FALSE;
    }
    else
    {
        switch (func)
        {
            case MemEditView:    // ":MEMEDIT.VIEW,50400000^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Parameter string: %s", arg);

                // Check parameter
                if (sscanf(arg, "%x", (PUINT32)&viewAddrP) != 1)
                {
                    flag = FALSE;
                }
                break;

            case MemEditWrite:    // ":MEMEDIT.WRITE,50400000,33333333"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "First Parameter string: %s", arg);

                // Check first parameter
                if (sscanf(arg, "%x", (PUINT32)&viewAddrP) != 1)
                {
                    flag = FALSE;
                }
                else
                {
                    // Get next parmeter.
                    arg = SysCmdPaFindNextParam(arg);

                    DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Second Parameter string: %s", arg);

                    // Check second parameter
                    if (sscanf(arg, "%x", &writeValue) != 1)
                    {
                        flag = FALSE;
                    }
                }
                break;

            case MemEditLength:    // ":"MEMEDIT.LENGTH^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Parameter string: %s", arg);

                // Check parameter
                if (sscanf(arg, "%x", &dumpLength) != 1)
                {
                    flag = FALSE;
                }
                break;

            case MemEditFill:     // ":MEMEDIT.FILL,50400000,00100000,33333333^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "First Parameter string: %s", arg);

                // Check first parameter
                if (sscanf(arg, "%x", (PUINT32)&viewAddrP) != 1)
                {
                    flag = FALSE;
                }
                else
                {
                    // Get next parmeter.
                    arg = SysCmdPaFindNextParam(arg);

                    DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Second Parameter string: %s", arg);

                    // Check second parameter
                    if (sscanf(arg, "%x", &fillLength) != 1)
                    {
                        flag = FALSE;
                    }
                    else
                    {
                        // Get next parmeter.
                        arg = SysCmdPaFindNextParam(arg);

                        DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Third Parameter string: %s", arg);

                        // Check third parameter
                        if (sscanf(arg, "%x", &writeValue) != 1)
                        {
                            flag = FALSE;
                        }
                    }
                }
                break;

            case MemEditCopy:     // ":MEMEDIT.COPY,50400000,60400000,00100000^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "First Parameter string: %s", arg);

                // Check first parameter
                if (sscanf(arg, "%x", (PCHAR)&srcAddrP) != 1)
                {
                    flag = FALSE;
                }
                else
                {
                    // Get next parmeter.
                    arg = SysCmdPaFindNextParam(arg);

                    DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Second Parameter string: %s", arg);

                    // Check second parameter
                    if (sscanf(arg, "%x", (PCHAR)&destAddrP) != 1)
                    {
                        flag = FALSE;
                    }
                    else
                    {
                        // Get next parmeter.
                        arg = SysCmdPaFindNextParam(arg);

                        DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Third Parameter string: %s", arg);

                        // Check third parameter
                        if (sscanf(arg, "%x", &copyLength) != 1)
                        {
                            flag = FALSE;
                        }
                    }
                }
                break;

            case MemEditCompare:     // ":MEMEDIT.COMPARE,50400000,60400000,00100000^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "First Parameter string: %s", arg);

                // Check first parameter
                if (sscanf(arg, "%x", (PCHAR)&srcAddrP) != 1)
                {
                    flag = FALSE;
                }
                else
                {
                    // Get next parmeter.
                    arg = SysCmdPaFindNextParam(arg);

                    DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Second Parameter string: %s", arg);

                    // Check second parameter
                    if (sscanf(arg, "%x", (PCHAR)&destAddrP) != 1)
                    {
                        flag = FALSE;
                    }
                    else
                    {
                        // Get next parmeter.
                        arg = SysCmdPaFindNextParam(arg);

                        DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Third Parameter string: %s", arg);

                        // Check third parameter
                        if (sscanf(arg, "%x", &compareLength) != 1)
                        {
                            flag = FALSE;
                        }
                    }
                }
                break;

            case MemEditWidth:    // "MEMEDIT.WIDTH,32^M" 

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Parameter string: %s", arg);

                // Check parameter
                if (sscanf(arg, "%d", &memoryWidth) != 1)
                {
                    flag = FALSE;
                }
                break;

            case MemEditSearch:    // ":MEMEDIT.SEARCH,50400000,33333333"^M"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "First Parameter string: %s", arg);

                // Check first parameter
                if (sscanf(arg, "%x", (PUINT32)&searchAddrP) != 1)
                {
                    flag = FALSE;
                }
                else
                {
                    // Get next parmeter.
                    arg = SysCmdPaFindNextParam(arg);

                    DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Second Parameter string: %s", arg);

                    // Check second parameter
                    if (sscanf(arg, "%x", &searchValue) != 1)
                    {
                        flag = FALSE;
                    }
                }
                break;

            case MemEditSearchLength:    // "MEMEDIT.SEARCHLENGTH,00100000"

                DM_CwDbgPrintf(DM_CW_MEMEDIT_0, "Parameter string: %s", arg);

                // Check parameter
                if (sscanf(arg, "%x", &searchLength) != 1)
                {
                    flag = FALSE;
                }
                break;

            case MemEditHigher:            // ":MEMEDIT.HIGHER^M"
            case MemEditLower:             // ":MEMEDIT.LOWER^M"
            case MemEditSearchHigher:      // "MEMEDIT.SEARCHHIGHER^M"
            case MemEditSearchLower:       // "MEMEDIT.SEARCHLOWER^M"
                break;
        }
    }

    return (flag);
}

/*----------------------------------------------------------------------
 * View memory - This function is called directly from the menu system.
 */

void DM_ViewMemory(void *menuP, char *arg)
{
    // Disable the menus from being displayed.
    gMenuEnabled = FALSE;

    // Check parameters.
    if (!GetParameters(arg, MemEditView))
    {
        // Ask user for address.
        printf("Enter address: 0x");
        viewAddrP = (PUINT32)GetHex(8, 52);
    }

    // Display memory.
    memoryDump();
}

/*----------------------------------------------------------------------
 * Scroll higher in memory - This function is called directly from the menu system.
 */

void DM_HigherMemory(void *funcP, char *arg)
{
    // Disable the menus from being displayed.
    gMenuEnabled = FALSE;

⌨️ 快捷键说明

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