Print this page
12220 loader multi-console shouldn't override bootenv.rc


  84 static uint_t kbm_debug = 0;
  85 #define DBG_MSG(s)      { if (kbm_debug) bop_printf(NULL, "%s", s); }
  86 #define DBG(x)          { if (kbm_debug)                        \
  87         bop_printf(NULL, "%s is %" PRIx64 "\n", #x, (uint64_t)(x));     \
  88         }
  89 
  90 #define PUT_STRING(s) {                         \
  91         char *cp;                               \
  92         for (cp = (s); *cp; ++cp)               \
  93                 bcons_putchar(*cp);             \
  94         }
  95 
  96 /* callback to boot_fb to set shadow frame buffer */
  97 extern void boot_fb_shadow_init(bootops_t *);
  98 
  99 bootops_t bootop;       /* simple bootops we'll pass on to kernel */
 100 struct bsys_mem bm;
 101 
 102 /*
 103  * Boot info from "glue" code in low memory. xbootp is used by:
 104  *      do_bop_phys_alloc(), do_bsys_alloc() and boot_prop_finish().
 105  */
 106 static struct xboot_info *xbootp;
 107 static uintptr_t next_virt;     /* next available virtual address */
 108 static paddr_t next_phys;       /* next available physical address from dboot */
 109 static paddr_t high_phys = -(paddr_t)1; /* last used physical address */
 110 
 111 /*
 112  * buffer for vsnprintf for console I/O
 113  */
 114 #define BUFFERSIZE      512
 115 static char buffer[BUFFERSIZE];
 116 
 117 /*
 118  * stuff to store/report/manipulate boot property settings.
 119  */
 120 typedef struct bootprop {
 121         struct bootprop *bp_next;
 122         char *bp_name;
 123         int bp_flags;                   /* DDI prop type */
 124         uint_t bp_vlen;                 /* 0 for boolean */


 653                         break;
 654                 }
 655                 bop_printf(NULL, "\n");
 656         }
 657 }
 658 
 659 /*
 660  * 2nd part of building the table of boot properties. This includes:
 661  * - values from /boot/solaris/bootenv.rc (ie. eeprom(1m) values)
 662  *
 663  * lines look like one of:
 664  * ^$
 665  * ^# comment till end of line
 666  * setprop name 'value'
 667  * setprop name value
 668  * setprop name "value"
 669  *
 670  * we do single character I/O since this is really just looking at memory
 671  */
 672 void
 673 boot_prop_finish(void)
 674 {
 675         int fd;
 676         char *line;
 677         int c;
 678         int bytes_read;
 679         char *name;
 680         int n_len;
 681         char *value;
 682         int v_len;
 683         char *inputdev; /* these override the command line if serial ports */
 684         char *outputdev;
 685         char *consoledev;
 686         uint64_t lvalue;
 687         int use_xencons = 0;
 688         extern int bootrd_debug;
 689 
 690 #ifdef __xpv
 691         if (!DOMAIN_IS_INITDOMAIN(xen_info))
 692                 use_xencons = 1;
 693 #endif /* __xpv */


 761                         ++value;
 762                         v_len -= 2;
 763                 }
 764                 name[n_len] = 0;
 765                 if (v_len > 0)
 766                         value[v_len] = 0;
 767                 else
 768                         continue;
 769 
 770                 /*
 771                  * ignore "boot-file" property, it's now meaningless
 772                  */
 773                 if (strcmp(name, "boot-file") == 0)
 774                         continue;
 775                 if (strcmp(name, "boot-args") == 0 &&
 776                     strlen(boot_args) > 0)
 777                         continue;
 778 
 779                 /*
 780                  * If a property was explicitly set on the command line
 781                  * it will override a setting in bootenv.rc







 782                  */
 783                 if (do_bsys_getproplen(NULL, name) >= 0)





 784                         continue;

 785 

 786                 bsetprops(name, value);
 787         }
 788 done:
 789         if (fd >= 0)
 790                 (void) BRD_CLOSE(bfs_ops, fd);
 791 

 792         /*
 793          * Check if we have to limit the boot time allocator
 794          */
 795         if (do_bsys_getproplen(NULL, "physmem") != -1 &&
 796             do_bsys_getprop(NULL, "physmem", line) >= 0 &&
 797             parse_value(line, &lvalue) != -1) {
 798                 if (0 < lvalue && (lvalue < physmem || physmem == 0)) {
 799                         physmem = (pgcnt_t)lvalue;
 800                         DBG(physmem);
 801                 }
 802         }
 803         early_allocation = 0;
 804 
 805         /*
 806          * Check for bootrd_debug.
 807          */
 808         if (find_boot_prop("bootrd_debug"))
 809                 bootrd_debug = 1;
 810 
 811         /*


 826                         (void) do_bsys_getprop(NULL, "output-device",
 827                             outputdev);
 828                 else
 829                         v_len = 0;
 830                 outputdev[v_len] = 0;
 831 
 832                 consoledev = outputdev + v_len + 1;
 833                 v_len = do_bsys_getproplen(NULL, "console");
 834                 if (v_len > 0) {
 835                         (void) do_bsys_getprop(NULL, "console", consoledev);
 836                         if (post_fastreboot &&
 837                             strcmp(consoledev, "graphics") == 0) {
 838                                 bsetprops("console", "text");
 839                                 v_len = strlen("text");
 840                                 bcopy("text", consoledev, v_len);
 841                         }
 842                 } else {
 843                         v_len = 0;
 844                 }
 845                 consoledev[v_len] = 0;
 846                 bcons_init2(inputdev, outputdev, consoledev);
 847         } else {
 848                 /*
 849                  * Ensure console property exists
 850                  * If not create it as "hypervisor"
 851                  */
 852                 v_len = do_bsys_getproplen(NULL, "console");
 853                 if (v_len < 0)
 854                         bsetprops("console", "hypervisor");
 855                 inputdev = outputdev = consoledev = "hypervisor";
 856                 bcons_init2(inputdev, outputdev, consoledev);
 857         }
 858 
 859         if (find_boot_prop("prom_debug") || kbm_debug)
 860                 boot_prop_display(line);
 861 }
 862 
 863 /*
 864  * print formatted output
 865  */
 866 /*ARGSUSED*/
 867 void
 868 vbop_printf(void *ptr, const char *fmt, va_list ap)
 869 {
 870         if (have_console == 0)
 871                 return;
 872 
 873         (void) vsnprintf(buffer, BUFFERSIZE, fmt, ap);
 874         PUT_STRING(buffer);
 875 }
 876 




  84 static uint_t kbm_debug = 0;
  85 #define DBG_MSG(s)      { if (kbm_debug) bop_printf(NULL, "%s", s); }
  86 #define DBG(x)          { if (kbm_debug)                        \
  87         bop_printf(NULL, "%s is %" PRIx64 "\n", #x, (uint64_t)(x));     \
  88         }
  89 
  90 #define PUT_STRING(s) {                         \
  91         char *cp;                               \
  92         for (cp = (s); *cp; ++cp)               \
  93                 bcons_putchar(*cp);             \
  94         }
  95 
  96 /* callback to boot_fb to set shadow frame buffer */
  97 extern void boot_fb_shadow_init(bootops_t *);
  98 
  99 bootops_t bootop;       /* simple bootops we'll pass on to kernel */
 100 struct bsys_mem bm;
 101 
 102 /*
 103  * Boot info from "glue" code in low memory. xbootp is used by:
 104  *      do_bop_phys_alloc(), do_bsys_alloc() and read_bootenvrc().
 105  */
 106 static struct xboot_info *xbootp;
 107 static uintptr_t next_virt;     /* next available virtual address */
 108 static paddr_t next_phys;       /* next available physical address from dboot */
 109 static paddr_t high_phys = -(paddr_t)1; /* last used physical address */
 110 
 111 /*
 112  * buffer for vsnprintf for console I/O
 113  */
 114 #define BUFFERSIZE      512
 115 static char buffer[BUFFERSIZE];
 116 
 117 /*
 118  * stuff to store/report/manipulate boot property settings.
 119  */
 120 typedef struct bootprop {
 121         struct bootprop *bp_next;
 122         char *bp_name;
 123         int bp_flags;                   /* DDI prop type */
 124         uint_t bp_vlen;                 /* 0 for boolean */


 653                         break;
 654                 }
 655                 bop_printf(NULL, "\n");
 656         }
 657 }
 658 
 659 /*
 660  * 2nd part of building the table of boot properties. This includes:
 661  * - values from /boot/solaris/bootenv.rc (ie. eeprom(1m) values)
 662  *
 663  * lines look like one of:
 664  * ^$
 665  * ^# comment till end of line
 666  * setprop name 'value'
 667  * setprop name value
 668  * setprop name "value"
 669  *
 670  * we do single character I/O since this is really just looking at memory
 671  */
 672 void
 673 read_bootenvrc(void)
 674 {
 675         int fd;
 676         char *line;
 677         int c;
 678         int bytes_read;
 679         char *name;
 680         int n_len;
 681         char *value;
 682         int v_len;
 683         char *inputdev; /* these override the command line if serial ports */
 684         char *outputdev;
 685         char *consoledev;
 686         uint64_t lvalue;
 687         int use_xencons = 0;
 688         extern int bootrd_debug;
 689 
 690 #ifdef __xpv
 691         if (!DOMAIN_IS_INITDOMAIN(xen_info))
 692                 use_xencons = 1;
 693 #endif /* __xpv */


 761                         ++value;
 762                         v_len -= 2;
 763                 }
 764                 name[n_len] = 0;
 765                 if (v_len > 0)
 766                         value[v_len] = 0;
 767                 else
 768                         continue;
 769 
 770                 /*
 771                  * ignore "boot-file" property, it's now meaningless
 772                  */
 773                 if (strcmp(name, "boot-file") == 0)
 774                         continue;
 775                 if (strcmp(name, "boot-args") == 0 &&
 776                     strlen(boot_args) > 0)
 777                         continue;
 778 
 779                 /*
 780                  * If a property was explicitly set on the command line
 781                  * it will override a setting in bootenv.rc. We make an
 782                  * exception for a property from the bootloader such as:
 783                  *
 784                  * console="text,ttya,ttyb,ttyc,ttyd"
 785                  *
 786                  * In such a case, picking the first value here (as
 787                  * lookup_console_devices() does) is at best a guess; if
 788                  * bootenv.rc has a value, it's probably better.
 789                  */
 790                 if (strcmp(name, "console") == 0) {
 791                         char propval[BP_MAX_STRLEN] = "";
 792 
 793                         if (do_bsys_getprop(NULL, name, propval) == -1 ||
 794                             strchr(propval, ',') != NULL)
 795                                 bsetprops(name, value);
 796                         continue;
 797                 }
 798 
 799                 if (do_bsys_getproplen(NULL, name) == -1)
 800                         bsetprops(name, value);
 801         }
 802 done:
 803         if (fd >= 0)
 804                 (void) BRD_CLOSE(bfs_ops, fd);
 805 
 806 
 807         /*
 808          * Check if we have to limit the boot time allocator
 809          */
 810         if (do_bsys_getproplen(NULL, "physmem") != -1 &&
 811             do_bsys_getprop(NULL, "physmem", line) >= 0 &&
 812             parse_value(line, &lvalue) != -1) {
 813                 if (0 < lvalue && (lvalue < physmem || physmem == 0)) {
 814                         physmem = (pgcnt_t)lvalue;
 815                         DBG(physmem);
 816                 }
 817         }
 818         early_allocation = 0;
 819 
 820         /*
 821          * Check for bootrd_debug.
 822          */
 823         if (find_boot_prop("bootrd_debug"))
 824                 bootrd_debug = 1;
 825 
 826         /*


 841                         (void) do_bsys_getprop(NULL, "output-device",
 842                             outputdev);
 843                 else
 844                         v_len = 0;
 845                 outputdev[v_len] = 0;
 846 
 847                 consoledev = outputdev + v_len + 1;
 848                 v_len = do_bsys_getproplen(NULL, "console");
 849                 if (v_len > 0) {
 850                         (void) do_bsys_getprop(NULL, "console", consoledev);
 851                         if (post_fastreboot &&
 852                             strcmp(consoledev, "graphics") == 0) {
 853                                 bsetprops("console", "text");
 854                                 v_len = strlen("text");
 855                                 bcopy("text", consoledev, v_len);
 856                         }
 857                 } else {
 858                         v_len = 0;
 859                 }
 860                 consoledev[v_len] = 0;
 861                 bcons_post_bootenvrc(inputdev, outputdev, consoledev);
 862         } else {
 863                 /*
 864                  * Ensure console property exists
 865                  * If not create it as "hypervisor"
 866                  */
 867                 v_len = do_bsys_getproplen(NULL, "console");
 868                 if (v_len < 0)
 869                         bsetprops("console", "hypervisor");
 870                 inputdev = outputdev = consoledev = "hypervisor";
 871                 bcons_post_bootenvrc(inputdev, outputdev, consoledev);
 872         }
 873 
 874         if (find_boot_prop("prom_debug") || kbm_debug)
 875                 boot_prop_display(line);
 876 }
 877 
 878 /*
 879  * print formatted output
 880  */
 881 /*ARGSUSED*/
 882 void
 883 vbop_printf(void *ptr, const char *fmt, va_list ap)
 884 {
 885         if (have_console == 0)
 886                 return;
 887 
 888         (void) vsnprintf(buffer, BUFFERSIZE, fmt, ap);
 889         PUT_STRING(buffer);
 890 }
 891