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 | 8 |
9 #include "host_common.h" | 9 #include "host_common.h" |
10 | 10 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 else if (!strcasecmp(name,"savedmem_base")) { | 482 else if (!strcasecmp(name,"savedmem_base")) { |
483 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000); | 483 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000); |
484 } else if (!strcasecmp(name,"savedmem_size")) { | 484 } else if (!strcasecmp(name,"savedmem_size")) { |
485 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000); | 485 return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000); |
486 } | 486 } |
487 /* NV storage values with no defaults for older BIOS. */ | 487 /* NV storage values with no defaults for older BIOS. */ |
488 else if (!strcasecmp(name,"tried_fwb")) { | 488 else if (!strcasecmp(name,"tried_fwb")) { |
489 value = VbGetNvStorage(VBNV_TRIED_FIRMWARE_B); | 489 value = VbGetNvStorage(VBNV_TRIED_FIRMWARE_B); |
490 } else if (!strcasecmp(name,"kern_nv")) { | 490 } else if (!strcasecmp(name,"kern_nv")) { |
491 value = VbGetNvStorage(VBNV_KERNEL_FIELD); | 491 value = VbGetNvStorage(VBNV_KERNEL_FIELD); |
| 492 } else if (!strcasecmp(name,"nvram_cleared")) { |
| 493 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET); |
492 } | 494 } |
493 /* NV storage values. If unable to get from NV storage, fall back to the | 495 /* NV storage values. If unable to get from NV storage, fall back to the |
494 * CMOS reboot field used by older BIOS. */ | 496 * CMOS reboot field used by older BIOS. */ |
495 else if (!strcasecmp(name,"recovery_request")) { | 497 else if (!strcasecmp(name,"recovery_request")) { |
496 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); | 498 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); |
497 if (-1 == value) | 499 if (-1 == value) |
498 value = VbGetCmosRebootField(CMOSRF_RECOVERY); | 500 value = VbGetCmosRebootField(CMOSRF_RECOVERY); |
499 } else if (!strcasecmp(name,"dbg_reset")) { | 501 } else if (!strcasecmp(name,"dbg_reset")) { |
500 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE); | 502 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE); |
501 if (-1 == value) | 503 if (-1 == value) |
502 value = VbGetCmosRebootField(CMOSRF_DEBUG_RESET); | 504 value = VbGetCmosRebootField(CMOSRF_DEBUG_RESET); |
503 } else if (!strcasecmp(name,"fwb_tries")) { | 505 } else if (!strcasecmp(name,"fwb_tries")) { |
504 value = VbGetNvStorage(VBNV_TRY_B_COUNT); | 506 value = VbGetNvStorage(VBNV_TRY_B_COUNT); |
505 if (-1 == value) | 507 if (-1 == value) |
506 value = VbGetCmosRebootField(CMOSRF_TRY_B); | 508 value = VbGetCmosRebootField(CMOSRF_TRY_B); |
507 } | 509 } |
508 /* Other parameters */ | 510 /* Other parameters */ |
509 else if (!strcasecmp(name,"recovery_reason")) { | 511 else if (!strcasecmp(name,"recovery_reason")) { |
510 return VbGetRecoveryReason(); | 512 return VbGetRecoveryReason(); |
511 } else if (!strcasecmp(name,"fmap_base")) { | 513 } else if (!strcasecmp(name,"fmap_base")) { |
512 value = ReadFileInt(ACPI_FMAP_PATH); | 514 value = ReadFileInt(ACPI_FMAP_PATH); |
513 } | 515 } |
514 | 516 |
515 /* TODO: implement the following properties: | |
516 * nvram_cleared | |
517 */ | |
518 | |
519 return value; | 517 return value; |
520 } | 518 } |
521 | 519 |
522 | 520 |
523 /* Read a system property string into a destination buffer of the specified | 521 /* Read a system property string into a destination buffer of the specified |
524 * size. | 522 * size. |
525 * | 523 * |
526 * Returns the passed buffer, or NULL if error. */ | 524 * Returns the passed buffer, or NULL if error. */ |
527 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { | 525 const char* VbGetSystemPropertyString(const char* name, char* dest, int size) { |
528 | 526 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 return NULL; | 565 return NULL; |
568 } | 566 } |
569 | 567 |
570 | 568 |
571 /* Set a system property integer. | 569 /* Set a system property integer. |
572 * | 570 * |
573 * Returns 0 if success, -1 if error. */ | 571 * Returns 0 if success, -1 if error. */ |
574 int VbSetSystemPropertyInt(const char* name, int value) { | 572 int VbSetSystemPropertyInt(const char* name, int value) { |
575 | 573 |
576 /* NV storage values with no defaults for older BIOS. */ | 574 /* NV storage values with no defaults for older BIOS. */ |
577 if (!strcasecmp(name,"kern_nv")) { | 575 if (!strcasecmp(name,"nvram_cleared")) { |
| 576 /* Can only clear this flag; it's set inside the NV storage library. */ |
| 577 return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0); |
| 578 } else if (!strcasecmp(name,"kern_nv")) { |
578 return VbSetNvStorage(VBNV_KERNEL_FIELD, value); | 579 return VbSetNvStorage(VBNV_KERNEL_FIELD, value); |
579 } | 580 } |
580 /* NV storage values. If unable to get from NV storage, fall back to the | 581 /* NV storage values. If unable to get from NV storage, fall back to the |
581 * CMOS reboot field used by older BIOS. */ | 582 * CMOS reboot field used by older BIOS. */ |
582 else if (!strcasecmp(name,"recovery_request")) { | 583 else if (!strcasecmp(name,"recovery_request")) { |
583 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value)) | 584 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value)) |
584 return 0; | 585 return 0; |
585 return VbSetCmosRebootField(CMOSRF_RECOVERY, value); | 586 return VbSetCmosRebootField(CMOSRF_RECOVERY, value); |
586 } else if (!strcasecmp(name,"dbg_reset")) { | 587 } else if (!strcasecmp(name,"dbg_reset")) { |
587 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value)) | 588 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value)) |
588 return 0; | 589 return 0; |
589 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value); | 590 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value); |
590 } else if (!strcasecmp(name,"fwb_tries")) { | 591 } else if (!strcasecmp(name,"fwb_tries")) { |
591 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value)) | 592 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value)) |
592 return 0; | 593 return 0; |
593 return VbSetCmosRebootField(CMOSRF_TRY_B, value); | 594 return VbSetCmosRebootField(CMOSRF_TRY_B, value); |
594 } | 595 } |
595 | 596 |
596 /* TODO: implement the following: | |
597 * nvram_cleared | |
598 */ | |
599 | |
600 return -1; | 597 return -1; |
601 } | 598 } |
602 | 599 |
603 | 600 |
604 /* Set a system property string. | 601 /* Set a system property string. |
605 * | 602 * |
606 * Returns 0 if success, -1 if error. */ | 603 * Returns 0 if success, -1 if error. */ |
607 int VbSetSystemPropertyString(const char* name, const char* value) { | 604 int VbSetSystemPropertyString(const char* name, const char* value) { |
608 | 605 |
609 /* TODO: support setting */ | 606 /* TODO: support setting */ |
610 return -1; | 607 return -1; |
611 } | 608 } |
OLD | NEW |