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

Disabling device intx assertions in order to enable MSI-x

parent 4c20393f
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,17 @@ void Driver::setStatus(u16 s) {
write_pci_config_word(_bus,_slot,_func,PCI_STATUS_OFFSET,s);
}
u16 Driver::get_command(void)
{
return (pci_readw(PCI_COMMAND_OFFSET));
}
void Driver::set_command(u16 c)
{
pci_writew(PCI_COMMAND_OFFSET, c);
}
u8
Driver::getRevision() {
if (!_present) throw new InitException();
......@@ -117,10 +128,16 @@ Driver::Init(Device* dev) {
parse_pci_config();
debug(fmt("Driver:Init %x:%x") % _vid % _id);
setBusMaster(true);
// Enable MSI-x
if (_have_msix) {
if (is_intx_enabled()) {
disable_intx();
}
}
debug(fmt("Driver initialized %x:%x") % _vid % _id);
return true;
}
......@@ -210,6 +227,26 @@ bool Driver::parse_pci_msix(u8 off)
return true;
}
bool Driver::is_intx_enabled(void)
{
u16 command = get_command();
return ( (command & PCI_COMMAND_INTX_DISABLE) == 0 );
}
void Driver::enable_intx(void)
{
u16 command = get_command();
command &= ~PCI_COMMAND_INTX_DISABLE;
set_command(command);
}
void Driver::disable_intx(void)
{
u16 command = get_command();
command |= PCI_COMMAND_INTX_DISABLE;
set_command(command);
}
u8 Driver::pci_readb(u8 offset)
{
return read_pci_config_byte(_bus, _slot, _func, offset);
......
......@@ -50,6 +50,8 @@ public:
u16 getStatus();
void setStatus(u16 s);
u16 get_command(void);
void set_command(u16 c);
bool getBusMaster();
void setBusMaster(bool m);
virtual void dumpConfig() const;
......@@ -88,6 +90,13 @@ protected:
bool allocateBARs();
virtual bool earlyInitChecks();
// Enable/Disable intx assertions
bool is_intx_enabled(void);
// Enable intx assertion
// intx assertions should be disabled in order to use MSI-x
void enable_intx(void);
void disable_intx(void);
// Parsing of extra capabilities
virtual bool parse_pci_capabilities(void);
virtual bool parse_pci_msix(u8 off);
......
......@@ -63,6 +63,10 @@ using processor::outl;
PCI_CAPABILITIES_PTR = 0x34,
};
enum pci_command_bits {
PCI_COMMAND_INTX_DISABLE = (1 << 10),
};
// Capability Register Offsets
enum pci_capabilities_offsets {
PCI_CAP_OFF_ID = 0x0,
......
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