1 /* $OpenBSD: apmcall.S,v 1.5 2003/06/03 20:10:31 mickey Exp $ */ 2 3 /* 4 * Copyright (c) 2000,2001 Michael Shalayeff 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <machine/asm.h> 30 31 #ifndef APM_DISABLE_INTERRUPTS 32 #define APM_DISABLE_INTERRUPTS 1 33 #endif /* APM_DISABLE_INTERRUPTS */ 34 35 .data 36 .globl _C_LABEL(apm_ep) 37 .globl _C_LABEL(apm_cli) 38 _C_LABEL(apm_cli): 39 .long APM_DISABLE_INTERRUPTS 40 /* 41 * int apmcall(u_int f, int dev, struct apmregs *r) 42 * 43 */ 44 .text 45 ENTRY(apmcall) 46 pushl %ebp 47 movl %esp, %ebp 48 pushl %ebx 49 pushl %esi 50 pushl %edi 51 52 movl 16(%ebp), %ebx 53 movl 8(%ebx), %ecx 54 movl 12(%ebx), %edx 55 movl 12(%ebp), %ebx 56 57 pushfl 58 59 cmp $0, _C_LABEL(apm_cli) 60 je 1f 61 cli 62 1: 63 #if defined(DEBUG) || defined(DIAGNOSTIC) 64 pushl %ds 65 pushl %es 66 pushl %fs 67 pushl %gs 68 xorl %eax, %eax 69 movl %eax, %ds 70 movl %eax, %es 71 movl %eax, %fs 72 movl %eax, %gs 73 #endif 74 movl 8(%ebp), %eax 75 76 clc 77 lcall %cs:*(_C_LABEL(apm_ep)) 78 pushl %eax 79 setc %al 80 movzbl %al, %esi 81 popl %eax 82 83 #if defined(DEBUG) || defined(DIAGNOSTIC) 84 popl %gs 85 popl %fs 86 popl %es 87 popl %ds 88 #endif 89 popfl 90 91 movl 16(%ebp), %edi 92 movl %eax, 0(%edi) 93 movl %ebx, 4(%edi) 94 movl %ecx, 8(%edi) 95 movl %edx, 12(%edi) 96 97 testl $0xff00, %eax 98 jnz 1f 99 xorl %esi, %esi 100 1: 101 movl %esi, %eax 102 103 popl %edi 104 popl %esi 105 popl %ebx 106 popl %ebp 107 ret 108 109 .end