acpi_machdep.c (128932) | acpi_machdep.c (128975) |
---|---|
1/*- 2 * Copyright (c) 2001 Mitsuru IWASAKI 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Mitsuru IWASAKI 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/i386/acpica/acpi_machdep.c 128932 2004-05-04 21:04:24Z jhb $"); | 28__FBSDID("$FreeBSD: head/sys/i386/acpica/acpi_machdep.c 128975 2004-05-05 19:51:15Z njl $"); |
29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/conf.h> 33#include <sys/fcntl.h> 34#include <sys/kernel.h> 35#include <sys/sysctl.h> 36#include <sys/uio.h> 37 38#include "acpi.h" | 29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/conf.h> 33#include <sys/fcntl.h> 34#include <sys/kernel.h> 35#include <sys/sysctl.h> 36#include <sys/uio.h> 37 38#include "acpi.h" |
39 | |
40#include <dev/acpica/acpivar.h> 41#include <dev/acpica/acpiio.h> 42 43static device_t acpi_dev; 44 45/* 46 * APM driver emulation 47 */ 48 | 39#include <dev/acpica/acpivar.h> 40#include <dev/acpica/acpiio.h> 41 42static device_t acpi_dev; 43 44/* 45 * APM driver emulation 46 */ 47 |
49#if __FreeBSD_version < 500000 50#include <sys/select.h> 51#else | |
52#include <sys/selinfo.h> | 48#include <sys/selinfo.h> |
53#endif | |
54 55#include <machine/apm_bios.h> 56#include <machine/pc/bios.h> 57 | 49 50#include <machine/apm_bios.h> 51#include <machine/pc/bios.h> 52 |
58#if __FreeBSD_version < 500000 59#include <i386/apm/apm.h> 60#else | |
61#include <i386/bios/apm.h> | 53#include <i386/bios/apm.h> |
62#endif | |
63 | 54 |
64u_int32_t acpi_reset_video = 1; | 55uint32_t acpi_reset_video = 1; |
65TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); 66 | 56TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); 57 |
58static int intr_model = ACPI_INTR_PIC; |
|
67static struct apm_softc apm_softc; 68 69static d_open_t apmopen; 70static d_close_t apmclose; 71static d_write_t apmwrite; 72static d_ioctl_t apmioctl; 73static d_poll_t apmpoll; 74 75static struct cdevsw apm_cdevsw = { 76 .d_version = D_VERSION, 77 .d_flags = D_NEEDGIANT, 78 .d_open = apmopen, 79 .d_close = apmclose, 80 .d_write = apmwrite, 81 .d_ioctl = apmioctl, 82 .d_poll = apmpoll, 83 .d_name = "apm", 84}; 85 | 59static struct apm_softc apm_softc; 60 61static d_open_t apmopen; 62static d_close_t apmclose; 63static d_write_t apmwrite; 64static d_ioctl_t apmioctl; 65static d_poll_t apmpoll; 66 67static struct cdevsw apm_cdevsw = { 68 .d_version = D_VERSION, 69 .d_flags = D_NEEDGIANT, 70 .d_open = apmopen, 71 .d_close = apmclose, 72 .d_write = apmwrite, 73 .d_ioctl = apmioctl, 74 .d_poll = apmpoll, 75 .d_name = "apm", 76}; 77 |
86static int intr_model = ACPI_INTR_PIC; 87 | |
88static int 89acpi_capm_convert_battstate(struct acpi_battinfo *battp) 90{ 91 int state; 92 93 state = 0xff; /* XXX unknown */ 94 95 if (battp->state & ACPI_BATT_STAT_DISCHARG) { --- 4 unchanged lines hidden (view full) --- 100 } 101 if (battp->state & ACPI_BATT_STAT_CRITICAL) 102 state = 2; /* critical */ 103 if (battp->state & ACPI_BATT_STAT_CHARGING) 104 state = 3; /* charging */ 105 106 /* If still unknown, determine it based on the battery capacity. */ 107 if (state == 0xff) { | 78static int 79acpi_capm_convert_battstate(struct acpi_battinfo *battp) 80{ 81 int state; 82 83 state = 0xff; /* XXX unknown */ 84 85 if (battp->state & ACPI_BATT_STAT_DISCHARG) { --- 4 unchanged lines hidden (view full) --- 90 } 91 if (battp->state & ACPI_BATT_STAT_CRITICAL) 92 state = 2; /* critical */ 93 if (battp->state & ACPI_BATT_STAT_CHARGING) 94 state = 3; /* charging */ 95 96 /* If still unknown, determine it based on the battery capacity. */ 97 if (state == 0xff) { |
108 if (battp->cap >= 50) { | 98 if (battp->cap >= 50) |
109 state = 0; /* high */ | 99 state = 0; /* high */ |
110 } else { | 100 else |
111 state = 1; /* low */ | 101 state = 1; /* low */ |
112 } | |
113 } 114 115 return (state); 116} 117 118static int 119acpi_capm_convert_battflags(struct acpi_battinfo *battp) 120{ 121 int flags; 122 123 flags = 0; 124 | 102 } 103 104 return (state); 105} 106 107static int 108acpi_capm_convert_battflags(struct acpi_battinfo *battp) 109{ 110 int flags; 111 112 flags = 0; 113 |
125 if (battp->cap >= 50) { | 114 if (battp->cap >= 50) |
126 flags |= APM_BATT_HIGH; | 115 flags |= APM_BATT_HIGH; |
127 } else { | 116 else { |
128 if (battp->state & ACPI_BATT_STAT_CRITICAL) 129 flags |= APM_BATT_CRITICAL; 130 else 131 flags |= APM_BATT_LOW; 132 } 133 if (battp->state & ACPI_BATT_STAT_CHARGING) 134 flags |= APM_BATT_CHARGING; 135 if (battp->state == ACPI_BATT_STAT_NOT_PRESENT) --- 37 unchanged lines hidden (view full) --- 173static int 174acpi_capm_get_pwstatus(apm_pwstatus_t app) 175{ 176 int batt_unit; 177 int acline; 178 struct acpi_battinfo batt; 179 180 if (app->ap_device != PMDV_ALLDEV && | 117 if (battp->state & ACPI_BATT_STAT_CRITICAL) 118 flags |= APM_BATT_CRITICAL; 119 else 120 flags |= APM_BATT_LOW; 121 } 122 if (battp->state & ACPI_BATT_STAT_CHARGING) 123 flags |= APM_BATT_CHARGING; 124 if (battp->state == ACPI_BATT_STAT_NOT_PRESENT) --- 37 unchanged lines hidden (view full) --- 162static int 163acpi_capm_get_pwstatus(apm_pwstatus_t app) 164{ 165 int batt_unit; 166 int acline; 167 struct acpi_battinfo batt; 168 169 if (app->ap_device != PMDV_ALLDEV && |
181 (app->ap_device < PMDV_BATT0 || app->ap_device > PMDV_BATT_ALL)) { | 170 (app->ap_device < PMDV_BATT0 || app->ap_device > PMDV_BATT_ALL)) |
182 return (1); | 171 return (1); |
183 } | |
184 185 if (app->ap_device == PMDV_ALLDEV) 186 batt_unit = -1; /* all units */ 187 else 188 batt_unit = app->ap_device - PMDV_BATT0; 189 190 if (acpi_battery_get_battinfo(batt_unit, &batt)) 191 return (1); --- 159 unchanged lines hidden --- | 172 173 if (app->ap_device == PMDV_ALLDEV) 174 batt_unit = -1; /* all units */ 175 else 176 batt_unit = app->ap_device - PMDV_BATT0; 177 178 if (acpi_battery_get_battinfo(batt_unit, &batt)) 179 return (1); --- 159 unchanged lines hidden --- |