RTEMS 6.1-rc7
Loading...
Searching...
No Matches
Macros | Functions | Variables
apic.h File Reference

APIC definitions. More...

#include <rtems/score/basedefs.h>

Go to the source code of this file.

Macros

#define APIC_BASE_MSR   0x1B
 
#define APIC_BASE_MSR_ENABLE   0x800
 
#define xAPIC_MAX_APIC_ID   0xFE
 
#define LAPIC_OFFSET(val)   (val >> 2)
 
#define LAPIC_REGISTER_ID   LAPIC_OFFSET(0x20)
 
#define LAPIC_REGISTER_EOI   LAPIC_OFFSET(0x0B0)
 
#define LAPIC_REGISTER_SPURIOUS   LAPIC_OFFSET(0x0F0)
 
#define LAPIC_REGISTER_ICR_LOW   LAPIC_OFFSET(0x300)
 
#define LAPIC_REGISTER_ICR_HIGH   LAPIC_OFFSET(0x310)
 
#define LAPIC_REGISTER_LVT_TIMER   LAPIC_OFFSET(0x320)
 
#define LAPIC_REGISTER_TIMER_INITCNT   LAPIC_OFFSET(0x380)
 
#define LAPIC_REGISTER_TIMER_CURRCNT   LAPIC_OFFSET(0x390)
 
#define LAPIC_REGISTER_TIMER_DIV   LAPIC_OFFSET(0x3E0)
 
#define LAPIC_LVT_MASK   0x10000
 
#define LAPIC_ICR_HIGH_MASK   0x00FFFFFF
 
#define LAPIC_ICR_LOW_MASK   0xFFF32000
 
#define LAPIC_ICR_DELIV_INIT   0x500
 
#define LAPIC_ICR_DELIV_START   0x600
 
#define LAPIC_ICR_DELIV_STAT_PEND   0x1000
 
#define LAPIC_ICR_ASSERT   0x4000
 
#define LAPIC_ICR_TRIG_LEVEL   0x8000
 
#define LAPIC_EOI_ACK   0
 
#define LAPIC_SELECT_TMR_PERIODIC   0x20000
 
#define LAPIC_SPURIOUS_ENABLE   0x100
 
#define LAPIC_TIMER_NUM_CALIBRATIONS   5
 
#define LAPIC_TIMER_DIVIDE_VALUE   16
 
#define LAPIC_TIMER_SELECT_DIVIDER   3
 
#define PIT_FREQUENCY   1193180
 
#define PIT_CALIBRATE_DIVIDER   20
 
#define PIT_CALIBRATE_TICKS   (PIT_FREQUENCY/PIT_CALIBRATE_DIVIDER)
 
#define PIT_PORT_CHAN0   0x40
 
#define PIT_PORT_CHAN1   0x41
 
#define PIT_PORT_CHAN2   0x42
 
#define PIT_PORT_CHAN2_GATE   0x61
 
#define PIT_CHAN2_TIMER_BIT   1
 
#define PIT_CHAN2_SPEAKER_BIT   2
 
#define PIT_PORT_MCR   0x43
 
#define PIT_SELECT_CHAN0   0b00000000
 
#define PIT_SELECT_CHAN1   0b01000000
 
#define PIT_SELECT_CHAN2   0b10000000
 
#define PIT_SELECT_ACCESS_LOHI   0b00110000
 
#define PIT_SELECT_ONE_SHOT_MODE   0b00000010
 
#define PIT_SELECT_BINARY_MODE   0
 
#define PIT_CHAN2_ENABLE(chan2_value)
 
#define PIT_CHAN2_WRITE_TICKS(pit_ticks)
 
#define PIT_CHAN2_START_DELAY(chan2_value)
 
#define PIT_CHAN2_WAIT_DELAY(pit_ticks)
 

Functions

 RTEMS_STATIC_ASSERT (PIT_CALIBRATE_TICKS<=0xffff, PIT_CALIBRATE_DIVIDER)
 
bool lapic_initialize (void)
 Initializes the Local APIC by hardware and software enabling it.
 
uint32_t lapic_timer_calc_ticks (uint64_t desired_freq_hz)
 Calculates the number of Local APIC timer ticks which can be used with lapic_timer_enable to set up a timer of given frequency.
 
void lapic_timer_enable (uint32_t reload_value)
 Enables the Local APIC timer.
 
uint8_t lapic_get_id (void)
 Retrieves the Local APIC ID.
 
void lapic_eoi (void)
 Signals an end of interrupt to the Local APIC.
 

Variables

volatile uint32_t * amd64_lapic_base
 
uint8_t amd64_lapic_to_cpu_map [xAPIC_MAX_APIC_ID+1]
 

Detailed Description

APIC definitions.

Macro Definition Documentation

◆ PIT_CHAN2_ENABLE

#define PIT_CHAN2_ENABLE (   chan2_value)
Value:
/* Enable the channel 2 timer gate and disable the speaker output */ \
chan2_value = (inport_byte(PIT_PORT_CHAN2_GATE) | PIT_CHAN2_TIMER_BIT) \
& ~PIT_CHAN2_SPEAKER_BIT; \
outport_byte(PIT_PORT_CHAN2_GATE, chan2_value); \
/* Initialize PIT in one-shot mode on Channel 2 */ \
outport_byte( \
PIT_PORT_MCR, \
PIT_SELECT_CHAN2 | PIT_SELECT_ACCESS_LOHI | \
PIT_SELECT_ONE_SHOT_MODE | PIT_SELECT_BINARY_MODE \
); \

◆ PIT_CHAN2_START_DELAY

#define PIT_CHAN2_START_DELAY (   chan2_value)
Value:
/* Restart PIT by disabling the gated input and then re-enabling it */ \
chan2_value &= ~PIT_CHAN2_TIMER_BIT; \
outport_byte(PIT_PORT_CHAN2_GATE, chan2_value); \
chan2_value |= PIT_CHAN2_TIMER_BIT; \
outport_byte(PIT_PORT_CHAN2_GATE, chan2_value); \

◆ PIT_CHAN2_WAIT_DELAY

#define PIT_CHAN2_WAIT_DELAY (   pit_ticks)
Value:
do { \
uint32_t curr_ticks = pit_ticks; \
while ( curr_ticks <= pit_ticks ) { \
/* Send latch command to read multi-byte value atomically */ \
outport_byte(PIT_PORT_MCR, PIT_SELECT_CHAN2); \
curr_ticks = inport_byte(PIT_PORT_CHAN2); \
curr_ticks |= inport_byte(PIT_PORT_CHAN2) << 8; \
} \
} while(0); \

◆ PIT_CHAN2_WRITE_TICKS

#define PIT_CHAN2_WRITE_TICKS (   pit_ticks)
Value:
/* Set PIT reload value */ \
outport_byte(PIT_PORT_CHAN2, pit_ticks & 0xff); \
stub_io_wait(); \
outport_byte(PIT_PORT_CHAN2, (pit_ticks >> 8) & 0xff); \

Function Documentation

◆ lapic_get_id()

uint8_t lapic_get_id ( void  )
inline

Retrieves the Local APIC ID.

Returns
Local APIC ID

◆ lapic_initialize()

bool lapic_initialize ( void  )

Initializes the Local APIC by hardware and software enabling it.

Initializes the Local APIC by hardware and software enabling it, and sets up the amd64_lapic_base pointer that can be used as a 32-bit addressable array to access Local APIC registers.

Returns
true if successful.

◆ lapic_timer_calc_ticks()

uint32_t lapic_timer_calc_ticks ( uint64_t  desired_freq_hz)

Calculates the number of Local APIC timer ticks which can be used with lapic_timer_enable to set up a timer of given frequency.

Parameters
desired_freq_hzThe frequency in Hz.
Returns
The number of Local APIC timer ticks.

◆ lapic_timer_enable()

void lapic_timer_enable ( uint32_t  reload_value)

Enables the Local APIC timer.

Parameters
reload_valueNumber of ticks per interrupt.