/* FUNCTIONS *****************************************************************/
-STDCALL
VOID
+STDCALL
KeInitializeProfile(PKPROFILE Profile,
PKPROCESS Process,
PVOID ImageBase,
/* Copy all the settings we were given */
Profile->Process = Process;
- Profile->RegionStart = ImageBase;
+ Profile->RangeBase = ImageBase;
Profile->BucketShift = BucketSize - 2; /* See ntinternals.net -- Alex */
- Profile->RegionEnd = (PVOID)(ULONG_PTR)ImageBase + ImageSize;
- Profile->Active = FALSE;
+ Profile->RangeLimit = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
+ Profile->Started = FALSE;
Profile->Source = ProfileSource;
Profile->Affinity = Affinity;
}
-STDCALL
VOID
+STDCALL
KeStartProfile(PKPROFILE Profile,
PVOID Buffer)
{
KIRQL OldIrql;
PKPROFILE_SOURCE_OBJECT SourceBuffer;
- PKPROFILE_SOURCE_OBJECT Source = NULL;
PKPROFILE_SOURCE_OBJECT CurrentSource;
BOOLEAN FreeBuffer = TRUE;
PKPROCESS ProfileProcess;
- PLIST_ENTRY ListEntry;
/* Allocate a buffer first, before we raise IRQL */
SourceBuffer = ExAllocatePoolWithTag(NonPagedPool,
sizeof(KPROFILE_SOURCE_OBJECT),
TAG('P', 'r', 'o', 'f'));
- RtlZeroMemory(Source, sizeof(KPROFILE_SOURCE_OBJECT));
+ RtlZeroMemory(SourceBuffer, sizeof(KPROFILE_SOURCE_OBJECT));
/* Raise to PROFILE_LEVEL */
KeRaiseIrql(PROFILE_LEVEL, &OldIrql);
KeAcquireSpinLockAtDpcLevel(&KiProfileLock);
/* Make sure it's not running */
- if (!Profile->Active) {
+ if (!Profile->Started) {
- /* Set it as active */
+ /* Set it as Started */
Profile->Buffer = Buffer;
- Profile->Active = TRUE;
+ Profile->Started = TRUE;
/* Get the process, if any */
ProfileProcess = Profile->Process;
/* Insert it into the Process List or Global List */
if (ProfileProcess) {
- InsertTailList(&ProfileProcess->ProfileListHead, &Profile->ListEntry);
+ InsertTailList(&ProfileProcess->ProfileListHead, &Profile->ProfileListEntry);
} else {
- InsertTailList(&KiProfileListHead, &Profile->ListEntry);
+ InsertTailList(&KiProfileListHead, &Profile->ProfileListEntry);
}
/* Check if this type of profile (source) is already running */
- for (ListEntry = KiProfileSourceListHead.Flink;
- ListEntry != &KiProfileSourceListHead;
- ListEntry = ListEntry->Flink) {
-
- /* Get the Source Object */
- CurrentSource = CONTAINING_RECORD(ListEntry,
- KPROFILE_SOURCE_OBJECT,
- ListEntry);
-
+ LIST_FOR_EACH(CurrentSource, &KiProfileSourceListHead, KPROFILE_SOURCE_OBJECT, ListEntry)
+ {
/* Check if it's the same as the one being requested now */
if (CurrentSource->Source == Profile->Source) {
-
- Source = CurrentSource;
break;
}
}
/* See if the loop found something */
- if (!Source) {
+ if (!CurrentSource) {
/* Nothing found, use our allocated buffer */
- Source = SourceBuffer;
+ CurrentSource = SourceBuffer;
/* Set up the Source Object */
- Source->Source = Profile->Source;
- InsertHeadList(&KiProfileSourceListHead, &Source->ListEntry);
+ CurrentSource->Source = Profile->Source;
+ InsertHeadList(&KiProfileSourceListHead, &CurrentSource->ListEntry);
/* Don't free the pool later on */
FreeBuffer = FALSE;
if (!FreeBuffer) ExFreePool(SourceBuffer);
}
+BOOLEAN
STDCALL
-VOID
KeStopProfile(PKPROFILE Profile)
{
KIRQL OldIrql;
- PLIST_ENTRY ListEntry;
PKPROFILE_SOURCE_OBJECT CurrentSource = NULL;
/* Raise to PROFILE_LEVEL and acquire spinlock */
KeAcquireSpinLockAtDpcLevel(&KiProfileLock);
/* Make sure it's running */
- if (Profile->Active) {
+ if (Profile->Started) {
/* Remove it from the list and disable */
- RemoveEntryList(&Profile->ListEntry);
- Profile->Active = FALSE;
+ RemoveEntryList(&Profile->ProfileListEntry);
+ Profile->Started = FALSE;
/* Find the Source Object */
- for (ListEntry = KiProfileSourceListHead.Flink;
- CurrentSource->Source != Profile->Source;
- ListEntry = ListEntry->Flink) {
-
- /* Get the Source Object */
- CurrentSource = CONTAINING_RECORD(ListEntry,
- KPROFILE_SOURCE_OBJECT,
- ListEntry);
+ LIST_FOR_EACH(CurrentSource, &KiProfileSourceListHead, KPROFILE_SOURCE_OBJECT, ListEntry)
+ {
+ if (CurrentSource->Source == Profile->Source) {
+ /* Remove it */
+ RemoveEntryList(&CurrentSource->ListEntry);
+ break;
+ }
}
- /* Remove it */
- RemoveEntryList(&CurrentSource->ListEntry);
}
/* Lower IRQL */
/* Free the Source Object */
if (CurrentSource) ExFreePool(CurrentSource);
+
+ /* FIXME */
+ return FALSE;
}
-STDCALL
ULONG
+STDCALL
KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource)
{
/* Check if this is the timer profile */
}
}
-STDCALL
VOID
+STDCALL
KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
ULONG Interval)
{
/*
* @implemented
*/
-STDCALL
VOID
+STDCALL
KeProfileInterrupt(PKTRAP_FRAME TrapFrame)
{
/* Called from HAL for Timer Profiling */
{
PULONG BucketValue;
PKPROFILE Profile;
- PLIST_ENTRY NextEntry;
/* Loop the List */
- for (NextEntry = ListHead->Flink; NextEntry != ListHead; NextEntry = NextEntry->Flink) {
-
- /* Get the Current Profile in the List */
- Profile = CONTAINING_RECORD(NextEntry, KPROFILE, ListEntry);
-
+ LIST_FOR_EACH(Profile, ListHead, KPROFILE, ProfileListEntry)
+ {
/* Check if the source is good, and if it's within the range */
if ((Profile->Source != Source) ||
- (TrapFrame->Eip < (ULONG_PTR)Profile->RegionStart) ||
- (TrapFrame->Eip > (ULONG_PTR)Profile->RegionEnd)) {
+ (TrapFrame->Eip < (ULONG_PTR)Profile->RangeBase) ||
+ (TrapFrame->Eip > (ULONG_PTR)Profile->RangeLimit)) {
continue;
}
/* Get the Pointer to the Bucket Value representing this EIP */
- BucketValue = (PULONG)(((ULONG_PTR)(Profile->Buffer +
- (TrapFrame->Eip - (ULONG_PTR)Profile->RegionStart))
+ BucketValue = (PULONG)((((ULONG_PTR)Profile->Buffer +
+ (TrapFrame->Eip - (ULONG_PTR)Profile->RangeBase))
>> Profile->BucketShift) &~ 0x3);
/* Increment the value */
* from the trap frame into the buffer, while using buckets and
* shifting like we specified. -- Alex
*/
-STDCALL
VOID
+STDCALL
KeProfileInterruptWithSource(IN PKTRAP_FRAME TrapFrame,
IN KPROFILE_SOURCE Source)
{
/*
* @implemented
*/
-STDCALL
VOID
+STDCALL
KeSetProfileIrql(IN KIRQL ProfileIrql)
{
/* Set the IRQL at which Profiling will run */