mirror of
https://git.freebsd.org/src.git
synced 2026-01-12 06:54:03 +00:00
stand: Add print_delay environment variable in loader
This adds support for a new `print_delay` environment variable, which inserts a delay in microseconds when `putchar` encounters a newline character. This can be useful when debugging. Reviewed by: markj, imp, ziaee, mckusick (mentor) Approved by: markj, imp, ziaee, mckusick (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50832
This commit is contained in:
parent
c7da9fb90b
commit
860f20cc13
5 changed files with 35 additions and 1 deletions
|
|
@ -372,6 +372,8 @@ extern struct arch_switch archsw;
|
|||
/* This must be provided by the MD code, but should it be in the archsw? */
|
||||
void delay(int delay);
|
||||
|
||||
int setprint_delay(struct env_var *ev, int flags, const void *value);
|
||||
|
||||
/* common code to set currdev variable. */
|
||||
int gen_setcurrdev(struct env_var *ev, int flags, const void *value);
|
||||
int mount_currdev(struct env_var *, int, const void *);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ static int twiddle_set(struct env_var *ev, int flags, const void *value);
|
|||
#endif
|
||||
int module_verbose = MODULE_VERBOSE;
|
||||
|
||||
static uint32_t print_delay_usec = 0;
|
||||
|
||||
static int
|
||||
module_verbose_set(struct env_var *ev, int flags, const void *value)
|
||||
{
|
||||
|
|
@ -65,6 +67,23 @@ module_verbose_set(struct env_var *ev, int flags, const void *value)
|
|||
return (CMD_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook to set the print delay
|
||||
*/
|
||||
int
|
||||
setprint_delay(struct env_var *ev, int flags, const void *value)
|
||||
{
|
||||
char *end;
|
||||
int usec = strtol(value, &end, 10);
|
||||
|
||||
if (*(char *)value == '\0' || *end != '\0')
|
||||
return (EINVAL);
|
||||
if (usec < 0)
|
||||
return (EINVAL);
|
||||
print_delay_usec = usec;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect possible console(s) to use. If preferred console(s) have been
|
||||
* specified, mark them as active. Else, mark the first probed console
|
||||
|
|
@ -178,6 +197,10 @@ putchar(int c)
|
|||
(C_PRESENTOUT | C_ACTIVEOUT))
|
||||
consoles[cons]->c_out(c);
|
||||
}
|
||||
|
||||
/* Pause after printing newline character if a print delay is set */
|
||||
if (print_delay_usec != 0 && c == '\n')
|
||||
delay(print_delay_usec);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ audit_event_type="etc_security_audit_event"
|
|||
# Default is unset and disabled (no delay).
|
||||
#autoboot_delay="10" # Delay in seconds before autobooting,
|
||||
# -1 for no user interrupts, NO to disable
|
||||
#print_delay="1000000" # Slow printing of loader messages, useful for
|
||||
# debugging. Given in microseconds.
|
||||
#password="" # Prevent changes to boot options
|
||||
#bootlock_password="" # Prevent booting (see check-password.4th(8))
|
||||
#geom_eli_passphrase_prompt="NO" # Prompt for geli(8) passphrase to mount root
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.Dd June 5, 2025
|
||||
.Dd June 12, 2025
|
||||
.Dt LOADER.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -116,6 +116,10 @@ option in this manner,
|
|||
.Va beastie_disable
|
||||
must be set to
|
||||
.Dq Li YES .
|
||||
.It Ar print_delay
|
||||
Add a delay in microseconds after printing each line.
|
||||
Default
|
||||
.Dq Li 0 .
|
||||
.It Ar boot_*
|
||||
See list in
|
||||
.Xr loader.efi 8
|
||||
|
|
|
|||
|
|
@ -1241,6 +1241,9 @@ main(int argc, CHAR16 *argv[])
|
|||
#endif
|
||||
cons_probe();
|
||||
|
||||
/* Set print_delay variable to have hooks in place. */
|
||||
env_setenv("print_delay", EV_VOLATILE, "", setprint_delay, env_nounset);
|
||||
|
||||
/* Set up currdev variable to have hooks in place. */
|
||||
env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue