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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW | 480 /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW |
481 * path exists in sysfs, it's a H2C BIOS. */ | 481 * path exists in sysfs, it's a H2C BIOS. */ |
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")) { |
| 491 value = VbGetNvStorage(VBNV_KERNEL_FIELD); |
490 } | 492 } |
491 /* NV storage values. If unable to get from NV storage, fall back to the | 493 /* NV storage values. If unable to get from NV storage, fall back to the |
492 * CMOS reboot field used by older BIOS. */ | 494 * CMOS reboot field used by older BIOS. */ |
493 else if (!strcasecmp(name,"recovery_request")) { | 495 else if (!strcasecmp(name,"recovery_request")) { |
494 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); | 496 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); |
495 if (-1 == value) | 497 if (-1 == value) |
496 value = VbGetCmosRebootField(CMOSRF_RECOVERY); | 498 value = VbGetCmosRebootField(CMOSRF_RECOVERY); |
497 } else if (!strcasecmp(name,"dbg_reset")) { | 499 } else if (!strcasecmp(name,"dbg_reset")) { |
498 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE); | 500 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE); |
499 if (-1 == value) | 501 if (-1 == value) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } else | 566 } else |
565 return NULL; | 567 return NULL; |
566 } | 568 } |
567 | 569 |
568 | 570 |
569 /* Set a system property integer. | 571 /* Set a system property integer. |
570 * | 572 * |
571 * Returns 0 if success, -1 if error. */ | 573 * Returns 0 if success, -1 if error. */ |
572 int VbSetSystemPropertyInt(const char* name, int value) { | 574 int VbSetSystemPropertyInt(const char* name, int value) { |
573 | 575 |
| 576 /* NV storage values with no defaults for older BIOS. */ |
| 577 if (!strcasecmp(name,"kern_nv")) { |
| 578 return VbSetNvStorage(VBNV_KERNEL_FIELD, value); |
| 579 } |
574 /* NV storage values. If unable to get from NV storage, fall back to the | 580 /* NV storage values. If unable to get from NV storage, fall back to the |
575 * CMOS reboot field used by older BIOS. */ | 581 * CMOS reboot field used by older BIOS. */ |
576 if (!strcasecmp(name,"recovery_request")) { | 582 else if (!strcasecmp(name,"recovery_request")) { |
577 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value)) | 583 if (0 == VbSetNvStorage(VBNV_RECOVERY_REQUEST, value)) |
578 return 0; | 584 return 0; |
579 return VbSetCmosRebootField(CMOSRF_RECOVERY, value); | 585 return VbSetCmosRebootField(CMOSRF_RECOVERY, value); |
580 } else if (!strcasecmp(name,"dbg_reset")) { | 586 } else if (!strcasecmp(name,"dbg_reset")) { |
581 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value)) | 587 if (0 == VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value)) |
582 return 0; | 588 return 0; |
583 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value); | 589 return VbSetCmosRebootField(CMOSRF_DEBUG_RESET, value); |
584 } else if (!strcasecmp(name,"fwb_tries")) { | 590 } else if (!strcasecmp(name,"fwb_tries")) { |
585 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value)) | 591 if (0 == VbSetNvStorage(VBNV_TRY_B_COUNT, value)) |
586 return 0; | 592 return 0; |
587 return VbSetCmosRebootField(CMOSRF_TRY_B, value); | 593 return VbSetCmosRebootField(CMOSRF_TRY_B, value); |
588 } | 594 } |
589 | 595 |
590 /* TODO: implement the following: | 596 /* TODO: implement the following: |
591 * nvram_cleared | 597 * nvram_cleared |
592 */ | 598 */ |
593 | 599 |
594 return -1; | 600 return -1; |
595 } | 601 } |
596 | 602 |
597 | 603 |
598 /* Set a system property string. | 604 /* Set a system property string. |
599 * | 605 * |
600 * Returns 0 if success, -1 if error. */ | 606 * Returns 0 if success, -1 if error. */ |
601 int VbSetSystemPropertyString(const char* name, const char* value) { | 607 int VbSetSystemPropertyString(const char* name, const char* value) { |
602 | 608 |
603 /* TODO: support setting */ | 609 /* TODO: support setting */ |
604 return -1; | 610 return -1; |
605 } | 611 } |
OLD | NEW |