halnok.c

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C语言 代码 · 共 66 行

C
66
字号
#include <windows.h>
#include "nkintr.h"
#include "platform.h"
#include "drv_glob.h"
#include "drv_glob.h"
#include "halether.h"
#include "ethdbg.h"

#define pDriverGlobals  ((PDRIVER_GLOBALS) DRIVER_GLOBALS_PHYSICAL_MEMORY_START)
static BOOL DebugEtherPresent;


void InitDebugEther (void)
{

    // Initialize ethernet debug support.  This requires that the ethernet
    // bootloader (eboot) is loaded.  Check for magic cookie in uninitialized
    // section of driver globals to determine if eboot is present or not.  If
    // not, don't touch the ethernet HW (will hang if FPGA doesn't have ether support).
    if ( pDriverGlobals->eth.EbootMagicNum == EBOOT_MAGIC_NUM ) {
        // Eboot is present, attempt to init the ethernet HW.  If the ethernet card
        // is not present, EdbgInit will return failure. Also, this will
        // read our IP and ethernet address from the serial EEPROM on the ethernet board.
        EdbgOutputDebugString("Ethernet bootloader present, peer IP address: %s\r\n",
                              inet_ntoa(pDriverGlobals->eth.DownloadHostAddr.dwIP));
        if ( EdbgInit() ) {
            OEMWriteDebugString(TEXT("Debug ethernet card initialized\r\n"));
            DebugEtherPresent = 1;

            // Attempt to configure debug services over ethernet.  SetKernelCommDev will block
            // (calling EdbgRegisterDfltClient) until the desktop application is started, and
            // will set up the necessary kernel hooks to route data to the peer.
            if ( (pDriverGlobals->eth.etherFlags & EDBG_FL_DBGMSG) && 
                 SetKernelCommDev(KERNEL_SVC_DBGMSG,KERNEL_COMM_ETHER) ) {
                EdbgOutputDebugString("Switched to ethernet for debug messages, host: %s, port: %d\r\n",
                                      inet_ntoa(pDriverGlobals->eth.DbgHostAddr.dwIP),
                                      ntohs(pDriverGlobals->eth.DbgHostAddr.wPort));
            }
            if ( (pDriverGlobals->eth.etherFlags & EDBG_FL_PPSH) &&
                 SetKernelCommDev(KERNEL_SVC_PPSH,KERNEL_COMM_ETHER) ) {
                EdbgOutputDebugString("Switched to ethernet for PPSH, host: %s, port: %d\r\n",
                                      inet_ntoa(pDriverGlobals->eth.PpshHostAddr.dwIP),
                                      ntohs(pDriverGlobals->eth.PpshHostAddr.wPort));
            }
            if ( (pDriverGlobals->eth.etherFlags & EDBG_FL_KDBG) &&
                 SetKernelCommDev(KERNEL_SVC_KDBG,KERNEL_COMM_ETHER) ) {
                EdbgOutputDebugString("Switched to ethernet for KDBG, host: %s, port: %d\r\n",
                                      inet_ntoa(pDriverGlobals->eth.KdbgHostAddr.dwIP),
                                      ntohs(pDriverGlobals->eth.KdbgHostAddr.wPort));
            }
        } else
            OEMWriteDebugString(TEXT("Debug ethernet card not present or failed init\r\n"));

        pDriverGlobals->eth.EbootMagicNum = 0;
    } else if ( DebugEtherPresent ) {
        // This is the case where we are resuming from OEMPowerOff. Just reinitialize the HW here..
        EdbgInit();
    }

    #ifdef PPSH_SERIAL
    // If we're running PPSH over serial, switch now, so that debug messages will get
    // formatted correctly (through lpWriteDebugStringFunc).
    SetKernelCommDev(KERNEL_SVC_PPSH,KERNEL_COMM_SERIAL);
    #endif

}

⌨️ 快捷键说明

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