From c5259e9c0a7abd781e42ec2bd55ec54f3c711588 Mon Sep 17 00:00:00 2001 From: yasuoka Date: Tue, 30 Aug 2016 20:31:09 +0000 Subject: [PATCH] Use MaxMode to terminate the mode iteration. Actually the old way couldn't interate the ConsOut modes properly on qemu. input NONAKA Kimihiro --- sys/arch/amd64/stand/efiboot/efiboot.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index 7833a8a25c6..29ea212e758 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.13 2016/06/10 18:36:06 jcs Exp $ */ +/* $OpenBSD: efiboot.c,v 1.14 2016/08/30 20:31:09 yasuoka Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -373,10 +373,10 @@ efi_video_init(void) EfiConsoleControlScreenText); mode80x25 = -1; mode100x31 = -1; - for (i = 0; ; i++) { + for (i = 0; i < conout->Mode->MaxMode; i++) { status = EFI_CALL(conout->QueryMode, conout, i, &cols, &rows); if (EFI_ERROR(status)) - break; + continue; if (mode80x25 < 0 && cols == 80 && rows == 25) mode80x25 = i; if (mode100x31 < 0 && cols == 100 && rows == 31) @@ -519,10 +519,10 @@ efi_makebootargs(void) status = EFI_CALL(BS->LocateProtocol, &gop_guid, NULL, (void **)&gop); if (!EFI_ERROR(status)) { - for (i = 0; ; i++) { + for (i = 0; i < gop->Mode->MaxMode; i++) { status = EFI_CALL(gop->QueryMode, gop, i, &sz, &info); if (EFI_ERROR(status)) - break; + continue; gopsiz = info->HorizontalResolution * info->VerticalResolution; if (gopsiz > bestsiz) { @@ -629,16 +629,17 @@ Xvideo_efi(void) int i, mode = -1; char *p; - for (i = 0; i < nitems(efi_video) && efi_video[i].cols > 0; i++) { - printf("Mode %d: %d x %d\n", i, - efi_video[i].cols, efi_video[i].rows); + for (i = 0; i < nitems(efi_video) && i < conout->Mode->MaxMode; i++) { + if (efi_video[i].cols > 0) + printf("Mode %d: %d x %d\n", i, + efi_video[i].cols, efi_video[i].rows); } if (cmd.argc == 2) { p = cmd.argv[1]; mode = strtol(p, &p, 10); } printf("\nCurrent Mode = %d\n", conout->Mode->Mode); - if (0 <= mode && mode < i) { + if (0 <= mode && mode < i && efi_video[mode].cols > 0) { EFI_CALL(conout->SetMode, conout, mode); efi_video_reset(); } -- 2.20.1