Files
OpenCellular/include/util.h
Duncan Laurie 32012be3c0 Export more battery information in LPC map
This data is used to populate the _BIF/_BIX packages in ACPI
but it currently needs an EC command to retrieve that isn't
easy to query in ACPI since it isn't using standard EC RAM.

1) Export these additional fields in init() state:
- Design Capacity of Full
- Design Voltage
- Last Full Charge Capacity
- Cycle Count
- Manufacturer String
- Model String
- Serial Number String

2) Fix an issue where battery current was not reported when
the battery was charging.

3) Remove the command interface so there is no duplication.

BUG=chrome-os-partner:7734
TEST=using (not yet published) coreboot to read battery status
via ACPI and verify that battery removal/insertion events
are properly handled.

Change-Id: If337aad3255e5b1a0f85168838f1dd86a32bbeb3
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
2012-04-06 14:49:30 -07:00

67 lines
1.6 KiB
C

/* Copyright (c) 2011 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.
*/
/* Various utility functions and macros */
#ifndef __UTIL_H
#define __UTIL_H
#include <stdint.h>
#include "config.h"
/**
* Trigger a compilation failure if the condition
* is not verified at build time.
*/
#define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2*!(cond)]))
/**
* Trigger a debug exception if the condition
* is not verified at runtime.
*/
#ifdef CONFIG_DEBUG
#define ASSERT(cond) do { \
if (!(cond)) \
__asm("bkpt"); \
} while (0);
#else
#define ASSERT(cond)
#endif
/* Standard macros / definitions */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define NULL ((void *)0)
/**
* macros for integer division with various rounding variants
* default integer division rounds down.
*/
#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y))
#define DIV_ROUND_NEAREST(x, y) (((x) + ((y) / 2)) / (y))
static inline uint8_t hex2asc(uint8_t hex)
{
return hex + ((hex > 9) ? 'A' : '0');
}
/* Standard library functions */
int atoi(const char *nptr);
int isdigit(int c);
int isspace(int c);
int isalpha(int c);
void *memcpy(void *dest, const void *src, int len);
void *memset(void *dest, int c, int len);
int strcasecmp(const char *s1, const char *s2);
int strlen(const char *s);
int strtoi(const char *nptr, char **endptr, int base);
char *strzcpy(char *dest, const char *src, int len);
int tolower(int c);
#endif /* __UTIL_H */