Skip to content
Snippets Groups Projects
Commit 826cea48 authored by Guy Zana's avatar Guy Zana
Browse files

Moved msix_compose() to apic_driver class

parent a2220493
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,6 @@ public:
virtual void self_ipi(unsigned vector);
virtual void ipi(unsigned cpu, unsigned vector);
virtual void eoi();
// vector should be above 31, below 15 will fail
// dest_id is the apic id, if using an io_apic.
bool compose_msix(u8 vector, u8 dest_id, u64& out_address, u32& out_data);
protected:
u32 _apic_base_lo;
u32 _apic_base_hi;
};
apic_driver::~apic_driver()
......@@ -23,7 +17,7 @@ apic_driver::~apic_driver()
}
x2apic::x2apic()
: _apic_base_lo(0xfee00000), _apic_base_hi(0)
: apic_driver()
{
processor::wrmsr(msr::IA32_APIC_BASE, _apic_base_lo | (3 << 10));
}
......@@ -62,27 +56,26 @@ void apic_driver::set_lvt(apiclvt source, unsigned vector)
write(static_cast<apicreg>(source), vector);
}
bool x2apic::compose_msix(u8 vector, u8 dest_id, u64& out_address, u32& out_data)
msi_message apic_driver::compose_msix(u8 vector, u8 dest_id)
{
msi_message msg;
if (vector <= 15) {
return false;
return msg;
}
u64 addr =
msg._addr =
( (u64)_apic_base_hi << 32 ) |
( _apic_base_lo & 0xFFF00000 ) |
( dest_id << 12 );
u32 data =
msg._data =
( delivery_mode::FIXED_DELIVERY << msi_data_fields::MSI_DELIVERY_MODE ) |
( level_assertion::MSI_ASSSERT << msi_data_fields::MSI_LEVEL_ASSERTION ) |
( trigger_mode::TRIGGER_MODE_EDGE << msi_data_fields::MSI_TRIGGER_MODE ) |
vector;
out_address = addr;
out_data = data;
return true;
return msg;
}
}
......@@ -67,14 +67,27 @@ enum trigger_mode {
TRIGGER_MODE_LEVEL = 1
};
struct msi_message {
msi_message() : _addr(0), _data(0) {}
u64 _addr;
u32 _data;
};
class apic_driver {
public:
apic_driver() : _apic_base_lo(0xfee00000), _apic_base_hi(0) {}
virtual ~apic_driver();
virtual void self_ipi(unsigned vector) = 0;
virtual void ipi(unsigned cpu, unsigned vector) = 0;
virtual void eoi() = 0;
virtual void write(apicreg reg, u32 value) = 0;
void set_lvt(apiclvt reg, unsigned vector);
// vector should be above 31, below 15 will fail
// dest_id is the apic id, if using an io_apic.
msi_message compose_msix(u8 vector, u8 dest_id);
protected:
u32 _apic_base_lo;
u32 _apic_base_hi;
};
extern apic_driver* apic;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment