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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) void *memset(void *s, int c, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	void *xs = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	size_t temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 		return xs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	c &= 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	c |= c << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	c |= c << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	if ((long)s & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		char *cs = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		*cs++ = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		s = cs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	if (count > 2 && (long)s & 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		short *ss = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		*ss++ = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		s = ss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		count -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	temp = count >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (temp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		long *ls = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		for (; temp; temp--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			*ls++ = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		size_t temp1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		asm volatile (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			"	movel %1,%2\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 			"	andw  #7,%2\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			"	lsrl  #3,%1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 			"	negw  %2\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			"	jmp   %%pc@(2f,%2:w:2)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 			"1:	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 			"	movel %3,%0@+\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 			"2:	dbra  %1,1b\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 			"	clrw  %1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 			"	subql #1,%1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 			"	jpl   1b"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			: "=a" (ls), "=d" (temp), "=&d" (temp1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			: "d" (c), "0" (ls), "1" (temp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		s = ls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	if (count & 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		short *ss = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		*ss++ = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		s = ss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	if (count & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		char *cs = s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		*cs = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	return xs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) EXPORT_SYMBOL(memset);