Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: host/lib/crossystem.c

Issue 6711045: Use VbSharedData instead of VbNvStorage for fwb_tries and kernkey_vfy (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « firmware/lib/vboot_nvstorage.c ('k') | tests/vboot_nvstorage_test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 /* Fields that GetVdatString() can get */ 95 /* Fields that GetVdatString() can get */
96 typedef enum VdatStringField { 96 typedef enum VdatStringField {
97 VDAT_STRING_TIMERS = 0, /* Timer values */ 97 VDAT_STRING_TIMERS = 0, /* Timer values */
98 VDAT_STRING_LOAD_FIRMWARE_DEBUG /* LoadFirmware() debug information */ 98 VDAT_STRING_LOAD_FIRMWARE_DEBUG /* LoadFirmware() debug information */
99 } VdatStringField; 99 } VdatStringField;
100 100
101 101
102 /* Fields that GetVdatInt() can get */ 102 /* Fields that GetVdatInt() can get */
103 typedef enum VdatIntField { 103 typedef enum VdatIntField {
104 VDAT_INT_FLAGS = 0, /* Flags */ 104 VDAT_INT_FLAGS = 0, /* Flags */
105 VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */ 105 VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */
106 VDAT_INT_KERNEL_VERSION_TPM /* Current kernel version in TPM */ 106 VDAT_INT_KERNEL_VERSION_TPM, /* Current kernel version in TPM */
107 VDAT_INT_TRIED_FIRMWARE_B, /* Tried firmware B due to fwb_tries */
108 VDAT_INT_KERNEL_KEY_VERIFIED /* Kernel key verified using
109 * signature, not just hash */
107 } VdatIntField; 110 } VdatIntField;
108 111
109 112
110 /* Copy up to dest_size-1 characters from src to dest, ensuring null 113 /* Copy up to dest_size-1 characters from src to dest, ensuring null
111 termination (which strncpy() doesn't do). Returns the destination 114 termination (which strncpy() doesn't do). Returns the destination
112 string. */ 115 string. */
113 char* StrCopy(char* dest, const char* src, int dest_size) { 116 char* StrCopy(char* dest, const char* src, int dest_size) {
114 strncpy(dest, src, dest_size); 117 strncpy(dest, src, dest_size);
115 dest[dest_size - 1] = '\0'; 118 dest[dest_size - 1] = '\0';
116 return dest; 119 return dest;
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 switch (field) { 674 switch (field) {
672 case VDAT_INT_FLAGS: 675 case VDAT_INT_FLAGS:
673 value = (int)sh->flags; 676 value = (int)sh->flags;
674 break; 677 break;
675 case VDAT_INT_FW_VERSION_TPM: 678 case VDAT_INT_FW_VERSION_TPM:
676 value = (int)sh->fw_version_tpm; 679 value = (int)sh->fw_version_tpm;
677 break; 680 break;
678 case VDAT_INT_KERNEL_VERSION_TPM: 681 case VDAT_INT_KERNEL_VERSION_TPM:
679 value = (int)sh->kernel_version_tpm; 682 value = (int)sh->kernel_version_tpm;
680 break; 683 break;
684 case VDAT_INT_TRIED_FIRMWARE_B:
685 value = (sh->flags & VBSD_FWB_TRIED ? 1 : 0);
686 break;
687 case VDAT_INT_KERNEL_KEY_VERIFIED:
688 value = (sh->flags & VBSD_KERNEL_KEY_VERIFIED ? 1 : 0);
689 break;
681 } 690 }
682 691
683 Free(ab); 692 Free(ab);
684 return value; 693 return value;
685 } 694 }
686 695
687 696
688 /* Read a system property integer. 697 /* Read a system property integer.
689 * 698 *
690 * Returns the property value, or -1 if error. */ 699 * Returns the property value, or -1 if error. */
(...skipping 21 matching lines...) Expand all
712 value = 1 - value; /* Mario reports this backwards */ 721 value = 1 - value; /* Mario reports this backwards */
713 } 722 }
714 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW 723 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW
715 * path exists in sysfs, it's a H2C BIOS. */ 724 * path exists in sysfs, it's a H2C BIOS. */
716 else if (!strcasecmp(name,"savedmem_base")) { 725 else if (!strcasecmp(name,"savedmem_base")) {
717 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000); 726 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000);
718 } else if (!strcasecmp(name,"savedmem_size")) { 727 } else if (!strcasecmp(name,"savedmem_size")) {
719 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000); 728 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000);
720 } 729 }
721 /* NV storage values with no defaults for older BIOS. */ 730 /* NV storage values with no defaults for older BIOS. */
722 else if (!strcasecmp(name,"tried_fwb")) { 731 else if (!strcasecmp(name,"kern_nv")) {
723 value = VbGetNvStorage(VBNV_TRIED_FIRMWARE_B);
724 } else if (!strcasecmp(name,"kern_nv")) {
725 value = VbGetNvStorage(VBNV_KERNEL_FIELD); 732 value = VbGetNvStorage(VBNV_KERNEL_FIELD);
726 } else if (!strcasecmp(name,"nvram_cleared")) { 733 } else if (!strcasecmp(name,"nvram_cleared")) {
727 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET); 734 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET);
728 } else if (!strcasecmp(name,"vbtest_errfunc")) { 735 } else if (!strcasecmp(name,"vbtest_errfunc")) {
729 value = VbGetNvStorage(VBNV_TEST_ERROR_FUNC); 736 value = VbGetNvStorage(VBNV_TEST_ERROR_FUNC);
730 } else if (!strcasecmp(name,"vbtest_errno")) { 737 } else if (!strcasecmp(name,"vbtest_errno")) {
731 value = VbGetNvStorage(VBNV_TEST_ERROR_NUM); 738 value = VbGetNvStorage(VBNV_TEST_ERROR_NUM);
732 } 739 }
733 /* NV storage values. If unable to get from NV storage, fall back to the 740 /* NV storage values. If unable to get from NV storage, fall back to the
734 * CMOS reboot field used by older BIOS. */ 741 * CMOS reboot field used by older BIOS. */
(...skipping 16 matching lines...) Expand all
751 } else if (!strcasecmp(name,"fmap_base")) { 758 } else if (!strcasecmp(name,"fmap_base")) {
752 value = ReadFileInt(ACPI_FMAP_PATH); 759 value = ReadFileInt(ACPI_FMAP_PATH);
753 } else if (!strcasecmp(name,"cros_debug")) { 760 } else if (!strcasecmp(name,"cros_debug")) {
754 value = VbGetCrosDebug(); 761 value = VbGetCrosDebug();
755 } else if (!strcasecmp(name,"vdat_flags")) { 762 } else if (!strcasecmp(name,"vdat_flags")) {
756 value = GetVdatInt(VDAT_INT_FLAGS); 763 value = GetVdatInt(VDAT_INT_FLAGS);
757 } else if (!strcasecmp(name,"tpm_fwver")) { 764 } else if (!strcasecmp(name,"tpm_fwver")) {
758 value = GetVdatInt(VDAT_INT_FW_VERSION_TPM); 765 value = GetVdatInt(VDAT_INT_FW_VERSION_TPM);
759 } else if (!strcasecmp(name,"tpm_kernver")) { 766 } else if (!strcasecmp(name,"tpm_kernver")) {
760 value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM); 767 value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM);
768 } else if (!strcasecmp(name,"tried_fwb")) {
769 value = GetVdatInt(VDAT_INT_TRIED_FIRMWARE_B);
761 } 770 }
762 771
763 return value; 772 return value;
764 } 773 }
765 774
766 /* Read a system property string into a destination buffer of the specified 775 /* Read a system property string into a destination buffer of the specified
767 * size. 776 * size.
768 * 777 *
769 * Returns the passed buffer, or NULL if error. */ 778 * Returns the passed buffer, or NULL if error. */
770 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { 779 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) {
(...skipping 20 matching lines...) Expand all
791 } else if (!strcasecmp(name,"ecfw_act")) { 800 } else if (!strcasecmp(name,"ecfw_act")) {
792 switch(ReadFileInt(ACPI_BINF_PATH ".2")) { 801 switch(ReadFileInt(ACPI_BINF_PATH ".2")) {
793 case 0: 802 case 0:
794 return StrCopy(dest, "RO", size); 803 return StrCopy(dest, "RO", size);
795 case 1: 804 case 1:
796 return StrCopy(dest, "RW", size); 805 return StrCopy(dest, "RW", size);
797 default: 806 default:
798 return NULL; 807 return NULL;
799 } 808 }
800 } else if (!strcasecmp(name,"kernkey_vfy")) { 809 } else if (!strcasecmp(name,"kernkey_vfy")) {
801 switch(VbGetNvStorage(VBNV_FW_VERIFIED_KERNEL_KEY)) { 810 switch(GetVdatInt(VDAT_INT_KERNEL_KEY_VERIFIED)) {
802 case 0: 811 case 0:
803 return "hash"; 812 return "hash";
804 case 1: 813 case 1:
805 return "sig"; 814 return "sig";
806 default: 815 default:
807 return NULL; 816 return NULL;
808 } 817 }
809 } else if (!strcasecmp(name, "vdat_timers")) { 818 } else if (!strcasecmp(name, "vdat_timers")) {
810 return GetVdatString(dest, size, VDAT_STRING_TIMERS); 819 return GetVdatString(dest, size, VDAT_STRING_TIMERS);
811 } else if (!strcasecmp(name, "vdat_lfdebug")) { 820 } else if (!strcasecmp(name, "vdat_lfdebug")) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 861
853 862
854 /* Set a system property string. 863 /* Set a system property string.
855 * 864 *
856 * Returns 0 if success, -1 if error. */ 865 * Returns 0 if success, -1 if error. */
857 int VbSetSystemPropertyString(const char* name, const char* value) { 866 int VbSetSystemPropertyString(const char* name, const char* value) {
858 867
859 /* TODO: support setting */ 868 /* TODO: support setting */
860 return -1; 869 return -1;
861 } 870 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_nvstorage.c ('k') | tests/vboot_nvstorage_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698