Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Sep 2020 16:19:21 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366228 - head/stand/lua
Message-ID:  <202009281619.08SGJLHh017519@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Mon Sep 28 16:19:21 2020
New Revision: 366228
URL: https://svnweb.freebsd.org/changeset/base/366228

Log:
  Report the kernel console on the boot screen
  
  Report what console the boot loader is telling the kernel to use:
  	o Dual (Serial Primary)
  	o Dual (Video Primary)
  	o Serial
  	o Video
  
  This allows the user to interrupt the boot and tweak the cosnole, if
  needed, in a trivial way. Useful for installs where the default
  selected may not be quite what you want, or when you are running a
  dual setup and need to toggle over to the other console being primary.
  The 'c'/'C' keys will do the cycling through the consoles.  Note:
  you'll still have to drop into the loader to set details about serial
  consoles. And this doesn't change the console the loader is using.
  
  Reviewed by: kevans@
  MFC After: 3 days
  Differential Revision: https://reviews.freebsd.org/D26573

Modified:
  head/stand/lua/core.lua
  head/stand/lua/menu.lua

Modified: head/stand/lua/core.lua
==============================================================================
--- head/stand/lua/core.lua	Mon Sep 28 14:47:36 2020	(r366227)
+++ head/stand/lua/core.lua	Mon Sep 28 16:19:21 2020	(r366228)
@@ -451,6 +451,40 @@ function core.popFrontTable(tbl)
 	return first_value, new_tbl
 end
 
+function core.getConsoleName()
+	if loader.getenv("boot_multicons") ~= nil then
+		if loader.getenv("boot_serial") ~= nil then
+			return "Dual (Serial primary)"
+		else
+			return "Dual (Video primary)"
+		end
+	else
+		if loader.getenv("boot_serial") ~= nil then
+			return "Serial"
+		else
+			return "Video"
+		end
+	end
+end
+
+function core.nextConsoleChoice()
+	if loader.getenv("boot_multicons") ~= nil then
+		if loader.getenv("boot_serial") ~= nil then
+			loader.unsetenv("boot_serial")
+		else
+			loader.unsetenv("boot_multicons")
+			loader.setenv("boot_serial", "YES")
+		end
+	else
+		if loader.getenv("boot_serial") ~= nil then
+			loader.unsetenv("boot_serial")
+		else
+			loader.setenv("boot_multicons", "YES")
+			loader.setenv("boot_serial", "YES")
+		end
+	end
+end
+
 recordDefaults()
 hook.register("config.reloaded", core.clearCachedKernels)
 return core

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Mon Sep 28 14:47:36 2020	(r366227)
+++ head/stand/lua/menu.lua	Mon Sep 28 16:19:21 2020	(r366228)
@@ -244,6 +244,7 @@ menu.welcome = {
 			boot_entry_2,
 			menu_entries.prompt,
 			menu_entries.reboot,
+			menu_entries.console,
 			{
 				entry_type = core.MENU_SEPARATOR,
 			},
@@ -283,6 +284,16 @@ menu.welcome = {
 				core.boot()
 			end,
 			alias = {"s", "S"},
+		},
+		console = {
+			entry_type = core.MENU_ENTRY,
+			name = function()
+				return color.highlight("C") .. "ons: " .. core.getConsoleName()
+			end,
+			func = function()
+				core.nextConsoleChoice()
+			end,
+			alias = {"c", "C"},
 		},
 		prompt = {
 			entry_type = core.MENU_RETURN,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009281619.08SGJLHh017519>