arch/powerpc/platforms/ps3/mm.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/ps3/mm.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/ps3/mm.c- Extension
.c- Size
- 32321 bytes
- Lines
- 1255
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-mapping.hlinux/kernel.hlinux/export.hlinux/memblock.hlinux/slab.hasm/cell-regs.hasm/firmware.hasm/udbg.hasm/lv1call.hasm/setup.hplatform.h
Detected Declarations
struct mem_regionstruct mapstruct dma_chunkfunction make_page_sizesfunction _debug_dump_mapfunction ps3_mm_phys_to_lparfunction ps3_mm_vas_createfunction ps3_mm_vas_destroyfunction ps3_mm_get_repository_highmemfunction ps3_mm_set_repository_highmemfunction ps3_mm_region_createfunction ps3_mm_region_destroyfunction dma_sb_lpar_to_busfunction _dma_dump_regionfunction _dma_dump_chunkfunction dma_find_chunkfunction list_for_each_entryfunction list_for_each_entryfunction dma_sb_free_chunkfunction dma_ioc0_free_chunkfunction dma_sb_map_pagesfunction dma_ioc0_map_pagesfunction dma_sb_region_createfunction dma_ioc0_region_createfunction dma_sb_region_freefunction list_for_each_entry_safefunction dma_ioc0_region_freefunction dma_sb_map_areafunction dma_ioc0_map_areafunction dma_sb_unmap_areafunction dma_ioc0_unmap_areafunction dma_sb_region_create_linearfunction dma_sb_region_free_linearfunction dma_region_create_linearfunction dma_sb_unmap_area_linearfunction ps3_dma_region_initfunction ps3_dma_region_createfunction ps3_dma_region_freefunction ps3_dma_mapfunction ps3_dma_unmapfunction ps3_mm_initfunction ps3_mm_shutdownexport ps3_mm_phys_to_lparexport ps3_dma_region_initexport ps3_dma_region_createexport ps3_dma_region_free
Annotated Snippet
struct mem_region {
u64 base;
u64 size;
unsigned long offset;
int destroy;
};
/**
* struct map - address space state variables holder
* @total: total memory available as reported by HV
* @vas_id - HV virtual address space id
* @htab_size: htab size in bytes
*
* The HV virtual address space (vas) allows for hotplug memory regions.
* Memory regions can be created and destroyed in the vas at runtime.
* @rm: real mode (bootmem) region
* @r1: highmem region(s)
*
* ps3 addresses
* virt_addr: a cpu 'translated' effective address
* phys_addr: an address in what Linux thinks is the physical address space
* lpar_addr: an address in the HV virtual address space
* bus_addr: an io controller 'translated' address on a device bus
*/
struct map {
u64 total;
u64 vas_id;
u64 htab_size;
struct mem_region rm;
struct mem_region r1;
};
#define debug_dump_map(x) _debug_dump_map(x, __func__, __LINE__)
static void __maybe_unused _debug_dump_map(const struct map *m,
const char *func, int line)
{
DBG("%s:%d: map.total = %llxh\n", func, line, m->total);
DBG("%s:%d: map.rm.size = %llxh\n", func, line, m->rm.size);
DBG("%s:%d: map.vas_id = %llu\n", func, line, m->vas_id);
DBG("%s:%d: map.htab_size = %llxh\n", func, line, m->htab_size);
DBG("%s:%d: map.r1.base = %llxh\n", func, line, m->r1.base);
DBG("%s:%d: map.r1.offset = %lxh\n", func, line, m->r1.offset);
DBG("%s:%d: map.r1.size = %llxh\n", func, line, m->r1.size);
}
static struct map map;
/**
* ps3_mm_phys_to_lpar - translate a linux physical address to lpar address
* @phys_addr: linux physical address
*/
unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr)
{
BUG_ON(is_kernel_addr(phys_addr));
return (phys_addr < map.rm.size || phys_addr >= map.total)
? phys_addr : phys_addr + map.r1.offset;
}
EXPORT_SYMBOL(ps3_mm_phys_to_lpar);
/**
* ps3_mm_vas_create - create the virtual address space
*/
void __init ps3_mm_vas_create(unsigned long* htab_size)
{
int result;
u64 start_address;
u64 size;
u64 access_right;
u64 max_page_size;
u64 flags;
result = lv1_query_logical_partition_address_region_info(0,
&start_address, &size, &access_right, &max_page_size,
&flags);
if (result) {
DBG("%s:%d: lv1_query_logical_partition_address_region_info "
"failed: %s\n", __func__, __LINE__,
ps3_result(result));
goto fail;
}
if (max_page_size < PAGE_SHIFT_16M) {
DBG("%s:%d: bad max_page_size %llxh\n", __func__, __LINE__,
max_page_size);
goto fail;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/kernel.h`, `linux/export.h`, `linux/memblock.h`, `linux/slab.h`, `asm/cell-regs.h`, `asm/firmware.h`, `asm/udbg.h`.
- Detected declarations: `struct mem_region`, `struct map`, `struct dma_chunk`, `function make_page_sizes`, `function _debug_dump_map`, `function ps3_mm_phys_to_lpar`, `function ps3_mm_vas_create`, `function ps3_mm_vas_destroy`, `function ps3_mm_get_repository_highmem`, `function ps3_mm_set_repository_highmem`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.