-; APM is not supported
-apm_error:
- mov ch, 9 ; Our string is 9 characters long
- mov si, apm_err
- call print_bytes_si
-
- jmp $ ; Infinite loop
-
-; Check APM support
-apm_chk:
- mov ah, 0x53 ; This is an APM command
- mov al, 0x00 ; APM: Installation Check
- mov bx, 0x0000 ; Device ID (0 is APM BIOS)
- int 0x15 ; Call
-
- jc apm_error ; Carry flag is set if there was an error
-
- cmp ah, 1 ; APM major version must be at least one
- jb apm_error
-
- cmp al, 1 ; APM minor version must be at least one
- jb apm_error
-
- ret
-
-
-; Disconnect from any APM interface
-apm_disco:
- mov ah, 0x53 ; This is an APM command
- mov al, 0x04 ; APM: Disconnect
- mov bx, 0x0000 ; Device ID (0 is APM BIOS)
- int 0x15 ; Call
-
- jc .apm_disco_error ; Carry flag is set if there was an error
- jmp .apm_disco_success
-
-; Disconnecting any APM interface failed
-.apm_disco_error:
- cmp ah, 0x03 ; Error code for no interface connected
- jne apm_error
-
-; No interface are connected now
-.apm_disco_success:
- ret
-
-; Connect to an APM interface
-apm_connect:
- mov ah, 0x53 ; This is an APM command
- mov bx, 0x0000 ; Device ID (0 is APM BIOS)
- int 0x15 ; Call
-
- jc apm_error ; Carry flag is set if there was an error
- ret
-
-; Set the APM Driver Version to 1.1
-apm_drv_init:
- mov ah, 0x53 ; This is an APM command
- mov al, 0x0e ; APM: Set Driver Supported Version
- mov bx, 0x0000 ; Device ID (0 is APM BIOS)
- mov ch, 1 ; APM Driver Major Version Number
- mov cl, 1 ; APM Driver Minor Version Number
- int 0x15 ; Call
-
- jc apm_error ; Carry flag is set if there was an error
- ret
-
-; Enable APM Power Management
-apm_mgmt_on:
- mov ah, 0x53 ; This is an APM command
- mov al, 0x08 ; APM: Change power management state
- mov bx, 0x0001 ; on all devices
- mov cx, 0x0001 ; to on
- int 0x15 ; Call
-
- jc apm_error ; Carry flag is set if there was an error
- ret
-
-; Power down the system
-apm_power_off:
- mov ah, 0x53 ; This is an APM command
- mov al, 0x07 ; APM: Set power state
- mov bx, 0x0001 ; on all devices
- mov cx, 0x0003 ; to off
- int 0x15 ; Call
-
- jc apm_error ; Carry flag is set if there was an error
- ret
-