Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

kdcpuapi.c File Reference

#include <stdio.h>
#include "kdp.h"

Go to the source code of this file.

Defines

#define END_OF_CONTROL_SPACE

Functions

LONG KdpLevelChange (ULONG Pc, PCONTEXT ContextRecord, PBOOLEAN SpecialCall)
LONG regValue (UCHAR reg, PCONTEXT ContextRecord)
BOOLEAN KdpIsSpecialCall (ULONG Pc, PCONTEXT ContextRecord, UCHAR opcode, UCHAR ModRM)
ULONG KdpGetReturnAddress (PCONTEXT ContextRecord)
ULONG KdpGetCallNextOffset (ULONG Pc, PCONTEXT ContextRecord)
BOOLEAN KdpIsTryFinallyReturn (ULONG Pc, PCONTEXT ContextRecord)
VOID KdpSetLoadState (IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, IN PCONTEXT ContextRecord)
VOID KdpSetStateChange (IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN BOOLEAN SecondChance)
VOID KdpGetStateChange (IN PDBGKD_MANIPULATE_STATE64 ManipulateState, IN PCONTEXT ContextRecord)
VOID KdpReadControlSpace (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)
VOID KdpWriteControlSpace (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)
VOID KdpReadIoSpace (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)
VOID KdpWriteIoSpace (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)
VOID KdpReadMachineSpecificRegister (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)
VOID KdpWriteMachineSpecificRegister (IN PDBGKD_MANIPULATE_STATE64 m, IN PSTRING AdditionalData, IN PCONTEXT Context)

Variables

ULONG KdpCurrentSymbolStart
ULONG KdpCurrentSymbolEnd
ULONG KdSpecialCalls []
ULONG KdNumberOfSpecialCalls


Define Documentation

#define END_OF_CONTROL_SPACE
 

Definition at line 28 of file 4/i386/kdcpuapi.c.


Function Documentation

ULONG KdpGetCallNextOffset ULONG  Pc,
PCONTEXT  ContextRecord
 

ULONG KdpGetReturnAddress PCONTEXT  ContextRecord  ) 
 

Referenced by KdpGetCallNextOffset().

VOID KdpGetStateChange IN PDBGKD_MANIPULATE_STATE64  ManipulateState,
IN PCONTEXT  ContextRecord
 

Definition at line 728 of file 4/i386/kdcpuapi.c.

References KdpCurrentSymbolEnd, KdpCurrentSymbolStart, KeNumberProcessors, KiProcessorBlock, L, NT_SUCCESS, and TRUE.

00735 : 00736 00737 Extract continuation control data from Manipulate_State message 00738 00739 Arguments: 00740 00741 ManipulateState - supplies pointer to Manipulate_State packet 00742 00743 ContextRecord - Supplies a pointer to a context record. 00744 00745 Return Value: 00746 00747 None. 00748 00749 --*/ 00750 00751 { 00752 PKPRCB Prcb; 00753 ULONG Processor; 00754 00755 if (NT_SUCCESS(ManipulateState->u.Continue2.ContinueStatus) == TRUE) { 00756 00757 // 00758 // If NT_SUCCESS returns TRUE, then the debugger is doing a 00759 // continue, and it makes sense to apply control changes. 00760 // Otherwise the debugger is saying that it doesn't know what 00761 // to do with this exception, so control values are ignored. 00762 // 00763 00764 if (ManipulateState->u.Continue2.ControlSet.TraceFlag == TRUE) { 00765 ContextRecord->EFlags |= 0x100L; 00766 00767 } else { 00768 ContextRecord->EFlags &= ~0x100L; 00769 00770 } 00771 00772 for (Processor = 0; Processor < (ULONG)KeNumberProcessors; Processor++) { 00773 Prcb = KiProcessorBlock[Processor]; 00774 00775 Prcb->ProcessorState.SpecialRegisters.KernelDr7 = 00776 ManipulateState->u.Continue2.ControlSet.Dr7; 00777 00778 Prcb->ProcessorState.SpecialRegisters.KernelDr6 = 0L; 00779 } 00780 if (ManipulateState->u.Continue2.ControlSet.CurrentSymbolStart != 1) { 00781 KdpCurrentSymbolStart = ManipulateState->u.Continue2.ControlSet.CurrentSymbolStart; 00782 KdpCurrentSymbolEnd = ManipulateState->u.Continue2.ControlSet.CurrentSymbolEnd; 00783 } 00784 } 00785 }

BOOLEAN KdpIsSpecialCall ULONG  Pc,
PCONTEXT  ContextRecord,
UCHAR  opcode,
UCHAR  ModRM
 

Referenced by KdpLevelChange().

BOOLEAN KdpIsTryFinallyReturn ULONG  Pc,
PCONTEXT  ContextRecord
 

Definition at line 96 of file 4/i386/kdcpuapi.c.

References FALSE, KdpCurrentSymbolEnd, KdpCurrentSymbolStart, KdpMoveMemory(), and TRUE.

Referenced by KdpLevelChange().

00100 { 00101 ULONG retaddr; 00102 ULONG calldisp; 00103 UCHAR inst; 00104 00105 // 00106 // The complier generates code for a try-finally that involves having 00107 // a ret instruction that does not match with a call instruction. 00108 // This ret never returns a value (ie, it's a c3 return and not a 00109 // c2). It always returns into the current symbol scope. It is never 00110 // preceeded by a leave, which (hopefully) should differentiate it 00111 // from recursive returns. Check for this, and if we find it count 00112 // it as *0* level change. 00113 // 00114 // As an optimization, the compiler will often change: 00115 // CALL 00116 // RET 00117 // into: 00118 // JMP 00119 // In either case, we figure out the return address. It's the first 4 bytes 00120 // on the stack. 00121 // 00122 00123 KdpMoveMemory( (PCHAR)&retaddr, (PCHAR)ContextRecord->Esp, 4 ); 00124 00125 // DPRINT(( "Start %x return %x end %x\n", KdpCurrentSymbolStart, retaddr, KdpCurrentSymbolEnd )); 00126 00127 if ( (KdpCurrentSymbolStart < retaddr) && (retaddr < KdpCurrentSymbolEnd) ) { 00128 00129 // 00130 // Well, things aren't this nice. We may have transferred but not yet 00131 // updated the start/end. This case occurs in a call to a thunk. We 00132 // look to see if the instruction before the return address is a call. 00133 // Gross and not 100% reliable. 00134 // 00135 00136 KdpMoveMemory( (PCHAR)&inst, (PCHAR)retaddr - 5, 1 ); 00137 KdpMoveMemory( (PCHAR)&calldisp, (PCHAR)retaddr - 4, 4 ); 00138 00139 if (inst == 0xe8 && calldisp + retaddr == Pc) { 00140 // DPRINT(( "call to thunk @ %x\n", Pc )); 00141 return FALSE; 00142 } 00143 00144 // 00145 // returning to the current function. Either a finally 00146 // or a recursive return. Check for a leave. This is not 100% 00147 // reliable since we are betting on an instruction longer than a byte 00148 // and not ending with 0xc9. 00149 // 00150 00151 KdpMoveMemory( (PCHAR)&inst, (PCHAR)Pc-1, 1 ); 00152 00153 if ( inst != 0xc9 ) { 00154 // not a leave. Assume a try-finally. 00155 // DPRINT(( "transfer at %x is try-finally\n", Pc )); 00156 return TRUE; 00157 } 00158 } 00159 00160 // 00161 // This appears to be a true RET instruction 00162 // 00163 00164 return FALSE; 00165 }

LONG KdpLevelChange ULONG  Pc,
PCONTEXT  ContextRecord,
PBOOLEAN  SpecialCall
 

VOID KdpReadControlSpace IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 789 of file 4/i386/kdcpuapi.c.

References ASSERT, KdpMoveMemory(), KdpSendPacket(), KeNumberProcessors, KiProcessorBlock, t(), and USHORT.

00797 : 00798 00799 This function is called in response of a read control space state 00800 manipulation message. Its function is to read implementation 00801 specific system data. 00802 00803 IMPLEMENTATION NOTE: 00804 00805 On the X86, control space is defined as follows: 00806 00807 0: Base of KPROCESSOR_STATE structure. (KPRCB.ProcessorState) 00808 This includes CONTEXT record, 00809 followed by a SPECIAL_REGISTERs record 00810 00811 Arguments: 00812 00813 m - Supplies the state manipulation message. 00814 00815 AdditionalData - Supplies any additional data for the message. 00816 00817 Context - Supplies the current context. 00818 00819 Return Value: 00820 00821 None. 00822 00823 --*/ 00824 00825 { 00826 PDBGKD_READ_MEMORY64 a = &m->u.ReadMemory; 00827 STRING MessageHeader; 00828 ULONG Length, t; 00829 PVOID StartAddr; 00830 00831 MessageHeader.Length = sizeof(*m); 00832 MessageHeader.Buffer = (PCHAR)m; 00833 00834 ASSERT(AdditionalData->Length == 0); 00835 00836 if (a->TransferCount > (PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64))) { 00837 Length = PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64); 00838 } else { 00839 Length = a->TransferCount; 00840 } 00841 if ((a->TargetBaseAddress < (ULONG64)(sizeof(KPROCESSOR_STATE))) && 00842 (m->Processor < (USHORT)KeNumberProcessors)) { 00843 t = (ULONG)(sizeof(KPROCESSOR_STATE)) - (ULONG)(a->TargetBaseAddress); 00844 if (t < Length) { 00845 Length = t; 00846 } 00847 StartAddr = (PVOID)((ULONG)a->TargetBaseAddress + 00848 (ULONG)&(KiProcessorBlock[m->Processor]->ProcessorState)); 00849 AdditionalData->Length = (USHORT)KdpMoveMemory( 00850 AdditionalData->Buffer, 00851 StartAddr, 00852 Length 00853 ); 00854 00855 if (Length == AdditionalData->Length) { 00856 m->ReturnStatus = STATUS_SUCCESS; 00857 } else { 00858 m->ReturnStatus = STATUS_UNSUCCESSFUL; 00859 } 00860 a->ActualBytesRead = AdditionalData->Length; 00861 00862 } else { 00863 AdditionalData->Length = 0; 00864 m->ReturnStatus = STATUS_UNSUCCESSFUL; 00865 a->ActualBytesRead = 0; 00866 } 00867 00868 KdpSendPacket( 00869 PACKET_TYPE_KD_STATE_MANIPULATE, 00870 &MessageHeader, 00871 AdditionalData 00872 ); 00873 UNREFERENCED_PARAMETER(Context); 00874 }

VOID KdpReadIoSpace IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 950 of file 4/i386/kdcpuapi.c.

References ASSERT, KdpSendPacket(), NULL, and PUSHORT.

00958 : 00959 00960 This function is called in response of a read io space state 00961 manipulation message. Its function is to read system io 00962 locations. 00963 00964 Arguments: 00965 00966 m - Supplies the state manipulation message. 00967 00968 AdditionalData - Supplies any additional data for the message. 00969 00970 Context - Supplies the current context. 00971 00972 Return Value: 00973 00974 None. 00975 00976 --*/ 00977 00978 { 00979 PDBGKD_READ_WRITE_IO64 a = &m->u.ReadWriteIo; 00980 STRING MessageHeader; 00981 00982 MessageHeader.Length = sizeof(*m); 00983 MessageHeader.Buffer = (PCHAR)m; 00984 00985 ASSERT(AdditionalData->Length == 0); 00986 00987 m->ReturnStatus = STATUS_SUCCESS; 00988 00989 // 00990 // Check Size and Alignment 00991 // 00992 00993 switch ( a->DataSize ) { 00994 case 1: 00995 a->DataValue = (ULONG)READ_PORT_UCHAR((PUCHAR)a->IoAddress); 00996 break; 00997 case 2: 00998 if ((ULONG)a->IoAddress & 1 ) { 00999 m->ReturnStatus = STATUS_DATATYPE_MISALIGNMENT; 01000 } else { 01001 a->DataValue = (ULONG)READ_PORT_USHORT((PUSHORT)a->IoAddress); 01002 } 01003 break; 01004 case 4: 01005 if ((ULONG)a->IoAddress & 3 ) { 01006 m->ReturnStatus = STATUS_DATATYPE_MISALIGNMENT; 01007 } else { 01008 a->DataValue = READ_PORT_ULONG((PULONG)a->IoAddress); 01009 } 01010 break; 01011 default: 01012 m->ReturnStatus = STATUS_INVALID_PARAMETER; 01013 } 01014 01015 KdpSendPacket( 01016 PACKET_TYPE_KD_STATE_MANIPULATE, 01017 &MessageHeader, 01018 NULL 01019 ); 01020 UNREFERENCED_PARAMETER(Context); 01021 }

VOID KdpReadMachineSpecificRegister IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 1098 of file 4/i386/kdcpuapi.c.

References ASSERT, EXCEPTION_EXECUTE_HANDLER, KdpSendPacket(), NULL, and RDMSR().

Referenced by KdpSendWaitContinue().

01106 : 01107 01108 This function is called in response of a read MSR 01109 manipulation message. Its function is to read the MSR. 01110 01111 Arguments: 01112 01113 m - Supplies the state manipulation message. 01114 01115 AdditionalData - Supplies any additional data for the message. 01116 01117 Context - Supplies the current context. 01118 01119 Return Value: 01120 01121 None. 01122 01123 --*/ 01124 01125 { 01126 PDBGKD_READ_WRITE_MSR a = &m->u.ReadWriteMsr; 01127 STRING MessageHeader; 01128 LARGE_INTEGER l; 01129 01130 MessageHeader.Length = sizeof(*m); 01131 MessageHeader.Buffer = (PCHAR)m; 01132 01133 ASSERT(AdditionalData->Length == 0); 01134 01135 m->ReturnStatus = STATUS_SUCCESS; 01136 01137 try { 01138 l.QuadPart = RDMSR(a->Msr); 01139 } except (EXCEPTION_EXECUTE_HANDLER) { 01140 l.QuadPart = 0; 01141 m->ReturnStatus = STATUS_NO_SUCH_DEVICE; 01142 } 01143 01144 a->DataValueLow = l.LowPart; 01145 a->DataValueHigh = l.HighPart; 01146 01147 KdpSendPacket( 01148 PACKET_TYPE_KD_STATE_MANIPULATE, 01149 &MessageHeader, 01150 NULL 01151 ); 01152 UNREFERENCED_PARAMETER(Context); 01153 }

VOID KdpSetLoadState IN PDBGKD_WAIT_STATE_CHANGE64  WaitStateChange,
IN PCONTEXT  ContextRecord
 

Definition at line 523 of file 4/i386/kdcpuapi.c.

References Count, End, FALSE, KdpDeleteBreakpointRange(), KdpMoveMemory(), KeGetCurrentPrcb, and USHORT.

00530 : 00531 00532 Fill in the Wait_State_Change message record for the load symbol case. 00533 00534 Arguments: 00535 00536 WaitStateChange - Supplies pointer to record to fill in 00537 00538 ContextRecord - Supplies a pointer to a context record. 00539 00540 Return Value: 00541 00542 None. 00543 00544 --*/ 00545 00546 { 00547 00548 ULONG Count; 00549 PVOID End; 00550 PKPRCB Prcb; 00551 00552 // 00553 // Store the special x86 register into the control report structure. 00554 // 00555 00556 Prcb = KeGetCurrentPrcb(); 00557 WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.KernelDr6; 00558 WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.KernelDr7; 00559 00560 // 00561 // Copy the immediate instruction stream into the control report structure. 00562 // 00563 00564 Count = KdpMoveMemory((PCHAR)(&(WaitStateChange->ControlReport.InstructionStream[0])), 00565 (PCHAR)(WaitStateChange->ProgramCounter), 00566 DBGKD_MAXSTREAM); 00567 00568 WaitStateChange->ControlReport.InstructionCount = (USHORT)Count; 00569 00570 // 00571 // Clear breakpoints in the copied instruction stream. If any breakpoints 00572 // are cleared, then recopy the instruction stream. 00573 // 00574 00575 End = (PVOID)((PUCHAR)(WaitStateChange->ProgramCounter) + Count - 1); 00576 if (KdpDeleteBreakpointRange((PVOID)WaitStateChange->ProgramCounter, End) != FALSE) { 00577 KdpMoveMemory(&WaitStateChange->ControlReport.InstructionStream[0], 00578 (PVOID)WaitStateChange->ProgramCounter, 00579 Count); 00580 } 00581 00582 // 00583 // Store the segment registers into the control report structure and set the 00584 // control flags. 00585 // 00586 00587 WaitStateChange->ControlReport.SegCs = (USHORT)(ContextRecord->SegCs); 00588 WaitStateChange->ControlReport.SegDs = (USHORT)(ContextRecord->SegDs); 00589 WaitStateChange->ControlReport.SegEs = (USHORT)(ContextRecord->SegEs); 00590 WaitStateChange->ControlReport.SegFs = (USHORT)(ContextRecord->SegFs); 00591 WaitStateChange->ControlReport.EFlags = ContextRecord->EFlags; 00592 WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS; 00593 00594 // 00595 // Copy context record into wait state change structure. 00596 // 00597 00598 KdpMoveMemory((PCHAR)(&WaitStateChange->Context), 00599 (PCHAR)ContextRecord, 00600 sizeof(CONTEXT)); 00601 00602 return; 00603 }

VOID KdpSetStateChange IN PDBGKD_WAIT_STATE_CHANGE64  WaitStateChange,
IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN BOOLEAN  SecondChance
 

Definition at line 607 of file 4/i386/kdcpuapi.c.

References KdpDeleteBreakpointRange(), KdpMoveMemory(), KdpQuickMoveMemory(), KeGetCurrentPrcb, KeGetCurrentThread, KeNumberProcessors, KeProcessorLevel, TRUE, and USHORT.

00616 : 00617 00618 Fill in the Wait_State_Change message record. 00619 00620 Arguments: 00621 00622 WaitStateChange - Supplies pointer to record to fill in 00623 00624 ExceptionRecord - Supplies a pointer to an exception record. 00625 00626 ContextRecord - Supplies a pointer to a context record. 00627 00628 SecondChance - Supplies a boolean value that determines whether this is 00629 the first or second chance for the exception. 00630 00631 Return Value: 00632 00633 None. 00634 00635 --*/ 00636 00637 { 00638 PKPRCB Prcb; 00639 BOOLEAN status; 00640 00641 // 00642 // Set up description of event, including exception record 00643 // 00644 00645 WaitStateChange->NewState = DbgKdExceptionStateChange; 00646 WaitStateChange->ProcessorLevel = KeProcessorLevel; 00647 WaitStateChange->Processor = (USHORT)KeGetCurrentPrcb()->Number; 00648 WaitStateChange->NumberProcessors = (ULONG)KeNumberProcessors; 00649 WaitStateChange->Thread = (ULONG64)(LONG64)(LONG_PTR) KeGetCurrentThread(); 00650 WaitStateChange->ProgramCounter = (ULONG64)(LONG64)(LONG_PTR) CONTEXT_TO_PROGRAM_COUNTER(ContextRecord); 00651 if (sizeof(EXCEPTION_RECORD) == sizeof(WaitStateChange->u.Exception.ExceptionRecord)) { 00652 KdpQuickMoveMemory((PCHAR)&WaitStateChange->u.Exception.ExceptionRecord, 00653 (PCHAR)ExceptionRecord, 00654 sizeof(EXCEPTION_RECORD)); 00655 } else { 00656 ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord, 00657 &WaitStateChange->u.Exception.ExceptionRecord 00658 ); 00659 } 00660 WaitStateChange->u.Exception.FirstChance = !SecondChance; 00661 00662 // 00663 // Copy instruction stream immediately following location of event 00664 // 00665 00666 WaitStateChange->ControlReport.InstructionCount = 00667 (USHORT)KdpMoveMemory( 00668 (PCHAR)(&(WaitStateChange->ControlReport.InstructionStream[0])), 00669 (PCHAR)(WaitStateChange->ProgramCounter), 00670 DBGKD_MAXSTREAM 00671 ); 00672 00673 // 00674 // Copy context record immediately following instruction stream 00675 // 00676 00677 KdpMoveMemory( 00678 (PCHAR)(&WaitStateChange->Context), 00679 (PCHAR)ContextRecord, 00680 sizeof(*ContextRecord) 00681 ); 00682 00683 // 00684 // Clear breakpoints in copied area 00685 // 00686 00687 status = KdpDeleteBreakpointRange( 00688 (PVOID)WaitStateChange->ProgramCounter, 00689 (PVOID)((PUCHAR)WaitStateChange->ProgramCounter + 00690 WaitStateChange->ControlReport.InstructionCount - 1) 00691 ); 00692 00693 // 00694 // If there were any breakpoints cleared, recopy the area without them 00695 // 00696 00697 if (status == TRUE) { 00698 KdpMoveMemory( 00699 (PUCHAR) &(WaitStateChange->ControlReport.InstructionStream[0]), 00700 (PUCHAR) WaitStateChange->ProgramCounter, 00701 WaitStateChange->ControlReport.InstructionCount 00702 ); 00703 } 00704 00705 00706 // 00707 // Special registers for the x86 00708 // 00709 Prcb = KeGetCurrentPrcb(); 00710 00711 WaitStateChange->ControlReport.Dr6 = 00712 Prcb->ProcessorState.SpecialRegisters.KernelDr6; 00713 00714 WaitStateChange->ControlReport.Dr7 = 00715 Prcb->ProcessorState.SpecialRegisters.KernelDr7; 00716 00717 WaitStateChange->ControlReport.SegCs = (USHORT)(ContextRecord->SegCs); 00718 WaitStateChange->ControlReport.SegDs = (USHORT)(ContextRecord->SegDs); 00719 WaitStateChange->ControlReport.SegEs = (USHORT)(ContextRecord->SegEs); 00720 WaitStateChange->ControlReport.SegFs = (USHORT)(ContextRecord->SegFs); 00721 WaitStateChange->ControlReport.EFlags = ContextRecord->EFlags; 00722 00723 WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS; 00724 00725 }

VOID KdpWriteControlSpace IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 877 of file 4/i386/kdcpuapi.c.

References KdpMoveMemory(), KdpSendPacket(), KeNumberProcessors, KiProcessorBlock, and USHORT.

00885 : 00886 00887 This function is called in response of a write control space state 00888 manipulation message. Its function is to write implementation 00889 specific system data. 00890 00891 Control space for x86 is as defined above. 00892 00893 Arguments: 00894 00895 m - Supplies the state manipulation message. 00896 00897 AdditionalData - Supplies any additional data for the message. 00898 00899 Context - Supplies the current context. 00900 00901 Return Value: 00902 00903 None. 00904 00905 --*/ 00906 00907 { 00908 PDBGKD_WRITE_MEMORY64 a = &m->u.WriteMemory; 00909 ULONG Length; 00910 STRING MessageHeader; 00911 PVOID StartAddr; 00912 00913 MessageHeader.Length = sizeof(*m); 00914 MessageHeader.Buffer = (PCHAR)m; 00915 00916 if ((((PUCHAR)a->TargetBaseAddress + a->TransferCount) <= 00917 (PUCHAR)(sizeof(KPROCESSOR_STATE))) && (m->Processor < (USHORT)KeNumberProcessors)) { 00918 00919 StartAddr = (PVOID)((ULONG)a->TargetBaseAddress + 00920 (ULONG)&(KiProcessorBlock[m->Processor]->ProcessorState)); 00921 00922 Length = KdpMoveMemory( 00923 StartAddr, 00924 AdditionalData->Buffer, 00925 AdditionalData->Length 00926 ); 00927 00928 if (Length == AdditionalData->Length) { 00929 m->ReturnStatus = STATUS_SUCCESS; 00930 } else { 00931 m->ReturnStatus = STATUS_UNSUCCESSFUL; 00932 } 00933 a->ActualBytesWritten = Length; 00934 00935 } else { 00936 AdditionalData->Length = 0; 00937 m->ReturnStatus = STATUS_UNSUCCESSFUL; 00938 a->ActualBytesWritten = 0; 00939 } 00940 00941 KdpSendPacket( 00942 PACKET_TYPE_KD_STATE_MANIPULATE, 00943 &MessageHeader, 00944 AdditionalData 00945 ); 00946 UNREFERENCED_PARAMETER(Context); 00947 }

VOID KdpWriteIoSpace IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 1024 of file 4/i386/kdcpuapi.c.

References ASSERT, KdpSendPacket(), NULL, PUSHORT, and USHORT.

01032 : 01033 01034 This function is called in response of a write io space state 01035 manipulation message. Its function is to write to system io 01036 locations. 01037 01038 Arguments: 01039 01040 m - Supplies the state manipulation message. 01041 01042 AdditionalData - Supplies any additional data for the message. 01043 01044 Context - Supplies the current context. 01045 01046 Return Value: 01047 01048 None. 01049 01050 --*/ 01051 01052 { 01053 PDBGKD_READ_WRITE_IO64 a = &m->u.ReadWriteIo; 01054 STRING MessageHeader; 01055 01056 MessageHeader.Length = sizeof(*m); 01057 MessageHeader.Buffer = (PCHAR)m; 01058 01059 ASSERT(AdditionalData->Length == 0); 01060 01061 m->ReturnStatus = STATUS_SUCCESS; 01062 01063 // 01064 // Check Size and Alignment 01065 // 01066 01067 switch ( a->DataSize ) { 01068 case 1: 01069 WRITE_PORT_UCHAR((PUCHAR)a->IoAddress, (UCHAR)a->DataValue); 01070 break; 01071 case 2: 01072 if ((ULONG)a->IoAddress & 1 ) { 01073 m->ReturnStatus = STATUS_DATATYPE_MISALIGNMENT; 01074 } else { 01075 WRITE_PORT_USHORT((PUSHORT)a->IoAddress, (USHORT)a->DataValue); 01076 } 01077 break; 01078 case 4: 01079 if ((ULONG)a->IoAddress & 3 ) { 01080 m->ReturnStatus = STATUS_DATATYPE_MISALIGNMENT; 01081 } else { 01082 WRITE_PORT_ULONG((PULONG)a->IoAddress, a->DataValue); 01083 } 01084 break; 01085 default: 01086 m->ReturnStatus = STATUS_INVALID_PARAMETER; 01087 } 01088 01089 KdpSendPacket( 01090 PACKET_TYPE_KD_STATE_MANIPULATE, 01091 &MessageHeader, 01092 NULL 01093 ); 01094 UNREFERENCED_PARAMETER(Context); 01095 }

VOID KdpWriteMachineSpecificRegister IN PDBGKD_MANIPULATE_STATE64  m,
IN PSTRING  AdditionalData,
IN PCONTEXT  Context
 

Definition at line 1156 of file 4/i386/kdcpuapi.c.

References ASSERT, EXCEPTION_EXECUTE_HANDLER, KdpSendPacket(), NULL, and WRMSR().

Referenced by KdpSendWaitContinue().

01164 : 01165 01166 This function is called in response of a write of a MSR 01167 manipulation message. Its function is to write to the MSR 01168 01169 Arguments: 01170 01171 m - Supplies the state manipulation message. 01172 01173 AdditionalData - Supplies any additional data for the message. 01174 01175 Context - Supplies the current context. 01176 01177 Return Value: 01178 01179 None. 01180 01181 --*/ 01182 01183 { 01184 PDBGKD_READ_WRITE_MSR a = &m->u.ReadWriteMsr; 01185 STRING MessageHeader; 01186 LARGE_INTEGER l; 01187 01188 MessageHeader.Length = sizeof(*m); 01189 MessageHeader.Buffer = (PCHAR)m; 01190 01191 ASSERT(AdditionalData->Length == 0); 01192 01193 m->ReturnStatus = STATUS_SUCCESS; 01194 01195 l.HighPart = a->DataValueHigh; 01196 l.LowPart = a->DataValueLow; 01197 01198 try { 01199 WRMSR (a->Msr, l.QuadPart); 01200 } except (EXCEPTION_EXECUTE_HANDLER) { 01201 m->ReturnStatus = STATUS_NO_SUCH_DEVICE; 01202 } 01203 01204 KdpSendPacket( 01205 PACKET_TYPE_KD_STATE_MANIPULATE, 01206 &MessageHeader, 01207 NULL 01208 ); 01209 UNREFERENCED_PARAMETER(Context); 01210 }

LONG regValue UCHAR  reg,
PCONTEXT  ContextRecord
 

Referenced by KdpIsSpecialCall().


Variable Documentation

ULONG KdNumberOfSpecialCalls
 

Definition at line 32 of file 4/i386/kdcpuapi.c.

ULONG KdpCurrentSymbolEnd
 

Definition at line 30 of file 4/i386/kdcpuapi.c.

ULONG KdpCurrentSymbolStart
 

Definition at line 30 of file 4/i386/kdcpuapi.c.

ULONG KdSpecialCalls[]
 

Definition at line 31 of file 4/i386/kdcpuapi.c.


Generated on Sat May 15 19:44:25 2004 for test by doxygen 1.3.7