Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/bebox/stand/boot Some cleanup.



details:   https://anonhg.NetBSD.org/src/rev/9d7371cfeadd
branches:  trunk
changeset: 473970:9d7371cfeadd
user:      sakamoto <sakamoto%NetBSD.org@localhost>
date:      Thu Jun 24 01:10:31 1999 +0000

description:
Some cleanup.
Move bootinfo related things to boot.c
and console related things to cons.c.

diffstat:

 sys/arch/bebox/stand/boot/Makefile  |   40 ++++++++----
 sys/arch/bebox/stand/boot/boot.c    |   48 +++++---------
 sys/arch/bebox/stand/boot/boot.h    |    4 +
 sys/arch/bebox/stand/boot/clock.c   |   49 +-------------
 sys/arch/bebox/stand/boot/cons.c    |   95 ++++++++++++++++------------
 sys/arch/bebox/stand/boot/cons.h    |   12 ++-
 sys/arch/bebox/stand/boot/ns16550.c |   13 +--
 sys/arch/bebox/stand/boot/pci.c     |  117 ------------------------------------
 8 files changed, 119 insertions(+), 259 deletions(-)

diffs (truncated from 674 to 300 lines):

diff -r b8c046f24691 -r 9d7371cfeadd sys/arch/bebox/stand/boot/Makefile
--- a/sys/arch/bebox/stand/boot/Makefile        Thu Jun 24 00:16:49 1999 +0000
+++ b/sys/arch/bebox/stand/boot/Makefile        Thu Jun 24 01:10:31 1999 +0000
@@ -1,25 +1,28 @@
-#      $NetBSD: Makefile,v 1.6 1999/02/13 02:54:43 lukem Exp $
+#      $NetBSD: Makefile,v 1.7 1999/06/24 01:10:31 sakamoto Exp $
 
 S= ${.CURDIR}/../../../..
 
 BASE= boot
-PROG= ${BASE}.pef
+BOOTPROG= ${BASE}.pef
 NEWVERSWHAT= "BOOT"
 
-SRCS= srt0.s boot.c clock.c com.c conf.c cons.c cpu.c devopen.c
-SRCS+= fd.c filesystem.c inkernel.c io.c pci.c tgets.c prf.c monitor.c
-SRCS+= kbd.c ns16550.c vreset.c vga.c video.c
+ASRCS+= srt0.s
+CSRCS+= boot.c clock.c com.c conf.c cons.c cpu.c devopen.c
+CSRCS+= fd.c filesystem.c inkernel.c io.c tgets.c prf.c monitor.c
+CSRCS+= kbd.c ns16550.c vreset.c vga.c video.c
 
-CLEANFILES+= vers.c vers.o netbsd.gz ${BASE} elf2pef
+CLEANFILES+= vers.c vers.o netbsd.gz ${BASE} ${BOOTPROG} elf2pef
 
-CPPFLAGS= -I${.CURDIR}/../../.. -I${S} -I${S}/lib/libsa
-CPPFLAGS+= -DDBMONITOR -DRELOC=${RELOC} -DENTRY=${ENTRY}
+CPPFLAGS= -I${.CURDIR} -I${.CURDIR}/../../.. -I${S} -I${S}/lib/libsa
+CPPFLAGS+= -D_STANDALONE -DDBMONITOR -DRELOC=${RELOC} -DENTRY=${ENTRY}
+#CPPFLAGS+= -DUSE_SCAN
 #CPPFLAGS+= -DCONS_BE
-CPPFLAGS+= -DCONS_VGA
-#CPPFLAGS+= -DCONS_SERIAL
-#CPPFLAGS+= -DCOMSPEED=9600 -DCOMPORT=0x3F8
-#CPPFLAGS+= -DUSE_SCAN
+#CPPFLAGS+= -DCONS_VGA
+CPPFLAGS+= -DCONS_SERIAL -DCOMSPEED=9600 -DCOMPORT=0x3F8
 
+AOBJS= ${ASRCS:.s=.o}
+COBJS= ${CSRCS:.c=.o}
+OBJS=  ${AOBJS} ${COBJS}
 AFLAGS= -x assembler-with-cpp -traditional-cpp
 MKMAN= no
 STRIPFLAG=
@@ -28,6 +31,11 @@
 ENTRY= 0x3100
 RELOC= 0x700000
 
+CLEANFILES+= ${.OBJDIR}/machine ${.OBJDIR}/powerpc
+
+.BEGIN:
+       @[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine
+       @[ -h powerpc ] || ln -s ${S}/arch/powerpc/include powerpc
 
 KERNEL?= ${S}/arch/bebox/compile/GENERIC/netbsd
 
@@ -47,7 +55,9 @@
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=         ${SALIB}
 
-${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} elf2pef
+all: ${BOOTPROG}
+
+${BOOTPROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} elf2pef
        sh ${.CURDIR}/../newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
        ${COMPILE.c} vers.c
        ${LD} -o ${BASE} -s -N -T ld.script -Ttext ${RELOC} ${OBJS} \
@@ -59,7 +69,9 @@
        ${.CURDIR}/elf2pef ${BASE} $@
 .endif
 
+
 elf2pef: elf2pef.c pef.h
-       ${HOST_CC} -O -DENTRY=${ENTRY} -I${.CURDIR} -o $@ ${.CURDIR}/elf2pef.c
+       ${HOST_LINK.c} -I/usr/include -I${.CURDIR} \
+               -DENTRY=${ENTRY} -o ${.TARGET} ${.IMPSRC}
 
 .include <bsd.prog.mk>
diff -r b8c046f24691 -r 9d7371cfeadd sys/arch/bebox/stand/boot/boot.c
--- a/sys/arch/bebox/stand/boot/boot.c  Thu Jun 24 00:16:49 1999 +0000
+++ b/sys/arch/bebox/stand/boot/boot.c  Thu Jun 24 01:10:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.7 1999/04/17 21:16:46 ws Exp $      */
+/*     $NetBSD: boot.c,v 1.8 1999/06/24 01:10:31 sakamoto Exp $        */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -37,19 +37,7 @@
 #include <machine/cpu.h>
 #include <machine/param.h>
 #include <bebox/include/bootinfo.h>
-#include <bebox/include/bus.h>
-
-#ifdef CONS_SERIAL
-# include "ns16550.h"
-# ifndef COMPORT
-#  define COMPORT COM1
-# endif
-# ifndef COMSPEED
-#  define COMSPEED 9600
-# endif
-#endif /* CONS_SERIAL */
-
-#define NAMELEN        128
+#include "boot.h"
 
 char *name;
 char *names[] = {
@@ -60,6 +48,7 @@
 };
 #define NUMNAMES (sizeof (names) / sizeof (names[0]))
 
+#define NAMELEN        128
 char namebuf[NAMELEN];
 char nametmp[NAMELEN];
 int args;
@@ -73,6 +62,7 @@
 main()
 {
        int fd, n = 0;
+       int addr, speed;
        char *cnname;
        void *p;
        void start_CPU1();
@@ -86,39 +76,37 @@
        resetCPU1();
 
        /*
-        * pci init
-        */
-       pci_init();
-
-       /*
         * console init
         */
-       cnname = cninit();
+       cnname = cninit(&addr, &speed);
 
        /*
         * make bootinfo
         */
        bootinfo = (void *)0x3030;
 
+       /*
+        * memory
+        */
        btinfo_memory.common.next = sizeof (btinfo_memory);
        btinfo_memory.common.type = BTINFO_MEMORY;
        btinfo_memory.memsize = *(int *)0x3010;
 
+       /*
+        * console
+        */
        btinfo_console.common.next = sizeof (btinfo_console);
        btinfo_console.common.type = BTINFO_CONSOLE;
-       if (cnname)
-               strcpy(btinfo_console.devname, cnname);
-#if defined(CONS_BE) || defined(CONS_VGA)
-       btinfo_console.addr = BEBOX_BUS_SPACE_MEM;
-#endif
-#ifdef CONS_SERIAL
-       btinfo_console.addr = COMPORT;
-       btinfo_console.speed = COMSPEED;
-#endif /* CONS_SERIAL */
+       strcpy(btinfo_console.devname, cnname);
+       btinfo_console.addr = addr;
+       btinfo_console.speed = speed;
 
+       /*
+        * clock
+        */
        btinfo_clock.common.next = 0;
        btinfo_clock.common.type = BTINFO_CLOCK;
-       btinfo_clock.ticks_per_sec = findcpuspeed();
+       btinfo_clock.ticks_per_sec = TICKS_PER_SEC;
 
        p = bootinfo;
        bcopy((void *)&btinfo_memory, p, sizeof (btinfo_memory));
diff -r b8c046f24691 -r 9d7371cfeadd sys/arch/bebox/stand/boot/boot.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/bebox/stand/boot/boot.h  Thu Jun 24 01:10:31 1999 +0000
@@ -0,0 +1,4 @@
+/*     $NetBSD: boot.h,v 1.1 1999/06/24 01:10:31 sakamoto Exp $        */
+
+#define        TICKS_PER_SEC   (33000000 / 4)          /* 33MHz */
+#define        NS_PER_TICK     (1000000000 / TICKS_PER_SEC)
diff -r b8c046f24691 -r 9d7371cfeadd sys/arch/bebox/stand/boot/clock.c
--- a/sys/arch/bebox/stand/boot/clock.c Thu Jun 24 00:16:49 1999 +0000
+++ b/sys/arch/bebox/stand/boot/clock.c Thu Jun 24 01:10:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.4 1999/02/15 04:38:06 sakamoto Exp $       */
+/*     $NetBSD: clock.c,v 1.5 1999/06/24 01:10:31 sakamoto Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,10 +34,7 @@
 #include <sys/param.h>
 #include <dev/isa/isareg.h>
 #include <dev/ic/i8253reg.h>
-
-#define FIRST_GUESS    0x2000
-
-static u_long ns_per_tick;
+#include "boot.h"
 
 static inline u_quad_t
 mftb()
@@ -59,49 +56,11 @@
 {
        u_quad_t tb;
        u_long tbh, tbl, scratch;
-       
+
        tb = mftb();
-       tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick;
+       tb += (n * 1000 + NS_PER_TICK - 1) / NS_PER_TICK;
        tbh = tb >> 32;
        tbl = tb;
        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(IO_TIMER1 + TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
-       outb(IO_TIMER1 + TIMER_CNTR0, 0xff);    /* lo */
-       outb(IO_TIMER1 + TIMER_CNTR0, 0xff);    /* hi */
-       for (i = FIRST_GUESS; i; i--)
-               ;
-       /* Read the value left in the counter */
-       outb(IO_TIMER1 + TIMER_MODE, TIMER_SEL0|TIMER_LATCH);
-       remainder = inb(IO_TIMER1 + TIMER_CNTR0);
-       remainder += (inb(IO_TIMER1 + 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);
-}
diff -r b8c046f24691 -r 9d7371cfeadd sys/arch/bebox/stand/boot/cons.c
--- a/sys/arch/bebox/stand/boot/cons.c  Thu Jun 24 00:16:49 1999 +0000
+++ b/sys/arch/bebox/stand/boot/cons.c  Thu Jun 24 01:10:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.c,v 1.3 1998/10/28 02:47:35 sakamoto Exp $        */
+/*     $NetBSD: cons.c,v 1.4 1999/06/24 01:10:31 sakamoto Exp $        */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -43,7 +43,6 @@
  */
 
 #include <sys/param.h>
-#include <bebox/include/bus.h>
 #include "cons.h"
 
 #ifdef CONS_BE
@@ -59,31 +58,41 @@
 #ifdef CONS_SERIAL
 void siocnprobe(), siocninit(), siocnputchar();
 int siocngetchar(), siocnscan();
+# include "ns16550.h"
+# ifndef COMPORT
+#  define COMPORT COM1
+# endif
+# ifndef COMSPEED
+#  define COMSPEED 9600
+# endif
 #endif
 
 struct consdev constab[] = {
 #ifdef CONS_BE
-       { "be", becnprobe, becninit, becngetchar, becnputchar, becnscan },
+       { "be", 0xd0000000, 0,
+         becnprobe, becninit, becngetchar, becnputchar, becnscan },
 #endif
 #ifdef CONS_VGA
-       { "vga", vgacnprobe, vgacninit, vgacngetchar, vgacnputchar, vgacnscan },
+       { "vga", 0xc0000000, 0,
+         vgacnprobe, vgacninit, vgacngetchar, vgacnputchar, vgacnscan },
 #endif



Home | Main Index | Thread Index | Old Index