mirror of
https://github.com/AuxXxilium/redpill-lkm5.git
synced 2024-11-23 15:01:01 +07:00
gleaning
This commit is contained in:
parent
d7e0766776
commit
727a11c912
30
compat/toolkit/drivers/pci/pci.h
Normal file
30
compat/toolkit/drivers/pci/pci.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef REDPILL_PCI_H
|
||||||
|
#define REDPILL_PCI_H
|
||||||
|
|
||||||
|
#warning "Using compatibility file for drivers/pci/pci.h - if possible do NOT compile using toolkit"
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) //v4.18 - v4.20
|
||||||
|
/* pci_dev priv_flags */
|
||||||
|
#define PCI_DEV_ADDED 1
|
||||||
|
|
||||||
|
static inline bool pci_dev_is_added(const struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) && LINUX_VERSION_CODE < KERNEL_VERSION(6,0,0) //v4.20 - v6.0
|
||||||
|
#define PCI_DEV_ADDED 0
|
||||||
|
|
||||||
|
static inline bool pci_dev_is_added(const struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline bool pci_dev_is_added(const struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
return 1 == dev->is_added;
|
||||||
|
}
|
||||||
|
#endif //LINUX_VERSION_CODE check
|
||||||
|
|
||||||
|
#endif /* REDPILL_PCI_H */
|
@ -373,7 +373,7 @@ static inline void restart_port(struct uart_8250_port *up)
|
|||||||
// because we did swap IRQ values. However, we MUST restart such port not to reinit the hardware (which doesn't
|
// because we did swap IRQ values. However, we MUST restart such port not to reinit the hardware (which doesn't
|
||||||
// care) but to fix the interrupt mapping in the kernel!
|
// care) but to fix the interrupt mapping in the kernel!
|
||||||
//skip extensive tests - it was working before
|
//skip extensive tests - it was working before
|
||||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,0,0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
|
||||||
port->flags |= UPF_NO_TXEN_TEST;
|
port->flags |= UPF_NO_TXEN_TEST;
|
||||||
#else
|
#else
|
||||||
port->quirks |= UPQ_NO_TXEN_TEST;
|
port->quirks |= UPQ_NO_TXEN_TEST;
|
||||||
|
@ -176,6 +176,9 @@
|
|||||||
#include <linux/pci_ids.h> //Constants for vendors, classes, and other
|
#include <linux/pci_ids.h> //Constants for vendors, classes, and other
|
||||||
#include <linux/list.h> //list_for_each
|
#include <linux/list.h> //list_for_each
|
||||||
#include <linux/device.h> //device_del
|
#include <linux/device.h> //device_del
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0)
|
||||||
|
#include <../drivers/pci/pci.h> //pci_dev_is_added
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PCIBUS_VIRTUAL_DOMAIN 0x0001 //normal PC buses are (always?) on domain 0, this is just a next one
|
#define PCIBUS_VIRTUAL_DOMAIN 0x0001 //normal PC buses are (always?) on domain 0, this is just a next one
|
||||||
#define PCI_DEVICE_NOT_FOUND_VID_DID 0xFFFFFFFF //A special case to detect non-existing devices (per PCI spec)
|
#define PCI_DEVICE_NOT_FOUND_VID_DID 0xFFFFFFFF //A special case to detect non-existing devices (per PCI spec)
|
||||||
@ -545,10 +548,10 @@ int vpci_remove_all_devices_and_buses(void)
|
|||||||
for_each_bus_idx() {
|
for_each_bus_idx() {
|
||||||
list_for_each_entry_safe(pci_dev, pci_dev_n, &buses[i]->devices, bus_list) {
|
list_for_each_entry_safe(pci_dev, pci_dev_n, &buses[i]->devices, bus_list) {
|
||||||
pr_loc_dbg("Detaching vDEV dev=%02x fn=%02x from bus=%02x [add=%d]", PCI_SLOT(pci_dev->devfn),
|
pr_loc_dbg("Detaching vDEV dev=%02x fn=%02x from bus=%02x [add=%d]", PCI_SLOT(pci_dev->devfn),
|
||||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,0,0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0)
|
||||||
PCI_FUNC(pci_dev->devfn), buses[i]->number, pci_dev->is_added);
|
PCI_FUNC(pci_dev->devfn), buses[i]->number, pci_dev->is_added);
|
||||||
#else
|
#else
|
||||||
PCI_FUNC(pci_dev->devfn), buses[i]->number, 0); // Not found a replacement for pci_dev->is_added
|
PCI_FUNC(pci_dev->devfn), buses[i]->number, pci_dev_is_added(pci_dev));
|
||||||
#endif
|
#endif
|
||||||
pci_stop_and_remove_bus_device(pci_dev);
|
pci_stop_and_remove_bus_device(pci_dev);
|
||||||
}
|
}
|
||||||
|
@ -348,10 +348,12 @@ static int _apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab, unsigned
|
|||||||
val -= (u64)loc;
|
val -= (u64)loc;
|
||||||
*(u32 *)loc = val;
|
*(u32 *)loc = val;
|
||||||
break;
|
break;
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0)
|
||||||
case R_X86_64_PC64:
|
case R_X86_64_PC64:
|
||||||
val -= (u64)loc;
|
val -= (u64)loc;
|
||||||
*(u64 *)loc = val;
|
*(u64 *)loc = val;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
pr_err("%s: Unknown rela relocation: %llu\n",
|
pr_err("%s: Unknown rela relocation: %llu\n",
|
||||||
me->name, ELF64_R_TYPE(rel[i].r_info));
|
me->name, ELF64_R_TYPE(rel[i].r_info));
|
||||||
|
Loading…
Reference in New Issue
Block a user