mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 10:45:02 +00:00
Currently ReadFileInt assumes that an integer value read from a file is never going to be "-1" and uses that value to indicate failure. In particular for GPIO values that may be returned by the kernel it is possible for them to be not simply 0 or 1 but instead a bit within the GPIO status register that indicates the value. The function semantics are changed to have the caller pass in the variable to store the integer in, and use the return code explicitly as a pass or fail condition. This requires all the callers of ReadFileInt to be changed to use the new scheme, and the x86 ReadGpio function is changed to normalize the GPIO value that is read from the kernel instead of assuming it is always 1 for active high values. BUG=chrome-os-partner:32645 BRANCH=samus,auron TEST=build for samus, check crossystem output and ensure that all values are properly reported and that wpsw_cur is correct now. Also tested to ensure no changes in output on: x86-alex, daisy, peach_pit, lumpy, stumpy, nyan_big, nyan_blaze, rush_ryu, panther, wolf, zako, auron, rambi, squawks, parrot_ivb, veyron_pinky Change-Id: I824152eed5f96cf1faaa18ba31a01f4d346ad172 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223009 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
47 lines
1.5 KiB
C
47 lines
1.5 KiB
C
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*
|
|
* Host-side misc functions for verified boot.
|
|
*/
|
|
|
|
#ifndef VBOOT_REFERENCE_HOST_MISC_H_
|
|
#define VBOOT_REFERENCE_HOST_MISC_H_
|
|
|
|
#include "utility.h"
|
|
#include "vboot_struct.h"
|
|
|
|
/* Copy up to dest_size-1 characters from src to dest, ensuring null
|
|
termination (which strncpy() doesn't do). Returns the destination
|
|
string. */
|
|
char* StrCopy(char* dest, const char* src, int dest_size);
|
|
|
|
/* Read data from [filename]. Store the size of returned data in [size].
|
|
*
|
|
* Returns the data buffer, which the caller must Free(), or NULL if
|
|
* error. */
|
|
uint8_t* ReadFile(const char* filename, uint64_t* size);
|
|
|
|
/* Read a string from a file. Passed the destination, dest size, and
|
|
* filename to read.
|
|
*
|
|
* Returns the destination, or NULL if error. */
|
|
char* ReadFileString(char* dest, int size, const char* filename);
|
|
|
|
/* Read an unsigned integer from a file and save into passed pointer.
|
|
*
|
|
* Returns 0 if success, -1 if error. */
|
|
int ReadFileInt(const char* filename, unsigned* value);
|
|
|
|
/* Check if a bit is set in a file which contains an integer.
|
|
*
|
|
* Returns 1 if the bit is set, 0 if clear, or -1 if error. */
|
|
int ReadFileBit(const char* filename, int bitmask);
|
|
|
|
/* Writes [size] bytes of [data] to [filename].
|
|
*
|
|
* Returns 0 if success, 1 if error. */
|
|
int WriteFile(const char* filename, const void *data, uint64_t size);
|
|
|
|
#endif /* VBOOT_REFERENCE_HOST_MISC_H_ */
|