📄 pentiumalib.s
字号:
cmpxchgb %dl,_pmcBusy /* if (_pmcBusy == TRUE) */ ret /* {ZF = 1; _pmcBusy = 0;} *//********************************************************************************* pentiumP6PmcStop1 - stop PMC1** SYNOPSIS* \ss* void pentiumP6PmcStop1 (void)* \se* * This routine stops only PMC1 (Performance Monitoring Counter 1)* by clearing the Performance Event Select Register 1.* Note, clearing the Performance Event Select Register 0 stops both counters,* PMC0 and PMC1.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcStop1) xorl %eax,%eax /* zero low-order 32 bits */ xorl %edx,%edx /* zero high-order 32 bits */ movl $ MSR_EVNTSEL1,%ecx /* specify MSR_EVNTSEL1 */ wrmsr /* write %edx:%eax to MSR_EVNTSEL1 */ ret/********************************************************************************* pentiumP6PmcGet - get the contents of PMC0 and PMC1** SYNOPSIS* \ss* void pentiumP6PmcGet (pPmc0, pPmc1)* long long int * pPmc0; /@ Performance Monitoring Counter 0 @/* long long int * pPmc1; /@ Performance Monitoring Counter 1 @/* \se* * This routine gets the contents of both PMC0 (Performance Monitoring Counter 0)* and PMC1. The first parameter is a pointer of 64Bit variable to store* the content of the Counter 0, and the second parameter is for the Counter 1.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcGet) movl $0,%ecx /* specify PMC0 */ rdpmc /* read PMC0 to %edx:%eax */ movl SP_ARG1(%esp),%ecx movl %eax,(%ecx) /* save low-order 32 bits */ movl %edx,4(%ecx) /* save high-order 32 bits */ movl $1,%ecx /* specify PMC1 */ rdpmc /* read PMC1 to %edx:%eax */ movl SP_ARG2(%esp),%ecx movl %eax,(%ecx) /* save low-order 32 bits */ movl %edx,4(%ecx) /* save high-order 32 bits */ ret/********************************************************************************* pentiumP6PmcGet0 - get the contents of PMC0** SYNOPSIS* \ss* void pentiumP6PmcGet0 (pPmc0)* long long int * pPmc0; /@ Performance Monitoring Counter 0 @/* \se* * This routine gets the contents of PMC0 (Performance Monitoring Counter 0).* The parameter is a pointer of 64Bit variable to store the content of* the Counter.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcGet0) movl $0,%ecx /* specify PMC0 */ rdpmc /* read PMC0 to %edx:%eax */ movl SP_ARG1(%esp),%ecx movl %eax,(%ecx) /* save low-order 32 bits */ movl %edx,4(%ecx) /* save high-order 32 bits */ ret/********************************************************************************* pentiumP6PmcGet1 - get the contents of PMC1** SYNOPSIS* \ss* void pentiumP6PmcGet1 (pPmc1)* long long int * pPmc1; /@ Performance Monitoring Counter 1 @/* \se* * This routine gets a content of PMC1 (Performance Monitoring Counter 1).* Parameter is a pointer of 64Bit variable to store the content of the Counter.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcGet1) movl $1,%ecx /* specify PMC1 */ rdpmc /* read PMC1 to %edx:%eax */ movl SP_ARG1(%esp),%ecx movl %eax,(%ecx) /* save low-order 32 bits */ movl %edx,4(%ecx) /* save high-order 32 bits */ ret/********************************************************************************* pentiumP6PmcReset - reset both PMC0 and PMC1** SYNOPSIS* \ss* void pentiumP6PmcReset (void)* \se* * This routine resets both PMC0 (Performance Monitoring Counter 0) and PMC1.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcReset) xorl %eax,%eax /* zero low-order 32 bits */ xorl %edx,%edx /* zero high-order 32 bits */ movl $ MSR_PERFCTR0,%ecx /* specify MSR_PERFCTR0 */ wrmsr /* write %edx:%eax to MSR_PERFCTR0 */ movl $ MSR_PERFCTR1,%ecx /* specify MSR_PERFCTR1 */ wrmsr /* write %edx:%eax to MSR_PERFCTR1 */ ret/********************************************************************************* pentiumP6PmcReset0 - reset PMC0** SYNOPSIS* \ss* void pentiumP6PmcReset0 (void)* \se* * This routine resets PMC0 (Performance Monitoring Counter 0).** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcReset0) xorl %eax,%eax /* zero low-order 32 bits */ xorl %edx,%edx /* zero high-order 32 bits */ movl $ MSR_PERFCTR0,%ecx /* specify MSR_PERFCTR0 */ wrmsr /* write %edx:%eax to MSR_PERFCTR0 */ ret/********************************************************************************* pentiumP6PmcReset1 - reset PMC1** SYNOPSIS* \ss* void pentiumP6PmcReset1 (void)* \se* * This routine resets PMC1 (Performance Monitoring Counter 1).** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP6PmcReset1) xorl %eax,%eax /* zero low-order 32 bits */ xorl %edx,%edx /* zero high-order 32 bits */ movl $ MSR_PERFCTR1,%ecx /* specify MSR_PERFCTR1 */ wrmsr /* write %edx:%eax to MSR_PERFCTR1 */ ret/********************************************************************************* pentiumP5PmcStart0 - start PMC0** SYNOPSIS* \ss* STATUS pentiumP5PmcStart0 (pmc0Cesr)* int pmc0Cesr; /@ PMC0 control and event select @/* \se** This routine starts PMC0 (Performance Monitoring Counter 0) * by writing specified PMC0 events to Performance Event Select Registers. * The only parameter is the content of Performance Event Select Register.** RETURNS: OK or ERROR if PMC0 is already started.*/ .balign 16,0x90FUNC_LABEL(pentiumP5PmcStart0) xorl %eax,%eax movl $ TRUE, %edx lock /* lock the BUS */ cmpxchgb %dl,_pmc0Busy /* if (_pmc0Busy == 0) */ jnz pentiumP5PmcStart0L0 /* {ZF = 1; _pmc0Busy = TRUE;} */ movl $ MSR_CESR,%ecx /* specify MSR_CESR */ rdmsr /* read from MSR_CESR */ andl $ 0xFFFF0000,%eax /* mask out PMC0 bits */ movl SP_ARG1(%esp),%edx /* new PMC0 bits */ andl $ 0x0000FFFF,%edx /* mask out the high 16 bits */ orl %edx,%eax /* merge with orig PMC1 bits */ xorl %edx,%edx /* high-order 32 bits */ wrmsr /* write %edx:%eax to MSR_CESR */ xorl %eax,%eax /* return OK */ retpentiumP5PmcStart0L0: movl $ ERROR,%eax ret/********************************************************************************* pentiumP5PmcStart1 - start PMC1** SYNOPSIS* \ss* STATUS pentiumP5PmcStart1 (pmc1Cesr)* int pmc1Cesr; /@ PMC1 control and event select @/* \se** This routine starts PMC1 (Performance Monitoring Counter 0) * by writing specified PMC1 events to Performance Event Select Registers. * The only parameter is the content of Performance Event Select Register.** RETURNS: OK or ERROR if PMC1 is already started.*/ .balign 16,0x90FUNC_LABEL(pentiumP5PmcStart1) xorl %eax,%eax movl $ TRUE, %edx lock /* lock the BUS */ cmpxchgb %dl,_pmc1Busy /* if (_pmc1Busy == 0) */ jnz pentiumP5PmcStart1L0 /* {ZF = 1; _pmcBusy = TRUE;} */ movl $ MSR_CESR,%ecx /* specify MSR_CESR */ rdmsr /* read from MSR_CESR */ andl $ 0x0000FFFF,%eax /* mask out PMC1 bits */ movl SP_ARG1(%esp),%edx /* new PMC1 bits */ shll $ 16,%edx /* shift PMC1 bits to higher 16 bits */ orl %edx,%eax /* merge with orig PMC1 bits */ xorl %edx,%edx /* high-order 32 bits */ wrmsr /* write %edx:%eax to MSR_CESR */ xorl %eax,%eax /* return OK */ retpentiumP5PmcStart1L0: movl $ ERROR,%eax ret/********************************************************************************* pentiumP5PmcStop - stop both P5 PMC0 and PMC1** SYNOPSIS* \ss* void pentiumP5PmcStop (void)* \se** This routine stops both PMC0 (Performance Monitoring Counter 0)* and PMC1 by clearing two Performance Event Select Registers.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP5PmcStop) xorl %eax,%eax /* zero low-order 32 bits */ xorl %edx,%edx /* zero high-order 32 bits */ movl $ MSR_CESR,%ecx wrmsr /* write %edx:%eax to CESR reg */ movl $ TRUE, %eax xorl %edx,%edx lock /* lock the BUS */ cmpxchgb %dl,_pmc0Busy /* if (_pmc0Busy == TRUE) */ /* {ZF = 1; _pmcBusy = 0;} */ movl $ TRUE, %eax xorl %edx,%edx lock /* lock the BUS */ cmpxchgb %dl,_pmc1Busy /* if (_pmc0Busy == TRUE) */ /* {ZF = 1; _pmcBusy = 0;} */ ret/********************************************************************************* pentiumP5PmcStop0 - stop P5 PMC0** SYNOPSIS* \ss* void pentiumP5PmcStop0 (void)* \se** This routine stops only PMC0 (Performance Monitoring Counter 0)* by clearing the PMC0 bits of Control and Event Select Register.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP5PmcStop0) movl $ MSR_CESR,%ecx /* select MSR_CESR register */ rdmsr andl $ 0xFFFF0000,%eax /* clear PMC0 bits in MSR_CESR */ xorl %edx,%edx /* zero high-order 32 bits */ wrmsr /* write %edx:%eax to MSR_CESR */ movl $ TRUE, %eax xorl %edx,%edx lock /* lock the BUS */ cmpxchgb %dl,_pmc0Busy /* if (_pmc0Busy == TRUE) */ ret/********************************************************************************* pentiumP5PmcStop1 - stop P5 PMC1** SYNOPSIS* \ss* void pentiumP5PmcStop1 (void)* \se** This routine stops only PMC1 (Performance Monitoring Counter 1)* by clearing the PMC1 bits of Control and Event Select Register.** RETURNS: N/A*/ .balign 16,0x90FUNC_LABEL(pentiumP5PmcStop1) movl $ MSR_CESR,%ecx /* select MSR_CESR register */ rdmsr andl $ 0x0000FFFF,%eax /* clear PMC1 bits in MSR_CESR */ xorl %edx,%edx /* zero high-order 32 bits */ wrmsr /* write %edx:%eax to MSR_CESR */ movl $ TRUE, %eax xorl %edx,%edx lock /* lock the BUS */ cmpxchgb %dl,_pmc1Busy /* if (_pmc1Busy == TRUE) */ ret/********************************************************************************* pentiumP5PmcGet - get the contents of P5 PMC0 and PMC1** SYNOPSIS* \ss* void pentiumP5PmcGet (pPmc0, pPmc1)* long long int * pPmc0; /@ Performance Monitoring Counter 0 @/* long long int * pPmc1; /@ Performance Monitoring Counter 1 @/* \se** This routine gets the contents of both PMC0 (Performance Monitoring Counter 0)* and PMC1. The first parameter is a pointer of 64Bit variable to store* the content of the Counter 0, and the second parameter is for the Counter 1.** RETURNS: N/A*/ .balign 16,0x90
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -