📄 debug.c
字号:
/*
* The content of this file or document is CONFIDENTIAL and PROPRIETARY
* to Jade Technologies Co., Ltd. It is subjected to the terms of a
* License Agreement between Licensee and Jade Technologies Co., Ltd.
* restricting among other things, the use, reproduction, distribution
* and transfer. Each of the embodiments, including this information
* and any derivative work shall retain this copyright notice.
*
* Copyright (c) 2004 - 2005 Jade Technologies Co., Ltd.
* All rights reserved.
----------------------------------------------------------------
File: debug.c,v
Revision: 1.0
----------------------------------------------------------------
$
Module Name:
Abstract:
Functions:
Notes:
The original Microsoft version of this file did serial debugging using the
ODO DMA engine to handle all the awkward multiple sends.
*/
/*****************************************************************************
*
* @doc EXTERNAL OEM
*
* @module debug.c | OEM Debug Serial Monitor Routines
*
******************************************************************************/
#include <windows.h>
#include <nkintr.h>
#include <halether.h>
#include <ethdbg.h>
#include <drv_glob.h>
#include "win_plat.h"
#include <pl011.h>
#include <oalfuncs.h>
#define pDriverGlobals ((PDRIVER_GLOBALS) DRIVER_GLOBALS_PHYSICAL_MEMORY_START)
/*
* @func void OEMInitDebugSerial - Initialize debug monitor port.
*
* NOTE: This function MUST NOT use any global variables!!!!!!
*/
void OEMInitDebugSerial(void)
{
InitSerial(VA_DEBUG_COMPORT);
#ifdef NOTYET
// 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.
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.
}
#endif
#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
// Route all debug messages to the serial port
SetKernelCommDev(KERNEL_SVC_DBGMSG,KERNEL_COMM_SERIAL);
// Enable serial debugging
SetKernelCommDev(KERNEL_SVC_KDBG,KERNEL_COMM_SERIAL);
}
/*****************************************************************************
*
*
* @func void | OEMWriteDebugString | Display string to the monitor port.
*
* @parm unsigned short * | str |
* Points to the receiving buffer.
*/
void
OEMWriteDebugString(unsigned short *str)
{
// Send message to serial port
while (*str)
OEMWriteDebugByte((unsigned char)*str++);
}
/*****************************************************************************
*
*
* @func void | OEMWriteDebugByte | Output byte to the monitor port.
*
* @parm unsigned char *| str |
* Points to the output buffer.
*/
void
OEMWriteDebugByte(BYTE ch)
{
// Wait until the flag register indicates the UART has room for another character
while ((READ_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_FR) & PL011_FR_TXFF) != 0)
;
WRITE_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_DR, ch);
}
/*****************************************************************************
*
*
* @func int | OEMReadDebugByte | Get a byte from the monitor port.
*
* @rdesc Returns:
* OEM_DEBUG_COM_ERROR Error detected
* OEM_DEBUG_READ_NODATA No data is available at the port.
* ch If data is available.
*
*/
int
OEMReadDebugByte(void)
{
ULONG ulReg;
/* Read the flag register to see if the FIFO is empty */
if ((READ_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_FR) & PL011_FR_RXFE) != 0)
return OEM_DEBUG_READ_NODATA;
// Read the data register (mask off receive error bits)
ulReg = READ_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_DR) & PL011_DR_MASK;
/* Read receive status register to see if there is an error */
if ((READ_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_RSR) & PL011_RSR_ALLERRORS) != 0)
return OEM_DEBUG_COM_ERROR;
return (int)ulReg;
}
/*****************************************************************************
*
*
* @func void | OEMClearDebugComError | Clear a debug communications error
*
*/
void
OEMClearDebugCommError(void)
{
/* Write to the UART Error Clear register to clear any errors */
WRITE_REGISTER_ULONG(VA_DEBUG_COMPORT + PL011_ECR, PL011_ECR_ALLERRORS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -