ReactOS 0.4.15-dev-7660-g0086d05
system.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for system.c:

Go to the source code of this file.

Classes

struct  acpi_system
 

Macros

#define NDEBUG
 
#define _COMPONENT   ACPI_SYSTEM_COMPONENT
 
#define PREFIX   "ACPI: "
 

Functions

ACPI_STATUS acpi_system_save_state (UINT32)
 
static int acpi_system_add (struct acpi_device *device)
 
static int acpi_system_remove (struct acpi_device *device, int type)
 
ACPI_STATUS acpi_suspend (UINT32 state)
 
ACPI_STATUS acpi_system_restore_state (UINT32 state)
 
ACPI_STATUS acpi_system_suspend (UINT32 state)
 
int acpi_system_init (void)
 
void acpi_system_exit (void)
 

Variables

static struct acpi_driver acpi_system_driver
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_SYSTEM_COMPONENT

Definition at line 37 of file system.c.

◆ NDEBUG

#define NDEBUG

Definition at line 32 of file system.c.

◆ PREFIX

#define PREFIX   "ACPI: "

Definition at line 40 of file system.c.

Function Documentation

◆ acpi_suspend()

ACPI_STATUS acpi_suspend ( UINT32  state)

acpi_suspend - OS-agnostic system suspend/resume support (S? states) @state: state we're entering

Definition at line 347 of file system.c.

349{
351
352 /* only support S1 and S5 on kernel 2.4 */
353 //if (state != ACPI_STATE_S1 && state != ACPI_STATE_S4
354 // && state != ACPI_STATE_S5)
355 // return AE_ERROR;
356
357
358 //if (ACPI_STATE_S4 == state) {
359 // /* For s4bios, we need a wakeup address. */
360 // if (1 == AcpiGbl_FACS->S4bios_f &&
361 // 0 != AcpiGbl_FADT->smi_cmd) {
362 // if (!acpi_wakeup_address)
363 // return AE_ERROR;
364 // AcpiSetFirmwareWakingVector((acpi_physical_address) acpi_wakeup_address);
365 // } else
366 // /* We don't support S4 under 2.4. Give up */
367 // return AE_ERROR;
368 //}
370
373 return status;
374
375 /* disable interrupts and flush caches */
376 _disable();
378
379 /* perform OS-specific sleep actions */
381
382 /* Even if we failed to go to sleep, all of the devices are in an suspended
383 * mode. So, we run these unconditionally to make sure we have a usable system
384 * no matter what.
385 */
388
389 /* make sure interrupts are enabled */
390 _enable();
391
392 /* reset firmware waking vector */
394
395 return status;
396}
#define ACPI_FLUSH_CPU_CACHE()
Definition: accygwin.h:53
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define ACPI_STATE_S5
Definition: actypes.h:629
UINT32 ACPI_STATUS
Definition: actypes.h:460
static int state
Definition: maze.c:121
ACPI_STATUS acpi_system_restore_state(UINT32 state)
Definition: system.c:156
ACPI_STATUS acpi_system_suspend(UINT32 state)
Definition: system.c:313
ACPI_STATUS AcpiEnterSleepStatePrep(UINT8 SleepState)
Definition: hwxfsleep.c:345
ACPI_STATUS AcpiSetFirmwareWakingVector(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
Definition: hwxfsleep.c:174
ACPI_STATUS AcpiLeaveSleepState(UINT8 SleepState)
Definition: hwxfsleep.c:505
ACPI_STATUS AcpiEnterSleepState(UINT8 SleepState)
Definition: hwxfsleep.c:435
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
Definition: ps.c:97

Referenced by Bus_FDO_Power().

◆ acpi_system_add()

static int acpi_system_add ( struct acpi_device device)
static

Definition at line 65 of file system.c.

67{
69 struct acpi_system *system = NULL;
70 UINT8 i = 0;
71
72 ACPI_FUNCTION_TRACE("acpi_system_add");
73
74 if (!device)
75 return_VALUE(-1);
76
78 if (!system)
79 return_VALUE(-14);
80 memset(system, 0, sizeof(struct acpi_system));
81
82 system->handle = device->handle;
86
87 DPRINT("%s [%s] (supports",
89 for (i=0; i<ACPI_S_STATE_COUNT; i++) {
90 UINT8 type_a, type_b;
91 status = AcpiGetSleepTypeData(i, &type_a, &type_b);
92 switch (i) {
93 case ACPI_STATE_S4:
94 if (/*AcpiGbl_FACS->S4bios_f &&*/
95 0 != AcpiGbl_FADT.SmiCommand) {
96 DPRINT(" S4bios\n");
97 system->states[i] = 1;
98 }
99 /* no break */
100 default:
101 if (ACPI_SUCCESS(status)) {
102 system->states[i] = 1;
103 DPRINT(" S%d", i);
104 }
105 }
106 }
107
108//#ifdef CONFIG_PM
109// /* Install the soft-off (S5) handler. */
110// if (system->states[ACPI_STATE_S5]) {
111// pm_power_off = acpi_power_off;
112// register_sysrq_key('o', &sysrq_acpi_poweroff_op);
113// }
114//#endif
115
116 return_VALUE(0);
117}
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
#define return_VALUE(s)
Definition: acoutput.h:499
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define acpi_device_bid(d)
Definition: acpi_bus.h:186
#define acpi_driver_data(d)
Definition: acpi_bus.h:289
#define acpi_device_class(d)
Definition: acpi_bus.h:191
#define acpi_device_name(d)
Definition: acpi_bus.h:190
#define ACPI_SYSTEM_CLASS
Definition: acpi_drivers.h:243
#define ACPI_SYSTEM_DEVICE_NAME
Definition: acpi_drivers.h:246
#define ACPI_STATE_S4
Definition: actypes.h:628
#define ACPI_S_STATE_COUNT
Definition: actypes.h:631
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ACPI_STATUS AcpiGetSleepTypeData(UINT8 SleepState, UINT8 *SleepTypeA, UINT8 *SleepTypeB)
Definition: hwxface.c:411
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int __cdecl system(_In_opt_z_ const char *_Command)
#define memset(x, y, z)
Definition: compat.h:39
#define DPRINT
Definition: sndvol32.h:71
Definition: devices.h:37

◆ acpi_system_exit()

void acpi_system_exit ( void  )

Definition at line 414 of file system.c.

415{
416 ACPI_FUNCTION_TRACE("acpi_system_exit");
419}
#define return_VOID
Definition: acoutput.h:495
void acpi_bus_unregister_driver(struct acpi_driver *driver)
Definition: bus.c:1056
static struct acpi_driver acpi_system_driver
Definition: system.c:47

Referenced by acpi_bus_exit().

◆ acpi_system_init()

int acpi_system_init ( void  )

Definition at line 399 of file system.c.

400{
401 int result = 0;
402
403 ACPI_FUNCTION_TRACE("acpi_system_init");
404
406 if (result < 0)
408
409 return_VALUE(0);
410}
#define AE_NOT_FOUND
Definition: acexcep.h:113
int acpi_bus_register_driver(struct acpi_driver *driver)
Definition: bus.c:1029
GLuint64EXT * result
Definition: glext.h:11304

Referenced by acpi_init().

◆ acpi_system_remove()

static int acpi_system_remove ( struct acpi_device device,
int  type 
)
static

Definition at line 120 of file system.c.

123{
124 struct acpi_system *system = NULL;
125
126 ACPI_FUNCTION_TRACE("acpi_system_remove");
127
129 return_VALUE(-1);
130
132
133//#ifdef CONFIG_PM
134// /* Remove the soft-off (S5) handler. */
135// if (system->states[ACPI_STATE_S5]) {
136// unregister_sysrq_key('o', &sysrq_acpi_poweroff_op);
137// pm_power_off = NULL;
138// }
139//#endif
140//
141//
142 ExFreePoolWithTag(system, 'IPCA');
143
144 return 0;
145}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

◆ acpi_system_restore_state()

ACPI_STATUS acpi_system_restore_state ( UINT32  state)

acpi_system_restore_state - OS-specific restoration of state @state: sleep state we're exiting

Note that if we're coming back from S4, the memory image should have already been loaded from the disk and is already in place. (Otherwise how else would we be here?).

Definition at line 156 of file system.c.

158{
159 /*
160 * We should only be here if we're coming back from STR or STD.
161 * And, in the case of the latter, the memory image should have already
162 * been loaded from disk.
163 */
164 if (state > ACPI_STATE_S1) {
165 //acpi_restore_state_mem();
166
167 /* Do _early_ resume for irqs. Required by
168 * ACPI specs.
169 */
170 /* TBD: call arch dependant reinitialization of the
171 * interrupts.
172 */
173#ifdef _X86_
174 //init_8259A(0);
175#endif
176 /* wait for power to come back */
178
179 }
180
181 /* Be really sure that irqs are disabled. */
182 //ACPI_DISABLE_IRQS();
183
184 /* Wait a little again, just in case... */
186
187 /* enable interrupts once again */
188 //ACPI_ENABLE_IRQS();
189
190 /* turn all the devices back on */
191 //if (state > ACPI_STATE_S1)
192 //pm_send_all(PM_RESUME, (void *)0);
193
194 return AE_OK;
195}
#define ACPI_STATE_S1
Definition: actypes.h:625
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81

Referenced by acpi_suspend().

◆ acpi_system_save_state()

ACPI_STATUS acpi_system_save_state ( UINT32  state)

acpi_system_save_state - save OS specific state and power down devices @state: sleep state we're entering.

This handles saving all context to memory, and possibly disk. First, we call to the device driver layer to save device state. Once we have that, we save whatevery processor and kernel state we need to memory. If we're entering S4, we then write the memory image to disk.

Only then it is safe for us to power down devices, since we may need the disks and upstream buses to write to.

Definition at line 212 of file system.c.

214{
215 int error = 0;
216
217 /* Send notification to devices that they will be suspended.
218 * If any device or driver cannot make the transition, either up
219 * or down, we'll get an error back.
220 */
221 /*if (state > ACPI_STATE_S1) {
222 error = pm_send_all(PM_SAVE_STATE, (void *)3);
223 if (error)
224 return AE_ERROR;
225 }*/
226
227 //if (state <= ACPI_STATE_S5) {
228 // /* Tell devices to stop I/O and actually save their state.
229 // * It is theoretically possible that something could fail,
230 // * so handle that gracefully..
231 // */
232 // if (state > ACPI_STATE_S1 && state != ACPI_STATE_S5) {
233 // error = pm_send_all(PM_SUSPEND, (void *)3);
234 // if (error) {
235 // /* Tell devices to restore state if they have
236 // * it saved and to start taking I/O requests.
237 // */
238 // pm_send_all(PM_RESUME, (void *)0);
239 // return error;
240 // }
241 // }
242
243 /* flush caches */
245
246 /* Do arch specific saving of state. */
247 if (state > ACPI_STATE_S1) {
248 error = 0;//acpi_save_state_mem();
249
250 /* TBD: if no s4bios, write codes for
251 * acpi_save_state_disk()...
252 */
253#if 0
254 if (!error && (state == ACPI_STATE_S4))
255 error = acpi_save_state_disk();
256#endif
257 /*if (error) {
258 pm_send_all(PM_RESUME, (void *)0);
259 return error;
260 }*/
261 }
262 //}
263 /* disable interrupts
264 * Note that acpi_suspend -- our caller -- will do this once we return.
265 * But, we want it done early, so we don't get any surprises during
266 * the device suspend sequence.
267 */
268 //ACPI_DISABLE_IRQS();
269
270 /* Unconditionally turn off devices.
271 * Obvious if we enter a sleep state.
272 * If entering S5 (soft off), this should put devices in a
273 * quiescent state.
274 */
275
276 //if (state > ACPI_STATE_S1) {
277 // error = pm_send_all(PM_SUSPEND, (void *)3);
278
279 // /* We're pretty screwed if we got an error from this.
280 // * We try to recover by simply calling our own restore_state
281 // * function; see above for definition.
282 // *
283 // * If it's S5 though, go through with it anyway..
284 // */
285 // if (error && state != ACPI_STATE_S5)
286 // acpi_system_restore_state(state);
287 //}
288 return error ? AE_ERROR : AE_OK;
289}
#define AE_ERROR
Definition: acexcep.h:109
#define error(str)
Definition: mkdosfs.c:1605

◆ acpi_system_suspend()

ACPI_STATUS acpi_system_suspend ( UINT32  state)

Definition at line 313 of file system.c.

315{
317 //unsigned long flags = 0;
318
319 //local_irq_save(flags);
320 /* kernel_fpu_begin(); */
321
322 switch (state) {
323 case ACPI_STATE_S1:
324 case ACPI_STATE_S5:
325 //barrier();
327 break;
328 case ACPI_STATE_S4:
329 //do_suspend_lowlevel_s4bios(0);
330 break;
331 }
332
333 /* kernel_fpu_end(); */
334 //local_irq_restore(flags);
335
336 return status;
337}

Referenced by acpi_suspend().

Variable Documentation

◆ acpi_system_driver

struct acpi_driver acpi_system_driver
static
Initial value:
= {
{0,0},
0,
0,
}
#define ACPI_SYSTEM_HID
Definition: acpi_drivers.h:244
#define ACPI_SYSTEM_DRIVER_NAME
Definition: acpi_drivers.h:245
static int acpi_system_add(struct acpi_device *device)
Definition: system.c:65
static int acpi_system_remove(struct acpi_device *device, int type)
Definition: system.c:120

Definition at line 47 of file system.c.

Referenced by acpi_system_exit(), and acpi_system_init().