Add findcpuspeed for delay() and to pass to the kernel(BUS FREQ information).
some bug fix.
This commit is contained in:
parent
c6d1f2e018
commit
5f78a36791
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.1 1998/01/16 04:17:35 sakamoto Exp $
|
||||
# $NetBSD: Makefile,v 1.2 1998/01/19 03:00:55 sakamoto Exp $
|
||||
|
||||
S= ${.CURDIR}/../../../..
|
||||
|
||||
|
@ -16,7 +16,7 @@ CPPFLAGS= -I${.CURDIR}/../../.. -I${S} -I${S}/lib/libsa
|
|||
CPPFLAGS+= -DDBMONITOR -DRELOC=${RELOC} -DENTRY=${ENTRY}
|
||||
CPPFLAGS+= -DCONS_VGA
|
||||
#CPPFLAGS+= -DCONS_SERIAL
|
||||
#CPPFLAGS+= -DCOMSPEED=38400 -DCOMPORT=0
|
||||
#CPPFLAGS+= -DCOMSPEED=38400 -DCOMPORT=0x3F8
|
||||
CPPFLAGS+= -DUSE_SCAN
|
||||
|
||||
AFLAGS= -x assembler-with-cpp -traditional-cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: boot.c,v 1.1 1998/01/16 04:17:36 sakamoto Exp $ */
|
||||
/* $Id: boot.c,v 1.2 1998/01/19 03:00:57 sakamoto Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -36,6 +36,9 @@
|
|||
#include <sys/reboot.h>
|
||||
#include <machine/param.h>
|
||||
#include <bebox/include/bootinfo.h>
|
||||
#ifdef CONS_SERIAL
|
||||
#include "ns16550.h"
|
||||
#endif /* CONS_SERIAL */
|
||||
|
||||
#define NAMELEN 128
|
||||
|
||||
|
@ -54,12 +57,14 @@ int args;
|
|||
void *startsym, *endsym, *bootinfo;
|
||||
struct btinfo_memory btinfo_memory;
|
||||
struct btinfo_console btinfo_console;
|
||||
struct btinfo_clock btinfo_clock;
|
||||
extern int errno;
|
||||
|
||||
void
|
||||
main()
|
||||
{
|
||||
int fd, n = 0;
|
||||
void *p;
|
||||
void start_CPU1();
|
||||
extern int CPU1_alive;
|
||||
extern char bootprog_name[], bootprog_rev[],
|
||||
|
@ -72,24 +77,23 @@ main()
|
|||
/*
|
||||
* make bootinfo
|
||||
*/
|
||||
bootinfo = (void *)0x3020;
|
||||
bootinfo = (void *)0x3030;
|
||||
|
||||
btinfo_memory.common.next =
|
||||
(void *)((size_t)bootinfo + sizeof (btinfo_memory));
|
||||
btinfo_memory.common.next = sizeof (btinfo_memory);
|
||||
btinfo_memory.common.type = BTINFO_MEMORY;
|
||||
btinfo_memory.memsize = *(int *)0x3010;
|
||||
|
||||
btinfo_memory.common.next = NULL;
|
||||
btinfo_memory.common.type = BTINFO_CONSOLE;
|
||||
btinfo_console.common.next = sizeof (btinfo_console);
|
||||
btinfo_console.common.type = BTINFO_CONSOLE;
|
||||
#ifdef CONS_VGA
|
||||
strcpy(btinfo_console.devname, "vga");
|
||||
#endif /* CONS_VGA */
|
||||
#ifdef CONS_SERIAL
|
||||
strcpy(btinfo_console.devname, "com");
|
||||
# ifdef COMPORT
|
||||
btinfo_console.port = COMPORT;
|
||||
btinfo_console.addr = COMPORT;
|
||||
# else /* COMPORT */
|
||||
btinfo_console.port = 0;
|
||||
btinfo_console.addr = COM1;
|
||||
# endif /* COMPORT */
|
||||
# ifdef COMSPEED
|
||||
btinfo_console.speed = COMSPEED;
|
||||
|
@ -98,9 +102,16 @@ main()
|
|||
# endif /* COMSPEED */
|
||||
#endif /* CONS_SERIAL */
|
||||
|
||||
bcopy((void *)&btinfo_memory, bootinfo, sizeof (btinfo_memory));
|
||||
bcopy((void *)&btinfo_console, btinfo_memory.common.next,
|
||||
sizeof (btinfo_console));
|
||||
btinfo_clock.common.next = 0;
|
||||
btinfo_clock.common.type = BTINFO_CLOCK;
|
||||
btinfo_clock.ticks_per_sec = findcpuspeed();
|
||||
|
||||
p = bootinfo;
|
||||
bcopy((void *)&btinfo_memory, p, sizeof (btinfo_memory));
|
||||
p += sizeof (btinfo_memory);
|
||||
bcopy((void *)&btinfo_console, p, sizeof (btinfo_console));
|
||||
p += sizeof (btinfo_console);
|
||||
bcopy((void *)&btinfo_clock, p, sizeof (btinfo_clock));
|
||||
|
||||
/*
|
||||
* console init
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clock.c,v 1.1 1998/01/16 04:17:37 sakamoto Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.2 1998/01/19 03:00:59 sakamoto Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -31,9 +31,13 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/ic/i8253reg.h>
|
||||
|
||||
static u_long ns_per_tick = 320;
|
||||
#define FIRST_GUESS 0x2000
|
||||
|
||||
static u_long ns_per_tick;
|
||||
|
||||
static inline u_quad_t
|
||||
mftb()
|
||||
|
@ -63,3 +67,41 @@ delay(n)
|
|||
asm ("1: mftbu %0; cmpw %0,%1; blt 1b; bgt 2f; mftb %0; cmpw %0,%2; blt 1b; 2:"
|
||||
:: "r"(scratch), "r"(tbh), "r"(tbl));
|
||||
}
|
||||
|
||||
int
|
||||
findcpuspeed()
|
||||
{
|
||||
int i;
|
||||
int ticks_per_sec;
|
||||
u_short remainder;
|
||||
u_quad_t tstart, tend;
|
||||
|
||||
/* Put counter in count down mode */
|
||||
outb(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
|
||||
outb(TIMER_CNTR0, 0xff); /* lo */
|
||||
outb(TIMER_CNTR0, 0xff); /* hi */
|
||||
for (i = FIRST_GUESS; i; i--)
|
||||
;
|
||||
/* Read the value left in the counter */
|
||||
outb(TIMER_MODE, TIMER_SEL0|TIMER_LATCH);
|
||||
remainder = inb(TIMER_CNTR0);
|
||||
remainder += (inb(TIMER_CNTR0) << 8);
|
||||
|
||||
tstart = mftb();
|
||||
for (i = FIRST_GUESS; i; i--)
|
||||
;
|
||||
tend = mftb();
|
||||
if (tend > tstart)
|
||||
tend -= tstart;
|
||||
else
|
||||
tend += UQUAD_MAX - tstart;
|
||||
|
||||
ticks_per_sec = (int)(tend * TIMER_FREQ / (0xffff - remainder));
|
||||
if (ticks_per_sec > 8000000) /* XXX */
|
||||
ticks_per_sec = 33000000 / 4;
|
||||
else
|
||||
ticks_per_sec = 25000000 / 4;
|
||||
ns_per_tick = 1000000000 / ticks_per_sec;
|
||||
|
||||
return (ticks_per_sec);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: devopen.c,v 1.1 1998/01/16 04:17:44 sakamoto Exp $ */
|
||||
/* $NetBSD: devopen.c,v 1.2 1998/01/19 03:01:00 sakamoto Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -60,7 +60,7 @@ devlookup(d)
|
|||
if (dp->dv_name)
|
||||
printf(" %s", dp->dv_name);
|
||||
printf("\n");
|
||||
return (ENODEV);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ns16550.c,v 1.1 1998/01/16 04:17:57 sakamoto Exp $ */
|
||||
/* $Id: ns16550.c,v 1.2 1998/01/19 03:01:01 sakamoto Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995-1997 Gary Thomas (gdt@linuxppc.org)
|
||||
|
@ -37,10 +37,6 @@
|
|||
|
||||
#include <bebox/include/bootinfo.h>
|
||||
#include "ns16550.h"
|
||||
typedef struct NS16550 *NS16550_t;
|
||||
|
||||
const NS16550_t COM_PORTS[] = { (NS16550_t)COM1, (NS16550_t)COM2,
|
||||
(NS16550_t)COM3, (NS16550_t)COM4 };
|
||||
|
||||
volatile struct NS16550 *
|
||||
NS16550_init()
|
||||
|
@ -49,7 +45,7 @@ NS16550_init()
|
|||
int speed;
|
||||
extern struct btinfo_console btinfo_console;
|
||||
|
||||
com_port = (struct NS16550 *) COM_PORTS[btinfo_console.port];
|
||||
com_port = (struct NS16550 *)(COMBASE + btinfo_console.addr);
|
||||
|
||||
com_port->lcr = 0x80; /* Access baud rate */
|
||||
speed = comspeed(btinfo_console.speed);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ns16550.h,v 1.1 1998/01/16 04:17:58 sakamoto Exp $ */
|
||||
/* $Id: ns16550.h,v 1.2 1998/01/19 03:01:03 sakamoto Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995-1997 Gary Thomas (gdt@linuxppc.org)
|
||||
|
@ -60,8 +60,8 @@ struct NS16550
|
|||
#define LSR_TEMT 0x40 /* Xmitter empty */
|
||||
#define LSR_ERR 0x80 /* Error */
|
||||
|
||||
#define COM1 0x800003F8
|
||||
#define COM2 0x800002F8
|
||||
#define COM3 0x80000380
|
||||
#define COM4 0x80000388
|
||||
|
||||
#define COMBASE 0x80000000
|
||||
#define COM1 0x3F8
|
||||
#define COM2 0x2F8
|
||||
#define COM3 0x380
|
||||
#define COM4 0x388
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tgets.c,v 1.1 1998/01/16 04:18:04 sakamoto Exp $ */
|
||||
/* $NetBSD: tgets.c,v 1.2 1998/01/19 03:01:04 sakamoto Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -46,7 +46,7 @@ tgets(buf)
|
|||
register char *lp;
|
||||
|
||||
#ifdef USE_SCAN
|
||||
#define SCANWAIT 20000
|
||||
#define SCANWAIT 10000
|
||||
#define PWAIT 500
|
||||
for (i = 0; i < PWAIT; i++) {
|
||||
if ((c = cnscan()) != -1)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$Id: version,v 1.1 1998/01/16 04:18:05 sakamoto Exp $
|
||||
$Id: version,v 1.2 1998/01/19 03:01:05 sakamoto Exp $
|
||||
|
||||
1.0: Boot program for BeBox; initial revision
|
||||
1.1: Boot program for BeBox; initial revision
|
||||
1.2: check BUS FREQ, add clock information
|
||||
|
|
Loading…
Reference in New Issue