arch/mips/loongson64/init.c

Source file repositories/reference/linux-study-clean/arch/mips/loongson64/init.c

File Facts

System
Linux kernel
Corpus path
arch/mips/loongson64/init.c
Extension
.c
Size
5585 bytes
Lines
236
Domain
Architecture Layer
Bucket
arch/mips
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (mem_type) {
		case SYSTEM_RAM_LOW:
		case SYSTEM_RAM_HIGH:
		case UMA_VIDEO_RAM:
			pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes usable\n",
				(u32)node_id, mem_type, &mem_start, &mem_size);
			memblock_add_node(mem_start, mem_size, node,
					  MEMBLOCK_NONE);
			break;
		case SYSTEM_RAM_RESERVED:
		case VIDEO_ROM:
		case ADAPTER_ROM:
		case ACPI_TABLE:
		case SMBIOS_TABLE:
			pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes reserved\n",
				(u32)node_id, mem_type, &mem_start, &mem_size);
			memblock_reserve(mem_start, mem_size);
			break;
		/* We should not reserve VUMA_VIDEO_RAM as it overlaps with MMIO */
		case VUMA_VIDEO_RAM:
		default:
			pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes unhandled\n",
				(u32)node_id, mem_type, &mem_start, &mem_size);
			break;
		}
	}

	/* Reserve vgabios if it comes from firmware */
	if (loongson_sysconf.vgabios_addr)
		memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr),
				SZ_256K);
	/* set nid for reserved memory */
	memblock_set_node((u64)node << 44, (u64)(node + 1) << 44,
			&memblock.reserved, node);
}

#ifndef CONFIG_NUMA
static void __init prom_init_memory(void)
{
	szmem(0);
}
#endif

void __init prom_init(void)
{
	fw_init_cmdline();

	if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
		loongson_sysconf.fw_interface = LOONGSON_DTB;
		prom_dtb_init_env();
	} else {
		loongson_sysconf.fw_interface = LOONGSON_LEFI;
		prom_lefi_init_env();
	}

	/* init base address of io space */
	set_io_port_base((unsigned long)PCI_IOBASE);

	if (loongson_sysconf.early_config)
		loongson_sysconf.early_config();

#ifdef CONFIG_NUMA
	prom_init_numa_memory();
#else
	prom_init_memory();
#endif

	/* Hardcode to CPU UART 0 */
	if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64R)
		setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE), 0, 1024);
	else
		setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE + 0x1e0), 0, 1024);

	register_smp_ops(&loongson3_smp_ops);
	board_nmi_handler_setup = mips_nmi_setup;
}

static int __init add_legacy_isa_io(struct fwnode_handle *fwnode, resource_size_t hw_start,
				    resource_size_t size)
{
	int ret = 0;
	struct logic_pio_hwaddr *range;
	unsigned long vaddr;

	range = kzalloc_obj(*range, GFP_ATOMIC);
	if (!range)
		return -ENOMEM;

	range->fwnode = fwnode;
	range->size = size = round_up(size, PAGE_SIZE);

Annotation

Implementation Notes