Skip to content

Commit

Permalink
ac97 trolling on real hw :(
Browse files Browse the repository at this point in the history
  • Loading branch information
marceldobehere committed Mar 4, 2024
1 parent 3046fab commit 6714980
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
Binary file modified MaslOS2.iso
Binary file not shown.
52 changes: 29 additions & 23 deletions kernel/devices/ac97/ac97.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ namespace AC97
PCI::enable_bus_mastering(address);
PrintMsg("> Enabled PCI Bus Mastering");
Println();



PrintfMsgCol("> AC97 REV: %d", Colors.bgreen, ((PCI::PCIDeviceHeader*)PCIBaseAddress)->Revision_ID);
Expand All @@ -220,14 +221,39 @@ namespace AC97
io_wait(1000);
}


bool driverOkay = true;
if (((PCI::PCIHeader0*)PCIBaseAddress)->BAR1 == 0)
{
PrintMsg("> AC97 Driver only uses BAR0 and is not supported");
PrintMsgEndLayer("AC97Driver");
return;
}

// m_address = address;
//m_mixer_address = PCI::io_read_word(address, PCI_BAR0) & ~1;
m_mixer_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 0);

//PrintMsgCol("> Mixer Address: {}", ConvertHexToString(m_mixer_address), Colors.yellow);
//PrintMsgCol("> Mixer Address (2): {}", ConvertHexToString(((PCI::PCIHeader0*)address)->BAR0), Colors.yellow);
if (m_mixer_type.type == PCI::PCI_BAR_TYPE_ENUM::MMIO64)
{
PrintMsgCol("> BUS TYPE USING BAR2", Colors.orange);
m_bus_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 2);
}
else
{
PrintMsgCol("> BUS TYPE USING BAR1", Colors.orange);
m_bus_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 1);
}

// Soft Reset
PrintfMsgCol("> AC97 SOFT RESET", Colors.orange);
PCI::write_byte(address, m_bus_type, BusRegisters::GLOBAL_CONTROL, GlobalControl::COLD_RESET);
io_wait(1000);
PCI::write_byte(address, m_bus_type, BusRegisters::GLOBAL_CONTROL, 0);
io_wait(1000);

if (osData.ac97Driver != NULL)
{
PrintMsg("> AC97 Driver already exists");
Expand All @@ -236,13 +262,6 @@ namespace AC97
}





io_wait(500);



//PrintMsgCol("> PCI Address: {}", ConvertHexToString(address), Colors.yellow);
//Println();
//IRQHandler(PCI::read_byte(address, PCI_INTERRUPT_LINE)),
Expand All @@ -252,23 +271,10 @@ namespace AC97
IRQHandlerCallbackFuncs[irqId] = (void*)&AC97Driver::HandleIRQ;
IRQHandlerCallbackHelpers[irqId] = (void*)this;
}


// m_address = address;
//m_mixer_address = PCI::io_read_word(address, PCI_BAR0) & ~1;
m_mixer_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 0);
//PrintMsgCol("> Mixer Address: {}", ConvertHexToString(m_mixer_address), Colors.yellow);
//PrintMsgCol("> Mixer Address (2): {}", ConvertHexToString(((PCI::PCIHeader0*)address)->BAR0), Colors.yellow);
if (m_mixer_type.type == PCI::PCI_BAR_TYPE_ENUM::MMIO64)
{
PrintMsgCol("> BUS TYPE USING BAR2", Colors.orange);
m_bus_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 2);
}
else
{
PrintMsgCol("> BUS TYPE USING BAR1", Colors.orange);
m_bus_type = PCI::pci_get_bar((PCI::PCIHeader0*)address, 1);
}



//PrintMsgCol("> Mixer Address (3): {}", ConvertHexToString(m_mixer_address), Colors.yellow);

//PrintMsgCol("> Bus Address: {}", ConvertHexToString(m_bus_address), Colors.yellow);
Expand Down

0 comments on commit 6714980

Please sign in to comment.