1 #!/usr/bin/sh
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 #
  22 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23 # Use is subject to license terms.
  24 #
  25 # Build-time script to generate the sd_iob_implX.c files.
  26 #
  27 START="$1"
  28 END="$2"
  29 FILE="$3"
  30 
  31 awk '
  32 /#define.*_SD_DEFAULT_IOBUFS/ {
  33         num = $3;
  34 printf("/* start = %d, end = %d, num %d */\n", start, end, num);
  35         if (num > end) {
  36                 num = end;
  37         }
  38 printf("/* start = %d, end = %d, num %d */\n", start, end, num);
  39 }
  40 
  41 END {
  42         printf("/* start = %d, end = %d, num %d */\n", start, end, num);
  43         printf("#include <sys/types.h>\n");
  44         printf("#include <sys/param.h>\n");
  45         printf("#include <sys/ksynch.h>\n");
  46         printf("#include <sys/kmem.h>\n");
  47         printf("#include <sys/stat.h>\n");
  48         printf("#include <sys/buf.h>\n");
  49         printf("#include <sys/open.h>\n");
  50         printf("#include <sys/conf.h>\n");
  51         printf("#include <sys/file.h>\n");
  52         printf("#include <sys/cmn_err.h>\n");
  53         printf("#include <sys/errno.h>\n");
  54         printf("#include <sys/debug.h>\n");
  55         printf("#include <sys/ddi.h>\n");
  56         printf("#include <sys/nsc_thread.h>\n");
  57         printf("#include <sys/nsctl/sd_bcache.h>\n");
  58         printf("#include <sys/nsctl/sd_trace.h>\n");
  59         printf("#include <ns/sdbc/sd_io.h>\n");
  60         printf("#include <ns/sdbc/sd_iob.h>\n");
  61 
  62         n = start;
  63         while (n < num) {
  64                 printf("IOB_DCB(%d)", n);
  65                 n = n + 1;
  66 
  67                 if (n % 4) {
  68                         printf(" ");
  69                 } else {
  70                         printf("\n");
  71                         if (!((n - start) % 2048) && (n < num))
  72                                 printf("static int _cscope_brkline%d;\n", n);
  73                 }
  74         }
  75 }' start=$START end=$END incdir=`dirname $FILE` $FILE
  76 
  77 exit 0