Skip to content

Instantly share code, notes, and snippets.

@daviddpd
Created October 1, 2017 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddpd/4c05dedcc4d7fb3d47f257de331b25e0 to your computer and use it in GitHub Desktop.
Save daviddpd/4c05dedcc4d7fb3d47f257de331b25e0 to your computer and use it in GitHub Desktop.
Example of switching the serial console base on the SMBIOS defined product
\ 2017, Public Domain: by David P. Discher dpd@dpdtech.com
\
\ Using this FreeBSD bhyve (loader?) to read a non-existant ENV, panics the loader. (seg fault)
\ TO use/test add these two lines to /boot/loader.rc, before "beastie-start"
\ include /boot/serial.4th
\ serialcheck
\ For later google results, this can also be use to change/set any loader value
\ based on any KENV in FreeBSD that is avaiable at the /boot/loader stage.
\ Keywords: FreeBSD, loader, forth, 4th, setting loader values, example
: serialcheck ( -- ) \ check to see if we should use com1 or com2
." Serial port, checking smbios.planar.product for Product One ... " cr
s" smbios.planar.product" getenv
s" Product One" compare-insensitive 0= if
." Product One, uses com1 ... " cr
s" set comconsole_port=0x3f8" evaluate
then
." Serial port, checking smbios.planar.product for Product Two ... " cr
s" smbios.planar.product" getenv
s" Product Two" compare-insensitive 0= if
." Product Two, uses com2 ... " cr
s" set comconsole_port=0x2f8" evaluate
then
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment