mdprof.c

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

C
68
字号
/* Copyright (c) 1999-2000 Microsoft Corporation.  All rights reserved. */
#include "windows.h"
#include "nkintr.h"
//#include <profiler.h>
#include "pc.h"
#include "..\..\hal\x86\timer.h"

// number of times to increase timer for profiling
#define PROFILE_MULT    100

int ProfileInterrupt(void);
extern int (*PProfileInterrupt)(void);  // pointer to profiler ISR, 

unsigned int ReschedCount;
extern DWORD GetEPC(void);
extern void ProfilerHit(DWORD);
extern void ProfilerReport(void);
extern unsigned long volatile   DiffMSec;
extern unsigned long volatile   CurMSec;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
SetTimer0(WORD wVal)
{
    __asm {
        // configure counter for correct mode
        mov     al, 00110100b           ; counter 0, 16-bit, mode 2, binary
        out     043h, al
        jmp     short $+2
        // load the timer with correct count value
        mov     ax, wVal
        out     040h, al
        jmp     short $+2
        mov     al,ah
        out     040h, al
    }
}



void OEMProfileTimerEnable(DWORD dwUSec) {
    PProfileInterrupt=ProfileInterrupt;
    SetTimer0(TIMER_COUNT/PROFILE_MULT);
    PICEnableInterrupt(INTR_TIMER0, TRUE);
    ReschedCount=0;
}

void OEMProfileTimerDisable(void) {
    PProfileInterrupt=NULL;
    SetTimer0(TIMER_COUNT);
    PICEnableInterrupt(INTR_TIMER0, TRUE);
}

int ProfileInterrupt(void) {
    
    ProfilerHit(GetEPC());
    if (ReschedCount++ < PROFILE_MULT)
        return SYSINTR_NOP;

    ReschedCount=0;
    CurMSec += SYSTEM_TICK_MS;
    DiffMSec += SYSTEM_TICK_MS;

    return SYSINTR_RESCHED;
}

⌨️ 快捷键说明

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