Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/initrd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <asm/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <os.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* Changed by uml_initrd_setup, which is a setup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static char *initrd __initdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int load_initrd(char *filename, void *buf, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int __init read_initrd(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	void *area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	long long size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	if (initrd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	err = os_file_size(initrd, &size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	 * This is necessary because alloc_bootmem craps out if you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	 * ask for no memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (size == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		printk(KERN_ERR "\"%s\" is a zero-size initrd\n", initrd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	area = memblock_alloc(size, SMP_CACHE_BYTES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	if (!area)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		panic("%s: Failed to allocate %llu bytes\n", __func__, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	if (load_initrd(initrd, area, size) == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	initrd_start = (unsigned long) area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	initrd_end = initrd_start + size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int __init uml_initrd_setup(char *line, int *add)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	initrd = line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __uml_setup("initrd=", uml_initrd_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "initrd=<initrd image>\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "    This is used to boot UML from an initrd image.  The argument is the\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) "    name of the file containing the image.\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static int load_initrd(char *filename, void *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	int fd, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	if (fd < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		       -fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	n = os_read_file(fd, buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	if (n != size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 		printk(KERN_ERR "Read of %d bytes from '%s' failed, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		       "err = %d\n", size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 		       filename, -n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	os_close_file(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }