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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * cmdline.c: Kernel command line creation using ARCS argc/argv.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <asm/sgialib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #undef DEBUG_CMDLINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * These macro take care of sign extension.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define prom_argv(index) ((char *) (long)argv[(index)])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static char *ignored[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	"ConsoleIn=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	"ConsoleOut=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	"SystemPartition=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	"OSLoader=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	"OSLoadPartition=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	"OSLoadFilename=",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	"OSLoadOptions="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static char *used_arc[][2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	{ "OSLoadPartition=", "root=" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	{ "OSLoadOptions=", "" }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	char *s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int actr, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	actr = 1; /* Always ignore argv[0] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	while (actr < argc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			int len = strlen(used_arc[i][0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			/* Ok, we want it. First append the replacement... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				strcat(cp, used_arc[i][1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 				cp += strlen(used_arc[i][1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				/* ... and now the argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				s = strchr(prom_argv(actr), '=');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				if (s) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 					s++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 					strcpy(cp, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 					cp += strlen(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				*cp++ = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		actr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	return cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) void __init prom_init_cmdline(int argc, LONG *argv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	char *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int actr, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	actr = 1; /* Always ignore argv[0] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	cp = arcs_cmdline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 * Move ARC variables to the beginning to make sure they can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * overridden by later arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	cp = move_firmware_args(argc, argv, cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	while (actr < argc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			int len = strlen(ignored[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			if (!strncmp(prom_argv(actr), ignored[i], len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				goto pic_cont;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		/* Ok, we want it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		strcpy(cp, prom_argv(actr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		cp += strlen(prom_argv(actr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		*cp++ = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	pic_cont:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		actr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	if (cp != arcs_cmdline)		/* get rid of trailing space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		--cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	*cp = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #ifdef DEBUG_CMDLINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }