The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/boot/mkboot

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/bin/rc
    2 #
    3 #  this file configures a boot program (/boot) for a kernel.
    4 #
    5 if(! ~ $#* 1){
    6         echo usage: mkboot file >[1=2]
    7         exit 1
    8 }
    9 
   10 cat <<'---'
   11 #include <u.h>
   12 #include <libc.h>
   13 #include "../boot/boot.h"
   14 
   15 Method  method[]={
   16 ---
   17 
   18 #
   19 #  configure all remote methods, i.e. all methods in the 'boot' section
   20 #
   21 #  EXAMPLE
   22 #       boot
   23 #               incon
   24 #               9600
   25 #               19200
   26 #
   27 ../port/mkextract boot 0 $* | awk '{
   28         printf "        { \""  "" $1 "\", "\
   29         "config" $1 ", "\
   30         "connect" $1 ", "
   31         print fieldn(2) " },"
   32         }
   33 
   34         func fieldn(n,  s,i)
   35         {
   36                 s = $0
   37                 while (n > 1) {
   38                         sub(/^[ \t]*/, "", s)
   39                         if (substr(s, 1, 1) == "\"") {
   40                                 sub(/^"[^\"]*"/, "", s)
   41                         } else {
   42                                 sub(/^[^ \t]*/, "", s)
   43                         }
   44                         n--
   45                 }
   46                 sub(/^[ \t]*/, "", s)
   47                 if (substr(s, 1, 1) == "\"") {
   48                         i = index(substr(s, 2), "\"")
   49                         if (i > 0)
   50                                 return substr(s, 1, i+1)
   51                         else
   52                                 return s
   53                 } else {
   54                         sub(/[ \t].*/, "", s)
   55                         return s
   56                 }
   57         }'
   58 
   59 cat <<'---'
   60         { 0 },
   61 };
   62 ---
   63 
   64 awk '
   65         BEGIN   { cpuflag = 0; bootprog = "boot"; bootdisk = "#S/sdC0/"; rootdir = "/root"; }
   66         $0 ~ "^boot" && $2=="cpu"\
   67                 { cpuflag = 1
   68                   if(NF == 4 && $3 == "boot")
   69                         bootdisk = $4
   70                 }
   71         $0 ~ "^boot" && $2=="rootdir" && NF==3\
   72                 { rootdir = $3 }
   73         $0 ~ "^boot" && ($2=="bboot" || $2=="romboot" || $2=="dosboot")\
   74                 { cpuflag = 1;  bootprog = $2; }
   75         $0 ~ "^boot" && $2=="boot" && NF==3\
   76                 { bootdisk = $3 }
   77         END     { print "int cpuflag = " cpuflag ";"
   78                   print "char* rootdir = \"" rootdir "\";"
   79                   print "char* bootdisk = \"" bootdisk "\";"
   80                   print "extern void " bootprog "(int, char**);"
   81                   print "void"
   82                   print "main(int argc, char **argv)"
   83                   print "{"
   84                   print "\t" bootprog "(argc, argv);"
   85                   print "}"
   86                 }
   87 ' $1
   88 
   89 #
   90 #  configure in a cache file system if a 
   91 # /386/bin/root appears in the bootdir section.
   92 #
   93 ../port/mkextract bootdir 0 $* | awk '
   94         BEGIN                   { cfs = 0 }
   95         $1 ~ "bin/cfs$" { cfs = 1 }
   96         END                     { if(cfs)
   97                                         print "int (*cfs)(int) = cache;"
   98                                   else
   99                                         print "int (*cfs)(int) = 0;"
  100                                 }
  101         '

Cache object: 5cf64abcfb3fbebfcdf020fde8b3bb64


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.