Subject: Bringing the PowerMac tree up to -current...
To: None <port-powerpc@NetBSD.ORG>
From: Charles M. Hannum <mycroft@mit.edu>
List: port-powerpc
Date: 02/24/1998 03:29:28
So I made the PowerMac kernel build in -current, stole the DDB support
from arch/powerpc (and fixed some bugs in it), and cleaned up the way
the OFW drivers were attached.  A diff between Tsubai's 980222 snapshot
and my tree is below.  (I also sent these patches to Tsubai).

As with Tsubai's 19980221 kernel, it still hangs at some point after
starting init(8).  I haven't yet determined why; I'll look at it again
later this week.

Once the hang is cleared up, I'd like to get this committed to the main
CVS tree.  There is still lots of work to do (like finishing the
bus_dma support, making am79c950.c MI, sharing the ADB code with the
mac68k port, ...), but it's certainly functional enough to be useful.


diff -rc2 powermac/conf/GENERIC /sys/arch/powermac/conf/GENERIC
*** powermac/conf/GENERIC	Fri Jan 30 23:50:30 1998
--- /sys/arch/powermac/conf/GENERIC	Tue Feb 24 00:46:58 1998
***************
*** 55,70 ****
  config		netbsd	root on ? type ?
  
! ofroot*		at root
  
! ofbus*		at openfirm?
  
! ofdisk*		at openfirm?
! 
! ofnet*		at openfirm?
  ipkdbif0	at ofnet?
  
! ofcons*		at openfirm?
  
! ofrtc*		at openfirm?
  
  pseudo-device	loop
--- 55,69 ----
  config		netbsd	root on ? type ?
  
! ofbus*		at mainbus?
! ofbus*		at ofbus?
  
! ofdisk*		at ofbus?
  
! ofnet*		at ofbus?
  ipkdbif0	at ofnet?
  
! ofcons*		at ofbus?
  
! ofrtc*		at ofbus?
  
  pseudo-device	loop
diff -rc2 powermac/conf/Makefile.powermac /sys/arch/powermac/conf/Makefile.powermac
*** powermac/conf/Makefile.powermac	Sun Feb 15 12:01:18 1998
--- /sys/arch/powermac/conf/Makefile.powermac	Sat Feb 21 18:26:31 1998
***************
*** 1,3 ****
- LD=ld27
  #	$NetBSD: Makefile.powermac,v 1.9.2.1 1997/11/12 23:45:50 thorpej Exp $
  #
--- 1,2 ----
diff -rc2 powermac/conf/OFCONS /sys/arch/powermac/conf/OFCONS
*** powermac/conf/OFCONS	Sat Feb 21 02:30:38 1998
--- /sys/arch/powermac/conf/OFCONS	Tue Feb 24 00:47:05 1998
***************
*** 66,75 ****
  sd*	at scsibus? target ? lun ?	# SCSI disks
  
! ofroot*		at mainbus0
! ofbus*		at openfirm?
! #ofdisk*	at openfirm?
! #ofnet*		at openfirm?
! ofcons*		at openfirm?
! #ofrtc*		at openfirm?
  
  pseudo-device	loop
--- 66,75 ----
  sd*	at scsibus? target ? lun ?	# SCSI disks
  
! ofbus*		at mainbus?
! ofbus*		at ofbus?
! #ofdisk*	at ofbus?
! #ofnet*		at ofbus?
! ofcons*		at ofbus?
! #ofrtc*		at ofbus?
  
  pseudo-device	loop
diff -rc2 powermac/conf/POWERMAC /sys/arch/powermac/conf/POWERMAC
*** powermac/conf/POWERMAC	Wed Feb 18 13:54:08 1998
--- /sys/arch/powermac/conf/POWERMAC	Tue Feb 24 00:47:10 1998
***************
*** 21,24 ****
--- 21,25 ----
  #options 	DEBUG
  options 	DIAGNOSTIC
+ options 	DDB
  options 	TRAP_PANICWAIT
  options		NMBCLUSTERS=1024
***************
*** 66,75 ****
  sd*	at scsibus? target ? lun ?	# SCSI disks
  
! #ofroot*	at mainbus0
! #ofbus*		at openfirm?
! #ofdisk*	at openfirm?
! #ofnet*		at openfirm?
! #ofcons*	at openfirm?
! #ofrtc*		at openfirm?
  
  pseudo-device	loop
--- 67,76 ----
  sd*	at scsibus? target ? lun ?	# SCSI disks
  
! ofbus*		at mainbus?
! #ofbus*		at ofbus?
! #ofdisk*	at ofbus?
! #ofnet*		at ofbus?
! #ofcons*	at ofbus?
! #ofrtc*		at ofbus?
  
  pseudo-device	loop
diff -rc2 powermac/conf/files.powermac /sys/arch/powermac/conf/files.powermac
*** powermac/conf/files.powermac	Sat Feb 21 02:42:26 1998
--- /sys/arch/powermac/conf/files.powermac	Mon Feb 23 22:59:21 1998
***************
*** 36,43 ****
--- 36,57 ----
  file	arch/powerpc/powerpc/trap.c
  file	dev/cons.c
+ file	dev/cninit.c				ofcons
+ file    arch/powerpc/powerpc/setjmp.S                   ddb
+ file    arch/powerpc/powerpc/db_memrw.c                 ddb
+ file    arch/powerpc/powerpc/db_disasm.c                ddb
+ file    arch/powerpc/powerpc/db_interface.c             ddb
+ file    arch/powerpc/powerpc/db_trace.c                 ddb
  
  # Firmworks OpenFirmware Bug Workarounds
  file	arch/powerpc/powerpc/ofwreal.S		firmworksbugs
  
+ 
+ #
+ # Generic OpenFirmware device support
+ #
+ include "dev/ofw/files.ofw"
+ major	{ofdisk = 0}
+ 
+ 
  #
  # Machine-independent SCSI drivers
***************
*** 48,56 ****
  major	{cd = 6}
  
  #
  # System bus types
  #
! define mainbus {}
! device	mainbus: pcibus, mainbus
  attach	mainbus at root
  file	arch/powermac/powermac/mainbus.c	mainbus
--- 62,71 ----
  major	{cd = 6}
  
+ 
  #
  # System bus types
  #
! define	mainbus {}
! device	mainbus: pcibus, mainbus, ofbus
  attach	mainbus at root
  file	arch/powermac/powermac/mainbus.c	mainbus
***************
*** 68,77 ****
  file	arch/powermac/pci/pchb.c		pchb
  
! device obio {}
! attach obio at pci
  file	arch/powermac/dev/obio.c		obio
  
! device esp: scsi, ncr53c9x
! attach esp at obio
  file	arch/powermac/dev/esp.c			esp
  
--- 83,92 ----
  file	arch/powermac/pci/pchb.c		pchb
  
! device	obio {}
! attach	obio at pci
  file	arch/powermac/dev/obio.c		obio
  
! device	esp: scsi, ncr53c9x
! attach	esp at obio
  file	arch/powermac/dev/esp.c			esp
  
***************
*** 81,142 ****
  file	arch/powermac/dev/am79c950.c		mc
  
! device zsc {channel = -1}
! attach zsc at obio
  file	arch/powermac/dev/zs.c	 		zsc needs-flag
  file	dev/ic/z8530sc.c			zsc
  
! device zstty: tty
! attach zstty at zsc
  file	dev/ic/z8530tty.c			zstty needs-flag
  
! device adb
! attach adb at obio
  file	arch/powermac/dev/adb.c			adb
  file	arch/powermac/dev/adb_direct.c		adb
- 
- 
- 
- 
- ##################################################
- #
- # We should use `include "dev/ofw/files.ofw"',
- # but `ofroot at root' ...
- 
- #
- # Openfirmware support
- #
- define	openfirm {}
- 
- # Generic disk support
- device	ofdisk: disk
- attach	ofdisk at openfirm
- file	dev/ofw/ofdisk.c		ofdisk needs-flag
- major	{ofdisk = 0}
- 
- # Generic net support
- define	ipkdbofn { [ disable = 0 ] }
- device	ofnet: ether, ifnet, ipkdbofn, arp
- attach	ofnet at openfirm
- file	dev/ofw/ofnet.c			ofnet | ipkdb_ofn needs-flag
- attach	ipkdbif at ipkdbofn with ipkdb_ofn
- 
- # Generic console support
- device	ofcons: tty
- attach	ofcons at openfirm
- file	dev/ofw/ofcons.c		ofcons needs-flag
- 
- # Generic RTC support
- device ofrtc
- attach	ofrtc at openfirm
- file	dev/ofw/ofrtc.c			ofrtc needs-flag
- 
- # Generic bus support
- device	ofbus: openfirm
- attach	ofbus at openfirm
- file	dev/ofw/ofbus.c			openfirm
- 
- device	ofroot: openfirm
- attach	ofroot at mainbus
- 
- file	dev/cninit.c			ofcons
- 
--- 96,110 ----
  file	arch/powermac/dev/am79c950.c		mc
  
! device	zsc {channel = -1}
! attach	zsc at obio
  file	arch/powermac/dev/zs.c	 		zsc needs-flag
  file	dev/ic/z8530sc.c			zsc
  
! device	zstty: tty
! attach	zstty at zsc
  file	dev/ic/z8530tty.c			zstty needs-flag
  
! device	adb
! attach	adb at obio
  file	arch/powermac/dev/adb.c			adb
  file	arch/powermac/dev/adb_direct.c		adb
diff -rc2 powermac/dev/am79c950.c /sys/arch/powermac/dev/am79c950.c
*** powermac/dev/am79c950.c	Mon Feb 16 07:35:32 1998
--- /sys/arch/powermac/dev/am79c950.c	Sat Feb 21 18:52:52 1998
***************
*** 101,108 ****
  static void mc_mediastatus __P((struct ifnet *, struct ifmediareq *));
  
- struct cfdriver mc_cd = {
- 	NULL, "mc", DV_IFNET
- };
- 
  /*
   * Compare two Ether/802 addresses for equality, inlined and
--- 101,104 ----
diff -rc2 powermac/dev/esp.c /sys/arch/powermac/dev/esp.c
*** powermac/dev/esp.c	Sat Feb 21 08:56:51 1998
--- /sys/arch/powermac/dev/esp.c	Mon Feb 23 20:57:18 1998
***************
*** 147,154 ****
  };
  
- struct cfdriver esp_cd = {
- 	NULL, "esp", DV_DULL
- };
- 
  struct scsipi_adapter esp_switch = {
  	ncr53c9x_scsi_cmd,
--- 147,150 ----
diff -rc2 powermac/dev/obio.c /sys/arch/powermac/dev/obio.c
*** powermac/dev/obio.c	Thu Feb 19 03:51:05 1998
--- /sys/arch/powermac/dev/obio.c	Sat Feb 21 18:53:11 1998
***************
*** 26,33 ****
  };
  
- struct cfdriver obio_cd = {
- 	NULL, "obio", DV_DULL
- };
- 
  int
  obio_match(parent, cf, aux)
--- 26,29 ----
diff -rc2 powermac/dev/zs.c /sys/arch/powermac/dev/zs.c
*** powermac/dev/zs.c	Thu Feb 19 08:15:14 1998
--- /sys/arch/powermac/dev/zs.c	Sat Feb 21 19:30:54 1998
***************
*** 164,176 ****
  
  struct zschan *
! zs_get_chan_addr(zs_unit, channel)
! 	int zs_unit, channel;
  {
  	struct zsdevice *addr;
  	struct zschan *zc;
  
! 	if (zs_unit >= 1)
  		return NULL;
! 	addr = zsaddr[zs_unit];
  	if (addr == NULL)
  		return NULL;
--- 164,176 ----
  
  struct zschan *
! zs_get_chan_addr(zsc_unit, channel)
! 	int zsc_unit, channel;
  {
  	struct zsdevice *addr;
  	struct zschan *zc;
  
! 	if (zsc_unit >= 1)
  		return NULL;
! 	addr = zsaddr[zsc_unit];
  	if (addr == NULL)
  		return NULL;
***************
*** 197,203 ****
  };
  
! struct cfdriver zsc_cd = {
! 	NULL, "zsc", DV_DULL
! };
  
  int zshard __P((void *));
--- 197,201 ----
  };
  
! extern struct cfdriver zsc_cd;
  
  int zshard __P((void *));
diff -rc2 powermac/include/bus.h /sys/arch/powermac/include/bus.h
*** powermac/include/bus.h	Thu Feb 12 11:30:01 1998
--- /sys/arch/powermac/include/bus.h	Sat Feb 21 18:48:51 1998
***************
*** 73,77 ****
   * Values for the Be bus space tag, not to be used directly by MI code.
   */
! /* #define	BEBOX_BUS_REVERSE	1 */
  
  /*
--- 73,77 ----
   * Values for the Be bus space tag, not to be used directly by MI code.
   */
! /* #define	POWERMAC_BUS_REVERSE	1 */
  
  /*
***************
*** 265,269 ****
  #define	BUS_DMA_NOWAIT		0x01	/* not safe to sleep */
  #define	BUS_DMA_ALLOCNOW	0x02	/* perform resource allocation now */
! #define	BUS_DMAMEM_NOSYNC	0x04	/* map memory to not require sync */
  #define	BUS_DMA_BUS1		0x10	/* placeholders for bus functions... */
  #define	BUS_DMA_BUS2		0x20
--- 265,269 ----
  #define	BUS_DMA_NOWAIT		0x01	/* not safe to sleep */
  #define	BUS_DMA_ALLOCNOW	0x02	/* perform resource allocation now */
! #define	BUS_DMA_COHERENT	0x04	/* hint: map memory DMA coherent */
  #define	BUS_DMA_BUS1		0x10	/* placeholders for bus functions... */
  #define	BUS_DMA_BUS2		0x20
***************
*** 276,292 ****
  
  /*
!  *	bus_dmasync_op_t
!  *
!  *	Operations performed by bus_dmamap_sync().
   */
! typedef enum {
! 	BUS_DMASYNC_PREREAD,
! 	BUS_DMASYNC_POSTREAD,
! 	BUS_DMASYNC_PREWRITE,
! 	BUS_DMASYNC_POSTWRITE,
! } bus_dmasync_op_t;
  
! typedef struct bebox_bus_dma_tag		*bus_dma_tag_t;
! typedef struct bebox_bus_dmamap		*bus_dmamap_t;
  
  /*
--- 276,288 ----
  
  /*
!  * Operations performed by bus_dmamap_sync().
   */
! #define	BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */
! #define	BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */
! #define	BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */
! #define	BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization */
  
! typedef struct powermac_bus_dma_tag	*bus_dma_tag_t;
! typedef struct powermac_bus_dmamap	*bus_dmamap_t;
  
  /*
***************
*** 296,304 ****
   *	are suitable for programming into DMA registers.
   */
! struct bebox_bus_dma_segment {
  	bus_addr_t	ds_addr;	/* DMA address */
  	bus_size_t	ds_len;		/* length of transfer */
  };
! typedef struct bebox_bus_dma_segment	bus_dma_segment_t;
  
  /*
--- 292,300 ----
   *	are suitable for programming into DMA registers.
   */
! struct powermac_bus_dma_segment {
  	bus_addr_t	ds_addr;	/* DMA address */
  	bus_size_t	ds_len;		/* length of transfer */
  };
! typedef struct powermac_bus_dma_segment	bus_dma_segment_t;
  
  /*
***************
*** 309,313 ****
   */
  
! struct bebox_bus_dma_tag {
  	void	*_cookie;		/* cookie used in the guts */
  
--- 305,309 ----
   */
  
! struct powermac_bus_dma_tag {
  	void	*_cookie;		/* cookie used in the guts */
  
***************
*** 328,332 ****
  	void	(*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
  	void	(*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
! 		    bus_dmasync_op_t));
  
  	/*
--- 324,328 ----
  	void	(*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
  	void	(*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
! 		    bus_addr_t, bus_size_t, int));
  
  	/*
***************
*** 358,364 ****
  #define	bus_dmamap_unload(t, p)					\
  	(*(t)->_dmamap_unload)((t), (p))
! #define	bus_dmamap_sync(t, p, o)				\
  	(void)((t)->_dmamap_sync ?				\
! 	    (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0)
  
  #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
--- 354,360 ----
  #define	bus_dmamap_unload(t, p)					\
  	(*(t)->_dmamap_unload)((t), (p))
! #define	bus_dmamap_sync(t, p, o, l, ops)			\
  	(void)((t)->_dmamap_sync ?				\
! 	    (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
  
  #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
***************
*** 378,382 ****
   *	Describes a DMA mapping.
   */
! struct bebox_bus_dmamap {
  	/*
  	 * PRIVATE MEMBERS: not for use my machine-independent code.
--- 374,378 ----
   *	Describes a DMA mapping.
   */
! struct powermac_bus_dmamap {
  	/*
  	 * PRIVATE MEMBERS: not for use my machine-independent code.
***************
*** 393,401 ****
  	 * PUBLIC MEMBERS: these are used by machine-independent code.
  	 */
  	int		dm_nsegs;	/* # valid segments in mapping */
  	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
  };
  
! #ifdef _BEBOX_BUS_DMA_PRIVATE
  int	_bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
  	    bus_size_t, int, bus_dmamap_t *));
--- 389,398 ----
  	 * PUBLIC MEMBERS: these are used by machine-independent code.
  	 */
+ 	bus_size_t	dm_mapsize;	/* size of the mapping */
  	int		dm_nsegs;	/* # valid segments in mapping */
  	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
  };
  
! #ifdef _POWERMAC_BUS_DMA_PRIVATE
  int	_bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
  	    bus_size_t, int, bus_dmamap_t *));
***************
*** 410,414 ****
  	    bus_dma_segment_t *, int, bus_size_t, int));
  void	_bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
! void	_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t));
  
  int	_bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
--- 407,412 ----
  	    bus_dma_segment_t *, int, bus_size_t, int));
  void	_bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
! void	_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
! 	    bus_size_t, int));
  
  int	_bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
***************
*** 428,431 ****
  	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
  	    vm_offset_t low, vm_offset_t high));
! #endif /* _BEBOX_BUS_DMA_PRIVATE */
  #endif /* _POWERMAC_BUS_H_ */
--- 426,430 ----
  	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
  	    vm_offset_t low, vm_offset_t high));
! #endif /* _POWERMAC_BUS_DMA_PRIVATE */
! 
  #endif /* _POWERMAC_BUS_H_ */
diff -rc2 powermac/include/powerpc.h /sys/arch/powermac/include/powerpc.h
*** powermac/include/powerpc.h	Fri Jan 31 07:20:17 1997
--- /sys/arch/powermac/include/powerpc.h	Mon Feb 23 22:49:10 1998
***************
*** 51,56 ****
  int dk_match __P((char *name));
  
- void ofrootfound __P((void));
- 
  extern	struct device *booted_device;
  extern	int booted_partition;
--- 51,54 ----
diff -rc2 powermac/include/types.h /sys/arch/powermac/include/types.h
*** powermac/include/types.h	Wed Nov  5 08:38:18 1997
--- /sys/arch/powermac/include/types.h	Sun Feb 22 20:30:15 1998
***************
*** 1,3 ****
! /*	$NetBSD: types.h,v 1.3.8.1 1997/11/05 04:39:19 thorpej Exp $	*/
  
  /*-
--- 1,3 ----
! /*	$NetBSD: types.h,v 1.5 1998/01/27 09:16:00 sakamoto Exp $	*/
  
  /*-
***************
*** 37,59 ****
  #include <sys/cdefs.h>
  
  #define	__BIT_TYPES_DEFINED__
! typedef	signed char		int8_t;
! typedef	unsigned char		u_int8_t;
! typedef	short			int16_t;
  typedef	unsigned short		u_int16_t;
! typedef	int			int32_t;
  typedef	unsigned int		u_int32_t;
  /* LONGLONG */
! typedef	long long		int64_t;
  /* LONGLONG */
  typedef	unsigned long long	u_int64_t;
  
  typedef	int32_t			register_t;
- 
- typedef	unsigned long		vm_size_t;
- typedef	unsigned long		vm_offset_t;
- 
- /* This is only to make some unneeded function declaration happy */
- #define	label_t	void
  
  #endif	/* _MACHTYPES_H_ */
--- 37,70 ----
  #include <sys/cdefs.h>
  
+ #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+ typedef struct _physadr {
+ 	int r[1];
+ } *physadr;
+ 
+ typedef struct label_t {
+         int val[40]; /* double check this XXX */
+ } label_t;
+ #endif
+ 
+ typedef	unsigned long	vm_offset_t;
+ typedef	unsigned long	vm_size_t;
+ 
+ /*
+  * Basic integral types.  Omit the typedef if
+  * not possible for a machine/compiler combination.
+  */
  #define	__BIT_TYPES_DEFINED__
! typedef	__signed char		   int8_t;
! typedef	unsigned char		 u_int8_t;
! typedef	short			  int16_t;
  typedef	unsigned short		u_int16_t;
! typedef	int			  int32_t;
  typedef	unsigned int		u_int32_t;
  /* LONGLONG */
! typedef	long long		  int64_t;
  /* LONGLONG */
  typedef	unsigned long long	u_int64_t;
  
  typedef	int32_t			register_t;
  
  #endif	/* _MACHTYPES_H_ */
diff -rc2 powermac/pci/pchb.c /sys/arch/powermac/pci/pchb.c
*** powermac/pci/pchb.c	Fri Feb  6 10:49:50 1998
--- /sys/arch/powermac/pci/pchb.c	Sat Feb 21 18:52:32 1998
***************
*** 56,63 ****
  };
  
- struct cfdriver pchb_cd = {
- 	NULL, "pchb", DV_DULL
- };
- 
  #define	PCI_PRODUCT_APPLE_BANDIT	1
  
--- 56,59 ----
diff -rc2 powermac/powermac/autoconf.c /sys/arch/powermac/powermac/autoconf.c
*** powermac/powermac/autoconf.c	Sat Feb 21 01:03:36 1998
--- /sys/arch/powermac/powermac/autoconf.c	Tue Feb 24 00:45:50 1998
***************
*** 52,56 ****
  
  struct devnametobdevmaj powermac_nam2blk[] = {
! 	{ "ofd",	0 },
  	{ "sd",		4 },
  #ifdef notyet
--- 52,56 ----
  
  struct devnametobdevmaj powermac_nam2blk[] = {
! 	{ "ofdisk",	0 },
  	{ "sd",		4 },
  #ifdef notyet
***************
*** 75,79 ****
  		panic("configure: mainbus not configured");
  
- 	/*ofrootfound();*/
  	(void)spl0();
  	cold = 0;
--- 75,78 ----
diff -rc2 powermac/powermac/conf.c /sys/arch/powermac/powermac/conf.c
*** powermac/powermac/conf.c	Sat Feb 21 02:48:20 1998
--- /sys/arch/powermac/powermac/conf.c	Tue Feb 24 00:45:04 1998
***************
*** 31,34 ****
--- 31,35 ----
   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
+ 
  #include <sys/param.h>
  #include <sys/buf.h>
***************
*** 40,44 ****
  
  #include "ofdisk.h"
! bdev_decl(ofd);
  bdev_decl(sw);
  #include "sd.h"
--- 41,45 ----
  
  #include "ofdisk.h"
! bdev_decl(ofdisk_);
  bdev_decl(sw);
  #include "sd.h"
***************
*** 50,54 ****
  
  struct bdevsw bdevsw[] = {
! 	bdev_disk_init(NOFDISK,ofd),	/* 0: Openfirmware disk */
  	bdev_swap_init(1,sw),		/* 1: swap pseudo device */
  	bdev_notdef(),			/* 2: */
--- 51,55 ----
  
  struct bdevsw bdevsw[] = {
! 	bdev_disk_init(NOFDISK,ofdisk_),/* 0: Openfirmware disk */
  	bdev_swap_init(1,sw),		/* 1: swap pseudo device */
  	bdev_notdef(),			/* 2: */
***************
*** 80,87 ****
  cdev_decl(sw);
  #include "ofcons.h"
! cdev_decl(ofc);
! cdev_decl(ofd);
  #include "ofrtc.h"
! cdev_decl(ofrtc);
  #include "bpfilter.h"
  cdev_decl(bpf);
--- 81,88 ----
  cdev_decl(sw);
  #include "ofcons.h"
! cdev_decl(ofcons_);
! cdev_decl(ofdisk_);
  #include "ofrtc.h"
! cdev_decl(ofrtc_);
  #include "bpfilter.h"
  cdev_decl(bpf);
***************
*** 111,117 ****
  	cdev_log_init(1,log),		/* 5: /dev/klog */
  	cdev_swap_init(1,sw),		/* 6: /dev/drum pseudo device */
! 	cdev_tty_init(NOFCONS,ofc),	/* 7: Openfirmware console */
! 	cdev_disk_init(NOFDISK,ofd),	/* 8: Openfirmware disk */
! 	cdev_rtc_init(NOFRTC,ofrtc),	/* 9: Openfirmware RTC */
  	cdev_bpftun_init(NBPFILTER,bpf),/* 10: Berkeley packet filter */
  	cdev_rnd_init(NRND,rnd),	/* 11: random source pseudo-device */
--- 112,118 ----
  	cdev_log_init(1,log),		/* 5: /dev/klog */
  	cdev_swap_init(1,sw),		/* 6: /dev/drum pseudo device */
! 	cdev_tty_init(NOFCONS,ofcons_),	/* 7: Openfirmware console */
! 	cdev_disk_init(NOFDISK,ofdisk_),/* 8: Openfirmware disk */
! 	cdev_rtc_init(NOFRTC,ofrtc_),	/* 9: Openfirmware RTC */
  	cdev_bpftun_init(NBPFILTER,bpf),/* 10: Berkeley packet filter */
  	cdev_rnd_init(NRND,rnd),	/* 11: random source pseudo-device */
***************
*** 198,208 ****
  	return makedev(major, minor(dev));
  }
  #if NOFCONS > 0
  #include <dev/cons.h>
  
! cons_decl(ofc);
  
  struct consdev constab[] = {
! 	cons_init(ofc),
  	{ 0 },
  };
--- 199,210 ----
  	return makedev(major, minor(dev));
  }
+ 
  #if NOFCONS > 0
  #include <dev/cons.h>
  
! cons_decl(ofcons_);
  
  struct consdev constab[] = {
! 	cons_init(ofcons_),
  	{ 0 },
  };
diff -rc2 powermac/powermac/cpu.c /sys/arch/powermac/powermac/cpu.c
*** powermac/powermac/cpu.c	Fri Feb 20 14:25:59 1998
--- /sys/arch/powermac/powermac/cpu.c	Sun Feb 22 23:46:52 1998
***************
*** 13,19 ****
  };
  
! struct cfdriver cpu_cd = {
! 	NULL, "cpu", DV_DULL
! };
  
  extern void *mapiodev();
--- 13,17 ----
  };
  
! extern struct cfdriver cpu_cd;
  
  extern void *mapiodev();
diff -rc2 powermac/powermac/locore.S /sys/arch/powermac/powermac/locore.S
*** powermac/powermac/locore.S	Mon Feb  9 10:36:44 1998
--- /sys/arch/powermac/powermac/locore.S	Sun Feb 22 21:13:56 1998
***************
*** 789,792 ****
--- 789,812 ----
  _C_LABEL(tlbdsmsize) = .-_C_LABEL(tlbdsmiss)
  
+ #ifdef DDB
+ #define	ddbsave	0xde0		/* primary save area for DDB */
+ /*
+  * In case of DDB we want a separate trap catcher for it
+  */
+ 	.local	ddbstk
+ 	.comm	ddbstk,INTSTK,8		/* ddb stack */
+ 
+ 	.globl	_C_LABEL(ddblow),_C_LABEL(ddbsize)
+ _C_LABEL(ddblow):
+ 	mtsprg	1,1			/* save SP */
+ 	stmw	28,ddbsave(0)		/* free r28-r31 */
+ 	mflr	28			/* save LR */
+ 	mfcr	29			/* save CR */
+ 	lis	1,ddbstk+INTSTK@ha	/* get new SP */
+ 	addi	1,1,ddbstk+INTSTK@l
+ 	bla	ddbtrap
+ _C_LABEL(ddbsize) = .-_C_LABEL(ddblow)
+ #endif	/* DDB */
+ 
  #if NIPKDB > 0
  #define	ipkdbsave	0xde0		/* primary save area for IPKDB */
***************
*** 1171,1174 ****
--- 1191,1239 ----
  	bl	_C_LABEL(decr_intr)
  	b	intr_exit
+ 
+ #ifdef DDB
+ /*
+  * Deliberate entry to ddbtrap
+  */
+ 	.globl	_C_LABEL(ddb_trap)
+ _C_LABEL(ddb_trap):
+ 	mtsprg	1,1
+ 	mfmsr	3
+ 	mtsrr1	3
+ 	andi.	3,3,~(PSL_EE|PSL_ME)@l
+ 	mtmsr	3			/* disable interrupts */
+ 	isync
+ 	stmw	28,ddbsave(0)
+ 	mflr	28
+ 	li	29,EXC_BPT
+ 	mtlr	29
+ 	mfcr	29
+ 	mtsrr0	28
+ 
+ /*
+  * Now the ddb trap catching code.
+  */
+ ddbtrap:
+ 	FRAME_SETUP(ddbsave)
+ /* Call C trap code: */
+ 	addi	3,1,8
+ 	bl	_C_LABEL(ddb_trap_glue)
+ 	or.	3,3,3
+ 	bne	ddbleave
+ /* This wasn't for DDB, so switch to real trap: */
+ 	lwz	3,FRAME_EXC+8(1)	/* save exception */
+ 	stw	3,ddbsave+8(0)
+ 	FRAME_LEAVE(ddbsave)
+ 	mtsprg	1,1			/* prepare for entrance to realtrap */
+ 	stmw	28,tempsave(0)
+ 	mflr	28
+ 	mfcr	29
+ 	lwz	31,ddbsave+8(0)
+ 	mtlr	31
+ 	b	realtrap
+ ddbleave:
+ 	FRAME_LEAVE(ddbsave)
+ 	rfi
+ #endif /* DDB */
  
  #if NIPKDB > 0
diff -rc2 powermac/powermac/mainbus.c /sys/arch/powermac/powermac/mainbus.c
*** powermac/powermac/mainbus.c	Fri Feb 20 10:44:33 1998
--- /sys/arch/powermac/powermac/mainbus.c	Tue Feb 24 00:23:11 1998
***************
*** 49,55 ****
  };
  
! struct cfdriver mainbus_cd = {
! 	NULL, "mainbus", DV_DULL
! };
  
  static struct bandit_addr bandit_f2, bandit_f4;
--- 49,53 ----
  };
  
! extern struct cfdriver mainbus_cd;
  
  static struct bandit_addr bandit_f2, bandit_f4;
***************
*** 77,83 ****
  	void *aux;
  {
  	struct pcibus_attach_args pba;
  	struct confargs ca;
- 	struct ofprobe probe;
  	int node;
  
--- 75,81 ----
  	void *aux;
  {
+ 	struct ofbus_attach_args oba;
  	struct pcibus_attach_args pba;
  	struct confargs ca;
  	int node;
  
***************
*** 88,94 ****
  	node = OF_peer(0);
  	if (node) {
! 		probe.name = "";
! 		probe.phandle = node;
! 		config_found(self, &probe, NULL);
  	}
  
--- 86,92 ----
  	node = OF_peer(0);
  	if (node) {
! 		oba.oba_busname = "ofw";
! 		oba.oba_phandle = node;
! 		config_found(self, &oba, NULL);
  	}
  
diff -rc2 powermac/powermac/vm_machdep.c /sys/arch/powermac/powermac/vm_machdep.c
*** powermac/powermac/vm_machdep.c	Fri Feb 13 09:30:44 1998
--- /sys/arch/powermac/powermac/vm_machdep.c	Sat Feb 21 18:40:12 1998
***************
*** 62,66 ****
  	*pcb = p1->p_addr->u_pcb;
  	
! 	pcb->pcb_pm = &p2->p_vmspace->vm_pmap;
  	pcb->pcb_pmreal = (struct pmap *)pmap_extract(pmap_kernel(), (vm_offset_t)pcb->pcb_pm);
  	
--- 62,66 ----
  	*pcb = p1->p_addr->u_pcb;
  	
! 	pcb->pcb_pm = p2->p_vmspace->vm_map.pmap;
  	pcb->pcb_pmreal = (struct pmap *)pmap_extract(pmap_kernel(), (vm_offset_t)pcb->pcb_pm);
  	
diff -rc2 powermac/stand/Makefile.inc /sys/arch/powermac/stand/Makefile.inc
*** powermac/stand/Makefile.inc	Sun Feb 22 09:36:53 1998
--- /sys/arch/powermac/stand/Makefile.inc	Mon Jan 26 01:44:47 1998
***************
*** 3,7 ****
  BINDIR=		/usr/mdec
  
! CPPFLAGS+=	-DSTANDALONE
  
  CFLAGS+=	-msoft-float
--- 3,7 ----
  BINDIR=		/usr/mdec
  
! CPPFLAGS+=	-DSTANDALONE -D_STANDALONE
  
  CFLAGS+=	-msoft-float
*** /dev/null	Tue Feb 24 02:19:04 1998
--- /sys/arch/powermac/include/db_machdep.h	Sun Feb 22 21:56:47 1998
***************
*** 0 ****
--- 1,101 ----
+ /*	$OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $	*/
+ /*	$NetBSD: db_machdep.h,v 1.1 1998/01/27 15:13:09 sakamoto Exp $	*/
+ 
+ /* 
+  * Mach Operating System
+  * Copyright (c) 1992 Carnegie Mellon University
+  * All Rights Reserved.
+  * 
+  * Permission to use, copy, modify and distribute this software and its
+  * documentation is hereby granted, provided that both the copyright
+  * notice and this permission notice appear in all copies of the
+  * software, derivative works or modified versions, and any portions
+  * thereof, and that both notices appear in supporting documentation.
+  * 
+  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+  * 
+  * Carnegie Mellon requests users of this software to return to
+  * 
+  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+  *  School of Computer Science
+  *  Carnegie Mellon University
+  *  Pittsburgh PA 15213-3890
+  * 
+  * any improvements or extensions that they make and grant Carnegie Mellon 
+  * the rights to redistribute these changes.
+  */
+ 
+ /*
+  * Machine-dependent defines for new kernel debugger.
+  */
+ #ifndef	_PPC_DB_MACHDEP_H_
+ #define	_PPC_DB_MACHDEP_H_
+ 
+ #include <vm/vm_prot.h>
+ #include <vm/vm_param.h>
+ #include <vm/vm_inherit.h>
+ #include <machine/trap.h>
+ 
+ #define	DB_ELF_SYMBOLS
+ #define	DB_ELFSIZE	32
+ 
+ typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
+ typedef	int		db_expr_t;	/* expression - signed */
+ struct powerpc_saved_state {
+ 	u_int32_t	r[32];		/* data registers */
+ 	u_int32_t	iar;
+ 	u_int32_t	msr;
+ };
+ typedef struct powerpc_saved_state db_regs_t;
+ db_regs_t	ddb_regs;		/* register state */
+ #define DDB_REGS	(&ddb_regs)
+ 
+ #define	PC_REGS(regs)	((db_addr_t)(regs)->iar)
+ 
+ #define	BKPT_INST	0x7C810808	/* breakpoint instruction */
+ 
+ #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
+ #define	BKPT_SET(inst)	(BKPT_INST)
+ 
+ #define	FIXUP_PC_AFTER_BREAK(regs)	((regs)->iar -= 4)
+ 
+ #define SR_SINGLESTEP	0x400
+ #define	db_clear_single_step(regs)	((regs)->msr &= ~SR_SINGLESTEP)
+ #define	db_set_single_step(regs)	((regs)->msr |=  SR_SINGLESTEP)
+ 
+ #define T_BREAKPOINT	0xffff
+ #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
+ 
+ #define T_WATCHPOINT	0xeeee
+ #ifdef T_WATCHPOINT
+ #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
+ #else
+ #define	IS_WATCHPOINT_TRAP(type, code)	0
+ #endif
+ 
+ #define	M_RTS		0xfc0007fe
+ #define I_RTS		0x4c000020
+ #define M_BC		0xfc000000
+ #define I_BC		0x40000000
+ #define M_B		0xfc000000
+ #define I_B		0x50000000
+ #define	M_RFI		0xfc0007fe
+ #define	I_RFI		0x4c000064
+ 
+ #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
+ #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
+ #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
+ 				 ((ins)&M_B  ) == I_B )
+ #define inst_load(ins)		0
+ #define inst_store(ins)		0
+ 
+ #ifdef _KERNEL
+ 
+ void	kdb_kintr __P((void *));
+ int	kdb_trap __P((int, void *));
+ 
+ #endif /* _KERNEL */
+ 
+ #endif	/* _PPC_DB_MACHDEP_H_ */