VxWorks Reference Manual : Libraries

pentiumALib

NAME

pentiumALib - Pentium and PentiumPro specific routines

ROUTINES

pentiumCr4Get( ) - get contents of CR4 register
pentiumCr4Set( ) - sets specified value to the CR4 register
pentiumPmcStart( ) - start both PMC0 and PMC1
pentiumPmcStop( ) - stop both PMC0 and PMC1
pentiumPmcStop1( ) - stop PMC1
pentiumPmcGet( ) - get the contents of PMC0 and PMC1
pentiumPmcGet0( ) - get the contents of PMC0
pentiumPmcGet1( ) - get the contents of PMC1
pentiumPmcReset( ) - reset both PMC0 and PMC1
pentiumPmcReset0( ) - reset PMC0
pentiumPmcReset1( ) - reset PMC1
pentiumTscGet64( ) - get 64Bit TSC (Timestamp Counter)
pentiumTscGet32( ) - get the lower half of the 64Bit TSC (Timestamp Counter)
pentiumTscReset( ) - reset the TSC (Timestamp Counter)
pentiumMsrGet( ) - get the contents of the specified MSR (Model Specific Register)
pentiumMsrSet( ) - set a value to the specified MSR (Model Specific Registers)
pentiumTlbFlush( ) - flush TLBs (Translation Lookaside Buffers)
pentiumSerialize( ) - execute a serializing instruction CPUID
pentiumBts( ) - execute atomic compare-and-exchange instruction to set a bit
pentiumBtc( ) - execute atomic compare-and-exchange instruction to clear a bit

DESCRIPTION

This module contains Pentium and PentiumPro specific routines written in assembly language.

MCA (Machine Check Architecture)

The Pentium processor introduced a new exception called the machine-check exception (interrupt-18). This exception is used to signal hardware-related errors, such as a parity error on a read cycle. The PentiumPro processor extends the types of errors that can be detected and that generate a machine- check exception. It also provides a new machine-check architecture that records information about a machine-check error and provides the basis for an extended error logging capability.

MCA is enabled and its status registers are cleared zero in sysHwInit( ). Its registers are accessed by pentiumMsrSet( ) and pentiumMsrGet( ).

PMC (Performance Monitoring Counters)

The PentiumPro processor has two performance-monitoring counters for use in monitoring internal hardware operations. These counters are duration or event counters that can be programmed to count any of approximately 100 different types of events, such as the number of instructions decoded, number of interrupts received, or number of cache loads.

There are nine routines to interface the PMC. These nine routines are:

  STATUS pentiumPmcStart
         (
         int pmcEvtSel0;        /* performance event select register 0 */
         int pmcEvtSel1;        /* performance event select register 1 */
         )
  void   pentiumPmcStop (void)
  void   pentiumPmcStop1 (void)
  void   pentiumPmcGet
         (
         long long int * pPmc0; /* performance monitoring counter 0 */
         long long int * pPmc1; /* performance monitoring counter 1 */
         )
  void   pentiumPmcGet0
         (
         long long int * pPmc0; /* performance monitoring counter 0 */
         )
  void   pentiumPmcGet1
         (
         long long int * pPmc1; /* performance monitoring counter 1 */
         )
  void   pentiumPmcReset (void)
  void   pentiumPmcReset0 (void)
  void   pentiumPmcReset1 (void)
pentiumPmcStart( ) starts both PMC0 and PMC1. pentiumPmcStop( ) stops them, and pentiumPmcStop1( ) stops only PMC1. pentiumPmcGet( ) gets contents of PMC0 and PMC1. pentiumPmcGet0( ) gets contents of PMC0, and pentiumPmcGet1( ) gets contents of PMC1. pentiumPmcReset( ) resets both PMC0 and PMC1. pentiumPmcReset0( ) resets PMC0, and pentiumPmcReset1( ) resets PMC1. PMC is enabled in sysHwInit( ). Selected events in the default configuration are PMC0 = number of hardware interrupts received and PMC1 = number of misaligned data memory references.

MSR (Model Specific Register)

The concept of model-specific registers (MSRs) to control hardware functions in the processor or to monitor processor activity was introduced in the PentiumPro processor. The new registers control the debug extensions, the performance counters, the machine-check exception capability, the machine check architecture, and the MTRRs. The MSRs can be read and written to using the RDMSR and WRMSR instructions, respectively.

There are two routines to interface the MSR. These two routines are:

  void pentiumMsrGet
       (
       int address,             /* MSR address */
       long long int * pData    /* MSR data */
       )

  void pentiumMsrSet
       (
       int address,             /* MSR address */
       long long int * pData    /* MSR data */
       )
pentiumMsrGet( ) get contents of the specified MSR, and pentiumMsrSet( ) sets value to the specified MSR.

TSC (Time Stamp Counter)

The PentiumPro processor provides a 64-bit time-stamp counter that is incremented every processor clock cycle. The counter is incremented even when the processor is halted by the HLT instruction or the external STPCLK# pin. The time-stamp counter is set to 0 following a hardware reset of the processor. The RDTSC instruction reads the time stamp counter and is guaranteed to return a monotonically increasing unique value whenever executed, except for 64-bit counter wraparound. Intel guarantees, architecturally, that the time-stamp counter frequency and configuration will be such that it will not wraparound within 10 years after being reset to 0. The period for counter wrap is several thousands of years in the PentiumPro and Pentium processors.

There are three routines to interface the TSC. These three routines are:

  void pentiumTscReset (void)

  void pentiumTscGet32 (void)

  void pentiumTscGet64
       (
       long long int * pTsc     /* TSC */
       )
pentiumTscReset( ) resets the TSC. pentiumTscGet32( ) gets the lower half of the 64Bit TSC, and pentiumTscGet64( ) gets the entire 64Bit TSC.

Four other routines are provided in this library. They are:

  void   pentiumTlbFlush (void)

  void   pentiumSerialize (void)

  STATUS pentiumBts
         (
         char * pFlag                   /* flag address */
         )

  STATUS pentiumBtc (pFlag)
         (
         char * pFlag                   /* flag address */
         )
pentiumTlbFlush( ) flushes TLBs (Translation Lookaside Buffers). pentiumSerialize( ) does serialization by executing CPUID instruction. pentiumBts( ) executes an atomic compare-and-exchange instruction to set a bit. pentiumBtc( ) executes an atomic compare-and-exchange instruction to clear a bit.

SEE ALSO

pentiumALib, Pentium, PentiumPro Family Developer's Manual


Libraries : Routines

pentiumCr4Get( )

NAME

pentiumCr4Get( ) - get contents of CR4 register

SYNOPSIS

int pentiumCr4Get (void)

DESCRIPTION

This routine gets the contents of the CR4 register.

RETURNS

Contents of CR4 register.

SEE ALSO

pentiumALib


Libraries : Routines

pentiumCr4Set( )

NAME

pentiumCr4Set( ) - sets specified value to the CR4 register

SYNOPSIS

void pentiumCr4Set
    (
    )
 int cr4; /* value to write CR4 register */

DESCRIPTION

This routine sets a specified value to the CR4 register.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcStart( )

NAME

pentiumPmcStart( ) - start both PMC0 and PMC1

SYNOPSIS

STATUS pentiumPmcStart
    (
    )
 int pmcEvtSel0; /* Performance Event Select Register 0 */
 int pmcEvtSel1; /* Performance Event Select Register 1 */

DESCRIPTION

This routine starts both PMC0 (Performance Monitoring Counter 0) and PMC1 by writing specified events to Performance Event Select Registers. The first parameter is a content of Performance Event Select Register 0, and the second parameter is for the Performance Event Select Register 1.

RETURNS

OK or ERROR if PMC is already started.

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcStop( )

NAME

pentiumPmcStop( ) - stop both PMC0 and PMC1

SYNOPSIS

void pentiumPmcStop (void)

DESCRIPTION

This routine stops both PMC0 (Performance Monitoring Counter 0) and PMC1 by clearing two Performance Event Select Registers.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcStop1( )

NAME

pentiumPmcStop1( ) - stop PMC1

SYNOPSIS

void pentiumPmcStop1 (void)

DESCRIPTION

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

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcGet( )

NAME

pentiumPmcGet( ) - get the contents of PMC0 and PMC1

SYNOPSIS

void pentiumPmcGet
    (
    )
 long long int * pPmc0; /* Performance Monitoring Counter 0 */
 long long int * pPmc1; /* Performance Monitoring Counter 1 */

DESCRIPTION

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

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcGet0( )

NAME

pentiumPmcGet0( ) - get the contents of PMC0

SYNOPSIS

void pentiumPmcGet0
    (
    )
 long long int * pPmc0; /* Performance Monitoring Counter 0 */

DESCRIPTION

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

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcGet1( )

NAME

pentiumPmcGet1( ) - get the contents of PMC1

SYNOPSIS

void pentiumPmcGet1
    (
    )
 long long int * pPmc1; /* Performance Monitoring Counter 1 */

DESCRIPTION

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

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcReset( )

NAME

pentiumPmcReset( ) - reset both PMC0 and PMC1

SYNOPSIS

void pentiumPmcReset (void)

DESCRIPTION

This routine resets both PMC0 (Performance Monitoring Counter 0) and PMC1.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcReset0( )

NAME

pentiumPmcReset0( ) - reset PMC0

SYNOPSIS

void pentiumPmcReset0 (void)

DESCRIPTION

This routine resets PMC0 (Performance Monitoring Counter 0).

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumPmcReset1( )

NAME

pentiumPmcReset1( ) - reset PMC1

SYNOPSIS

void pentiumPmcReset1 (void)

DESCRIPTION

This routine resets PMC1 (Performance Monitoring Counter 1).

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumTscGet64( )

NAME

pentiumTscGet64( ) - get 64Bit TSC (Timestamp Counter)

SYNOPSIS

void pentiumTscGet64
    (
    )
 long long int * pTsc; /* Timestamp Counter */

DESCRIPTION

This routine gets 64Bit TSC by RDTSC instruction. Parameter is a pointer of 64Bit variable to store the content of the Counter.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumTscGet32( )

NAME

pentiumTscGet32( ) - get the lower half of the 64Bit TSC (Timestamp Counter)

SYNOPSIS

UINT32 pentiumTscGet32 (void)

DESCRIPTION

This routine gets a lower half of the 64Bit TSC by RDTSC instruction. RDTSC instruction saves the lower 32Bit in EAX register, so this routine simply returns after executing RDTSC instruction.

RETURNS

Lower half of the 64Bit TSC (Timestamp Counter)

SEE ALSO

pentiumALib


Libraries : Routines

pentiumTscReset( )

NAME

pentiumTscReset( ) - reset the TSC (Timestamp Counter)

SYNOPSIS

void pentiumTscReset (void)

DESCRIPTION

This routine resets the TSC by writing zero to the TSC with WRMSR instruction.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumMsrGet( )

NAME

pentiumMsrGet( ) - get the contents of the specified MSR (Model Specific Register)

SYNOPSIS

void pentiumMsrGet
    (
    )
 int addr; /* MSR address */
 long long int * pData; /* MSR data */

DESCRIPTION

This routine gets the contents of the specified MSR. The first parameter is an address of the MSR. The second parameter is a pointer of 64Bit variable.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumMsrSet( )

NAME

pentiumMsrSet( ) - set a value to the specified MSR (Model Specific Registers)

SYNOPSIS

void pentiumMsrSet
    (
    )
 int addr; /* MSR address */
 long long int * pData; /* MSR data */

DESCRIPTION

This routine sets a value to a specified MSR. The first parameter is an address of the MSR. The second parameter is a pointer of 64Bit variable.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumTlbFlush( )

NAME

pentiumTlbFlush( ) - flush TLBs (Translation Lookaside Buffers)

SYNOPSIS

void pentiumTlbFlush (void)

DESCRIPTION

This routine flushes TLBs by loading the CR3 register. All of the TLBs are automatically invalidated any time the CR3 register is loaded. The page global enable (PGE) flag in register CR4 and the global flag in a page-directory or page-table entry can be used to frequently used pages from being automatically invalidated in the TLBs on a load of CR3 register. The only way to deterministically invalidate global page entries is to clear the PGE flag and then invalidate the TLBs.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumSerialize( )

NAME

pentiumSerialize( ) - execute a serializing instruction CPUID

SYNOPSIS

void pentiumSerialize (void)

DESCRIPTION

This routine executes a serializing instruction CPUID. Serialization means that all modifications to flags, registers, and memory by previous instructions are completed before the next instruction is fetched and executed and all buffered writes have drained to memory.

RETURNS

N/A

SEE ALSO

pentiumALib


Libraries : Routines

pentiumBts( )

NAME

pentiumBts( ) - execute atomic compare-and-exchange instruction to set a bit

SYNOPSIS

STATUS pentiumBts
    (
    )
 char * pFlag; /* flag address */

DESCRIPTION

This routine compares a byte specified by the first parameter with 0. If it is 0, it changes it to TRUE and returns OK. If it is not 0, it returns ERROR. LOCK and CMPXCHGB are used to get the atomic memory access.

RETURNS

OK or ERROR if the specified flag is not zero.

SEE ALSO

pentiumALib


Libraries : Routines

pentiumBtc( )

NAME

pentiumBtc( ) - execute atomic compare-and-exchange instruction to clear a bit

SYNOPSIS

STATUS pentiumBtc
    (
    )
 char * pFlag; /* flag address */

DESCRIPTION

This routine compares a byte specified by the first parameter with TRUE. If it is TRUE, it changes it to 0 and returns OK. If it is not TRUE, it returns ERROR. LOCK and CMPXCHGB are used to get the atomic memory access.

RETURNS

OK or ERROR if the specified flag is not TRUE

SEE ALSO

pentiumALib