| OLD | NEW | 
|    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  Loading... | 
|   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 */ | 
 |  106   VDAT_INT_KERNEL_VERSION_TPM      /* Current kernel version in TPM */ | 
|  105 } VdatIntField; |  107 } VdatIntField; | 
|  106  |  108  | 
|  107  |  109  | 
|  108 /* Copy up to dest_size-1 characters from src to dest, ensuring null |  110 /* Copy up to dest_size-1 characters from src to dest, ensuring null | 
|  109    termination (which strncpy() doesn't do).  Returns the destination |  111    termination (which strncpy() doesn't do).  Returns the destination | 
|  110    string. */ |  112    string. */ | 
|  111 char* StrCopy(char* dest, const char* src, int dest_size) { |  113 char* StrCopy(char* dest, const char* src, int dest_size) { | 
|  112   strncpy(dest, src, dest_size); |  114   strncpy(dest, src, dest_size); | 
|  113   dest[dest_size - 1] = '\0'; |  115   dest[dest_size - 1] = '\0'; | 
|  114   return dest; |  116   return dest; | 
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  663  |  665  | 
|  664   if (!ab) |  666   if (!ab) | 
|  665     return -1; |  667     return -1; | 
|  666  |  668  | 
|  667   sh = (VbSharedDataHeader*)ab->buffer; |  669   sh = (VbSharedDataHeader*)ab->buffer; | 
|  668  |  670  | 
|  669   switch (field) { |  671   switch (field) { | 
|  670     case VDAT_INT_FLAGS: |  672     case VDAT_INT_FLAGS: | 
|  671       value = (int)sh->flags; |  673       value = (int)sh->flags; | 
|  672       break; |  674       break; | 
|  673  |  675     case VDAT_INT_FW_VERSION_TPM: | 
 |  676       value = (int)sh->fw_version_tpm; | 
 |  677       break; | 
 |  678     case VDAT_INT_KERNEL_VERSION_TPM: | 
 |  679       value = (int)sh->kernel_version_tpm; | 
 |  680       break; | 
|  674   } |  681   } | 
|  675  |  682  | 
|  676   Free(ab); |  683   Free(ab); | 
|  677   return value; |  684   return value; | 
|  678 } |  685 } | 
|  679  |  686  | 
|  680  |  687  | 
|  681 /* Read a system property integer. |  688 /* Read a system property integer. | 
|  682  * |  689  * | 
|  683  * Returns the property value, or -1 if error. */ |  690  * Returns the property value, or -1 if error. */ | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  740   } |  747   } | 
|  741   /* Other parameters */ |  748   /* Other parameters */ | 
|  742   else if (!strcasecmp(name,"recovery_reason")) { |  749   else if (!strcasecmp(name,"recovery_reason")) { | 
|  743     return VbGetRecoveryReason(); |  750     return VbGetRecoveryReason(); | 
|  744   } else if (!strcasecmp(name,"fmap_base")) { |  751   } else if (!strcasecmp(name,"fmap_base")) { | 
|  745     value = ReadFileInt(ACPI_FMAP_PATH); |  752     value = ReadFileInt(ACPI_FMAP_PATH); | 
|  746   } else if (!strcasecmp(name,"cros_debug")) { |  753   } else if (!strcasecmp(name,"cros_debug")) { | 
|  747     value = VbGetCrosDebug(); |  754     value = VbGetCrosDebug(); | 
|  748   } else if (!strcasecmp(name,"vdat_flags")) { |  755   } else if (!strcasecmp(name,"vdat_flags")) { | 
|  749     value = GetVdatInt(VDAT_INT_FLAGS); |  756     value = GetVdatInt(VDAT_INT_FLAGS); | 
 |  757   } else if (!strcasecmp(name,"tpm_fwver")) { | 
 |  758     value = GetVdatInt(VDAT_INT_FW_VERSION_TPM); | 
 |  759   } else if (!strcasecmp(name,"tpm_kernver")) { | 
 |  760     value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM); | 
|  750   } |  761   } | 
|  751  |  762  | 
|  752   return value; |  763   return value; | 
|  753 } |  764 } | 
|  754  |  765  | 
|  755 /* Read a system property string into a destination buffer of the specified |  766 /* Read a system property string into a destination buffer of the specified | 
|  756  * size. |  767  * size. | 
|  757  * |  768  * | 
|  758  * Returns the passed buffer, or NULL if error. */ |  769  * Returns the passed buffer, or NULL if error. */ | 
|  759 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { |  770 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  841  |  852  | 
|  842  |  853  | 
|  843 /* Set a system property string. |  854 /* Set a system property string. | 
|  844  * |  855  * | 
|  845  * Returns 0 if success, -1 if error. */ |  856  * Returns 0 if success, -1 if error. */ | 
|  846 int VbSetSystemPropertyString(const char* name, const char* value) { |  857 int VbSetSystemPropertyString(const char* name, const char* value) { | 
|  847  |  858  | 
|  848   /* TODO: support setting */ |  859   /* TODO: support setting */ | 
|  849   return -1; |  860   return -1; | 
|  850 } |  861 } | 
| OLD | NEW |