11.2Smartin/*	$NetBSD: delay.c,v 1.2 2008/04/28 20:23:18 martin Exp $	*/
21.1Stsutsui
31.1Stsutsui/*-
41.1Stsutsui * Copyright (c) 2003, 2005 The NetBSD Foundation, Inc.
51.1Stsutsui * All rights reserved.
61.1Stsutsui *
71.1Stsutsui * This code is derived from software contributed to The NetBSD Foundation
81.1Stsutsui * by Manuel Bouyer.
91.1Stsutsui *
101.1Stsutsui * Redistribution and use in source and binary forms, with or without
111.1Stsutsui * modification, are permitted provided that the following conditions
121.1Stsutsui * are met:
131.1Stsutsui * 1. Redistributions of source code must retain the above copyright
141.1Stsutsui *    notice, this list of conditions and the following disclaimer.
151.1Stsutsui * 2. Redistributions in binary form must reproduce the above copyright
161.1Stsutsui *    notice, this list of conditions and the following disclaimer in the
171.1Stsutsui *    documentation and/or other materials provided with the distribution.
181.1Stsutsui *
191.1Stsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Stsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Stsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Stsutsui * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Stsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Stsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Stsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Stsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Stsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Stsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Stsutsui * POSSIBILITY OF SUCH DAMAGE.
301.1Stsutsui */
311.1Stsutsui
321.1Stsutsui#include <sys/types.h>
331.1Stsutsui#include <lib/libsa/stand.h>
341.1Stsutsui
351.1Stsutsui#include "local.h"
361.1Stsutsui
371.1Stsutsui#define CPU_SPEED	133	/* XXX */
381.1Stsutsui
391.1Stsutsuivoid
401.1Stsutsuidelay(int us)
411.1Stsutsui{
421.1Stsutsui	volatile register int N;
431.1Stsutsui
441.1Stsutsui	/*
451.1Stsutsui	 * XXX need *real* clock calibration.
461.1Stsutsui	 */
471.1Stsutsui	if (us > 300)
481.1Stsutsui		us -= 300;
491.1Stsutsui	N = us * CPU_SPEED;
501.1Stsutsui
511.1Stsutsui	while ((N -= 5) > 0)
521.1Stsutsui		continue;
531.1Stsutsui}
54