Patch series "mips: address -Wmissing-prototypes warnings". Address the -Wmissing-prototypes warnings that showed up in mips as the last major architecture after my patch to enable the option everywhere. This patch (of 20): The mips decompressor has some string functions defined locally that are not declared in the right place: arch/mips/boot/compressed/dbg.c:12:13: error: no previous prototype for 'putc' [-Werror=missing-prototypes] arch/mips/boot/compressed/dbg.c:16:6: error: no previous prototype for 'puts' [-Werror=missing-prototypes] arch/mips/boot/compressed/dbg.c:26:6: error: no previous prototype for 'puthex' [-Werror=missing-prototypes] arch/mips/boot/compressed/string.c:11:7: error: no previous prototype for 'memcpy' [-Werror=missing-prototypes] arch/mips/boot/compressed/string.c:22:7: error: no previous prototype for 'memset' [-Werror=missing-prototypes] arch/mips/boot/compressed/string.c:32:15: error: no previous prototype for 'memmove' [-Werror=missing-prototypes] arch/mips/boot/compressed/decompress.c:43:6: error: no previous prototype for 'error' [-Werror=missing-prototypes] arch/mips/boot/compressed/decompress.c:91:6: error: no previous prototype for 'decompress_kernel' [-Werror=missing-prototypes] Include the string.h header where needed and add a decompress.h header to have shared prototypes for the rest. Link: https://lkml.kernel.org/r/20231204115710.2247097-1-arnd@kernel.org Link: https://lkml.kernel.org/r/20231204115710.2247097-2-arnd@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Stephen Rothwell <sfr@rothwell.id.au> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
130 lines
3.1 KiB
C
130 lines
3.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright 2001 MontaVista Software Inc.
|
|
* Author: Matt Porter <mporter@mvista.com>
|
|
*
|
|
* Copyright (C) 2009 Lemote, Inc.
|
|
* Author: Wu Zhangjin <wuzhangjin@gmail.com>
|
|
*/
|
|
|
|
#define DISABLE_BRANCH_PROFILING
|
|
|
|
#define __NO_FORTIFY
|
|
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/libfdt.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
#include <asm/unaligned.h>
|
|
#include <asm-generic/vmlinux.lds.h>
|
|
|
|
#include "decompress.h"
|
|
|
|
/*
|
|
* These two variables specify the free mem region
|
|
* that can be used for temporary malloc area
|
|
*/
|
|
unsigned long free_mem_ptr;
|
|
unsigned long free_mem_end_ptr;
|
|
|
|
void error(char *x)
|
|
{
|
|
puts("\n\n");
|
|
puts(x);
|
|
puts("\n\n -- System halted");
|
|
|
|
while (1)
|
|
; /* Halt */
|
|
}
|
|
|
|
/* activate the code for pre-boot environment */
|
|
#define STATIC static
|
|
|
|
#ifdef CONFIG_KERNEL_GZIP
|
|
#include "../../../../lib/decompress_inflate.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_BZIP2
|
|
#include "../../../../lib/decompress_bunzip2.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_LZ4
|
|
#include "../../../../lib/decompress_unlz4.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_LZMA
|
|
#include "../../../../lib/decompress_unlzma.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_LZO
|
|
#include "../../../../lib/decompress_unlzo.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_XZ
|
|
#include "../../../../lib/decompress_unxz.c"
|
|
#endif
|
|
|
|
#ifdef CONFIG_KERNEL_ZSTD
|
|
#include "../../../../lib/decompress_unzstd.c"
|
|
#endif
|
|
|
|
const unsigned long __stack_chk_guard = 0x000a0dff;
|
|
|
|
void __stack_chk_fail(void)
|
|
{
|
|
error("stack-protector: Kernel stack is corrupted\n");
|
|
}
|
|
|
|
void decompress_kernel(unsigned long boot_heap_start)
|
|
{
|
|
unsigned long zimage_start, zimage_size;
|
|
|
|
zimage_start = (unsigned long)(__image_begin);
|
|
zimage_size = (unsigned long)(__image_end) -
|
|
(unsigned long)(__image_begin);
|
|
|
|
puts("zimage at: ");
|
|
puthex(zimage_start);
|
|
puts(" ");
|
|
puthex(zimage_size + zimage_start);
|
|
puts("\n");
|
|
|
|
/* This area are prepared for mallocing when decompressing */
|
|
free_mem_ptr = boot_heap_start;
|
|
free_mem_end_ptr = boot_heap_start + BOOT_HEAP_SIZE;
|
|
|
|
/* Display standard Linux/MIPS boot prompt */
|
|
puts("Uncompressing Linux at load address ");
|
|
puthex(VMLINUX_LOAD_ADDRESS_ULL);
|
|
puts("\n");
|
|
|
|
/* Decompress the kernel with according algorithm */
|
|
__decompress((char *)zimage_start, zimage_size, 0, 0,
|
|
(void *)VMLINUX_LOAD_ADDRESS_ULL, 0, 0, error);
|
|
|
|
if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) &&
|
|
fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) {
|
|
unsigned int image_size, dtb_size;
|
|
|
|
dtb_size = fdt_totalsize((void *)&__appended_dtb);
|
|
|
|
/* last four bytes is always image size in little endian */
|
|
image_size = get_unaligned_le32((void *)__image_end - 4);
|
|
|
|
/* The device tree's address must be properly aligned */
|
|
image_size = ALIGN(image_size, STRUCT_ALIGNMENT);
|
|
|
|
puts("Copy device tree to address ");
|
|
puthex(VMLINUX_LOAD_ADDRESS_ULL + image_size);
|
|
puts("\n");
|
|
|
|
/* copy dtb to where the booted kernel will expect it */
|
|
memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,
|
|
__appended_dtb, dtb_size);
|
|
}
|
|
|
|
/* FIXME: should we flush cache here? */
|
|
puts("Now, booting the kernel...\n");
|
|
}
|