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

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

Issue 6719005: Cherry-pick vboot_reference files from TOT to support crossystem (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@0.11.257.B
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/stub/utility_stub.c ('k') | tests/tpm_lite/timing.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>
9 #include <sys/stat.h>
10 #include <unistd.h>
11 #include <ctype.h>
8 12
9 #include "host_common.h" 13 #include "host_common.h"
10 14
11 #include "crossystem.h" 15 #include "crossystem.h"
12 #include "utility.h" 16 #include "utility.h"
13 #include "vboot_common.h" 17 #include "vboot_common.h"
14 #include "vboot_nvstorage.h" 18 #include "vboot_nvstorage.h"
19 #include "vboot_struct.h"
15 20
16 /* ACPI constants from Chrome OS Main Processor Firmware Spec */ 21 /* ACPI constants from Chrome OS Main Processor Firmware Spec */
17 /* GPIO signal types */ 22 /* GPIO signal types */
18 #define GPIO_SIGNAL_TYPE_RECOVERY 1 23 #define GPIO_SIGNAL_TYPE_RECOVERY 1
19 #define GPIO_SIGNAL_TYPE_DEV 2 24 #define GPIO_SIGNAL_TYPE_DEV 2
20 #define GPIO_SIGNAL_TYPE_WP 3 25 #define GPIO_SIGNAL_TYPE_WP 3
21 /* CHSW bitflags */ 26 /* CHSW bitflags */
22 #define CHSW_RECOVERY_BOOT 0x00000002 27 #define CHSW_RECOVERY_BOOT 0x00000002
23 #define CHSW_RECOVERY_EC_BOOT 0x00000004 28 #define CHSW_RECOVERY_EC_BOOT 0x00000004
24 #define CHSW_DEV_BOOT 0x00000020 29 #define CHSW_DEV_BOOT 0x00000020
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 66
62 /* Base name for ACPI files */ 67 /* Base name for ACPI files */
63 #define ACPI_BASE_PATH "/sys/devices/platform/chromeos_acpi" 68 #define ACPI_BASE_PATH "/sys/devices/platform/chromeos_acpi"
64 /* Paths for frequently used ACPI files */ 69 /* Paths for frequently used ACPI files */
65 #define ACPI_BINF_PATH ACPI_BASE_PATH "/BINF" 70 #define ACPI_BINF_PATH ACPI_BASE_PATH "/BINF"
66 #define ACPI_CHNV_PATH ACPI_BASE_PATH "/CHNV" 71 #define ACPI_CHNV_PATH ACPI_BASE_PATH "/CHNV"
67 #define ACPI_CHSW_PATH ACPI_BASE_PATH "/CHSW" 72 #define ACPI_CHSW_PATH ACPI_BASE_PATH "/CHSW"
68 #define ACPI_FMAP_PATH ACPI_BASE_PATH "/FMAP" 73 #define ACPI_FMAP_PATH ACPI_BASE_PATH "/FMAP"
69 #define ACPI_GPIO_PATH ACPI_BASE_PATH "/GPIO" 74 #define ACPI_GPIO_PATH ACPI_BASE_PATH "/GPIO"
70 #define ACPI_VBNV_PATH ACPI_BASE_PATH "/VBNV" 75 #define ACPI_VBNV_PATH ACPI_BASE_PATH "/VBNV"
76 #define ACPI_VDAT_PATH ACPI_BASE_PATH "/VDAT"
71 77
72 /* Base name for GPIO files */ 78 /* Base name for GPIO files */
73 #define GPIO_BASE_PATH "/sys/class/gpio" 79 #define GPIO_BASE_PATH "/sys/class/gpio"
74 #define GPIO_EXPORT_PATH GPIO_BASE_PATH "/export" 80 #define GPIO_EXPORT_PATH GPIO_BASE_PATH "/export"
75 81
76 /* Filename for NVRAM file */ 82 /* Filename for NVRAM file */
77 #define NVRAM_PATH "/dev/nvram" 83 #define NVRAM_PATH "/dev/nvram"
78 84
79 /* Filename for kernel command line */ 85 /* Filename for kernel command line */
80 #define KERNEL_CMDLINE_PATH "/proc/cmdline" 86 #define KERNEL_CMDLINE_PATH "/proc/cmdline"
81 87
88 /* A structure to contain buffer data retrieved from the ACPI. */
89 typedef struct {
90 int buffer_size;
91 uint8_t* buffer;
92 } AcpiBuffer;
93
94
95 /* Fields that GetVdatString() can get */
96 typedef enum VdatStringField {
97 VDAT_STRING_TIMERS = 0, /* Timer values */
98 VDAT_STRING_LOAD_FIRMWARE_DEBUG, /* LoadFirmware() debug information */
99 VDAT_STRING_LOAD_KERNEL_DEBUG /* LoadKernel() debug information */
100 } VdatStringField;
101
102
103 /* Fields that GetVdatInt() can get */
104 typedef enum VdatIntField {
105 VDAT_INT_FLAGS = 0, /* Flags */
106 VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */
107 VDAT_INT_KERNEL_VERSION_TPM, /* Current kernel version in TPM */
108 VDAT_INT_TRIED_FIRMWARE_B, /* Tried firmware B due to fwb_tries */
109 VDAT_INT_KERNEL_KEY_VERIFIED /* Kernel key verified using
110 * signature, not just hash */
111 } VdatIntField;
112
82 113
83 /* Copy up to dest_size-1 characters from src to dest, ensuring null 114 /* Copy up to dest_size-1 characters from src to dest, ensuring null
84 termination (which strncpy() doesn't do). Returns the destination 115 termination (which strncpy() doesn't do). Returns the destination
85 string. */ 116 string. */
86 char* StrCopy(char* dest, const char* src, int dest_size) { 117 char* StrCopy(char* dest, const char* src, int dest_size) {
87 strncpy(dest, src, dest_size); 118 strncpy(dest, src, dest_size);
88 dest[dest_size - 1] = '\0'; 119 dest[dest_size - 1] = '\0';
89 return dest; 120 return dest;
90 } 121 }
91 122
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (0 != fseek(f, chnv, SEEK_SET) || EOF == (fputc(nvbyte, f))) { 308 if (0 != fseek(f, chnv, SEEK_SET) || EOF == (fputc(nvbyte, f))) {
278 fclose(f); 309 fclose(f);
279 return -1; 310 return -1;
280 } 311 }
281 312
282 /* Success */ 313 /* Success */
283 fclose(f); 314 fclose(f);
284 return 0; 315 return 0;
285 } 316 }
286 317
318 /*
319 * Get buffer data from ACPI.
320 *
321 * Buffer data is expected to be represented by a file which is a text dump of
322 * the buffer, representing each byte by two hex numbers, space and newline
323 * separated.
324 *
325 * Input - ACPI file name to get data from.
326 *
327 * Output: a pointer to AcpiBuffer structure containing the binary
328 * representation of the data. The caller is responsible for
329 * deallocating the pointer, this will take care of both the structure
330 * and the buffer. Null in case of error.
331 */
332
333 AcpiBuffer* VbGetBuffer(const char* filename)
334 {
335 FILE* f = NULL;
336 char* file_buffer = NULL;
337 AcpiBuffer* acpi_buffer = NULL;
338 AcpiBuffer* return_value = NULL;
339
340 do {
341 struct stat fs;
342 uint8_t* output_ptr;
343 int rv, i, real_size;
344
345 rv = stat(filename, &fs);
346 if (rv || !S_ISREG(fs.st_mode))
347 break;
348
349 f = fopen(filename, "r");
350 if (!f)
351 break;
352
353 file_buffer = Malloc(fs.st_size + 1);
354 if (!file_buffer)
355 break;
356
357 real_size = fread(file_buffer, 1, fs.st_size, f);
358 if (!real_size)
359 break;
360 file_buffer[real_size] = '\0';
361
362 /* Each byte in the output will replace two characters and a space
363 * in the input, so the output size does not exceed input side/3
364 * (a little less if account for newline characters). */
365 acpi_buffer = Malloc(sizeof(AcpiBuffer) + real_size/3);
366 if (!acpi_buffer)
367 break;
368 acpi_buffer->buffer = (uint8_t*)(acpi_buffer + 1);
369 acpi_buffer->buffer_size = 0;
370 output_ptr = acpi_buffer->buffer;
371
372 /* process the file contents */
373 for (i = 0; i < real_size; i++) {
374 char* base, *end;
375
376 base = file_buffer + i;
377
378 if (!isxdigit(*base))
379 continue;
380
381 output_ptr[acpi_buffer->buffer_size++] = strtol(base, &end, 16) & 0xff;
382
383 if ((end - base) != 2)
384 /* Input file format error */
385 break;
386
387 i += 2; /* skip the second character and the following space */
388 }
389
390 if (i == real_size) {
391 /* all is well */
392 return_value = acpi_buffer;
393 acpi_buffer = NULL; /* prevent it from deallocating */
394 }
395 } while(0);
396
397 /* wrap up */
398 if (f)
399 fclose(f);
400
401 if (file_buffer)
402 Free(file_buffer);
403
404 if (acpi_buffer)
405 Free(acpi_buffer);
406
407 return return_value;
408 }
287 409
288 /* Read an integer property from VbNvStorage. 410 /* Read an integer property from VbNvStorage.
289 * 411 *
290 * Returns the parameter value, or -1 if error. */ 412 * Returns the parameter value, or -1 if error. */
291 int VbGetNvStorage(VbNvParam param) { 413 int VbGetNvStorage(VbNvParam param) {
292 FILE* f; 414 FILE* f;
293 VbNvContext vnc; 415 VbNvContext vnc;
294 int offs; 416 int offs;
295 uint32_t value; 417 uint32_t value;
296 int retval; 418 int retval;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 /* Normal new firmware or older Chrome OS firmware allows debug if the 612 /* Normal new firmware or older Chrome OS firmware allows debug if the
491 * dev switch is on. */ 613 * dev switch is on. */
492 if (1 == ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT)) 614 if (1 == ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT))
493 return 1; 615 return 1;
494 616
495 /* All other cases disallow debug. */ 617 /* All other cases disallow debug. */
496 return 0; 618 return 0;
497 } 619 }
498 620
499 621
622 char* GetVdatLoadFirmwareDebug(char* dest, int size,
623 const VbSharedDataHeader* sh) {
624 snprintf(dest, size,
625 "Check A result=%d\n"
626 "Check B result=%d\n"
627 "Firmware index booted=0x%02x\n"
628 "TPM combined version at start=0x%08x\n"
629 "Lowest combined version from firmware=0x%08x\n",
630 sh->check_fw_a_result,
631 sh->check_fw_b_result,
632 sh->firmware_index,
633 sh->fw_version_tpm_start,
634 sh->fw_version_lowest);
635 return dest;
636 }
637
638
639 #define TRUNCATED "\n(truncated)\n"
640
641 char* GetVdatLoadKernelDebug(char* dest, int size,
642 const VbSharedDataHeader* sh) {
643 int used = 0;
644 int first_call_tracked = 0;
645 int call;
646
647 /* Make sure we have space for truncation warning */
648 if (size < strlen(TRUNCATED) + 1)
649 return NULL;
650 size -= strlen(TRUNCATED) + 1;
651
652 used += snprintf(
653 dest + used, size - used,
654 "Calls to LoadKernel()=%d\n",
655 sh->lk_call_count);
656 if (used > size)
657 goto LoadKernelDebugExit;
658
659 /* Report on the last calls */
660 if (sh->lk_call_count > VBSD_MAX_KERNEL_CALLS)
661 first_call_tracked = sh->lk_call_count - VBSD_MAX_KERNEL_CALLS;
662 for (call = first_call_tracked; call < sh->lk_call_count; call++) {
663 const VbSharedDataKernelCall* shc =
664 sh->lk_calls + (call & (VBSD_MAX_KERNEL_CALLS - 1));
665 int first_part_tracked = 0;
666 int part;
667
668 used += snprintf(
669 dest + used, size - used,
670 "Call %d:\n"
671 " Boot flags=0x%02x\n"
672 " Boot mode=%d\n"
673 " Test error=%d\n"
674 " Return code=%d\n"
675 " Debug flags=0x%02x\n"
676 " Drive sectors=%" PRIu64 "\n"
677 " Sector size=%d\n"
678 " Check result=%d\n"
679 " Kernel partitions found=%d\n",
680 call + 1,
681 shc->boot_flags,
682 shc->boot_mode,
683 shc->test_error_num,
684 shc->return_code,
685 shc->flags,
686 shc->sector_count,
687 shc->sector_size,
688 shc->check_result,
689 shc->kernel_parts_found);
690 if (used > size)
691 goto LoadKernelDebugExit;
692
693 /* If we found too many partitions, only prints ones where the
694 * structure has info. */
695 if (shc->kernel_parts_found > VBSD_MAX_KERNEL_PARTS)
696 first_part_tracked = shc->kernel_parts_found - VBSD_MAX_KERNEL_PARTS;
697
698 /* Report on the partitions checked */
699 for (part = first_part_tracked; part < shc->kernel_parts_found; part++) {
700 const VbSharedDataKernelPart* shp =
701 shc->parts + (part & (VBSD_MAX_KERNEL_PARTS - 1));
702
703 used += snprintf(
704 dest + used, size - used,
705 " Kernel %d:\n"
706 " GPT index=%d\n"
707 " Start sector=%" PRIu64 "\n"
708 " Sector count=%" PRIu64 "\n"
709 " Combined version=0x%08x\n"
710 " Check result=%d\n"
711 " Debug flags=0x%02x\n",
712 part + 1,
713 shp->gpt_index,
714 shp->sector_start,
715 shp->sector_count,
716 shp->combined_version,
717 shp->check_result,
718 shp->flags);
719 if (used > size)
720 goto LoadKernelDebugExit;
721 }
722 }
723
724 LoadKernelDebugExit:
725
726 /* Warn if data was truncated; we left space for this above. */
727 if (used > size)
728 strcat(dest, TRUNCATED);
729
730 return dest;
731 }
732
733
734 char* GetVdatString(char* dest, int size, VdatStringField field)
735 {
736 VbSharedDataHeader* sh;
737 AcpiBuffer* ab = VbGetBuffer(ACPI_VDAT_PATH);
738 char* value = dest;
739 if (!ab)
740 return NULL;
741
742 sh = (VbSharedDataHeader*)ab->buffer;
743
744 switch (field) {
745 case VDAT_STRING_TIMERS:
746 snprintf(dest, size,
747 "LFS=%" PRIu64 ",%" PRIu64
748 " LF=%" PRIu64 ",%" PRIu64
749 " LK=%" PRIu64 ",%" PRIu64,
750 sh->timer_load_firmware_start_enter,
751 sh->timer_load_firmware_start_exit,
752 sh->timer_load_firmware_enter,
753 sh->timer_load_firmware_exit,
754 sh->timer_load_kernel_enter,
755 sh->timer_load_kernel_exit);
756 break;
757
758 case VDAT_STRING_LOAD_FIRMWARE_DEBUG:
759 value = GetVdatLoadFirmwareDebug(dest, size, sh);
760 break;
761
762 case VDAT_STRING_LOAD_KERNEL_DEBUG:
763 value = GetVdatLoadKernelDebug(dest, size, sh);
764 break;
765
766 default:
767 Free(ab);
768 return NULL;
769 }
770
771 Free(ab);
772 return value;
773 }
774
775
776 int GetVdatInt(VdatIntField field) {
777 VbSharedDataHeader* sh;
778 AcpiBuffer* ab = VbGetBuffer(ACPI_VDAT_PATH);
779 int value = -1;
780
781 if (!ab)
782 return -1;
783
784 sh = (VbSharedDataHeader*)ab->buffer;
785
786 switch (field) {
787 case VDAT_INT_FLAGS:
788 value = (int)sh->flags;
789 break;
790 case VDAT_INT_FW_VERSION_TPM:
791 value = (int)sh->fw_version_tpm;
792 break;
793 case VDAT_INT_KERNEL_VERSION_TPM:
794 value = (int)sh->kernel_version_tpm;
795 break;
796 case VDAT_INT_TRIED_FIRMWARE_B:
797 value = (sh->flags & VBSD_FWB_TRIED ? 1 : 0);
798 break;
799 case VDAT_INT_KERNEL_KEY_VERIFIED:
800 value = (sh->flags & VBSD_KERNEL_KEY_VERIFIED ? 1 : 0);
801 break;
802 }
803
804 Free(ab);
805 return value;
806 }
807
808
500 /* Read a system property integer. 809 /* Read a system property integer.
501 * 810 *
502 * Returns the property value, or -1 if error. */ 811 * Returns the property value, or -1 if error. */
503 int VbGetSystemPropertyInt(const char* name) { 812 int VbGetSystemPropertyInt(const char* name) {
504 int value = -1; 813 int value = -1;
505 814
506 /* Switch positions */ 815 /* Switch positions */
507 if (!strcasecmp(name,"devsw_cur")) { 816 if (!strcasecmp(name,"devsw_cur")) {
508 value = ReadGpio(GPIO_SIGNAL_TYPE_DEV); 817 value = ReadGpio(GPIO_SIGNAL_TYPE_DEV);
509 } else if (!strcasecmp(name,"devsw_boot")) { 818 } else if (!strcasecmp(name,"devsw_boot")) {
(...skipping 14 matching lines...) Expand all
524 value = 1 - value; /* Mario reports this backwards */ 833 value = 1 - value; /* Mario reports this backwards */
525 } 834 }
526 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW 835 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW
527 * path exists in sysfs, it's a H2C BIOS. */ 836 * path exists in sysfs, it's a H2C BIOS. */
528 else if (!strcasecmp(name,"savedmem_base")) { 837 else if (!strcasecmp(name,"savedmem_base")) {
529 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000); 838 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000);
530 } else if (!strcasecmp(name,"savedmem_size")) { 839 } else if (!strcasecmp(name,"savedmem_size")) {
531 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000); 840 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000);
532 } 841 }
533 /* NV storage values with no defaults for older BIOS. */ 842 /* NV storage values with no defaults for older BIOS. */
534 else if (!strcasecmp(name,"tried_fwb")) { 843 else if (!strcasecmp(name,"kern_nv")) {
535 value = VbGetNvStorage(VBNV_TRIED_FIRMWARE_B);
536 } else if (!strcasecmp(name,"kern_nv")) {
537 value = VbGetNvStorage(VBNV_KERNEL_FIELD); 844 value = VbGetNvStorage(VBNV_KERNEL_FIELD);
538 } else if (!strcasecmp(name,"nvram_cleared")) { 845 } else if (!strcasecmp(name,"nvram_cleared")) {
539 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET); 846 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET);
847 } else if (!strcasecmp(name,"vbtest_errfunc")) {
848 value = VbGetNvStorage(VBNV_TEST_ERROR_FUNC);
849 } else if (!strcasecmp(name,"vbtest_errno")) {
850 value = VbGetNvStorage(VBNV_TEST_ERROR_NUM);
540 } 851 }
541 /* NV storage values. If unable to get from NV storage, fall back to the 852 /* NV storage values. If unable to get from NV storage, fall back to the
542 * CMOS reboot field used by older BIOS. */ 853 * CMOS reboot field used by older BIOS. */
543 else if (!strcasecmp(name,"recovery_request")) { 854 else if (!strcasecmp(name,"recovery_request")) {
544 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); 855 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST);
545 if (-1 == value) 856 if (-1 == value)
546 value = VbGetCmosRebootField(CMOSRF_RECOVERY); 857 value = VbGetCmosRebootField(CMOSRF_RECOVERY);
547 } else if (!strcasecmp(name,"dbg_reset")) { 858 } else if (!strcasecmp(name,"dbg_reset")) {
548 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE); 859 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE);
549 if (-1 == value) 860 if (-1 == value)
550 value = VbGetCmosRebootField(CMOSRF_DEBUG_RESET); 861 value = VbGetCmosRebootField(CMOSRF_DEBUG_RESET);
551 } else if (!strcasecmp(name,"fwb_tries")) { 862 } else if (!strcasecmp(name,"fwb_tries")) {
552 value = VbGetNvStorage(VBNV_TRY_B_COUNT); 863 value = VbGetNvStorage(VBNV_TRY_B_COUNT);
553 if (-1 == value) 864 if (-1 == value)
554 value = VbGetCmosRebootField(CMOSRF_TRY_B); 865 value = VbGetCmosRebootField(CMOSRF_TRY_B);
555 } 866 }
556 /* Other parameters */ 867 /* Other parameters */
557 else if (!strcasecmp(name,"recovery_reason")) { 868 else if (!strcasecmp(name,"recovery_reason")) {
558 return VbGetRecoveryReason(); 869 return VbGetRecoveryReason();
559 } else if (!strcasecmp(name,"fmap_base")) { 870 } else if (!strcasecmp(name,"fmap_base")) {
560 value = ReadFileInt(ACPI_FMAP_PATH); 871 value = ReadFileInt(ACPI_FMAP_PATH);
561 } else if (!strcasecmp(name,"cros_debug")) { 872 } else if (!strcasecmp(name,"cros_debug")) {
562 value = VbGetCrosDebug(); 873 value = VbGetCrosDebug();
874 } else if (!strcasecmp(name,"vdat_flags")) {
875 value = GetVdatInt(VDAT_INT_FLAGS);
876 } else if (!strcasecmp(name,"tpm_fwver")) {
877 value = GetVdatInt(VDAT_INT_FW_VERSION_TPM);
878 } else if (!strcasecmp(name,"tpm_kernver")) {
879 value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM);
880 } else if (!strcasecmp(name,"tried_fwb")) {
881 value = GetVdatInt(VDAT_INT_TRIED_FIRMWARE_B);
563 } 882 }
564 883
565 return value; 884 return value;
566 } 885 }
567 886
568
569 /* Read a system property string into a destination buffer of the specified 887 /* Read a system property string into a destination buffer of the specified
570 * size. 888 * size.
571 * 889 *
572 * Returns the passed buffer, or NULL if error. */ 890 * Returns the passed buffer, or NULL if error. */
573 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { 891 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) {
574 892
575 if (!strcasecmp(name,"hwid")) { 893 if (!strcasecmp(name,"hwid")) {
576 return ReadFileString(dest, size, ACPI_BASE_PATH "/HWID"); 894 return ReadFileString(dest, size, ACPI_BASE_PATH "/HWID");
577 } else if (!strcasecmp(name,"fwid")) { 895 } else if (!strcasecmp(name,"fwid")) {
578 return ReadFileString(dest, size, ACPI_BASE_PATH "/FWID"); 896 return ReadFileString(dest, size, ACPI_BASE_PATH "/FWID");
(...skipping 15 matching lines...) Expand all
594 } else if (!strcasecmp(name,"ecfw_act")) { 912 } else if (!strcasecmp(name,"ecfw_act")) {
595 switch(ReadFileInt(ACPI_BINF_PATH ".2")) { 913 switch(ReadFileInt(ACPI_BINF_PATH ".2")) {
596 case 0: 914 case 0:
597 return StrCopy(dest, "RO", size); 915 return StrCopy(dest, "RO", size);
598 case 1: 916 case 1:
599 return StrCopy(dest, "RW", size); 917 return StrCopy(dest, "RW", size);
600 default: 918 default:
601 return NULL; 919 return NULL;
602 } 920 }
603 } else if (!strcasecmp(name,"kernkey_vfy")) { 921 } else if (!strcasecmp(name,"kernkey_vfy")) {
604 switch(VbGetNvStorage(VBNV_FW_VERIFIED_KERNEL_KEY)) { 922 switch(GetVdatInt(VDAT_INT_KERNEL_KEY_VERIFIED)) {
605 case 0: 923 case 0:
606 return "hash"; 924 return "hash";
607 case 1: 925 case 1:
608 return "sig"; 926 return "sig";
609 default: 927 default:
610 return NULL; 928 return NULL;
611 } 929 }
930 } else if (!strcasecmp(name, "vdat_timers")) {
931 return GetVdatString(dest, size, VDAT_STRING_TIMERS);
932 } else if (!strcasecmp(name, "vdat_lfdebug")) {
933 return GetVdatString(dest, size, VDAT_STRING_LOAD_FIRMWARE_DEBUG);
934 } else if (!strcasecmp(name, "vdat_lkdebug")) {
935 return GetVdatString(dest, size, VDAT_STRING_LOAD_KERNEL_DEBUG);
612 } else 936 } else
613 return NULL; 937 return NULL;
614 } 938 }
615 939
616 940
617 /* Set a system property integer. 941 /* Set a system property integer.
618 * 942 *
619 * Returns 0 if success, -1 if error. */ 943 * Returns 0 if success, -1 if error. */
620 int VbSetSystemPropertyInt(const char* name, int value) { 944 int VbSetSystemPropertyInt(const char* name, int value) {
621 945
622 /* NV storage values with no defaults for older BIOS. */ 946 /* NV storage values with no defaults for older BIOS. */
623 if (!strcasecmp(name,"nvram_cleared")) { 947 if (!strcasecmp(name,"nvram_cleared")) {
624 /* Can only clear this flag; it's set inside the NV storage library. */ 948 /* Can only clear this flag; it's set inside the NV storage library. */
625 return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0); 949 return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0);
626 } else if (!strcasecmp(name,"kern_nv")) { 950 } else if (!strcasecmp(name,"kern_nv")) {
627 return VbSetNvStorage(VBNV_KERNEL_FIELD, value); 951 return VbSetNvStorage(VBNV_KERNEL_FIELD, value);
952 } else if (!strcasecmp(name,"vbtest_errfunc")) {
953 return VbSetNvStorage(VBNV_TEST_ERROR_FUNC, value);
954 } else if (!strcasecmp(name,"vbtest_errno")) {
955 return VbSetNvStorage(VBNV_TEST_ERROR_NUM, value);
628 } 956 }
629 /* NV storage values. If unable to get from NV storage, fall back to the 957 /* NV storage values. If unable to get from NV storage, fall back to the
630 * CMOS reboot field used by older BIOS. */ 958 * CMOS reboot field used by older BIOS. */
631 else if (!strcasecmp(name,"recovery_request")) { 959 else if (!strcasecmp(name,"recovery_request")) {
632 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value)) 960 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value))
633 return 0; 961 return 0;
634 return VbSetCmosRebootField(CMOSRF_RECOVERY, value); 962 return VbSetCmosRebootField(CMOSRF_RECOVERY, value);
635 } else if (!strcasecmp(name,"dbg_reset")) { 963 } else if (!strcasecmp(name,"dbg_reset")) {
636 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value)) 964 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value))
637 return 0; 965 return 0;
638 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value); 966 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value);
639 } else if (!strcasecmp(name,"fwb_tries")) { 967 } else if (!strcasecmp(name,"fwb_tries")) {
640 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value)) 968 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value))
641 return 0; 969 return 0;
642 return VbSetCmosRebootField(CMOSRF_TRY_B, value); 970 return VbSetCmosRebootField(CMOSRF_TRY_B, value);
643 } 971 }
644 972
645 return -1; 973 return -1;
646 } 974 }
647 975
648 976
649 /* Set a system property string. 977 /* Set a system property string.
650 * 978 *
651 * Returns 0 if success, -1 if error. */ 979 * Returns 0 if success, -1 if error. */
652 int VbSetSystemPropertyString(const char* name, const char* value) { 980 int VbSetSystemPropertyString(const char* name, const char* value) {
653 981
654 /* TODO: support setting */ 982 /* TODO: support setting */
655 return -1; 983 return -1;
656 } 984 }
OLDNEW
« no previous file with comments | « firmware/stub/utility_stub.c ('k') | tests/tpm_lite/timing.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698