/** @file
SEC Core Debug Agent Library instance implementition.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SecPeiDebugAgentLib.h"
/**
Get pointer to Mailbox from IDT entry before memory is ready.
**/
VOID *
)
{
Mailbox = IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow + (IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16);
}
/**
Set the pointer of Mailbox into IDT entry before memory is ready.
@param[in] Mailbox The pointer of Mailbox.
**/
)
{
}
/**
Get the pointer to Mailbox from IDT entry and build the Mailbox into GUIDed Hob
after memory is ready.
@return Pointer to Mailbox.
**/
)
{
return BuildGuidDataHob (
sizeof (DEBUG_AGENT_MAILBOX)
);
}
/**
Get Debug Agent Mailbox pointer.
@return Mailbox pointer.
**/
)
{
return (DEBUG_AGENT_MAILBOX *) GetMailboxPointerInIdtEntry ();
}
/**
Get debug port handle.
@return Debug port handle.
**/
)
{
}
/**
Trigger one software interrupt to debug agent to handle it.
@param Signature Software interrupt signature.
**/
)
{
//
// Save Debug Register State
//
Dr0 = AsmReadDr0 ();
Dr1 = AsmReadDr1 ();
//
// DR0 = Signature
//
//
// Do INT3 to communicate with HOST side
//
CpuBreakpoint ();
//
// Restore Debug Register State only when Host didn't change it inside exception handler.
// Dr registers can only be changed by setting the HW breakpoint.
//
AsmWriteDr0 (Dr0);
AsmWriteDr1 (Dr1);
}
/**
Initialize debug agent.
This function is used to set up debug environment for SEC and PEI phase.
If InitFlag is DEBUG_AGENT_INIT_PREMEM_SEC, it will overirde IDT table entries
and initialize debug port. It will enable interrupt to support break-in feature.
It will set up debug agent Mailbox in cache-as-ramfrom. It will be called before
physical memory is ready.
If InitFlag is DEBUG_AGENT_INIT_POSTMEM_SEC, debug agent will build one GUIDed
HOB to copy debug agent Mailbox. It will be called after physical memory is ready.
This function is used to set up debug environment to support source level debugging.
If certain Debug Agent Library instance has to save some private data in the stack,
this function must work on the mode that doesn't return to the caller, then
the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one
function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is
responsible to invoke the passing-in function at the end of InitializeDebugAgent().
If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by
passing in the Context to be its parameter.
If Function() is NULL, Debug Agent Library instance will return after setup debug
environment.
@param[in] InitFlag Init flag is used to decide the initialize process.
@param[in] Context Context needed according to InitFlag; it was optional.
@param[in] Function Continue function called by debug agent library; it was
optional.
**/
)
{
switch (InitFlag) {
//
// Get and save debug port handle and set the length of memory block.
//
//
// If reaches here, it means Debug Port initialization failed.
//
break;
//
// Memory has been ready
//
if (IsHostConnected()) {
//
// Trigger one software interrupt to inform HOST
//
}
Mailbox = BuildMailboxHob ();
EnableInterrupts ();
break;
default:
//
// Only DEBUG_AGENT_INIT_PREMEM_SEC and DEBUG_AGENT_INIT_POSTMEM_SEC are allowed for this
// Debug Agent library instance.
//
CpuDeadLoop ();
break;
}
//
// If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.
//
}
}
/**
Caller provided function to be invoked at the end of DebugPortInitialize().
Refer to the descrption for DebugPortInitialize() for more details.
@param[in] Context The first input argument of DebugPortInitialize().
@param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
**/
)
{
//
// Trigger one software interrupt to inform HOST
//
//
// If Temporary RAM region is below 128 MB, then send message to
// host to disable low memory filtering.
//
}
//
// Enable CPU interrupts so debug timer interrupts can be delivered
//
EnableInterrupts ();
//
// Call continuation function if it is not NULL.
//
}
}