Port-powerpc archive

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

new evbppc console



Hi!


I wrote new evbppc console for MI/MD.
How is it?

--
kiyohara
Index: arch/evbppc/evbppc/evbppc_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/evbppc/evbppc_machdep.c,v
retrieving revision 1.4
diff -c -r1.4 evbppc_machdep.c
*** arch/evbppc/evbppc/evbppc_machdep.c 2003/07/25 11:44:19     1.4
--- arch/evbppc/evbppc/evbppc_machdep.c 2004/01/12 11:52:56
***************
*** 79,85 ****
--- 79,88 ----
  #include <machine/cpu.h>
  #include <machine/bus.h>
  #include <machine/pmap.h>
+ #include <machine/autoconf.h>
  
+ #include <powerpc/ibm4xx/dev/opbvar.h>
+ 
  int fake_mapiodev = 1;
  
  /*
***************
*** 115,118 ****
--- 118,139 ----
        }
        pmap_update(pmap_kernel());
        return (void *)(va + off);
+ }
+ 
+ /*
+  * consinit:
+  * initialize the system console.
+  * XXX - shouldn't deal with this initted thing, but then,
+  * it shouldn't be called from initppc either.
+  */
+ void
+ consinit()
+ {
+       (*consinit_machdep)();
+ }
+ 
+ void
+ generic_cnattach(int conspeed, int com_freq, int comcnmode)
+ {
+       com_opb_cnattach(conspeed, com_freq, comcnmode);
  }
Index: arch/evbppc/obs405/consinit.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/obs405/consinit.c,v
retrieving revision 1.1
diff -c -r1.1 consinit.c
*** arch/evbppc/obs405/consinit.c       2003/09/23 14:45:14     1.1
--- arch/evbppc/obs405/consinit.c       2004/01/12 11:52:57
***************
*** 29,61 ****
  #include <sys/cdefs.h>
  __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.1 2003/09/23 14:45:14 shige Exp 
$");
  
- #include "opt_kgdb.h"
- 
  #include <sys/param.h>
  #include <sys/systm.h>
  #include <sys/device.h>
  #include <machine/bus.h>
  
- #include <powerpc/ibm4xx/ibm405gp.h>
- #include <powerpc/ibm4xx/dev/opbvar.h>
- 
- #include "com.h"
- #if (NCOM > 0)
- #include <sys/termios.h>
  #include <dev/ic/comreg.h>
- #include <dev/ic/comvar.h>
- #endif
- 
- #include <dev/cons.h>
- 
- #ifndef CONSDEVNAME
- #define CONSDEVNAME "com"
- #endif
  
- #if (NCOM > 0)
- #ifndef CONADDR
- #define CONADDR IBM405GP_UART0_BASE
- #endif
  #ifndef CONSPEED
  #define CONSPEED B9600        /*  */
  // #define CONSPEED B115200   /* 9600 is too slow for my taste */
--- 29,44 ----
  #include <sys/cdefs.h>
  __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.1 2003/09/23 14:45:14 shige Exp 
$");
  
  #include <sys/param.h>
  #include <sys/systm.h>
  #include <sys/device.h>
+ #include <sys/termios.h>
  #include <machine/bus.h>
+ #include <machine/autoconf.h>
+ #include <machine/obs405.h>
  
  #include <dev/ic/comreg.h>
  
  #ifndef CONSPEED
  #define CONSPEED B9600        /*  */
  // #define CONSPEED B115200   /* 9600 is too slow for my taste */
***************
*** 63,139 ****
  #ifndef CONMODE
  #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
  #endif
- int comcnmode = CONMODE;
- #endif /* NCOM */
- 
- #ifdef KGDB
- #ifndef KGDB_DEVNAME
- #define KGDB_DEVNAME "com"
- #endif
- char kgdb_devname[] = KGDB_DEVNAME;
- 
- #if (NCOM > 1)
- #ifndef KGDB_DEVADDR
- #define KGDB_DEVADDR  UART1_BASE
- #endif
- int comkgdbaddr = KGDB_DEVADDR;
- 
- #ifndef KGDB_DEVRATE
- #define KGDB_DEVRATE CONSPEED
- #endif
- int comkgdbrate = KGDB_DEVRATE;
- 
- #ifndef KGDB_DEVMODE
- #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 
8N1 */
- #endif
- int comkgdbmode = KGDB_DEVMODE;
- 
- #endif /* NCOM */
  
- #endif /* KGDB */
  
- /*
-  * consinit:
-  * initialize the system console.
-  * XXX - shouldn't deal with this initted thing, but then,
-  * it shouldn't be called from initppc either.
-  */
  void
! consinit(void)
  {
!       static int initted = 0;
! #if (NCOM > 0)
!       bus_space_tag_t tag;
! #endif
! 
!       if (initted)
!               return;
!       initted = 1;
! 
! #if (NCOM > 0)
!       /* We *know* the com-console attaches to opb */
!       tag = opb_get_bus_space_tag();
  
!       if (comcnattach(tag, CONADDR, CONSPEED, COM_FREQ*4,
!           COM_TYPE_NORMAL, comcnmode))
!               panic("can't init serial console @%x", CONADDR);
!       else
!               return;
! #endif
!       panic("console device missing -- serial console not in kernel");
!       /* Of course, this is moot if there is no console... */
  }
- 
- #ifdef KGDB
- void
- kgdb_port_init(void)
- {
- #if (NCOM > 0)
-       if(!strcmp(kgdb_devname, "com")) {
-               bus_space_tag_t tag = opb_get_bus_space_tag();
-               com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ * 4,
-                   COM_TYPE_NORMAL, comkgdbmode);
-       }
- #endif
- }
- #endif
--- 46,57 ----
  #ifndef CONMODE
  #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
  #endif
  
  
  void
! consinit_obs405(void)
  {
!       com_freq = COM_FREQ * 4;
  
!       generic_cnattach(CONSPEED, com_freq, CONMODE);
  }
Index: arch/evbppc/obs405/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/obs405/machdep.c,v
retrieving revision 1.1
diff -c -r1.1 machdep.c
*** arch/evbppc/obs405/machdep.c        2003/09/23 14:45:14     1.1
--- arch/evbppc/obs405/machdep.c        2004/01/12 11:52:57
***************
*** 100,105 ****
--- 100,107 ----
  #include <machine/bus.h>
  #include <machine/trap.h>
  #include <machine/powerpc.h>
+ #include <machine/autoconf.h>
+ #include <machine/obs405.h>
  #include <powerpc/spr.h>
  #include <powerpc/ibm4xx/dcr405gp.h>
  
***************
*** 129,134 ****
--- 131,137 ----
  
        ibm4xx_init_board_data(info_block, startkernel);
  
+       consinit_machdep = consinit_obs405;
        ibm4xx_init((void (*)(void))ext_intr);
  
        /*
Index: arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c,v
retrieving revision 1.1
diff -c -r1.1 ibm4xxgpx_autoconf.c
*** arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c    2003/09/24 11:47:02     1.1
--- arch/powerpc/ibm4xx/ibm4xxgpx_autoconf.c    2004/01/12 11:53:04
***************
*** 46,51 ****
--- 46,52 ----
  
  struct device *booted_device;
  int booted_partition;
+ int com_freq;
  
  /*
   * List of port-specific devices to attach to the processor local bus.
***************
*** 101,110 ****
        if (strcmp(dev->dv_cfdata->cf_name, "com") == 0 &&
            strcmp(parent->dv_cfdata->cf_name, "opb") == 0) {
                /* Set the frequency of the on-chip UART. */
-               int freq = COM_FREQ * 6;
- 
                if (prop_set(dev_propdb, dev, "frequency",
!                            &freq, sizeof(freq), PROP_INT, 0) != 0)
                        printf("WARNING: unable to set frequency "
                            "property for %s\n", dev->dv_xname);
                return;
--- 102,109 ----
        if (strcmp(dev->dv_cfdata->cf_name, "com") == 0 &&
            strcmp(parent->dv_cfdata->cf_name, "opb") == 0) {
                /* Set the frequency of the on-chip UART. */
                if (prop_set(dev_propdb, dev, "frequency",
!                            &com_freq, sizeof(com_freq), PROP_INT, 0) != 0)
                        printf("WARNING: unable to set frequency "
                            "property for %s\n", dev->dv_xname);
                return;
Index: arch/powerpc/ibm4xx/dev/com_opb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/dev/com_opb.c,v
retrieving revision 1.11
diff -c -r1.11 com_opb.c
*** arch/powerpc/ibm4xx/dev/com_opb.c   2003/07/15 02:54:44     1.11
--- arch/powerpc/ibm4xx/dev/com_opb.c   2004/01/12 11:53:04
***************
*** 38,43 ****
--- 38,45 ----
  #include <sys/cdefs.h>
  __KERNEL_RCSID(0, "$NetBSD: com_opb.c,v 1.11 2003/07/15 02:54:44 lukem Exp 
$");
  
+ #include "opt_kgdb.h"
+ 
  #include <sys/param.h>
  #include <sys/device.h>
  #include <sys/tty.h>
***************
*** 47,57 ****
--- 49,100 ----
  
  #include <machine/cpu.h>
  
+ #include <powerpc/ibm4xx/ibm405gp.h>
  #include <powerpc/ibm4xx/dev/opbvar.h>
  
+ #include <dev/cons.h>
  #include <dev/ic/comreg.h>
  #include <dev/ic/comvar.h>
  
+ #include "com.h"
+ 
+ #ifndef CONSDEVNAME
+ #define CONSDEVNAME "com"
+ #endif
+ 
+ #if (NCOM > 0)
+ #ifndef CONADDR
+ #define CONADDR IBM405GP_UART0_BASE
+ #endif
+ #endif /* NCOM */
+ 
+ #ifdef KGDB
+ #ifndef KGDB_DEVNAME
+ #define KGDB_DEVNAME "com"
+ #endif
+ char kgdb_devname[] = KGDB_DEVNAME;
+ 
+ #if (NCOM > 1)
+ #ifndef KGDB_DEVADDR
+ #define KGDB_DEVADDR  UART1_BASE
+ #endif
+ int comkgdbaddr = KGDB_DEVADDR;
+ 
+ #ifndef KGDB_DEVRATE
+ #define KGDB_DEVRATE CONSPEED
+ #endif
+ int comkgdbrate = KGDB_DEVRATE;
+ 
+ #ifndef KGDB_DEVMODE
+ #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 
8N1
+ */
+ #endif
+ int comkgdbmode = KGDB_DEVMODE;
+ 
+ #endif /* NCOM */
+ 
+ #endif /* KGDB */
+ 
  struct com_opb_softc {
        struct com_softc sc_com;
        void *sc_ih;
***************
*** 63,68 ****
--- 106,137 ----
  CFATTACH_DECL(com_opb, sizeof(struct com_opb_softc),
      com_opb_probe, com_opb_attach, NULL, NULL);
  
+ void
+ com_opb_cnattach(int conspeed, int com_freq, int comcnmode)
+ {
+       static int initted = 0;
+ #if (NCOM > 0)
+       bus_space_tag_t tag;
+ #endif
+ 
+       if (initted)
+               return;
+       initted = 1;
+ 
+ #if (NCOM > 0)
+       /* We *know* the com-console attaches to opb */
+       tag = opb_get_bus_space_tag();
+ 
+       if (comcnattach(
+           tag, CONADDR, conspeed, com_freq, COM_TYPE_NORMAL, comcnmode))
+               panic("can't init serial console @%x", CONADDR);
+       else
+               return;
+ #endif
+       panic("console device missing -- serial console not in kernel");
+       /* Of course, this is moot if there is no console... */
+ }
+ 
  int
  com_opb_probe(struct device *parent, struct cfdata *cf, void *aux)
  {
***************
*** 100,102 ****
--- 169,185 ----
  
        intr_establish(oaa->opb_irq, IST_LEVEL, IPL_SERIAL, comintr, sc);
  }
+ 
+ #ifdef KGDB
+ void
+ kgdb_port_init(void)
+ {
+ #if (NCOM > 0)
+       if(!strcmp(kgdb_devname, "com")) {
+               bus_space_tag_t tag = opb_get_bus_space_tag();
+               com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, com_freq,
+                   COM_TYPE_NORMAL, comkgdbmode);
+       }
+ #endif
+ }
+ #endif
Index: arch/powerpc/ibm4xx/dev/opbvar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/dev/opbvar.h,v
retrieving revision 1.2
diff -c -r1.2 opbvar.h
*** arch/powerpc/ibm4xx/dev/opbvar.h    2003/07/25 10:12:44     1.2
--- arch/powerpc/ibm4xx/dev/opbvar.h    2004/01/12 11:53:05
***************
*** 47,49 ****
--- 47,51 ----
  
  /* For use before opb_attach() is called */
  extern bus_space_tag_t opb_get_bus_space_tag(void);
+ 
+ void com_opb_cnattach(int, int, int);
/*      $NetBSD$        */

/*
 * Copyright (c) 2003
 *     KIYOHARA Takashi.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _EVBPPC_AUTOCONF_H_
#define _EVBPPC_AUTOCONF_H_

void (*consinit_machdep) __P((void));
void generic_cnattach(int, int, int);

extern int com_freq;

#endif  /* _EVBPPC_AUTOCONF_H_ */
/*      $NetBSD$        */

/*
 * Copyright (c) 2003
 *     KIYOHARA Takashi.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _OBS405_H
#define _OBS405_H

void consinit_obs405(void);

#endif  /* _OBS405_H */


Home | Main Index | Thread Index | Old Index