- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpower.c
More file actions
Latest commit
17 lines (14 loc) · 565 Bytes
/
Copy pathpower.c
File metadata and controls
17 lines (14 loc) · 565 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include"types.h"
typedefstruct {
uint8_tac_status; // 0 = Battery, 1 = Plugged in (AC Power), 0xFF = Unknown
uint8_tbattery_status; // 0 = High, 1 = Low, 2 = Critical, 3 = Charging
uint8_tbattery_percent; // 0% - 100% (0xFF = Unknown)
} PowerStatus;
// Basic ACPI/QEMU Power Off trigger via Port 0x604
voidpower_off(void) {
// Shutdown command sent to QEMU / Bochs emulator ACPI port
outb(0x604, 0x00); // Magic shutdown value
outb(0x604, 0x20);
// Fallback APM shutdown via port 0xB004
outb(0xB004, 0x2000);
}