<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>Hello Joel,</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span>Yeah, it makes sense to merge the scripts. I'll do it & submit the patch.</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span>The script I wrote can evaluate a single bsp directory, all bsps in a cpu family or if
 you place it or give it the path of libbsp, then it'll evaluate all the RTEMS bsps.</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal;"><span>Will have to determine how the previous script works & how it can be merged with mine. Will do that :-)</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, clean, sans-serif;
 background-color: transparent; font-style: normal;">Regards</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal;"><span style="background-color:transparent;line-height:1.22;">Vipul Nayyar </span></div><div style="color: rgb(0, 0, 0); font-size: 12.727272033691406px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal;"><br></div><div><br></div>  <div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Joel Sherrill <joel.sherrill@oarcorp.com><br> <b><span style="font-weight: bold;">To:</span></b> Vipul Nayyar <nayyar_vipul@yahoo.com> <br><b><span style="font-weight:
 bold;">Cc:</span></b> "rtems-devel@rtems.org" <rtems-devel@rtems.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, 16 September 2013 8:17 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [PATCH] Bash script to review BSP File Organization<br> </font> </div> <div class="y_msg_container"><br>Does it make sense for this to be merged into the other script?<br><br>It already does some BSP specific checks and my original intention<br>was to have someone run it before submitting a new BSP. It seems<br>odd to ask them to run two scripts.<br><br>Can this be run on a single BSP directory?<br><br>I am trying to catch up this week. :)<br><br>On 9/14/2013 3:01 PM, Vipul Nayyar wrote:<br>> ---<br>>   merge-helpers/review_bsp_files | 465 +++++++++++++++++++++++++++++++++++++++++<br>>   1 file changed, 465 insertions(+)<br>>   create mode 100755 merge-helpers/review_bsp_files<br>><br>> diff
 --git a/merge-helpers/review_bsp_files b/merge-helpers/review_bsp_files<br>> new file mode 100755<br>> index 0000000..422d256<br>> --- /dev/null<br>> +++ b/merge-helpers/review_bsp_files<br>> @@ -0,0 +1,465 @@<br>> +#! /bin/bash<br>> +<br>> +# Bash Script to find discrepancies in BSP file organization<br>> +# Author : Vipul Nayyar <<a ymailto="mailto:nayyar_vipul@yahoo.com" href="mailto:nayyar_vipul@yahoo.com">nayyar_vipul@yahoo.com</a>><br>> +<br>> +<br>> +filename="0"<br>> +# Passing --verbose turns verbose to 1 & gives the whole story, otherwise '0' to give only important stuff.<br>> +verbose="0"<br>> +faults="0"<br>> +# Passing --warnings turns warnings to 1 & gives all the critical & non-critical bsp file org. problems.<br>> +warnings="0"<br>> +flag="0"<br>> +<br>> +calling_path=`pwd`<br>> +path=""<br>> +<br>> +important="1"<br>> +rtems_internal=""<br>>
 +internal_done="0"<br>> +<br>> +<br>> +# Finds all rtems internal functions ( name starting with '_' & type specifier)<br>> +# that are defined in cpukit & libcpu<br>> +function find_rtems_internal(){<br>> +       if [[ $internal_done == "1" ]]; then<br>> +               return<br>> +       fi<br>> +       echo "Compiling list of RTEMS Internal functions ..."<br>> +       internal_files=""<br>> +<br>> +       for k in `find -name *.c`<br>> +       do<br>> +               for j in `grep -oE "[a-z|A-Z|0-9|_]+[\ |^][_]+[a-z|A-Z|0-9|_]*[\ ]*\(" $k`<br>> +               do<br>> +                       if [[ $j == "_"* ]]; then<br>> +     
                          j=${j%%\(}<br>> +                               internal_files="$j $internal_files"<br>> +                       fi<br>> +<br>> +               done<br>> +       done<br>> +<br>> +       for k in `find ../c/src/lib/libcpu/ -name *.c`<br>> +       do<br>> +               for j in `grep -oE "[a-z|A-Z|0-9|_]+[\ |^][_]+[a-z|A-Z|0-9|_]*[\ ]*\(" $k`<br>> +               do<br>> +                       if [[ $j == "_"* ]]; then<br>> +                     
          j=${j%%\(}<br>> +                               internal_files="$j $internal_files"<br>> +                       fi<br>> +<br>> +               done<br>> +       done<br>> +<br>> +       for k in $internal_files<br>> +       do<br>> +               if echo $rtems_internal |grep -q $k ; then<br>> +                       echo > /dev/null<br>> +               else<br>> +                       rtems_internal="$k $rtems_internal"<br>> +               fi<br>> + 
      done<br>> +<br>> +       internal_done="1"<br>> +}<br>> +<br>> +# Finds all internal functions common in bsp and (cpukit + libcpu)<br>> +function find_bsp_internal(){<br>> +       bsp_methods=""<br>> +       common_internal_methods=""<br>> +<br>> +# Searching for internal functions starting with '_' called(i.e ending with a ';')<br>> +       for i in `find -name *.c`<br>> +       do<br>> +               file_contents=`tr -d '\n' < $i | grep -oE "[ |^][_]+[a-z|A-Z|0-9|_]*[ ]*[\n]*\([^;]*\)[ ]*;" | tr -d '\n' `<br>> +<br>> +               for j in `echo "$file_contents" | grep -oE "[_]+[a-z|A-Z|0-9|_]*[ ]*\("`<br>> +               do<br>> +                   
    if `echo "$bsp_methods" |grep -q "${j%%\(}"` ; then<br>> +                               echo > /dev/null<br>> +                       else<br>> +                               bsp_methods="${j%%\(} $bsp_methods"<br>> +                       fi<br>> +               done<br>> +       done<br>> +<br>> +# Identifying common fucntions between $rtems_interval & $bsp_methods<br>> +       for i in $rtems_internal<br>> +       do<br>> +               if [[ $i == "__asm__" || $i == "__attribute__" || $i == "__volatile__" || $i == "__"*
 ]];then<br>> +                       continue<br>> +               fi<br>> +               for j in $bsp_methods<br>> +               do<br>> +                       if [[ $i == $j ]]; then<br>> +                               common_internal_methods="$j $common_internal_methods"<br>> +                       fi<br>> +               done<br>> +       done<br>> +<br>> +       if [[ $common_internal_methods != "" ]]; then<br>> +               echo -e "$bsp : RTEMS Internal functions
 used : \c"<br>> +               for i in $common_internal_methods<br>> +               do<br>> +                       echo -e "${i}() \c"<br>> +               done<br>> +               flag="1"<br>> +       fi<br>> +}<br>> +<br>> +<br>> +# Passing 1 initially to any check function states that the file/method/header<br>> +# being checked is of critical nature<br>> +function check_file(){<br>> +       filename="0"<br>> +       if [[ $1 == 1 ]]; then<br>> +               important="1"<br>> +               shift<br>> +       else<br>> +              
 important="0"<br>> +       fi<br>> +<br>> +#Grabbing the path of file being evaluated from Makefile.am<br>> +       if grep -wqE "[ ]*[^\ ]*/($1)" Makefile.am ; then<br>> +               file_path=`grep -woE "[ ]*[^\ ]*/($1)" Makefile.am | head --lines=1`<br>> +               cd `dirname $file_path`<br>> +               filename=$1<br>> +               file_path=`pwd`<br>> +<br>> +               cd - > /dev/null<br>> +               shift<br>> +<br>> +# Checking if file lies in correct directory path<br>> +               for i in $*<br>> +               do<br>> +         
              if [[ -d $i ]]; then<br>> +                               cd $i<br>> +                       else<br>> +                               continue<br>> +                       fi<br>> +<br>> +<br>> +                       if [[ "$file_path" == `pwd` ]]; then<br>> +                               filename="$file_path/$filename"<br>> +                               cd - >/dev/null<br>> +           
                    return<br>> +                       fi<br>> +                       cd - > /dev/null<br>> +               done<br>> +               echo "$bsp : $filename not present in correct path"<br>> +               filename="$file_path/$filename"<br>> +               return<br>> +       else<br>> +               if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then<br>> +                       flag="1"<br>> +                       echo "$bsp :
 $1 not compiled"<br>> +               fi<br>> +       fi<br>> +<br>> +       filename="0"<br>> +       faults="1"<br>> +       return<br>> +}<br>> +<br>> +# Checking presence of functions in specific files<br>> +function check_methods(){<br>> +       if [[ $1 == 1 ]]; then<br>> +               important="1"<br>> +               shift<br>> +       else<br>> +               important="0"<br>> +       fi<br>> +<br>> +       for i in $*<br>> +       do<br>> +<br>> +# When correct file for this function does not exist<br>> +               if [[ $filename == "0" ]];then<br>> + 
                      if grep -rqlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" * ;then<br>> +                          if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]];then<br>> +                               echo $bsp : ${i%(*}"()" present in file `grep -rlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" *`<br>> +                          fi<br>> +                       fi<br>> +               else<br>> +<br>> +# When correct file for this function exists<br>> +                       if grep -Eq "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" $filename ;
 then<br>> +                               if [[ $verbose -eq "1" ]] ;then<br>> +                                       echo "$bsp : `basename $filename` : ${i%(*}() present in file"<br>> +                               fi<br>> +                       else<br>> +                               if grep -rqlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" * ;then<br>> +                                  if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]];then<br>> +     
                                  echo $bsp : ${i%(*}"()" present in file `grep -rlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" *`<br>> +                                  fi<br>> +                               else<br>> +                                       if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then<br>> +                                               echo "$bsp : `basename $filename` : ${i%(*}() function does not exist in $filename "<br>> +         
                                      flag="1"<br>> +                                       fi<br>> +                                               faults="1"<br>> +                               fi<br>> +                       fi<br>> +<br>> +               fi<br>> +       done<br>> +}<br>> +<br>> +# Checking presence of headers installed by bsp<br>> +function check_header(){<br>> +       if [[ $1 == 1 ]]; then<br>> + 
              important="1"<br>> +               shift<br>> +       else<br>> +               important="0"<br>> +       fi<br>> +<br>> +       for i in $*<br>> +       do<br>> +               if  grep -wq "$i" Makefile.am ;then<br>> +                       if [[ ! -f "$i" && ! -f "${i}.in" ]] ;then<br>> +                               continue<br>> +                       fi<br>> +                       if [[ $verbose -eq "1" ]] ;then<br>> +         
                      cd `dirname $i`<br>> +                               echo "$bsp : `basename $i` installed from directory" ${PWD##*/c/src/lib/}<br>> +                               cd - > /dev/null<br>> +                       fi<br>> +                       return<br>> +               fi<br>> +       done<br>> +<br>> +       if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then<br>> +               echo "${bsp%%[\ ]*} : `basename $1` not installed "<br>> +         
      flag="1"<br>> +       fi<br>> +       filename="0"<br>> +       faults="1"<br>> +       return<br>> +<br>> +}<br>> +<br>> +# Reviewing for a BSP Starts<br>> +function main(){<br>> +<br>> +       flag="0"<br>> +<br>> +       check_file 1 start.S ../shared/start/ start/<br>> +       if [[ $filename != "0" ]];then<br>> +               if grep -wq "start" "$filename" || grep -wq "_start" "$filename"; then<br>> +                       if [[ $verbose -eq "1" ]] ;then<br>> +                               echo "$bsp : `basename $filename` start() present in $filename"<br>> +               
        fi<br>> +               else<br>> +                       echo "$bsp : `basename $filename` start() does not exist in start.S"<br>> +               fi<br>> +       fi<br>> +<br>> +       check_file 1 bspstart.c ../../shared/ ../shared/ startup/<br>> +       check_methods "bsp_start"<br>> +<br>> +       check_file 1 bspreset.c ../../shared/ ../shared/ startup/<br>> +       check_methods 1 "bsp_reset"<br>> +<br>> +<br>> +       check_file 1 bootcard.c ../../shared/<br>> +       check_header ../../shared/include/bootcard.h<br>> +<br>> +       check_file 1 bspclean.c ../../shared/ startup/<br>> +       check_methods
 "bsp_fatal_extension"<br>> +<br>> +       check_file 1 bspgetworkarea.c ../../shared/ ../../shared/startup ../shared/ ../shared/startup/ startup/<br>> +       check_methods 1 "bsp_work_area_initialize"<br>> +<br>> +<br>> +       check_file 1 bsplibc.c ../../shared/<br>> +       check_methods "bsp_libc_init"<br>> +<br>> +       check_file 1 bsppost.c ../../shared/<br>> +       check_methods "bsp_postdriver_hook"<br>> +<br>> +       check_file 1 bsppredriverhook.c ../../shared/ ../shared/startup/ startup/<br>> +       check_methods "bsp_predriver_hook"<br>> +<br>> +<br>> +       check_file gnatinstallhandler.c ../../shared/<br>> +<br>> +       check_file sbrk.c ../../shared/ ../../shared/ startup/<br>> +       check_methods
 "sbrk"<br>> +<br>> +<br>> +       check_file stackalloc.c ../../shared/src/<br>> +       check_methods "bsp_stack_allocate_init" "bsp_stack_allocate" "bsp_stack_free"<br>> +<br>> +       check_header ../../shared/include/stackalloc.h<br>> +<br>> +       # Interrupt Files<br>> +       check_file 1 irq.c irq/<br>> +       check_methods "bsp_interrupt_vector_enable" "bsp_interrupt_vector_disable" "bsp_interrupt_facility_initialize" "bsp_interrupt_dispatch"<br>> +       check_header 1 include/irq.h<br>> +<br>> +       # PIC Support<br>> +<br>> +       check_file irq-default-handler.c ../../shared/src/<br>> +<br>> +       check_file 1 irq-generic.c ../../shared/src/<br>> +       check_header 1 ../../shared/include/irq-generic.h<br>>
 +<br>> +       check_file irq-info.c ../../shared/src/<br>> +       check_header ../../shared/include/irq-info.h<br>> +<br>> +       check_file irq-legacy.c ../../shared/src/<br>> +       check_file irq-server.c ../../shared/src/<br>> +       check_file irq-shell.c ../../shared/src/<br>> +<br>> +       # Real Time Clock<br>> +       check_file rtc-config.c rtc/<br>> +       check_methods "bsp_rtc_initialize" "bsp_rtc_get_time" "bsp_rtc_set_time" "bsp_rtc_probe"<br>> +<br>> +<br>> +       check_file 1 tod.c ../../shared/ tod/<br>> +<br>> +       # Benchmark Timers<br>> +       check_file benchmark_timer.c benchmark_timer/<br>> +       check_methods "benchmark_timer_initialize" "benchmark_timer_read"
 "benchmark_timer_disable_subtracting_average_overhead"<br>> +<br>> +<br>> +       # Standard Headers<br>> +<br>> +       check_header 1 include/bsp.h<br>> +       check_header include/bspopts.h<br>> +       check_header 1 ../../shared/include/coverhd.h include/coverhd.h<br>> +       check_header ../../shared/include/utility.h<br>> +       check_header 1 ../../shared/include/tm27.h include/tm27.h<br>> +<br>> +       # Finding all internal functions being used in a bsp<br>> +       find_bsp_internal<br>> +<br>> +       if [[ $flag == "1" ]]; then<br>> +               echo -e "\n"<br>> +       fi<br>> +}<br>> +<br>> +# Verifying if the directory given or pwd is a valid bsp, shared architecture, or libbsp
 directory<br>> +function check_given_dir(){<br>> +       if echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)/([^/]+)/([^/]+)*" ; then<br>> +               return 0<br>> +<br>> +       elif echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)/([^/]+)" ; then<br>> +# BSP given<br>> +               cd ../../../../../../cpukit<br>> +               find_rtems_internal<br>> +<br>> +               cd - > /dev/null<br>> +               bsp=${cur_dir##*/}<br>> +<br>> +               if [[ $bsp == "shared" || $bsp == "autom4te.cache" || $bsp == "no_bsp" ]]; then<br>> +                       return 0<br>> +     
          else<br>> +                       main<br>> +               fi<br>> +       elif echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)" ; then<br>> +# Shared architecture given<br>> +               for i in *<br>> +               do<br>> +                       if [[ -d $i ]]; then<br>> +                               if [[ $i == "shared" || $i == "autom4te.cache" || $i == "no_bsp" ]]; then<br>> +                                       echo -n<br>> +               
                else<br>> +                                       cd ../../../../../cpukit<br>> +                                       find_rtems_internal<br>> +                                       cd - > /dev/null<br>> +                                       bsp=$i<br>> +<br>> +                                       cd $bsp<br>> +                           
            main<br>> +                                       cd .. > /dev/null<br>> +                               fi<br>> +                       fi<br>> +               done<br>> +       elif echo $cur_dir | grep -Eq "c/src/lib/libbsp" ; then<br>> +# libbsp given<br>> +               for i in */*/Makefile.am<br>> +               do<br>> +                       i=`dirname $i`<br>> +                       if [[ -d $i ]]; then<br>> +   
                            if [[ $i == "shared" || $i == "autom4te.cache" || $i == "no_cpu/no_bsp" ]]; then<br>> +                                       echo -n<br>> +                               else<br>> +                                       cd ../../../../cpukit<br>> +                                       find_rtems_internal<br>> +                                       cd - > /dev/null<br>> +     
                                  bsp=$i<br>> +<br>> +                                       cd $bsp<br>> +                                       main<br>> +                                       cd ../../ > /dev/null<br>> +                               fi<br>> +                       fi<br>> +               done<br>> +<br>> +       else<br>> +           
    return 0<br>> +       fi<br>> +}<br>> +<br>> +# Evaluating Command Line Arguments<br>> +function start(){<br>> +<br>> +       for i in $*<br>> +       do<br>> +               case $i in<br>> +                       "--verbose") verbose="1" # The whole story<br>> +                       ;;<br>> +<br>> +                       "--warnings") warnings="1" # All warnings<br>> +                                                 verbose="0"<br>> +                       ;;<br>> +<br>> + 
                      "--help") echo "Help to be provided"<br>> +                       ;;<br>> +<br>> +                       *) path="$path $i"  ;; # If not above options, then assumed to be a path for bsp<br>> +               esac<br>> +       done<br>> +<br>> +# No path given, search for bsp from pwd<br>> +       if [[ -z $path ]];then<br>> +               path=$PWD<br>> +               cur_dir=`pwd`<br>> +               check_given_dir<br>> +               if [[ $? -eq 1 ]];then<br>> +                 
      echo "Current directory does not seem a valid RTEMS directory"<br>> +               fi<br>> +<br>> +       else<br>> +               for i in $path<br>> +               do<br>> +                       if [[ -d $i ]]; then<br>> +                               echo > /dev/null<br>> +                       else<br>> +                               echo "$i is an invalid directory."<br>> +                               continue<br>> +       
                fi<br>> +<br>> +                       cd $i<br>> +                       cur_dir=`pwd`<br>> +                       check_given_dir<br>> +                       if [[ $? -eq 1 ]];then<br>> +                               echo "$i does not seem a valid RTEMS directory"<br>> +                       fi<br>> +                       cd $calling_path<br>> +<br>> +               done<br>> +       fi<br>> +}<br>> +<br>> +#
 Let the Game begin !!<br>> +start $*<br>> +<br>> +# End of Checks<br>> +if [[ $faults -eq "0" ]] ; then<br>> +       echo -e "\nNo faults found in BSP organization"<br>> +fi<br>> --<br>> 1.7.11.7<br>><br>> _______________________________________________<br>> rtems-devel mailing list<br>> <a ymailto="mailto:rtems-devel@rtems.org" href="mailto:rtems-devel@rtems.org">rtems-devel@rtems.org</a><br>> <a href="http://www.rtems.org/mailman/listinfo/rtems-devel" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br><br><br>-- <br>Joel Sherrill, Ph.D.             Director of Research & Development<br><a ymailto="mailto:joel.sherrill@OARcorp.com" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications Research<br>Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br>Support Available 
               (256) 722-9985<br><br><br><br></div> </div> </div>  </div></body></html>