1*58a2b000SEvgeniy Ivanov/* $NetBSD: biosdelay.S,v 1.4 2005/12/11 12:17:48 christos Exp $ */ 2*58a2b000SEvgeniy Ivanov 3*58a2b000SEvgeniy Ivanov/* 4*58a2b000SEvgeniy Ivanov * Copyright (c) 1996, 1997 5*58a2b000SEvgeniy Ivanov * Perry E. Metzger. All rights reserved. 6*58a2b000SEvgeniy Ivanov * 7*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without 8*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions 9*58a2b000SEvgeniy Ivanov * are met: 10*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright 11*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer. 12*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright 13*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the 14*58a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution. 15*58a2b000SEvgeniy Ivanov * 3. All advertising materials mentioning features or use of this software 16*58a2b000SEvgeniy Ivanov * must display the following acknowledgements: 17*58a2b000SEvgeniy Ivanov * This product includes software developed for the NetBSD Project 18*58a2b000SEvgeniy Ivanov * by Perry E. Metzger. 19*58a2b000SEvgeniy Ivanov * 4. The names of the authors may not be used to endorse or promote products 20*58a2b000SEvgeniy Ivanov * derived from this software without specific prior written permission. 21*58a2b000SEvgeniy Ivanov * 22*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23*58a2b000SEvgeniy Ivanov * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24*58a2b000SEvgeniy Ivanov * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25*58a2b000SEvgeniy Ivanov * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26*58a2b000SEvgeniy Ivanov * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27*58a2b000SEvgeniy Ivanov * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28*58a2b000SEvgeniy Ivanov * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29*58a2b000SEvgeniy Ivanov * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30*58a2b000SEvgeniy Ivanov * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31*58a2b000SEvgeniy Ivanov * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*58a2b000SEvgeniy Ivanov * 33*58a2b000SEvgeniy Ivanov */ 34*58a2b000SEvgeniy Ivanov 35*58a2b000SEvgeniy Ivanov#include <machine/asm.h> 36*58a2b000SEvgeniy Ivanov 37*58a2b000SEvgeniy Ivanov .text 38*58a2b000SEvgeniy Ivanov 39*58a2b000SEvgeniy Ivanov/* 40*58a2b000SEvgeniy Ivanov * BIOS call "INT 15H Function 86H" to sleep for a set number of microseconds 41*58a2b000SEvgeniy Ivanov * Call with %ah = 0x86 42*58a2b000SEvgeniy Ivanov * %cx = time interval (high) 43*58a2b000SEvgeniy Ivanov * %dx = time interval (low) 44*58a2b000SEvgeniy Ivanov * Return: 45*58a2b000SEvgeniy Ivanov * If error 46*58a2b000SEvgeniy Ivanov * CF = set 47*58a2b000SEvgeniy Ivanov * else 48*58a2b000SEvgeniy Ivanov * CF = clear 49*58a2b000SEvgeniy Ivanov */ 50*58a2b000SEvgeniy IvanovENTRY(delay) 51*58a2b000SEvgeniy Ivanov pushl %ebp 52*58a2b000SEvgeniy Ivanov pushl %ebx 53*58a2b000SEvgeniy Ivanov pushl %esi 54*58a2b000SEvgeniy Ivanov pushl %edi 55*58a2b000SEvgeniy Ivanov 56*58a2b000SEvgeniy Ivanov movw 20(%esp), %dx 57*58a2b000SEvgeniy Ivanov movw 22(%esp), %cx 58*58a2b000SEvgeniy Ivanov 59*58a2b000SEvgeniy Ivanov call _C_LABEL(prot_to_real) 60*58a2b000SEvgeniy Ivanov .code16 61*58a2b000SEvgeniy Ivanov 62*58a2b000SEvgeniy Ivanov movb $0x86, %ah 63*58a2b000SEvgeniy Ivanov int $0x15 64*58a2b000SEvgeniy Ivanov setnc %ah 65*58a2b000SEvgeniy Ivanov 66*58a2b000SEvgeniy Ivanov movb %ah, %bl # real_to_prot uses %eax 67*58a2b000SEvgeniy Ivanov 68*58a2b000SEvgeniy Ivanov calll _C_LABEL(real_to_prot) 69*58a2b000SEvgeniy Ivanov .code32 70*58a2b000SEvgeniy Ivanov 71*58a2b000SEvgeniy Ivanov xorl %eax, %eax 72*58a2b000SEvgeniy Ivanov movb %bl, %al 73*58a2b000SEvgeniy Ivanov 74*58a2b000SEvgeniy Ivanov popl %edi 75*58a2b000SEvgeniy Ivanov popl %esi 76*58a2b000SEvgeniy Ivanov popl %ebx 77*58a2b000SEvgeniy Ivanov popl %ebp 78*58a2b000SEvgeniy Ivanov ret 79