arch/parisc/boot/compressed/misc.c
Source file repositories/reference/linux-study-clean/arch/parisc/boot/compressed/misc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/parisc/boot/compressed/misc.c- Extension
.c- Size
- 7804 bytes
- Lines
- 384
- Domain
- Architecture Layer
- Bucket
- arch/parisc
- 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.
Dependency Surface
linux/uaccess.hlinux/elf.hlinux/unaligned.hasm/page.hsizes.h../../../../lib/decompress_inflate.c../../../../lib/decompress_bunzip2.c../../../../lib/decompress_unlz4.c../../../../lib/decompress_unlzma.c../../../../lib/decompress_unlzo.c../../../../lib/decompress_unxz.c
Detected Declarations
function strlenfunction putsfunction putcharfunction errorfunction print_numfunction printffunction abortfunction freefunction flush_data_cachefunction parse_elffunction punned_get_unaligned_le32function decompress_kernel
Annotated Snippet
if (fmt[i] != '%') {
put:
putchar(fmt[i++]);
continue;
}
if (fmt[++i] == '%')
goto put;
print_num(va_arg(args, unsigned long),
fmt[i] == 'x' ? 16:10);
++i;
}
va_end(args);
return 0;
}
/* helper functions for libgcc */
void abort(void)
{
error("aborted.");
}
#undef malloc
static void *malloc(size_t size)
{
return malloc_gzip(size);
}
#undef free
static void free(void *ptr)
{
return free_gzip(ptr);
}
static void flush_data_cache(char *start, unsigned long length)
{
char *end = start + length;
do {
asm volatile("fdc 0(%0)" : : "r" (start));
asm volatile("fic 0(%%sr0,%0)" : : "r" (start));
start += 16;
} while (start < end);
asm volatile("fdc 0(%0)" : : "r" (end));
asm ("sync");
}
static void parse_elf(void *output)
{
#ifdef CONFIG_64BIT
Elf64_Ehdr ehdr;
Elf64_Phdr *phdrs, *phdr;
#else
Elf32_Ehdr ehdr;
Elf32_Phdr *phdrs, *phdr;
#endif
void *dest;
int i;
memcpy(&ehdr, output, sizeof(ehdr));
if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ||
ehdr.e_ident[EI_MAG1] != ELFMAG1 ||
ehdr.e_ident[EI_MAG2] != ELFMAG2 ||
ehdr.e_ident[EI_MAG3] != ELFMAG3) {
error("Kernel is not a valid ELF file");
return;
}
#ifdef DEBUG
printf("Parsing ELF... ");
#endif
phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
if (!phdrs)
error("Failed to allocate space for phdrs");
memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum);
for (i = 0; i < ehdr.e_phnum; i++) {
phdr = &phdrs[i];
switch (phdr->p_type) {
case PT_LOAD:
dest = (void *)((unsigned long) phdr->p_paddr &
(__PAGE_OFFSET_DEFAULT-1));
memmove(dest, output + phdr->p_offset, phdr->p_filesz);
break;
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/elf.h`, `linux/unaligned.h`, `asm/page.h`, `sizes.h`, `../../../../lib/decompress_inflate.c`, `../../../../lib/decompress_bunzip2.c`, `../../../../lib/decompress_unlz4.c`.
- Detected declarations: `function strlen`, `function puts`, `function putchar`, `function error`, `function print_num`, `function printf`, `function abort`, `function free`, `function flush_data_cache`, `function parse_elf`.
- Atlas domain: Architecture Layer / arch/parisc.
- 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.