arch/sh/mm/init.c
Source file repositories/reference/linux-study-clean/arch/sh/mm/init.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/mm/init.c- Extension
.c- Size
- 8477 bytes
- Lines
- 371
- Domain
- Architecture Layer
- Bucket
- arch/sh
- 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
linux/mm.hlinux/swap.hlinux/init.hlinux/gfp.hlinux/memblock.hlinux/proc_fs.hlinux/pagemap.hlinux/percpu.hlinux/io.hlinux/dma-mapping.hlinux/export.hasm/mmu_context.hasm/mmzone.hasm/kexec.hasm/tlb.hasm/cacheflush.hasm/sections.hasm/setup.hasm/cache.hasm/pgalloc.hlinux/sizes.hioremap.h
Detected Declarations
function generic_mem_initfunction plat_mem_setupfunction set_pte_physfunction clear_pte_physfunction __set_fixmapfunction __clear_fixmapfunction one_md_table_initfunction one_page_table_initfunction page_table_kmap_checkfunction page_table_range_initfunction allocate_pgdatfunction do_init_bootmemfunction early_reserve_memfunction arch_zone_limits_initfunction paging_initfunction mem_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/arch/sh/mm/init.c
*
* Copyright (C) 1999 Niibe Yutaka
* Copyright (C) 2002 - 2011 Paul Mundt
*
* Based on linux/arch/i386/mm/init.c:
* Copyright (C) 1995 Linus Torvalds
*/
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/init.h>
#include <linux/gfp.h>
#include <linux/memblock.h>
#include <linux/proc_fs.h>
#include <linux/pagemap.h>
#include <linux/percpu.h>
#include <linux/io.h>
#include <linux/dma-mapping.h>
#include <linux/export.h>
#include <asm/mmu_context.h>
#include <asm/mmzone.h>
#include <asm/kexec.h>
#include <asm/tlb.h>
#include <asm/cacheflush.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/cache.h>
#include <asm/pgalloc.h>
#include <linux/sizes.h>
#include "ioremap.h"
pgd_t swapper_pg_dir[PTRS_PER_PGD];
void __init generic_mem_init(void)
{
memblock_add(__MEMORY_START, __MEMORY_SIZE);
}
void __init __weak plat_mem_setup(void)
{
/* Nothing to see here, move along. */
}
#ifdef CONFIG_MMU
static pte_t *__get_pte_phys(unsigned long addr)
{
pgd_t *pgd;
p4d_t *p4d;
pud_t *pud;
pmd_t *pmd;
pgd = pgd_offset_k(addr);
if (pgd_none(*pgd)) {
pgd_ERROR(*pgd);
return NULL;
}
p4d = p4d_alloc(NULL, pgd, addr);
if (unlikely(!p4d)) {
p4d_ERROR(*p4d);
return NULL;
}
pud = pud_alloc(NULL, p4d, addr);
if (unlikely(!pud)) {
pud_ERROR(*pud);
return NULL;
}
pmd = pmd_alloc(NULL, pud, addr);
if (unlikely(!pmd)) {
pmd_ERROR(*pmd);
return NULL;
}
return pte_offset_kernel(pmd, addr);
}
static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
{
pte_t *pte;
pte = __get_pte_phys(addr);
if (!pte_none(*pte)) {
pte_ERROR(*pte);
return;
}
Annotation
- Immediate include surface: `linux/mm.h`, `linux/swap.h`, `linux/init.h`, `linux/gfp.h`, `linux/memblock.h`, `linux/proc_fs.h`, `linux/pagemap.h`, `linux/percpu.h`.
- Detected declarations: `function generic_mem_init`, `function plat_mem_setup`, `function set_pte_phys`, `function clear_pte_phys`, `function __set_fixmap`, `function __clear_fixmap`, `function one_md_table_init`, `function one_page_table_init`, `function page_table_kmap_check`, `function page_table_range_init`.
- Atlas domain: Architecture Layer / arch/sh.
- Implementation status: source 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.