Adding upstream version 3.86+dfsg.
[syslinux-debian/hramrach.git] / com32 / gpllib / dmi / dmi_battery.c
blobb0eab9bbf729395029f0896cf79dfe8ae0f48e09
1 /* ----------------------------------------------------------------------- *
3 * Pportions of this file taken from the dmidecode project
5 * Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
6 * Copyright (C) 2002-2008 Jean Delvare <khali@linux-fr.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * For the avoidance of doubt the "preferred form" of this code is one which
23 * is in an open unpatent encumbered format. Where cryptographic key signing
24 * forms part of the process of creating an executable the information
25 * including keys needed to generate an equivalently functional executable
26 * are deemed to be part of the source code.
29 #include <dmi/dmi.h>
30 #include <stdio.h>
31 const char *dmi_battery_chemistry(uint8_t code)
33 /* 3.3.23.1 */
34 static const char *chemistry[] = {
35 "Other", /* 0x01 */
36 "Unknown",
37 "Lead Acid",
38 "Nickel Cadmium",
39 "Nickel Metal Hydride",
40 "Lithium Ion",
41 "Zinc Air",
42 "Lithium Polymer" /* 0x08 */
45 if (code >= 0x01 && code <= 0x08)
46 return chemistry[code - 0x01];
47 return out_of_spec;
50 void dmi_battery_capacity(uint16_t code, uint8_t multiplier, char *capacity)
52 if (code == 0)
53 sprintf(capacity, "%s", "Unknown");
54 else
55 sprintf(capacity, "%u mWh", code * multiplier);
58 void dmi_battery_voltage(uint16_t code, char *voltage)
60 if (code == 0)
61 sprintf(voltage, "%s", "Unknown");
62 else
63 sprintf(voltage, "%u mV", code);
66 void dmi_battery_maximum_error(uint8_t code, char *error)
68 if (code == 0xFF)
69 sprintf(error, "%s", "Unknown");
70 else
71 sprintf(error, "%u%%", code);