arch/mips/loongson64/env.c
Source file repositories/reference/linux-study-clean/arch/mips/loongson64/env.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/loongson64/env.c- Extension
.c- Size
- 10669 bytes
- Lines
- 355
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-map-ops.hlinux/export.hlinux/libfdt.hlinux/minmax.hlinux/pci_ids.hlinux/serial_core.hlinux/string_choices.hasm/bootinfo.hloongson.hboot_param.hbuiltin_dtbs.hworkarounds.h
Detected Declarations
function prom_dtb_init_envfunction lefi_fixup_fdt_serialfunction lefi_fixup_fdtfunction prom_lefi_init_envexport cpu_clock_freq
Annotated Snippet
if (!clk) {
pr_warn("UART 0x%llx misses clock-frequency property\n",
uart_addr);
return -ENOENT;
} else if (len != 4) {
pr_warn("UART 0x%llx has invalid clock-frequency property\n",
uart_addr);
return -EINVAL;
}
fdt32_st(clk, uart_clk);
return 0;
}
return -ENODEV;
}
static void __init lefi_fixup_fdt(struct system_loongson *system)
{
static unsigned char fdt_buf[16 << 10] __initdata;
struct uart_device *uartdev;
bool is_loongson64g;
u64 uart_base;
int ret, i;
ret = fdt_open_into(loongson_fdt_blob, fdt_buf, sizeof(fdt_buf));
if (ret) {
pr_err("Failed to open FDT to fix up\n");
return;
}
is_loongson64g = (read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64G;
for (i = 0; i < min(system->nr_uarts, MAX_UARTS); i++) {
uartdev = &system->uarts[i];
/*
* Some firmware does not set nr_uarts properly and passes empty
* items. Ignore them silently.
*/
if (uartdev->uart_base == 0)
continue;
/* Our DT only works with UPIO_MEM. */
if (uartdev->iotype != UPIO_MEM) {
pr_warn("Ignore UART 0x%llx with iotype %u passed by firmware\n",
uartdev->uart_base, uartdev->iotype);
continue;
}
ret = lefi_fixup_fdt_serial(fdt_buf, uartdev->uart_base,
uartdev->uartclk);
/*
* LOONGSON64G's CPU serials are mapped to two different
* addresses, one full-featured but differs from
* previous generations, one fully compatible with them.
*
* It's unspecified that which mapping should uart_base refer
* to, thus we should try fixing up with both.
*/
if (ret == -ENODEV && is_loongson64g) {
switch (uartdev->uart_base) {
case 0x1fe00100:
uart_base = 0x1fe001e0;
break;
case 0x1fe00110:
uart_base = 0x1fe001e8;
break;
case 0x1fe001e0:
uart_base = 0x1fe00100;
break;
case 0x1fe001e8:
uart_base = 0x1fe00110;
break;
default:
pr_err("Unexpected UART address 0x%llx passed by firmware\n",
uartdev->uart_base);
ret = -EINVAL;
goto err_fixup;
}
ret = lefi_fixup_fdt_serial(fdt_buf, uart_base,
uartdev->uartclk);
}
err_fixup:
if (ret)
pr_err("Couldn't fix up FDT node for UART 0x%llx\n",
uartdev->uart_base);
Annotation
- Immediate include surface: `linux/dma-map-ops.h`, `linux/export.h`, `linux/libfdt.h`, `linux/minmax.h`, `linux/pci_ids.h`, `linux/serial_core.h`, `linux/string_choices.h`, `asm/bootinfo.h`.
- Detected declarations: `function prom_dtb_init_env`, `function lefi_fixup_fdt_serial`, `function lefi_fixup_fdt`, `function prom_lefi_init_env`, `export cpu_clock_freq`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.