Changeset 414 for branches/branch-1-0/src/helpers/acpih.c
- Timestamp:
- Feb 26, 2013, 3:44:10 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/src/helpers/acpih.c
r410 r414 17 17 18 18 /* 19 * Copyright (C) 2006-201 2Paul Ratcliffe.19 * Copyright (C) 2006-2013 Paul Ratcliffe. 20 20 * This file is part of the "XWorkplace helpers" source package. 21 21 * This is free software; you can redistribute it and/or modify … … 68 68 ACPITKWALKNAMESPACE *pAcpiTkWalkNamespace = NULL; 69 69 ACPITKEVALUATEOBJECT *pAcpiTkEvaluateObject = NULL; 70 // @@added V1.0.9 (2012-12-10) [slevine]: additional ACPI support 71 ACPITKPREPARETOSLEEP *pAcpiTkPrepareToSleep = NULL; 70 72 71 73 /* … … 126 128 DosQueryProcAddr(G_hmodACPI, ORD_ACPITKEVALUATEOBJECT, 127 129 NULL, (PFN *) &pAcpiTkEvaluateObject); 130 // @@added V1.0.9 (2012-12-10) [slevine]: additional ACPI support 131 DosQueryProcAddr(G_hmodACPI, ORD_ACPITKPREPARETOSLEEP, 132 NULL, (PFN *) &pAcpiTkPrepareToSleep); 128 133 } 129 134 } … … 133 138 else 134 139 { 135 char cTmp; // Required to ensure code not optimized away136 ULONG ulMemSize, ulMemFlags;137 138 140 G_ulCount++; 139 /* Force the shutdown function to be in memory. 140 * This is probably not the best place to do this, but it is the easiest. 141 * The function code may or may not cross page boundary and older versions 142 * of acpi32.dll placed the function as the last function in the DLL, 143 * so we need to check if the page exists before attempting to force it 144 * into memory. 145 * @@added V1.0.9 (2012-02-23) [dazarewicz]: additional ACPI support 141 142 // @@added V1.0.9 (2012-12-10) [slevine]: use AcpiTkPrepareToSleep rather than workaround 143 /* This function does not exist in older versions of acpi 144 * As a result the shutdown attempt will usually hang because 145 * the required code has not been committed into memory. 146 146 */ 147 cTmp = *((volatile char *)pAcpiGoToSleep); /* Ensure paged in */ 148 149 ulMemSize = 1; 150 if (DosQueryMem(((char *)pAcpiGoToSleep) + 4096, &ulMemSize, &ulMemFlags) == NO_ERROR) 151 { 152 if (ulMemFlags & PAG_COMMIT) 153 cTmp = *(((volatile char *)pAcpiGoToSleep) + 4096); /* Ensure paged in */ 154 } 147 if (pAcpiTkPrepareToSleep) 148 pAcpiTkPrepareToSleep(ACPI_STATE_S5); 155 149 156 150 return(pAcpiStartApi(phACPI)); … … 178 172 pAcpiEndApi = NULL; 179 173 pAcpiGoToSleep = NULL; 174 // @@added V1.0.9 (2012-12-10) [slevine]: additional ACPI support 175 pAcpiTkPrepareToSleep = NULL; 180 176 } 181 177 } … … 251 247 *@@added V1.0.9 (2012-02-20) [slevine]: code from David Azarewicz 252 248 */ 249 253 250 APIRET acpihGetPowerStatus(PAPM pApm, PBOOL pfChanged) 254 251 { … … 260 257 BOOL fChanged; 261 258 262 if (pAcpiTkWalkNamespace == NULL) 263 return 1; 264 265 if (pApm == NULL) 259 /* Make sure all the functions we need have valid pointers. 260 * @@added V1.0.9 (2012-02-25) [dazarewicz]: additional ACPI support 261 */ 262 if ( (pAcpiTkWalkNamespace == NULL) 263 || (pAcpiTkGetObjectInfoAlloc == NULL) 264 || (pAcpiTkGetHandle == NULL) 265 || (pAcpiTkOsFree == NULL) 266 || (pAcpiTkEvaluateObject == NULL) 267 || (pApm == NULL) 268 ) 266 269 return 1; 267 270 … … 292 295 Status = pAcpiTkEvaluateObject(G_ahAC, NULL, NULL, &Result); 293 296 if (Status != AE_OK) 294 ulTmp = 2; 295 else 296 if (Object[0].Type != ACPI_TYPE_INTEGER) 297 ulTmp = 2; 297 ulTmp = 2; // assume on backup power 298 else if (Object[0].Type != ACPI_TYPE_INTEGER) 299 ulTmp = 2; // assume on backup power 298 300 else 299 301 ulTmp = (UINT32)OBJECT_VALUE(0); … … 313 315 Result.Length = sizeof(Object); 314 316 Result.Pointer = Object; 317 // Get battery info 315 318 Status = pAcpiTkEvaluateObject(G_ahBat[uiI], "_BIF", NULL, &Result); 316 319 if (Status != AE_OK) … … 321 324 322 325 Obj = Result.Pointer; 323 Obj = (ACPI_OBJECT *)Obj[0].Package.Elements; // _BIFpackage326 Obj = (ACPI_OBJECT *)Obj[0].Package.Elements; // Battery info package 324 327 LastFull = (UINT32)OBJ_VALUE(2); 325 328 if (LastFull == 0xffffffff) … … 331 334 Result.Length = sizeof(Object); 332 335 Result.Pointer = Object; 336 // Get battery status 333 337 Status = pAcpiTkEvaluateObject(G_ahBat[uiI], "_BST", NULL, &Result); 334 338 if (Status != AE_OK) … … 346 350 347 351 // If battery units are mWh or mAh 352 // If not, it is a percentage 348 353 if ((UINT32)OBJ_VALUE(0) != 0xffffffff) 349 354 {
Note:
See TracChangeset
for help on using the changeset viewer.