18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciif [ $# -ne 2 ] ; then 58c2ecf20Sopenharmony_ci [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` 68c2ecf20Sopenharmony_ci asm_header_dir=tools/include/uapi/asm-generic 78c2ecf20Sopenharmony_ci arch_header_dir=tools/arch/${hostarch}/include/uapi/asm 88c2ecf20Sopenharmony_cielse 98c2ecf20Sopenharmony_ci asm_header_dir=$1 108c2ecf20Sopenharmony_ci arch_header_dir=$2 118c2ecf20Sopenharmony_cifi 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cicommon_mman=${asm_header_dir}/mman-common.h 148c2ecf20Sopenharmony_ciarch_mman=${arch_header_dir}/mman.h 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciprefix="PROT" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciprintf "static const char *mmap_prot[] = {\n" 198c2ecf20Sopenharmony_ciregex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+%s_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' ${prefix}` 208c2ecf20Sopenharmony_ci([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && 218c2ecf20Sopenharmony_ci(egrep $regex ${common_mman} | \ 228c2ecf20Sopenharmony_ci egrep -vw PROT_NONE | \ 238c2ecf20Sopenharmony_ci sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 248c2ecf20Sopenharmony_ci xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n") 258c2ecf20Sopenharmony_ci[ -f ${arch_mman} ] && egrep -q $regex ${arch_mman} && 268c2ecf20Sopenharmony_ci(egrep $regex ${arch_mman} | \ 278c2ecf20Sopenharmony_ci egrep -vw PROT_NONE | \ 288c2ecf20Sopenharmony_ci sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 298c2ecf20Sopenharmony_ci xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n") 308c2ecf20Sopenharmony_ciprintf "};\n" 31