From 3155f0ec7fb015225c6ae42f782b8c25f2d79f88 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 19 Jul 2013 11:47:17 +1200 Subject: Committed --- power.asm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 power.asm (limited to 'power.asm') diff --git a/power.asm b/power.asm new file mode 100644 index 0000000..dd03bde --- /dev/null +++ b/power.asm @@ -0,0 +1,56 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; name: jaspos_power_connect +;; @param none +;; @return none +;; Connects the APM interface or displays an APM +;; error code on failure +;; +jaspos_power_connect: + push power_msgConnecting ; Display a message saying that we're connecting the interface + call jaspos_monitor_dispstring ; + mov ax, 0x5301 ; ax = 0x5301 - connect interface subfunction + xor bx, bx ; zero-out bx + int 0x15 ; Int 15.5301 - connect APM interface + jc .error ; catch errors from interrupt +.quit: + ret + +.error: + push msgFailedWithCode ; Display a message explaining that it failed + call jaspos_monitor_dispstring ; + mov [free_ram+4], byte 0 ; Ensure there'll be a null-terminator + push free_ram + 4 ; arg1 = buffer + push ax ; arg2 = decimal number + call jaspos_strutils_d2str ; Convert decimal to string + push free_ram ; Load address on NumberBuffer for printing + call jaspos_monitor_dispstring ; Print NumberBuffer + jmp .quit ; Jump to .quit for some POPping and then return +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; name: jaspos_power_shutdown +;; @param none +;; @return none +;; Powers the computer off using the (already +;; connected) APM interface +;; +jaspos_power_shutdown: + mov ax, 0x5307 ; ax = 5307 - Set power state + mov bx, 0x0001 ; bx = 0001 - Device: BIOS + mov cx, 0x0003 ; cx = 0003 - power state: off + int 0x15 ; Int 15.5307 - set power state using APM interface + jc .error ; Catch errors + ret +.error: + push msgFailedWithCode ; Warn user of error + call jaspos_monitor_dispstring ; + mov [free_ram+5], byte 0 + push free_ram + 4 + push ax + call jaspos_strutils_d2str ; Convert AH to string in NumberBuffer + push free_ram ; Print NumberBuffer + call jaspos_monitor_dispstring ; + jmp jaspos.panic +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \ No newline at end of file -- cgit v1.1