VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  1) #!/bin/bash
4f19048fd0a00 (Thomas Gleixner 2019-05-27 08:55:14 +0200  2) # SPDX-License-Identifier: GPL-2.0-only
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  3) # Translate the bits making up a GFP mask
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  4) # (c) 2009, Mel Gorman <mel@csn.ul.ie>
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  5) SOURCE=
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  6) GFPMASK=none
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  7) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  8) # Helper function to report failures and exit
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700  9) die() {
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 10) 	echo ERROR: $@
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 11) 	if [ "$TMPFILE" != "" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 12) 		rm -f $TMPFILE
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 13) 	fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 14) 	exit -1
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 15) }
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 16) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 17) usage() {
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 18) 	echo "usage: gfp-translate [-h] [ --source DIRECTORY ] gfpmask"
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 19) 	exit 0
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 20) }
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 21) 
3ad2f3fbb9614 (Daniel Mack     2010-02-03 08:01:28 +0800 22) # Parse command-line arguments
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 23) while [ $# -gt 0 ]; do
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 24) 	case $1 in
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 25) 		--source)
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 26) 			SOURCE=$2
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 27) 			shift 2
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 28) 			;;
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 29) 		-h)
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 30) 			usage
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 31) 			;;
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 32) 		--help)
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 33) 			usage
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 34) 			;;
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 35) 		*)
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 36) 			GFPMASK=$1
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 37) 			shift
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 38) 			;;
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 39) 	esac
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 40) done
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 41) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 42) # Guess the kernel source directory if it's not set. Preference is in order of
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 43) # o current directory
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 44) # o /usr/src/linux
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 45) if [ "$SOURCE" = "" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 46) 	if [ -r "/usr/src/linux/Makefile" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 47) 		SOURCE=/usr/src/linux
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 48) 	fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 49) 	if [ -r "`pwd`/Makefile" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 50) 		SOURCE=`pwd`
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 51) 	fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 52) fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 53) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 54) # Confirm that a source directory exists
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 55) if [ ! -r "$SOURCE/Makefile" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 56) 	die "Could not locate kernel source directory or it is invalid"
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 57) fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 58) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 59) # Confirm that a GFP mask has been specified
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 60) if [ "$GFPMASK" = "none" ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 61) 	usage
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 62) fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 63) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 64) # Extract GFP flags from the kernel source
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 65) TMPFILE=`mktemp -t gfptranslate-XXXXXX` || exit 1
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 66) grep -q ___GFP $SOURCE/include/linux/gfp.h
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 67) if [ $? -eq 0 ]; then
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 68) 	grep "^#define ___GFP" $SOURCE/include/linux/gfp.h | sed -e 's/u$//' | grep -v GFP_BITS > $TMPFILE
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 69) else
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 70) 	grep "^#define __GFP" $SOURCE/include/linux/gfp.h | sed -e 's/(__force gfp_t)//' | sed -e 's/u)/)/' | grep -v GFP_BITS | sed -e 's/)\//) \//' > $TMPFILE
27af038494ef2 (Mel Gorman      2010-11-24 12:57:17 -0800 71) fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 72) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 73) # Parse the flags
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 74) IFS="
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 75) "
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 76) echo Source: $SOURCE
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 77) echo Parsing: $GFPMASK
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 78) for LINE in `cat $TMPFILE`; do
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 79) 	MASK=`echo $LINE | awk '{print $3}'`
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 80) 	if [ $(($GFPMASK&$MASK)) -ne 0 ]; then
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 81) 		echo $LINE
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 82) 	fi
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 83) done
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 84) 
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 85) rm -f $TMPFILE
608e8e66a154c (Mel Gorman      2009-06-16 15:33:04 -0700 86) exit 0