NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
Lapic Class Reference

Static Public Member Functions

static ALWAYS_INLINE unsigned id ()
static ALWAYS_INLINE unsigned version ()
static ALWAYS_INLINE unsigned lvt_max ()
static ALWAYS_INLINE void eoi ()
static ALWAYS_INLINE void set_timer (unsigned val)
static ALWAYS_INLINE unsigned get_timer ()
static void init ()
static void calibrate ()
static void lvt_vector (unsigned) asm("lvt_vector")

Static Public Attributes

static unsigned freq_tsc
static unsigned freq_bus

Additional Inherited Members

Public Types inherited from Apic
enum  Delivery_mode {
  DLV_FIXED = 0U << 8 , DLV_LOWEST_PRIO = 1U << 8 , DLV_SMI = 2U << 8 , DLV_REMOTE_READ = 3U << 8 ,
  DLV_NMI = 4U << 8 , DLV_INIT = 5U << 8 , DLV_SIPI = 6U << 8 , DLV_EXTINT = 7U << 8
}
enum  Mask { UNMASKED = 0U << 16 , MASKED = 1U << 16 }

Member Function Documentation

◆ calibrate()

void Lapic::calibrate ( )
static
77{
78 assert (0);
79/*
80 uint32 v1 = read (LAPIC_TMR_CCR);
81 uint32 t1 = static_cast<uint32>(rdtsc());
82 Acpi::delay (250);
83 uint32 v2 = read (LAPIC_TMR_CCR);
84 uint32 t2 = static_cast<uint32>(rdtsc());
85
86 freq_tsc = (t2 - t1) / 250;
87 freq_bus = (v1 - v2) / 250;
88
89 trace (TRACE_CPU, "TSC:%u kHz BUS:%u kHz", freq_tsc, freq_bus);
90*/
91}

◆ eoi()

ALWAYS_INLINE void Lapic::eoi ( )
inlinestatic
112 {
113 write (LAPIC_EOI, 0);
114 }

◆ get_timer()

ALWAYS_INLINE unsigned Lapic::get_timer ( )
inlinestatic
124 {
125 return read (LAPIC_TMR_CCR);
126 }

◆ id()

ALWAYS_INLINE unsigned Lapic::id ( )
inlinestatic
94 {
95 return read (LAPIC_IDR) >> 24 & 0xff;
96 }

◆ init()

void Lapic::init ( )
static
32{
33 assert (0);
34/*
35 Paddr apic_base = Msr::read<Paddr>(Msr::IA32_APIC_BASE);
36
37 Pd::kern.Space_mem::delreg (apic_base & ~PAGE_MASK);
38 Hptp (Hpt::current()).update (LAPIC_ADDR, 0, Hpt::HPT_NX | Hpt::HPT_G | Hpt::HPT_UC | Hpt::HPT_W | Hpt::HPT_P, apic_base & ~PAGE_MASK);
39
40 Msr::write (Msr::IA32_APIC_BASE, apic_base | 0x800);
41
42 uint32 svr = read (LAPIC_SVR);
43 if (!(svr & 0x100))
44 write (LAPIC_SVR, svr | 0x100);
45
46 switch (lvt_max()) {
47 default:
48 set_lvt (LAPIC_LVT_THERM, VEC_LVT_THERM, DLV_FIXED);
49 case 4:
50 set_lvt (LAPIC_LVT_PERFM, VEC_LVT_PERFM, DLV_FIXED);
51 case 3:
52 set_lvt (LAPIC_LVT_ERROR, VEC_LVT_ERROR, DLV_FIXED);
53 case 2:
54 set_lvt (LAPIC_LVT_LINT1, 0, DLV_NMI);
55 case 1:
56 set_lvt (LAPIC_LVT_LINT0, 0, DLV_EXTINT, MASKED);
57 case 0:
58 set_lvt (LAPIC_LVT_TIMER, VEC_LVT_TIMER, DLV_FIXED);
59 }
60
61 write (LAPIC_TPR, 0x10);
62 write (LAPIC_TMR_DCR, 0xb);
63 write (LAPIC_TMR_ICR, ~0U);
64
65 Cpu::id = find_cpu (id());
66
67 if ((Cpu::bsp = apic_base & 0x100))
68 calibrate();
69
70 write (LAPIC_TMR_ICR, 0);
71
72 trace (TRACE_APIC, "APIC:%#lx ID:%#x VER:%#x LVT:%#x", apic_base & ~PAGE_MASK, id(), version(), lvt_max());
73*/
74}

◆ lvt_max()

ALWAYS_INLINE unsigned Lapic::lvt_max ( )
inlinestatic
106 {
107 return read (LAPIC_LVR) >> 16 & 0xff;
108 }

◆ lvt_vector()

void Lapic::lvt_vector ( unsigned vector)
static
99{
100 //unsigned lvt = vector - VEC_LVT;
101
102 switch (vector) {
103 case VEC_LVT_TIMER: timer_handler(); break;
104 }
105
106 eoi();
107
108}

◆ set_timer()

ALWAYS_INLINE void Lapic::set_timer ( unsigned val)
inlinestatic
118 {
119 write (LAPIC_TMR_ICR, val);
120 }

◆ version()

ALWAYS_INLINE unsigned Lapic::version ( )
inlinestatic
100 {
101 return read (LAPIC_LVR) & 0xff;
102 }

The documentation for this class was generated from the following files: