!************************************************************************** !* !* Network driver interface for netboot bootrom !* !* Module: timer.S !* Purpose: Timer access routines !* Entries: wait10ms !* !************************************************************************** !* !* Copyright (C) 2003 Gero Kuhlmann !* !* This program is free software; you can redistribute it and/or modify !* it under the terms of the GNU General Public License as published by !* the Free Software Foundation; either version 2 of the License, or !* any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. !* !* $Id: timer.S,v 1.1 2003/03/09 00:43:07 gkminix Exp $ !* ! !************************************************************************** ! ! Load assembler macros and other include files. ! #include ! !************************************************************************** ! ! Definitions to access the PC hardware timer ! TIMER_0 equ $40 ! Timer 0 port number TIMER_MODE equ $43 ! Timer mode port number TIMER_TICKS equ $5D3A ! Number of timer counts for 10 ms ! !************************************************************************** ! ! Start code segment. ! .text public wait10ms ! !************************************************************************** ! ! Wait a number of 10 millisecond intervals ! Input: BX - Number of intervals to wait ! Output: None ! Registers changed: AX, BX ! wait10ms: pushf push cx push dx wait1: cli mov dx,#TIMER_MODE xor al,al out dx,al ! write timer 0 count mode jcxz wait2 ! wait a little bit to avoid a bug wait2: jcxz wait3 ! in certain Neptune chipsets wait3: mov dx,#TIMER_0 in al,dx ! read timer LSB mov cl,al in al,dx ! read timer MSB mov ch,al sti wait4: cli mov dx,#TIMER_MODE xor al,al out dx,al ! write timer 0 count mode jcxz wait5 wait5: jcxz wait6 wait6: mov dx,#TIMER_0 in al,dx ! read timer LSB mov ah,al in al,dx ! read timer MSB xchg ah,al sti neg ax add ax,cx ! check if timeout value reached cmp ax,#TIMER_TICKS jb wait4 ! no, read timer again dec bx jnz wait1 ! check if number of loops reached pop dx pop cx popf ret ! !************************************************************************** ! end