Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/efiboot efiboot: Added serial console su...



details:   https://anonhg.NetBSD.org/src/rev/892fa88bd663
branches:  trunk
changeset: 831376:892fa88bd663
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Tue Mar 27 14:15:05 2018 +0000

description:
efiboot: Added serial console support.

diffstat:

 sys/arch/i386/stand/efiboot/Makefile.efiboot       |    4 +-
 sys/arch/i386/stand/efiboot/boot.c                 |  118 ++++-
 sys/arch/i386/stand/efiboot/bootia32/efibootia32.c |    8 +-
 sys/arch/i386/stand/efiboot/bootx64/efibootx64.c   |    8 +-
 sys/arch/i386/stand/efiboot/efiboot.c              |   12 +-
 sys/arch/i386/stand/efiboot/efiboot.h              |    8 +-
 sys/arch/i386/stand/efiboot/efichar.c              |  195 ++++++++
 sys/arch/i386/stand/efiboot/eficons.c              |  467 +++++++++++++++++++-
 sys/arch/i386/stand/efiboot/efidelay.c             |   18 +-
 sys/arch/i386/stand/efiboot/efidisk.c              |    8 +-
 sys/arch/i386/stand/efiboot/efimemory.c            |   18 +-
 11 files changed, 765 insertions(+), 99 deletions(-)

diffs (truncated from 1318 to 300 lines):

diff -r 1eeba97b75ec -r 892fa88bd663 sys/arch/i386/stand/efiboot/Makefile.efiboot
--- a/sys/arch/i386/stand/efiboot/Makefile.efiboot      Tue Mar 27 11:59:49 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot      Tue Mar 27 14:15:05 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.10 2018/03/08 10:34:33 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
 
 S=             ${.CURDIR}/../../../../..
 
@@ -12,7 +12,7 @@
 LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
 LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
 LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
+LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
 LIBI386SRCS+= efigetsecs.c efimemory.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
diff -r 1eeba97b75ec -r 892fa88bd663 sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c        Tue Mar 27 11:59:49 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c        Tue Mar 27 14:15:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.7 2018/03/20 10:18:10 nonaka Exp $  */
+/*     $NetBSD: boot.c,v 1.8 2018/03/27 14:15:05 nonaka Exp $  */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -463,11 +463,16 @@
        char *sep, *sep2 = NULL;
        int ioport, speed = 0;
 
+       if (*arg == '\0') {
+               efi_cons_show();
+               return;
+       }
+
        sep = strchr(arg, ',');
        if (sep != NULL) {
                *sep++ = '\0';
                sep2 = strchr(sep, ',');
-               if (sep != NULL)
+               if (sep2 != NULL)
                        *sep2++ = '\0';
        }
 
@@ -555,6 +560,8 @@
 command_version(char *arg)
 {
        CHAR16 *path;
+       char *upath, *ufirmware;
+       int rv;
 
        if (strcmp(arg, "full") == 0) {
                printf("ImageBase: 0x%" PRIxPTR "\n",
@@ -562,12 +569,24 @@
                printf("Stack: 0x%" PRIxPTR "\n", efi_main_sp);
                printf("EFI version: %d.%02d\n",
                    ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
-               Print(L"EFI Firmware: %s (rev %d.%02d)\n", ST->FirmwareVendor,
-                   ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
+               ufirmware = NULL;
+               rv = ucs2_to_utf8(ST->FirmwareVendor, &ufirmware);
+               if (rv == 0) {
+                       printf("EFI Firmware: %s (rev %d.%02d)\n", ufirmware,
+                           ST->FirmwareRevision >> 16,
+                           ST->FirmwareRevision & 0xffff);
+                       FreePool(ufirmware);
+               }
                path = DevicePathToStr(efi_bootdp);
-               Print(L"Boot DevicePath: %d:%d:%s\n", DevicePathType(efi_bootdp),
-                   DevicePathSubType(efi_bootdp), path);
+               upath = NULL;
+               rv = ucs2_to_utf8(path, &upath);
                FreePool(path);
+               if (rv == 0) {
+                       printf("Boot DevicePath: %d:%d:%s\n",
+                           DevicePathType(efi_bootdp),
+                           DevicePathSubType(efi_bootdp), upath);
+                       FreePool(upath);
+               }
        }
 
        printf("\n"
@@ -603,7 +622,9 @@
        EFI_HANDLE *handles;
        EFI_DEVICE_PATH *dp0, *dp;
        CHAR16 *path;
+       char *upath;
        UINTN cols, rows, row = 0;
+       int rv;
 
        status = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut,
            ST->ConOut->Mode->Mode, &cols, &rows);
@@ -626,41 +647,54 @@
                if (EFI_ERROR(status))
                        break;
 
-               Print(L"DevicePathType %d\n", DevicePathType(dp0));
+               printf("DevicePathType %d\n", DevicePathType(dp0));
                if (++row >= rows) {
                        row = 0;
-                       Print(L"Press Any Key to continue :");
+                       printf("Press Any Key to continue :");
                        (void) awaitkey(-1, 0);
-                       Print(L"\n");
+                       printf("\n");
                }
                for (dp = dp0;
                     !IsDevicePathEnd(dp);
                     dp = NextDevicePathNode(dp)) {
+
                        path = DevicePathToStr(dp);
-                       Print(L"%d:%d:%s\n", DevicePathType(dp), DevicePathSubType(dp), path);
+                       upath = NULL;
+                       rv = ucs2_to_utf8(path, &upath);
                        FreePool(path);
+                       if (rv) {
+                               printf("convert failed\n");
+                               break;
+                       }
+
+                       printf("%d:%d:%s\n", DevicePathType(dp),
+                           DevicePathSubType(dp), upath);
+                       FreePool(upath);
 
                        if (++row >= rows) {
                                row = 0;
-                               Print(L"Press Any Key to continue :");
+                               printf("Press Any Key to continue :");
                                (void) awaitkey(-1, 0);
-                               Print(L"\n");
+                               printf("\n");
                        }
                }
        }
 }
 
+
 void
 command_efivar(char *arg)
 {
-       static const CHAR16 header[] =
-        L"GUID                                Variable Name        Value\n"
-        L"=================================== ==================== ========\n";
+       static const char header[] =
+        "GUID                                 Variable Name        Value\n"
+        "==================================== ==================== ========\n";
        EFI_STATUS status;
        UINTN sz = 64, osz;
-       CHAR16 *name = NULL, *tmp, *val;
+       CHAR16 *name = NULL, *tmp, *val, guid[128];
+       char *uname, *uval, *uguid;
        EFI_GUID vendor;
        UINTN cols, rows, row = 0;
+       int rv;
 
        status = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut,
            ST->ConOut->Mode->Mode, &cols, &rows);
@@ -671,15 +705,15 @@
 
        name = AllocatePool(sz);
        if (name == NULL) {
-               Print(L"memory allocation failed: %ld bytes\n",
-                   (UINT64)sz);
+               printf("memory allocation failed: %" PRIuMAX" bytes\n",
+                   (uintmax_t)sz);
                return;
        }
 
        SetMem(name, sz, 0);
        vendor = NullGuid;
 
-       Print(L"%s", header);
+       printf("%s", header);
        for (;;) {
                osz = sz;
                status = uefi_call_wrapper(RT->GetNextVariableName, 3,
@@ -688,15 +722,15 @@
                        if (status == EFI_NOT_FOUND)
                                break;
                        if (status != EFI_BUFFER_TOO_SMALL) {
-                               Print(L"GetNextVariableName failed: %r\n",
-                                   status);
+                               printf("GetNextVariableName failed: %" PRIxMAX "\n",
+                                   (uintmax_t)status);
                                break;
                        }
 
                        tmp = AllocatePool(sz);
                        if (tmp == NULL) {
-                               Print(L"memory allocation failed: %ld bytes\n",
-                                   (UINT64)sz);
+                               printf("memory allocation failed: %" PRIuMAX
+                                   "bytes\n", (uintmax_t)sz);
                                break;
                        }
                        SetMem(tmp, sz, 0);
@@ -707,15 +741,43 @@
                }
 
                val = LibGetVariable(name, &vendor);
-               Print(L"%.-35g %.-20s %s\n", &vendor, name,
-                   val ? val : L"(null)");
-               FreePool(val);
+               if (val != NULL) {
+                       uval = NULL;
+                       rv = ucs2_to_utf8(val, &uval);
+                       FreePool(val);
+                       if (rv) {
+                               printf("value convert failed\n");
+                               break;
+                       }
+               } else
+                       uval = NULL;
+               uname = NULL;
+               rv = ucs2_to_utf8(name, &uname);
+               if (rv) {
+                       printf("name convert failed\n");
+                       FreePool(uval);
+                       break;
+               }
+               GuidToString(guid, &vendor);
+               uguid = NULL;
+               rv = ucs2_to_utf8(guid, &uguid);
+               if (rv) {
+                       printf("GUID convert failed\n");
+                       FreePool(uval);
+                       FreePool(uname);
+                       break;
+               }
+               printf("%-35s %-20s %s\n", uguid, uname, uval ? uval : "(null)");
+               FreePool(uguid);
+               FreePool(uname);
+               if (uval != NULL)
+                       FreePool(uval);
 
                if (++row >= rows) {
                        row = 0;
-                       Print(L"Press Any Key to continue :");
+                       printf("Press Any Key to continue :");
                        (void) awaitkey(-1, 0);
-                       Print(L"\n");
+                       printf("\n");
                }
        }
 
diff -r 1eeba97b75ec -r 892fa88bd663 sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
--- a/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c        Tue Mar 27 11:59:49 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c        Tue Mar 27 14:15:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efibootia32.c,v 1.3 2017/04/29 00:05:35 nonaka Exp $   */
+/*     $NetBSD: efibootia32.c,v 1.4 2018/03/27 14:15:05 nonaka Exp $   */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -46,8 +46,8 @@
        status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
            EfiLoaderData, sz, &addr);
        if (EFI_ERROR(status))
-               Panic(L"%a: AllocatePages() failed: %d page(s): %r",
-                   __func__, sz, status);
+               panic("%s: AllocatePages() failed: %d page(s): %" PRIxMAX,
+                   __func__, sz, (uintmax_t)status);
        startprog32 = (void *)(u_long)addr;
        CopyMem(startprog32, startprog32_start, startprog32_size);
 }
@@ -67,5 +67,5 @@
 void
 multiboot(physaddr_t entry, physaddr_t header, physaddr_t sp)
 {
-       Panic(L"%a: not implemented", __func__);
+       panic("%s: not implemented", __func__);
 }
diff -r 1eeba97b75ec -r 892fa88bd663 sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
--- a/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c  Tue Mar 27 11:59:49 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c  Tue Mar 27 14:15:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efibootx64.c,v 1.3 2017/04/29 00:05:35 nonaka Exp $    */
+/*     $NetBSD: efibootx64.c,v 1.4 2018/03/27 14:15:05 nonaka Exp $    */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -46,8 +46,8 @@
        status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
            EfiLoaderData, sz, &addr);
        if (EFI_ERROR(status))
-               Panic(L"%a: AllocatePages() failed: %d page(s): %r",
-                   __func__, sz, status);
+               panic("%s: AllocatePages() failed: %d page(s): %" PRIxMAX,
+                   __func__, sz, (uintmax_t)status);
        startprog64 = (void *)addr;
        CopyMem(startprog64, startprog64_start, startprog64_size);
 }
@@ -72,5 +72,5 @@
 void
 multiboot(physaddr_t entry, physaddr_t header, physaddr_t sp)
 {
-       Panic(L"%a: not implemented", __func__);
+       panic("%s: not implemented", __func__);
 }



Home | Main Index | Thread Index | Old Index