arch/mips/cavium-octeon/executive/cvmx-bootmem.c
Source file repositories/reference/linux-study-clean/arch/mips/cavium-octeon/executive/cvmx-bootmem.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/cavium-octeon/executive/cvmx-bootmem.c- Extension
.c- Size
- 23736 bytes
- Lines
- 796
- 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/export.hlinux/kernel.hasm/octeon/cvmx.hasm/octeon/cvmx-spinlock.hasm/octeon/cvmx-bootmem.h
Detected Declarations
function offsetoffunction addressiblefunction cvmx_bootmem_phy_set_nextfunction cvmx_bootmem_phy_get_sizefunction cvmx_bootmem_phy_get_nextfunction cvmx_bootmem_lockfunction cvmx_bootmem_unlockfunction cvmx_bootmem_initfunction cvmx_bootmem_phy_allocfunction __cvmx_bootmem_phy_freefunction cvmx_bootmem_phy_named_block_findfunction voidfunction cvmx_bootmem_phy_named_block_freefunction cvmx_bootmem_free_namedfunction cvmx_bootmem_phy_named_block_allocexport cvmx_bootmem_alloc_namedexport cvmx_bootmem_alloc_named_range_onceexport cvmx_bootmem_find_named_block
Annotated Snippet
if (flags & CVMX_BOOTMEM_FLAG_END_ALLOC) {
desired_min_addr = usable_max - req_size;
/*
* Align desired address down to required
* alignment.
*/
desired_min_addr &= ~(alignment - 1);
}
/* Match at start of entry */
if (desired_min_addr == ent_addr) {
if (req_size < ent_size) {
/*
* big enough to create a new block
* from top portion of block.
*/
new_ent_addr = ent_addr + req_size;
cvmx_bootmem_phy_set_next(new_ent_addr,
cvmx_bootmem_phy_get_next(ent_addr));
cvmx_bootmem_phy_set_size(new_ent_addr,
ent_size -
req_size);
/*
* Adjust next pointer as following
* code uses this.
*/
cvmx_bootmem_phy_set_next(ent_addr,
new_ent_addr);
}
/*
* adjust prev ptr or head to remove this
* entry from list.
*/
if (prev_addr)
cvmx_bootmem_phy_set_next(prev_addr,
cvmx_bootmem_phy_get_next(ent_addr));
else
/*
* head of list being returned, so
* update head ptr.
*/
cvmx_bootmem_desc->head_addr =
cvmx_bootmem_phy_get_next(ent_addr);
if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
cvmx_bootmem_unlock();
return desired_min_addr;
}
/*
* block returned doesn't start at beginning of entry,
* so we know that we will be splitting a block off
* the front of this one. Create a new block from the
* beginning, add to list, and go to top of loop
* again.
*
* create new block from high portion of
* block, so that top block starts at desired
* addr.
*/
new_ent_addr = desired_min_addr;
cvmx_bootmem_phy_set_next(new_ent_addr,
cvmx_bootmem_phy_get_next
(ent_addr));
cvmx_bootmem_phy_set_size(new_ent_addr,
cvmx_bootmem_phy_get_size
(ent_addr) -
(desired_min_addr -
ent_addr));
cvmx_bootmem_phy_set_size(ent_addr,
desired_min_addr - ent_addr);
cvmx_bootmem_phy_set_next(ent_addr, new_ent_addr);
/* Loop again to handle actual alloc from new block */
}
error_out:
/* We didn't find anything, so return error */
if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
cvmx_bootmem_unlock();
return -1;
}
int __cvmx_bootmem_phy_free(uint64_t phy_addr, uint64_t size, uint32_t flags)
{
uint64_t cur_addr;
uint64_t prev_addr = 0; /* zero is invalid */
int retval = 0;
#ifdef DEBUG
cvmx_dprintf("__cvmx_bootmem_phy_free addr: 0x%llx, size: 0x%llx\n",
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `asm/octeon/cvmx.h`, `asm/octeon/cvmx-spinlock.h`, `asm/octeon/cvmx-bootmem.h`.
- Detected declarations: `function offsetof`, `function addressible`, `function cvmx_bootmem_phy_set_next`, `function cvmx_bootmem_phy_get_size`, `function cvmx_bootmem_phy_get_next`, `function cvmx_bootmem_lock`, `function cvmx_bootmem_unlock`, `function cvmx_bootmem_init`, `function cvmx_bootmem_phy_alloc`, `function __cvmx_bootmem_phy_free`.
- 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.