Skip to content

Commit

Permalink
LoongArch: Old BPI compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: liuyun <[email protected]>
Signed-off-by: Yanteng Si <[email protected]>
  • Loading branch information
Yanteng Si authored and Avenger-285714 committed May 13, 2024
1 parent d7aad0c commit 59eab58
Show file tree
Hide file tree
Showing 18 changed files with 845 additions and 27 deletions.
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/addrspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ extern unsigned long vm_map_base;
#define PCI_IOSIZE SZ_32M
#define ISA_IOSIZE SZ_16K
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
#define ISA_PHY_IOBASE LOONGSON_LIO_BASE

#define PHYS_LINK_KADDR PHYSADDR(VMLINUX_LOAD_ADDRESS)

Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define _ASM_LOONGARCH_EFI_H

#include <linux/efi.h>
#include <asm/early_ioremap.h>

void __init efi_init(void);
void __init efi_runtime_init(void);
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o \
alternative.o unwind.o
obj-y += legacy_boot.o

obj-$(CONFIG_ACPI) += acpi.o
obj-$(CONFIG_EFI) += efi.o
Expand Down
7 changes: 6 additions & 1 deletion arch/loongarch/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <asm/io.h>
#include <asm/numa.h>
#include <asm/loongson.h>
#include "legacy_boot.h"

int acpi_disabled;
EXPORT_SYMBOL(acpi_disabled);
Expand Down Expand Up @@ -58,7 +59,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
}

#ifdef CONFIG_SMP
static int set_processor_mask(u32 id, u32 flags)
int set_processor_mask(u32 id, u32 flags)
{

int cpu, cpuid = id;
Expand Down Expand Up @@ -132,6 +133,10 @@ static void __init acpi_process_madt(void)
__cpu_logical_map[i] = -1;
}
#endif

if (efi_bp && bpi_version <= BPI_VERSION_V1)
legacy_madt_table_init();

acpi_table_parse_madt(ACPI_MADT_TYPE_CORE_PIC,
acpi_parse_processor, MAX_CORE_PIC);

Expand Down
12 changes: 9 additions & 3 deletions arch/loongarch/kernel/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <asm/tlb.h>
#include <asm/loongson.h>
#include <asm/pgalloc.h>
#include "legacy_boot.h"

static unsigned long efi_nr_tables;
static unsigned long efi_config_table;
Expand Down Expand Up @@ -172,6 +173,9 @@ static int __init set_virtual_map(void)
efi_set_virtual_address_map_t *svam;
efi_memory_desc_t *in, runtime_map[32];

if (efi_bp)
return EFI_SUCCESS;

size = sizeof(efi_memory_desc_t);

for_each_efi_memory_desc(in) {
Expand Down Expand Up @@ -254,10 +258,12 @@ void __init efi_init(void)
void *config_tables;
struct efi_boot_memmap *tbl;

if (!efi_system_table)
return;
if (efi_system_table)
efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table,
sizeof(*efi_systab));
else
efi_systab = (efi_system_table_t *)efi_bp->systemtable;

efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
if (!efi_systab) {
pr_err("Can't find EFI system table.\n");
return;
Expand Down
9 changes: 8 additions & 1 deletion arch/loongarch/kernel/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <asm/bootinfo.h>
#include <asm/loongson.h>
#include <asm/setup.h>
#include "legacy_boot.h"

u64 efi_system_table;
struct loongson_system_configuration loongson_sysconf;
Expand All @@ -20,13 +21,19 @@ EXPORT_SYMBOL(loongson_sysconf);
void __init init_environ(void)
{
int efi_boot = fw_arg0;
char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE);
char *cmdline;

legacy_boot_init(fw_arg0, fw_arg1, fw_arg2);

if (efi_bp)
return;

if (efi_boot)
set_bit(EFI_BOOT, &efi.flags);
else
clear_bit(EFI_BOOT, &efi.flags);

cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE);
strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
strscpy(init_command_line, cmdline, COMMAND_LINE_SIZE);
early_memunmap(cmdline, COMMAND_LINE_SIZE);
Expand Down
25 changes: 15 additions & 10 deletions arch/loongarch/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <asm/irq.h>
#include <asm/loongson.h>
#include <asm/setup.h>
#include "legacy_boot.h"

DEFINE_PER_CPU(unsigned long, irq_stack);
DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
Expand Down Expand Up @@ -61,6 +62,12 @@ static int __init early_pci_mcfg_parse(struct acpi_table_header *header)
if (header->length < sizeof(struct acpi_table_mcfg))
return -EINVAL;

for (i = 0; i < MAX_IO_PICS; i++) {
msi_group[i].pci_segment = -1;
msi_group[i].node = -1;
pch_group[i].node = -1;
}

n = (header->length - sizeof(struct acpi_table_mcfg)) /
sizeof(struct acpi_mcfg_allocation);
mcfg = (struct acpi_table_mcfg *)header;
Expand All @@ -76,14 +83,6 @@ static int __init early_pci_mcfg_parse(struct acpi_table_header *header)

static void __init init_vec_parent_group(void)
{
int i;

for (i = 0; i < MAX_IO_PICS; i++) {
msi_group[i].pci_segment = -1;
msi_group[i].node = -1;
pch_group[i].node = -1;
}

acpi_table_parse(ACPI_SIG_MCFG, early_pci_mcfg_parse);
}

Expand All @@ -99,7 +98,7 @@ static int __init get_ipi_irq(void)

void __init init_IRQ(void)
{
int i;
int i, ret;
#ifdef CONFIG_SMP
int r, ipi_irq;
static int ipi_dummy_dev;
Expand All @@ -111,7 +110,13 @@ void __init init_IRQ(void)
clear_csr_estat(ESTATF_IP);

init_vec_parent_group();
irqchip_init();
if (efi_bp && bpi_version <= BPI_VERSION_V1) {
ret = setup_legacy_IRQ();
if (ret)
panic("IRQ domain init error!\n");
} else {
irqchip_init();
}
#ifdef CONFIG_SMP
ipi_irq = get_ipi_irq();
if (ipi_irq < 0)
Expand Down
Loading

0 comments on commit 59eab58

Please sign in to comment.