Deleted Added
full compact
main.c (318480) main.c (328889)
1/*-
2 * Copyright (c) 2008-2010 Rui Paulo
3 * Copyright (c) 2006 Marcel Moolenaar
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008-2010 Rui Paulo
3 * Copyright (c) 2006 Marcel Moolenaar
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: stable/11/sys/boot/efi/loader/main.c 318480 2017-05-18 18:39:23Z markj $");
29__FBSDID("$FreeBSD: stable/11/sys/boot/efi/loader/main.c 328889 2018-02-05 17:01:18Z kevans $");
30
31#include <sys/param.h>
32#include <sys/reboot.h>
33#include <sys/boot.h>
34#include <inttypes.h>
35#include <stand.h>
36#include <string.h>
37#include <setjmp.h>

--- 460 unchanged lines hidden (view full) ---

498command_memmap(int argc, char *argv[])
499{
500 UINTN sz;
501 EFI_MEMORY_DESCRIPTOR *map, *p;
502 UINTN key, dsz;
503 UINT32 dver;
504 EFI_STATUS status;
505 int i, ndesc;
30
31#include <sys/param.h>
32#include <sys/reboot.h>
33#include <sys/boot.h>
34#include <inttypes.h>
35#include <stand.h>
36#include <string.h>
37#include <setjmp.h>

--- 460 unchanged lines hidden (view full) ---

498command_memmap(int argc, char *argv[])
499{
500 UINTN sz;
501 EFI_MEMORY_DESCRIPTOR *map, *p;
502 UINTN key, dsz;
503 UINT32 dver;
504 EFI_STATUS status;
505 int i, ndesc;
506 char line[80];
506 static char *types[] = {
507 "Reserved",
508 "LoaderCode",
509 "LoaderData",
510 "BootServicesCode",
511 "BootServicesData",
512 "RuntimeServicesCode",
513 "RuntimeServicesData",

--- 15 unchanged lines hidden (view full) ---

529 map = malloc(sz);
530 status = BS->GetMemoryMap(&sz, map, &key, &dsz, &dver);
531 if (EFI_ERROR(status)) {
532 printf("Can't read memory map\n");
533 return (CMD_ERROR);
534 }
535
536 ndesc = sz / dsz;
507 static char *types[] = {
508 "Reserved",
509 "LoaderCode",
510 "LoaderData",
511 "BootServicesCode",
512 "BootServicesData",
513 "RuntimeServicesCode",
514 "RuntimeServicesData",

--- 15 unchanged lines hidden (view full) ---

530 map = malloc(sz);
531 status = BS->GetMemoryMap(&sz, map, &key, &dsz, &dver);
532 if (EFI_ERROR(status)) {
533 printf("Can't read memory map\n");
534 return (CMD_ERROR);
535 }
536
537 ndesc = sz / dsz;
537 printf("%23s %12s %12s %8s %4s\n",
538 snprintf(line, sizeof(line), "%23s %12s %12s %8s %4s\n",
538 "Type", "Physical", "Virtual", "#Pages", "Attr");
539 "Type", "Physical", "Virtual", "#Pages", "Attr");
540 pager_open();
541 if (pager_output(line)) {
542 pager_close();
543 return (CMD_OK);
544 }
539
540 for (i = 0, p = map; i < ndesc;
541 i++, p = NextMemoryDescriptor(p, dsz)) {
542 printf("%23s %012jx %012jx %08jx ", types[p->Type],
545
546 for (i = 0, p = map; i < ndesc;
547 i++, p = NextMemoryDescriptor(p, dsz)) {
548 printf("%23s %012jx %012jx %08jx ", types[p->Type],
543 (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart,
544 (uintmax_t)p->NumberOfPages);
549 (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart,
550 (uintmax_t)p->NumberOfPages);
545 if (p->Attribute & EFI_MEMORY_UC)
546 printf("UC ");
547 if (p->Attribute & EFI_MEMORY_WC)
548 printf("WC ");
549 if (p->Attribute & EFI_MEMORY_WT)
550 printf("WT ");
551 if (p->Attribute & EFI_MEMORY_WB)
552 printf("WB ");
553 if (p->Attribute & EFI_MEMORY_UCE)
554 printf("UCE ");
555 if (p->Attribute & EFI_MEMORY_WP)
556 printf("WP ");
557 if (p->Attribute & EFI_MEMORY_RP)
558 printf("RP ");
559 if (p->Attribute & EFI_MEMORY_XP)
560 printf("XP ");
551 if (p->Attribute & EFI_MEMORY_UC)
552 printf("UC ");
553 if (p->Attribute & EFI_MEMORY_WC)
554 printf("WC ");
555 if (p->Attribute & EFI_MEMORY_WT)
556 printf("WT ");
557 if (p->Attribute & EFI_MEMORY_WB)
558 printf("WB ");
559 if (p->Attribute & EFI_MEMORY_UCE)
560 printf("UCE ");
561 if (p->Attribute & EFI_MEMORY_WP)
562 printf("WP ");
563 if (p->Attribute & EFI_MEMORY_RP)
564 printf("RP ");
565 if (p->Attribute & EFI_MEMORY_XP)
566 printf("XP ");
561 printf("\n");
567 if (pager_output("\n"))
568 break;
562 }
563
569 }
570
571 pager_close();
564 return (CMD_OK);
565}
566
567COMMAND_SET(configuration, "configuration", "print configuration tables",
568 command_configuration);
569
570static const char *
571guid_to_string(EFI_GUID *guid)

--- 5 unchanged lines hidden (view full) ---

577 guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
578 guid->Data4[5], guid->Data4[6], guid->Data4[7]);
579 return (buf);
580}
581
582static int
583command_configuration(int argc, char *argv[])
584{
572 return (CMD_OK);
573}
574
575COMMAND_SET(configuration, "configuration", "print configuration tables",
576 command_configuration);
577
578static const char *
579guid_to_string(EFI_GUID *guid)

--- 5 unchanged lines hidden (view full) ---

585 guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
586 guid->Data4[5], guid->Data4[6], guid->Data4[7]);
587 return (buf);
588}
589
590static int
591command_configuration(int argc, char *argv[])
592{
593 char line[80];
585 UINTN i;
586
594 UINTN i;
595
587 printf("NumberOfTableEntries=%lu\n",
596 snprintf(line, sizeof(line), "NumberOfTableEntries=%lu\n",
588 (unsigned long)ST->NumberOfTableEntries);
597 (unsigned long)ST->NumberOfTableEntries);
598 pager_open();
599 if (pager_output(line)) {
600 pager_close();
601 return (CMD_OK);
602 }
603
589 for (i = 0; i < ST->NumberOfTableEntries; i++) {
590 EFI_GUID *guid;
591
592 printf(" ");
593 guid = &ST->ConfigurationTable[i].VendorGuid;
594 if (!memcmp(guid, &mps, sizeof(EFI_GUID)))
595 printf("MPS Table");
596 else if (!memcmp(guid, &acpi, sizeof(EFI_GUID)))

--- 9 unchanged lines hidden (view full) ---

606 else if (!memcmp(guid, &memtype, sizeof(EFI_GUID)))
607 printf("Memory Type Information Table");
608 else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID)))
609 printf("Debug Image Info Table");
610 else if (!memcmp(guid, &fdtdtb, sizeof(EFI_GUID)))
611 printf("FDT Table");
612 else
613 printf("Unknown Table (%s)", guid_to_string(guid));
604 for (i = 0; i < ST->NumberOfTableEntries; i++) {
605 EFI_GUID *guid;
606
607 printf(" ");
608 guid = &ST->ConfigurationTable[i].VendorGuid;
609 if (!memcmp(guid, &mps, sizeof(EFI_GUID)))
610 printf("MPS Table");
611 else if (!memcmp(guid, &acpi, sizeof(EFI_GUID)))

--- 9 unchanged lines hidden (view full) ---

621 else if (!memcmp(guid, &memtype, sizeof(EFI_GUID)))
622 printf("Memory Type Information Table");
623 else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID)))
624 printf("Debug Image Info Table");
625 else if (!memcmp(guid, &fdtdtb, sizeof(EFI_GUID)))
626 printf("FDT Table");
627 else
628 printf("Unknown Table (%s)", guid_to_string(guid));
614 printf(" at %p\n", ST->ConfigurationTable[i].VendorTable);
629 snprintf(line, sizeof(line), " at %p\n",
630 ST->ConfigurationTable[i].VendorTable);
631 if (pager_output(line))
632 break;
615 }
616
633 }
634
635 pager_close();
617 return (CMD_OK);
618}
619
620
621COMMAND_SET(mode, "mode", "change or display EFI text modes", command_mode);
622
623static int
624command_mode(int argc, char *argv[])

--- 415 unchanged lines hidden ---
636 return (CMD_OK);
637}
638
639
640COMMAND_SET(mode, "mode", "change or display EFI text modes", command_mode);
641
642static int
643command_mode(int argc, char *argv[])

--- 415 unchanged lines hidden ---