Sat Jan 3 11:17:41 2009 UTC ()
Pull up revisions:
  1.39  sys/arch/atari/dev/clock.c
  1.31  sys/arch/atari/include/param.h
(requested by tsutsui in ticket #1253).

Simplify delay based on x86 version.


(jdc)
diff -r1.37 -r1.37.34.1 src/sys/arch/atari/dev/clock.c
diff -r1.30 -r1.30.68.1 src/sys/arch/atari/include/param.h

cvs diff -r1.37 -r1.37.34.1 src/sys/arch/atari/dev/clock.c (expand / switch to unified diff)

--- src/sys/arch/atari/dev/clock.c 2005/12/24 20:06:58 1.37
+++ src/sys/arch/atari/dev/clock.c 2009/01/03 11:17:41 1.37.34.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: clock.c,v 1.37 2005/12/24 20:06:58 perry Exp $ */ 1/* $NetBSD: clock.c,v 1.37.34.1 2009/01/03 11:17:41 jdc Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1990 The Regents of the University of California. 4 * Copyright (c) 1982, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -67,27 +67,27 @@ @@ -67,27 +67,27 @@
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE. 72 * SUCH DAMAGE.
73 * 73 *
74 * from: Utah $Hdr: clock.c 1.18 91/01/21$ 74 * from: Utah $Hdr: clock.c 1.18 91/01/21$
75 * 75 *
76 * @(#)clock.c 7.6 (Berkeley) 5/7/91 76 * @(#)clock.c 7.6 (Berkeley) 5/7/91
77 */ 77 */
78 78
79#include <sys/cdefs.h> 79#include <sys/cdefs.h>
80__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.37 2005/12/24 20:06:58 perry Exp $"); 80__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.37.34.1 2009/01/03 11:17:41 jdc Exp $");
81 81
82#include <sys/param.h> 82#include <sys/param.h>
83#include <sys/kernel.h> 83#include <sys/kernel.h>
84#include <sys/systm.h> 84#include <sys/systm.h>
85#include <sys/device.h> 85#include <sys/device.h>
86#include <sys/uio.h> 86#include <sys/uio.h>
87#include <sys/conf.h> 87#include <sys/conf.h>
88#include <sys/proc.h> 88#include <sys/proc.h>
89#include <sys/event.h> 89#include <sys/event.h>
90 90
91#include <dev/clock_subr.h> 91#include <dev/clock_subr.h>
92 92
93#include <machine/psl.h> 93#include <machine/psl.h>
@@ -323,59 +323,55 @@ clkread() @@ -323,59 +323,55 @@ clkread()
323 return(delta + tick); 323 return(delta + tick);
324 return(delta); 324 return(delta);
325} 325}
326 326
327#define TIMB_FREQ 614400 327#define TIMB_FREQ 614400
328#define TIMB_LIMIT 256 328#define TIMB_LIMIT 256
329 329
330/* 330/*
331 * Wait "n" microseconds. 331 * Wait "n" microseconds.
332 * Relies on MFP-Timer B counting down from TIMB_LIMIT at TIMB_FREQ Hz. 332 * Relies on MFP-Timer B counting down from TIMB_LIMIT at TIMB_FREQ Hz.
333 * Note: timer had better have been programmed before this is first used! 333 * Note: timer had better have been programmed before this is first used!
334 */ 334 */
335void 335void
336delay(n) 336delay(unsigned int n)
337int n; 
338{ 337{
339 int ticks, otick; 338 int ticks, otick, remaining;
340 339
341 /* 340 /*
342 * Read the counter first, so that the rest of the setup overhead is 341 * Read the counter first, so that the rest of the setup overhead is
343 * counted. 342 * counted.
344 */ 343 */
345 otick = MFP->mf_tbdr; 344 otick = MFP->mf_tbdr;
346 345
347 /* 346 if (n <= UINT_MAX / TIMB_FREQ) {
348 * Calculate ((n * TIMER_FREQ) / 1e6) using explicit assembler code so 347 /*
349 * we can take advantage of the intermediate 64-bit quantity to prevent 348 * For unsigned arithmetic, division can be replaced with
350 * loss of significance. 349 * multiplication with the inverse and a shift.
351 */ 350 */
352 n -= 5; 351 remaining = n * TIMB_FREQ / 1000000;
353 if(n < 0) 352 } else {
354 return; 353 /* This is a very long delay.
355 { 354 * Being slow here doesn't matter.
356 u_int temp; 355 */
357  356 remaining = (unsigned long long) n * TIMB_FREQ / 1000000;
358 __asm volatile ("mulul %2,%1:%0" : "=d" (n), "=d" (temp) 
359 : "d" (TIMB_FREQ), "d" (n)); 
360 __asm volatile ("divul %1,%2:%0" : "=d" (n) 
361 : "d"(1000000),"d"(temp),"0"(n)); 
362 } 357 }
363 358
364 while(n > 0) { 359 while(remaining > 0) {
365 ticks = MFP->mf_tbdr; 360 ticks = MFP->mf_tbdr;
366 if(ticks > otick) 361 if(ticks > otick)
367 n -= TIMB_LIMIT - (ticks - otick); 362 remaining -= TIMB_LIMIT - (ticks - otick);
368 else n -= otick - ticks; 363 else
 364 remaining -= otick - ticks;
369 otick = ticks; 365 otick = ticks;
370 } 366 }
371} 367}
372 368
373#ifdef GPROF 369#ifdef GPROF
374/* 370/*
375 * profclock() is expanded in line in lev6intr() unless profiling kernel. 371 * profclock() is expanded in line in lev6intr() unless profiling kernel.
376 * Assumes it is called with clock interrupts blocked. 372 * Assumes it is called with clock interrupts blocked.
377 */ 373 */
378profclock(pc, ps) 374profclock(pc, ps)
379 caddr_t pc; 375 caddr_t pc;
380 int ps; 376 int ps;
381{ 377{

cvs diff -r1.30 -r1.30.68.1 src/sys/arch/atari/include/param.h (expand / switch to unified diff)

--- src/sys/arch/atari/include/param.h 2005/12/11 12:16:59 1.30
+++ src/sys/arch/atari/include/param.h 2009/01/03 11:17:41 1.30.68.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: param.h,v 1.30 2005/12/11 12:16:59 christos Exp $ */ 1/* $NetBSD: param.h,v 1.30.68.1 2009/01/03 11:17:41 jdc Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. 4 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -102,19 +102,19 @@ @@ -102,19 +102,19 @@
102#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 102#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
103 103
104/* 104/*
105 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 105 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
106 * logical pages. 106 * logical pages.
107 */ 107 */
108#define NKMEMPAGES_MIN_DEFAULT ((3 * 1024 * 1024) >> PAGE_SHIFT) 108#define NKMEMPAGES_MIN_DEFAULT ((3 * 1024 * 1024) >> PAGE_SHIFT)
109#define NKMEMPAGES_MAX_DEFAULT ((3 * 1024 * 1024) >> PAGE_SHIFT) 109#define NKMEMPAGES_MAX_DEFAULT ((3 * 1024 * 1024) >> PAGE_SHIFT)
110 110
111#ifdef _KERNEL 111#ifdef _KERNEL
112 112
113#include <machine/intr.h> 113#include <machine/intr.h>
114 114
115void delay __P((int)); 115void delay(unsigned int);
116 116
117#define DELAY(n) delay(n) 117#define DELAY(n) delay(n)
118#endif /* _KERNEL */ 118#endif /* _KERNEL */
119 119
120#endif /* !_MACHINE_PARAM_H_ */ 120#endif /* !_MACHINE_PARAM_H_ */