mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Move ACPI and DSDT files to Core directory
This commit is contained in:
parent
b06cc8da26
commit
83bd843e2b
@ -18,8 +18,6 @@
|
||||
#include <types.h>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <elf.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "multiboot2.h"
|
||||
#include "../../../../../kernel.h"
|
||||
@ -43,14 +41,6 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
||||
BootInfo mb2binfo{};
|
||||
|
||||
{
|
||||
uint64_t div = 1193180 / 1000;
|
||||
outb(0x43, 0xB6);
|
||||
outb(0x42, (uint8_t)div);
|
||||
outb(0x42, (uint8_t)(div >> 8));
|
||||
uint8_t tmp = inb(0x61);
|
||||
if (tmp != (tmp | 3))
|
||||
outb(0x61, tmp | 3);
|
||||
|
||||
auto InfoAddress = Info;
|
||||
for (auto Tag = (struct multiboot_tag *)((uint8_t *)InfoAddress + 8);
|
||||
;
|
||||
@ -306,9 +296,6 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tmp = inb(0x61) & 0xFC;
|
||||
outb(0x61, tmp);
|
||||
}
|
||||
|
||||
Entry(&mb2binfo);
|
||||
|
@ -1,294 +0,0 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Kernel is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FENNIX_KERNEL_ACPI_H__
|
||||
#define __FENNIX_KERNEL_ACPI_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <boot/binfo.h>
|
||||
#include <ints.hpp>
|
||||
#include <cpu.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace ACPI
|
||||
{
|
||||
class ACPI
|
||||
{
|
||||
public:
|
||||
struct ACPIHeader
|
||||
{
|
||||
unsigned char Signature[4];
|
||||
uint32_t Length;
|
||||
uint8_t Revision;
|
||||
uint8_t Checksum;
|
||||
uint8_t OEMID[6];
|
||||
uint8_t OEMTableID[8];
|
||||
uint32_t OEMRevision;
|
||||
uint32_t CreatorID;
|
||||
uint32_t CreatorRevision;
|
||||
} __packed;
|
||||
|
||||
struct GenericAddressStructure
|
||||
{
|
||||
uint8_t AddressSpace;
|
||||
uint8_t BitWidth;
|
||||
uint8_t BitOffset;
|
||||
uint8_t AccessSize;
|
||||
uint64_t Address;
|
||||
} __packed;
|
||||
|
||||
struct MCFGHeader
|
||||
{
|
||||
struct ACPIHeader Header;
|
||||
uint64_t Reserved;
|
||||
} __packed;
|
||||
|
||||
struct HPETHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint8_t HardwareRevID;
|
||||
uint8_t ComparatorCount : 5;
|
||||
uint8_t CounterSize : 1;
|
||||
uint8_t Reserved : 1;
|
||||
uint8_t LegacyReplacement : 1;
|
||||
uint16_t PCIVendorID;
|
||||
struct GenericAddressStructure Address;
|
||||
uint8_t HPETNumber;
|
||||
uint16_t MinimumTick;
|
||||
uint8_t PageProtection;
|
||||
} __packed;
|
||||
|
||||
struct FADTHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t FirmwareCtrl;
|
||||
uint32_t Dsdt;
|
||||
uint8_t Reserved;
|
||||
uint8_t PreferredPowerManagementProfile;
|
||||
uint16_t SCI_Interrupt;
|
||||
uint32_t SMI_CommandPort;
|
||||
uint8_t AcpiEnable;
|
||||
uint8_t AcpiDisable;
|
||||
uint8_t S4BIOS_REQ;
|
||||
uint8_t PSTATE_Control;
|
||||
uint32_t PM1aEventBlock;
|
||||
uint32_t PM1bEventBlock;
|
||||
uint32_t PM1aControlBlock;
|
||||
uint32_t PM1bControlBlock;
|
||||
uint32_t PM2ControlBlock;
|
||||
uint32_t PMTimerBlock;
|
||||
uint32_t GPE0Block;
|
||||
uint32_t GPE1Block;
|
||||
uint8_t PM1EventLength;
|
||||
uint8_t PM1ControlLength;
|
||||
uint8_t PM2ControlLength;
|
||||
uint8_t PMTimerLength;
|
||||
uint8_t GPE0Length;
|
||||
uint8_t GPE1Length;
|
||||
uint8_t GPE1Base;
|
||||
uint8_t CStateControl;
|
||||
uint16_t WorstC2Latency;
|
||||
uint16_t WorstC3Latency;
|
||||
uint16_t FlushSize;
|
||||
uint16_t FlushStride;
|
||||
uint8_t DutyOffset;
|
||||
uint8_t DutyWidth;
|
||||
uint8_t DayAlarm;
|
||||
uint8_t MonthAlarm;
|
||||
uint8_t Century;
|
||||
uint16_t BootArchitectureFlags;
|
||||
uint8_t Reserved2;
|
||||
uint32_t Flags;
|
||||
struct GenericAddressStructure ResetReg;
|
||||
uint8_t ResetValue;
|
||||
uint8_t Reserved3[3];
|
||||
uint64_t X_FirmwareControl;
|
||||
uint64_t X_Dsdt;
|
||||
struct GenericAddressStructure X_PM1aEventBlock;
|
||||
struct GenericAddressStructure X_PM1bEventBlock;
|
||||
struct GenericAddressStructure X_PM1aControlBlock;
|
||||
struct GenericAddressStructure X_PM1bControlBlock;
|
||||
struct GenericAddressStructure X_PM2ControlBlock;
|
||||
struct GenericAddressStructure X_PMTimerBlock;
|
||||
struct GenericAddressStructure X_GPE0Block;
|
||||
struct GenericAddressStructure X_GPE1Block;
|
||||
} __packed;
|
||||
|
||||
struct BGRTHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint16_t Version;
|
||||
uint8_t Status;
|
||||
uint8_t ImageType;
|
||||
uint64_t ImageAddress;
|
||||
uint32_t ImageOffsetX;
|
||||
uint32_t ImageOffsetY;
|
||||
};
|
||||
|
||||
struct SRATHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t TableRevision; // Must be value 1
|
||||
uint64_t Reserved; // Reserved, must be zero
|
||||
};
|
||||
|
||||
struct TPM2Header
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t Flags;
|
||||
uint64_t ControlAddress;
|
||||
uint32_t StartMethod;
|
||||
};
|
||||
|
||||
struct TCPAHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint16_t Reserved;
|
||||
uint32_t MaxLogLength;
|
||||
uint64_t LogAddress;
|
||||
};
|
||||
|
||||
struct WAETHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t Flags;
|
||||
};
|
||||
|
||||
struct HESTHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t ErrorSourceCount;
|
||||
};
|
||||
|
||||
struct MADTHeader
|
||||
{
|
||||
ACPIHeader Header;
|
||||
uint32_t LocalControllerAddress;
|
||||
uint32_t Flags;
|
||||
char Entries[];
|
||||
} __packed;
|
||||
|
||||
ACPIHeader *XSDT = nullptr;
|
||||
MCFGHeader *MCFG = nullptr;
|
||||
HPETHeader *HPET = nullptr;
|
||||
FADTHeader *FADT = nullptr;
|
||||
BGRTHeader *BGRT = nullptr;
|
||||
SRATHeader *SRAT = nullptr;
|
||||
TPM2Header *TPM2 = nullptr;
|
||||
TCPAHeader *TCPA = nullptr;
|
||||
WAETHeader *WAET = nullptr;
|
||||
MADTHeader *MADT = nullptr;
|
||||
HESTHeader *HEST = nullptr;
|
||||
bool XSDTSupported = false;
|
||||
|
||||
void *FindTable(ACPIHeader *ACPIHeader, char *Signature);
|
||||
void SearchTables(ACPIHeader *Header);
|
||||
ACPI();
|
||||
~ACPI();
|
||||
};
|
||||
|
||||
class MADT
|
||||
{
|
||||
public:
|
||||
struct APICHeader
|
||||
{
|
||||
uint8_t Type;
|
||||
uint8_t Length;
|
||||
} __packed;
|
||||
|
||||
struct MADTIOApic
|
||||
{
|
||||
struct APICHeader Header;
|
||||
uint8_t APICID;
|
||||
uint8_t reserved;
|
||||
uint32_t Address;
|
||||
uint32_t GSIBase;
|
||||
} __packed;
|
||||
|
||||
struct MADTIso
|
||||
{
|
||||
struct APICHeader Header;
|
||||
uint8_t BuSSource;
|
||||
uint8_t IRQSource;
|
||||
uint32_t GSI;
|
||||
uint16_t Flags;
|
||||
} __packed;
|
||||
|
||||
struct MADTNmi
|
||||
{
|
||||
struct APICHeader Header;
|
||||
uint8_t processor;
|
||||
uint16_t flags;
|
||||
uint8_t lint;
|
||||
} __packed;
|
||||
|
||||
struct LocalAPIC
|
||||
{
|
||||
struct APICHeader Header;
|
||||
uint8_t ACPIProcessorId;
|
||||
uint8_t APICId;
|
||||
uint32_t Flags;
|
||||
} __packed;
|
||||
|
||||
struct LAPIC
|
||||
{
|
||||
uint8_t id;
|
||||
uintptr_t PhysicalAddress;
|
||||
void *VirtualAddress;
|
||||
};
|
||||
|
||||
std::vector<MADTIOApic *> ioapic;
|
||||
std::vector<MADTIso *> iso;
|
||||
std::vector<MADTNmi *> nmi;
|
||||
std::vector<LocalAPIC *> lapic;
|
||||
struct LAPIC *LAPICAddress;
|
||||
uint16_t CPUCores;
|
||||
|
||||
MADT(ACPI::MADTHeader *madt);
|
||||
~MADT();
|
||||
};
|
||||
|
||||
class DSDT : public Interrupts::Handler
|
||||
{
|
||||
private:
|
||||
uint32_t SMI_CMD = 0;
|
||||
uint8_t ACPI_ENABLE = 0;
|
||||
uint8_t ACPI_DISABLE = 0;
|
||||
uint32_t PM1a_CNT = 0;
|
||||
uint32_t PM1b_CNT = 0;
|
||||
uint16_t SLP_TYPa = 0;
|
||||
uint16_t SLP_TYPb = 0;
|
||||
uint16_t SLP_EN = 0;
|
||||
uint16_t SCI_EN = 0;
|
||||
uint8_t PM1_CNT_LEN = 0;
|
||||
|
||||
ACPI *acpi;
|
||||
void OnInterruptReceived(CPU::x64::TrapFrame *Frame);
|
||||
|
||||
public:
|
||||
bool ACPIShutdownSupported = false;
|
||||
|
||||
void Reboot();
|
||||
void Shutdown();
|
||||
|
||||
DSDT(ACPI *acpi);
|
||||
~DSDT();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_ACPI_H__
|
@ -18,6 +18,7 @@
|
||||
#include "apic.hpp"
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <uart.hpp>
|
||||
#include <lock.hpp>
|
||||
#include <cpu.hpp>
|
||||
@ -25,7 +26,6 @@
|
||||
#include <io.h>
|
||||
|
||||
#include "../../../kernel.h"
|
||||
#include "../acpi.hpp"
|
||||
|
||||
NewLock(APICLock);
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
#include <smp.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <ints.hpp>
|
||||
#include <assert.h>
|
||||
#include <cpu.hpp>
|
||||
#include <atomic>
|
||||
|
||||
#include "../../../kernel.h"
|
||||
#include "../acpi.hpp"
|
||||
#include "apic.hpp"
|
||||
|
||||
extern "C" uint64_t _trampoline_start, _trampoline_end;
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Kernel is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acpi.hpp"
|
||||
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
namespace ACPI
|
||||
{
|
||||
__no_sanitize("alignment") void *ACPI::FindTable(ACPI::ACPIHeader *ACPIHeader, char *Signature)
|
||||
{
|
||||
for (uint64_t t = 0; t < ((ACPIHeader->Length - sizeof(ACPI::ACPIHeader)) / (XSDTSupported ? 8 : 4)); t++)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
|
||||
// TODO: Should I be concerned about unaligned memory access?
|
||||
ACPI::ACPIHeader *SDTHdr = nullptr;
|
||||
if (XSDTSupported)
|
||||
SDTHdr = (ACPI::ACPIHeader *)(*(uint64_t *)((uint64_t)ACPIHeader + sizeof(ACPI::ACPIHeader) + (t * 8)));
|
||||
else
|
||||
SDTHdr = (ACPI::ACPIHeader *)(*(uint32_t *)((uint64_t)ACPIHeader + sizeof(ACPI::ACPIHeader) + (t * 4)));
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (SDTHdr->Signature[i] != Signature[i])
|
||||
break;
|
||||
if (i == 3)
|
||||
{
|
||||
trace("%s found at address %p", Signature, (uintptr_t)SDTHdr);
|
||||
return SDTHdr;
|
||||
}
|
||||
}
|
||||
}
|
||||
// warn("%s not found!", Signature);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ACPI::SearchTables(ACPIHeader *Header)
|
||||
{
|
||||
if (!Header)
|
||||
return;
|
||||
|
||||
HPET = (HPETHeader *)FindTable(Header, (char *)"HPET");
|
||||
FADT = (FADTHeader *)FindTable(Header, (char *)"FACP");
|
||||
MCFG = (MCFGHeader *)FindTable(Header, (char *)"MCFG");
|
||||
BGRT = (BGRTHeader *)FindTable(Header, (char *)"BGRT");
|
||||
SRAT = (SRATHeader *)FindTable(Header, (char *)"SRAT");
|
||||
TPM2 = (TPM2Header *)FindTable(Header, (char *)"TPM2");
|
||||
TCPA = (TCPAHeader *)FindTable(Header, (char *)"TCPA");
|
||||
WAET = (WAETHeader *)FindTable(Header, (char *)"WAET");
|
||||
MADT = (MADTHeader *)FindTable(Header, (char *)"APIC");
|
||||
HEST = (HESTHeader *)FindTable(Header, (char *)"HEST");
|
||||
FindTable(Header, (char *)"BERT");
|
||||
FindTable(Header, (char *)"CPEP");
|
||||
FindTable(Header, (char *)"DSDT");
|
||||
FindTable(Header, (char *)"ECDT");
|
||||
FindTable(Header, (char *)"EINJ");
|
||||
FindTable(Header, (char *)"ERST");
|
||||
FindTable(Header, (char *)"FACS");
|
||||
FindTable(Header, (char *)"MSCT");
|
||||
FindTable(Header, (char *)"MPST");
|
||||
FindTable(Header, (char *)"OEMx");
|
||||
FindTable(Header, (char *)"PMTT");
|
||||
FindTable(Header, (char *)"PSDT");
|
||||
FindTable(Header, (char *)"RASF");
|
||||
FindTable(Header, (char *)"RSDT");
|
||||
FindTable(Header, (char *)"SBST");
|
||||
FindTable(Header, (char *)"SLIT");
|
||||
FindTable(Header, (char *)"SSDT");
|
||||
FindTable(Header, (char *)"XSDT");
|
||||
FindTable(Header, (char *)"DRTM");
|
||||
FindTable(Header, (char *)"FPDT");
|
||||
FindTable(Header, (char *)"GTDT");
|
||||
FindTable(Header, (char *)"PCCT");
|
||||
FindTable(Header, (char *)"S3PT");
|
||||
FindTable(Header, (char *)"MATR");
|
||||
FindTable(Header, (char *)"MSDM");
|
||||
FindTable(Header, (char *)"WPBT");
|
||||
FindTable(Header, (char *)"OSDT");
|
||||
FindTable(Header, (char *)"RSDP");
|
||||
FindTable(Header, (char *)"NFIT");
|
||||
FindTable(Header, (char *)"ASF!");
|
||||
FindTable(Header, (char *)"BOOT");
|
||||
FindTable(Header, (char *)"CSRT");
|
||||
FindTable(Header, (char *)"DBG2");
|
||||
FindTable(Header, (char *)"DBGP");
|
||||
FindTable(Header, (char *)"DMAR");
|
||||
FindTable(Header, (char *)"IBFT");
|
||||
FindTable(Header, (char *)"IORT");
|
||||
FindTable(Header, (char *)"IVRS");
|
||||
FindTable(Header, (char *)"LPIT");
|
||||
FindTable(Header, (char *)"MCHI");
|
||||
FindTable(Header, (char *)"MTMR");
|
||||
FindTable(Header, (char *)"SLIC");
|
||||
FindTable(Header, (char *)"SPCR");
|
||||
FindTable(Header, (char *)"SPMI");
|
||||
FindTable(Header, (char *)"UEFI");
|
||||
FindTable(Header, (char *)"VRTC");
|
||||
FindTable(Header, (char *)"WDAT");
|
||||
FindTable(Header, (char *)"WDDT");
|
||||
FindTable(Header, (char *)"WDRT");
|
||||
FindTable(Header, (char *)"ATKG");
|
||||
FindTable(Header, (char *)"GSCI");
|
||||
FindTable(Header, (char *)"IEIT");
|
||||
FindTable(Header, (char *)"HMAT");
|
||||
FindTable(Header, (char *)"CEDT");
|
||||
FindTable(Header, (char *)"AEST");
|
||||
}
|
||||
|
||||
ACPI::ACPI()
|
||||
{
|
||||
trace("Initializing ACPI");
|
||||
if (bInfo.RSDP->Revision >= 2 && bInfo.RSDP->XSDTAddress)
|
||||
{
|
||||
debug("XSDT supported");
|
||||
XSDTSupported = true;
|
||||
XSDT = (ACPIHeader *)(bInfo.RSDP->XSDTAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("RSDT supported");
|
||||
XSDT = (ACPIHeader *)(uintptr_t)bInfo.RSDP->RSDTAddress;
|
||||
}
|
||||
|
||||
this->SearchTables(XSDT);
|
||||
|
||||
if (FADT)
|
||||
{
|
||||
outb(s_cst(uint16_t, FADT->SMI_CommandPort), FADT->AcpiEnable);
|
||||
while (!(inw(s_cst(uint16_t, FADT->PM1aControlBlock)) & 1))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
ACPI::~ACPI()
|
||||
{
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
#include <types.h>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#include "multiboot2.h"
|
||||
#include "../../../../../kernel.h"
|
||||
@ -42,14 +41,6 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
||||
BootInfo mb2binfo{};
|
||||
|
||||
{
|
||||
uint64_t div = 1193180 / 1000;
|
||||
outb(0x43, 0xB6);
|
||||
outb(0x42, (uint8_t)div);
|
||||
outb(0x42, (uint8_t)(div >> 8));
|
||||
uint8_t tmp = inb(0x61);
|
||||
if (tmp != (tmp | 3))
|
||||
outb(0x61, tmp | 3);
|
||||
|
||||
int pos = 0;
|
||||
auto InfoAddress = Info;
|
||||
for (auto Tag = (struct multiboot_tag *)((uint8_t *)InfoAddress + 8);
|
||||
@ -306,9 +297,6 @@ EXTERNC void multiboot_main(uintptr_t Magic, uintptr_t Info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tmp = inb(0x61) & 0xFC;
|
||||
outb(0x61, tmp);
|
||||
}
|
||||
|
||||
Entry(&mb2binfo);
|
||||
|
@ -1,255 +0,0 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Kernel is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acpi.hpp"
|
||||
|
||||
#include <time.hpp>
|
||||
#include <debug.h>
|
||||
#include <smp.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#include "cpu/apic.hpp"
|
||||
#include "../../kernel.h"
|
||||
|
||||
#define ACPI_TIMER 0x0001
|
||||
#define ACPI_BUSMASTER 0x0010
|
||||
#define ACPI_GLOBAL 0x0020
|
||||
#define ACPI_POWER_BUTTON 0x0100
|
||||
#define ACPI_SLEEP_BUTTON 0x0200
|
||||
#define ACPI_RTC_ALARM 0x0400
|
||||
#define ACPI_PCIE_WAKE 0x4000
|
||||
#define ACPI_WAKE 0x8000
|
||||
|
||||
namespace ACPI
|
||||
{
|
||||
__always_inline inline bool IsCanonical(uint64_t Address)
|
||||
{
|
||||
return ((Address <= 0x00007FFFFFFFFFFF) || ((Address >= 0xFFFF800000000000) && (Address <= 0xFFFFFFFFFFFFFFFF)));
|
||||
}
|
||||
|
||||
#define ACPI_ENABLED 0x0001
|
||||
#define ACPI_SLEEP 0x2000
|
||||
|
||||
#define ACPI_GAS_MMIO 0
|
||||
#define ACPI_GAS_IO 1
|
||||
#define ACPI_GAS_PCI 2
|
||||
|
||||
void DSDT::OnInterruptReceived(CPU::x32::TrapFrame *Frame)
|
||||
{
|
||||
debug("SCI Handle Triggered");
|
||||
uint16_t Event = 0;
|
||||
{
|
||||
uint16_t a = 0, b = 0;
|
||||
if (acpi->FADT->PM1aEventBlock)
|
||||
{
|
||||
a = inw(s_cst(uint16_t, acpi->FADT->PM1aEventBlock));
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1aEventBlock), a);
|
||||
}
|
||||
if (acpi->FADT->PM1bEventBlock)
|
||||
{
|
||||
b = inw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock));
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock), b);
|
||||
}
|
||||
Event = a | b;
|
||||
}
|
||||
|
||||
debug("SCI Event: %#lx", Event);
|
||||
if (Event & ACPI_BUSMASTER)
|
||||
{
|
||||
fixme("ACPI Busmaster");
|
||||
}
|
||||
else if (Event & ACPI_GLOBAL)
|
||||
{
|
||||
fixme("ACPI Global");
|
||||
}
|
||||
else if (Event & ACPI_POWER_BUTTON)
|
||||
{
|
||||
if (TaskManager && !TaskManager->IsPanic())
|
||||
{
|
||||
TaskManager->CreateThread(TaskManager->CreateProcess(nullptr,
|
||||
"Shutdown",
|
||||
Tasking::TaskExecutionMode::Kernel),
|
||||
Tasking::IP(KST_Shutdown));
|
||||
}
|
||||
else
|
||||
KernelShutdownThread(false);
|
||||
}
|
||||
else if (Event & ACPI_SLEEP_BUTTON)
|
||||
{
|
||||
fixme("ACPI Sleep Button");
|
||||
}
|
||||
else if (Event & ACPI_RTC_ALARM)
|
||||
{
|
||||
fixme("ACPI RTC Alarm");
|
||||
}
|
||||
else if (Event & ACPI_PCIE_WAKE)
|
||||
{
|
||||
fixme("ACPI PCIe Wake");
|
||||
}
|
||||
else if (Event & ACPI_WAKE)
|
||||
{
|
||||
fixme("ACPI Wake");
|
||||
}
|
||||
else if (Event & ACPI_TIMER)
|
||||
{
|
||||
fixme("ACPI Timer");
|
||||
}
|
||||
else
|
||||
{
|
||||
error("ACPI unknown event %#lx on CPU %d", Event, GetCurrentCPU()->ID);
|
||||
CPU::Stop();
|
||||
}
|
||||
UNUSED(Frame);
|
||||
}
|
||||
|
||||
void DSDT::Shutdown()
|
||||
{
|
||||
trace("Shutting down...");
|
||||
if (SCI_EN == 1)
|
||||
{
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1aControlBlock),
|
||||
s_cst(uint16_t,
|
||||
(inw(s_cst(uint16_t,
|
||||
acpi->FADT->PM1aControlBlock)) &
|
||||
0xE3FF) |
|
||||
((SLP_TYPa << 10) | ACPI_SLEEP)));
|
||||
|
||||
if (acpi->FADT->PM1bControlBlock)
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1bControlBlock),
|
||||
s_cst(uint16_t,
|
||||
(inw(
|
||||
s_cst(uint16_t, acpi->FADT->PM1bControlBlock)) &
|
||||
0xE3FF) |
|
||||
((SLP_TYPb << 10) | ACPI_SLEEP)));
|
||||
|
||||
outw(s_cst(uint16_t, PM1a_CNT), SLP_TYPa | SLP_EN);
|
||||
if (PM1b_CNT)
|
||||
outw(s_cst(uint16_t, PM1b_CNT), SLP_TYPb | SLP_EN);
|
||||
}
|
||||
}
|
||||
|
||||
void DSDT::Reboot()
|
||||
{
|
||||
trace("Rebooting...");
|
||||
switch (acpi->FADT->ResetReg.AddressSpace)
|
||||
{
|
||||
case ACPI_GAS_MMIO:
|
||||
{
|
||||
*(uint8_t *)(acpi->FADT->ResetReg.Address) = acpi->FADT->ResetValue;
|
||||
break;
|
||||
}
|
||||
case ACPI_GAS_IO:
|
||||
{
|
||||
outb(s_cst(uint16_t, acpi->FADT->ResetReg.Address), acpi->FADT->ResetValue);
|
||||
break;
|
||||
}
|
||||
case ACPI_GAS_PCI:
|
||||
{
|
||||
fixme("ACPI_GAS_PCI not supported.");
|
||||
/*
|
||||
seg - 0
|
||||
bus - 0
|
||||
dev - (FADT->ResetReg.Address >> 32) & 0xFFFF
|
||||
function - (FADT->ResetReg.Address >> 16) & 0xFFFF
|
||||
offset - FADT->ResetReg.Address & 0xFFFF
|
||||
value - FADT->ResetValue
|
||||
*/
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
error("Unknown reset register address space: %d", acpi->FADT->ResetReg.AddressSpace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DSDT::DSDT(ACPI *acpi) : Interrupts::Handler(acpi->FADT->SCI_Interrupt)
|
||||
{
|
||||
this->acpi = acpi;
|
||||
uint64_t Address = ((IsCanonical(acpi->FADT->X_Dsdt) && acpi->XSDTSupported) ? acpi->FADT->X_Dsdt : acpi->FADT->Dsdt);
|
||||
uint8_t *S5Address = (uint8_t *)(Address) + 36;
|
||||
ACPI::ACPI::ACPIHeader *Header = (ACPI::ACPI::ACPIHeader *)Address;
|
||||
size_t Length = Header->Length;
|
||||
while (Length-- > 0)
|
||||
{
|
||||
if (!memcmp(S5Address, "_S5_", 4))
|
||||
break;
|
||||
S5Address++;
|
||||
}
|
||||
if (Length <= 0)
|
||||
{
|
||||
warn("_S5 not present in ACPI");
|
||||
return;
|
||||
}
|
||||
if ((*(S5Address - 1) == 0x08 || (*(S5Address - 2) == 0x08 && *(S5Address - 1) == '\\')) && *(S5Address + 4) == 0x12)
|
||||
{
|
||||
S5Address += 5;
|
||||
S5Address += ((*S5Address & 0xC0) >> 6) + 2;
|
||||
if (*S5Address == 0x0A)
|
||||
S5Address++;
|
||||
SLP_TYPa = s_cst(uint16_t, *(S5Address) << 10);
|
||||
S5Address++;
|
||||
if (*S5Address == 0x0A)
|
||||
S5Address++;
|
||||
SLP_TYPb = s_cst(uint16_t, *(S5Address) << 10);
|
||||
SMI_CMD = acpi->FADT->SMI_CommandPort;
|
||||
ACPI_ENABLE = acpi->FADT->AcpiEnable;
|
||||
ACPI_DISABLE = acpi->FADT->AcpiDisable;
|
||||
PM1a_CNT = acpi->FADT->PM1aControlBlock;
|
||||
PM1b_CNT = acpi->FADT->PM1bControlBlock;
|
||||
PM1_CNT_LEN = acpi->FADT->PM1ControlLength;
|
||||
SLP_EN = 1 << 13;
|
||||
SCI_EN = 1;
|
||||
trace("ACPI Shutdown is supported");
|
||||
ACPIShutdownSupported = true;
|
||||
|
||||
uint16_t value = ACPI_POWER_BUTTON | ACPI_SLEEP_BUTTON | ACPI_WAKE;
|
||||
{
|
||||
uint16_t a = s_cst(uint16_t, acpi->FADT->PM1aEventBlock + (acpi->FADT->PM1EventLength / 2));
|
||||
uint16_t b = s_cst(uint16_t, acpi->FADT->PM1bEventBlock + (acpi->FADT->PM1EventLength / 2));
|
||||
debug("SCI Event: %#lx [a:%#x b:%#x]", value, a, b);
|
||||
if (acpi->FADT->PM1aEventBlock)
|
||||
outw(a, value);
|
||||
if (acpi->FADT->PM1bEventBlock)
|
||||
outw(b, value);
|
||||
}
|
||||
|
||||
{
|
||||
uint16_t a = 0, b = 0;
|
||||
if (acpi->FADT->PM1aEventBlock)
|
||||
{
|
||||
a = inw(s_cst(uint16_t, acpi->FADT->PM1aEventBlock));
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1aEventBlock), a);
|
||||
}
|
||||
if (acpi->FADT->PM1bEventBlock)
|
||||
{
|
||||
b = inw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock));
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock), b);
|
||||
}
|
||||
}
|
||||
((APIC::APIC *)Interrupts::apic[0])->RedirectIRQ(0, acpi->FADT->SCI_Interrupt, 1);
|
||||
return;
|
||||
}
|
||||
warn("Failed to parse _S5 in ACPI");
|
||||
SCI_EN = 0;
|
||||
}
|
||||
|
||||
DSDT::~DSDT()
|
||||
{
|
||||
}
|
||||
}
|
@ -20,12 +20,12 @@
|
||||
#include <memory.hpp>
|
||||
#include <uart.hpp>
|
||||
#include <lock.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <cpu.hpp>
|
||||
#include <smp.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#include "../../../kernel.h"
|
||||
#include "../acpi.hpp"
|
||||
|
||||
NewLock(APICLock);
|
||||
|
||||
|
@ -18,21 +18,13 @@
|
||||
#include <smp.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <ints.hpp>
|
||||
#include <assert.h>
|
||||
#include <cpu.hpp>
|
||||
#include <atomic>
|
||||
|
||||
#include <smp.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <ints.hpp>
|
||||
#include <assert.h>
|
||||
#include <cpu.hpp>
|
||||
#include <atomic>
|
||||
|
||||
#include "../../../kernel.h"
|
||||
#include "../acpi.hpp"
|
||||
#include "apic.hpp"
|
||||
|
||||
enum SMPTrampolineAddress
|
||||
|
@ -15,12 +15,12 @@
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acpi.hpp"
|
||||
#include <acpi.hpp>
|
||||
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "../../kernel.h"
|
||||
#include "../kernel.h"
|
||||
|
||||
namespace ACPI
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace ACPI
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (short i = 0; i < 4; i++)
|
||||
{
|
||||
if (SDTHdr->Signature[i] != Signature[i])
|
||||
break;
|
||||
@ -142,6 +142,14 @@ namespace ACPI
|
||||
XSDT = (ACPIHeader *)(uintptr_t)bInfo.RSDP->RSDTAddress;
|
||||
}
|
||||
|
||||
if (!Memory::Virtual().Check(XSDT))
|
||||
{
|
||||
warn("%s is not mapped!",
|
||||
XSDTSupported ? "XSDT" : "RSDT");
|
||||
debug("XSDT: %p", XSDT);
|
||||
Memory::Virtual().Map(XSDT, XSDT, Memory::RW);
|
||||
}
|
||||
|
||||
this->SearchTables(XSDT);
|
||||
|
||||
if (FADT)
|
@ -15,15 +15,19 @@
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acpi.hpp"
|
||||
#include <acpi.hpp>
|
||||
|
||||
#include <time.hpp>
|
||||
#include <debug.h>
|
||||
#include <smp.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#include "cpu/apic.hpp"
|
||||
#include "../../kernel.h"
|
||||
#if defined(a64)
|
||||
#include "../Architecture/amd64/cpu/apic.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../Architecture/i386/cpu/apic.hpp"
|
||||
#endif
|
||||
#include "../kernel.h"
|
||||
|
||||
#define ACPI_TIMER 0x0001
|
||||
#define ACPI_BUSMASTER 0x0010
|
||||
@ -38,7 +42,9 @@ namespace ACPI
|
||||
{
|
||||
__always_inline inline bool IsCanonical(uint64_t Address)
|
||||
{
|
||||
return ((Address <= 0x00007FFFFFFFFFFF) || ((Address >= 0xFFFF800000000000) && (Address <= 0xFFFFFFFFFFFFFFFF)));
|
||||
return ((Address <= 0x00007FFFFFFFFFFF) ||
|
||||
((Address >= 0xFFFF800000000000) &&
|
||||
(Address <= 0xFFFFFFFFFFFFFFFF)));
|
||||
}
|
||||
|
||||
#define ACPI_ENABLED 0x0001
|
||||
@ -48,7 +54,11 @@ namespace ACPI
|
||||
#define ACPI_GAS_IO 1
|
||||
#define ACPI_GAS_PCI 2
|
||||
|
||||
void DSDT::OnInterruptReceived(CPU::x64::TrapFrame *Frame)
|
||||
#if defined(a64)
|
||||
void DSDT::OnInterruptReceived(CPU::x64::TrapFrame *)
|
||||
#elif defined(a32)
|
||||
void DSDT::OnInterruptReceived(CPU::x32::TrapFrame *)
|
||||
#endif
|
||||
{
|
||||
debug("SCI Handle Triggered");
|
||||
uint16_t Event = 0;
|
||||
@ -113,7 +123,6 @@ namespace ACPI
|
||||
error("ACPI unknown event %#lx on CPU %d", Event, GetCurrentCPU()->ID);
|
||||
CPU::Stop();
|
||||
}
|
||||
UNUSED(Frame);
|
||||
}
|
||||
|
||||
void DSDT::Shutdown()
|
||||
@ -184,18 +193,29 @@ namespace ACPI
|
||||
uint64_t Address = ((IsCanonical(acpi->FADT->X_Dsdt) && acpi->XSDTSupported) ? acpi->FADT->X_Dsdt : acpi->FADT->Dsdt);
|
||||
uint8_t *S5Address = (uint8_t *)(Address) + 36;
|
||||
ACPI::ACPI::ACPIHeader *Header = (ACPI::ACPI::ACPIHeader *)Address;
|
||||
if (!Memory::Virtual().Check(Header))
|
||||
{
|
||||
warn("DSDT is not mapped");
|
||||
debug("DSDT: %#lx", Address);
|
||||
Memory::Virtual().Map(Header, Header, Memory::RW);
|
||||
}
|
||||
|
||||
size_t Length = Header->Length;
|
||||
Memory::Virtual().Map(Header, Header, Length, Memory::RW);
|
||||
|
||||
while (Length-- > 0)
|
||||
{
|
||||
if (!memcmp(S5Address, "_S5_", 4))
|
||||
break;
|
||||
S5Address++;
|
||||
}
|
||||
|
||||
if (Length <= 0)
|
||||
{
|
||||
warn("_S5 not present in ACPI");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((*(S5Address - 1) == 0x08 || (*(S5Address - 2) == 0x08 && *(S5Address - 1) == '\\')) && *(S5Address + 4) == 0x12)
|
||||
{
|
||||
S5Address += 5;
|
||||
@ -218,11 +238,11 @@ namespace ACPI
|
||||
trace("ACPI Shutdown is supported");
|
||||
ACPIShutdownSupported = true;
|
||||
|
||||
uint16_t value = ACPI_POWER_BUTTON | ACPI_SLEEP_BUTTON | ACPI_WAKE;
|
||||
{
|
||||
uint16_t value = ACPI_POWER_BUTTON | ACPI_SLEEP_BUTTON | ACPI_WAKE;
|
||||
uint16_t a = s_cst(uint16_t, acpi->FADT->PM1aEventBlock + (acpi->FADT->PM1EventLength / 2));
|
||||
uint16_t b = s_cst(uint16_t, acpi->FADT->PM1bEventBlock + (acpi->FADT->PM1EventLength / 2));
|
||||
debug("SCI Event: %#llx [a:%#x b:%#x]", value, a, b);
|
||||
debug("SCI Event: %#x [a:%#x b:%#x]", value, a, b);
|
||||
if (acpi->FADT->PM1aEventBlock)
|
||||
outw(a, value);
|
||||
if (acpi->FADT->PM1bEventBlock)
|
||||
@ -242,6 +262,7 @@ namespace ACPI
|
||||
outw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock), b);
|
||||
}
|
||||
}
|
||||
|
||||
((APIC::APIC *)Interrupts::apic[0])->RedirectIRQ(0, acpi->FADT->SCI_Interrupt, 1);
|
||||
return;
|
||||
}
|
@ -18,20 +18,19 @@
|
||||
#include <ints.hpp>
|
||||
|
||||
#include <syscalls.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <smp.hpp>
|
||||
#include <vector>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(a64)
|
||||
#include "../Architecture/amd64/cpu/apic.hpp"
|
||||
#include "../Architecture/amd64/cpu/gdt.hpp"
|
||||
#include "../Architecture/amd64/cpu/idt.hpp"
|
||||
#include "../Architecture/amd64/acpi.hpp"
|
||||
#include "../Architecture/amd64/cpu/apic.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../Architecture/i386/cpu/apic.hpp"
|
||||
#include "../Architecture/i386/cpu/gdt.hpp"
|
||||
#include "../Architecture/i386/cpu/idt.hpp"
|
||||
#include "../Architecture/i386/acpi.hpp"
|
||||
#include "../Architecture/i386/cpu/apic.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
|
@ -17,19 +17,13 @@
|
||||
|
||||
#include <memory.hpp>
|
||||
|
||||
#include <acpi.hpp>
|
||||
#include <debug.h>
|
||||
#include <elf.h>
|
||||
#ifdef DEBUG
|
||||
#include <uart.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
namespace Memory
|
||||
|
@ -18,12 +18,7 @@
|
||||
#include <pci.hpp>
|
||||
|
||||
#include <power.hpp>
|
||||
#if defined(a64)
|
||||
#include "../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
#include <acpi.hpp>
|
||||
|
||||
#include "../kernel.h"
|
||||
|
||||
@ -927,7 +922,7 @@ namespace PCI
|
||||
if (PCIDeviceHdr->DeviceID == 0xFFFF)
|
||||
return;
|
||||
}
|
||||
debug("PCI Bus DeviceID:%#llx VendorID:%#llx BIST:%#llx Cache:%#llx Class:%#llx Cmd:%#llx HdrType:%#llx LatencyTimer:%#llx ProgIF:%#llx RevID:%#llx Status:%#llx SubClass:%#llx ",
|
||||
debug("PCI Bus DeviceID:%#x VendorID:%#x BIST:%#x Cache:%#x Class:%#x Cmd:%#x HdrType:%#x LatencyTimer:%#x ProgIF:%#x RevID:%#x Status:%#x SubClass:%#x ",
|
||||
PCIDeviceHdr->DeviceID, PCIDeviceHdr->VendorID, PCIDeviceHdr->BIST,
|
||||
PCIDeviceHdr->CacheLineSize, PCIDeviceHdr->Class, PCIDeviceHdr->Command,
|
||||
PCIDeviceHdr->HeaderType, PCIDeviceHdr->LatencyTimer, PCIDeviceHdr->ProgIF,
|
||||
|
@ -18,18 +18,12 @@
|
||||
#include <power.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "../kernel.h"
|
||||
|
||||
#if defined(a64)
|
||||
#include "../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
namespace Power
|
||||
{
|
||||
void Power::Reboot()
|
||||
|
@ -18,16 +18,10 @@
|
||||
#include <time.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
namespace Time
|
||||
@ -80,7 +74,7 @@ return false;
|
||||
{
|
||||
#if defined(a86)
|
||||
ACPI::ACPI::HPETHeader *HPET_HDR = (ACPI::ACPI::HPETHeader *)hpet;
|
||||
Memory::Virtual().Remap((void *)HPET_HDR->Address.Address,
|
||||
Memory::Virtual().Map((void *)HPET_HDR->Address.Address,
|
||||
(void *)HPET_HDR->Address.Address,
|
||||
Memory::PTFlag::RW | Memory::PTFlag::PCD);
|
||||
this->hpet = (HPET *)HPET_HDR->Address.Address;
|
||||
|
@ -18,15 +18,10 @@
|
||||
#include <time.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
namespace Time
|
||||
|
@ -18,15 +18,10 @@
|
||||
#include <time.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <acpi.hpp>
|
||||
#include <debug.h>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
|
@ -113,14 +113,11 @@ namespace Gigabit
|
||||
RX[i]->Status = 0;
|
||||
}
|
||||
|
||||
#pragma diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshift-count-overflow"
|
||||
|
||||
WriteCMD(REG::TXDESCLO, (uint32_t)(Ptr >> 32));
|
||||
WriteCMD(REG::TXDESCHI, (uint32_t)(Ptr & 0xFFFFFFFF));
|
||||
|
||||
#pragma diagnostic pop
|
||||
|
||||
WriteCMD(REG::RXDESCLO, (uint32_t)Ptr);
|
||||
WriteCMD(REG::RXDESCHI, 0);
|
||||
|
||||
|
@ -283,7 +283,9 @@ static void *sys_mmap(void *addr, size_t length, int prot,
|
||||
if (prot & PROT_WRITE)
|
||||
MapFlags |= Memory::RW;
|
||||
if (prot & PROT_EXEC)
|
||||
{
|
||||
debug("PROT_EXEC ignored"); /* MapFlags |= Memory::XD; */
|
||||
}
|
||||
|
||||
switch (flags & MAP_TYPE)
|
||||
{
|
||||
@ -335,7 +337,9 @@ static int sys_mprotect(void *addr, size_t len, int prot)
|
||||
if (prot & PROT_WRITE)
|
||||
vmm.Map(addr, addr, len, Memory::RW, Memory::Virtual::FourKiB);
|
||||
if (prot & PROT_EXEC)
|
||||
{
|
||||
debug("PROT_EXEC ignored"); /* MapFlags |= Memory::XD; */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,16 +17,10 @@
|
||||
|
||||
#include <vm.hpp>
|
||||
|
||||
#include <acpi.hpp>
|
||||
#include <cpu.hpp>
|
||||
#include <debug.h>
|
||||
|
||||
#if defined(a64)
|
||||
#include "../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(a32)
|
||||
#include "../Architecture/i386/acpi.hpp"
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../kernel.h"
|
||||
|
||||
bool DetectByHypervisor()
|
||||
|
@ -278,7 +278,11 @@ namespace ACPI
|
||||
uint8_t PM1_CNT_LEN = 0;
|
||||
|
||||
ACPI *acpi;
|
||||
#if defined(a64)
|
||||
void OnInterruptReceived(CPU::x64::TrapFrame *Frame);
|
||||
#elif defined(a32)
|
||||
void OnInterruptReceived(CPU::x32::TrapFrame *Frame);
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool ACPIShutdownSupported = false;
|
Loading…
x
Reference in New Issue
Block a user