-/* $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 <yasuoka@yasuoka.net>
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)
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) {
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();
}