summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-04 20:39:07 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-04 20:39:07 +0000
commitb5304bb58ccc8685d27ff0f96701bb1cb258a6b9 (patch)
tree4a5df4ff90f4b17e9461da71efb1bb18e882b5a2 /sys/arch
parent15d15e3ad69f61e77c02fed009906131becd759f (diff)
Import NetBSD's direct adb code on mac68k, switching to real keyboard and mouse
drivers, and to wscons as the console; a few parts borrowed from OpenBSD/macppc as well. Currently only working with displays configured in 1bpp or 8bpp modes; this limitation will be worked on ASAP. Tested by claudio@ kettenis@ martin@ nick@ and I on various models. X11 changes coming soon.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/mac68k/conf/GENERIC60
-rw-r--r--sys/arch/mac68k/conf/RAMDISK45
-rw-r--r--sys/arch/mac68k/conf/files.mac68k40
-rw-r--r--sys/arch/mac68k/dev/6x10.h1416
-rw-r--r--sys/arch/mac68k/dev/adb.c660
-rw-r--r--sys/arch/mac68k/dev/adb_direct.c2220
-rw-r--r--sys/arch/mac68k/dev/adbsys.c315
-rw-r--r--sys/arch/mac68k/dev/adbsysasm.s74
-rw-r--r--sys/arch/mac68k/dev/adbvar.h92
-rw-r--r--sys/arch/mac68k/dev/akbd.c536
-rw-r--r--sys/arch/mac68k/dev/akbdmap.h431
-rw-r--r--sys/arch/mac68k/dev/akbdvar.h71
-rw-r--r--sys/arch/mac68k/dev/ams.c535
-rw-r--r--sys/arch/mac68k/dev/amsvar.h67
-rw-r--r--sys/arch/mac68k/dev/grf.c315
-rw-r--r--sys/arch/mac68k/dev/grf_iv.c26
-rw-r--r--sys/arch/mac68k/dev/grf_mv.c26
-rw-r--r--sys/arch/mac68k/dev/grf_subr.c9
-rw-r--r--sys/arch/mac68k/dev/grfvar.h58
-rw-r--r--sys/arch/mac68k/dev/ite.c1345
-rw-r--r--sys/arch/mac68k/dev/macfb.c359
-rw-r--r--sys/arch/mac68k/dev/macfbvar.h (renamed from sys/arch/mac68k/dev/itevar.h)66
-rw-r--r--sys/arch/mac68k/dev/pm_direct.c806
-rw-r--r--sys/arch/mac68k/dev/pm_direct.h10
-rw-r--r--sys/arch/mac68k/include/adbsys.h90
-rw-r--r--sys/arch/mac68k/include/grfioctl.h76
-rw-r--r--sys/arch/mac68k/include/iteioctl.h53
-rw-r--r--sys/arch/mac68k/include/keyboard.h279
-rw-r--r--sys/arch/mac68k/mac68k/autoconf.c13
-rw-r--r--sys/arch/mac68k/mac68k/conf.c34
-rw-r--r--sys/arch/mac68k/mac68k/locore.s13
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c162
-rw-r--r--sys/arch/mac68k/mac68k/macrom.c13
-rw-r--r--sys/arch/mac68k/mac68k/macrom.h4
-rw-r--r--sys/arch/mac68k/mac68k/pmap_bootstrap.c10
-rw-r--r--sys/arch/mac68k/mac68k/pram.c13
-rw-r--r--sys/arch/mac68k/mac68k/trap.c8
-rw-r--r--sys/arch/mac68k/mac68k/via.c19
-rw-r--r--sys/arch/mac68k/mac68k/wscons_machdep.c117
39 files changed, 4644 insertions, 5842 deletions
diff --git a/sys/arch/mac68k/conf/GENERIC b/sys/arch/mac68k/conf/GENERIC
index a53c3695511..902dda0f2f5 100644
--- a/sys/arch/mac68k/conf/GENERIC
+++ b/sys/arch/mac68k/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.41 2005/08/03 02:10:44 dlg Exp $
+# $OpenBSD: GENERIC,v 1.42 2006/01/04 20:39:04 miod Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -21,38 +21,42 @@ option M68020 # Must have 68851 PMMU
option FPSP
option FPU_EMULATE
option COMPAT_SUNOS # SunOS m68k binary compatibility
-option DISABLE_ADB_WITH_SERIAL_CONSOLE
#option MRG_ADB # Use ROM-based ADB driver
+option WSDISPLAY_COMPAT_RAWKBD
config bsd swap generic
-mainbus0 at root
+mainbus0 at root
# on-board I/O
-obio0 at mainbus?
+obio0 at mainbus?
-adb0 at obio?
-asc0 at obio? # ASC/EASC audio
-esp0 at obio? # SCSI NCR 53C9x
-esp1 at obio? # SCSI NCR 53C9x
-intvid0 at obio? # Internal video hardware
-mc* at obio? # MACE ethernet on Centris/Quadra 660av
-sn* at obio? # Internal ethernet
-zsc0 at obio? # Zilog serial chip
-zstty* at zsc?
+adb0 at obio?
+akbd* at adb? # ADB keyboard
+ams* at adb? # ADB mouse
+asc0 at obio? # ASC/EASC audio
+esp0 at obio? # SCSI NCR 53C9x
+esp1 at obio? # SCSI NCR 53C9x
+intvid0 at obio? # Internal video hardware
+mc* at obio? # MACE ethernet on Centris/Quadra 660av
+sn* at obio? # Internal ethernet
+zsc0 at obio? # Zilog serial chip
+zstty* at zsc?
+
+# nubus boards
nubus0 at mainbus?
ae* at nubus? # Most Apple Ethernet Cards
macvid* at nubus? # NuBus video cards
sn* at nubus? # SONIC-based ethernet cards
-# Attach grf semantics to all video hardware as it is found
-grf* at intvid?
-grf* at macvid?
-
-# Attach ite semantics to the appropriate grf device
-ite0 at grf?
+# workstation console
+macfb* at intvid?
+macfb* at macvid?
+wskbd* at akbd? mux 1
+wsmouse* at ams? mux 0
+wsdisplay* at macfb?
# Enable only one of ncrscsi or sbc
ncrscsi0 at obio? # SCSI NCR 5380
@@ -62,11 +66,13 @@ scsibus* at esp?
scsibus* at ncrscsi?
scsibus* at sbc?
-sd* at scsibus? # SCSI disk drives
-st* at scsibus? # SCSI tape drives
-cd* at scsibus? # SCSI CD-ROM drives
-ch* at scsibus? # SCSI autochangers
-ss* at scsibus? # SCSI scanners
-safte* at scsibus? # SCSI accessed fault-tolerant enclosures
-ses* at scsibus? # SCSI enclosure services
-uk* at scsibus? # SCSI unknown
+sd* at scsibus? # SCSI disk drives
+st* at scsibus? # SCSI tape drives
+cd* at scsibus? # SCSI CD-ROM drives
+ch* at scsibus? # SCSI autochangers
+ss* at scsibus? # SCSI scanners
+safte* at scsibus? # SCSI accessed fault-tolerant enclosures
+ses* at scsibus? # SCSI enclosure services
+uk* at scsibus? # SCSI unknown
+
+pseudo-device wsmux 2
diff --git a/sys/arch/mac68k/conf/RAMDISK b/sys/arch/mac68k/conf/RAMDISK
index 9e6fdd81899..947e918505b 100644
--- a/sys/arch/mac68k/conf/RAMDISK
+++ b/sys/arch/mac68k/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.18 2005/05/01 07:54:42 david Exp $
+# $OpenBSD: RAMDISK,v 1.19 2006/01/04 20:39:04 miod Exp $
#
# RAMDISK - bsd.rd configuration file (non-SBC version)
@@ -33,38 +33,41 @@ option M68030
option M68020 # Must have 68851 PMMU
option FPSP
option FPU_EMULATE
-option DISABLE_ADB_WITH_SERIAL_CONSOLE
#option MRG_ADB # Use ROM-based ADB driver
config bsd root on rd0a
maxusers 32
-mainbus0 at root
+mainbus0 at root
# on-board I/O
-obio0 at mainbus?
+obio0 at mainbus?
-adb0 at obio?
-esp0 at obio? # SCSI NCR 53C9x
-esp1 at obio? # SCSI NCR 53C9x
-intvid0 at obio? # Internal video hardware
-mc* at obio? # MACE ethernet on Centris/Quadra 660av
-sn* at obio? # Internal ethernet
-zsc0 at obio? # Zilog serial chip
-zstty* at zsc?
+adb0 at obio?
+akbd* at adb? # ADB keyboard
+#ams* at adb? # ADB mouse
+esp0 at obio? # SCSI NCR 53C9x
+esp1 at obio? # SCSI NCR 53C9x
+intvid0 at obio? # Internal video hardware
+mc* at obio? # MACE ethernet on Centris/Quadra 660av
+sn* at obio? # Internal ethernet
+zsc0 at obio? # Zilog serial chip
+zstty* at zsc?
+
+# nubus boards
nubus0 at mainbus?
ae* at nubus? # Most Apple Ethernet Cards
macvid* at nubus? # NuBus video cards
sn* at nubus? # SONIC-based ethernet cards
-# Attach grf semantics to all video hardware as it is found
-grf* at intvid?
-grf* at macvid?
-
-# Attach ite semantics to the appropriate grf device
-ite0 at grf?
+# workstation console
+macfb* at intvid?
+macfb* at macvid?
+wskbd* at akbd?
+#wsmouse* at ams?
+wsdisplay* at macfb?
# Enable only one of ncrscsi or sbc
ncrscsi0 at obio? # SCSI NCR 5380
@@ -74,8 +77,8 @@ scsibus* at esp?
scsibus* at ncrscsi?
scsibus* at sbc?
-sd* at scsibus? # SCSI disk drives
-st* at scsibus? # SCSI tape drives
-cd* at scsibus? # SCSI CD-ROM drives
+sd* at scsibus? # SCSI disk drives
+st* at scsibus? # SCSI tape drives
+cd* at scsibus? # SCSI CD-ROM drives
pseudo-device rd 1
diff --git a/sys/arch/mac68k/conf/files.mac68k b/sys/arch/mac68k/conf/files.mac68k
index 4f4a4f6b996..e65f25c428d 100644
--- a/sys/arch/mac68k/conf/files.mac68k
+++ b/sys/arch/mac68k/conf/files.mac68k
@@ -1,4 +1,4 @@
-# $OpenBSD: files.mac68k,v 1.34 2005/12/21 18:52:27 miod Exp $
+# $OpenBSD: files.mac68k,v 1.35 2006/01/04 20:39:04 miod Exp $
# $NetBSD: files.mac68k,v 1.61 1997/03/01 20:22:16 scottr Exp $
# mac68k-specific configuration info
@@ -19,19 +19,34 @@ device nubus {}
attach nubus at mainbus
file arch/mac68k/dev/nubus.c nubus
-device adb
+device adb {}
attach adb at obio
file arch/mac68k/dev/adb.c adb
-file arch/mac68k/dev/adbsys.c
-file arch/mac68k/dev/adbsysasm.s
-file arch/mac68k/dev/adb_direct.c
+file arch/mac68k/dev/adbsysasm.s adb
+file arch/mac68k/dev/adb_direct.c adb
file arch/mac68k/dev/pm_direct.c
+#
+# "workstation console" routines
+#
+include "dev/wscons/files.wscons"
+
+#
+# adb devices
+#
+device akbd: wskbddev
+attach akbd at adb
+file arch/mac68k/dev/akbd.c akbd needs-flag
+
+device ams: wsmousedev
+attach ams at adb
+file arch/mac68k/dev/ams.c ams needs-flag
+
device asc
attach asc at obio
file arch/mac68k/dev/asc.c asc needs-flag
-define grfbus {}
+define grfbus {}
file arch/mac68k/dev/grf_subr.c grfbus
device intvid: grfbus
@@ -42,19 +57,15 @@ device macvid: grfbus
attach macvid at nubus
file arch/mac68k/dev/grf_mv.c macvid
-device grf {}
-attach grf at grfbus
-file arch/mac68k/dev/grf.c grf needs-flag
+device macfb: wsemuldisplaydev, wsrasteremulops
+attach macfb at grfbus
+file arch/mac68k/dev/macfb.c macfb needs-flag
device ae: ifnet, ether
attach ae at nubus with ae_nubus
file arch/mac68k/dev/if_ae_nubus.c ae_nubus
file arch/mac68k/dev/if_ae.c ae
-device ite
-attach ite at grf
-file arch/mac68k/dev/ite.c ite needs-flag
-
device sn: ifnet, ether
attach sn at obio with sn_obio
attach sn at nubus with sn_nubus
@@ -87,12 +98,10 @@ device zsc {[channel = -1]}
attach zsc at obio
file arch/mac68k/dev/zs.c zsc needs-flag
file arch/mac68k/dev/z8530sc.c zsc
-#file dev/ic/z8530sc.c zsc
device zstty: tty
attach zstty at zsc
file arch/mac68k/dev/z8530tty.c zstty needs-flag
-#file dev/ic/z8530tty.c zstty needs-flag
file arch/m68k/m68k/db_memrw.c ddb
include "arch/m68k/fpe/files.fpe"
@@ -117,6 +126,7 @@ file arch/mac68k/mac68k/sys_machdep.c
file arch/mac68k/mac68k/trap.c
file arch/mac68k/mac68k/via.c
file arch/mac68k/mac68k/vm_machdep.c
+file arch/mac68k/mac68k/wscons_machdep.c
file dev/cninit.c
diff --git a/sys/arch/mac68k/dev/6x10.h b/sys/arch/mac68k/dev/6x10.h
deleted file mode 100644
index c3c20b49c75..00000000000
--- a/sys/arch/mac68k/dev/6x10.h
+++ /dev/null
@@ -1,1416 +0,0 @@
-/* $OpenBSD: 6x10.h,v 1.2 1996/05/26 18:35:13 briggs Exp $ */
-/* $NetBSD: 6x10.h,v 1.4 1995/04/21 02:47:35 briggs Exp $ */
-
-/* This file was automatically generated by the program "sf" from */
-/* the Bitmap Description Format file "6x10.bdf". */
-
-static unsigned char Font6x10[] = {
- 0x00, /* ........ *//* (char = 0, 0x00) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 1, 0x01) */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x0E, /* ..###... */
- 0x1F, /* .#####.. */
- 0x0E, /* ..###... */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 2, 0x02) */
- 0x15, /* .#.#.#.. */
- 0x0A, /* ..#.#... */
- 0x15, /* .#.#.#.. */
- 0x0A, /* ..#.#... */
- 0x15, /* .#.#.#.. */
- 0x0A, /* ..#.#... */
- 0x15, /* .#.#.#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 3, 0x03) */
- 0x12, /* .#..#... */
- 0x12, /* .#..#... */
- 0x1E, /* .####... */
- 0x12, /* .#..#... */
- 0x12, /* .#..#... */
- 0x0F, /* ..####.. */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
-
- 0x00, /* ........ *//* (char = 4, 0x04) */
- 0x1C, /* .###.... */
- 0x10, /* .#...... */
- 0x18, /* .##..... */
- 0x10, /* .#...... */
- 0x17, /* .#.###.. */
- 0x04, /* ...#.... */
- 0x06, /* ...##... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x00, /* ........ *//* (char = 5, 0x05) */
- 0x0E, /* ..###... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x0E, /* ..###... */
- 0x09, /* ..#..#.. */
- 0x0E, /* ..###... */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
-
- 0x00, /* ........ *//* (char = 6, 0x06) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x1E, /* .####... */
- 0x0F, /* ..####.. */
- 0x08, /* ..#..... */
- 0x0E, /* ..###... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
-
- 0x00, /* ........ *//* (char = 7, 0x07) */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 8, 0x08) */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x1F, /* .#####.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 9, 0x09) */
- 0x12, /* .#..#... */
- 0x1A, /* .##.#... */
- 0x1A, /* .##.#... */
- 0x16, /* .#.##... */
- 0x12, /* .#..#... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x0F, /* ..####.. */
-
- 0x00, /* ........ *//* (char = 10, 0x0a) */
- 0x12, /* .#..#... */
- 0x12, /* .#..#... */
- 0x0C, /* ..##.... */
- 0x08, /* ..#..... */
- 0x0F, /* ..####.. */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
-
- 0x04, /* ...#.... *//* (char = 11, 0x0b) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x3C, /* ####.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 12, 0x0c) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x3C, /* ####.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x00, /* ........ *//* (char = 13, 0x0d) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x07, /* ...###.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x04, /* ...#.... *//* (char = 14, 0x0e) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x07, /* ...###.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x04, /* ...#.... *//* (char = 15, 0x0f) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x3F, /* ######.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x3F, /* ######.. *//* (char = 16, 0x10) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 17, 0x11) */
- 0x00, /* ........ */
- 0x3F, /* ######.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 18, 0x12) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x3F, /* ######.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 19, 0x13) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x3F, /* ######.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 20, 0x14) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x3F, /* ######.. */
- 0x00, /* ........ */
-
- 0x04, /* ...#.... *//* (char = 21, 0x15) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x07, /* ...###.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x04, /* ...#.... *//* (char = 22, 0x16) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x3C, /* ####.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x04, /* ...#.... *//* (char = 23, 0x17) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x3F, /* ######.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 24, 0x18) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x3F, /* ######.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x04, /* ...#.... *//* (char = 25, 0x19) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
-
- 0x00, /* ........ *//* (char = 26, 0x1a) */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x08, /* ..#..... */
- 0x02, /* ....#... */
- 0x01, /* .....#.. */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 27, 0x1b) */
- 0x10, /* .#...... */
- 0x08, /* ..#..... */
- 0x02, /* ....#... */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 28, 0x1c) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 29, 0x1d) */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x1F, /* .#####.. */
- 0x04, /* ...#.... */
- 0x1F, /* .#####.. */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 30, 0x1e) */
- 0x06, /* ...##... */
- 0x09, /* ..#..#.. */
- 0x08, /* ..#..... */
- 0x1C, /* .###.... */
- 0x08, /* ..#..... */
- 0x09, /* ..#..#.. */
- 0x16, /* .#.##... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 31, 0x1f) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 32, 0x20) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 33, 0x21) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 34, 0x22) */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 35, 0x23) */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x1F, /* .#####.. */
- 0x0A, /* ..#.#... */
- 0x1F, /* .#####.. */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 36, 0x24) */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x14, /* .#.#.... */
- 0x0E, /* ..###... */
- 0x05, /* ...#.#.. */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 37, 0x25) */
- 0x09, /* ..#..#.. */
- 0x15, /* .#.#.#.. */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x15, /* .#.#.#.. */
- 0x12, /* .#..#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 38, 0x26) */
- 0x08, /* ..#..... */
- 0x14, /* .#.#.... */
- 0x14, /* .#.#.... */
- 0x08, /* ..#..... */
- 0x15, /* .#.#.#.. */
- 0x12, /* .#..#... */
- 0x0D, /* ..##.#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 39, 0x27) */
- 0x06, /* ...##... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 40, 0x28) */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 41, 0x29) */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 42, 0x2a) */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x1F, /* .#####.. */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 43, 0x2b) */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x1F, /* .#####.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 44, 0x2c) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x06, /* ...##... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 45, 0x2d) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 46, 0x2e) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 47, 0x2f) */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 48, 0x30) */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 49, 0x31) */
- 0x04, /* ...#.... */
- 0x0C, /* ..##.... */
- 0x14, /* .#.#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 50, 0x32) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x01, /* .....#.. */
- 0x06, /* ...##... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 51, 0x33) */
- 0x1F, /* .#####.. */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x06, /* ...##... */
- 0x01, /* .....#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 52, 0x34) */
- 0x02, /* ....#... */
- 0x06, /* ...##... */
- 0x0A, /* ..#.#... */
- 0x12, /* .#..#... */
- 0x1F, /* .#####.. */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 53, 0x35) */
- 0x1F, /* .#####.. */
- 0x10, /* .#...... */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x01, /* .....#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 54, 0x36) */
- 0x06, /* ...##... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 55, 0x37) */
- 0x1F, /* .#####.. */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 56, 0x38) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 57, 0x39) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x13, /* .#..##.. */
- 0x0D, /* ..##.#.. */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x0C, /* ..##.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 58, 0x3a) */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 59, 0x3b) */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x06, /* ...##... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 60, 0x3c) */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x01, /* .....#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 61, 0x3d) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 62, 0x3e) */
- 0x10, /* .#...... */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 63, 0x3f) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 64, 0x40) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x13, /* .#..##.. */
- 0x15, /* .#.#.#.. */
- 0x16, /* .#.##... */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 65, 0x41) */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x1F, /* .#####.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 66, 0x42) */
- 0x1E, /* .####... */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x0E, /* ..###... */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x1E, /* .####... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 67, 0x43) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 68, 0x44) */
- 0x1E, /* .####... */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x09, /* ..#..#.. */
- 0x1E, /* .####... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 69, 0x45) */
- 0x1F, /* .#####.. */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x1E, /* .####... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 70, 0x46) */
- 0x1F, /* .#####.. */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x1E, /* .####... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 71, 0x47) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x13, /* .#..##.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 72, 0x48) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x1F, /* .#####.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 73, 0x49) */
- 0x0E, /* ..###... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 74, 0x4a) */
- 0x07, /* ...###.. */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 75, 0x4b) */
- 0x11, /* .#...#.. */
- 0x12, /* .#..#... */
- 0x14, /* .#.#.... */
- 0x18, /* .##..... */
- 0x14, /* .#.#.... */
- 0x12, /* .#..#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 76, 0x4c) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 77, 0x4d) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x1B, /* .##.##.. */
- 0x15, /* .#.#.#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 78, 0x4e) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x19, /* .##..#.. */
- 0x15, /* .#.#.#.. */
- 0x13, /* .#..##.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 79, 0x4f) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 80, 0x50) */
- 0x1E, /* .####... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x1E, /* .####... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 81, 0x51) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x15, /* .#.#.#.. */
- 0x0E, /* ..###... */
- 0x01, /* .....#.. */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 82, 0x52) */
- 0x1E, /* .####... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x1E, /* .####... */
- 0x14, /* .#.#.... */
- 0x12, /* .#..#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 83, 0x53) */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x01, /* .....#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 84, 0x54) */
- 0x1F, /* .#####.. */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 85, 0x55) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 86, 0x56) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 87, 0x57) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x15, /* .#.#.#.. */
- 0x15, /* .#.#.#.. */
- 0x1B, /* .##.##.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 88, 0x58) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 89, 0x59) */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 90, 0x5a) */
- 0x1F, /* .#####.. */
- 0x01, /* .....#.. */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x10, /* .#...... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 91, 0x5b) */
- 0x0E, /* ..###... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 92, 0x5c) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 93, 0x5d) */
- 0x0E, /* ..###... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 94, 0x5e) */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 95, 0x5f) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 96, 0x60) */
- 0x0C, /* ..##.... */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 97, 0x61) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0E, /* ..###... */
- 0x01, /* .....#.. */
- 0x0F, /* ..####.. */
- 0x11, /* .#...#.. */
- 0x0F, /* ..####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 98, 0x62) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x11, /* .#...#.. */
- 0x19, /* .##..#.. */
- 0x16, /* .#.##... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 99, 0x63) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x10, /* .#...... */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 100, 0x64) */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x0D, /* ..##.#.. */
- 0x13, /* .#..##.. */
- 0x11, /* .#...#.. */
- 0x13, /* .#..##.. */
- 0x0D, /* ..##.#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 101, 0x65) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x1F, /* .#####.. */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 102, 0x66) */
- 0x06, /* ...##... */
- 0x09, /* ..#..#.. */
- 0x08, /* ..#..... */
- 0x1E, /* .####... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 103, 0x67) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0D, /* ..##.#.. */
- 0x12, /* .#..#... */
- 0x0C, /* ..##.... */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
-
- 0x00, /* ........ *//* (char = 104, 0x68) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 105, 0x69) */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x0C, /* ..##.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 106, 0x6a) */
- 0x02, /* ....#... */
- 0x00, /* ........ */
- 0x06, /* ...##... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x02, /* ....#... */
- 0x12, /* .#..#... */
- 0x12, /* .#..#... */
- 0x0C, /* ..##.... */
-
- 0x00, /* ........ *//* (char = 107, 0x6b) */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x11, /* .#...#.. */
- 0x12, /* .#..#... */
- 0x1C, /* .###.... */
- 0x12, /* .#..#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 108, 0x6c) */
- 0x0C, /* ..##.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 109, 0x6d) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1A, /* .##.#... */
- 0x15, /* .#.#.#.. */
- 0x15, /* .#.#.#.. */
- 0x15, /* .#.#.#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 110, 0x6e) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 111, 0x6f) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0E, /* ..###... */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 112, 0x70) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x19, /* .##..#.. */
- 0x16, /* .#.##... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
-
- 0x00, /* ........ *//* (char = 113, 0x71) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0D, /* ..##.#.. */
- 0x13, /* .#..##.. */
- 0x13, /* .#..##.. */
- 0x0D, /* ..##.#.. */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
- 0x01, /* .....#.. */
-
- 0x00, /* ........ *//* (char = 114, 0x72) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x16, /* .#.##... */
- 0x19, /* .##..#.. */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x10, /* .#...... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 115, 0x73) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x0E, /* ..###... */
- 0x10, /* .#...... */
- 0x0E, /* ..###... */
- 0x01, /* .....#.. */
- 0x1E, /* .####... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 116, 0x74) */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x1E, /* .####... */
- 0x08, /* ..#..... */
- 0x08, /* ..#..... */
- 0x09, /* ..#..#.. */
- 0x06, /* ...##... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 117, 0x75) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x13, /* .#..##.. */
- 0x0D, /* ..##.#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 118, 0x76) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 119, 0x77) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x15, /* .#.#.#.. */
- 0x15, /* .#.#.#.. */
- 0x0A, /* ..#.#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 120, 0x78) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x0A, /* ..#.#... */
- 0x04, /* ...#.... */
- 0x0A, /* ..#.#... */
- 0x11, /* .#...#.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 121, 0x79) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x11, /* .#...#.. */
- 0x11, /* .#...#.. */
- 0x13, /* .#..##.. */
- 0x0D, /* ..##.#.. */
- 0x01, /* .....#.. */
- 0x11, /* .#...#.. */
- 0x0E, /* ..###... */
-
- 0x00, /* ........ *//* (char = 122, 0x7a) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x1F, /* .#####.. */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x1F, /* .#####.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 123, 0x7b) */
- 0x03, /* ....##.. */
- 0x04, /* ...#.... */
- 0x02, /* ....#... */
- 0x0C, /* ..##.... */
- 0x02, /* ....#... */
- 0x04, /* ...#.... */
- 0x03, /* ....##.. */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 124, 0x7c) */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x04, /* ...#.... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 125, 0x7d) */
- 0x18, /* .##..... */
- 0x04, /* ...#.... */
- 0x08, /* ..#..... */
- 0x06, /* ...##... */
- 0x08, /* ..#..... */
- 0x04, /* ...#.... */
- 0x18, /* .##..... */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 126, 0x7e) */
- 0x09, /* ..#..#.. */
- 0x15, /* .#.#.#.. */
- 0x12, /* .#..#... */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
- 0x00, /* ........ *//* (char = 127, 0x7f) */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
- 0x00, /* ........ */
-
-};
diff --git a/sys/arch/mac68k/dev/adb.c b/sys/arch/mac68k/dev/adb.c
index e83010937ed..50531807ce1 100644
--- a/sys/arch/mac68k/dev/adb.c
+++ b/sys/arch/mac68k/dev/adb.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: adb.c,v 1.14 2005/11/21 18:16:37 millert Exp $ */
-/* $NetBSD: adb.c,v 1.13 1996/12/16 16:17:02 scottr Exp $ */
+/* $OpenBSD: adb.c,v 1.15 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: adb.c,v 1.47 2005/06/16 22:43:36 jmc Exp $ */
-/*-
+/*
* Copyright (C) 1994 Bradley A. Grantham
* All rights reserved.
*
@@ -11,7 +11,7 @@
* 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
-e* notice, this list of conditions and the following disclaimer in the
+ * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
@@ -34,531 +34,265 @@ e* notice, this list of conditions and the following disclaimer in the
#include <sys/param.h>
#include <sys/device.h>
#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/selinfo.h>
#include <sys/poll.h>
+#include <sys/selinfo.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/timeout.h>
#include <machine/autoconf.h>
-#include <machine/keyboard.h>
+#include <machine/cpu.h>
-#include <arch/mac68k/mac68k/macrom.h>
-#include <arch/mac68k/dev/adbvar.h>
-#include <arch/mac68k/dev/itevar.h>
+#include <mac68k/dev/adbvar.h>
/*
* Function declarations.
*/
-static int adbmatch(struct device *, void *, void *);
-static void adbattach(struct device *, struct device *, void *);
+int adbmatch(struct device *, void *, void *);
+void adbattach(struct device *, struct device *, void *);
+int adbprint(void *, const char *);
+void adb_attach_deferred(void *);
+
+extern void adb_jadbproc(void);
/*
* Global variables.
*/
-int adb_polling = 0; /* Are we polling? (Debugger mode) */
+int adb_polling = 0; /* Are we polling? (Debugger mode) */
+#ifdef ADB_DEBUG
+int adb_debug = 0; /* Output debugging messages */
+#endif /* ADB_DEBUG */
+
+extern struct mac68k_machine_S mac68k_machine;
+extern int adbHardware;
+extern char *adbHardwareDescr[];
/*
- * Local variables.
+ * Driver definition.
*/
-
-/* External keyboard translation matrix */
-extern unsigned char keyboard[128][3];
-
-/* Event queue definitions */
-#if !defined(ADB_MAX_EVENTS)
-#define ADB_MAX_EVENTS 200 /* Maximum events to be kept in queue */
- /* maybe should be higher for slower macs? */
-#endif /* !defined(ADB_MAX_EVENTS) */
-static adb_event_t adb_evq[ADB_MAX_EVENTS]; /* ADB event queue */
-static int adb_evq_tail = 0; /* event queue tail */
-static int adb_evq_len = 0; /* event queue length */
-
-/* ADB device state information */
-static int adb_isopen = 0; /* Are we queuing events for adb_read? */
-static struct selinfo adb_selinfo; /* select() info */
-static struct proc *adb_ioproc = NULL; /* process to wakeup */
-
-/* Key repeat parameters */
-static int adb_rptdelay = 20; /* ticks before auto-repeat */
-static int adb_rptinterval = 6; /* ticks between auto-repeat */
-static int adb_repeating = -1; /* key that is auto-repeating */
-static adb_event_t adb_rptevent;/* event to auto-repeat */
-
-/* Driver definition. -- This should probably be a bus... */
struct cfattach adb_ca = {
sizeof(struct device), adbmatch, adbattach
};
-
struct cfdriver adb_cd = {
NULL, "adb", DV_DULL
};
-struct timeout repeat_timeout;
-
-static int
-adbmatch(parent, vcf, aux)
- struct device *parent;
- void *vcf;
- void *aux;
+int
+adbmatch(struct device *parent, void *vcf, void *aux)
{
- return 1;
+ static int adb_matched = 0;
+
+ /* Allow only one instance. */
+ if (adb_matched)
+ return (0);
+
+ adb_matched = 1;
+ return (1);
}
-static void
-adbattach(parent, dev, aux)
- struct device *parent, *dev;
- void *aux;
+void
+adbattach(struct device *parent, struct device *self, void *aux)
{
- printf(" (ADB event device)\n");
+ printf("\n");
+ startuphook_establish(adb_attach_deferred, self);
}
-void
-adb_enqevent(event)
- adb_event_t *event;
+void
+adb_attach_deferred(void *v)
{
- int s;
+ struct device *self = v;
+ ADBDataBlock adbdata;
+ struct adb_attach_args aa_args;
+ int totaladbs;
+ int adbindex, adbaddr;
+
+ printf("%s", self->dv_xname);
+ adb_polling = 1;
+
+#ifdef MRG_ADB
+ if (!mrg_romready()) {
+ printf(": no ROM ADB driver in this kernel for this machine\n");
+ return;
+ }
- if (adb_evq_tail < 0 || adb_evq_tail >= ADB_MAX_EVENTS)
- panic("adb: event queue tail is out of bounds");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: call mrg_initadbintr\n");
+#endif
- if (adb_evq_len < 0 || adb_evq_len > ADB_MAX_EVENTS)
- panic("adb: event queue len is out of bounds");
+ mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: returned from mrg_initadbintr\n");
+#endif
- s = splhigh();
+ /* ADBReInit pre/post-processing */
+ JADBProc = adb_jadbproc;
- if (adb_evq_len == ADB_MAX_EVENTS) {
- splx(s);
- return; /* Oh, well... */
- }
- adb_evq[(adb_evq_len + adb_evq_tail) % ADB_MAX_EVENTS] =
- *event;
- adb_evq_len++;
+ /* Initialize ADB */
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: calling ADBAlternateInit.\n");
+#endif
- selwakeup(&adb_selinfo);
- if (adb_ioproc)
- psignal(adb_ioproc, SIGIO);
+ printf(": mrg");
+ ADBAlternateInit();
+#else
+ ADBReInit();
+ printf(": %s", adbHardwareDescr[adbHardware]);
- splx(s);
-}
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: done with ADBReInit\n");
+#endif
-void
-adb_handoff(event)
- adb_event_t *event;
-{
- if (adb_isopen && !adb_polling) {
- adb_enqevent(event);
- } else {
- if (event->def_addr == 2)
- ite_intr(event);
- }
-}
+#endif /* MRG_ADB */
+ totaladbs = CountADBs();
-void
-adb_autorepeat(keyp)
- void *keyp;
-{
- int key = (int) keyp;
+ printf(", %d target%s\n", totaladbs, (totaladbs == 1) ? "" : "s");
- adb_rptevent.bytes[0] |= 0x80;
- microtime(&adb_rptevent.timestamp);
- adb_handoff(&adb_rptevent); /* do key up */
+ /* for each ADB device */
+ for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
+ /* Get the ADB information */
+ adbaddr = GetIndADB(&adbdata, adbindex);
- adb_rptevent.bytes[0] &= 0x7f;
- microtime(&adb_rptevent.timestamp);
- adb_handoff(&adb_rptevent); /* do key down */
+ aa_args.origaddr = (int)(adbdata.origADBAddr);
+ aa_args.adbaddr = adbaddr;
+ aa_args.handler_id = (int)(adbdata.devType);
- if (adb_repeating == key) {
- timeout_set(&repeat_timeout, adb_autorepeat, keyp);
- timeout_add(&repeat_timeout, adb_rptinterval);
+ (void)config_found(self, &aa_args, adbprint);
}
+ adb_polling = 0;
}
-void
-adb_dokeyupdown(event)
- adb_event_t *event;
+int
+adbprint(void *args, const char *name)
{
- int adb_key;
-
- if (event->def_addr == 2) {
- adb_key = event->u.k.key & 0x7f;
- if (!(event->u.k.key & 0x80) &&
- keyboard[event->u.k.key & 0x7f][0] != 0) {
- /* ignore shift & control */
- if (adb_repeating != -1) {
- timeout_del(&repeat_timeout);
+ struct adb_attach_args *aa_args = (struct adb_attach_args *)args;
+ int rv = UNCONF;
+
+ if (name) { /* no configured device matched */
+ rv = UNSUPP; /* most ADB device types are unsupported */
+
+ /* print out what kind of ADB device we have found */
+ printf("%s addr %d: ", name, aa_args->adbaddr);
+ switch(aa_args->origaddr) {
+#ifdef DIAGNOSTIC
+ case ADBADDR_SECURE:
+ printf("security dongle (%d)",
+ aa_args->handler_id);
+ break;
+#endif
+ case ADBADDR_MAP:
+ printf("mapped device (%d)",
+ aa_args->handler_id);
+ rv = UNCONF;
+ break;
+ case ADBADDR_REL:
+ printf("relative positioning device (%d)",
+ aa_args->handler_id);
+ rv = UNCONF;
+ break;
+#ifdef DIAGNOSTIC
+ case ADBADDR_ABS:
+ switch (aa_args->handler_id) {
+ case ADB_ARTPAD:
+ printf("WACOM ArtPad II");
+ break;
+ default:
+ printf("absolute positioning device (%d)",
+ aa_args->handler_id);
+ break;
}
- adb_rptevent = *event;
- adb_repeating = adb_key;
- timeout_set(&repeat_timeout, adb_autorepeat,
- (caddr_t)adb_key);
- timeout_add(&repeat_timeout, adb_rptdelay);
- } else {
- if (adb_repeating != -1) {
- adb_repeating = -1;
- timeout_del(&repeat_timeout);
+ break;
+ case ADBADDR_DATATX:
+ printf("data transfer device (modem?) (%d)",
+ aa_args->handler_id);
+ break;
+ case ADBADDR_MISC:
+ switch (aa_args->handler_id) {
+ case ADB_POWERKEY:
+ printf("Sophisticated Circuits PowerKey");
+ break;
+ default:
+ printf("misc. device (remote control?) (%d)",
+ aa_args->handler_id);
+ break;
}
- adb_rptevent = *event;
- }
- }
- adb_handoff(event);
-}
-
-static int adb_ms_buttons = 0;
-
-void
-adb_keymaybemouse(event)
- adb_event_t *event;
-{
- static int optionkey_down = 0;
- adb_event_t new_event;
-
- if (event->u.k.key == ADBK_KEYDOWN(ADBK_OPTION)) {
- optionkey_down = 1;
- } else if (event->u.k.key == ADBK_KEYUP(ADBK_OPTION)) {
- /* key up */
- optionkey_down = 0;
- if (adb_ms_buttons & 0xfe) {
- adb_ms_buttons &= 1;
- new_event.def_addr = ADBADDR_MS;
- new_event.u.m.buttons = adb_ms_buttons;
- new_event.u.m.dx = new_event.u.m.dy = 0;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- }
- } else if (optionkey_down) {
- if (event->u.k.key == ADBK_KEYDOWN(ADBK_LEFT)) {
- adb_ms_buttons |= 2; /* middle down */
- new_event.def_addr = ADBADDR_MS;
- new_event.u.m.buttons = adb_ms_buttons;
- new_event.u.m.dx = new_event.u.m.dy = 0;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- } else if (event->u.k.key == ADBK_KEYUP(ADBK_LEFT)) {
- adb_ms_buttons &= ~2; /* middle up */
- new_event.def_addr = ADBADDR_MS;
- new_event.u.m.buttons = adb_ms_buttons;
- new_event.u.m.dx = new_event.u.m.dy = 0;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- } else if (event->u.k.key == ADBK_KEYDOWN(ADBK_RIGHT)) {
- adb_ms_buttons |= 4; /* right down */
- new_event.def_addr = ADBADDR_MS;
- new_event.u.m.buttons = adb_ms_buttons;
- new_event.u.m.dx = new_event.u.m.dy = 0;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- } else if (event->u.k.key == ADBK_KEYUP(ADBK_RIGHT)) {
- adb_ms_buttons &= ~4; /* right up */
- new_event.def_addr = ADBADDR_MS;
- new_event.u.m.buttons = adb_ms_buttons;
- new_event.u.m.dx = new_event.u.m.dy = 0;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- } else if (ADBK_MODIFIER(event->u.k.key)) {
- /* ctrl, shift, cmd */
- adb_dokeyupdown(event);
- } else if (!(event->u.k.key & 0x80)) {
- /* key down */
- new_event = *event;
-
- /* send option-down */
- new_event.u.k.key = ADBK_KEYDOWN(ADBK_OPTION);
- new_event.bytes[0] = new_event.u.k.key;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
-
- /* send key-down */
- new_event.u.k.key = event->bytes[0];
- new_event.bytes[0] = new_event.u.k.key;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
-
- /* send key-up */
- new_event.u.k.key =
- ADBK_KEYUP(ADBK_KEYVAL(event->bytes[0]));
- microtime(&new_event.timestamp);
- new_event.bytes[0] = new_event.u.k.key;
- adb_dokeyupdown(&new_event);
-
- /* send option-up */
- new_event.u.k.key = ADBK_KEYUP(ADBK_OPTION);
- new_event.bytes[0] = new_event.u.k.key;
- microtime(&new_event.timestamp);
- adb_dokeyupdown(&new_event);
- } else {
- /* option-keyup -- do nothing. */
- }
- } else {
- adb_dokeyupdown(event);
- }
-}
-
-
-void
-adb_processevent(event)
- adb_event_t *event;
-{
- adb_event_t new_event;
- int i, button_bit, max_byte, mask, buttons;
-
- new_event = *event;
- buttons = 0;
-
- switch (event->def_addr) {
- case ADBADDR_KBD:
- new_event.u.k.key = event->bytes[0];
- new_event.bytes[1] = 0xff;
- adb_keymaybemouse(&new_event);
- if (event->bytes[1] != 0xff) {
- new_event.u.k.key = event->bytes[1];
- new_event.bytes[0] = event->bytes[1];
- new_event.bytes[1] = 0xff;
- adb_keymaybemouse(&new_event);
- }
- break;
- case ADBADDR_MS:
- /*
- * This should handle both plain ol' Apple mice and mice
- * that claim to support the Extended Apple Mouse Protocol.
- */
- max_byte = event->byte_count;
- button_bit = 1;
- switch (event->hand_id) {
- case ADBMS_USPEED:
- /* MicroSpeed mouse */
- if (max_byte == 4)
- buttons = (~event->bytes[2]) & 0xff;
- else
- buttons = (event->bytes[0] & 0x80) ? 0 : 1;
break;
default:
- /* Classic Mouse Protocol (up to 2 buttons) */
- for (i = 0; i < 2; i++, button_bit <<= 1)
- /* 0 when button down */
- if (!(event->bytes[i] & 0x80))
- buttons |= button_bit;
- else
- buttons &= ~button_bit;
- /* Extended Protocol (up to 6 more buttons) */
- for (mask = 0x80; i < max_byte;
- i += (mask == 0x80), button_bit <<= 1) {
- /* 0 when button down */
- if (!(event->bytes[i] & mask))
- buttons |= button_bit;
- else
- buttons &= ~button_bit;
- mask = ((mask >> 4) & 0xf)
- | ((mask & 0xf) << 4);
- }
+ printf("unknown type device, (handler %d)",
+ aa_args->handler_id);
break;
+#endif /* DIAGNOSTIC */
}
- new_event.u.m.buttons = adb_ms_buttons | buttons;
- new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
- ((event->bytes[1] & 0x40) ? 64 : 0);
- new_event.u.m.dy = ((signed int) (event->bytes[0] & 0x3f)) -
- ((event->bytes[0] & 0x40) ? 64 : 0);
- adb_dokeyupdown(&new_event);
- break;
- default: /* God only knows. */
- adb_dokeyupdown(event);
- }
-}
+ } else /* a device matched and was configured */
+ printf(" addr %d: ", aa_args->adbaddr);
-
-int
-adbopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- register int unit;
- int error = 0;
- int s;
-
- unit = minor(dev);
- if (unit != 0)
- return (ENXIO);
-
- s = splhigh();
- if (adb_isopen) {
- splx(s);
- return (EBUSY);
- }
- splx(s);
- adb_evq_tail = 0;
- adb_evq_len = 0;
- adb_isopen = 1;
- adb_ioproc = p;
-
- return (error);
-}
-
-
-int
-adbclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- adb_isopen = 0;
- adb_ioproc = NULL;
- return (0);
-}
-
-
-int
-adbread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int s, error;
- int willfit;
- int total;
- int firstmove;
- int moremove;
-
- if (uio->uio_resid < sizeof(adb_event_t))
- return (EMSGSIZE); /* close enough. */
-
- s = splhigh();
- if (adb_evq_len == 0) {
- splx(s);
- return (0);
- }
- willfit = howmany(uio->uio_resid, sizeof(adb_event_t));
- total = (adb_evq_len < willfit) ? adb_evq_len : willfit;
-
- firstmove = (adb_evq_tail + total > ADB_MAX_EVENTS)
- ? (ADB_MAX_EVENTS - adb_evq_tail) : total;
-
- error = uiomove((caddr_t) & adb_evq[adb_evq_tail],
- firstmove * sizeof(adb_event_t), uio);
- if (error) {
- splx(s);
- return (error);
- }
- moremove = total - firstmove;
-
- if (moremove > 0) {
- error = uiomove((caddr_t) & adb_evq[0],
- moremove * sizeof(adb_event_t), uio);
- if (error) {
- splx(s);
- return (error);
- }
- }
- adb_evq_tail = (adb_evq_tail + total) % ADB_MAX_EVENTS;
- adb_evq_len -= total;
- splx(s);
- return (0);
-}
-
-
-int
-adbwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- return 0;
+ return (rv);
}
-int
-adbioctl(dev, cmd, data, flag, p)
- dev_t dev;
- int cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+/*
+ * adb_op_sync
+ *
+ * This routine does exactly what the adb_op routine does, except that after
+ * the adb_op is called, it waits until the return value is present before
+ * returning.
+ *
+ * NOTE: The user specified compRout is ignored, since this routine specifies
+ * it's own to adb_op, which is why you really called this in the first place
+ * anyway.
+ */
+int
+adb_op_sync(Ptr buffer, Ptr compRout, Ptr data, short command)
{
- switch (cmd) {
- case ADBIOC_DEVSINFO: {
- adb_devinfo_t *di;
- ADBDataBlock adbdata;
- int totaldevs;
- int adbaddr;
- int i;
-
- di = (void *) data;
-
- /* Initialize to no devices */
- for (i = 0; i < 16; i++)
- di->dev[i].addr = -1;
-
- totaldevs = CountADBs();
- for (i = 1; i <= totaldevs; i++) {
- adbaddr = GetIndADB(&adbdata, i);
- di->dev[adbaddr].addr = adbaddr;
- di->dev[adbaddr].default_addr = adbdata.origADBAddr;
- di->dev[adbaddr].handler_id = adbdata.devType;
- }
-
- /* Must call ADB Manager to get devices now */
- break;
- }
-
- case ADBIOC_GETREPEAT:{
- adb_rptinfo_t *ri;
-
- ri = (void *) data;
- ri->delay_ticks = adb_rptdelay;
- ri->interval_ticks = adb_rptinterval;
- break;
- }
-
- case ADBIOC_SETREPEAT:{
- adb_rptinfo_t *ri;
-
- ri = (void *) data;
- adb_rptdelay = ri->delay_ticks;
- adb_rptinterval = ri->interval_ticks;
- break;
- }
+ int tmout;
+ int result;
+ volatile int flag = 0;
- case ADBIOC_RESET:
- adb_init();
- break;
-
- case ADBIOC_LISTENCMD:{
- adb_listencmd_t *lc;
+ result = ADBOp(buffer, (void *)adb_op_comprout, (Ptr)&flag,
+ command); /* send command */
+ if (result == 0) { /* send ok? */
+ /*
+ * Total time to wait is calculated as follows:
+ * - Tlt (stop to start time): 260 usec
+ * - start bit: 100 usec
+ * - up to 8 data bytes: 64 * 100 usec = 6400 usec
+ * - stop bit (with SRQ): 140 usec
+ * Total: 6900 usec
+ *
+ * This is the total time allowed by the specification. Any
+ * device that doesn't conform to this will fail to operate
+ * properly on some Apple systems. In spite of this we
+ * double the time to wait; some Cuda-based apparently
+ * queues some commands and allows the main CPU to continue
+ * processing (radical concept, eh?). To be safe, allow
+ * time for two complete ADB transactions to occur.
+ */
+ for (tmout = 13800; !flag && tmout >= 10; tmout -= 10)
+ delay(10);
+ if (!flag && tmout > 0)
+ delay(tmout);
- lc = (void *) data;
+ if (!flag)
+ result = -2;
}
- default:
- return (EINVAL);
- }
- return (0);
+ return result;
}
-int
-adbpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+/*
+ * adb_op_comprout
+ *
+ * This function is used by the adb_op_sync routine so it knows when the
+ * function is done.
+ */
+void
+adb_op_comprout(void)
{
- int revents = 0;
-
- if (events & (POLLIN | POLLRDNORM)) {
- /* succeed if there is something to read */
- if (adb_evq_len > 0)
- revents |= events & (POLLIN | POLLRDNORM);
- else
- selrecord(p, &adb_selinfo);
- }
- if (events & (POLLOUT | POLLWRNORM)) {
- /* always fails => never blocks */
- revents |= events & (POLLOUT | POLLWRNORM);
- }
-
- return (revents);
+ asm("movw #1,a2@ | update flag value");
}
diff --git a/sys/arch/mac68k/dev/adb_direct.c b/sys/arch/mac68k/dev/adb_direct.c
index f6f747ca974..70bb750fe58 100644
--- a/sys/arch/mac68k/dev/adb_direct.c
+++ b/sys/arch/mac68k/dev/adb_direct.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: adb_direct.c,v 1.15 2004/11/26 21:21:23 miod Exp $ */
-/* $NetBSD: adb_direct.c,v 1.5 1997/04/21 18:04:28 scottr Exp $ */
+/* $OpenBSD: adb_direct.c,v 1.16 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: adb_direct.c,v 1.51 2005/06/16 22:43:36 jmc Exp $ */
-/* From: adb_direct.c 2.02 4/18/97 jpw */
+/* From: adb_direct.c 2.02 4/18/97 jpw */
/*
* Copyright (C) 1996, 1997 John P. Wittkoski
@@ -33,38 +33,58 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* This code is rather messy, but I don't have time right now
+/*
+ * This code is rather messy, but I don't have time right now
* to clean it up as much as I would like.
- * But it works, so I'm happy. :-) jpw */
+ * But it works, so I'm happy. :-) jpw
+ */
+
+/*
+ * TO DO:
+ * - We could reduce the time spent in the adb_intr_* routines
+ * by having them save the incoming and outgoing data directly
+ * in the adbInbound and adbOutbound queues, as it would reduce
+ * the number of times we need to copy the data around. It
+ * would also make the code more readable and easier to follow.
+ * - (Related to above) Use the header part of adbCommand to
+ * reduce the number of copies we have to do of the data.
+ * - (Related to above) Actually implement the adbOutbound queue.
+ * This is fairly easy once you switch all the intr routines
+ * over to using adbCommand structs directly.
+ * - There is a bug in the state machine of adb_intr_cuda
+ * code that causes hangs, especially on 030 machines, probably
+ * because of some timing issues. Because I have been unable to
+ * determine the exact cause of this bug, I used the timeout function
+ * to check for and recover from this condition. If anyone finds
+ * the actual cause of this bug, the calls to timeout and the
+ * adb_cuda_tickle routine can be removed.
+ */
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/cdefs.h>
+#include <sys/pool.h>
+#include <sys/queue.h>
#include <sys/systm.h>
+#include <sys/timeout.h>
#include <machine/viareg.h>
#include <machine/param.h>
#include <machine/cpu.h>
-#include <machine/adbsys.h> /* required for adbvar.h */
-
-#include <arch/mac68k/mac68k/macrom.h>
-#include "adbvar.h"
+#include <mac68k/dev/adbvar.h>
#define printf_intr printf
-#else
+#else /* !__NetBSD__, i.e. Mac OS */
#include "via.h" /* for macos based testing */
-typedef unsigned char u_char;
-#endif
-
-
-#ifdef MRG_ADB
-int adb_poweroff(void);
-int adb_read_date_time(unsigned long *t);
-int adb_set_date_time(unsigned long t);
-#endif
+/* #define ADB_DEBUG */ /* more verbose for testing */
-/* more verbose for testing */
-/*#define DEBUG*/
+/* Types of ADB hardware that we support */
+#define ADB_HW_UNKNOWN 0x0 /* don't know */
+#define ADB_HW_II 0x1 /* Mac II series */
+#define ADB_HW_IISI 0x2 /* Mac IIsi series */
+#define ADB_HW_PB 0x3 /* PowerBook series */
+#define ADB_HW_CUDA 0x4 /* Machines with a Cuda chip */
+#endif /* __NetBSD__ */
/* some misc. leftovers */
#define vPB 0x0000
@@ -74,31 +94,25 @@ int adb_set_date_time(unsigned long t);
#define vSR_INT 0x04
#define vSR_OUT 0x10
-/* types of adb hardware that we (will eventually) support */
-#define ADB_HW_UNKNOWN 0x01 /* don't know */
-#define ADB_HW_II 0x02 /* Mac II series */
-#define ADB_HW_IISI 0x03 /* Mac IIsi series */
-#define ADB_HW_PB 0x04 /* PowerBook series */
-#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
-
/* the type of ADB action that we are currently preforming */
-#define ADB_ACTION_NOTREADY 0x01 /* has not been initialized yet */
-#define ADB_ACTION_IDLE 0x02 /* the bus is currently idle */
-#define ADB_ACTION_OUT 0x03 /* sending out a command */
-#define ADB_ACTION_IN 0x04 /* receiving data */
+#define ADB_ACTION_NOTREADY 0x1 /* has not been initialized yet */
+#define ADB_ACTION_IDLE 0x2 /* the bus is currently idle */
+#define ADB_ACTION_OUT 0x3 /* sending out a command */
+#define ADB_ACTION_IN 0x4 /* receiving data */
+#define ADB_ACTION_POLLING 0x5 /* polling - II only */
/*
* These describe the state of the ADB bus itself, although they
* don't necessarily correspond directly to ADB states.
* Note: these are not really used in the IIsi code.
*/
-#define ADB_BUS_UNKNOWN 0x01 /* we don't know yet - all models */
-#define ADB_BUS_IDLE 0x02 /* bus is idle - all models */
-#define ADB_BUS_CMD 0x03 /* starting a command - II models */
-#define ADB_BUS_ODD 0x04 /* the "odd" state - II models */
-#define ADB_BUS_EVEN 0x05 /* the "even" state - II models */
-#define ADB_BUS_ACTIVE 0x06 /* active state - IIsi models */
-#define ADB_BUS_ACK 0x07 /* currently ACKing - IIsi models */
+#define ADB_BUS_UNKNOWN 0x1 /* we don't know yet - all models */
+#define ADB_BUS_IDLE 0x2 /* bus is idle - all models */
+#define ADB_BUS_CMD 0x3 /* starting a command - II models */
+#define ADB_BUS_ODD 0x4 /* the "odd" state - II models */
+#define ADB_BUS_EVEN 0x5 /* the "even" state - II models */
+#define ADB_BUS_ACTIVE 0x6 /* active state - IIsi models */
+#define ADB_BUS_ACK 0x7 /* currently ACKing - IIsi models */
/*
* Shortcuts for setting or testing the VIA bit states.
@@ -111,7 +125,7 @@ int adb_set_date_time(unsigned long t);
#define ADB_SET_STATE_EVEN() via_reg(VIA1, vBufB) = ((via_reg(VIA1, \
vBufB) | vPB4) & ~vPB5)
#define ADB_SET_STATE_ODD() via_reg(VIA1, vBufB) = ((via_reg(VIA1, \
- vBufB) | vPB5) & ~vPB4 )
+ vBufB) | vPB5) & ~vPB4)
#define ADB_SET_STATE_ACTIVE() via_reg(VIA1, vBufB) |= vPB5
#define ADB_SET_STATE_INACTIVE() via_reg(VIA1, vBufB) &= ~vPB5
#define ADB_SET_STATE_TIP() via_reg(VIA1, vBufB) &= ~vPB5
@@ -144,7 +158,11 @@ int adb_set_date_time(unsigned long t);
* Maximum ADB message length; includes space for data, result, and
* device code - plus a little for safety.
*/
-#define MAX_ADB_MSG_LENGTH 20
+#define ADB_MAX_MSG_LENGTH 16
+#define ADB_MAX_HDR_LENGTH 8
+
+#define ADB_QUEUE 32
+#define ADB_TICKLE_TICKS 4
/*
* A structure for storing information about each ADB device.
@@ -152,22 +170,49 @@ int adb_set_date_time(unsigned long t);
struct ADBDevEntry {
void (*ServiceRtPtr)(void);
void *DataAreaAddr;
- char devType;
- char origAddr;
- char currentAddr;
+ int devType;
+ int origAddr;
+ int currentAddr;
};
/*
* Used to hold ADB commands that are waiting to be sent out.
*/
struct adbCmdHoldEntry {
- u_char outBuf[MAX_ADB_MSG_LENGTH]; /* our message */
+ u_char outBuf[ADB_MAX_MSG_LENGTH]; /* our message */
u_char *saveBuf; /* buffer to know where to save result */
u_char *compRout; /* completion routine pointer */
u_char *data; /* completion routine data pointer */
};
/*
+ * Eventually used for two separate queues, the queue between
+ * the upper and lower halves, and the outgoing packet queue.
+ * TO DO: adbCommand can replace all of adbCmdHoldEntry eventually
+ */
+struct adbCommand {
+ u_char header[ADB_MAX_HDR_LENGTH]; /* not used yet */
+ u_char data[ADB_MAX_MSG_LENGTH]; /* packet data only */
+ u_char *saveBuf; /* where to save result */
+ u_char *compRout; /* completion routine pointer */
+ u_char *compData; /* completion routine data pointer */
+ u_int cmd; /* the original command for this data */
+ u_int unsol; /* 1 if packet was unsolicited */
+ u_int ack_only; /* 1 for no special processing */
+};
+
+/*
+ * Text representations of each hardware class
+ */
+const char *adbHardwareDescr[MAX_ADB_HW + 1] = {
+ "unknown",
+ "II series",
+ "IIsi series",
+ "PowerBook",
+ "Cuda",
+};
+
+/*
* A few variables that we need and their initial values.
*/
int adbHardware = ADB_HW_UNKNOWN;
@@ -177,11 +222,12 @@ int adbWaiting = 0; /* waiting for return data from the device */
int adbWriteDelay = 0; /* working on (or waiting to do) a write */
int adbOutQueueHasData = 0; /* something in the queue waiting to go out */
int adbNextEnd = 0; /* the next incoming bute is the last (II) */
+int adbSoftPower = 0; /* machine supports soft power */
int adbWaitingCmd = 0; /* ADB command we are waiting for */
-u_char *adbBuffer = (long) 0; /* pointer to user data area */
-void *adbCompRout = (long) 0; /* pointer to the completion routine */
-void *adbCompData = (long) 0; /* pointer to the completion routine data */
+u_char *adbBuffer = (long)0; /* pointer to user data area */
+void *adbCompRout = (long)0; /* pointer to the completion routine */
+void *adbCompData = (long)0; /* pointer to the completion routine data */
long adbFakeInts = 0; /* keeps track of fake ADB interrupts for
* timeouts (II) */
int adbStarting = 1; /* doing ADBReInit so do polling differently */
@@ -190,8 +236,8 @@ int adbSendTalk = 0; /* the intr routine is sending the talk, not
int adbPolling = 0; /* we are polling for service request */
int adbPollCmd = 0; /* the last poll command we sent */
-u_char adbInputBuffer[MAX_ADB_MSG_LENGTH]; /* data input buffer */
-u_char adbOutputBuffer[MAX_ADB_MSG_LENGTH]; /* data output buffer */
+u_char adbInputBuffer[ADB_MAX_MSG_LENGTH]; /* data input buffer */
+u_char adbOutputBuffer[ADB_MAX_MSG_LENGTH]; /* data output buffer */
struct adbCmdHoldEntry adbOutQueue; /* our 1 entry output queue */
int adbSentChars = 0; /* how many characters we have sent */
@@ -199,30 +245,50 @@ int adbLastDevice = 0; /* last ADB dev we heard from (II ONLY) */
int adbLastDevIndex = 0; /* last ADB dev loc in dev table (II ONLY) */
int adbLastCommand = 0; /* the last ADB command we sent (II) */
-struct ADBDevEntry ADBDevTable[16]; /* our ADB device table */
+struct ADBDevEntry ADBDevTable[16]; /* our ADB device table */
int ADBNumDevices; /* num. of ADB devices found with ADBReInit */
+struct adbCommand adbInbound[ADB_QUEUE]; /* incoming queue */
+volatile int adbInCount = 0; /* how many packets in in queue */
+int adbInHead = 0; /* head of in queue */
+int adbInTail = 0; /* tail of in queue */
+struct adbCommand adbOutbound[ADB_QUEUE]; /* outgoing queue - not used yet */
+int adbOutCount = 0; /* how many packets in out queue */
+int adbOutHead = 0; /* head of out queue */
+int adbOutTail = 0; /* tail of out queue */
+
+int tickle_count = 0; /* how many tickles seen for this packet? */
+int tickle_serial = 0; /* the last packet tickled */
+int adb_cuda_serial = 0; /* the current packet */
+
+struct timeout adb_cuda_timeout;
+
extern struct mac68k_machine_S mac68k_machine;
void pm_setup_adb(void);
+void pm_hw_setup(void);
void pm_check_adb_devices(int);
-void pm_intr(void);
+void pm_intr(void *);
int pm_adb_op(u_char *, void *, void *, int);
void pm_init_adb_device(void);
/*
* The following are private routines.
*/
+#ifdef ADB_DEBUG
void print_single(u_char *);
-void adb_intr(void);
-void adb_intr_II(void);
-void adb_intr_IIsi(void);
-void adb_intr_cuda(void);
+#endif
+int adb_intr(void *);
+int adb_intr_II(void *);
+int adb_intr_IIsi(void *);
+int adb_intr_cuda(void *);
+void adb_soft_intr(void);
int send_adb_II(u_char *, u_char *, void *, void *, int);
int send_adb_IIsi(u_char *, u_char *, void *, void *, int);
int send_adb_cuda(u_char *, u_char *, void *, void *, int);
void adb_intr_cuda_test(void);
-void adb_handle_unsol(u_char *);
+void adb_cuda_tickle(void);
+void adb_pass_up(struct adbCommand *);
void adb_op_comprout(void);
void adb_reinit(void);
int count_adbs(void);
@@ -231,11 +297,9 @@ int get_adb_info(ADBDataBlock *, int);
int set_adb_info(ADBSetInfoBlock *, int);
void adb_setup_hw_type(void);
int adb_op(Ptr, Ptr, Ptr, short);
-void adb_handle_unsol(u_char *);
-int adb_op_sync(Ptr, Ptr, Ptr, short);
void adb_read_II(u_char *);
-void adb_cleanup(u_char *);
-void adb_cleanup_IIsi(u_char *);
+void adb_hw_setup(void);
+void adb_hw_setup_IIsi(u_char *);
void adb_comp_exec(void);
int adb_cmd_result(u_char *);
int adb_cmd_extra(u_char *);
@@ -245,6 +309,7 @@ int adb_prog_switch_disable(void);
/* we should create this and it will be the public version */
int send_adb(u_char *, void *, void *);
+#ifdef ADB_DEBUG
/*
* print_single
* Diagnostic display routine. Displays the hex values of the
@@ -252,64 +317,97 @@ int send_adb(u_char *, void *, void *);
* is in [0].
*/
void
-print_single(thestring)
- u_char *thestring;
+print_single(u_char *str)
{
int x;
- if ((int) (thestring[0]) == 0) {
- printf_intr("nothing returned\n");
+ if (str == 0) {
+ printf_intr("no data - null pointer\n");
return;
}
- if (thestring == 0) {
- printf_intr("no data - null pointer\n");
+ if (*str == 0) {
+ printf_intr("nothing returned\n");
return;
}
- if (thestring[0] > 20) {
+ if (*str > 20) {
printf_intr("ADB: ACK > 20 no way!\n");
- thestring[0] = 20;
+ *str = (u_char)20;
}
- printf_intr("(length=0x%x):", thestring[0]);
- for (x = 0; x < thestring[0]; x++)
- printf_intr(" 0x%02x", thestring[x + 1]);
+ printf_intr("(length=0x%x):", (u_int)*str);
+ for (x = 1; x <= *str; x++)
+ printf_intr(" 0x%02x", (u_int)*(str + x));
printf_intr("\n");
}
+#endif
+
+void
+adb_cuda_tickle(void)
+{
+ volatile int s;
+
+ if (adbActionState == ADB_ACTION_IN) {
+ if (tickle_serial == adb_cuda_serial) {
+ if (++tickle_count > 0) {
+ s = splhigh();
+ adbActionState = ADB_ACTION_IDLE;
+ adbInputBuffer[0] = 0;
+ ADB_SET_STATE_IDLE_CUDA();
+ splx(s);
+ }
+ } else {
+ tickle_serial = adb_cuda_serial;
+ tickle_count = 0;
+ }
+ } else {
+ tickle_serial = adb_cuda_serial;
+ tickle_count = 0;
+ }
+ timeout_add(&adb_cuda_timeout, ADB_TICKLE_TICKS);
+}
/*
* called when when an adb interrupt happens
*
* Cuda version of adb_intr
- * TO DO: do we want to add some zshard calls in here?
+ * TO DO: do we want to add some calls to intr_dispatch() here to
+ * grab serial interrupts?
*/
-void
-adb_intr_cuda(void)
+int
+adb_intr_cuda(void *arg)
{
- int i, ending, len;
- unsigned int s;
+ volatile int i, ending;
+ volatile unsigned int s;
+ struct adbCommand packet;
s = splhigh(); /* can't be too careful - might be called */
/* from a routine, NOT an interrupt */
ADB_VIA_CLR_INTR(); /* clear interrupt */
-
ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */
switch_start:
switch (adbActionState) {
case ADB_ACTION_IDLE:
- /* This is an unexpected packet, so grab the first (dummy)
+ /*
+ * This is an unexpected packet, so grab the first (dummy)
* byte, set up the proper vars, and tell the chip we are
- * starting to receive the packet by setting the TIP bit. */
+ * starting to receive the packet by setting the TIP bit.
+ */
adbInputBuffer[1] = ADB_SR();
- ADB_SET_STATE_TIP();
+ adb_cuda_serial++;
+ if (ADB_INTR_IS_OFF) /* must have been a fake start */
+ break;
+
ADB_SET_SR_INPUT();
- delay(ADB_DELAY); /* required delay */
-#ifdef DEBUG
- printf_intr("idle 0x%02x ", adbInputBuffer[1]);
-#endif
+ ADB_SET_STATE_TIP();
+
adbInputBuffer[0] = 1;
adbActionState = ADB_ACTION_IN;
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("idle 0x%02x ", adbInputBuffer[1]);
+#endif
break;
case ADB_ACTION_IN:
@@ -320,72 +418,54 @@ switch_start:
else
ending = 0;
- /* if the second byte is 0xff, it's a "dummy" packet */
- if (adbInputBuffer[2] == 0xff)
- ending = 1;
-
if (1 == ending) { /* end of message? */
-#ifdef DEBUG
- printf_intr("in end 0x%02x ",
- adbInputBuffer[adbInputBuffer[0]]);
- print_single(adbInputBuffer);
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf_intr("in end 0x%02x ",
+ adbInputBuffer[adbInputBuffer[0]]);
+ print_single(adbInputBuffer);
+ }
#endif
- /* Are we waiting AND does this packet match what we
+ /*
+ * Are we waiting AND does this packet match what we
* are waiting for AND is it coming from either the
* ADB or RTC/PRAM sub-device? This section _should_
* recognize all ADB and RTC/PRAM type commands, but
* there may be more... NOTE: commands are always at
- * [4], even for RTC/PRAM commands. */
+ * [4], even for RTC/PRAM commands.
+ */
+ /* set up data for adb_pass_up */
+ memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1);
+
if ((adbWaiting == 1) &&
(adbInputBuffer[4] == adbWaitingCmd) &&
((adbInputBuffer[2] == 0x00) ||
(adbInputBuffer[2] == 0x01))) {
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.unsol = 0;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
- if (adbBuffer != (long) 0) {
- /* if valid return data pointer */
- /* get return length minus extras */
- len = adbInputBuffer[0] - 4;
- /*
- * If adb_op is ever made to be called
- * from a user routine, we should use
- * a copyout or copyin here to be sure
- * we're in the correct context
- */
- for (i = 1; i <= len; i++)
- adbBuffer[i] = adbInputBuffer[4 + i];
- if (len < 0)
- len = 0;
- adbBuffer[0] = len;
- }
- /* call completion routine and clean up */
- adb_comp_exec();
- adbWaitingCmd = 0;
+ adbWaitingCmd = 0; /* reset "waiting" vars */
adbWaiting = 0;
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
} else {
- /*
- * This was an unsolicited packet, so
- * pass the data off to the handler for
- * this device if we are NOT doing this
- * during a ADBReInit.
- * This section IGNORES all data that is not
- * from the ADB sub-device. That is, not from
- * RTC or PRAM. Maybe we should fix later,
- * but do the other devices every send things
- * without being asked?
- */
- if (adbStarting == 0)
- if (adbInputBuffer[2] == 0x00)
- adb_handle_unsol(adbInputBuffer);
+ packet.unsol = 1;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
}
+
/* reset vars and signal the end of this frame */
adbActionState = ADB_ACTION_IDLE;
adbInputBuffer[0] = 0;
ADB_SET_STATE_IDLE_CUDA();
+ /*ADB_SET_SR_INPUT();*/
/*
* If there is something waiting to be sent out,
@@ -395,9 +475,6 @@ switch_start:
delay(ADB_DELAY); /* required */
adbSentChars = 0;
adbActionState = ADB_ACTION_OUT;
-
-/* TO DO: don't we need to set up adbWaiting vars here??? */
-
/*
* If the interrupt is on, we were too slow
* and the chip has already started to send
@@ -405,8 +482,8 @@ switch_start:
* and start a read cycle.
*/
if (ADB_INTR_IS_ON) {
- ADB_SET_STATE_IDLE_CUDA();
ADB_SET_SR_INPUT();
+ ADB_SET_STATE_IDLE_CUDA();
adbSentChars = 0;
adbActionState = ADB_ACTION_IDLE;
adbInputBuffer[0] = 0;
@@ -417,33 +494,35 @@ switch_start:
* so load the first byte and tell the chip
* we want to send.
*/
+ ADB_SET_STATE_TIP();
ADB_SET_SR_OUTPUT();
ADB_SR() = adbOutputBuffer[adbSentChars + 1];
- ADB_SET_STATE_TIP();
}
} else {
ADB_TOGGLE_STATE_ACK_CUDA();
-#ifdef DEBUG
- printf_intr("in 0x%02x ",
- adbInputBuffer[adbInputBuffer[0]]);
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("in 0x%02x ",
+ adbInputBuffer[adbInputBuffer[0]]);
#endif
}
break;
case ADB_ACTION_OUT:
i = ADB_SR(); /* reset SR-intr in IFR */
-#ifdef DEBUG
- printf_intr("intr out 0x%02x ", i);
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("intr out 0x%02x ", i);
#endif
- ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
adbSentChars++;
if (ADB_INTR_IS_ON) { /* ADB intr low during write */
-#ifdef DEBUG
- printf_intr("intr was on ");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("intr was on ");
#endif
- ADB_SET_STATE_IDLE_CUDA();
ADB_SET_SR_INPUT(); /* make sure SR is set to IN */
+ ADB_SET_STATE_IDLE_CUDA();
adbSentChars = 0; /* must start all over */
adbActionState = ADB_ACTION_IDLE; /* new state */
adbInputBuffer[0] = 0;
@@ -459,63 +538,82 @@ switch_start:
* back? */
adbWaiting = 1; /* signal waiting for return */
adbWaitingCmd = adbOutputBuffer[2]; /* save waiting command */
- } else {/* no talk, so done */
- adb_comp_exec(); /* call completion
- * routine */
- adbWaitingCmd = 0; /* reset "waiting" vars,
- * just in case */
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+ } else { /* no talk, so done */
+ /* set up stuff for adb_pass_up */
+ memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1);
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.cmd = adbWaitingCmd;
+ packet.unsol = 0;
+ packet.ack_only = 1;
+ adb_pass_up(&packet);
+
+ /* reset "waiting" vars, just in case */
+ adbWaitingCmd = 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
}
adbWriteDelay = 0; /* done writing */
adbActionState = ADB_ACTION_IDLE; /* signal bus is idle */
+ ADB_SET_SR_INPUT();
ADB_SET_STATE_IDLE_CUDA();
-#ifdef DEBUG
- printf_intr("write done ");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("write done ");
#endif
} else {
ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* send next byte */
ADB_TOGGLE_STATE_ACK_CUDA(); /* signal byte ready to
* shift */
-#ifdef DEBUG
- printf_intr("toggle ");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("toggle ");
#endif
}
break;
case ADB_ACTION_NOTREADY:
- printf_intr("adb: not yet initialized\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: not yet initialized\n");
+#endif
break;
default:
- printf_intr("intr: unknown ADB state\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("intr: unknown ADB state\n");
+#endif
+ break;
}
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
splx(s); /* restore */
- return;
-} /* end adb_intr_IIsi */
+ return (1);
+} /* end adb_intr_cuda */
int
-send_adb_cuda(u_char * in, u_char * buffer, void *compRout, void *data, int
+send_adb_cuda(u_char *in, u_char *buffer, void *compRout, void *data, int
command)
{
- int i, s, len;
+ int s, len;
-#ifdef DEBUG
- printf_intr("SEND\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("SEND\n");
#endif
if (adbActionState == ADB_ACTION_NOTREADY)
return 1;
- s = splhigh(); /* don't interrupt while we are messing with
- * the ADB */
+ /* Don't interrupt while we are messing with the ADB */
+ s = splhigh();
if ((adbActionState == ADB_ACTION_IDLE) && /* ADB available? */
(ADB_INTR_IS_OFF)) { /* and no incoming interrupt? */
@@ -528,13 +626,16 @@ send_adb_cuda(u_char * in, u_char * buffer, void *compRout, void *data, int
return 1; /* really busy! */
}
-#ifdef DEBUG
- printf_intr("QUEUE\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("QUEUE\n");
#endif
- if ((long) in == (long) 0) { /* need to convert? */
- /* don't need to use adb_cmd_extra here because this section
- * will be called */
- /* ONLY when it is an ADB command (no RTC or PRAM) */
+ if ((long)in == (long)0) { /* need to convert? */
+ /*
+ * Don't need to use adb_cmd_extra here because this section
+ * will be called ONLY when it is an ADB command (no RTC or
+ * PRAM)
+ */
if ((command & 0x0c) == 0x08) /* copy addl data ONLY if
* doing a listen! */
len = buffer[0]; /* length of additional data */
@@ -544,14 +645,13 @@ send_adb_cuda(u_char * in, u_char * buffer, void *compRout, void *data, int
adbOutputBuffer[0] = 2 + len; /* dev. type + command + addl.
* data */
adbOutputBuffer[1] = 0x00; /* mark as an ADB command */
- adbOutputBuffer[2] = (u_char) command; /* load command */
+ adbOutputBuffer[2] = (u_char)command; /* load command */
- for (i = 1; i <= len; i++) /* copy additional output
- * data, if any */
- adbOutputBuffer[2 + i] = buffer[i];
+ /* copy additional output data, if any */
+ memcpy(adbOutputBuffer + 3, buffer + 1, len);
} else
- for (i = 0; i <= (adbOutputBuffer[0] + 1); i++)
- adbOutputBuffer[i] = in[i];
+ /* if data ready, just copy over */
+ memcpy(adbOutputBuffer, in, in[0] + 2);
adbSentChars = 0; /* nothing sent yet */
adbBuffer = buffer; /* save buffer to know where to save result */
@@ -560,8 +660,9 @@ send_adb_cuda(u_char * in, u_char * buffer, void *compRout, void *data, int
adbWaitingCmd = adbOutputBuffer[2]; /* save wait command */
if (adbWriteDelay != 1) { /* start command now? */
-#ifdef DEBUG
- printf_intr("out start NOW");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("out start NOW");
#endif
delay(ADB_DELAY);
adbActionState = ADB_ACTION_OUT; /* set next state */
@@ -574,24 +675,26 @@ send_adb_cuda(u_char * in, u_char * buffer, void *compRout, void *data, int
splx(s);
- if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked ? */
+ if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked? */
/* poll until byte done */
while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON)
|| (adbWaiting == 1))
- if (ADB_SR_INTR_IS_ON) /* wait for "interrupt" */
- adb_intr_cuda(); /* go process
- * "interrupt" */
+ if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */
+ adb_intr_cuda(NULL); /* go process it */
+ if (adb_polling)
+ adb_soft_intr();
+ }
return 0;
} /* send_adb_cuda */
-/* TO DO: add one or two zshard calls in here */
-void
-adb_intr_II(void)
+int
+adb_intr_II(void *arg)
{
- int i, len, intr_on = 0;
- int send = 0, do_srq = 0;
+ struct adbCommand packet;
+ int i, intr_on = 0;
+ int send = 0;
unsigned int s;
s = splhigh(); /* can't be too careful - might be called */
@@ -601,24 +704,73 @@ adb_intr_II(void)
ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */
-/*if (ADB_INTR_IS_ON)*/
-/* printf_intr("INTR ON ");*/
+ delay(ADB_DELAY); /* yuck (don't remove) */
+
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
+
if (ADB_INTR_IS_ON)
intr_on = 1; /* save for later */
-
+
+switch_start:
switch (adbActionState) {
+ case ADB_ACTION_POLLING:
+ if (!intr_on) {
+ if (adbOutQueueHasData) {
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("POLL-doing-out-queue. ");
+#endif
+ ADB_SET_STATE_IDLE_II();
+ delay(ADB_DELAY);
+
+ /* copy over data */
+ memcpy(adbOutputBuffer, adbOutQueue.outBuf,
+ adbOutQueue.outBuf[0] + 2);
+
+ adbBuffer = adbOutQueue.saveBuf; /* user data area */
+ adbCompRout = adbOutQueue.compRout; /* completion routine */
+ adbCompData = adbOutQueue.data; /* comp. rout. data */
+ adbOutQueueHasData = 0; /* currently processing
+ * "queue" entry */
+ adbSentChars = 0; /* nothing sent yet */
+ adbActionState = ADB_ACTION_OUT; /* set next state */
+ ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
+ ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
+ adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
+ ADB_SET_STATE_CMD(); /* tell ADB that we want to send */
+ break;
+ } else {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("pIDLE ");
+#endif
+ adbActionState = ADB_ACTION_IDLE;
+ }
+ } else {
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("pIN ");
+#endif
+ adbActionState = ADB_ACTION_IN;
+ }
+ delay(ADB_DELAY);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
+ goto switch_start;
+ break;
case ADB_ACTION_IDLE:
if (!intr_on) {
- /* printf_intr("FAKE DROPPED \n"); */
- /* printf_intr(" XX "); */
i = ADB_SR();
+ adbBusState = ADB_BUS_IDLE;
+ adbActionState = ADB_ACTION_IDLE;
+ ADB_SET_STATE_IDLE_II();
break;
}
- adbNextEnd = 0;
- /* printf_intr("idle "); */
adbInputBuffer[0] = 1;
adbInputBuffer[1] = ADB_SR(); /* get first byte */
- /* printf_intr("0x%02x ", adbInputBuffer[1]); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("idle 0x%02x ", adbInputBuffer[1]);
+#endif
ADB_SET_SR_INPUT(); /* make sure SR is set to IN */
adbActionState = ADB_ACTION_IN; /* set next state */
ADB_SET_STATE_EVEN(); /* set bus state to even */
@@ -627,128 +779,113 @@ adb_intr_II(void)
case ADB_ACTION_IN:
adbInputBuffer[++adbInputBuffer[0]] = ADB_SR(); /* get byte */
- /* printf_intr("in 0x%02x ",
- * adbInputBuffer[adbInputBuffer[0]]); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("in 0x%02x ",
+ adbInputBuffer[adbInputBuffer[0]]);
+#endif
ADB_SET_SR_INPUT(); /* make sure SR is set to IN */
- /*
- * Check for an unsolicited Service Request (SRQ).
- * An empty SRQ packet NEVER ends, so we must manually
- * check for the following condition.
- */
- if (adbInputBuffer[0] == 4 && adbInputBuffer[2] == 0xff &&
- adbInputBuffer[3] == 0xff && adbInputBuffer[4] == 0xff &&
- intr_on && !adbNextEnd)
- do_srq = 1;
-
- if (adbNextEnd == 1) { /* process last byte of packet */
- adbNextEnd = 0;
- /* printf_intr("done: "); */
-
- /* If the following conditions are true (4 byte
- * message, last 3 bytes are 0xff) then we basically
- * got a "no response" from the ADB chip, so change
- * the message to an empty one. We also clear intr_on
- * to stop the SRQ send later on because these packets
- * normally have the SRQ bit set even when there is
- * NOT a pending SRQ. */
- if (adbInputBuffer[0] == 4 && adbInputBuffer[2] == 0xff &&
- adbInputBuffer[3] == 0xff && adbInputBuffer[4] == 0xff) {
- /* printf_intr("NO RESP "); */
- intr_on = 0;
- adbInputBuffer[0] = 0;
+ if (intr_on) { /* process last byte of packet */
+ adbInputBuffer[0]--; /* minus one */
+ /*
+ * If intr_on was true, and it's the second byte, then
+ * the byte we just discarded is really valid, so
+ * adjust the count
+ */
+ if (adbInputBuffer[0] == 2) {
+ adbInputBuffer[0]++;
}
- adbLastDevice = (adbInputBuffer[1] & 0xf0) >> 4;
-
- if ((!adbWaiting || adbPolling)
- && (adbInputBuffer[0] != 0)) {
- /* unsolicided - ignore if starting */
- if (!adbStarting)
- adb_handle_unsol(adbInputBuffer);
- } else
- if (!adbPolling) { /* someone asked for it */
- /* printf_intr("SOL: "); */
- /* print_single(adbInputBuffer); */
- if (adbBuffer != (long) 0) { /* if valid return data
- * pointer */
- /* get return length minus
- * extras */
- len = adbInputBuffer[0] - 1;
-
- /* if adb_op is ever made to
- * be called from a user
- * routine, we should use a
- * copyout or copyin here to
- * be sure we're in the
- * correct context. */
- for (i = 1; i <= len; i++)
- adbBuffer[i] = adbInputBuffer[i + 1];
- if (len < 0)
- len = 0;
- adbBuffer[0] = len;
- }
- adb_comp_exec();
- }
+
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80) {
+ printf_intr("done: ");
+ print_single(adbInputBuffer);
+ }
+#endif
+
+ adbLastDevice = ADB_CMDADDR(adbInputBuffer[1]);
+
+ if (adbInputBuffer[0] == 1 && !adbWaiting) { /* SRQ!!!*/
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr(" xSRQ! ");
+#endif
+ adb_guess_next_device();
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("try 0x%0x ",
+ adbLastDevice);
+#endif
+ adbOutputBuffer[0] = 1;
+ adbOutputBuffer[1] = ADBTALK(adbLastDevice, 0);
+
+ adbSentChars = 0; /* nothing sent yet */
+ adbActionState = ADB_ACTION_POLLING; /* set next state */
+ ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
+ ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
+ adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
+ ADB_SET_STATE_CMD(); /* tell ADB that we want to */
+ break;
+ }
+
+ /* set up data for adb_pass_up */
+ memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1);
+
+ if (!adbWaiting && (adbInputBuffer[0] != 0)) {
+ packet.unsol = 1;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
+ } else {
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.unsol = 0;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
+ }
+
adbWaiting = 0;
- adbPolling = 0;
adbInputBuffer[0] = 0;
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
/*
* Since we are done, check whether there is any data
* waiting to do out. If so, start the sending the data.
*/
if (adbOutQueueHasData == 1) {
- /* printf_intr("XXX: DOING OUT QUEUE\n"); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("XXX: DOING OUT QUEUE\n");
+#endif
/* copy over data */
- for (i = 0; i <= (adbOutQueue.outBuf[0] + 1); i++)
- adbOutputBuffer[i] = adbOutQueue.outBuf[i];
+ memcpy(adbOutputBuffer, adbOutQueue.outBuf,
+ adbOutQueue.outBuf[0] + 2);
adbBuffer = adbOutQueue.saveBuf; /* user data area */
adbCompRout = adbOutQueue.compRout; /* completion routine */
adbCompData = adbOutQueue.data; /* comp. rout. data */
adbOutQueueHasData = 0; /* currently processing
* "queue" entry */
- adbPolling = 0;
send = 1;
- /* if intr_on is true, then it's a SRQ so poll
- * other devices. */
- } else
- if (intr_on) {
- /* printf_intr("starting POLL "); */
- do_srq = 1;
- adbPolling = 1;
- } else
- if ((adbInputBuffer[1] & 0x0f) != 0x0c) {
- /* printf_intr("xC HACK "); */
- adbPolling = 1;
- send = 1;
- adbOutputBuffer[0] = 1;
- adbOutputBuffer[1] = (adbInputBuffer[1] & 0xf0) | 0x0c;
- } else {
- /* printf_intr("ending "); */
- adbBusState = ADB_BUS_IDLE;
- adbActionState = ADB_ACTION_IDLE;
- ADB_SET_STATE_IDLE_II();
- break;
- }
- }
- /*
- * If do_srq is true then something above determined that
- * the message has ended and some device is sending a
- * service request. So we need to determine the next device
- * and send a poll to it. (If the device we send to isn't the
- * one that sent the SRQ, that ok as it will be caught
- * the next time though.)
- */
- if (do_srq) {
- /* printf_intr("SRQ! "); */
- adbPolling = 1;
- adb_guess_next_device();
- adbOutputBuffer[0] = 1;
- adbOutputBuffer[1] = ((adbLastDevice & 0x0f) << 4) | 0x0c;
- send = 1;
+ } else {
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("XXending ");
+#endif
+ adb_guess_next_device();
+ adbOutputBuffer[0] = 1;
+ adbOutputBuffer[1] = ((adbLastDevice & 0x0f) << 4) | 0x0c;
+ adbSentChars = 0; /* nothing sent yet */
+ adbActionState = ADB_ACTION_POLLING; /* set next state */
+ ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
+ ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
+ adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
+ ADB_SET_STATE_CMD(); /* tell ADB that we want to */
+ break;
+ }
}
+
/*
* If send is true then something above determined that
* the message has ended and we need to start sending out
@@ -756,7 +893,6 @@ adb_intr_II(void)
* is data waiting to go out or because an SRQ was seen.
*/
if (send) {
- adbNextEnd = 0;
adbSentChars = 0; /* nothing sent yet */
adbActionState = ADB_ACTION_OUT; /* set next state */
ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
@@ -767,9 +903,6 @@ adb_intr_II(void)
break;
}
/* We only get this far if the message hasn't ended yet. */
- if (!intr_on) /* if adb intr. on then the */
- adbNextEnd = 1; /* NEXT byte is the last */
-
switch (adbBusState) { /* set to next state */
case ADB_BUS_EVEN:
ADB_SET_STATE_ODD(); /* set state to odd */
@@ -787,9 +920,6 @@ adb_intr_II(void)
break;
case ADB_ACTION_OUT:
- adbNextEnd = 0;
- if (!adbPolling)
- adbWaiting = 1; /* not unsolicited */
i = ADB_SR(); /* clear interrupt */
adbSentChars++;
/*
@@ -803,44 +933,74 @@ adb_intr_II(void)
ADB_SET_SR_INPUT();
adbBusState = ADB_BUS_EVEN;
ADB_SET_STATE_EVEN();
- /* printf_intr("talk out 0x%02x ", i); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("talk out 0x%02x ", i);
+#endif
+ /* we want something back */
+ adbWaiting = 1;
break;
}
- /* If it's not a TALK, check whether all data has been sent.
+ /*
+ * If it's not a TALK, check whether all data has been sent.
* If so, call the completion routine and clean up. If not,
- * advance to the next state. */
- /* printf_intr("non-talk out 0x%0x ", i); */
+ * advance to the next state.
+ */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("non-talk out 0x%0x ", i);
+#endif
ADB_SET_SR_OUTPUT();
if (adbOutputBuffer[0] == adbSentChars) { /* check for done */
- /* printf_intr("done \n"); */
- adb_comp_exec();
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("done \n");
+#endif
+ /* set up stuff for adb_pass_up */
+ memcpy(packet.data, adbOutputBuffer, adbOutputBuffer[0] + 1);
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.cmd = adbWaitingCmd;
+ packet.unsol = 0;
+ packet.ack_only = 1;
+ adb_pass_up(&packet);
+
+ /* reset "waiting" vars, just in case */
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
if (adbOutQueueHasData == 1) {
/* copy over data */
- for (i = 0; i <= (adbOutQueue.outBuf[0] + 1); i++)
- adbOutputBuffer[i] = adbOutQueue.outBuf[i];
+ memcpy(adbOutputBuffer, adbOutQueue.outBuf,
+ adbOutQueue.outBuf[0] + 2);
adbBuffer = adbOutQueue.saveBuf; /* user data area */
adbCompRout = adbOutQueue.compRout; /* completion routine */
adbCompData = adbOutQueue.data; /* comp. rout. data */
adbOutQueueHasData = 0; /* currently processing
* "queue" entry */
- adbPolling = 0;
+ adbSentChars = 0; /* nothing sent yet */
+ adbActionState = ADB_ACTION_OUT; /* set next state */
+ ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
+ ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
+ adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
+ ADB_SET_STATE_CMD(); /* tell ADB that we want to
+ * send */
+ break;
} else {
+ /* send talk to last device instead */
adbOutputBuffer[0] = 1;
- adbOutputBuffer[1] = (adbOutputBuffer[1] & 0xf0) | 0x0c;
- adbPolling = 1; /* non-user poll */
+ adbOutputBuffer[1] =
+ ADBTALK(ADB_CMDADDR(adbOutputBuffer[1]), 0);
+
+ adbSentChars = 0; /* nothing sent yet */
+ adbActionState = ADB_ACTION_IDLE; /* set next state */
+ ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
+ ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
+ adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
+ ADB_SET_STATE_CMD(); /* tell ADB that we want to */
+ break;
}
- adbNextEnd = 0;
- adbSentChars = 0; /* nothing sent yet */
- adbActionState = ADB_ACTION_OUT; /* set next state */
- ADB_SET_SR_OUTPUT(); /* set shift register for OUT */
- ADB_SR() = adbOutputBuffer[1]; /* load byte for output */
- adbBusState = ADB_BUS_CMD; /* set bus to cmd state */
- ADB_SET_STATE_CMD(); /* tell ADB that we want to
- * send */
- break;
}
ADB_SR() = adbOutputBuffer[adbSentChars + 1];
switch (adbBusState) { /* advance to next state */
@@ -856,20 +1016,29 @@ adb_intr_II(void)
break;
default:
- printf_intr("strange state!!! (0x%x)\n", adbBusState);
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf_intr("strange state!!! (0x%x)\n",
+ adbBusState);
+ }
+#endif
break;
}
break;
default:
- printf_intr("adb: unknown ADB state (during intr)\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: unknown ADB state (during intr)\n");
+#endif
+ break;
}
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
splx(s); /* restore */
- return;
+ return (1);
}
@@ -878,22 +1047,22 @@ adb_intr_II(void)
* send_adb version for II series machines
*/
int
-send_adb_II(u_char * in, u_char * buffer, void *compRout, void *data, int command)
+send_adb_II(u_char *in, u_char *buffer, void *compRout, void *data, int command)
{
- int i, s, len;
+ int s, len;
if (adbActionState == ADB_ACTION_NOTREADY) /* return if ADB not
* available */
return 1;
- s = splhigh(); /* don't interrupt while we are messing with
- * the ADB */
+ /* Don't interrupt while we are messing with the ADB */
+ s = splhigh();
if (0 != adbOutQueueHasData) { /* right now, "has data" means "full" */
splx(s); /* sorry, try again later */
return 1;
}
- if ((long) in == (long) 0) { /* need to convert? */
+ if ((long)in == (long)0) { /* need to convert? */
/*
* Don't need to use adb_cmd_extra here because this section
* will be called ONLY when it is an ADB command (no RTC or
@@ -906,15 +1075,13 @@ send_adb_II(u_char * in, u_char * buffer, void *compRout, void *data, int comman
len = 0;/* no additional data */
adbOutQueue.outBuf[0] = 1 + len; /* command + addl. data */
- adbOutQueue.outBuf[1] = (u_char) command; /* load command */
+ adbOutQueue.outBuf[1] = (u_char)command; /* load command */
- for (i = 1; i <= len; i++) /* copy additional output
- * data, if any */
- adbOutQueue.outBuf[1 + i] = buffer[i];
+ /* copy additional output data, if any */
+ memcpy(adbOutQueue.outBuf + 2, buffer + 1, len);
} else
/* if data ready, just copy over */
- for (i = 0; i <= (adbOutQueue.outBuf[0] + 1); i++)
- adbOutQueue.outBuf[i] = in[i];
+ memcpy(adbOutQueue.outBuf, in, in[0] + 2);
adbOutQueue.saveBuf = buffer; /* save buffer to know where to save
* result */
@@ -923,11 +1090,10 @@ send_adb_II(u_char * in, u_char * buffer, void *compRout, void *data, int comman
adbOutQueue.data = data;/* save completion routine data pointer */
if ((adbActionState == ADB_ACTION_IDLE) && /* is ADB available? */
- (ADB_INTR_IS_OFF) &&/* and no incoming interrupts? */
- (adbPolling == 0)) {/* and we are not currently polling */
+ (ADB_INTR_IS_OFF)) { /* and no incoming interrupts? */
/* then start command now */
- for (i = 0; i <= (adbOutQueue.outBuf[0] + 1); i++) /* copy over data */
- adbOutputBuffer[i] = adbOutQueue.outBuf[i];
+ memcpy(adbOutputBuffer, adbOutQueue.outBuf,
+ adbOutQueue.outBuf[0] + 2); /* copy over data */
adbBuffer = adbOutQueue.saveBuf; /* pointer to user data
* area */
@@ -950,12 +1116,15 @@ send_adb_II(u_char * in, u_char * buffer, void *compRout, void *data, int comman
splx(s);
- if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked ? */
+ if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked? */
/* poll until message done */
while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON)
- || (adbWaiting == 1) || (adbPolling == 1))
- if (ADB_SR_INTR_IS_ON) /* wait for "interrupt" */
- adb_intr_II(); /* go process "interrupt" */
+ || (adbWaiting == 1))
+ if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */
+ adb_intr_II(NULL); /* go process it */
+ if (adb_polling)
+ adb_soft_intr();
+ }
return 0;
}
@@ -971,8 +1140,10 @@ adb_guess_next_device(void)
int last, i, dummy;
if (adbStarting) {
- /* start polling EVERY device, since we can't be sure there is
- * anything in the device table yet */
+ /*
+ * Start polling EVERY device, since we can't be sure there is
+ * anything in the device table yet
+ */
if (adbLastDevice < 1 || adbLastDevice > 15)
adbLastDevice = 1;
if (++adbLastDevice > 15) /* point to next one */
@@ -996,7 +1167,7 @@ adb_guess_next_device(void)
* device! This can happen if
* there are no devices on the
* bus */
- dummy = 2;
+ dummy = 1;
break;
}
/* found the next device */
@@ -1007,33 +1178,37 @@ adb_guess_next_device(void)
}
return adbLastDevice;
}
+
+
/*
* Called when when an adb interrupt happens.
* This routine simply transfers control over to the appropriate
* code for the machine we are running on.
*/
-void
-adb_intr(void)
+int
+adb_intr(void *arg)
{
switch (adbHardware) {
- case ADB_HW_II:
- adb_intr_II();
+ case ADB_HW_II:
+ return adb_intr_II(arg);
break;
case ADB_HW_IISI:
- adb_intr_IIsi();
+ return adb_intr_IIsi(arg);
break;
- case ADB_HW_PB:
+ case ADB_HW_PB: /* Should not come through here. */
break;
case ADB_HW_CUDA:
- adb_intr_cuda();
+ return adb_intr_cuda(arg);
break;
case ADB_HW_UNKNOWN:
break;
}
+
+ return (-1);
}
@@ -1043,10 +1218,11 @@ adb_intr(void)
* IIsi version of adb_intr
*
*/
-void
-adb_intr_IIsi(void)
+int
+adb_intr_IIsi(void *arg)
{
- int i, ending, len;
+ struct adbCommand packet;
+ int i, ending;
unsigned int s;
s = splhigh(); /* can't be too careful - might be called */
@@ -1071,7 +1247,7 @@ switch_start:
ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */
delay(ADB_DELAY); /* delay */
ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
break;
case ADB_ACTION_IN:
@@ -1085,15 +1261,19 @@ switch_start:
ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */
delay(ADB_DELAY); /* delay */
ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
if (1 == ending) { /* end of message? */
ADB_SET_STATE_INACTIVE(); /* signal end of frame */
- /* this section _should_ handle all ADB and RTC/PRAM
- * type commands, */
- /* but there may be more... */
- /* note: commands are always at [4], even for rtc/pram
- * commands */
+ /*
+ * This section _should_ handle all ADB and RTC/PRAM
+ * type commands, but there may be more... Note:
+ * commands are always at [4], even for rtc/pram
+ * commands
+ */
+ /* set up data for adb_pass_up */
+ memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1);
+
if ((adbWaiting == 1) && /* are we waiting AND */
(adbInputBuffer[4] == adbWaitingCmd) && /* the cmd we sent AND */
((adbInputBuffer[2] == 0x00) || /* it's from the ADB
@@ -1101,40 +1281,22 @@ switch_start:
(adbInputBuffer[2] == 0x01))) { /* it's from the
* PRAM/RTC device */
- /* is this data we are waiting for? */
- if (adbBuffer != (long) 0) { /* if valid return data
- * pointer */
- /* get return length minus extras */
- len = adbInputBuffer[0] - 4;
- /* if adb_op is ever made to be called
- * from a user routine, we should use
- * a copyout or copyin here to be sure
- * we're in the correct context */
- for (i = 1; i <= len; i++)
- adbBuffer[i] = adbInputBuffer[4 + i];
- if (len < 0)
- len = 0;
- adbBuffer[0] = len;
- }
- adb_comp_exec(); /* call completion
- * routine */
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.unsol = 0;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
adbWaitingCmd = 0; /* reset "waiting" vars */
adbWaiting = 0;
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
} else {
- /* pass the data off to the handler */
- /* This section IGNORES all data that is not
- * from the ADB sub-device. That is, not from
- * rtc or pram. Maybe we should fix later,
- * but do the other devices every send things
- * without being asked? */
- if (adbStarting == 0) /* ignore if during
- * adbreinit */
- if (adbInputBuffer[2] == 0x00)
- adb_handle_unsol(adbInputBuffer);
+ packet.unsol = 1;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
}
adbActionState = ADB_ACTION_IDLE;
@@ -1146,7 +1308,7 @@ switch_start:
adbActionState = ADB_ACTION_OUT; /* set next state */
delay(ADB_DELAY); /* delay */
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
if (ADB_INTR_IS_ON) { /* ADB intr low during
* write */
@@ -1187,13 +1349,13 @@ switch_start:
adbWriteDelay = 1; /* must retry when done with
* read */
delay(ADB_DELAY); /* delay */
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
goto switch_start; /* process next state right
* now */
break;
}
delay(ADB_DELAY); /* required delay */
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
if (adbOutputBuffer[0] == adbSentChars) { /* check for done */
if (0 == adb_cmd_result(adbOutputBuffer)) { /* do we expect data
@@ -1201,13 +1363,22 @@ switch_start:
adbWaiting = 1; /* signal waiting for return */
adbWaitingCmd = adbOutputBuffer[2]; /* save waiting command */
} else {/* no talk, so done */
- adb_comp_exec(); /* call completion
- * routine */
- adbWaitingCmd = 0; /* reset "waiting" vars,
- * just in case */
- adbBuffer = (long) 0;
- adbCompRout = (long) 0;
- adbCompData = (long) 0;
+ /* set up stuff for adb_pass_up */
+ memcpy(packet.data, adbInputBuffer,
+ adbInputBuffer[0] + 1);
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.cmd = adbWaitingCmd;
+ packet.unsol = 0;
+ packet.ack_only = 1;
+ adb_pass_up(&packet);
+
+ /* reset "waiting" vars, just in case */
+ adbWaitingCmd = 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
}
adbWriteDelay = 0; /* done writing */
@@ -1221,18 +1392,25 @@ switch_start:
break;
case ADB_ACTION_NOTREADY:
- printf_intr("adb: not yet initialized\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: not yet initialized\n");
+#endif
break;
default:
- printf_intr("intr: unknown ADB state\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("intr: unknown ADB state\n");
+#endif
+ break;
}
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
splx(s); /* restore */
- return;
+ return (1);
} /* end adb_intr_IIsi */
@@ -1240,27 +1418,27 @@ switch_start:
* if the device is currently busy, and there is no data waiting to go out, then
* the data is "queued" in the outgoing buffer. If we are already waiting, then
* we return.
- * in: if (in==0) then the command string is built from command and buffer
- * if (in!=0) then in is used as the command string
- * buffer: additional data to be sent (used only if in==0)
+ * in: if (in == 0) then the command string is built from command and buffer
+ * if (in != 0) then in is used as the command string
+ * buffer: additional data to be sent (used only if in == 0)
* this is also where return data is stored
* compRout: the completion routine that is called when then return value
* is received (if a return value is expected)
* data: a data pointer that can be used by the completion routine
- * command: an ADB command to be sent (used only if in==0)
+ * command: an ADB command to be sent (used only if in == 0)
*
*/
int
-send_adb_IIsi(u_char * in, u_char * buffer, void *compRout, void *data, int
+send_adb_IIsi(u_char *in, u_char *buffer, void *compRout, void *data, int
command)
{
- int i, s, len;
+ int s, len;
if (adbActionState == ADB_ACTION_NOTREADY)
return 1;
- s = splhigh(); /* don't interrupt while we are messing with
- * the ADB */
+ /* Don't interrupt while we are messing with the ADB */
+ s = splhigh();
if ((adbActionState == ADB_ACTION_IDLE) && /* ADB available? */
(ADB_INTR_IS_OFF)) {/* and no incoming interrupt? */
@@ -1274,10 +1452,12 @@ send_adb_IIsi(u_char * in, u_char * buffer, void *compRout, void *data, int
return 1; /* really busy! */
}
- if ((long) in == (long) 0) { /* need to convert? */
- /* don't need to use adb_cmd_extra here because this section
- * will be called */
- /* ONLY when it is an ADB command (no RTC or PRAM) */
+ if ((long)in == (long)0) { /* need to convert? */
+ /*
+ * Don't need to use adb_cmd_extra here because this section
+ * will be called ONLY when it is an ADB command (no RTC or
+ * PRAM)
+ */
if ((command & 0x0c) == 0x08) /* copy addl data ONLY if
* doing a listen! */
len = buffer[0]; /* length of additional data */
@@ -1287,14 +1467,13 @@ send_adb_IIsi(u_char * in, u_char * buffer, void *compRout, void *data, int
adbOutputBuffer[0] = 2 + len; /* dev. type + command + addl.
* data */
adbOutputBuffer[1] = 0x00; /* mark as an ADB command */
- adbOutputBuffer[2] = (u_char) command; /* load command */
+ adbOutputBuffer[2] = (u_char)command; /* load command */
- for (i = 1; i <= len; i++) /* copy additional output
- * data, if any */
- adbOutputBuffer[2 + i] = buffer[i];
+ /* copy additional output data, if any */
+ memcpy(adbOutputBuffer + 3, buffer + 1, len);
} else
- for (i = 0; i <= (adbOutputBuffer[0] + 1); i++)
- adbOutputBuffer[i] = in[i];
+ /* if data ready, just copy over */
+ memcpy(adbOutputBuffer, in, in[0] + 2);
adbSentChars = 0; /* nothing sent yet */
adbBuffer = buffer; /* save buffer to know where to save result */
@@ -1318,153 +1497,259 @@ send_adb_IIsi(u_char * in, u_char * buffer, void *compRout, void *data, int
splx(s);
- if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked ? */
+ if (0x0100 <= (s & 0x0700)) /* were VIA1 interrupts blocked? */
/* poll until byte done */
while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON)
|| (adbWaiting == 1))
- if (ADB_SR_INTR_IS_ON) /* wait for "interrupt" */
- adb_intr_IIsi(); /* go process
- * "interrupt" */
+ if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */
+ adb_intr_IIsi(NULL); /* go process it */
+ if (adb_polling)
+ adb_soft_intr();
+ }
- return 0;
+ return 0;
} /* send_adb_IIsi */
-
-/*
- * adb_comp_exec
- * This is a general routine that calls the completion routine if there is one.
+/*
+ * adb_pass_up is called by the interrupt-time routines.
+ * It takes the raw packet data that was received from the
+ * device and puts it into the queue that the upper half
+ * processes. It then signals for a soft ADB interrupt which
+ * will eventually call the upper half routine (adb_soft_intr).
+ *
+ * If in->unsol is 0, then this is either the notification
+ * that the packet was sent (on a LISTEN, for example), or the
+ * response from the device (on a TALK). The completion routine
+ * is called only if the user specified one.
+ *
+ * If in->unsol is 1, then this packet was unsolicited and
+ * so we look up the device in the ADB device table to determine
+ * what it's default service routine is.
+ *
+ * If in->ack_only is 1, then we really only need to call
+ * the completion routine, so don't do any other stuff.
+ *
+ * Note that in->data contains the packet header AND data,
+ * while adbInbound[]->data contains ONLY data.
+ *
+ * Note: Called only at interrupt time. Assumes this.
*/
void
-adb_comp_exec(void)
+adb_pass_up(struct adbCommand *in)
{
- if ((long) 0 != adbCompRout) /* don't call if empty return location */
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- asm("
- movml #0xffff, sp@- | save all registers
- movl %0, a2 | adbCompData
- movl %1, a1 | adbCompRout
- movl %2, a0 | adbBuffer
- movl %3, d0 | adbWaitingCmd
- jbsr a1@ | go call the routine
- movml sp@+, #0xffff | restore all registers"
- :
- :"g"(adbCompData), "g"(adbCompRout),
- "g"(adbBuffer), "g"(adbWaitingCmd)
- :"d0", "a0", "a1", "a2");
-#else /* for macos based testing */
- asm {
- movem.l a0/a1/a2/d0, -(a7)
- move.l adbCompData, a2
- move.l adbCompRout, a1
- move.l adbBuffer, a0
- move.w adbWaitingCmd, d0
- jsr(a1)
- movem.l(a7) +, d0/a2/a1/a0
+ int start = 0, len = 0, cmd = 0;
+ ADBDataBlock block;
+
+ /* temp for testing */
+ /*u_char *buffer = 0;*/
+ /*u_char *compdata = 0;*/
+ /*u_char *comprout = 0;*/
+
+ if (adbInCount >= ADB_QUEUE) {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: ring buffer overflow\n");
+#endif
+ return;
+ }
+
+ if (in->ack_only) {
+ len = in->data[0];
+ cmd = in->cmd;
+ start = 0;
+ } else {
+ switch (adbHardware) {
+ case ADB_HW_II:
+ cmd = in->data[1];
+ if (in->data[0] < 2)
+ len = 0;
+ else
+ len = in->data[0]-1;
+ start = 1;
+ break;
+
+ case ADB_HW_IISI:
+ case ADB_HW_CUDA:
+ /* If it's unsolicited, accept only ADB data for now */
+ if (in->unsol)
+ if (0 != in->data[2])
+ return;
+ cmd = in->data[4];
+ if (in->data[0] < 5)
+ len = 0;
+ else
+ len = in->data[0]-4;
+ start = 4;
+ break;
+
+ case ADB_HW_PB:
+ cmd = in->data[1];
+ if (in->data[0] < 2)
+ len = 0;
+ else
+ len = in->data[0]-1;
+ start = 1;
+ break;
+
+ case ADB_HW_UNKNOWN:
+ return;
}
+
+ /* Make sure there is a valid device entry for this device */
+ if (in->unsol) {
+ /* ignore unsolicited data during adbreinit */
+ if (adbStarting)
+ return;
+ /* get device's comp. routine and data area */
+ if (-1 == get_adb_info(&block, ADB_CMDADDR(cmd)))
+ return;
+ }
+ }
+
+ /*
+ * If this is an unsolicited packet, we need to fill in
+ * some info so adb_soft_intr can process this packet
+ * properly. If it's not unsolicited, then use what
+ * the caller sent us.
+ */
+ if (in->unsol) {
+ adbInbound[adbInTail].compRout = (void *)block.dbServiceRtPtr;
+ adbInbound[adbInTail].compData = (void *)block.dbDataAreaAddr;
+ adbInbound[adbInTail].saveBuf = (void *)adbInbound[adbInTail].data;
+ } else {
+ adbInbound[adbInTail].compRout = (void *)in->compRout;
+ adbInbound[adbInTail].compData = (void *)in->compData;
+ adbInbound[adbInTail].saveBuf = (void *)in->saveBuf;
+ }
+
+#ifdef ADB_DEBUG
+ if (adb_debug && in->data[1] == 2)
+ printf_intr("adb: caught error\n");
#endif
+
+ /* copy the packet data over */
+ /*
+ * TO DO: If the *_intr routines fed their incoming data
+ * directly into an adbCommand struct, which is passed to
+ * this routine, then we could eliminate this copy.
+ */
+ memcpy(adbInbound[adbInTail].data + 1, in->data + start + 1, len);
+ adbInbound[adbInTail].data[0] = len;
+ adbInbound[adbInTail].cmd = cmd;
+
+ adbInCount++;
+ if (++adbInTail >= ADB_QUEUE)
+ adbInTail = 0;
+
+ /*
+ * If the debugger is running, call upper half manually.
+ * Otherwise, trigger a soft interrupt to handle the rest later.
+ */
+ if (adb_polling)
+ adb_soft_intr();
+ else
+ setsoftadb();
+
+ return;
}
/*
- * This routine handles what needs to be done after an unsolicited
- * message is read from the ADB device. 'in' points to the raw
- * data received from the device, including device number
- * (on IIsi) and result code.
+ * Called to process the packets after they have been
+ * placed in the incoming queue.
*
- * Note that the service (completion) routine for an unsolicited
- * message is whatever is set in the ADB device table. This is
- * different than for a device responding to a specific request,
- * where the completion routine is defined by the caller.
*/
void
-adb_handle_unsol(u_char * in)
+adb_soft_intr(void)
{
- int i, cmd = 0;
- u_char data[MAX_ADB_MSG_LENGTH];
+ int s;
+ int cmd = 0;
u_char *buffer = 0;
- ADBDataBlock block;
+ u_char *comprout = 0;
+ u_char *compdata = 0;
- /* make local copy so we don't destroy the real one - it may be needed
- * later. */
- for (i = 0; i <= (in[0] + 1); i++)
- data[i] = in[i];
-
- switch (adbHardware) {
- case ADB_HW_II:
- /* adjust the "length" byte */
- cmd = data[1];
- if (data[0] < 2)
- data[1] = 0;
- else
- data[1] = data[0] - 1;
-
- buffer = (data + 1);
- break;
-
- case ADB_HW_IISI:
- case ADB_HW_CUDA:
- /* only handles ADB for now */
- if (0 != *(data + 2))
- return;
-
- /* adjust the "length" byte */
- cmd = data[4];
- if (data[0] < 5)
- data[4] = 0;
- else
- data[4] = data[0] - 4;
-
- buffer = (data + 4);
- break;
-
- case ADB_HW_PB:
- return; /* how does PM handle "unsolicited" messages? */
+#if 0
+ s = splhigh();
+ printf_intr("sr: %x\n", (s & 0x0700));
+ splx(s);
+#endif
- case ADB_HW_UNKNOWN:
- return;
- }
+/*delay(2*ADB_DELAY);*/
- if (-1 == get_adb_info(&block, ((cmd & 0xf0) >> 4)))
- return;
+ while (adbInCount) {
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("%x %x %x ",
+ adbInCount, adbInHead, adbInTail);
+#endif
+ /* get the data we need from the queue */
+ buffer = adbInbound[adbInHead].saveBuf;
+ comprout = adbInbound[adbInHead].compRout;
+ compdata = adbInbound[adbInHead].compData;
+ cmd = adbInbound[adbInHead].cmd;
+
+ /* copy over data to data area if it's valid */
+ /*
+ * Note that for unsol packets we don't want to copy the
+ * data anywhere, so buffer was already set to 0.
+ * For ack_only buffer was set to 0, so don't copy.
+ */
+ if (buffer)
+ memcpy(buffer, adbInbound[adbInHead].data,
+ adbInbound[adbInHead].data[0] + 1);
+
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80) {
+ printf_intr("%p %p %p %x ",
+ buffer, comprout, compdata, (short)cmd);
+ printf_intr("buf: ");
+ print_single(adbInbound[adbInHead].data);
+ }
+#endif
- /* call default completion routine if it's valid */
- /* TO DO: This section of code is somewhat redundant with
- * adb_comp_exec (above). Some day we may want to generalize it and
- * make it a single function. */
- if ((long) 0 != (long) block.dbServiceRtPtr) {
+ /* call default completion routine if it's valid */
+ if (comprout) {
#if defined(__NetBSD__) || defined(__OpenBSD__)
- asm("
- movml #0xffff, sp@- | save all registers
- movl %0, a2 | block.dbDataAreaAddr
- movl %1, a1 | block.dbServiceRtPtr
- movl %2, a0 | buffer
- movl %3, d0 | cmd
- jbsr a1@ | go call the routine
- movml sp@+, #0xffff | restore all registers"
- :
- : "g"(block.dbDataAreaAddr),
- "g"(block.dbServiceRtPtr), "g"(buffer), "g"(cmd)
- : "d0", "a0", "a1", "a2");
+ __asm __volatile (
+ " movml #0xffff,sp@- \n" /* save all regs */
+ " movl %0,a2 \n" /* compdata */
+ " movl %1,a1 \n" /* comprout */
+ " movl %2,a0 \n" /* buffer */
+ " movl %3,d0 \n" /* cmd */
+ " jbsr a1@ \n" /* go call routine */
+ " movml sp@+,#0xffff" /* restore all regs */
+ :
+ : "g"(compdata), "g"(comprout),
+ "g"(buffer), "g"(cmd)
+ : "d0", "a0", "a1", "a2");
#else /* for macos based testing */
- asm
- {
- movem.l a0/a1/a2/d0, -(a7)
- move.l block.dbDataAreaAddr, a2
- move.l block.dbServiceRtPtr, a1
- move.l buffer, a0
- move.w cmd, d0
- jsr(a1)
- movem.l(a7) +, d0/a2/a1/a0
- }
+ asm
+ {
+ movem.l a0/a1/a2/d0, -(a7)
+ move.l compdata, a2
+ move.l comprout, a1
+ move.l buffer, a0
+ move.w cmd, d0
+ jsr(a1)
+ movem.l(a7)+, d0/a2/a1/a0
+ }
#endif
+ }
+
+ s = splhigh();
+ adbInCount--;
+ if (++adbInHead >= ADB_QUEUE)
+ adbInHead = 0;
+ splx(s);
+
}
return;
}
/*
- * This is my version of the ADBOp routine. It mainly just calls the hardware-specific
- * routine.
+ * This is my version of the ADBOp routine. It mainly just calls the
+ * hardware-specific routine.
*
* data : pointer to data area to be used by compRout
* compRout : completion routine
@@ -1472,8 +1757,8 @@ adb_handle_unsol(u_char * in)
* byte 0 = # of bytes
* : for TALK: points to place to save return data
* command : the adb command to send
- * result : 0 = success
- * : -1 = could not complete
+ * result : 0 = success
+ * : -1 = could not complete
*/
int
adb_op(Ptr buffer, Ptr compRout, Ptr data, short command)
@@ -1482,9 +1767,8 @@ adb_op(Ptr buffer, Ptr compRout, Ptr data, short command)
switch (adbHardware) {
case ADB_HW_II:
- result = send_adb_II((u_char *) 0,
- (u_char *) buffer, (void *) compRout,
- (void *) data, (int) command);
+ result = send_adb_II((u_char *)0, (u_char *)buffer,
+ (void *)compRout, (void *)data, (int)command);
if (result == 0)
return 0;
else
@@ -1492,9 +1776,8 @@ adb_op(Ptr buffer, Ptr compRout, Ptr data, short command)
break;
case ADB_HW_IISI:
- result = send_adb_IIsi((u_char *) 0,
- (u_char *) buffer, (void *) compRout,
- (void *) data, (int) command);
+ result = send_adb_IIsi((u_char *)0, (u_char *)buffer,
+ (void *)compRout, (void *)data, (int)command);
/*
* I wish I knew why this delay is needed. It usually needs to
* be here when several commands are sent in close succession,
@@ -1519,9 +1802,8 @@ adb_op(Ptr buffer, Ptr compRout, Ptr data, short command)
break;
case ADB_HW_CUDA:
- result = send_adb_cuda((u_char *) 0,
- (u_char *) buffer, (void *) compRout,
- (void *) data, (int) command);
+ result = send_adb_cuda((u_char *)0, (u_char *)buffer,
+ (void *)compRout, (void *)data, (int)command);
if (result == 0)
return 0;
else
@@ -1536,33 +1818,92 @@ adb_op(Ptr buffer, Ptr compRout, Ptr data, short command)
/*
- * adb_cleanup
- * This routine simply calls the appropriate version of the adb_cleanup routine.
+ * adb_hw_setup
+ * This routine sets up the possible machine specific hardware
+ * config (mainly VIA settings) for the various models.
*/
void
-adb_cleanup(u_char * in)
+adb_hw_setup(void)
{
volatile int i;
+ u_char send_string[ADB_MAX_MSG_LENGTH];
switch (adbHardware) {
case ADB_HW_II:
+ via1_register_irq(2, adb_intr_II, NULL, NULL);
+
+ via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
+ * outputs */
+ via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
+ via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
+ * to IN (II, IIsi) */
+ adbActionState = ADB_ACTION_IDLE; /* used by all types of
+ * hardware (II, IIsi) */
+ adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
+ * code only */
+ via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
+ * are on (II, IIsi) */
+ ADB_SET_STATE_IDLE_II(); /* set ADB bus state to idle */
+
ADB_VIA_CLR_INTR(); /* clear interrupt */
break;
case ADB_HW_IISI:
+ via1_register_irq(2, adb_intr_IIsi, NULL, NULL);
+ via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
+ * outputs */
+ via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
+ via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
+ * to IN (II, IIsi) */
+ adbActionState = ADB_ACTION_IDLE; /* used by all types of
+ * hardware (II, IIsi) */
+ adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
+ * code only */
+ via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
+ * are on (II, IIsi) */
+ ADB_SET_STATE_IDLE_IISI(); /* set ADB bus state to idle */
+
/* get those pesky clock ticks we missed while booting */
- adb_cleanup_IIsi(in);
+ for (i = 0; i < 30; i++) {
+ delay(ADB_DELAY);
+ adb_hw_setup_IIsi(send_string);
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf_intr("adb: cleanup: ");
+ print_single(send_string);
+ }
+#endif
+ delay(ADB_DELAY);
+ if (ADB_INTR_IS_OFF)
+ break;
+ }
break;
case ADB_HW_PB:
/*
- * XXX - really PM_VIA_CLR_INTR - should we put it in
+ * XXX - really PM_VIA_CLR_INTR - should we put it in
* pm_direct.h?
*/
- via_reg(VIA1, vIFR) = 0x90; /* clear interrupt */
+ pm_hw_setup();
break;
case ADB_HW_CUDA:
+ via1_register_irq(2, adb_intr_cuda, NULL, NULL);
+ via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
+ * outputs */
+ via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
+ via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
+ * to IN */
+ via_reg(VIA1, vACR) = (via_reg(VIA1, vACR) | 0x0c) & ~0x10;
+ adbActionState = ADB_ACTION_IDLE; /* used by all types of
+ * hardware */
+ adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
+ * code only */
+ via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
+ * are on */
+ ADB_SET_STATE_IDLE_CUDA(); /* set ADB bus state to idle */
+
+ /* sort of a device reset */
i = ADB_SR(); /* clear interrupt */
ADB_VIA_INTR_DISABLE(); /* no interrupts while clearing */
ADB_SET_STATE_IDLE_CUDA(); /* reset state to idle */
@@ -1579,20 +1920,24 @@ adb_cleanup(u_char * in)
break;
case ADB_HW_UNKNOWN:
+ default:
+ via_reg(VIA1, vIER) = 0x04; /* turn interrupts off - TO
+ * DO: turn PB ints off? */
return;
+ break;
}
}
/*
- * adb_cleanup_IIsi
+ * adb_hw_setup_IIsi
* This is sort of a "read" routine that forces the adb hardware through a read cycle
* if there is something waiting. This helps "clean up" any commands that may have gotten
* stuck or stopped during the boot process.
*
*/
void
-adb_cleanup_IIsi(u_char * buffer)
+adb_hw_setup_IIsi(u_char *buffer)
{
int i;
int dummy;
@@ -1614,17 +1959,21 @@ adb_cleanup_IIsi(u_char * buffer)
endofframe = 0;
while (0 == endofframe) {
- /* poll for ADB interrupt and watch for timeout */
- /* if time out, keep going in hopes of not hanging the
- * ADB chip - I think */
+ /*
+ * Poll for ADB interrupt and watch for timeout.
+ * If time out, keep going in hopes of not hanging
+ * the ADB chip - I think
+ */
my_time = ADB_DELAY * 5;
while ((ADB_SR_INTR_IS_OFF) && (my_time-- > 0))
dummy = via_reg(VIA1, vBufB);
buffer[i++] = ADB_SR(); /* reset interrupt flag by
* reading vSR */
- /* perhaps put in a check here that ignores all data
- * after the first MAX_ADB_MSG_LENGTH bytes ??? */
+ /*
+ * Perhaps put in a check here that ignores all data
+ * after the first ADB_MAX_MSG_LENGTH bytes ???
+ */
if (ADB_INTR_IS_OFF) /* check for end of frame */
endofframe = 1;
@@ -1643,7 +1992,7 @@ adb_cleanup_IIsi(u_char * buffer)
splx(s); /* restore interrupts */
return;
-} /* adb_cleanup_IIsi */
+} /* adb_hw_setup_IIsi */
@@ -1654,110 +2003,49 @@ adb_cleanup_IIsi(u_char * buffer)
void
adb_reinit(void)
{
- u_char send_string[MAX_ADB_MSG_LENGTH];
- int s = 0;
+ u_char send_string[ADB_MAX_MSG_LENGTH];
+ ADBDataBlock data; /* temp. holder for getting device info */
volatile int i, x;
+ int s;
int command;
int result;
int saveptr; /* point to next free relocation address */
int device;
int nonewtimes; /* times thru loop w/o any new devices */
- ADBDataBlock data; /* temp. holder for getting device info */
+
+ adb_setup_hw_type(); /* setup hardware type */
/* Make sure we are not interrupted while building the table. */
- if (adbHardware != ADB_HW_PB) /* ints must be on for PB? */
+ /* ints must be on for PB & IOP (at least, for now) */
+ if (adbHardware != ADB_HW_PB)
s = splhigh();
+ else
+ s = 0; /* XXX shut the compiler up*/
ADBNumDevices = 0; /* no devices yet */
/* Let intr routines know we are running reinit */
adbStarting = 1;
- /* Initialize the ADB table. For now, we'll always use the same table
- * that is defined at the beginning of this file - no mallocs. */
- for (i = 0; i < 16; i++)
- ADBDevTable[i].devType = 0;
-
- adb_setup_hw_type(); /* setup hardware type */
-
- /* Set up all the VIA bits we need to do the ADB stuff. */
- switch (adbHardware) {
- case ADB_HW_II:
- via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
- * outputs */
- via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
- via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
- * to IN (II, IIsi) */
- adbActionState = ADB_ACTION_IDLE; /* used by all types of
- * hardware (II, IIsi) */
- adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
- * code only */
- via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
- * are on (II, IIsi) */
- ADB_SET_STATE_IDLE_II(); /* set ADB bus state to idle */
- break;
-
- case ADB_HW_IISI:
- via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
- * outputs */
- via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
- via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
- * to IN (II, IIsi) */
- adbActionState = ADB_ACTION_IDLE; /* used by all types of
- * hardware (II, IIsi) */
- adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
- * code only */
- via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
- * are on (II, IIsi) */
- ADB_SET_STATE_IDLE_IISI(); /* set ADB bus state to idle */
- break;
-
- case ADB_HW_PB:
- break; /* there has to be more than this? */
-
- case ADB_HW_CUDA:
- via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5:
- * outputs */
- via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */
- via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set
- * to IN */
- via_reg(VIA1, vACR) = (via_reg(VIA1, vACR) | 0x0c) & ~0x10;
- adbActionState = ADB_ACTION_IDLE; /* used by all types of
- * hardware */
- adbBusState = ADB_BUS_IDLE; /* this var. used in II-series
- * code only */
- via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts
- * are on */
- ADB_SET_STATE_IDLE_CUDA(); /* set ADB bus state to idle */
- break;
-
- case ADB_HW_UNKNOWN: /* if type unknown then skip out */
- default:
- via_reg(VIA1, vIER) = 0x04; /* turn interrupts off - TO
- * DO: turn PB ints off? */
- splx(s);
- return;
- }
-
/*
- * Clear out any "leftover" commands. Remember that up until this
- * point, the interrupt routine will be either off or it should be
- * able to ignore inputs until the device table is built.
+ * Initialize the ADB table. For now, we'll always use the same table
+ * that is defined at the beginning of this file - no mallocs.
*/
- for (i = 0; i < 30; i++) {
- delay(ADB_DELAY);
- adb_cleanup(send_string);
- printf_intr("adb: cleanup: ");
- print_single(send_string);
- delay(ADB_DELAY);
- if (ADB_INTR_IS_OFF)
- break;
+ for (i = 0; i < 16; i++) {
+ ADBDevTable[i].devType = 0;
+ ADBDevTable[i].origAddr = ADBDevTable[i].currentAddr = 0;
}
+ adb_hw_setup(); /* init the VIA bits and hard reset ADB */
+
+ delay(1000);
+
/* send an ADB reset first */
- adb_op_sync((Ptr) 0, (Ptr) 0, (Ptr) 0, (short) 0x00);
+ (void)adb_op_sync((Ptr)0, (Ptr)0, (Ptr)0, (short)0x00);
+ delay(3000);
- /* Probe for ADB devices. Probe devices 1-15 quickly to determine
+ /*
+ * Probe for ADB devices. Probe devices 1-15 quickly to determine
* which device addresses are in use and which are free. For each
* address that is in use, move the device at that address to a higher
* free address. Continue doing this at that address until no device
@@ -1765,25 +2053,31 @@ adb_reinit(void)
* back to the original address. Do this for the remaining addresses
* that we determined were in use.
*
- * When finished, do this entire process over again with the updated list
- * of in use addresses. Do this until no new devices have been found
- * in 20 passes though the in use address list. (This probably seems
- * long and complicated, but it's the best way to detect multiple
+ * When finished, do this entire process over again with the updated
+ * list of in use addresses. Do this until no new devices have been
+ * found in 20 passes though the in use address list. (This probably
+ * seems long and complicated, but it's the best way to detect multiple
* devices at the same address - sometimes it takes a couple of tries
- * before the collision is detected.) */
+ * before the collision is detected.)
+ */
/* initial scan through the devices */
for (i = 1; i < 16; i++) {
- command = (int) (0x0f | ((int) (i & 0x000f) << 4)); /* talk R3 */
- result = adb_op_sync((Ptr) send_string, (Ptr) 0, (Ptr) 0, (short) command);
- if (0x00 != send_string[0]) { /* anything come back ?? */
- ADBDevTable[++ADBNumDevices].devType = (u_char) send_string[2];
+ command = ADBTALK(i, 3);
+ result = adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+
+ if (result == 0 && send_string[0] != 0) {
+ /* found a device */
+ ++ADBNumDevices;
+ KASSERT(ADBNumDevices < 16);
+ ADBDevTable[ADBNumDevices].devType =
+ (int)(send_string[2]);
ADBDevTable[ADBNumDevices].origAddr = i;
ADBDevTable[ADBNumDevices].currentAddr = i;
- ADBDevTable[ADBNumDevices].DataAreaAddr = (long) 0;
- ADBDevTable[ADBNumDevices].ServiceRtPtr = (void *) 0;
- /* printf_intr("initial device found (at index %i)\n",
- * ADBNumDevices); */
+ ADBDevTable[ADBNumDevices].DataAreaAddr =
+ (long)0;
+ ADBDevTable[ADBNumDevices].ServiceRtPtr = (void *)0;
pm_check_adb_devices(i); /* tell pm driver device
* is here */
}
@@ -1794,128 +2088,241 @@ adb_reinit(void)
if (-1 == get_adb_info(&data, saveptr))
break;
- if (saveptr == 0) /* no free addresses??? */
- saveptr = 15;
-
- /* printf_intr("first free is: 0x%02x\n", saveptr); */
- /* printf_intr("devices: %i\n", ADBNumDevices); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80) {
+ printf_intr("first free is: 0x%02x\n", saveptr);
+ printf_intr("devices: %i\n", ADBNumDevices);
+ }
+#endif
nonewtimes = 0; /* no loops w/o new devices */
- while (nonewtimes++ < 11) {
- for (i = 1; i <= ADBNumDevices; i++) {
+ while (saveptr > 0 && nonewtimes++ < 11) {
+ for (i = 1;saveptr > 0 && i <= ADBNumDevices; i++) {
device = ADBDevTable[i].currentAddr;
- /* printf_intr("moving device 0x%02x to 0x%02x (index
- * 0x%02x) ", device, saveptr, i); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("moving device 0x%02x to 0x%02x "
+ "(index 0x%02x) ", device, saveptr, i);
+#endif
/* send TALK R3 to address */
- command = (int) (0x0f | ((int) (device & 0x000f) << 4));
- adb_op_sync((Ptr) send_string, (Ptr) 0, (Ptr) 0, (short) command);
+ command = ADBTALK(device, 3);
+ (void)adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
/* move device to higher address */
- command = (int) (0x0b | ((int) (device & 0x000f) << 4));
+ command = ADBLISTEN(device, 3);
send_string[0] = 2;
- send_string[1] = (u_char) (saveptr | 0x60);
+ send_string[1] = (u_char)(saveptr | 0x60);
send_string[2] = 0xfe;
- adb_op_sync((Ptr) send_string, (Ptr) 0, (Ptr) 0, (short) command);
+ (void)adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+ delay(1000);
+
+ /* send TALK R3 - anthing at new address? */
+ command = ADBTALK(saveptr, 3);
+ send_string[0] = 0;
+ result = adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+ delay(1000);
+
+ if (result != 0 || send_string[0] == 0) {
+ /*
+ * maybe there's a communication breakdown;
+ * just in case, move it back from whence it
+ * came, and we'll try again later
+ */
+ command = ADBLISTEN(saveptr, 3);
+ send_string[0] = 2;
+ send_string[1] = (u_char)(device | 0x60);
+ send_string[2] = 0x00;
+ (void)adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("failed, continuing\n");
+#endif
+ delay(1000);
+ continue;
+ }
/* send TALK R3 - anything at old address? */
- command = (int) (0x0f | ((int) (device & 0x000f) << 4));
- result = adb_op_sync((Ptr) send_string, (Ptr) 0, (Ptr) 0, (short) command);
- if (send_string[0] != 0) {
+ command = ADBTALK(device, 3);
+ send_string[0] = 0;
+ result = adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+ if (result == 0 && send_string[0] != 0) {
/* new device found */
/* update data for previously moved device */
ADBDevTable[i].currentAddr = saveptr;
- /* printf_intr("old device at index %i\n",i); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("old device at index %i\n",i);
+#endif
/* add new device in table */
- /* printf_intr("new device found\n"); */
- ADBDevTable[++ADBNumDevices].devType = (u_char) send_string[2];
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("new device found\n");
+#endif
+ if (saveptr > ADBNumDevices) {
+ ++ADBNumDevices;
+ KASSERT(ADBNumDevices < 16);
+ }
+ ADBDevTable[ADBNumDevices].devType =
+ (int)(send_string[2]);
ADBDevTable[ADBNumDevices].origAddr = device;
ADBDevTable[ADBNumDevices].currentAddr = device;
/* These will be set correctly in adbsys.c */
/* Until then, unsol. data will be ignored. */
- ADBDevTable[ADBNumDevices].DataAreaAddr = (long) 0;
- ADBDevTable[ADBNumDevices].ServiceRtPtr = (void *) 0;
+ ADBDevTable[ADBNumDevices].DataAreaAddr =
+ (long)0;
+ ADBDevTable[ADBNumDevices].ServiceRtPtr =
+ (void *)0;
/* find next unused address */
- for (x = saveptr; x > 0; x--)
+ for (x = saveptr; x > 0; x--) {
if (-1 == get_adb_info(&data, x)) {
saveptr = x;
break;
}
- /* printf_intr("new free is 0x%02x\n",
- * saveptr); */
+ }
+ if (x == 0)
+ saveptr = 0;
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("new free is 0x%02x\n",
+ saveptr);
+#endif
nonewtimes = 0;
/* tell pm driver device is here */
pm_check_adb_devices(device);
} else {
- /* printf_intr("moving back...\n"); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("moving back...\n");
+#endif
/* move old device back */
- command = (int) (0x0b | ((int) (saveptr & 0x000f) << 4));
+ command = ADBLISTEN(saveptr, 3);
send_string[0] = 2;
- send_string[1] = (u_char) (device | 0x60);
+ send_string[1] = (u_char)(device | 0x60);
send_string[2] = 0xfe;
- adb_op_sync((Ptr) send_string, (Ptr) 0, (Ptr) 0, (short) command);
+ (void)adb_op_sync((Ptr)send_string, (Ptr)0,
+ (Ptr)0, (short)command);
+ delay(1000);
}
}
}
-#ifdef DEBUG
- for (i = 1; i <= ADBNumDevices; i++) {
- x = get_ind_adb_info(&data, i);
- if (x != -1)
- printf_intr("index 0x%x, addr 0x%x, type 0x%x\n", i, x, data.devType);
-
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ for (i = 1; i <= ADBNumDevices; i++) {
+ x = get_ind_adb_info(&data, i);
+ if (x != -1)
+ printf_intr("index 0x%x, addr 0x%x, type 0x%hx\n",
+ i, x, data.devType);
+ }
}
#endif
- adb_prog_switch_enable(); /* enable the programmer's switch, if
- * we have one */
+#ifndef MRG_ADB
+ /* enable the programmer's switch, if we have one */
+ adb_prog_switch_enable();
+#endif
- if (0 == ADBNumDevices) /* tell user if no devices found */
- printf_intr("adb: no devices found\n");
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ if (0 == ADBNumDevices) /* tell user if no devices found */
+ printf_intr("adb: no devices found\n");
+ }
+#endif
adbStarting = 0; /* not starting anymore */
- printf_intr("adb: ADBReInit complete\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: ADBReInit complete\n");
+#endif
- if (adbHardware != ADB_HW_PB) /* ints must be on for PB? */
+ if (adbHardware == ADB_HW_CUDA) {
+ timeout_set(&adb_cuda_timeout, (void *)adb_cuda_tickle, NULL);
+ timeout_add(&adb_cuda_timeout, ADB_TICKLE_TICKS);
+ }
+
+ /* ints must be on for PB & IOP (at least, for now) */
+ if (adbHardware != ADB_HW_PB)
splx(s);
+
return;
}
-/* adb_cmd_result
- * This routine lets the caller know whether the specified adb command string should
- * expect a returned result, such as a TALK command.
+/*
+ * adb_comp_exec
+ * This is a general routine that calls the completion routine if there is one.
+ * NOTE: This routine is now only used by pm_direct.c
+ * All the code in this file (adb_direct.c) uses
+ * the adb_pass_up routine now.
+ */
+void
+adb_comp_exec(void)
+{
+ if ((long)0 != adbCompRout) /* don't call if empty return location */
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ __asm __volatile(
+ " movml #0xffff,sp@- \n" /* save all registers */
+ " movl %0,a2 \n" /* adbCompData */
+ " movl %1,a1 \n" /* adbCompRout */
+ " movl %2,a0 \n" /* adbBuffer */
+ " movl %3,d0 \n" /* adbWaitingCmd */
+ " jbsr a1@ \n" /* go call the routine */
+ " movml sp@+,#0xffff" /* restore all registers */
+ :
+ : "g"(adbCompData), "g"(adbCompRout),
+ "g"(adbBuffer), "g"(adbWaitingCmd)
+ : "d0", "a0", "a1", "a2");
+#else /* for Mac OS-based testing */
+ asm {
+ movem.l a0/a1/a2/d0, -(a7)
+ move.l adbCompData, a2
+ move.l adbCompRout, a1
+ move.l adbBuffer, a0
+ move.w adbWaitingCmd, d0
+ jsr(a1)
+ movem.l(a7) +, d0/a2/a1/a0
+ }
+#endif
+}
+
+
+/*
+ * adb_cmd_result
+ *
+ * This routine lets the caller know whether the specified adb command string
+ * should expect a returned result, such as a TALK command.
+ *
* returns: 0 if a result should be expected
* 1 if a result should NOT be expected
*/
int
-adb_cmd_result(u_char * in)
+adb_cmd_result(u_char *in)
{
switch (adbHardware) {
- case ADB_HW_II:
+ case ADB_HW_II:
/* was it an ADB talk command? */
if ((in[1] & 0x0c) == 0x0c)
return 0;
- else
- return 1;
- break;
+ return 1;
case ADB_HW_IISI:
case ADB_HW_CUDA:
- /* was is an ADB talk command? */
+ /* was it an ADB talk command? */
if ((in[1] == 0x00) && ((in[2] & 0x0c) == 0x0c))
return 0;
- /* was is an RTC/PRAM read date/time? */
- else
- if ((in[1] == 0x01) && (in[2] == 0x03))
- return 0;
- else
- return 1;
- break;
+ /* was it an RTC/PRAM read date/time? */
+ if ((in[1] == 0x01) && (in[2] == 0x03))
+ return 0;
+ return 1;
case ADB_HW_PB:
return 1;
- break;
case ADB_HW_UNKNOWN:
default:
@@ -1924,36 +2331,37 @@ adb_cmd_result(u_char * in)
}
-/* adb_cmd_extra
- * This routine lets the caller know whether the specified adb command string may have
- * extra data appended to the end of it, such as a LISTEN command.
+/*
+ * adb_cmd_extra
+ *
+ * This routine lets the caller know whether the specified adb command string
+ * may have extra data appended to the end of it, such as a LISTEN command.
+ *
* returns: 0 if extra data is allowed
* 1 if extra data is NOT allowed
*/
int
-adb_cmd_extra(u_char * in)
+adb_cmd_extra(u_char *in)
{
switch (adbHardware) {
- case ADB_HW_II:
+ case ADB_HW_II:
if ((in[1] & 0x0c) == 0x08) /* was it a listen command? */
return 0;
- else
- return 1;
- break;
+ return 1;
case ADB_HW_IISI:
case ADB_HW_CUDA:
- /* TO DO: support needs to be added to recognize RTC and PRAM
- * commands */
+ /*
+ * TO DO: support needs to be added to recognize RTC and PRAM
+ * commands
+ */
if ((in[2] & 0x0c) == 0x08) /* was it a listen command? */
return 0;
- else /* add others later */
- return 1;
- break;
+ /* add others later */
+ return 1;
case ADB_HW_PB:
return 1;
- break;
case ADB_HW_UNKNOWN:
default:
@@ -1962,41 +2370,6 @@ adb_cmd_extra(u_char * in)
}
-/* adb_op_sync
- * This routine does exactly what the adb_op routine does, except that after the
- * adb_op is called, it waits until the return value is present before returning
- */
-int
-adb_op_sync(Ptr buffer, Ptr compRout, Ptr data, short command)
-{
- int result;
- volatile int flag = 0;
-
- result = adb_op(buffer, (void *) adb_op_comprout,
- (void *) &flag, command); /* send command */
- if (result == 0) { /* send ok? */
- while (0 == flag); /* wait for compl. routine */
- return 0;
- } else
- return result;
-}
-
-
-/* adb_op_comprout
- * This function is used by the adb_op_sync routine so it knows when the function is
- * done.
- */
-void
-adb_op_comprout(void)
-{
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- asm("movw #1,a2@ | update flag value");
-#else /* for macos based testing */
- asm {
- move.w #1,(a2) } /* update flag value */
-#endif
-}
-
void
adb_setup_hw_type(void)
{
@@ -2004,75 +2377,127 @@ adb_setup_hw_type(void)
response = mac68k_machine.machineid;
+ /*
+ * Determine what type of ADB hardware we are running on.
+ */
switch (response) {
- case 6: /* II */
- case 7: /* IIx */
- case 8: /* IIcx */
- case 9: /* SE/30 */
- case 11: /* IIci */
- case 22: /* Quadra 700 */
- case 30: /* Centris 650 */
- case 35: /* Quadra 800 */
- case 36: /* Quadra 650 */
- case 52: /* Centris 610 */
- case 53: /* Quadra 610 */
+ case MACH_MACC610: /* Centris 610 */
+ case MACH_MACC650: /* Centris 650 */
+ case MACH_MACII: /* II */
+ case MACH_MACIICI: /* IIci */
+ case MACH_MACIICX: /* IIcx */
+ case MACH_MACIIX: /* IIx */
+ case MACH_MACQ610: /* Quadra 610 */
+ case MACH_MACQ650: /* Quadra 650 */
+ case MACH_MACQ700: /* Quadra 700 */
+ case MACH_MACQ800: /* Quadra 800 */
+ case MACH_MACSE30: /* SE/30 */
adbHardware = ADB_HW_II;
- printf_intr("adb: using II series hardware support\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: using II series hardware support\n");
+#endif
break;
- case 18: /* IIsi */
- case 20: /* Quadra 900 - not sure if IIsi or not */
- case 23: /* Classic II */
- case 26: /* Quadra 950 - not sure if IIsi or not */
- case 27: /* LC III, Performa 450 */
- case 37: /* LC II, Performa 400/405/430 */
- case 44: /* IIvi */
- case 45: /* Performa 600 */
- case 48: /* IIvx */
- case 49: /* Color Classic - not sure if IIsi or not */
- case 62: /* Performa 460/465/467 */
- case 83: /* Color Classic II - not sure if IIsi or not */
+
+ case MACH_MACCLASSICII: /* Classic II */
+ case MACH_MACLCII: /* LC II, Performa 400/405/430 */
+ case MACH_MACLCIII: /* LC III, Performa 450 */
+ case MACH_MACIISI: /* IIsi */
+ case MACH_MACIIVI: /* IIvi */
+ case MACH_MACIIVX: /* IIvx */
+ case MACH_MACP460: /* Performa 460/465/467 */
+ case MACH_MACP600: /* Performa 600 */
adbHardware = ADB_HW_IISI;
- printf_intr("adb: using IIsi series hardware support\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: using IIsi series hardware support\n");
+#endif
break;
- case 21: /* PowerBook 170 */
- case 25: /* PowerBook 140 */
- case 54: /* PowerBook 145 */
- case 34: /* PowerBook 160 */
- case 84: /* PowerBook 165 */
- case 50: /* PowerBook 165c */
- case 33: /* PowerBook 180 */
- case 71: /* PowerBook 180c */
- case 115: /* PowerBook 150 */
+
+ case MACH_MACPB140: /* PowerBook 140 */
+ case MACH_MACPB145: /* PowerBook 145 */
+ case MACH_MACPB160: /* PowerBook 160 */
+ case MACH_MACPB165: /* PowerBook 165 */
+ case MACH_MACPB165C: /* PowerBook 165c */
+ case MACH_MACPB170: /* PowerBook 170 */
+ case MACH_MACPB180: /* PowerBook 180 */
+ case MACH_MACPB180C: /* PowerBook 180c */
adbHardware = ADB_HW_PB;
pm_setup_adb();
- printf_intr("adb: using PowerBook 100-series hardware support\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: using PowerBook 100-series hardware support\n");
+#endif
break;
- case 29: /* PowerBook Duo 210 */
- case 32: /* PowerBook Duo 230 */
- case 38: /* PowerBook Duo 250 */
- case 72: /* PowerBook 500 series */
- case 77: /* PowerBook Duo 270 */
- case 102: /* PowerBook Duo 280 */
- case 103: /* PowerBook Duo 280c */
+
+ case MACH_MACPB150: /* PowerBook 150 */
+ case MACH_MACPB210: /* PowerBook Duo 210 */
+ case MACH_MACPB230: /* PowerBook Duo 230 */
+ case MACH_MACPB250: /* PowerBook Duo 250 */
+ case MACH_MACPB270: /* PowerBook Duo 270 */
+ case MACH_MACPB280: /* PowerBook Duo 280 */
+ case MACH_MACPB280C: /* PowerBook Duo 280c */
+ case MACH_MACPB500: /* PowerBook 500 series */
+ case MACH_MACPB190: /* PowerBook 190 */
+ case MACH_MACPB190CS: /* PowerBook 190cs */
adbHardware = ADB_HW_PB;
pm_setup_adb();
- printf_intr("adb: using PowerBook Duo-series and PowerBook 500-series hardware support\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: using PowerBook Duo-series and PowerBook 500-series hardware support\n");
+#endif
break;
- case 56: /* LC 520 */
- case 60: /* Centris 660AV */
- case 78: /* Quadra 840AV */
- case 80: /* LC 550, Performa 550 */
- case 89: /* LC 475, Performa 475/476 */
- case 92: /* LC 575, Performa 575/577/578 */
- case 94: /* Quadra 605 */
- case 98: /* LC 630, Performa 630, Quadra 630 */
+
+ case MACH_MACC660AV: /* Centris 660AV */
+ case MACH_MACCCLASSIC: /* Color Classic */
+ case MACH_MACCCLASSICII: /* Color Classic II */
+ case MACH_MACLC475: /* LC 475, Performa 475/476 */
+ case MACH_MACLC475_33: /* Clock-chipped 47x */
+ case MACH_MACLC520: /* LC 520 */
+ case MACH_MACLC575: /* LC 575, Performa 575/577/578 */
+ case MACH_MACP550: /* LC 550, Performa 550 */
+ case MACH_MACTV: /* Macintosh TV */
+ case MACH_MACP580: /* Performa 580/588 */
+ case MACH_MACQ605: /* Quadra 605 */
+ case MACH_MACQ605_33: /* Clock-chipped Quadra 605 */
+ case MACH_MACQ630: /* LC 630, Performa 630, Quadra 630 */
+ case MACH_MACQ840AV: /* Quadra 840AV */
adbHardware = ADB_HW_CUDA;
- printf_intr("adb: using Cuda series hardware support\n");
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf_intr("adb: using Cuda series hardware support\n");
+#endif
break;
+
default:
adbHardware = ADB_HW_UNKNOWN;
- printf_intr("adb: hardware type unknown for this machine\n");
- printf_intr("adb: ADB support is disabled\n");
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf_intr("adb: hardware type unknown for this machine\n");
+ printf_intr("adb: ADB support is disabled\n");
+ }
+#endif
+ break;
+ }
+
+ /*
+ * Determine whether this machine has ADB based soft power.
+ */
+ switch (response) {
+ case MACH_MACCCLASSIC: /* Color Classic */
+ case MACH_MACCCLASSICII: /* Color Classic II */
+ case MACH_MACIISI: /* IIsi */
+ case MACH_MACIIVI: /* IIvi */
+ case MACH_MACIIVX: /* IIvx */
+ case MACH_MACLC520: /* LC 520 */
+ case MACH_MACLC575: /* LC 575, Performa 575/577/578 */
+ case MACH_MACP550: /* LC 550, Performa 550 */
+ case MACH_MACTV: /* Macintosh TV */
+ case MACH_MACP580: /* Performa 580/588 */
+ case MACH_MACP600: /* Performa 600 */
+ case MACH_MACQ630: /* LC 630, Performa 630, Quadra 630 */
+ case MACH_MACQ840AV: /* Quadra 840AV */
+ adbSoftPower = 1;
break;
}
}
@@ -2086,33 +2511,36 @@ count_adbs(void)
found = 0;
for (i = 1; i < 16; i++)
- if (0 != ADBDevTable[i].devType)
+ if (0 != ADBDevTable[i].currentAddr)
found++;
return found;
}
int
-get_ind_adb_info(ADBDataBlock * info, int index)
+get_ind_adb_info(ADBDataBlock *info, int index)
{
if ((index < 1) || (index > 15)) /* check range 1-15 */
return (-1);
- /* printf_intr("index 0x%x devType is: 0x%x\n", index,
- ADBDevTable[index].devType); */
+#ifdef ADB_DEBUG
+ if (adb_debug & 0x80)
+ printf_intr("index 0x%x devType is: 0x%x\n", index,
+ ADBDevTable[index].devType);
+#endif
if (0 == ADBDevTable[index].devType) /* make sure it's a valid entry */
return (-1);
- info->devType = ADBDevTable[index].devType;
- info->origADBAddr = ADBDevTable[index].origAddr;
- info->dbServiceRtPtr = (Ptr) ADBDevTable[index].ServiceRtPtr;
- info->dbDataAreaAddr = (Ptr) ADBDevTable[index].DataAreaAddr;
+ info->devType = (unsigned char)(ADBDevTable[index].devType);
+ info->origADBAddr = (unsigned char)(ADBDevTable[index].origAddr);
+ info->dbServiceRtPtr = (Ptr)ADBDevTable[index].ServiceRtPtr;
+ info->dbDataAreaAddr = (Ptr)ADBDevTable[index].DataAreaAddr;
return (ADBDevTable[index].currentAddr);
}
int
-get_adb_info(ADBDataBlock * info, int adbAddr)
+get_adb_info(ADBDataBlock *info, int adbAddr)
{
int i;
@@ -2121,8 +2549,8 @@ get_adb_info(ADBDataBlock * info, int adbAddr)
for (i = 1; i < 15; i++)
if (ADBDevTable[i].currentAddr == adbAddr) {
- info->devType = ADBDevTable[i].devType;
- info->origADBAddr = ADBDevTable[i].origAddr;
+ info->devType = (unsigned char)(ADBDevTable[i].devType);
+ info->origADBAddr = (unsigned char)(ADBDevTable[i].origAddr);
info->dbServiceRtPtr = (Ptr)ADBDevTable[i].ServiceRtPtr;
info->dbDataAreaAddr = ADBDevTable[i].DataAreaAddr;
return 0; /* found */
@@ -2132,7 +2560,7 @@ get_adb_info(ADBDataBlock * info, int adbAddr)
}
int
-set_adb_info(ADBSetInfoBlock * info, int adbAddr)
+set_adb_info(ADBSetInfoBlock *info, int adbAddr)
{
int i;
@@ -2155,24 +2583,23 @@ set_adb_info(ADBSetInfoBlock * info, int adbAddr)
int
mrg_adbintr(void)
{
- adb_intr();
+ adb_intr(NULL);
return 1; /* mimic mrg_adbintr in macrom.h just in case */
}
int
-mrg_pmintr(void) /* we don't do this yet */
+mrg_pmintr(void)
{
- pm_intr();
+ pm_intr(NULL);
return 1; /* mimic mrg_pmintr in macrom.h just in case */
}
-#endif
-/* caller should really use machine-independent version: getPramTime */
+/* caller should really use machine-independant version: getPramTime */
/* this version does pseudo-adb access only */
int
adb_read_date_time(unsigned long *time)
{
- u_char output[MAX_ADB_MSG_LENGTH];
+ u_char output[ADB_MAX_MSG_LENGTH];
int result;
volatile int flag = 0;
@@ -2184,16 +2611,15 @@ adb_read_date_time(unsigned long *time)
output[0] = 0x02; /* 2 byte message */
output[1] = 0x01; /* to pram/rtc device */
output[2] = 0x03; /* read date/time */
- result = send_adb_IIsi((u_char *) output,
- (u_char *) output, (void *) adb_op_comprout,
- (int *) &flag, (int) 0);
+ result = send_adb_IIsi((u_char *)output, (u_char *)output,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
while (0 == flag) /* wait for result */
;
- *time = (long) (*(long *) (output + 1));
+ *time = (long)(*(long *)(output + 1));
return 0;
case ADB_HW_PB:
@@ -2203,16 +2629,15 @@ adb_read_date_time(unsigned long *time)
output[0] = 0x02; /* 2 byte message */
output[1] = 0x01; /* to pram/rtc device */
output[2] = 0x03; /* read date/time */
- result = send_adb_cuda((u_char *) output,
- (u_char *) output, (void *) adb_op_comprout,
- (void *) &flag, (int) 0);
+ result = send_adb_cuda((u_char *)output, (u_char *)output,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
while (0 == flag) /* wait for result */
;
- *time = (long) (*(long *) (output + 1));
+ *time = (long)(*(long *)(output + 1));
return 0;
case ADB_HW_UNKNOWN:
@@ -2221,12 +2646,12 @@ adb_read_date_time(unsigned long *time)
}
}
-/* caller should really use machine-independent version: setPramTime */
+/* caller should really use machine-independant version: setPramTime */
/* this version does pseudo-adb access only */
int
adb_set_date_time(unsigned long time)
{
- u_char output[MAX_ADB_MSG_LENGTH];
+ u_char output[ADB_MAX_MSG_LENGTH];
int result;
volatile int flag = 0;
@@ -2238,13 +2663,12 @@ adb_set_date_time(unsigned long time)
output[0] = 0x06; /* 6 byte message */
output[1] = 0x01; /* to pram/rtc device */
output[2] = 0x09; /* set date/time */
- output[3] = (u_char) (time >> 24);
- output[4] = (u_char) (time >> 16);
- output[5] = (u_char) (time >> 8);
- output[6] = (u_char) (time);
- result = send_adb_IIsi((u_char *) output,
- (u_char *) 0, (void *) adb_op_comprout,
- (void *) &flag, (int) 0);
+ output[3] = (u_char)(time >> 24);
+ output[4] = (u_char)(time >> 16);
+ output[5] = (u_char)(time >> 8);
+ output[6] = (u_char)(time);
+ result = send_adb_IIsi((u_char *)output, (u_char *)0,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
@@ -2260,13 +2684,12 @@ adb_set_date_time(unsigned long time)
output[0] = 0x06; /* 6 byte message */
output[1] = 0x01; /* to pram/rtc device */
output[2] = 0x09; /* set date/time */
- output[3] = (u_char) (time >> 24);
- output[4] = (u_char) (time >> 16);
- output[5] = (u_char) (time >> 8);
- output[6] = (u_char) (time);
- result = send_adb_cuda((u_char *) output,
- (u_char *) 0, (void *) adb_op_comprout,
- (void *) &flag, (int) 0);
+ output[3] = (u_char)(time >> 24);
+ output[4] = (u_char)(time >> 16);
+ output[5] = (u_char)(time >> 8);
+ output[6] = (u_char)(time);
+ result = send_adb_cuda((u_char *)output, (u_char *)0,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
@@ -2285,16 +2708,21 @@ adb_set_date_time(unsigned long time)
int
adb_poweroff(void)
{
- u_char output[MAX_ADB_MSG_LENGTH];
+ u_char output[ADB_MAX_MSG_LENGTH];
int result;
+ if (!adbSoftPower)
+ return -1;
+
+ adb_polling = 1;
+
switch (adbHardware) {
case ADB_HW_IISI:
output[0] = 0x02; /* 2 byte message */
output[1] = 0x01; /* to pram/rtc/soft-power device */
output[2] = 0x0a; /* set date/time */
- result = send_adb_IIsi((u_char *) output,
- (u_char *) 0, (void *) 0, (void *) 0, (int) 0);
+ result = send_adb_IIsi((u_char *)output, (u_char *)0,
+ (void *)0, (void *)0, (int)0);
if (result != 0) /* exit if not sent */
return -1;
@@ -2305,9 +2733,20 @@ adb_poweroff(void)
case ADB_HW_PB:
return -1;
- /* TO DO: some cuda models claim to do soft power - check out */
- case ADB_HW_II: /* II models don't do soft power */
- case ADB_HW_CUDA: /* cuda doesn't do soft power */
+ case ADB_HW_CUDA:
+ output[0] = 0x02; /* 2 byte message */
+ output[1] = 0x01; /* to pram/rtc/soft-power device */
+ output[2] = 0x0a; /* set date/time */
+ result = send_adb_cuda((u_char *)output, (u_char *)0,
+ (void *)0, (void *)0, (int)0);
+ if (result != 0) /* exit if not sent */
+ return -1;
+
+ for (;;); /* wait for power off */
+
+ return 0;
+
+ case ADB_HW_II: /* II models don't do ADB soft power */
case ADB_HW_UNKNOWN:
default:
return -1;
@@ -2317,7 +2756,7 @@ adb_poweroff(void)
int
adb_prog_switch_enable(void)
{
- u_char output[MAX_ADB_MSG_LENGTH];
+ u_char output[ADB_MAX_MSG_LENGTH];
int result;
volatile int flag = 0;
@@ -2327,9 +2766,8 @@ adb_prog_switch_enable(void)
output[1] = 0x01; /* to pram/rtc/soft-power device */
output[2] = 0x1c; /* prog. switch control */
output[3] = 0x01; /* enable */
- result = send_adb_IIsi((u_char *) output,
- (u_char *) 0, (void *) adb_op_comprout,
- (void *) &flag, (int) 0);
+ result = send_adb_IIsi((u_char *)output, (u_char *)0,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
@@ -2352,7 +2790,7 @@ adb_prog_switch_enable(void)
int
adb_prog_switch_disable(void)
{
- u_char output[MAX_ADB_MSG_LENGTH];
+ u_char output[ADB_MAX_MSG_LENGTH];
int result;
volatile int flag = 0;
@@ -2362,9 +2800,8 @@ adb_prog_switch_disable(void)
output[1] = 0x01; /* to pram/rtc/soft-power device */
output[2] = 0x1c; /* prog. switch control */
output[3] = 0x01; /* disable */
- result = send_adb_IIsi((u_char *) output,
- (u_char *) 0, (void *) adb_op_comprout,
- (void *) &flag, (int) 0);
+ result = send_adb_IIsi((u_char *)output, (u_char *)0,
+ (void *)adb_op_comprout, (void *)&flag, (int)0);
if (result != 0) /* exit if not sent */
return -1;
@@ -2384,8 +2821,6 @@ adb_prog_switch_disable(void)
}
}
-#ifndef MRG_ADB
-
int
CountADBs(void)
{
@@ -2399,19 +2834,19 @@ ADBReInit(void)
}
int
-GetIndADB(ADBDataBlock * info, int index)
+GetIndADB(ADBDataBlock *info, int index)
{
return (get_ind_adb_info(info, index));
}
int
-GetADBInfo(ADBDataBlock * info, int adbAddr)
+GetADBInfo(ADBDataBlock *info, int adbAddr)
{
return (get_adb_info(info, adbAddr));
}
int
-SetADBInfo(ADBSetInfoBlock * info, int adbAddr)
+SetADBInfo(ADBSetInfoBlock *info, int adbAddr)
{
return (set_adb_info(info, adbAddr));
}
@@ -2423,4 +2858,3 @@ ADBOp(Ptr buffer, Ptr compRout, Ptr data, short commandNum)
}
#endif
-
diff --git a/sys/arch/mac68k/dev/adbsys.c b/sys/arch/mac68k/dev/adbsys.c
deleted file mode 100644
index 78bbead2ba5..00000000000
--- a/sys/arch/mac68k/dev/adbsys.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* $OpenBSD: adbsys.c,v 1.11 2002/03/14 01:26:35 millert Exp $ */
-/* $NetBSD: adbsys.c,v 1.24 1997/01/13 07:01:23 scottr Exp $ */
-
-/*-
- * Copyright (C) 1994 Bradley A. Grantham
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Bradley A. Grantham.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <machine/cpu.h>
-#include <machine/viareg.h>
-
-#include <arch/mac68k/mac68k/macrom.h>
-#include <arch/mac68k/dev/adbvar.h>
-
-extern struct mac68k_machine_S mac68k_machine;
-
-/* from adb.c */
-void adb_processevent(adb_event_t * event);
-
-extern void adb_jadbproc(void);
-
-void
-adb_complete(buffer, data_area, adb_command)
- caddr_t buffer;
- caddr_t data_area;
- int adb_command;
-{
- adb_event_t event;
- ADBDataBlock adbdata;
- int adbaddr;
- int error;
-#ifdef MRG_DEBUG
- register int i;
-
- printf("adb: transaction completion\n");
-#endif
-
- adbaddr = (adb_command & 0xf0) >> 4;
- error = GetADBInfo(&adbdata, adbaddr);
-#ifdef MRG_DEBUG
- printf("adb: GetADBInfo returned %d\n", error);
-#endif
-
- event.addr = adbaddr;
- event.hand_id = adbdata.devType;
- event.def_addr = adbdata.origADBAddr;
- event.byte_count = buffer[0];
- memcpy(event.bytes, buffer + 1, event.byte_count);
-
-#ifdef MRG_DEBUG
- printf("adb: from %d at %d (org %d) %d:", event.addr,
- event.hand_id, event.def_addr, buffer[0]);
- for (i = 1; i <= buffer[0]; i++)
- printf(" %x", buffer[i]);
- printf("\n");
-#endif
-
- microtime(&event.timestamp);
-
- adb_processevent(&event);
-}
-
-static volatile int extdms_done;
-
-/*
- * initialize extended mouse - probes devices as
- * described in _Inside Macintosh, Devices_.
- */
-void
-extdms_init(totaladbs)
- int totaladbs;
-{
- ADBDataBlock adbdata;
- int adbindex, adbaddr;
- short cmd;
- char buffer[9];
-
- for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
- /* Get the ADB information */
- adbaddr = GetIndADB(&adbdata, adbindex);
- if (adbdata.origADBAddr == ADBADDR_MS &&
- (adbdata.devType == ADBMS_USPEED)) {
- /* Found MicroSpeed Mouse Deluxe Mac */
- cmd = ((adbaddr<<4)&0xF0)|0x9; /* listen 1 */
-
- /*
- * To setup the MicroSpeed, it appears that we can
- * send the following command to the mouse and then
- * expect data back in the form:
- * buffer[0] = 4 (bytes)
- * buffer[1], buffer[2] as std. mouse
- * buffer[3] = buffer[4] = 0xff when no buttons
- * are down. When button N down, bit N is clear.
- * buffer[4]'s locking mask enables a
- * click to toggle the button down state--sort of
- * like the "Easy Access" shift/control/etc. keys.
- * buffer[3]'s alternative speed mask enables using
- * different speed when the corr. button is down
- */
- buffer[0] = 4;
- buffer[1] = 0x00; /* Alternative speed */
- buffer[2] = 0x00; /* speed = maximum */
- buffer[3] = 0x10; /* enable extended protocol,
- * lower bits = alt. speed mask
- * = 0000b
- */
- buffer[4] = 0x07; /* Locking mask = 0000b,
- * enable buttons = 0111b
- */
- extdms_done = 0;
- ADBOp((Ptr)buffer, (Ptr)extdms_complete,
- (Ptr)&extdms_done, cmd);
- while (!extdms_done)
- /* busy wait until done */;
- }
- if (adbdata.origADBAddr == ADBADDR_MS &&
- ( adbdata.devType == ADBMS_100DPI
- || adbdata.devType == ADBMS_200DPI)) {
- /* found a mouse */
- cmd = ((adbaddr << 4) & 0xf0) | 0x3;
-
- extdms_done = 0;
- cmd = (cmd & 0xf3) | 0x0c; /* talk command */
- ADBOp((Ptr)buffer, (Ptr)extdms_complete,
- (Ptr)&extdms_done, cmd);
- while (!extdms_done)
- /* busy wait until done */;
-
- buffer[2] = '\004'; /* make handler ID 4 */
- extdms_done = 0;
- cmd = (cmd & 0xf3) | 0x08; /* listen command */
- ADBOp((Ptr)buffer, (Ptr)extdms_complete,
- (Ptr)&extdms_done, cmd);
- while (!extdms_done)
- /* busy wait until done */;
- }
- }
-}
-
-void
-adb_init()
-{
- ADBDataBlock adbdata;
- ADBSetInfoBlock adbinfo;
- int totaladbs;
- int adbindex, adbaddr;
- int error;
- char buffer[9];
-
-#ifdef DISABLE_ADB_WHEN_SERIAL_CONSOLE
- if ((mac68k_machine.serial_console & 0x03)) {
- printf("adb: using serial console\n");
- return;
- }
-#endif
-
-#ifdef MRG_ADB /* We don't care about ADB ROM driver if we
- * aren't using the MRG_ADB method for
- * ADB/PRAM/RTC. */
- if (!mrg_romready()) {
- printf("adb: no ROM ADB driver in this kernel for this machine\n");
- return;
- }
-#endif
- printf("adb: bus subsystem\n");
-#ifdef MRG_DEBUG
- printf("adb: call mrg_initadbintr\n");
-#endif
-
- mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
-#ifdef MRG_DEBUG
- printf("adb: returned from mrg_initadbintr\n");
-#endif
-
- /* ADBReInit pre/post-processing */
- JADBProc = adb_jadbproc;
-
- /*
- * Initialize ADB
- *
- * If not using MRG_ADB method to access ADB, then call
- * ADBReInit directly. Otherwise use ADB AlternateInit()
- */
-#ifndef MRG_ADB
- printf("adb: calling ADBReInit\n");
- ADBReInit();
-#else
-#ifdef MRG_DEBUG
- printf("adb: calling ADBAlternateInit.\n");
-#endif
- ADBAlternateInit();
-#endif
-
-#ifdef MRG_DEBUG
- printf("adb: done with ADBReInit\n");
-#endif
-
- totaladbs = CountADBs();
- extdms_init(totaladbs);
-
- /* for each ADB device */
- for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
- /* Get the ADB information */
- adbaddr = GetIndADB(&adbdata, adbindex);
-
- /* Print out the glory */
- printf("adb: ");
- switch (adbdata.origADBAddr) {
- case ADBADDR_MAP:
- switch (adbdata.devType) {
- case ADB_STDKBD:
- printf("keyboard");
- break;
- case ADB_EXTKBD:
- printf("extended keyboard");
- break;
- case ADB_PBKBD:
- printf("PowerBook keyboard");
- break;
- default:
- printf("mapped device (%d)",
- adbdata.devType);
- break;
- }
- break;
- case ADBADDR_REL:
- extdms_done = 0;
- /* talk register 3 */
- ADBOp((Ptr)buffer, (Ptr)extdms_complete,
- (Ptr)&extdms_done, (adbaddr << 4) | 0xf);
- while (!extdms_done)
- /* busy-wait until done */;
- switch (buffer[2]) {
- case ADBMS_100DPI:
- printf("100 dpi mouse");
- break;
- case ADBMS_200DPI:
- printf("200 dpi mouse");
- break;
- case ADBMS_USPEED:
- printf("MicroSpeed mouse, default parameters");
- break;
- case ADBMS_EXTENDED:
- extdms_done = 0;
- /* talk register 1 */
- ADBOp((Ptr)buffer, (Ptr)extdms_complete,
- (Ptr)&extdms_done,
- (adbaddr << 4) | 0xd);
- while (!extdms_done)
- /* busy-wait until done */;
- printf("extended mouse "
- "<%c%c%c%c> %d-button %d dpi ",
- buffer[1], buffer[2],
- buffer[3], buffer[4],
- (int)buffer[8],
- (int)*(short *)&buffer[5]);
- if (buffer[7] == 1)
- printf("mouse");
- else if (buffer[7] == 2)
- printf("trackball");
- else
- printf("unknown device");
- break;
- default:
- printf("relative positioning device (mouse?) (%d)", adbdata.devType);
- break;
- }
- break;
- case ADBADDR_ABS:
- printf("absolute positioning device (tablet?) (%d)", adbdata.devType);
- break;
- default:
- printf("unknown type device, (def %d, handler %d)", adbdata.origADBAddr,
- adbdata.devType);
- break;
- }
- printf(" at %d\n", adbaddr);
-
- /* Set completion routine to be MacBSD's */
- adbinfo.siServiceRtPtr = (Ptr) adb_asmcomplete;
- adbinfo.siDataAreaAddr = NULL;
- error = SetADBInfo(&adbinfo, adbaddr);
-#ifdef MRG_DEBUG
- printf("returned %d from SetADBInfo\n", error);
-#endif
- }
-}
diff --git a/sys/arch/mac68k/dev/adbsysasm.s b/sys/arch/mac68k/dev/adbsysasm.s
index 478e52a0db3..c5a78df8867 100644
--- a/sys/arch/mac68k/dev/adbsysasm.s
+++ b/sys/arch/mac68k/dev/adbsysasm.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: adbsysasm.s,v 1.2 1996/05/26 18:35:16 briggs Exp $ */
-/* $NetBSD: adbsysasm.s,v 1.2 1995/09/03 20:59:56 briggs Exp $ */
+/* $OpenBSD: adbsysasm.s,v 1.3 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: adbsysasm.s,v 1.11 2001/11/20 03:19:42 chs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@@ -31,44 +31,62 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "akbd.h"
+#include "ams.h"
+#include <machine/asm.h>
+
/*
* ADB subsystem routines in assembly
*/
-/* This routine is called when a device has sent us some data. */
+#if NAKBD > 0
+/* This routine is called when a keyboard has sent us some data. */
+/* (provided it has been set up with SetADBInfo) */
+GLOBAL(adb_kbd_asmcomplete)
+ moveml #0x80e0,sp@- | save scratch regs
+ movl d0,sp@- /* ADB command byte */
+ movl a2,sp@- /* data area pointer */
+ /* a1 is the pointer to this routine itself. */
+ movl a0,sp@- /* device data buffer */
+ jbsr _C_LABEL(kbd_adbcomplete)
+ addl #12,sp /* pop params */
+ moveml sp@+,#0x0701 | restore scratch regs
+ rts
+#endif
+
+#if NAMS > 0
+/* This routine is called when a mouse has sent us some data. */
/* (provided it has been set up with SetADBInfo) */
- .global _adb_asmcomplete
- .global _adb_complete
-_adb_asmcomplete:
- moveml #0xc0c0, sp@- | save scratch regs
- movl d0, sp@- /* ADB command byte */
- movl a2, sp@- /* data area pointer */
+GLOBAL(adb_ms_asmcomplete)
+ moveml #0x80e0,sp@- | save scratch regs
+ movl d0,sp@- /* ADB command byte */
+ movl a2,sp@- /* data area pointer */
/* a1 is the pointer to this routine itself. */
- movl a0, sp@- /* device data buffer */
- jbsr _adb_complete
- addl #12, sp /* pop params */
- moveml sp@+, #0x0303 | restore scratch regs
+ movl a0,sp@- /* device data buffer */
+ jbsr _C_LABEL(ms_adbcomplete)
+ addl #12,sp /* pop params */
+ moveml sp@+,#0x0701 | restore scratch regs
rts
+#endif
+
+#ifdef MRG_ADB
-_adb_jadbprochello:
+#if defined(ADB_DEBUG) && 0
+GLOBAL(adb_jadbprochello)
.asciz "adb: hello from adbproc\n"
.even
+#endif
- .global _adb_jadbproc
-_adb_jadbproc:
-#if defined(MRG_DEBUG) && 0
- moveml #0xc0c0, sp@- | save scratch regs
- movl _adb_jadbprochello, sp@-
- jbsr _printf
- addl #4, sp /* pop params */
- moveml sp@+, #0x0303 | restore scratch regs
+GLOBAL(adb_jadbproc)
+#if defined(ADB_DEBUG) && 0
+ moveml #0xc0c0,sp@- | save scratch regs
+ movl _C_LABEL(adb_jadbprochello),sp@-
+ jbsr _C_LABEL(printf)
+ addl #4,sp /* pop params */
+ moveml sp@+,#0x0303 | restore scratch regs
#endif
- /* Don't do anything; adb_init fixes dev info for us. */
+ /* Don't do anything; adbattach fixes dev info for us. */
rts
- /* ADBOp's completion routine used by extdms_init() in adbsys.c. */
- .global _extdms_complete
-_extdms_complete:
- movl #-1,a2@ | set done flag
- rts
+#endif /* MRG_ADB */
diff --git a/sys/arch/mac68k/dev/adbvar.h b/sys/arch/mac68k/dev/adbvar.h
index 67e40f1fcbd..e06099a3765 100644
--- a/sys/arch/mac68k/dev/adbvar.h
+++ b/sys/arch/mac68k/dev/adbvar.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: adbvar.h,v 1.8 2003/09/23 16:51:11 millert Exp $ */
-/* $NetBSD: adbvar.h,v 1.5 1997/01/13 07:01:24 scottr Exp $ */
+/* $OpenBSD: adbvar.h,v 1.9 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: adbvar.h,v 1.22 2005/01/15 16:00:59 chs Exp $ */
-/*-
+/*
* Copyright (C) 1994 Bradley A. Grantham
* All rights reserved.
*
@@ -31,60 +31,60 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <mac68k/mac68k/macrom.h>
#include <machine/adbsys.h>
-#define ADB_MAXTRACE (NBPG / sizeof(int) - 1)
-extern int adb_traceq[ADB_MAXTRACE];
-extern int adb_traceq_tail;
-extern int adb_traceq_len;
-
-typedef struct adb_trace_xlate_s {
- int params;
- char *string;
-} adb_trace_xlate_t;
+/*
+ * Arguments used to attach a device to the Apple Desktop Bus
+ */
+struct adb_attach_args {
+ int origaddr;
+ int adbaddr;
+ int handler_id;
+};
-extern adb_trace_xlate_t adb_trace_xlations[];
+extern int adb_polling;
-/* adb.c */
-void adb_asmcomplete(void);
-void adb_enqevent(adb_event_t *event);
-void adb_handoff(adb_event_t *event);
-void adb_autorepeat(void *keyp);
-void adb_dokeyupdown(adb_event_t *event);
-void adb_keymaybemouse(adb_event_t *event);
-void adb_processevent(adb_event_t *event);
-int adbopen(dev_t dev, int flag, int mode, struct proc *p);
-int adbclose(dev_t dev, int flag, int mode, struct proc *p);
-int adbread(dev_t dev, struct uio *uio, int flag);
-int adbwrite(dev_t dev, struct uio *uio, int flag);
-int adbioctl(dev_t , int , caddr_t , int , struct proc *);
-int adbpoll(dev_t dev, int rw, struct proc *p);
+#ifdef DEBUG
+#ifndef ADB_DEBUG
+#define ADB_DEBUG
+#endif
+#endif
-/* adbsysadm.s */
-void extdms_complete(void);
+#ifdef ADB_DEBUG
+extern int adb_debug;
+#endif
-/* adbsys.c */
-void adb_complete(caddr_t buffer, caddr_t data_area, int adb_command);
-void extdms_init(int);
+/* adb.c */
+int adb_op_sync(Ptr, Ptr, Ptr, short);
+void adb_op_comprout(void);
-#ifndef MRG_ADB
+/* adbsysasm.s */
+void adb_kbd_asmcomplete(void);
+void adb_ms_asmcomplete(void);
/* types of adb hardware that we (will eventually) support */
-#define ADB_HW_UNKNOWN 0x01 /* don't know */
-#define ADB_HW_II 0x02 /* Mac II series */
-#define ADB_HW_IISI 0x03 /* Mac IIsi series */
-#define ADB_HW_PB 0x04 /* PowerBook series */
-#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
+#define ADB_HW_UNKNOWN 0x0 /* don't know */
+#define ADB_HW_II 0x1 /* Mac II series */
+#define ADB_HW_IISI 0x2 /* Mac IIsi series */
+#define ADB_HW_PB 0x3 /* PowerBook series */
+#define ADB_HW_CUDA 0x4 /* Machines with a Cuda chip */
+#define MAX_ADB_HW 4 /* Number of ADB hardware types */
+
+#define ADB_CMDADDR(cmd) ((u_int8_t)(cmd & 0xf0) >> 4)
+#define ADBFLUSH(dev) ((((u_int8_t)dev & 0x0f) << 4) | 0x01)
+#define ADBLISTEN(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x08 | reg)
+#define ADBTALK(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x0c | reg)
+#ifndef MRG_ADB
/* adb_direct.c */
int adb_poweroff(void);
int CountADBs(void);
void ADBReInit(void);
-int GetIndADB(ADBDataBlock * info, int index);
-int GetADBInfo(ADBDataBlock * info, int adbAddr);
-int SetADBInfo(ADBSetInfoBlock * info, int adbAddr);
-int ADBOp(Ptr buffer, Ptr compRout, Ptr data, short commandNum);
-int adb_read_date_time(unsigned long *t);
-int adb_set_date_time(unsigned long t);
-
-#endif
+int GetIndADB(ADBDataBlock *, int);
+int GetADBInfo(ADBDataBlock *, int);
+int SetADBInfo(ADBSetInfoBlock *, int);
+int ADBOp(Ptr, Ptr, Ptr, short);
+int adb_read_date_time(unsigned long *);
+int adb_set_date_time(unsigned long);
+#endif /* !MRG_ADB */
diff --git a/sys/arch/mac68k/dev/akbd.c b/sys/arch/mac68k/dev/akbd.c
new file mode 100644
index 00000000000..b3f2e9f12c6
--- /dev/null
+++ b/sys/arch/mac68k/dev/akbd.c
@@ -0,0 +1,536 @@
+/* $OpenBSD: akbd.c,v 1.1 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: akbd.c,v 1.17 2005/01/15 16:00:59 chs Exp $ */
+
+/*
+ * Copyright (C) 1998 Colin Wood
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Colin Wood.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/timeout.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/fcntl.h>
+#include <sys/poll.h>
+#include <sys/selinfo.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+#include <sys/systm.h>
+
+#include "wskbd.h"
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wskbdvar.h>
+#include <dev/wscons/wsksymdef.h>
+#include <dev/wscons/wsksymvar.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+#include <machine/viareg.h>
+
+#include <mac68k/dev/adbvar.h>
+#include <mac68k/dev/akbdmap.h>
+#include <mac68k/dev/akbdvar.h>
+
+#define KEYBOARD_ARRAY
+#include <machine/keyboard.h>
+
+/*
+ * Function declarations.
+ */
+int akbdmatch(struct device *, void *, void *);
+void akbdattach(struct device *, struct device *, void *);
+void kbd_adbcomplete(caddr_t, caddr_t, int);
+void kbd_processevent(adb_event_t *, struct akbd_softc *);
+int akbd_is_console(void);
+
+/* Driver definition. */
+struct cfattach akbd_ca = {
+ sizeof(struct akbd_softc), akbdmatch, akbdattach
+};
+struct cfdriver akbd_cd = {
+ NULL, "akbd", DV_DULL
+};
+
+int akbd_enable(void *, int);
+void akbd_set_leds(void *, int);
+int akbd_ioctl(void *, u_long, caddr_t, int, struct proc *);
+int akbd_intr(adb_event_t *, struct akbd_softc *);
+void akbd_rawrepeat(void *v);
+
+
+struct wskbd_accessops akbd_accessops = {
+ akbd_enable,
+ akbd_set_leds,
+ akbd_ioctl,
+};
+
+struct wskbd_mapdata akbd_keymapdata = {
+ akbd_keydesctab,
+#ifdef AKBD_LAYOUT
+ AKBD_LAYOUT,
+#else
+ KB_US,
+#endif
+};
+
+int
+akbdmatch(struct device *parent, void *vcf, void *aux)
+{
+ struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
+
+ if (aa_args->origaddr == ADBADDR_KBD)
+ return 1;
+ else
+ return 0;
+}
+
+void
+akbdattach(struct device *parent, struct device *self, void *aux)
+{
+ ADBSetInfoBlock adbinfo;
+ struct akbd_softc *sc = (struct akbd_softc *)self;
+ struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
+ int error, kbd_done;
+ short cmd;
+ u_char buffer[9];
+#if NWSKBD > 0
+ struct wskbddev_attach_args a;
+ static int akbd_console_initted;
+ int wskbd_eligible;
+
+ wskbd_eligible = 1;
+#endif
+
+ sc->origaddr = aa_args->origaddr;
+ sc->adbaddr = aa_args->adbaddr;
+ sc->handler_id = aa_args->handler_id;
+
+ sc->sc_leds = (u_int8_t)0x00; /* initially off */
+
+ adbinfo.siServiceRtPtr = (Ptr)adb_kbd_asmcomplete;
+ adbinfo.siDataAreaAddr = (caddr_t)sc;
+
+ switch (sc->handler_id) {
+ case ADB_STDKBD:
+ printf("standard keyboard\n");
+ break;
+ case ADB_ISOKBD:
+ printf("standard keyboard (ISO layout)\n");
+ break;
+ case ADB_EXTKBD:
+ cmd = ADBTALK(sc->adbaddr, 1);
+ kbd_done =
+ (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd) == 0);
+
+ /* Ignore Logitech MouseMan/Trackman pseudo keyboard */
+ if (kbd_done && buffer[1] == 0x9a && buffer[2] == 0x20) {
+ printf("Mouseman (non-EMP) pseudo keyboard\n");
+ adbinfo.siServiceRtPtr = (Ptr)0;
+ adbinfo.siDataAreaAddr = (Ptr)0;
+#if NWSKBD > 0
+ wskbd_eligible = 0;
+#endif /* NWSKBD > 0 */
+ } else if (kbd_done && buffer[1] == 0x9a && buffer[2] == 0x21) {
+ printf("Trackman (non-EMP) pseudo keyboard\n");
+ adbinfo.siServiceRtPtr = (Ptr)0;
+ adbinfo.siDataAreaAddr = (Ptr)0;
+#if NWSKBD > 0
+ wskbd_eligible = 0;
+#endif /* NWSKBD > 0 */
+ } else {
+ printf("extended keyboard\n");
+#ifdef notyet
+ blinkleds(sc);
+#endif
+ }
+ break;
+ case ADB_EXTISOKBD:
+ printf("extended keyboard (ISO layout)\n");
+#ifdef notyet
+ blinkleds(sc);
+#endif
+ break;
+ case ADB_KBDII:
+ printf("keyboard II\n");
+ break;
+ case ADB_ISOKBDII:
+ printf("keyboard II (ISO layout)\n");
+ break;
+ case ADB_PBKBD:
+ printf("PowerBook keyboard\n");
+ break;
+ case ADB_PBISOKBD:
+ printf("PowerBook keyboard (ISO layout)\n");
+ break;
+ case ADB_ADJKPD:
+ printf("adjustable keypad\n");
+#if NWSKBD > 0
+ wskbd_eligible = 0;
+#endif /* NWSKBD > 0 */
+ break;
+ case ADB_ADJKBD:
+ printf("adjustable keyboard\n");
+ break;
+ case ADB_ADJISOKBD:
+ printf("adjustable keyboard (ISO layout)\n");
+ break;
+ case ADB_ADJJAPKBD:
+ printf("adjustable keyboard (Japanese layout)\n");
+ break;
+ case ADB_PBEXTISOKBD:
+ printf("PowerBook extended keyboard (ISO layout)\n");
+ break;
+ case ADB_PBEXTJAPKBD:
+ printf("PowerBook extended keyboard (Japanese layout)\n");
+ break;
+ case ADB_JPKBDII:
+ printf("keyboard II (Japanese layout)\n");
+ break;
+ case ADB_PBEXTKBD:
+ printf("PowerBook extended keyboard\n");
+ break;
+ case ADB_DESIGNKBD:
+ printf("extended keyboard\n");
+#ifdef notyet
+ blinkleds(sc);
+#endif
+ break;
+ case ADB_PBJPKBD:
+ printf("PowerBook keyboard (Japanese layout)\n");
+ break;
+ case ADB_PBG3JPKBD:
+ printf("PowerBook G3 keyboard (Japanese layout)\n");
+ break;
+ case ADB_PBG4KBD:
+ printf("PowerBook G4 keyboard (Inverted T)\n");
+ break;
+ case ADB_IBITISOKBD:
+ printf("iBook keyboard with inverted T (ISO layout)\n");
+ break;
+ default:
+ printf("mapped device (%d)\n", sc->handler_id);
+#if NWSKBD > 0
+ wskbd_eligible = 0;
+#endif /* NWSKBD > 0 */
+ break;
+ }
+ error = SetADBInfo(&adbinfo, sc->adbaddr);
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("akbd: returned %d from SetADBInfo\n", error);
+#endif
+
+#if NWSKBD > 0
+ if (akbd_is_console() && wskbd_eligible)
+ a.console = (++akbd_console_initted == 1);
+ else
+ a.console = 0;
+ a.keymap = &akbd_keymapdata;
+ a.accessops = &akbd_accessops;
+ a.accesscookie = sc;
+
+ sc->sc_wskbddev = config_found(self, &a, wskbddevprint);
+#endif
+}
+
+
+/*
+ * Handle putting the keyboard data received from the ADB into
+ * an ADB event record.
+ */
+void
+kbd_adbcomplete(caddr_t buffer, caddr_t data_area, int adb_command)
+{
+ adb_event_t event;
+ struct akbd_softc *ksc;
+ int adbaddr;
+#ifdef ADB_DEBUG
+ int i;
+
+ if (adb_debug)
+ printf("adb: transaction completion\n");
+#endif
+
+ adbaddr = ADB_CMDADDR(adb_command);
+ ksc = (struct akbd_softc *)data_area;
+
+ event.addr = adbaddr;
+ event.hand_id = ksc->handler_id;
+ event.def_addr = ksc->origaddr;
+ event.byte_count = buffer[0];
+ memcpy(event.bytes, buffer + 1, event.byte_count);
+
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf("akbd: from %d at %d (org %d) %d:", event.addr,
+ event.hand_id, event.def_addr, buffer[0]);
+ for (i = 1; i <= buffer[0]; i++)
+ printf(" %x", buffer[i]);
+ printf("\n");
+ }
+#endif
+
+ microtime(&event.timestamp);
+
+ kbd_processevent(&event, ksc);
+}
+
+/*
+ * Given a keyboard ADB event, record the keycodes and call the key
+ * repeat handler, optionally passing the event through the mouse
+ * button emulation handler first.
+ */
+void
+kbd_processevent(adb_event_t *event, struct akbd_softc *ksc)
+{
+ adb_event_t new_event;
+
+ new_event = *event;
+ new_event.u.k.key = event->bytes[0];
+ new_event.bytes[1] = 0xff;
+#if NWSKBD > 0
+ if (ksc->sc_wskbddev != NULL) /* wskbd is attached? */
+ akbd_intr(&new_event, ksc);
+#endif
+ if (event->bytes[1] != 0xff) {
+ new_event.u.k.key = event->bytes[1];
+ new_event.bytes[0] = event->bytes[1];
+ new_event.bytes[1] = 0xff;
+#if NWSKBD > 0
+ if (ksc->sc_wskbddev != NULL) /* wskbd is attached? */
+ akbd_intr(&new_event, ksc);
+#endif
+ }
+
+}
+
+int
+akbd_enable(void *v, int on)
+{
+ return 0;
+}
+
+void
+akbd_set_leds(void *v, int on)
+{
+}
+
+int
+akbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ struct akbd_softc *sc = v;
+#endif
+
+ switch (cmd) {
+
+ case WSKBDIO_GTYPE:
+ *(int *)data = WSKBD_TYPE_ADB;
+ return 0;
+ case WSKBDIO_SETLEDS:
+ return 0;
+ case WSKBDIO_GETLEDS:
+ *(int *)data = 0;
+ return 0;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ case WSKBDIO_SETMODE:
+ sc->sc_rawkbd = *(int *)data == WSKBD_RAW;
+ timeout_del(&sc->sc_rawrepeat_ch);
+ return (0);
+#endif
+ case WSKBDIO_BELL:
+ case WSKBDIO_COMPLEXBELL:
+#define d ((struct wskbd_bell_data *)data)
+ mac68k_ring_bell(d->pitch, d->period * hz / 1000, 100);
+ /* comes in as msec, goes out as ticks; volume ignored */
+#undef d
+ return (0);
+
+ default:
+ return (-1);
+ }
+}
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+void
+akbd_rawrepeat(void *v)
+{
+ struct akbd_softc *sc = v;
+ int s;
+
+ s = spltty();
+ wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep);
+ splx(s);
+ timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAYN / 1000);
+}
+#endif
+
+int adb_polledkey;
+int
+akbd_intr(adb_event_t *event, struct akbd_softc *sc)
+{
+ int key, press, val;
+ int type;
+ static int shift;
+
+ key = event->u.k.key;
+
+ /*
+ * Caps lock is weird. The key sequence generated is:
+ * press: down(57) [57] (LED turns on)
+ * release: up(127) [255]
+ * press: up(127) [255]
+ * release: up(57) [185] (LED turns off)
+ */
+ if (ADBK_KEYVAL(key) == ADBK_CAPSLOCK)
+ shift = 0;
+
+ if (key == 255) {
+ if (shift == 0) {
+ key = ADBK_KEYUP(ADBK_CAPSLOCK);
+ shift = 1;
+ } else {
+ key = ADBK_KEYDOWN(ADBK_CAPSLOCK);
+ shift = 0;
+ }
+ }
+
+ press = ADBK_PRESS(key);
+ val = ADBK_KEYVAL(key);
+
+ type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
+
+ if (adb_polling) {
+ adb_polledkey = key;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ } else if (sc->sc_rawkbd) {
+ char cbuf[MAXKEYS *2];
+ int c, j, s;
+ int npress;
+
+ j = npress = 0;
+
+ c = keyboard[val][3];
+ if (c == 0) {
+ return 0; /* XXX */
+ }
+ if (c & 0x80)
+ cbuf[j++] = 0xe0;
+ cbuf[j] = c & 0x7f;
+ if (type == WSCONS_EVENT_KEY_UP) {
+ cbuf[j] |= 0x80;
+ } else {
+ /* this only records last key pressed */
+ if (c & 0x80)
+ sc->sc_rep[npress++] = 0xe0;
+ sc->sc_rep[npress++] = c & 0x7f;
+ }
+ j++;
+ s = spltty();
+ wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
+ splx(s);
+ timeout_del(&sc->sc_rawrepeat_ch);
+ sc->sc_nrep = npress;
+ if (npress != 0)
+ timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAY1/1000);
+ return 0;
+#endif
+ } else {
+ wskbd_input(sc->sc_wskbddev, type, val);
+ }
+
+ return 0;
+}
+
+int
+akbd_is_console(void)
+{
+ extern struct mac68k_machine_S mac68k_machine;
+
+ return ((mac68k_machine.serial_console & 0x03) == 0);
+}
+
+void akbd_cngetc(void *, u_int *, int *);
+void akbd_cnpollc(void *, int);
+
+struct wskbd_consops akbd_consops = {
+ akbd_cngetc,
+ akbd_cnpollc,
+};
+
+int
+akbd_cnattach(void)
+{
+ extern struct wskbd_mapdata akbd_keymapdata;
+
+ wskbd_cnattach(&akbd_consops, NULL, &akbd_keymapdata);
+
+ return 0;
+}
+
+void
+akbd_cngetc(void *v, u_int *type, int *data)
+{
+ int intbits, key, press, val;
+ int s;
+ extern int adb_polledkey;
+
+ s = splhigh();
+
+ adb_polledkey = -1;
+ adb_polling = 1;
+
+ while (adb_polledkey == -1) {
+ intbits = via_reg(VIA1, vIFR);
+
+ if (intbits & V1IF_ADBRDY) {
+ mrg_adbintr();
+ via_reg(VIA1, vIFR) = V1IF_ADBRDY;
+ }
+ if (intbits & 0x10) {
+ mrg_pmintr();
+ via_reg(VIA1, vIFR) = 0x10;
+ }
+ }
+
+ adb_polling = 0;
+ splx(s);
+
+ key = adb_polledkey;
+ press = ADBK_PRESS(key);
+ val = ADBK_KEYVAL(key);
+
+ *data = val;
+ *type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
+}
+
+void
+akbd_cnpollc(void *v, int on)
+{
+}
diff --git a/sys/arch/mac68k/dev/akbdmap.h b/sys/arch/mac68k/dev/akbdmap.h
new file mode 100644
index 00000000000..8e0c01f0523
--- /dev/null
+++ b/sys/arch/mac68k/dev/akbdmap.h
@@ -0,0 +1,431 @@
+/* $NetBSD: akbdmap.h,v 1.7 2005/05/05 22:29:41 abs Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Juergen Hannken-Illjes.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/* XXX This list is incomplete. */
+
+#define KC(n) KS_KEYCODE(n)
+
+static const keysym_t akbd_keydesc_us[] = {
+/* pos command normal shifted */
+ KC(0), KS_a,
+ KC(1), KS_s,
+ KC(2), KS_d,
+ KC(3), KS_f,
+ KC(4), KS_h,
+ KC(5), KS_g,
+ KC(6), KS_z,
+ KC(7), KS_x,
+ KC(8), KS_c,
+ KC(9), KS_v,
+
+ KC(11), KS_b,
+ KC(12), KS_q,
+ KC(13), KS_w,
+ KC(14), KS_e,
+ KC(15), KS_r,
+ KC(16), KS_y,
+ KC(17), KS_t,
+ KC(18), KS_1, KS_exclam,
+ KC(19), KS_2, KS_at,
+ KC(20), KS_3, KS_numbersign,
+ KC(21), KS_4, KS_dollar,
+ KC(22), KS_6, KS_asciicircum,
+ KC(23), KS_5, KS_percent,
+ KC(24), KS_equal, KS_plus,
+ KC(25), KS_9, KS_parenleft,
+ KC(26), KS_7, KS_ampersand,
+ KC(27), KS_minus, KS_underscore,
+ KC(28), KS_8, KS_asterisk,
+ KC(29), KS_0, KS_parenright,
+ KC(30), KS_bracketright, KS_braceright,
+ KC(31), KS_o,
+ KC(32), KS_u,
+ KC(33), KS_bracketleft, KS_braceleft,
+ KC(34), KS_i,
+ KC(35), KS_p,
+ KC(36), KS_Return,
+ KC(37), KS_l,
+ KC(38), KS_j,
+ KC(39), KS_apostrophe, KS_quotedbl,
+ KC(40), KS_k,
+ KC(41), KS_semicolon, KS_colon,
+ KC(42), KS_backslash, KS_bar,
+ KC(43), KS_comma, KS_less,
+ KC(44), KS_slash, KS_question,
+ KC(45), KS_n,
+ KC(46), KS_m,
+ KC(47), KS_period, KS_greater,
+ KC(48), KS_Tab,
+ KC(49), KS_space,
+ KC(50), KS_grave, KS_asciitilde,
+ KC(51), KS_Delete,
+ KC(52), KS_KP_Enter, /* Pretend this is alt-R ? */
+ KC(53), KS_Escape,
+ KC(54), KS_Control_L,
+ KC(55), KS_Cmd, /* Command */
+ KC(56), KS_Shift_L,
+ KC(57), KS_Caps_Lock,
+ KC(58), KS_Cmd1, /* Option */
+ KC(59), KS_Left,
+ KC(60), KS_Right,
+ KC(61), KS_Down,
+ KC(62), KS_Up,
+
+ KC(65), KS_KP_Decimal,
+ KC(67), KS_KP_Multiply,
+ KC(69), KS_KP_Add,
+ KC(71), KS_Num_Lock,
+ KC(75), KS_KP_Divide,
+ KC(76), KS_KP_Enter,
+ KC(78), KS_KP_Subtract,
+
+ KC(81), KS_KP_Equal,
+ KC(82), KS_KP_Insert, KS_KP_0,
+ KC(83), KS_KP_End, KS_KP_1,
+ KC(84), KS_KP_Down, KS_KP_2,
+ KC(85), KS_KP_Next, KS_KP_3,
+ KC(86), KS_KP_Left, KS_KP_4,
+ KC(87), KS_KP_Begin, KS_KP_5,
+ KC(88), KS_KP_Right, KS_KP_6,
+ KC(89), KS_KP_Home, KS_KP_7,
+
+ KC(91), KS_KP_Up, KS_KP_8,
+ KC(92), KS_KP_Prior, KS_KP_9,
+
+ KC(95), KS_KP_Delete, KS_KP_Decimal,
+ KC(96), KS_f5,
+ KC(97), KS_f6,
+ KC(98), KS_f7,
+ KC(99), KS_f3,
+ KC(100), KS_f8,
+
+ KC(101), KS_f9,
+
+ KC(103), KS_f11,
+
+ KC(105), KS_Print_Screen,
+ KC(106), KS_KP_Enter,
+ KC(107), KS_Hold_Screen,
+
+ KC(109), KS_f10,
+
+ KC(111), KS_f12,
+
+ KC(113), KS_Pause,
+ KC(114), KS_Insert,
+ KC(115), KS_Home,
+ KC(116), KS_Prior,
+ KC(117), KS_Delete,
+ KC(118), KS_f4,
+ KC(119), KS_End,
+ KC(120), KS_f2,
+ KC(121), KS_Next,
+ KC(122), KS_f1,
+
+ KC(127), KS_Cmd_Debugger,
+};
+
+static const keysym_t akbd_keydesc_fr[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(0), KS_q,
+ KC(1), KS_s, KS_S, KS_Ograve,
+ KC(4), KS_h, KS_H, KS_Igrave, KS_Icircumflex,
+ KC(6), KS_w, KS_W, KS_less, KS_greater,
+ KC(8), KS_c, KS_C, KS_copyright, KS_cent,
+ KC(10), KS_at, KS_numbersign,
+ KC(11), KS_b, KS_B, KS_ssharp,
+ KC(12), KS_a, KS_A, KS_ae, KS_AE,
+ KC(13), KS_z, KS_Z, KS_Acircumflex, KS_Aring,
+ KC(14), KS_e, KS_E, KS_ecircumflex, KS_Ecircumflex,
+ KC(15), KS_r, KS_R, KS_registered, /* Euro */
+ KC(16), KS_y, KS_Y, KS_Uacute,
+ KC(18), KS_ampersand, KS_1, KS_voidSymbol, KS_dead_acute,
+ KC(19), KS_eacute, KS_2, KS_ediaeresis,
+ KC(20), KS_quotedbl, KS_3,
+ KC(21), KS_apostrophe, KS_4, KS_braceleft, KS_bracketleft,
+ KC(22), KS_section, KS_6, KS_paragraph,
+ KC(23), KS_parenleft, KS_5, KS_braceleft, KS_bracketleft,
+ KC(24), KS_minus, KS_underscore, KS_braceright,
+ KC(25), KS_ccedilla, KS_9, KS_Ccedilla, KS_Agrave,
+ KC(26), KS_egrave, KS_7, KS_guillemotleft,KS_guillemotright,
+ KC(27), KS_parenright, KS_degree, KS_braceright, KS_bracketright,
+ KC(28), KS_exclam, KS_8, KS_exclamdown, KS_Ucircumflex,
+ KC(29), KS_agrave, KS_0, KS_oslash,
+ KC(30), KS_dollar, KS_asterisk, KS_comma, KS_yen,
+ KC(33), KS_dead_circumflex, KS_dead_diaeresis,KS_ocircumflex,KS_Ocircumflex,
+ KC(34), KS_i, KS_I, KS_icircumflex, KS_Icircumflex,
+ KC(37), KS_l, KS_L, KS_notsign, KS_bar,
+ KC(38), KS_j, KS_J, KS_Idiaeresis, KS_Igrave,
+ KC(39), KS_ugrave, KS_percent, KS_Ugrave,
+ KC(40), KS_k, KS_K, KS_Egrave, KS_Ediaeresis,
+ KC(41), KS_m, KS_M, KS_mu, KS_Ograve,
+ KC(42), KS_dead_grave, KS_sterling, KS_at, KS_numbersign,
+ KC(43), KS_semicolon, KS_period,
+ KC(44), KS_equal, KS_plus, KS_voidSymbol, KS_plusminus,
+ KC(45), KS_n, KS_N, KS_dead_tilde,
+ KC(46), KS_comma, KS_question, KS_voidSymbol, KS_questiondown,
+ KC(47), KS_colon, KS_slash, KS_division, KS_backslash,
+ KC(50), KS_less, KS_greater,
+ KC(52), KS_Alt_R,
+ KC(55), KS_Meta_L, /* Command */
+ KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
+};
+
+static const keysym_t akbd_keydesc_fr_nodead[] = {
+ KC(18), KS_ampersand, KS_1, KS_voidSymbol, KS_acute,
+ KC(33), KS_asciicircum, KS_diaeresis, KS_ocircumflex, KS_Ocircumflex,
+ KC(42), KS_grave, KS_sterling, KS_at, KS_numbersign,
+ KC(45), KS_n, KS_N, KS_asciitilde,
+};
+
+static const keysym_t akbd_keydesc_jp[] = {
+/* pos command normal shifted */
+ KC(19), KS_2, KS_quotedbl,
+ KC(22), KS_6, KS_ampersand,
+ KC(24), KS_asciicircum, KS_asciitilde,
+ KC(25), KS_9, KS_parenright,
+ KC(26), KS_7, KS_apostrophe,
+ KC(27), KS_minus, KS_equal,
+ KC(28), KS_8, KS_parenleft,
+ KC(29), KS_0,
+ KC(30), KS_bracketleft, KS_braceleft,
+ KC(33), KS_at, KS_grave,
+ KC(39), KS_colon, KS_asterisk,
+
+ KC(41), KS_semicolon, KS_plus,
+ KC(42), KS_bracketright,KS_braceright,
+ KC(93), KS_backslash, KS_bar,
+ KC(94), KS_underscore,
+};
+
+static const keysym_t akbd_keydesc_uk[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(10), KS_section, KS_plusminus,
+ KC(20), KS_3, KS_sterling, KS_numbersign,
+ KC(52), KS_KP_Enter,
+ KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
+};
+
+static const keysym_t akbd_keydesc_sv[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(10), KS_section, KS_degree,
+ KC(19), KS_2, KS_quotedbl, KS_at,
+ KC(21), KS_4, KS_dollar,
+ KC(22), KS_6, KS_ampersand,
+ KC(24), KS_dead_acute, KS_dead_grave,
+ KC(25), KS_9, KS_parenright, KS_bracketright,
+ KC(26), KS_7, KS_slash, KS_braceleft,
+ KC(27), KS_plus, KS_question, KS_backslash,
+ KC(28), KS_8, KS_parenleft, KS_bracketleft,
+ KC(29), KS_0, KS_equal, KS_braceright,
+ KC(30), KS_dead_diaeresis,KS_dead_circumflex,KS_dead_tilde,
+ KC(33), KS_aring,
+ KC(39), KS_adiaeresis,
+ KC(41), KS_odiaeresis,
+ KC(42), KS_apostrophe, KS_asterisk,
+ KC(43), KS_comma, KS_semicolon,
+ KC(44), KS_minus, KS_underscore,
+ KC(47), KS_period, KS_colon,
+ KC(50), KS_less, KS_greater, KS_bar,
+ KC(58), KS_Mode_switch,KS_Multi_key,
+};
+
+static const keysym_t akbd_keydesc_sv_nodead[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(24), KS_apostrophe, KS_grave,
+ KC(30), KS_diaeresis, KS_asciicircum, KS_asciitilde,
+};
+
+static const keysym_t akbd_keydesc_de[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(0), KS_a, KS_A, KS_aring, KS_Aring,
+ KC(1), KS_s, KS_S, KS_voidSymbol, KS_Iacute,
+ KC(3), KS_f, KS_F, KS_voidSymbol, KS_Idiaeresis,
+ KC(4), KS_h, KS_H, KS_ordfeminine, KS_Oacute,
+ KC(5), KS_g, KS_G, KS_copyright, KS_Igrave,
+ KC(6), KS_y, KS_Y, KS_yen,
+ KC(7), KS_x, KS_X, KS_voidSymbol, KS_Ugrave,
+ KC(8), KS_c, KS_C, KS_ccedilla, KS_Ccedilla,
+ KC(10), KS_dead_circumflex,KS_degree,
+ KC(12), KS_q, KS_Q, KS_guillemotleft,KS_guillemotright,
+ KC(15), KS_r, KS_R, KS_registered, KS_cedilla,
+ KC(16), KS_z, KS_Z,
+ KC(18), KS_1, KS_exclam, KS_exclamdown, KS_notsign,
+ KC(19), KS_2, KS_quotedbl,
+ KC(20), KS_3, KS_section, KS_paragraph, KS_numbersign,
+ KC(21), KS_4, KS_dollar, KS_cent, KS_sterling,
+ KC(22), KS_6, KS_ampersand, KS_bracketright,KS_dead_circumflex,
+ KC(23), KS_5, KS_percent, KS_bracketleft,
+ KC(24), KS_dead_acute, KS_dead_grave, KS_apostrophe,
+ KC(25), KS_9, KS_parenright, KS_braceright, KS_periodcentered,
+ KC(26), KS_7, KS_slash, KS_bar, KS_backslash,
+ KC(27), KS_ssharp, KS_question, KS_questiondown,
+ KC(28), KS_8, KS_parenleft, KS_braceleft,
+ KC(29), KS_0, KS_equal, KS_voidSymbol, KS_macron,
+ KC(30), KS_plus, KS_asterisk, KS_plusminus,
+ KC(31), KS_o, KS_O, KS_oslash, KS_Ooblique,
+ KC(32), KS_u, KS_U, KS_dead_diaeresis,KS_Aacute,
+ KC(33), KS_udiaeresis, KS_Udiaeresis, KS_voidSymbol, KS_degree,
+ KC(34), KS_i, KS_I, KS_voidSymbol, KS_Ucircumflex,
+ KC(37), KS_l, KS_L, KS_at,
+ KC(38), KS_j, KS_J, KS_masculine,
+ KC(39), KS_adiaeresis, KS_Adiaeresis, KS_ae, KS_AE,
+ KC(41), KS_odiaeresis, KS_Odiaeresis,
+ KC(42), KS_numbersign, KS_apostrophe,
+ KC(43), KS_comma, KS_semicolon,
+ KC(44), KS_minus, KS_underscore,
+ KC(45), KS_n, KS_N, KS_dead_tilde,
+ KC(46), KS_m, KS_M, KS_mu,
+ KC(47), KS_period, KS_colon,
+ KC(50), KS_less, KS_greater,
+ KC(52), KS_Multi_key,
+ KC(58), KS_Mode_switch,
+};
+
+static const keysym_t akbd_keydesc_de_nodead[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(10), KS_asciicircum, KS_degree,
+ KC(22), KS_6, KS_ampersand, KS_bracketright,KS_asciicircum,
+ KC(24), KS_acute, KS_grave, KS_apostrophe,
+ KC(32), KS_u, KS_U, KS_diaeresis, KS_Aacute,
+ KC(45), KS_n, KS_N, KS_asciitilde,
+};
+
+static const keysym_t akbd_keydesc_sf[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(6), KS_y,
+ KC(10), KS_paragraph, KS_degree,
+ KC(16), KS_z,
+ KC(18), KS_plus, KS_1,
+ KC(19), KS_quotedbl, KS_2,
+ KC(20), KS_asterisk, KS_3,
+ KC(21), KS_ccedilla, KS_4, KS_Ccedilla,
+ KC(22), KS_ampersand, KS_6,
+ KC(23), KS_percent, KS_5,
+ KC(24), KS_dead_circumflex,KS_grave,
+ KC(25), KS_parenright, KS_9,
+ KC(26), KS_slash, KS_7,
+ KC(27), KS_apostrophe, KS_question,
+ KC(28), KS_parenleft, KS_8,
+ KC(29), KS_equal, KS_0,
+ KC(30), KS_dead_diaeresis,KS_exclam,
+ KC(33), KS_egrave, KS_udiaeresis,
+ KC(39), KS_agrave, KS_adiaeresis,
+ KC(41), KS_eacute, KS_odiaeresis,
+ KC(42), KS_dollar, KS_sterling,
+ KC(43), KS_period, KS_colon,
+ KC(46), KS_comma, KS_semicolon,
+ KC(47), KS_minus, KS_underscore,
+ KC(50), KS_less, KS_greater,
+};
+
+static const keysym_t akbd_keydesc_es[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(10), KS_degree, KS_ordfeminine, KS_backslash,
+ KC(18), KS_1, KS_exclam, KS_bar,
+ KC(19), KS_2, KS_quotedbl, KS_at,
+ KC(20), KS_3, KS_periodcentered, KS_numbersign,
+ KC(21), KS_4, KS_dollar, KS_asciitilde,
+ KC(22), KS_6, KS_ampersand, KS_notsign,
+ KC(23), KS_5, KS_percent,
+ KC(24), KS_exclamdown, KS_questiondown,
+ KC(25), KS_9, KS_parenright,
+ KC(26), KS_7, KS_slash,
+ KC(27), KS_apostrophe, KS_question,
+ KC(28), KS_8, KS_parenleft,
+ KC(29), KS_0, KS_equal,
+ KC(30), KS_plus, KS_asterisk, KS_bracketright,
+ KC(33), KS_dead_grave, KS_dead_circumflex, KS_bracketleft,
+ KC(39), KS_dead_acute, KS_dead_diaeresis, KS_braceleft,
+ KC(41), KS_ntilde,
+ KC(42), KS_ccedilla, KS_Ccedilla, KS_braceright,
+ KC(43), KS_comma, KS_semicolon,
+ KC(44), KS_minus, KS_underscore,
+ KC(47), KS_period, KS_colon,
+ KC(50), KS_less, KS_greater,
+ KC(55), KS_Alt_L, /* Command */
+ KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
+};
+
+static const keysym_t akbd_keydesc_pt[] = {
+/* pos normal shifted altgr shift-altgr */
+ KC(7), KS_x, KS_X, KS_guillemotleft, KS_guillemotright,
+ KC(10), KS_section, KS_plusminus,
+ KC(19), KS_2, KS_quotedbl, KS_at,
+ KC(20), KS_3, KS_numbersign, KS_sterling,
+ KC(22), KS_6, KS_ampersand,
+ KC(24), KS_plus, KS_asterisk,
+ KC(25), KS_9, KS_parenright, KS_bracketright, KS_braceright,
+ KC(26), KS_7, KS_slash,
+ KC(27), KS_apostrophe, KS_question,
+ KC(28), KS_8, KS_parenleft, KS_bracketleft, KS_braceleft,
+ KC(29), KS_0, KS_equal,
+ KC(30), KS_dead_acute, KS_dead_grave,
+ KC(33), KS_masculine, KS_ordfeminine,
+ KC(39), KS_dead_tilde, KS_dead_circumflex,
+ KC(41), KS_ccedilla, KS_Ccedilla,
+ KC(43), KS_comma, KS_semicolon,
+ KC(44), KS_minus, KS_underscore,
+ KC(47), KS_period, KS_colon,
+ KC(50), KS_less, KS_greater,
+ KC(58), KS_Mode_switch,
+ KC(81), KS_KP_Equal,
+};
+
+#define KBD_MAP(name, base, map) \
+ { name, base, sizeof(map)/sizeof(keysym_t), map }
+
+static const struct wscons_keydesc akbd_keydesctab[] = {
+ KBD_MAP(KB_US, 0, akbd_keydesc_us),
+ KBD_MAP(KB_FR, KB_US, akbd_keydesc_fr),
+ KBD_MAP(KB_JP, KB_US, akbd_keydesc_jp),
+ KBD_MAP(KB_FR | KB_NODEAD, KB_FR, akbd_keydesc_fr_nodead),
+ KBD_MAP(KB_SF, KB_US, akbd_keydesc_sf),
+ KBD_MAP(KB_SV, KB_US, akbd_keydesc_sv),
+ KBD_MAP(KB_SV | KB_NODEAD, KB_SV, akbd_keydesc_sv_nodead),
+ KBD_MAP(KB_DE, KB_US, akbd_keydesc_de),
+ KBD_MAP(KB_DE | KB_NODEAD, KB_DE, akbd_keydesc_de_nodead),
+ KBD_MAP(KB_UK, KB_US, akbd_keydesc_uk),
+ KBD_MAP(KB_ES, KB_US, akbd_keydesc_es),
+ KBD_MAP(KB_PT, KB_US, akbd_keydesc_pt),
+ {0, 0, 0, 0}
+};
+
+#undef KBD_MAP
+#undef KC
+
diff --git a/sys/arch/mac68k/dev/akbdvar.h b/sys/arch/mac68k/dev/akbdvar.h
new file mode 100644
index 00000000000..9688e8b421c
--- /dev/null
+++ b/sys/arch/mac68k/dev/akbdvar.h
@@ -0,0 +1,71 @@
+/* $OpenBSD: akbdvar.h,v 1.1 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: akbdvar.h,v 1.4 1999/02/17 14:56:56 tsubai Exp $ */
+
+/*
+ * Copyright (C) 1998 Colin Wood
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Colin Wood.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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 _MAC68K_KBDVAR_H_
+#define _MAC68K_KBDVAR_H_
+
+#include <machine/adbsys.h>
+
+/*
+ * State info, per keyboard instance.
+ */
+struct akbd_softc {
+ struct device sc_dev;
+
+ /* ADB info */
+ int origaddr; /* ADB device type (ADBADDR_KBD) */
+ int adbaddr; /* current ADB address */
+ int handler_id; /* type of keyboard */
+
+ u_int8_t sc_leds; /* current LED state */
+ struct device *sc_wskbddev;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+#define MAXKEYS 20
+#define REP_DELAY1 400
+#define REP_DELAYN 100
+ int sc_rawkbd;
+ int sc_nrep;
+ char sc_rep[MAXKEYS];
+ struct timeout sc_rawrepeat_ch;
+#endif /* defined(WSDISPLAY_COMPAT_RAWKBD) */
+};
+
+/* LED register bits, inverse of actual register value */
+#define LED_NUMLOCK 0x1
+#define LED_CAPSLOCK 0x2
+#define LED_SCROLL_LOCK 0x4
+
+void kbd_adbcomplete(caddr_t buffer, caddr_t data_area, int adb_command);
+int akbd_cnattach(void);
+
+#endif /* _MAC68K_KBDVAR_H_ */
diff --git a/sys/arch/mac68k/dev/ams.c b/sys/arch/mac68k/dev/ams.c
new file mode 100644
index 00000000000..874a601d0cf
--- /dev/null
+++ b/sys/arch/mac68k/dev/ams.c
@@ -0,0 +1,535 @@
+/* $OpenBSD: ams.c,v 1.1 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: ams.c,v 1.11 2000/12/19 03:13:40 tsubai Exp $ */
+
+/*
+ * Copyright (C) 1998 Colin Wood
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Colin Wood.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/fcntl.h>
+#include <sys/poll.h>
+#include <sys/selinfo.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+#include <sys/systm.h>
+
+#include <machine/autoconf.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#include <mac68k/dev/adbvar.h>
+#include <mac68k/dev/amsvar.h>
+
+/*
+ * Function declarations.
+ */
+int amsmatch(struct device *, void *, void *);
+void amsattach(struct device *, struct device *, void *);
+void ems_init(struct ams_softc *);
+void ms_processevent(adb_event_t *event, struct ams_softc *);
+
+/* Driver definition. */
+struct cfattach ams_ca = {
+ sizeof(struct ams_softc), amsmatch, amsattach
+};
+/* Driver definition. */
+struct cfdriver ams_cd = {
+ NULL, "ams", DV_DULL
+};
+
+
+int ams_enable(void *);
+int ams_ioctl(void *, u_long, caddr_t, int, struct proc *);
+void ams_disable(void *);
+
+const struct wsmouse_accessops ams_accessops = {
+ ams_enable,
+ ams_ioctl,
+ ams_disable,
+};
+
+int
+amsmatch(struct device *parent, void *cf, void *aux)
+{
+ struct adb_attach_args *aa_args = aux;
+
+ if (aa_args->origaddr == ADBADDR_MS)
+ return 1;
+ else
+ return 0;
+}
+
+void
+amsattach(struct device *parent, struct device *self, void *aux)
+{
+ ADBSetInfoBlock adbinfo;
+ struct ams_softc *sc = (struct ams_softc *)self;
+ struct adb_attach_args *aa_args = aux;
+ int error;
+ struct wsmousedev_attach_args a;
+
+ sc->origaddr = aa_args->origaddr;
+ sc->adbaddr = aa_args->adbaddr;
+ sc->handler_id = aa_args->handler_id;
+
+ sc->sc_class = MSCLASS_MOUSE;
+ sc->sc_buttons = 1;
+ sc->sc_res = 100;
+ sc->sc_devid[0] = 0;
+ sc->sc_devid[4] = 0;
+
+ adbinfo.siServiceRtPtr = (Ptr)adb_ms_asmcomplete;
+ adbinfo.siDataAreaAddr = (caddr_t)sc;
+
+ ems_init(sc);
+
+ /* print out the type of mouse we have */
+ switch (sc->handler_id) {
+ case ADBMS_100DPI:
+ printf("%d-button, %d dpi mouse\n", sc->sc_buttons,
+ (int)(sc->sc_res));
+ break;
+ case ADBMS_200DPI:
+ sc->sc_res = 200;
+ printf("%d-button, %d dpi mouse\n", sc->sc_buttons,
+ (int)(sc->sc_res));
+ break;
+ case ADBMS_MSA3:
+ printf("Mouse Systems A3 mouse, %d-button, %d dpi\n",
+ sc->sc_buttons, (int)(sc->sc_res));
+ break;
+ case ADBMS_USPEED:
+ printf("MicroSpeed mouse, default parameters\n");
+ break;
+ case ADBMS_UCONTOUR:
+ printf("Contour mouse, default parameters\n");
+ break;
+ case ADBMS_TURBO:
+ printf("Kensington Turbo Mouse\n");
+ break;
+ case ADBMS_EXTENDED:
+ if (sc->sc_devid[0] == '\0') {
+ printf("Logitech ");
+ switch (sc->sc_class) {
+ case MSCLASS_MOUSE:
+ printf("MouseMan (non-EMP) mouse");
+ break;
+ case MSCLASS_TRACKBALL:
+ printf("TrackMan (non-EMP) trackball");
+ break;
+ default:
+ printf("non-EMP relative positioning device");
+ break;
+ }
+ printf("\n");
+ } else {
+ printf("EMP ");
+ switch (sc->sc_class) {
+ case MSCLASS_TABLET:
+ printf("tablet");
+ break;
+ case MSCLASS_MOUSE:
+ printf("mouse");
+ break;
+ case MSCLASS_TRACKBALL:
+ printf("trackball");
+ break;
+ case MSCLASS_TRACKPAD:
+ printf("trackpad");
+ break;
+ default:
+ printf("unknown device");
+ break;
+ }
+ printf(" <%s> %d-button, %d dpi\n", sc->sc_devid,
+ sc->sc_buttons, (int)(sc->sc_res));
+ }
+ break;
+ default:
+ printf("relative positioning device (mouse?) (%d)\n",
+ sc->handler_id);
+ break;
+ }
+ error = SetADBInfo(&adbinfo, sc->adbaddr);
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("ams: returned %d from SetADBInfo\n", error);
+#endif
+
+ a.accessops = &ams_accessops;
+ a.accesscookie = sc;
+ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+}
+
+
+/*
+ * Initialize extended mouse support -- probes devices as described
+ * in Inside Macintosh: Devices, Chapter 5 "ADB Manager".
+ *
+ * Extended Mouse Protocol is documented in TechNote HW1:
+ * "ADB - The Untold Story: Space Aliens Ate My Mouse"
+ *
+ * Supports: Extended Mouse Protocol, MicroSpeed Mouse Deluxe,
+ * Mouse Systems A^3 Mouse, Logitech non-EMP MouseMan
+ */
+void
+ems_init(struct ams_softc *sc)
+{
+ int adbaddr;
+ short cmd;
+ u_char buffer[9];
+
+ adbaddr = sc->adbaddr;
+ if (sc->origaddr != ADBADDR_MS)
+ return;
+ if (sc->handler_id == ADBMS_USPEED ||
+ sc->handler_id == ADBMS_UCONTOUR) {
+ /* Found MicroSpeed Mouse Deluxe Mac or Contour Mouse */
+ cmd = ADBLISTEN(adbaddr, 1);
+
+ /*
+ * To setup the MicroSpeed or the Contour, it appears
+ * that we can send the following command to the mouse
+ * and then expect data back in the form:
+ * buffer[0] = 4 (bytes)
+ * buffer[1], buffer[2] as std. mouse
+ * buffer[3] = buffer[4] = 0xff when no buttons
+ * are down. When button N down, bit N is clear.
+ * buffer[4]'s locking mask enables a
+ * click to toggle the button down state--sort of
+ * like the "Easy Access" shift/control/etc. keys.
+ * buffer[3]'s alternative speed mask enables using
+ * different speed when the corr. button is down
+ */
+ buffer[0] = 4;
+ buffer[1] = 0x00; /* Alternative speed */
+ buffer[2] = 0x00; /* speed = maximum */
+ buffer[3] = 0x10; /* enable extended protocol,
+ * lower bits = alt. speed mask
+ * = 0000b
+ */
+ buffer[4] = 0x07; /* Locking mask = 0000b,
+ * enable buttons = 0111b
+ */
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+
+ sc->sc_buttons = 3;
+ sc->sc_res = 200;
+ return;
+ }
+ if (sc->handler_id == ADBMS_TURBO) {
+ /* Found Kensington Turbo Mouse */
+ static u_char data1[] =
+ { 8, 0xe7, 0x8c, 0, 0, 0, 0xff, 0xff, 0x94 };
+ static u_char data2[] =
+ { 8, 0xa5, 0x14, 0, 0, 0x69, 0xff, 0xff, 0x27 };
+
+ buffer[0] = 0;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, ADBFLUSH(adbaddr));
+
+ adb_op_sync((Ptr)data1, (Ptr)0, (Ptr)0, ADBLISTEN(adbaddr, 2));
+
+ buffer[0] = 0;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, ADBFLUSH(adbaddr));
+
+ adb_op_sync((Ptr)data2, (Ptr)0, (Ptr)0, ADBLISTEN(adbaddr, 2));
+ return;
+ }
+ if ((sc->handler_id == ADBMS_100DPI) ||
+ (sc->handler_id == ADBMS_200DPI)) {
+ /* found a mouse */
+ cmd = ADBTALK(adbaddr, 3);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd)) {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: ems_init timed out\n");
+#endif
+ return;
+ }
+
+ /* Attempt to initialize Extended Mouse Protocol */
+ buffer[2] = 4; /* make handler ID 4 */
+ cmd = ADBLISTEN(adbaddr, 3);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd)) {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: ems_init timed out\n");
+#endif
+ return;
+ }
+
+ /*
+ * Check to see if successful, if not
+ * try to initialize it as other types
+ */
+ cmd = ADBTALK(adbaddr, 3);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd) == 0 &&
+ buffer[2] == ADBMS_EXTENDED) {
+ sc->handler_id = ADBMS_EXTENDED;
+ cmd = ADBTALK(adbaddr, 1);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd)) {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: ems_init timed out\n");
+#endif
+ } else if (buffer[0] == 8) {
+ /* we have a true EMP device */
+ sc->sc_class = buffer[7];
+ sc->sc_buttons = buffer[8];
+ sc->sc_res = (int)*(short *)&buffer[5];
+ bcopy(&(buffer[1]), sc->sc_devid, 4);
+ } else if (buffer[1] == 0x9a &&
+ ((buffer[2] == 0x20) || (buffer[2] == 0x21))) {
+ /*
+ * Set up non-EMP Mouseman/Trackman to put
+ * button bits in 3rd byte instead of sending
+ * via pseudo keyboard device.
+ */
+ cmd = ADBLISTEN(adbaddr, 1);
+ buffer[0]=2;
+ buffer[1]=0x00;
+ buffer[2]=0x81;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+
+ cmd = ADBLISTEN(adbaddr, 1);
+ buffer[0]=2;
+ buffer[1]=0x01;
+ buffer[2]=0x81;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+
+ cmd = ADBLISTEN(adbaddr, 1);
+ buffer[0]=2;
+ buffer[1]=0x02;
+ buffer[2]=0x81;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+
+ cmd = ADBLISTEN(adbaddr, 1);
+ buffer[0]=2;
+ buffer[1]=0x03;
+ buffer[2]=0x38;
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+
+ sc->sc_buttons = 3;
+ sc->sc_res = 400;
+ if (buffer[2] == 0x21)
+ sc->sc_class = MSCLASS_TRACKBALL;
+ else
+ sc->sc_class = MSCLASS_MOUSE;
+ } else
+ /* unknown device? */;
+ } else {
+ /* Attempt to initialize as an A3 mouse */
+ buffer[2] = 0x03; /* make handler ID 3 */
+ cmd = ADBLISTEN(adbaddr, 3);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd)) {
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("adb: ems_init timed out\n");
+#endif
+ return;
+ }
+
+ /*
+ * Check to see if successful, if not
+ * try to initialize it as other types
+ */
+ cmd = ADBTALK(adbaddr, 3);
+ if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd) == 0
+ && buffer[2] == ADBMS_MSA3) {
+ sc->handler_id = ADBMS_MSA3;
+ /* Initialize as above */
+ cmd = ADBLISTEN(adbaddr, 2);
+ /* listen 2 */
+ buffer[0] = 3;
+ buffer[1] = 0x00;
+ /* Irrelevant, buffer has 0x77 */
+ buffer[2] = 0x07;
+ /*
+ * enable 3 button mode = 0111b,
+ * speed = normal
+ */
+ adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd);
+ sc->sc_buttons = 3;
+ sc->sc_res = 300;
+ } else {
+ /* No special support for this mouse */
+ }
+ }
+ }
+}
+
+/*
+ * Handle putting the mouse data received from the ADB into
+ * an ADB event record.
+ */
+void
+ms_adbcomplete(caddr_t buffer, caddr_t data_area, int adb_command)
+{
+ adb_event_t event;
+ struct ams_softc *sc;
+ int adbaddr;
+#ifdef ADB_DEBUG
+ int i;
+
+ if (adb_debug)
+ printf("adb: transaction completion\n");
+#endif
+
+ adbaddr = ADB_CMDADDR(adb_command);
+ sc = (struct ams_softc *)data_area;
+
+ if ((sc->handler_id == ADBMS_EXTENDED) && (sc->sc_devid[0] == 0)) {
+ /* massage the data to look like EMP data */
+ if ((buffer[3] & 0x04) == 0x04)
+ buffer[1] &= 0x7f;
+ else
+ buffer[1] |= 0x80;
+ if ((buffer[3] & 0x02) == 0x02)
+ buffer[2] &= 0x7f;
+ else
+ buffer[2] |= 0x80;
+ if ((buffer[3] & 0x01) == 0x01)
+ buffer[3] = 0x00;
+ else
+ buffer[3] = 0x80;
+ }
+
+ event.addr = adbaddr;
+ event.hand_id = sc->handler_id;
+ event.def_addr = sc->origaddr;
+ event.byte_count = buffer[0];
+ memcpy(event.bytes, buffer + 1, event.byte_count);
+
+#ifdef ADB_DEBUG
+ if (adb_debug) {
+ printf("ams: from %d at %d (org %d) %d:", event.addr,
+ event.hand_id, event.def_addr, buffer[0]);
+ for (i = 1; i <= buffer[0]; i++)
+ printf(" %x", buffer[i]);
+ printf("\n");
+ }
+#endif
+
+ microtime(&event.timestamp);
+
+ ms_processevent(&event, sc);
+}
+
+/*
+ * Given a mouse ADB event, record the button settings, calculate the
+ * x- and y-axis motion, and handoff the event to the appropriate subsystem.
+ */
+void
+ms_processevent(adb_event_t *event, struct ams_softc *sc)
+{
+ adb_event_t new_event;
+ int i, button_bit, max_byte, mask, buttons;
+
+ new_event = *event;
+ buttons = 0;
+
+ /*
+ * This should handle both plain ol' Apple mice and mice
+ * that claim to support the Extended Apple Mouse Protocol.
+ */
+ max_byte = event->byte_count;
+ button_bit = 1;
+ switch (event->hand_id) {
+ case ADBMS_USPEED:
+ case ADBMS_UCONTOUR:
+ /* MicroSpeed mouse and Contour mouse */
+ if (max_byte == 4)
+ buttons = (~event->bytes[2]) & 0xff;
+ else
+ buttons = (event->bytes[0] & 0x80) ? 0 : 1;
+ break;
+ case ADBMS_MSA3:
+ /* Mouse Systems A3 mouse */
+ if (max_byte == 3)
+ buttons = (~event->bytes[2]) & 0x07;
+ else
+ buttons = (event->bytes[0] & 0x80) ? 0 : 1;
+ break;
+ default:
+ /* Classic Mouse Protocol (up to 2 buttons) */
+ for (i = 0; i < 2; i++, button_bit <<= 1)
+ /* 0 when button down */
+ if (!(event->bytes[i] & 0x80))
+ buttons |= button_bit;
+ else
+ buttons &= ~button_bit;
+ /* Extended Protocol (up to 6 more buttons) */
+ for (mask = 0x80; i < max_byte;
+ i += (mask == 0x80), button_bit <<= 1) {
+ /* 0 when button down */
+ if (!(event->bytes[i] & mask))
+ buttons |= button_bit;
+ else
+ buttons &= ~button_bit;
+ mask = ((mask >> 4) & 0xf)
+ | ((mask & 0xf) << 4);
+ }
+ break;
+ }
+ new_event.u.m.buttons = sc->sc_mb | buttons;
+ new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
+ ((event->bytes[1] & 0x40) ? 64 : 0);
+ new_event.u.m.dy = ((signed int) (event->bytes[0] & 0x3f)) -
+ ((event->bytes[0] & 0x40) ? 64 : 0);
+
+ if (sc->sc_wsmousedev)
+ wsmouse_input(sc->sc_wsmousedev, new_event.u.m.buttons,
+ new_event.u.m.dx, -new_event.u.m.dy, 0,
+ WSMOUSE_INPUT_DELTA);
+}
+
+int
+ams_enable(void *v)
+{
+ return 0;
+}
+
+int
+ams_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ switch (cmd) {
+ case WSMOUSEIO_GTYPE:
+ *(u_int *)data = WSMOUSE_TYPE_ADB;
+ return (0);
+ }
+
+ return -1;
+}
+
+void
+ams_disable(void *v)
+{
+}
diff --git a/sys/arch/mac68k/dev/amsvar.h b/sys/arch/mac68k/dev/amsvar.h
new file mode 100644
index 00000000000..a4d7960cbd6
--- /dev/null
+++ b/sys/arch/mac68k/dev/amsvar.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: amsvar.h,v 1.1 2006/01/04 20:39:04 miod Exp $ */
+/* $NetBSD: amsvar.h,v 1.4 1999/06/17 06:59:05 tsubai Exp $ */
+
+/*
+ * Copyright (C) 1998 Colin Wood
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Colin Wood.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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 _MAC68K_AMSVAR_H_
+#define _MAC68K_AMSVAR_H_
+
+/*
+ * State info, per mouse instance.
+ */
+struct ams_softc {
+ struct device sc_dev;
+
+ /* ADB info */
+ int origaddr; /* ADB device type (ADBADDR_MS) */
+ int adbaddr; /* current ADB address */
+ int handler_id; /* type of mouse */
+
+ /* Extended Mouse Protocol info, faked for non-EMP mice */
+ u_int8_t sc_class; /* mouse class (mouse, trackball) */
+ u_int8_t sc_buttons; /* number of buttons */
+ u_int32_t sc_res; /* mouse resolution (dpi) */
+ char sc_devid[5]; /* device indentifier */
+
+ int sc_mb; /* current button state */
+ struct device *sc_wsmousedev;
+};
+
+/* EMP device classes */
+#define MSCLASS_TABLET 0
+#define MSCLASS_MOUSE 1
+#define MSCLASS_TRACKBALL 2
+#define MSCLASS_TRACKPAD 3
+
+void ms_adbcomplete(caddr_t buffer, caddr_t data_area, int adb_command);
+void ms_handoff(adb_event_t *event, struct ams_softc *);
+
+#endif /* _MAC68K_AMSVAR_H_ */
diff --git a/sys/arch/mac68k/dev/grf.c b/sys/arch/mac68k/dev/grf.c
deleted file mode 100644
index 159df4083a1..00000000000
--- a/sys/arch/mac68k/dev/grf.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* $OpenBSD: grf.c,v 1.30 2005/10/23 19:00:26 martin Exp $ */
-/* $NetBSD: grf.c,v 1.53 1998/06/02 02:14:20 scottr Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * from: Utah $Hdr: grf.c 1.31 91/01/21$
- *
- * @(#)grf.c 7.8 (Berkeley) 5/7/91
- */
-
-/*
- * Graphics display driver for the Macintosh.
- * This is the hardware-independent portion of the driver.
- * Hardware access is through the grfdev routines below.
- */
-
-#include <sys/param.h>
-
-#include <sys/device.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-#include <sys/mman.h>
-#include <sys/poll.h>
-#include <sys/proc.h>
-#include <sys/resourcevar.h>
-#include <sys/vnode.h>
-#include <sys/systm.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/grfioctl.h>
-
-#include <miscfs/specfs/specdev.h>
-
-#include <uvm/uvm.h>
-
-#include <mac68k/dev/nubus.h>
-#include <mac68k/dev/itevar.h>
-#include <mac68k/dev/grfvar.h>
-
-#include "grf.h"
-#include "ite.h"
-
-#if NITE == 0
-#define iteon(u,f)
-#define iteoff(u,f)
-#endif
-
-int grfmatch(struct device *, void *, void *);
-void grfattach(struct device *, struct device *, void *);
-
-struct cfdriver grf_cd = {
- NULL, "grf", DV_DULL
-};
-
-struct cfattach grf_ca = {
- sizeof(struct grf_softc), grfmatch, grfattach
-};
-
-#ifdef DEBUG
-#define GRF_DEBUG
-#endif
-
-#ifdef GRF_DEBUG
-#define GDB_DEVNO 0x01
-#define GDB_MMAP 0x02
-#define GDB_IOMAP 0x04
-#define GDB_LOCK 0x08
-int grfdebug = 0;
-#endif
-
-int
-grfmatch(parent, vcf, aux)
- struct device *parent;
- void *vcf;
- void *aux;
-{
- struct grfbus_attach_args *ga = aux;
-
- return (strcmp(ga->ga_name, "grf") == 0);
-}
-
-void
-grfattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct grf_softc *sc = (struct grf_softc *)self;
- struct grfbus_attach_args *ga = aux;
-
- printf("\n");
-
- /* Load forwarded pointers. */
- sc->sc_grfmode = ga->ga_grfmode;
- sc->sc_slot = ga->ga_slot;
- sc->sc_tag = ga->ga_tag;
- sc->sc_regh = ga->ga_handle;
- sc->sc_mode = ga->ga_mode;
- sc->sc_phys = ga->ga_phys;
-
- sc->sc_flags = GF_ALIVE; /* XXX bogus */
-
- /*
- * Attach ite semantics to the grf. Change the name, forward
- * everything else.
- */
- ga->ga_name = "ite";
- (void)config_found(self, ga, grfbusprint);
-}
-
-/*ARGSUSED*/
-int
-grfopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- register struct grf_softc *gp;
- int unit;
- int error;
-
- unit = GRFUNIT(dev);
- gp = grf_cd.cd_devs[unit];
-
- if (unit >= grf_cd.cd_ndevs || (gp->sc_flags & GF_ALIVE) == 0)
- return (ENXIO);
-
- if ((gp->sc_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE))
- return (EBUSY);
-
- /*
- * First open.
- * XXX: always put in graphics mode.
- */
- error = 0;
- if ((gp->sc_flags & GF_OPEN) == 0) {
- gp->sc_flags |= GF_OPEN;
- error = grfon(dev);
- }
- return (error);
-}
-
-/*ARGSUSED*/
-int
-grfclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- register struct grf_softc *gp;
-
- gp = grf_cd.cd_devs[GRFUNIT(dev)];
-
- (void)grfoff(dev);
- gp->sc_flags &= GF_ALIVE;
-
- return (0);
-}
-
-/*ARGSUSED*/
-int
-grfioctl(dev, cmd, data, flag, p)
- dev_t dev;
- int cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct grf_softc *gp;
- struct grfmode *gm;
- int error;
- int unit = GRFUNIT(dev);
-
- gp = grf_cd.cd_devs[unit];
- gm = gp->sc_grfmode;
- error = 0;
-
- switch (cmd) {
- case GRFIOCON:
- error = grfon(dev);
- break;
- case GRFIOCOFF:
- error = grfoff(dev);
- break;
-
- case GRFIOCGMODE:
- bcopy(gm, data, sizeof(struct grfmode));
- break;
- case GRFIOCGETMODE:
- error = (*gp->sc_mode)(gp, GM_CURRMODE, data);
- break;
- case GRFIOCSETMODE:
- error = (*gp->sc_mode)(gp, GM_NEWMODE, data);
- break;
- case GRFIOCLISTMODES:
- error = (*gp->sc_mode)(gp, GM_LISTMODES, data);
- break;
-
- default:
- error = EINVAL;
- break;
- }
- return (error);
-}
-
-/*ARGSUSED*/
-int
-grfpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
-{
- /* always fails => never blocks */
- return (events & (POLLOUT | POLLWRNORM));
-}
-
-/*ARGSUSED*/
-paddr_t
-grfmmap(dev, off, prot)
- dev_t dev;
- off_t off;
- int prot;
-{
- struct grf_softc *gp = grf_cd.cd_devs[GRFUNIT(dev)];
- struct grfmode *gm = gp->sc_grfmode;
- u_long addr;
-
-#ifdef GRF_DEBUG
- if (grfdebug & GDB_MMAP)
- printf("grfmmap(%x): off %x, prot %x\n", dev, off, prot);
-#endif
-
- if (off < trunc_page(gm->fboff) ||
- off >= round_page(gm->fbsize + gm->fboff))
- addr = (-1); /* XXX bogus */
- else
- addr = atop(gp->sc_phys + off);
-
-#ifdef GRF_DEBUG
- if (grfdebug & GDB_MMAP)
- printf("grfmmap(%x): returning addr 0x%08lx\n", dev, addr);
-#endif
- return (int)addr;
-}
-
-int
-grfon(dev)
- dev_t dev;
-{
- int unit = GRFUNIT(dev);
- struct grf_softc *gp;
-
- gp = grf_cd.cd_devs[unit];
-
- /*
- * XXX: iteoff call relies on devices being in same order
- * as ITEs and the fact that iteoff only uses the minor part
- * of the dev arg.
- */
- iteoff(unit, 3);
-
- return (*gp->sc_mode)(gp, GM_GRFON, NULL);
-}
-
-int
-grfoff(dev)
- dev_t dev;
-{
- int unit = GRFUNIT(dev);
- struct grf_softc *gp;
- int error;
-
- gp = grf_cd.cd_devs[unit];
-
- error = (*gp->sc_mode)(gp, GM_GRFOFF, NULL);
-
- /* XXX: see comment for iteoff above */
- iteon(unit, 2);
-
- return (error);
-}
diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c
index d00d3e28936..58220e594e2 100644
--- a/sys/arch/mac68k/dev/grf_iv.c
+++ b/sys/arch/mac68k/dev/grf_iv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf_iv.c,v 1.31 2005/09/27 09:45:48 martin Exp $ */
+/* $OpenBSD: grf_iv.c,v 1.32 2006/01/04 20:39:04 miod Exp $ */
/* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */
/*
@@ -72,7 +72,6 @@
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <machine/cpu.h>
-#include <machine/grfioctl.h>
#include <machine/viareg.h>
#include <uvm/uvm_extern.h>
@@ -88,7 +87,6 @@ extern long videorowbytes;
extern long videobitdepth;
extern u_long videosize;
-static int grfiv_mode(struct grf_softc *gp, int cmd, void *arg);
static int grfiv_match(struct device *, void *, void *);
static void grfiv_attach(struct device *, struct device *, void *);
@@ -364,25 +362,5 @@ grfiv_attach(parent, self, aux)
gm->fboff = sc->sc_fbofs;
/* Perform common video attachment. */
- grf_establish(sc, NULL, grfiv_mode);
-}
-
-static int
-grfiv_mode(sc, cmd, arg)
- struct grf_softc *sc;
- int cmd;
- void *arg;
-{
- switch (cmd) {
- case GM_GRFON:
- case GM_GRFOFF:
- return 0;
- case GM_CURRMODE:
- break;
- case GM_NEWMODE:
- break;
- case GM_LISTMODES:
- break;
- }
- return EINVAL;
+ grf_establish(sc);
}
diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c
index 9893193d021..b42a5ef83af 100644
--- a/sys/arch/mac68k/dev/grf_mv.c
+++ b/sys/arch/mac68k/dev/grf_mv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf_mv.c,v 1.26 2005/09/12 10:07:29 martin Exp $ */
+/* $OpenBSD: grf_mv.c,v 1.27 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */
/*
@@ -42,7 +42,6 @@
#include <machine/bus.h>
#include <machine/cpu.h>
-#include <machine/grfioctl.h>
#include <machine/viareg.h>
#include <mac68k/dev/nubus.h>
@@ -68,7 +67,6 @@ static int grfmv_intr_gvimage(void *vsc);
static int grfmv_intr_radius_gsc(void *vsc);
static int grfmv_intr_radius_gx(void *vsc);
-static int grfmv_mode(struct grf_softc *gp, int cmd, void *arg);
static int grfmv_match(struct device *, void *, void *);
static void grfmv_attach(struct device *, struct device *, void *);
@@ -375,27 +373,7 @@ bad:
}
/* Perform common video attachment. */
- grf_establish(sc, &sc->sc_slot, grfmv_mode);
-}
-
-static int
-grfmv_mode(gp, cmd, arg)
- struct grf_softc *gp;
- int cmd;
- void *arg;
-{
- switch (cmd) {
- case GM_GRFON:
- case GM_GRFOFF:
- return 0;
- case GM_CURRMODE:
- break;
- case GM_NEWMODE:
- break;
- case GM_LISTMODES:
- break;
- }
- return EINVAL;
+ grf_establish(sc);
}
/* Interrupt handlers... */
diff --git a/sys/arch/mac68k/dev/grf_subr.c b/sys/arch/mac68k/dev/grf_subr.c
index 58c44afef60..ac35af1678e 100644
--- a/sys/arch/mac68k/dev/grf_subr.c
+++ b/sys/arch/mac68k/dev/grf_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grf_subr.c,v 1.7 2005/08/06 19:51:43 martin Exp $ */
+/* $OpenBSD: grf_subr.c,v 1.8 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: grf_subr.c,v 1.6 1997/02/20 00:23:28 scottr Exp $ */
/*-
@@ -42,16 +42,13 @@
#include <sys/systm.h>
#include <machine/bus.h>
-#include <machine/grfioctl.h>
#include <mac68k/dev/nubus.h>
#include <mac68k/dev/grfvar.h>
void
-grf_establish(sc, sp, g_mode)
+grf_establish(sc)
struct grfbus_softc *sc;
- nubus_slot *sp;
- int (*g_mode)(struct grf_softc *, int, void *);
{
struct grfmode *gm = &sc->curr_mode;
struct grfbus_attach_args ga;
@@ -66,9 +63,7 @@ grf_establish(sc, sp, g_mode)
/* Attach grf semantics to the hardware. */
ga.ga_name = "grf";
ga.ga_grfmode = gm;
- ga.ga_slot = sp;
ga.ga_phys = sc->sc_basepa;
- ga.ga_mode = g_mode;
(void)config_found(&sc->sc_dev, &ga, grfbusprint);
}
diff --git a/sys/arch/mac68k/dev/grfvar.h b/sys/arch/mac68k/dev/grfvar.h
index 4ac5a1ffb60..a89a57c453d 100644
--- a/sys/arch/mac68k/dev/grfvar.h
+++ b/sys/arch/mac68k/dev/grfvar.h
@@ -1,5 +1,6 @@
-/* $OpenBSD: grfvar.h,v 1.16 2005/08/06 19:51:43 martin Exp $ */
+/* $OpenBSD: grfvar.h,v 1.17 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: grfvar.h,v 1.11 1996/08/04 06:03:58 scottr Exp $ */
+/* $NetBSD: grfioctl.h,v 1.5 1995/07/02 05:26:45 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,6 +40,21 @@
* @(#)grfvar.h 7.3 (Berkeley) 5/7/91
*/
+struct grfmode {
+ u_int8_t mode_id; /* Identifier for mode */
+ caddr_t fbbase; /* Base of page of frame buffer */
+ u_int32_t fbsize; /* Size of frame buffer */
+ u_int16_t fboff; /* Offset of frame buffer from base */
+ u_int16_t rowbytes; /* Screen rowbytes */
+ u_int16_t width; /* Screen width */
+ u_int16_t height; /* Screen height */
+ u_int16_t hres; /* Horizontal resolution (dpi) */
+ u_int16_t vres; /* Vertical resolution (dpi) */
+ u_int16_t ptype; /* 0 = indexed, 0x10 = direct */
+ u_int16_t psize; /* Screen depth */
+ char pad[32]; /* Space for expansion */
+};
+
#define CARD_NAME_LEN 64
/*
@@ -64,38 +80,14 @@ struct grfbus_softc {
};
/*
- * State info, per grf instance.
- */
-struct grf_softc {
- struct device sc_dev; /* device glue */
-
- bus_space_tag_t sc_tag;
- bus_space_handle_t sc_regh;
-
- int sc_flags; /* driver flags */
- u_long sc_phys; /* PA of framebuffer */
-
- struct grfmode *sc_grfmode; /* forwarded ... */
- nubus_slot *sc_slot;
- /* mode-change on/off/mode function */
- int (*sc_mode)(struct grf_softc *, int, void *);
-};
-
-/*
* Attach grf and ite semantics to Mac video hardware.
*/
struct grfbus_attach_args {
char *ga_name; /* name of semantics to attach */
- bus_space_tag_t ga_tag;
- bus_space_handle_t ga_handle;
struct grfmode *ga_grfmode;
- nubus_slot *ga_slot;
bus_addr_t ga_phys;
- int (*ga_mode)(struct grf_softc *, int, void *);
};
-typedef caddr_t (*grf_phys_t)(struct grf_softc *gp, vaddr_t addr);
-
/* flags */
#define GF_ALIVE 0x01
#define GF_OPEN 0x02
@@ -112,7 +104,7 @@ typedef caddr_t (*grf_phys_t)(struct grf_softc *gp, vaddr_t addr);
#define GM_NEWMODE 5
/* minor device interpretation */
-#define GRFUNIT(d) ((d) & 0x7)
+#define GRFUNIT(d) (minor(d))
/*
* Nubus image data structure. This is the equivalent of a PixMap in
@@ -144,17 +136,5 @@ struct image_data {
#define VID_PAGE_CNT 3
#define VID_DEV_TYPE 4
-int grfopen(dev_t dev, int flag, int mode, struct proc *p);
-int grfclose(dev_t dev, int flag, int mode, struct proc *p);
-int grfioctl(dev_t, int, caddr_t, int, struct proc *p);
-int grfpoll(dev_t dev, int rw, struct proc *p);
-paddr_t grfmmap(dev_t dev, off_t off, int prot);
-int grfon(dev_t dev);
-int grfoff(dev_t dev);
-int grfaddr(struct grf_softc *gp, register int off);
-int grfmap(dev_t dev, caddr_t *addrp, struct proc *p);
-int grfunmap(dev_t dev, caddr_t addr, struct proc *p);
-
-void grf_establish(struct grfbus_softc *, nubus_slot *,
- int (*)(struct grf_softc *, int, void *));
+void grf_establish(struct grfbus_softc *);
int grfbusprint(void *, const char *);
diff --git a/sys/arch/mac68k/dev/ite.c b/sys/arch/mac68k/dev/ite.c
deleted file mode 100644
index 30917bd4cfd..00000000000
--- a/sys/arch/mac68k/dev/ite.c
+++ /dev/null
@@ -1,1345 +0,0 @@
-/* $OpenBSD: ite.c,v 1.25 2005/07/23 23:28:58 martin Exp $ */
-/* $NetBSD: ite.c,v 1.32 1997/02/20 00:23:25 scottr Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * from: Utah $Hdr: ite.c 1.28 92/12/20$
- *
- * @(#)ite.c 8.2 (Berkeley) 1/12/94
- */
-
-/*
- * ite.c
- *
- * The ite module handles the system console; that is, stuff printed
- * by the kernel and by user programs while "desktop" and X aren't
- * running. Some (very small) parts are based on hp300's 4.4 ite.c,
- * hence the above copyright.
- *
- * -- Brad and Lawrence, June 26th, 1994
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <dev/cons.h>
-#include <sys/conf.h>
-#include <sys/device.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/tty.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/frame.h>
-#include <machine/viareg.h>
-
-#define KEYBOARD_ARRAY
-#include <machine/keyboard.h>
-#include <machine/adbsys.h>
-#include <machine/iteioctl.h>
-#include <machine/grfioctl.h>
-
-#include <uvm/uvm_extern.h>
-#include <uvm/uvm_pmap.h>
-
-#include "../mac68k/macrom.h"
-
-#include "nubus.h"
-#include "itevar.h"
-#include "grfvar.h"
-
-#include "6x10.h"
-#define CHARWIDTH 6
-#define CHARHEIGHT 10
-
-/* Local function prototypes */
-static __inline void putpixel1(int, int, int *, int);
-static void putpixel2(int, int, int *, int);
-static void putpixel4(int, int, int *, int);
-static void putpixel8(int, int, int *, int);
-static void putpixel16(int, int, int *, int);
-static void putpixel32(int, int, int *, int);
-static void reversepixel1(int, int, int);
-static void writechar(char, int, int, int);
-static void drawcursor(void);
-static void erasecursor(void);
-static void scrollup(void);
-static void scrolldown(void);
-static void clear_screen(int);
-static void clear_line(int);
-static void reset_tabs(void);
-static void clear_tabs(void);
-static void vt100_reset(void);
-static void putc_normal(char);
-static void putc_esc(char);
-static void putc_gotpars(char);
-static void putc_getpars(char);
-static void putc_square(char);
-static void ite_putchar(char);
-static int ite_pollforchar(void);
-static int itematch(struct device *, void *, void *);
-static void iteattach(struct device *, struct device *, void *);
-static int ite_init(void);
-
-#define dprintf if (0) printf
-
-#define ATTR_NONE 0
-#define ATTR_BOLD 1
-#define ATTR_UNDER 2
-#define ATTR_REVERSE 4
-
-enum vt100state_e {
- ESnormal, /* Nothing yet */
- ESesc, /* Got ESC */
- ESsquare, /* Got ESC [ */
- ESgetpars, /* About to get or getting the parameters */
- ESgotpars, /* Finished getting the parameters */
- ESfunckey, /* Function key */
- EShash, /* DEC-specific stuff (screen align, etc.) */
- ESsetG0, /* Specify the G0 character set */
- ESsetG1, /* Specify the G1 character set */
- ESignore /* Ignore this sequence */
-} vt100state = ESnormal;
-
-/* From Booter via locore */
-long videoaddr;
-long videorowbytes;
-long videobitdepth;
-unsigned long videosize;
-
-/* Calculated by itecninit() */
-static int ite_initted = 0;
-static int width, height; /* width, height in pixels */
-static int scrcols, scrrows; /* width, height in characters */
-static int screenrowbytes; /* number of visible bytes per row */
-
-/* VT100 emulation */
-#define MAXPARS 16 /* max number of VT100 op parameters */
-static int par[MAXPARS], numpars; /* parameter array, # of parameters */
-static int x = 0, y = 0; /* current VT100 cursor location */
-static int savex, savey; /* saved cursor location */
-static int hanging_cursor; /* cursor waiting for more output */
-static int attr; /* current video attribute */
-static char tab_stops[255]; /* tab stops */
-static int scrreg_top; /* scroll region */
-static int scrreg_bottom;
-
-/* Console bell parameters */
-static int bell_freq = 1880; /* frequency */
-static int bell_length = 10; /* duration */
-static int bell_volume = 100; /* volume */
-
-/* For polled ADB mode */
-static int polledkey;
-extern int adb_polling;
-
-extern u_int32_t mac68k_vidphys;
-
-struct tty *ite_tty; /* Our tty */
-
-static void (*putpixel)(int x, int y, int *c, int num);
-static void (*reversepixel)(int x, int y, int num);
-
-/* For capslock key functionality */
-#define isealpha(ch) (((ch)>='A'&&(ch)<='Z')||((ch)>='a'&&(ch)<='z')||((ch)>=0xC0&&(ch)<=0xFF))
-
-/*
- * Bitmap handling functions
- */
-
-static __inline void
-putpixel1(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned int i, mask;
- unsigned char *sc;
-
- sc = (unsigned char *) videoaddr;
-
- i = 7 - (xx & 7);
- mask = ~(1 << i);
- sc += yy * videorowbytes + (xx >> 3);
- while (num--) {
- *sc &= mask;
- *sc |= (*c++ & 1) << i;
- sc += videorowbytes;
- }
-}
-
-static void
-putpixel2(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned int i, mask;
- unsigned char *sc;
-
- sc = (unsigned char *) videoaddr;
-
- i = 6 - ((xx & 3) << 1);
- mask = ~(3 << i);
- sc += yy * videorowbytes + (xx >> 2);
- while (num--) {
- *sc &= mask;
- *sc |= (*c++ & 3) << i;
- sc += videorowbytes;
- }
-}
-
-static void
-putpixel4(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned int i, mask;
- unsigned char *sc;
-
- sc = (unsigned char *) videoaddr;
-
- i = 4 - ((xx & 1) << 2);
- mask = ~(15 << i);
- sc += yy * videorowbytes + (xx >> 1);
- while (num--) {
- *sc &= mask;
- *sc |= (*c++ & 15) << i;
- sc += videorowbytes;
- }
-}
-
-static void
-putpixel8(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned char *sc;
-
- sc = (unsigned char *) videoaddr;
-
- sc += yy * videorowbytes + xx;
- while (num--) {
- *sc = *c++ & 0xff;
- sc += videorowbytes;
- }
-}
-
-static void
-putpixel16(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned short *sc;
- int videorowshorts;
- unsigned char uc;
-
- sc = (unsigned short *)videoaddr;
-
- videorowshorts = videorowbytes >> 1;
- sc += yy * videorowshorts + xx;
- while (num--) {
- uc = (*c++ & 0xff);
- *sc = (uc << 8) | uc;
- sc += videorowshorts;
- }
-}
-
-static void
-putpixel32(xx, yy, c, num)
- int xx, yy;
- int *c;
- int num;
-{
- unsigned long *sc;
- int videorowlongs;
- unsigned char uc;
-
- sc = (unsigned long *)videoaddr;
-
- videorowlongs = videorowbytes >> 2;
- sc += yy * videorowlongs + xx;
- while (num--) {
- uc = (*c++ & 0xff);
- *sc = (uc << 24) | (uc << 16) | (uc << 8) | uc;
- sc += videorowlongs;
-}
-}
-
-static void
-reversepixel1(xx, yy, num)
- int xx, yy, num;
-{
- unsigned int mask;
- unsigned char *sc;
- unsigned long *sl;
- unsigned short *ss;
- int videorowshorts;
- int videorowlongs;
-
- sc = (unsigned char *) videoaddr;
- mask = 0; /* Get rid of warning from compiler */
-
- switch (videobitdepth) {
- case 1:
- mask = 1 << (7 - (xx & 7));
- sc += yy * videorowbytes + (xx >> 3);
- break;
- case 2:
- mask = 3 << (6 - ((xx & 3) << 1));
- sc += yy * videorowbytes + (xx >> 2);
- break;
- case 4:
- mask = 15 << (4 - ((xx & 1) << 2));
- sc += yy * videorowbytes + (xx >> 1);
- break;
- case 8:
- mask = 255;
- sc += yy * videorowbytes + xx;
- break;
- case 16:
- videorowshorts = videorowbytes >> 1;
- ss = (unsigned short *) videoaddr;
- ss += yy * videorowshorts + xx;
- while (num--) {
- *ss ^= 0xffff;
- ss += videorowshorts;
- }
- return;
- case 32:
- videorowlongs = videorowbytes >> 2;
- sl = (unsigned long *) videoaddr;
- sl += yy * videorowlongs + xx;
- while (num--) {
- *sl ^= 0xffffffff;
- sl += videorowlongs;
- }
- return;
- default:
- panic("reversepixel(): unsupported bit depth");
- }
-
- while (num--) {
- *sc ^= mask;
- sc += videorowbytes;
- }
-}
-
-static void
-writechar(ch, x, y, attr)
- char ch;
- int x, y, attr;
-{
- int i, j, mask, rev, col[CHARHEIGHT];
- unsigned char *c;
-
- ch &= 0x7F;
- x *= CHARWIDTH;
- y *= CHARHEIGHT;
-
- rev = (attr & ATTR_REVERSE) ? 255 : 0;
-
- c = &Font6x10[ch * CHARHEIGHT];
-
- switch (videobitdepth) {
- case 1:
- for (j = 0; j < CHARWIDTH; j++) {
- mask = 1 << (CHARWIDTH - 1 - j);
- for (i = 0; i < CHARHEIGHT; i++)
- col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
- putpixel1(x + j, y, col, CHARHEIGHT);
- }
- if (attr & ATTR_UNDER) {
- col[0] = 255;
- for (j = 0; j < CHARWIDTH; j++)
- putpixel1(x + j, y + CHARHEIGHT - 1, col, 1);
- }
- break;
- case 2:
- case 4:
- case 8:
- case 16:
- case 32:
- for (j = 0; j < CHARWIDTH; j++) {
- mask = 1 << (CHARWIDTH - 1 - j);
- for (i = 0; i < CHARHEIGHT; i++)
- col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
- putpixel(x + j, y, col, CHARHEIGHT);
- }
- if (attr & ATTR_UNDER) {
- col[0] = 255;
- for (j = 0; j < CHARWIDTH; j++)
- putpixel(x + j, y + CHARHEIGHT - 1, col, 1);
- }
- break;
- }
-}
-
-static void
-drawcursor()
-{
- unsigned int j, X, Y;
-
- X = x * CHARWIDTH;
- Y = y * CHARHEIGHT;
-
- for (j = 0; j < CHARWIDTH; j++)
- reversepixel(X + j, Y, CHARHEIGHT);
-}
-
-static void
-erasecursor()
-{
- unsigned int j, X, Y;
-
- X = x * CHARWIDTH;
- Y = y * CHARHEIGHT;
-
- for (j = 0; j < CHARWIDTH; j++)
- reversepixel(X + j, Y, CHARHEIGHT);
-}
-
-static void
-scrollup()
-{
- unsigned char *from, *to;
- unsigned int linebytes;
- unsigned short i;
-
- linebytes = videorowbytes * CHARHEIGHT;
- to = (unsigned char *) videoaddr + (scrreg_top * linebytes);
- from = to + linebytes;
-
- for (i = (scrreg_bottom - scrreg_top) * CHARHEIGHT; i > 0; i--) {
- ovbcopy(from, to, screenrowbytes);
- from += videorowbytes;
- to += videorowbytes;
- }
- for (i = CHARHEIGHT; i > 0; i--) {
- bzero(to, screenrowbytes);
- to += videorowbytes;
- }
-}
-
-static void
-scrolldown()
-{
- unsigned char *from, *to;
- unsigned int linebytes;
- unsigned short i;
-
- linebytes = videorowbytes * CHARHEIGHT;
- to = (unsigned char *) videoaddr + ((scrreg_bottom + 1) * linebytes);
- from = to - linebytes;
-
- for (i = (scrreg_bottom - scrreg_top) * CHARHEIGHT; i > 0; i--) {
- from -= videorowbytes;
- to -= videorowbytes;
- ovbcopy(from, to, screenrowbytes);
- }
- for (i = CHARHEIGHT; i > 0; i--) {
- to -= videorowbytes;
- bzero(to, screenrowbytes);
- }
-}
-
-static void
-clear_screen(which)
- int which;
-{
- unsigned char *p;
- unsigned short len, i;
-
- p = (unsigned char *) videoaddr;
-
- switch (which) {
- case 0: /* To end of screen */
- if (x > 0) {
- clear_line(0);
- if (y < scrrows)
- y++;
- x = 0;
- }
- p += y * videorowbytes * CHARHEIGHT;
- len = scrrows - y;
- break;
- case 1: /* To start of screen */
- if (x > 0) {
- clear_line(1);
- if (y > 0)
- y--;
- x = 0;
- }
- len = y;
- break;
- case 2: /* Whole screen */
- default:
- len = scrrows;
- break;
- }
-
- for (i = len * CHARHEIGHT; i > 0; i--) {
- bzero(p, screenrowbytes);
- p += videorowbytes;
- }
-}
-
-static void
-clear_line(which)
- int which;
-{
- unsigned char *to;
- unsigned int linebytes;
- int start, end, i;
-
-
- /*
- * This routine runs extremely slowly. I don't think it's
- * used all that often, except for To end of line. I'll go
- * back and speed this up when I speed up the whole ite
- * module. --LK
- */
-
- switch (which) {
- default:
- case 0: /* To end of line */
- start = x;
- end = scrcols;
- break;
- case 1: /* To start of line */
- start = 0;
- end = x;
- break;
- case 2: /* Whole line */
- linebytes = videorowbytes * CHARHEIGHT;
- to = (unsigned char *) videoaddr + (y * linebytes);
-
- for (i = CHARHEIGHT; i > 0; i--) {
- bzero(to, screenrowbytes);
- to += videorowbytes;
- }
- return;
- }
-
- for (i = start; i < end; i++)
- writechar(' ', i, y, ATTR_NONE);
-}
-
-static void
-reset_tabs()
-{
- int i;
-
- for (i = 0; i<= scrcols; i++)
- tab_stops[i] = ((i % 8) == 0);
-}
-
-static void
-clear_tabs()
-{
- int i;
-
- for (i = 0; i <= scrcols; i++)
- tab_stops[i] = 0;
-}
-
-static void
-vt100_reset()
-{
- reset_tabs();
- scrreg_top = 0;
- scrreg_bottom = scrrows - 1;
- attr = ATTR_NONE;
-}
-
-static void
-putc_normal(ch)
- char ch;
-{
- switch (ch) {
- case '\a': /* Beep */
- mac68k_ring_bell(bell_freq, bell_length, bell_volume);
- break;
- case 127: /* Delete */
- case '\b': /* Backspace */
- if (hanging_cursor)
- hanging_cursor = 0;
- else if (x > 0)
- x--;
- break;
- case '\t': /* Tab */
- do
- ite_putchar(' ');
- while ((tab_stops[x] == 0) && (x < scrcols));
- break;
- case '\n': /* Line feed */
- if (y == scrreg_bottom)
- scrollup();
- else
- y++;
- break;
- case '\r': /* Carriage return */
- x = 0;
- hanging_cursor = 0;
- break;
- case '\e': /* Escape */
- vt100state = ESesc;
- hanging_cursor = 0;
- break;
- default:
- if (ch >= ' ') {
- if (hanging_cursor) {
- x = 0;
- if (y == scrreg_bottom)
- scrollup();
- else
- y++;
- hanging_cursor = 0;
- }
-
- writechar(ch, x, y, attr);
-
- if (x == scrcols - 1)
- hanging_cursor = 1;
- else
- x++;
- if (x >= scrcols) { /* can we ever get here? */
- x = 0;
- y++;
- }
- }
- break;
- }
-}
-
-static void
-putc_esc(ch)
- char ch;
-{
- vt100state = ESnormal;
-
- switch (ch) {
- case '[':
- vt100state = ESsquare;
- break;
- case '(':
- vt100state = ESsetG0;
- break;
- case ')':
- vt100state = ESsetG1;
- break;
- case 'E': /* Next line */
- x = 0;
- /* FALLTHROUGH */
- case 'D': /* Line feed */
- if (y == scrreg_bottom)
- scrollup();
- else
- y++;
- break;
- case 'H': /* Set tab stop */
- tab_stops[x] = 1;
- break;
- case 'M': /* Cursor up */
- if (y == scrreg_top)
- scrolldown();
- else
- y--;
- break;
- case '>':
- vt100_reset();
- break;
- case '7': /* Save cursor */
- savex = x;
- savey = y;
- break;
- case '8': /* Restore cursor */
- x = savex;
- y = savey;
- break;
- default:
- /* Rest not supported */
- break;
- }
-}
-
-static void
-putc_gotpars(ch)
- char ch;
-{
- int i;
-
- vt100state = ESnormal;
- switch (ch) {
- case 'A': /* Up */
- y -= par[0] ? par[0] : 1;
- break;
- case 'B': /* Down */
- y += par[0] ? par[0] : 1;
- break;
- case 'C': /* Right */
- x+= par[0] ? par[0] : 1;
- break;
- case 'D': /* Left */
- x-= par[0] ? par[0] : 1;
- break;
- case 'H': /* Set cursor position */
- case 'f': /* Set cursor position */
- x = par[1] - 1;
- y = par[0] - 1;
- hanging_cursor = 0;
- break;
- case 'J': /* Clear part of screen */
- clear_screen(par[0]);
- break;
- case 'K': /* Clear part of line */
- clear_line(par[0]);
- break;
- case 'L': /* Add line */
- if (scrreg_top < scrreg_bottom) {
- i = scrreg_top;
- scrreg_top = y;
- scrolldown();
- scrreg_top = i;
- } else
- clear_line(0);
- break;
- case 'M': /* Delete line */
- if (scrreg_top < scrreg_bottom) {
- i = scrreg_top;
- scrreg_top = y;
- scrollup();
- scrreg_top = i;
- } else
- clear_line(0);
- break;
- case 'g': /* Clear tab stops */
- if (numpars >= 1) {
- if (par[0] == 3)
- clear_tabs();
- else if (par[0] == 0)
- tab_stops[x] = 0;
- }
- break;
- case 'm': /* Set attribute */
- for (i = 0; i < numpars; i++) {
- switch (par[i]) {
- case 0:
- attr = ATTR_NONE;
- break;
- case 1:
- attr |= ATTR_BOLD;
- break;
- case 4:
- attr |= ATTR_UNDER;
- break;
- case 7:
- attr |= ATTR_REVERSE;
- break;
- case 21:
- attr &= ~ATTR_BOLD;
- break;
- case 24:
- attr &= ~ATTR_UNDER;
- break;
- case 27:
- attr &= ~ATTR_REVERSE;
- break;
- }
- }
- break;
- case 'r': /* Set scroll region */
- /* ensure top < bottom, and both within limits */
- if ((numpars > 0) && (par[0] < scrrows))
- scrreg_top = par[0] - 1;
- else
- scrreg_top = 0;
- if ((numpars > 1) && (par[1] <= scrrows) && (par[1] > par[0]))
- scrreg_bottom = par[1] - 1;
- else
- scrreg_bottom = scrrows - 1;
- break;
- }
-}
-
-static void
-putc_getpars(ch)
- char ch;
-{
- switch (ch) {
- case '?':
- /* Not supported */
- return;
- case '[':
- vt100state = ESnormal;
- /* Not supported */
- return;
- default:
- if (ch == ';' && numpars < MAXPARS - 1)
- numpars++;
- else if (ch >= '0' && ch <= '9') {
- par[numpars] *= 10;
- par[numpars] += ch - '0';
- } else {
- numpars++;
- vt100state = ESgotpars;
- putc_gotpars(ch);
- }
- }
-}
-
-static void
-putc_square(ch)
- char ch;
-{
- unsigned short i;
-
- for (i = 0; i < MAXPARS; i++)
- par[i] = 0;
-
- numpars = 0;
- vt100state = ESgetpars;
-
- putc_getpars(ch);
-}
-
-static void
-ite_putchar(ch)
- char ch;
-{
- switch (vt100state) {
- default:
- vt100state = ESnormal; /* FALLTHROUGH */
- case ESnormal:
- putc_normal(ch);
- break;
- case ESesc:
- putc_esc(ch);
- break;
- case ESsquare:
- putc_square(ch);
- break;
- case ESgetpars:
- putc_getpars(ch);
- break;
- case ESgotpars:
- putc_gotpars(ch);
- break;
- }
-
- if (x >= scrcols)
- x = scrcols - 1;
- if (x < 0)
- x = 0;
- if (y >= scrrows)
- y = scrrows - 1;
- if (y < 0)
- y = 0;
-}
-
-
-/*
- * Keyboard support functions
- */
-
-static int
-ite_pollforchar()
-{
- int s;
- register int intbits;
-
- s = splhigh();
-
- polledkey = -1;
- adb_polling = 1;
-
- /* pretend we're VIA interrupt dispatcher */
- while (polledkey == -1) {
- intbits = via_reg(VIA1, vIFR);
-
- if (intbits & V1IF_ADBRDY) {
- (void)mrg_adbintr();
- via_reg(VIA1, vIFR) = V1IF_ADBRDY;
- }
- if (intbits & 0x10) {
- (void)mrg_pmintr();
- via_reg(VIA1, vIFR) = 0x10;
- }
- }
-
- adb_polling = 0;
-
- splx(s);
-
- return polledkey;
-}
-
-
-/*
- * Autoconfig attachment
- */
-
-struct cfattach ite_ca = {
- sizeof(struct device), itematch, iteattach
-};
-
-struct cfdriver ite_cd = {
- NULL, "ite", DV_TTY
-};
-
-static int
-itematch(parent, vcf, aux)
- struct device *parent;
- void *vcf;
- void *aux;
-{
- struct grfbus_attach_args *ga = aux;
- struct grfmode *gm = ga->ga_grfmode;
- paddr_t pa;
-
- if (strcmp(ga->ga_name, "ite"))
- return 0;
- pmap_extract(pmap_kernel(), (vaddr_t) gm->fbbase + gm->fboff, &pa);
-
- return (pa == (vaddr_t) mac68k_vidphys);
-}
-
-static void
-iteattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- printf(" (minimal console)\n");
- (void) ite_init();
-}
-
-
-/*
- * Tty handling functions
- */
-
-int
-iteopen(dev, mode, devtype, p)
- dev_t dev;
- int mode;
- int devtype;
- struct proc *p;
-{
- register struct tty *tp;
- register int error;
-
- dprintf("iteopen(): enter(0x%x)\n", (int) dev);
-
- if (!ite_initted)
- return (ENXIO);
-
- if (ite_tty == NULL) {
- tp = ite_tty = ttymalloc();
- } else
- tp = ite_tty;
- if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE)
- && p->p_ucred->cr_uid != 0)
- return (EBUSY);
-
- tp->t_oproc = itestart;
- tp->t_param = NULL;
- tp->t_dev = dev;
- if ((tp->t_state & TS_ISOPEN) == 0) {
- ttychars(tp);
- tp->t_iflag = TTYDEF_IFLAG;
- tp->t_oflag = TTYDEF_OFLAG;
- tp->t_cflag = CS8 | CREAD;
- tp->t_lflag = TTYDEF_LFLAG;
- tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
- tp->t_state = TS_ISOPEN | TS_CARR_ON;
- ttsetwater(tp);
- }
-
- error = (*linesw[tp->t_line].l_open) (dev, tp);
- tp->t_winsize.ws_row = scrrows;
- tp->t_winsize.ws_col = scrcols;
-
- dprintf("iteopen(): exit(%d)\n", error);
- return (error);
-}
-
-int
-iteclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- dprintf("iteclose: enter (%d)\n", (int) dev);
-
- (*linesw[ite_tty->t_line].l_close) (ite_tty, flag);
- ttyclose(ite_tty);
-#if 0
- ttyfree(ite_tty);
- ite_tty = (struct tty *) 0;
-#endif
-
- dprintf("iteclose: exit\n");
- return 0;
-}
-
-int
-iteread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- dprintf("iteread: enter\n");
- return (*linesw[ite_tty->t_line].l_read) (ite_tty, uio, flag);
-}
-
-int
-itewrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- dprintf("itewrite: enter\n");
- return (*linesw[ite_tty->t_line].l_write) (ite_tty, uio, flag);
-}
-
-struct tty *
-itetty(dev)
- dev_t dev;
-{
- return (ite_tty);
-}
-
-int
-iteioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- int cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- register struct tty *tp = ite_tty;
- int error;
-
- dprintf("iteioctl: enter(%d, 0x%x)\n", cmd, cmd);
-
- error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, addr, flag, p);
- if (error >= 0) {
- dprintf("iteioctl: exit(%d)\n", error);
- return (error);
- }
-
- error = ttioctl(tp, cmd, addr, flag, p);
- if (error >= 0) {
- dprintf("iteioctl: exit(%d)\n", error);
- return (error);
- }
-
- switch (cmd) {
- case ITEIOC_RINGBELL:
- return mac68k_ring_bell(bell_freq, bell_length, bell_volume);
- case ITEIOC_SETBELL:
- {
- struct bellparams *bp = (void *) addr;
-
- /* Do some sanity checks. */
- if (bp->freq < 10 || bp->freq > 40000)
- return (EINVAL);
- if (bp->len < 0 || bp->len > 3600)
- return (EINVAL);
- if (bp->vol < 0 || bp->vol > 100)
- return (EINVAL);
-
- bell_freq = bp->freq;
- bell_length = bp->len;
- bell_volume = bp->vol;
- return (0);
- }
- case ITEIOC_GETBELL:
- {
- struct bellparams *bp = (void *) addr;
-
- bell_freq = bp->freq;
- bell_length = bp->len;
- bell_volume = bp->vol;
- return (0);
- }
- }
-
- dprintf("iteioctl: exit(ENOTTY)\n");
- return (ENOTTY);
-}
-
-void
-itestart(tp)
- register struct tty *tp;
-{
- register int cc, s;
-
- s = spltty();
- if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) {
- splx(s);
- return;
- }
- tp->t_state |= TS_BUSY;
-
- cc = tp->t_outq.c_cc;
- splx(s);
- erasecursor();
- while (cc-- > 0)
- ite_putchar(getc(&tp->t_outq));
- drawcursor();
-
- s = spltty();
- tp->t_state &= ~TS_BUSY;
- splx(s);
-}
-
-void
-itestop(tp, flag)
- struct tty *tp;
- int flag;
-{
- int s;
-
- s = spltty();
- if (tp->t_state & TS_BUSY)
- if ((tp->t_state & TS_TTSTOP) == 0)
- tp->t_state |= TS_FLUSH;
- splx(s);
-}
-
-int
-ite_intr(event)
- adb_event_t *event;
-{
- static int shift = 0, control = 0, capslock = 0;
- int key, press, val, state;
- char str[10], *s;
-
- key = event->u.k.key;
- press = ADBK_PRESS(key);
- val = ADBK_KEYVAL(key);
-
- if (val == ADBK_SHIFT)
- shift = press;
- else if (val == ADBK_CAPSLOCK)
- capslock = !capslock;
- else if (val == ADBK_CONTROL)
- control = press;
- else if (press) {
- switch (val) {
- case ADBK_UP:
- str[0] = '\e';
- str[1] = 'O';
- str[2] = 'A';
- str[3] = '\0';
- break;
- case ADBK_DOWN:
- str[0] = '\e';
- str[1] = 'O';
- str[2] = 'B';
- str[3] = '\0';
- break;
- case ADBK_RIGHT:
- str[0] = '\e';
- str[1] = 'O';
- str[2] = 'C';
- str[3] = '\0';
- break;
- case ADBK_LEFT:
- str[0] = '\e';
- str[1] = 'O';
- str[2] = 'D';
- str[3] = '\0';
- break;
- default:
- state = 0;
- if (capslock && isealpha(keyboard[val][1]))
- state = 1;
- if (shift)
- state = 1;
- if (control)
- state = 2;
- str[0] = keyboard[val][state];
- str[1] = '\0';
- break;
- }
- if (adb_polling)
- polledkey = str[0];
- else
- for (s = str; *s; s++)
- (*linesw[ite_tty->t_line].l_rint)(*s, ite_tty);
- }
- return 0;
-}
-/*
- * Console functions
- */
-
-int
-itecnprobe(cp)
- struct consdev *cp;
-{
- int maj, unit;
-
- /* locate the major number */
- for (maj = 0; maj < nchrdev; maj++)
- if (cdevsw[maj].d_open == iteopen)
- break;
-
- if (maj == nchrdev)
- panic("itecnprobe(): did not find iteopen().");
-
- unit = 0; /* hardcode first device as console. */
-
- /* initialize required fields */
- cp->cn_dev = makedev(maj, unit);
- cp->cn_pri = CN_INTERNAL;
-
- return 0;
-}
-
-int
-itecninit(cp)
- struct consdev *cp;
-{
- return ite_init();
-}
-
-void
-itereset()
-{
- width = videosize & 0xffff;
- height = (videosize >> 16) & 0xffff;
- scrrows = height / CHARHEIGHT;
- scrcols = width / CHARWIDTH;
-
- switch (videobitdepth) {
- default:
- case 1:
- putpixel = putpixel1;
- reversepixel = reversepixel1;
- screenrowbytes = (width + 7) >> 3;
- break;
- case 2:
- putpixel = putpixel2;
- reversepixel = reversepixel1;
- screenrowbytes = (width + 3) >> 2;
- break;
- case 4:
- putpixel = putpixel4;
- reversepixel = reversepixel1;
- screenrowbytes = (width + 1) >> 1;
- break;
- case 8:
- putpixel = putpixel8;
- reversepixel = reversepixel1;
- screenrowbytes = width;
- break;
- case 16:
- putpixel = putpixel16;
- reversepixel = reversepixel1;
- screenrowbytes = width*2;
- break;
- case 32:
- putpixel = putpixel32;
- reversepixel = reversepixel1;
- screenrowbytes = width*4;
- break;
- }
-
- vt100_reset();
-}
-
-int
-ite_init()
-{
- if (ite_initted)
- return 0;
-
- ite_initted = 1;
- itereset();
- return iteon((dev_t) 0, 0);
-}
-
-int
-iteon(dev, flags)
- dev_t dev;
- int flags;
-{
- erasecursor();
- clear_screen(2);
- drawcursor();
- return 0;
-}
-
-int
-iteoff(dev, flags)
- dev_t dev;
- int flags;
-{
- erasecursor();
- clear_screen(2);
- return 0;
-}
-
-int
-itecngetc(dev)
- dev_t dev;
-{
- /* Oh, man... */
-
- return ite_pollforchar();
-}
-
-void
-itecnputc(dev, c)
- dev_t dev;
- int c;
-{
- extern dev_t mac68k_zsdev;
- extern int zscnputc(dev_t dev, int c);
-
- erasecursor();
- ite_putchar(c);
- drawcursor();
- if (mac68k_machine.serial_boot_echo)
- zscnputc(mac68k_zsdev, c);
-}
diff --git a/sys/arch/mac68k/dev/macfb.c b/sys/arch/mac68k/dev/macfb.c
new file mode 100644
index 00000000000..ea17513ae71
--- /dev/null
+++ b/sys/arch/mac68k/dev/macfb.c
@@ -0,0 +1,359 @@
+/* $OpenBSD: macfb.c,v 1.1 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: macfb.c,v 1.11 2005/01/15 16:00:59 chs Exp $ */
+/*
+ * Copyright (c) 1998 Matt DeBergalis
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Matt DeBergalis
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <machine/cpu.h>
+#include <machine/bus.h>
+
+#include <mac68k/dev/nubus.h>
+#include <mac68k/dev/grfvar.h>
+#include <mac68k/dev/macfbvar.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <dev/wscons/wsconsio.h>
+
+#include <dev/rcons/raster.h>
+#include <dev/wscons/wscons_raster.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+int macfb_match(struct device *, void *, void *);
+void macfb_attach(struct device *, struct device *, void *);
+
+struct cfattach macfb_ca = {
+ sizeof(struct macfb_softc), macfb_match, macfb_attach
+};
+
+struct cfdriver macfb_cd = {
+ NULL, "macfb", DV_DULL
+};
+
+const struct wsdisplay_emulops macfb_emulops = {
+ rcons_cursor,
+ rcons_mapchar,
+ rcons_putchar,
+ rcons_copycols,
+ rcons_erasecols,
+ rcons_copyrows,
+ rcons_eraserows,
+ rcons_alloc_attr
+};
+
+struct wsscreen_descr macfb_stdscreen = {
+ "std",
+ 0, 0, /* will be filled in -- XXX shouldn't, it's global */
+ &macfb_emulops,
+ 0, 0,
+ WSSCREEN_REVERSE
+};
+
+const struct wsscreen_descr *_macfb_scrlist[] = {
+ &macfb_stdscreen,
+};
+
+const struct wsscreen_list macfb_screenlist = {
+ sizeof(_macfb_scrlist) / sizeof(struct wsscreen_descr *),
+ _macfb_scrlist
+};
+
+int macfb_ioctl(void *, u_long, caddr_t, int, struct proc *);
+paddr_t macfb_mmap(void *, off_t, int);
+int macfb_alloc_screen(void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *);
+void macfb_free_screen(void *, void *);
+int macfb_show_screen(void *, void *, int,
+ void (*)(void *, int, int), void *);
+
+const struct wsdisplay_accessops macfb_accessops = {
+ macfb_ioctl,
+ macfb_mmap,
+ macfb_alloc_screen,
+ macfb_free_screen,
+ macfb_show_screen,
+ NULL, /* load_font */
+ NULL, /* scrollback */
+ NULL, /* getchar */
+ NULL /* burner */
+};
+
+void macfb_init(struct macfb_devconfig *);
+
+paddr_t macfb_consaddr;
+static int macfb_is_console(paddr_t);
+
+static struct macfb_devconfig macfb_console_dc;
+
+/* From Booter via locore */
+extern long videoaddr;
+extern long videorowbytes;
+extern long videobitdepth;
+extern u_long videosize;
+extern u_int32_t mac68k_vidlog;
+extern u_int32_t mac68k_vidphys;
+extern u_int32_t mac68k_vidlen;
+
+static int
+macfb_is_console(paddr_t addr)
+{
+ if (addr != macfb_consaddr &&
+ (addr >= 0xf9000000 && addr <= 0xfeffffff)) {
+ /*
+ * This is in the NuBus standard slot space range, so we
+ * may well have to look at 0xFssxxxxx, too. Mask off the
+ * slot number and duplicate it in bits 20-23, per IM:V
+ * pp 459, 463, and IM:VI ch 30 p 17.
+ * Note: this is an ugly hack and I wish I knew what
+ * to do about it. -- sr
+ */
+ addr = (paddr_t)(((u_long)addr & 0xff0fffff) |
+ (((u_long)addr & 0x0f000000) >> 4));
+ }
+ return ((mac68k_machine.serial_console & 0x03) == 0
+ && (addr == macfb_consaddr));
+}
+
+void
+macfb_clear(struct macfb_devconfig *dc)
+{
+ int i, rows;
+
+ /* clear the display */
+ rows = dc->dc_ht;
+ for (i = 0; rows-- > 0; i += dc->dc_rowbytes)
+ memset((u_char *)dc->dc_vaddr + dc->dc_offset + i,
+ 0, dc->dc_rowbytes);
+}
+
+void
+macfb_init(struct macfb_devconfig *dc)
+{
+ struct raster *rap;
+ struct rcons *rcp;
+
+ macfb_clear(dc);
+
+ rap = &dc->dc_raster;
+ rap->width = dc->dc_wid;
+ rap->height = dc->dc_ht;
+ rap->depth = dc->dc_depth;
+ rap->linelongs = dc->dc_rowbytes / sizeof(u_int32_t);
+ rap->pixels = (u_int32_t *)(dc->dc_vaddr + dc->dc_offset);
+
+ /* initialize the raster console blitter */
+ rcp = &dc->dc_rcons;
+ rcp->rc_sp = rap;
+ rcp->rc_crow = rcp->rc_ccol = -1;
+ rcp->rc_crowp = &rcp->rc_crow;
+ rcp->rc_ccolp = &rcp->rc_ccol;
+ rcons_init(rcp, 128, 192);
+
+ macfb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
+ macfb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
+}
+
+int
+macfb_match(struct device *parent, void *match, void *aux)
+{
+ return (1);
+}
+
+void
+macfb_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct grfbus_attach_args *ga = aux;
+ struct grfmode *gm = ga->ga_grfmode;
+ struct macfb_softc *sc;
+ struct wsemuldisplaydev_attach_args waa;
+ int isconsole;
+
+ sc = (struct macfb_softc *)self;
+
+#ifdef DIAGNOSTIC /* temporary */
+ printf(" offset %p", gm->fboff);
+#endif
+ printf("\n");
+
+ isconsole = macfb_is_console(ga->ga_phys + ga->ga_grfmode->fboff);
+
+ if (isconsole) {
+ sc->sc_dc = &macfb_console_dc;
+ sc->nscreens = 1;
+ } else {
+ sc->sc_dc = malloc(sizeof(struct macfb_devconfig), M_DEVBUF, M_WAITOK);
+ sc->sc_dc->dc_vaddr = (vaddr_t)gm->fbbase;
+ sc->sc_dc->dc_paddr = ga->ga_phys;
+ sc->sc_dc->dc_size = gm->fbsize;
+
+ sc->sc_dc->dc_wid = gm->width;
+ sc->sc_dc->dc_ht = gm->height;
+ sc->sc_dc->dc_depth = gm->psize;
+ sc->sc_dc->dc_rowbytes = gm->rowbytes;
+
+ sc->sc_dc->dc_offset = gm->fboff;
+
+ macfb_init(sc->sc_dc);
+
+ sc->nscreens = 0;
+ }
+
+ waa.console = isconsole;
+ waa.scrdata = &macfb_screenlist;
+ waa.accessops = &macfb_accessops;
+ waa.accesscookie = sc;
+
+ config_found(self, &waa, wsemuldisplaydevprint);
+}
+
+
+int
+macfb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ struct macfb_softc *sc = v;
+ struct macfb_devconfig *dc = sc->sc_dc;
+ struct wsdisplay_fbinfo *wdf;
+
+ switch (cmd) {
+ case WSDISPLAYIO_GTYPE:
+ *(int *)data = 0; /* XXX */
+ break;
+
+ case WSDISPLAYIO_GINFO:
+ wdf = (struct wsdisplay_fbinfo *)data;
+ wdf->height = dc->dc_raster.height;
+ wdf->width = dc->dc_raster.width;
+ wdf->depth = dc->dc_raster.depth;
+ wdf->cmsize = 0; /* until we can change it... */
+ break;
+
+ case WSDISPLAYIO_LINEBYTES:
+ *(u_int *)data = dc->dc_rowbytes;
+ break;
+
+ case WSDISPLAYIO_GVIDEO:
+ case WSDISPLAYIO_SVIDEO:
+ break;
+ default:
+ return (-1);
+ }
+
+ return (0);
+}
+
+paddr_t
+macfb_mmap(void *v, off_t offset, int prot)
+{
+ struct macfb_softc *sc = v;
+ struct macfb_devconfig *dc = sc->sc_dc;
+ paddr_t addr;
+
+ if (offset >= 0 &&
+ offset < round_page(dc->dc_size))
+ addr = atop(dc->dc_paddr + dc->dc_offset + offset);
+ else
+ addr = (-1);
+
+ return addr;
+}
+
+int
+macfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
+ int *curxp, int *curyp, long *defattrp)
+{
+ struct macfb_softc *sc = v;
+ long defattr;
+
+ if (sc->nscreens > 0)
+ return (ENOMEM);
+
+ *cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
+ *curxp = 0;
+ *curyp = 0;
+ rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr);
+ *defattrp = defattr;
+ sc->nscreens++;
+ return (0);
+}
+
+void
+macfb_free_screen(void *v, void *cookie)
+{
+ struct macfb_softc *sc = v;
+
+#ifdef DIAGNOSTIC
+ if (sc->sc_dc == &macfb_console_dc)
+ panic("cfb_free_screen: console");
+#endif
+
+ sc->nscreens--;
+}
+
+int
+macfb_show_screen(void *v, void *cookie, int waitok,
+ void (*cb)(void *, int, int), void *cbarg)
+{
+ return 0;
+}
+
+int
+macfb_cnattach(paddr_t addr)
+{
+ struct macfb_devconfig *dc = &macfb_console_dc;
+ long defattr;
+
+ dc->dc_vaddr = trunc_page(videoaddr);
+ dc->dc_paddr = trunc_page(mac68k_vidphys);
+
+ dc->dc_wid = videosize & 0xffff;
+ dc->dc_ht = (videosize >> 16) & 0xffff;
+ dc->dc_depth = videobitdepth;
+ dc->dc_rowbytes = videorowbytes;
+
+ dc->dc_size = (mac68k_vidlen > 0) ?
+ mac68k_vidlen : dc->dc_ht * dc->dc_rowbytes;
+ dc->dc_offset = m68k_page_offset(mac68k_vidphys);
+
+ /* set up the display */
+ macfb_init(&macfb_console_dc);
+
+ rcons_alloc_attr(&dc->dc_rcons, 0, 0, 0, &defattr);
+
+ wsdisplay_cnattach(&macfb_stdscreen, &dc->dc_rcons,
+ 0, 0, defattr);
+
+ macfb_consaddr = addr;
+ return (0);
+}
diff --git a/sys/arch/mac68k/dev/itevar.h b/sys/arch/mac68k/dev/macfbvar.h
index 36f62bcb2f2..3dd0765a853 100644
--- a/sys/arch/mac68k/dev/itevar.h
+++ b/sys/arch/mac68k/dev/macfbvar.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: itevar.h,v 1.4 2002/06/11 05:13:37 miod Exp $ */
-/* $NetBSD: itevar.h,v 1.1 1996/05/05 06:16:49 briggs Exp $ */
-
+/* $OpenBSD: macfbvar.h,v 1.1 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: macfbvar.h,v 1.3 2005/01/15 16:00:59 chs Exp $ */
/*
- * Copyright (c) 1995 Allen Briggs. All rights reserved.
+ * Copyright (c) 1998 Matt DeBergalis
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -14,9 +14,9 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by Allen Briggs.
+ * This product includes software developed by Matt DeBergalis
* 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -30,27 +30,33 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/adbsys.h>
-
-int ite_intr(adb_event_t *event);
-int iteon(dev_t dev, int flags);
-int iteoff(dev_t dev, int flags);
-void itereset(void);
-
-#ifndef CN_DEAD
-#include <dev/cons.h>
-#endif
-
-void itestop(struct tty * tp, int flag);
-void itestart(register struct tty * tp);
-int iteopen(dev_t dev, int mode, int devtype, struct proc * p);
-int iteclose(dev_t dev, int flag, int mode, struct proc * p);
-int iteread(dev_t dev, struct uio * uio, int flag);
-int itewrite(dev_t dev, struct uio * uio, int flag);
-int iteioctl(dev_t, int, caddr_t, int, struct proc *);
-struct tty *itetty(dev_t dev);
-
-int itecnprobe(struct consdev * cp);
-int itecninit(struct consdev * cp);
-int itecngetc(dev_t dev);
-void itecnputc(dev_t dev, int c);
+#include <dev/rcons/raster.h>
+#include <dev/wscons/wscons_raster.h>
+
+#include <machine/bus.h>
+
+struct macfb_devconfig {
+ vaddr_t dc_vaddr; /* memory space virtual base address */
+ paddr_t dc_paddr; /* memory space physical base address */
+ psize_t dc_size; /* size of slot memory */
+
+ int dc_offset; /* offset from dc_vaddr to base of flat fb */
+
+ int dc_wid; /* width of frame buffer */
+ int dc_ht; /* height of frame buffer */
+ int dc_depth; /* depth of frame buffer */
+ int dc_rowbytes; /* bytes in fb scan line */
+
+ struct raster dc_raster; /* raster description */
+ struct rcons dc_rcons; /* raster blitter control info */
+};
+
+struct macfb_softc {
+ struct device sc_dev;
+
+ int nscreens;
+ struct macfb_devconfig *sc_dc;
+};
+
+int macfb_cnattach(paddr_t);
+void macfb_clear(struct macfb_devconfig *);
diff --git a/sys/arch/mac68k/dev/pm_direct.c b/sys/arch/mac68k/dev/pm_direct.c
index 49158ade649..d35df8189b4 100644
--- a/sys/arch/mac68k/dev/pm_direct.c
+++ b/sys/arch/mac68k/dev/pm_direct.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: pm_direct.c,v 1.8 2005/02/11 20:09:30 martin Exp $ */
-/* $NetBSD: pm_direct.c,v 1.4 1998/02/23 03:11:26 scottr Exp $ */
+/* $OpenBSD: pm_direct.c,v 1.9 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: pm_direct.c,v 1.25 2005/10/28 21:54:52 christos Exp $ */
/*
* Copyright (C) 1997 Takashi Hamada
@@ -15,7 +15,7 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by Takashi HAMADA
+ * This product includes software developed by Takashi Hamada
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -30,29 +30,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* From: pm_direct.c 1.3 03/18/98 Takashi Hamada */
+#ifdef DEBUG
+#ifndef ADB_DEBUG
+#define ADB_DEBUG
+#endif
+#endif
-/* #define PM_DEBUG 1 */
/* #define PM_GRAB_SI 1 */
-#include <sys/types.h>
-#include <sys/cdefs.h>
+#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/time.h>
-#include <machine/adbsys.h>
#include <machine/cpu.h>
-#include <machine/param.h>
#include <machine/viareg.h>
-#include <arch/mac68k/mac68k/macrom.h>
-#include <arch/mac68k/dev/adbvar.h>
-
-#include "pm_direct.h"
+#include <mac68k/dev/adbvar.h>
+#include <mac68k/dev/pm_direct.h>
/* hardware dependent values */
extern u_short ADBDelay;
extern u_int32_t HwCfgFlags3;
+extern struct mac68k_machine_S mac68k_machine;
+
/* define the types of the Power Manager */
#define PM_HW_UNKNOWN 0x00 /* don't know */
@@ -66,10 +67,10 @@ extern u_int32_t HwCfgFlags3;
#define PM_VIA_CLR_INTR() via_reg(VIA1, vIFR) = 0x90
#define PM_SET_STATE_ACKON() via_reg(VIA2, vBufB) |= 0x04
#define PM_SET_STATE_ACKOFF() via_reg(VIA2, vBufB) &= ~0x04
-#define PM_IS_ON ( 0x02 == (via_reg(VIA2, vBufB) & 0x02) )
-#define PM_IS_OFF ( 0x00 == (via_reg(VIA2, vBufB) & 0x02) )
+#define PM_IS_ON (0x02 == (via_reg(VIA2, vBufB) & 0x02))
+#define PM_IS_OFF (0x00 == (via_reg(VIA2, vBufB) & 0x02))
-/*
+/*
* Variables for internal use
*/
int pmHardware = PM_HW_UNKNOWN;
@@ -80,42 +81,74 @@ u_int pm_counter = 0; /* clock count */
/* these values shows that number of data returned after 'send' cmd is sent */
char pm_send_cmd_type[] = {
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x01,0x01,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x00,
- 0xff,0x00,0x02,0x01,0x01,0xff,0xff,0xff, 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x04,0x14,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x02,0xff,0xff,0xff,0xff,0xff,
- 0x01,0x01,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x01,0x00,0x02,0x02,0xff,0x01,0x03,0x01, 0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,
- 0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
- 0x01,0x01,0x01,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0x04,0x04,
- 0x04,0xff,0x00,0xff,0xff,0xff,0xff,0xff, 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x01,0x02,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x02,0x02,0x02,0x04,0xff,0x00,0xff,0xff, 0x01,0x01,0x03,0x02,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x01,0x01,0xff,0xff,0x00,0x00,0xff,0xff,
- 0xff,0x04,0x00,0xff,0xff,0xff,0xff,0xff, 0x03,0xff,0x00,0xff,0x00,0xff,0xff,0x00,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0xff, 0x00, 0x02, 0x01, 0x01, 0xff, 0xff, 0xff,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x04, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x00, 0x02, 0x02, 0xff, 0x01, 0x03, 0x01,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x04,
+ 0x04, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x02, 0x02, 0x02, 0x04, 0xff, 0x00, 0xff, 0xff,
+ 0x01, 0x01, 0x03, 0x02, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x01, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
/* these values shows that number of data returned after 'receive' cmd is sent */
char pm_receive_cmd_type[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x05,0x15,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x03,0x03,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0x04,0x03,0x09,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0x02,0xff,0xff,0xff,
- 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0x02,0xff,0xff,0xff,0xff,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x04, 0x03, 0x09, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
@@ -124,75 +157,78 @@ char pm_receive_cmd_type[] = {
*/
/* for debugging */
-#ifdef PM_DEBUG
-void pm_printerr( char *, int, int, char * );
+#ifdef ADB_DEBUG
+void pm_printerr(const char *, int, int, char *);
#endif
-int pm_wait_busy(int);
-int pm_wait_free(int);
+int pm_wait_busy(int);
+int pm_wait_free(int);
/* these functions are for the PB1XX series */
-int pm_receive_pm1(u_char *);
-int pm_send_pm1(u_char,int);
-int pm_pmgrop_pm1(PMData *);
-void pm_intr_pm1(void);
+int pm_receive_pm1(u_char *);
+int pm_send_pm1(u_char, int);
+int pm_pmgrop_pm1(PMData *);
+int pm_intr_pm1(void *);
/* these functions are for the PB Duo series and the PB 5XX series */
-int pm_receive_pm2(u_char *);
-int pm_send_pm2(u_char);
-int pm_pmgrop_pm2(PMData *);
-void pm_intr_pm2(void);
+int pm_receive_pm2(u_char *);
+int pm_send_pm2(u_char);
+int pm_pmgrop_pm2(PMData *);
+int pm_intr_pm2(void *);
/* this function is MRG-Based (for testing) */
-int pm_pmgrop_mrg(PMData *);
+int pm_pmgrop_mrg(PMData *);
/* these functions are called from adb_direct.c */
-void pm_setup_adb(void);
-void pm_check_adb_devices(int);
-void pm_intr(void);
-int pm_adb_op(u_char *, void *, void *, int);
+void pm_setup_adb(void);
+void pm_check_adb_devices(int);
+void pm_intr(void *);
+int pm_adb_op(u_char *, void *, void *, int);
+void pm_hw_setup(void);
-/* these functions also use the valiables of adb_direct.c */
-void pm_adb_get_TALK_result(PMData *);
-void pm_adb_get_ADB_data(PMData *);
-void pm_adb_poll_next_device_pm1(PMData *);
+/* these functions also use the variables of adb_direct.c */
+void pm_adb_get_TALK_result(PMData *);
+void pm_adb_get_ADB_data(PMData *);
+void pm_adb_poll_next_device_pm1(PMData *);
/*
- * These valiables are in adb_direct.c.
+ * These variables are in adb_direct.c.
*/
extern u_char *adbBuffer; /* pointer to user data area */
-#define MAX_ADB_MSG_LENGTH 20
-extern u_char adbInputBuffer[MAX_ADB_MSG_LENGTH]; /* data input buffer */
extern void *adbCompRout; /* pointer to the completion routine */
extern void *adbCompData; /* pointer to the completion routine data */
extern int adbWaiting; /* waiting for return data from the device */
extern int adbWaitingCmd; /* ADB command we are waiting for */
extern int adbStarting; /* doing ADB reinit, so do "polling" differently */
-/*
- * Define the external functions
- */
-extern void adb_comp_exec(void); /* from adb_direct.c */
-
+#define ADB_MAX_MSG_LENGTH 16
+#define ADB_MAX_HDR_LENGTH 8
+struct adbCommand {
+ u_char header[ADB_MAX_HDR_LENGTH]; /* not used yet */
+ u_char data[ADB_MAX_MSG_LENGTH]; /* packet data only */
+ u_char *saveBuf; /* where to save result */
+ u_char *compRout; /* completion routine pointer */
+ u_char *compData; /* completion routine data pointer */
+ u_int cmd; /* the original command for this data */
+ u_int unsol; /* 1 if packet was unsolicited */
+ u_int ack_only; /* 1 for no special processing */
+};
+extern void adb_pass_up(struct adbCommand *);
-#ifdef PM_DEBUG
+#ifdef ADB_DEBUG
/*
* This function dumps contents of the PMData
*/
void
-pm_printerr(ttl, rval, num, data)
- char *ttl;
- int rval;
- int num;
- char *data;
+pm_printerr(const char *ttl, int rval, int num, char *data)
{
int i;
- printf( "pm: %s:%04x %02x ", ttl, rval, num );
- for( i=0; i<num; i++ )
- printf( "%02x ", data[i] );
- printf( "\n" );
+ printf("pm: %s:%04x %02x ", ttl, rval, num);
+ for (i = 0; i < num; i++)
+ printf("%02x ", data[i]);
+ printf("\n");
}
#endif
@@ -207,7 +243,6 @@ pm_setup_adb(void)
switch (mac68k_machine.machineid) {
case MACH_MACPB140:
case MACH_MACPB145:
- case MACH_MACPB150:
case MACH_MACPB160:
case MACH_MACPB165:
case MACH_MACPB165C:
@@ -216,6 +251,7 @@ pm_setup_adb(void)
case MACH_MACPB180C:
pmHardware = PM_HW_PB1XX;
break;
+ case MACH_MACPB150:
case MACH_MACPB210:
case MACH_MACPB230:
case MACH_MACPB250:
@@ -223,6 +259,8 @@ pm_setup_adb(void)
case MACH_MACPB280:
case MACH_MACPB280C:
case MACH_MACPB500:
+ case MACH_MACPB190:
+ case MACH_MACPB190CS:
pmHardware = PM_HW_PB5XX;
break;
default:
@@ -235,8 +273,7 @@ pm_setup_adb(void)
* Check the existent ADB devices
*/
void
-pm_check_adb_devices(id)
- int id;
+pm_check_adb_devices(int id)
{
u_short ed = 0x1;
@@ -249,17 +286,16 @@ pm_check_adb_devices(id)
* Wait until PM IC is busy
*/
int
-pm_wait_busy(delay)
- int delay;
+pm_wait_busy(int xdelay)
{
- while(PM_IS_ON) {
+ while (PM_IS_ON) {
#ifdef PM_GRAB_SI
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
#endif
- if ((--delay) < 0)
- return( 1 ); /* timeout */
+ if ((--xdelay) < 0)
+ return 1; /* timeout */
}
- return( 0 );
+ return 0;
}
@@ -267,17 +303,16 @@ pm_wait_busy(delay)
* Wait until PM IC is free
*/
int
-pm_wait_free(delay)
- int delay;
+pm_wait_free(int xdelay)
{
- while(PM_IS_OFF) {
+ while (PM_IS_OFF) {
#ifdef PM_GRAB_SI
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
#endif
- if ((--delay) < 0)
- return( 0 ); /* timeout */
+ if ((--xdelay) < 0)
+ return 0; /* timeout */
}
- return( 1 );
+ return 1;
}
@@ -290,23 +325,22 @@ pm_wait_free(delay)
* Receive data from PM for the PB1XX series
*/
int
-pm_receive_pm1(data)
- u_char *data;
+pm_receive_pm1(u_char *data)
{
int rval = 0xffffcd34;
via_reg(VIA2, vDirA) = 0x00;
- switch( 1 ) {
+ switch (1) {
default:
- if (pm_wait_busy( 0x40 ) != 0)
+ if (pm_wait_busy(0x40) != 0)
break; /* timeout */
PM_SET_STATE_ACKOFF();
*data = via_reg(VIA2, 0x200);
rval = 0xffffcd33;
- if (pm_wait_free( 0x40 ) == 0)
+ if (pm_wait_free(0x40) == 0)
break; /* timeout */
rval = 0x00;
@@ -316,7 +350,7 @@ pm_receive_pm1(data)
PM_SET_STATE_ACKON();
via_reg(VIA2, vDirA) = 0x00;
- return( rval );
+ return rval;
}
@@ -325,32 +359,32 @@ pm_receive_pm1(data)
* Send data to PM for the PB1XX series
*/
int
-pm_send_pm1(data, delay)
- u_char data;
- int delay;
+pm_send_pm1(u_char data, int timo)
{
- int rval;
+ int rval;
via_reg(VIA2, vDirA) = 0xff;
via_reg(VIA2, 0x200) = data;
PM_SET_STATE_ACKOFF();
- if (pm_wait_busy( 0x400 ) != 0) {
+#if 0
+ if (pm_wait_busy(0x400) == 0) {
+#else
+ if (pm_wait_busy(timo) == 0) {
+#endif
PM_SET_STATE_ACKON();
- via_reg(VIA2, vDirA) = 0x00;
-
- return( 0xffffcd36 );
+ if (pm_wait_free(0x40) != 0)
+ rval = 0x0;
+ else
+ rval = 0xffffcd35;
+ } else {
+ rval = 0xffffcd36;
}
- rval = 0x0;
- PM_SET_STATE_ACKON();
- if (pm_wait_free( 0x40 ) == 0)
- rval = 0xffffcd35;
-
PM_SET_STATE_ACKON();
via_reg(VIA2, vDirA) = 0x00;
- return( rval );
+ return rval;
}
@@ -358,17 +392,16 @@ pm_send_pm1(data, delay)
* My PMgrOp routine for the PB1XX series
*/
int
-pm_pmgrop_pm1(pmdata)
- PMData *pmdata;
+pm_pmgrop_pm1(PMData *pmdata)
{
- int i;
- int s = 0x81815963;
- u_char via1_vIER, via1_vDirA;
- int rval = 0;
- int num_pm_data = 0;
- u_char pm_cmd;
- u_char pm_data;
- u_char *pm_buf;
+ int i;
+ int s = 0x81815963;
+ u_char via1_vIER, via1_vDirA;
+ int rval = 0;
+ int num_pm_data = 0;
+ u_char pm_cmd;
+ u_char pm_data;
+ u_char *pm_buf;
/* disable all inetrrupts but PM */
via1_vIER = via_reg(VIA1, vIER);
@@ -376,50 +409,51 @@ pm_pmgrop_pm1(pmdata)
via1_vDirA = via_reg(VIA1, vDirA);
- switch( pmdata->command ) {
+ switch (pmdata->command) {
default:
- for( i=0; i<7; i++ ) {
+ for (i = 0; i < 7; i++) {
via_reg(VIA2, vDirA) = 0x00;
/* wait until PM is free */
- if (pm_wait_free( ADBDelay ) == 0) { /* timeout */
+ if (pm_wait_free(ADBDelay) == 0) { /* timeout */
via_reg(VIA2, vDirA) = 0x00;
/* restore formar value */
via_reg(VIA1, vDirA) = via1_vDirA;
via_reg(VIA1, vIER) = via1_vIER;
- return( 0xffffcd38 );
+ return 0xffffcd38;
}
- switch( mac68k_machine.machineid ) {
+ switch (mac68k_machine.machineid) {
case MACH_MACPB160:
case MACH_MACPB165:
case MACH_MACPB165C:
+ case MACH_MACPB170:
case MACH_MACPB180:
case MACH_MACPB180C:
{
- int delay = ADBDelay * 16;
+ int xdelay = ADBDelay * 16;
via_reg(VIA2, vDirA) = 0x00;
- while((via_reg(VIA2, 0x200) == 0x7f) && (delay >= 0))
- delay--;
+ while ((via_reg(VIA2, 0x200) == 0x7f) && (xdelay >= 0))
+ xdelay--;
- if (delay < 0) { /* timeout */
+ if (xdelay < 0) { /* timeout */
via_reg(VIA2, vDirA) = 0x00;
/* restore formar value */
via_reg(VIA1, vIER) = via1_vIER;
- return( 0xffffcd38 );
+ return 0xffffcd38;
}
}
} /* end switch */
- s=splhigh();
+ s = splhigh();
via1_vDirA = via_reg(VIA1, vDirA);
via_reg(VIA1, vDirA) &= 0x7f;
pm_cmd = (u_char)(pmdata->command & 0xff);
- if ((rval = pm_send_pm1( pm_cmd, ADBDelay*8 )) == 0) /* succeeded to send PM command */
- break;
+ if ((rval = pm_send_pm1(pm_cmd, ADBDelay * 8)) == 0)
+ break; /* send command succeeded */
via_reg(VIA1, vDirA) = via1_vDirA;
splx(s);
@@ -431,50 +465,51 @@ pm_pmgrop_pm1(pmdata)
/* restore formar value */
via_reg(VIA1, vDirA) = via1_vDirA;
via_reg(VIA1, vIER) = via1_vIER;
- return( 0xffffcd38 );
+ if (s != 0x81815963)
+ splx(s);
+ return 0xffffcd38;
}
/* send # of PM data */
num_pm_data = pmdata->num_data;
- if ((rval = pm_send_pm1( (u_char)(num_pm_data & 0xff), ADBDelay*8 )) != 0)
+ if ((rval = pm_send_pm1((u_char)(num_pm_data & 0xff), ADBDelay * 8)) != 0)
break; /* timeout */
/* send PM data */
pm_buf = (u_char *)pmdata->s_buf;
- for( i=0; i<num_pm_data; i++ )
- if((rval = pm_send_pm1( pm_buf[i], ADBDelay*8 )) != 0)
- break; /* timeout */
+ for (i = 0; i < num_pm_data; i++)
+ if ((rval = pm_send_pm1(pm_buf[i], ADBDelay * 8)) != 0)
+ break; /* timeout */
if ((i != num_pm_data) && (num_pm_data != 0))
- break; /* timeout */
+ break; /* timeout */
/* Will PM IC return data? */
if ((pm_cmd & 0x08) == 0) {
rval = 0;
- break; /* no returned data */
+ break; /* no returned data */
}
rval = 0xffffcd37;
- if (pm_wait_busy( ADBDelay ) != 0) {
+ if (pm_wait_busy(ADBDelay) != 0)
break; /* timeout */
- }
/* receive PM command */
- if ((rval = pm_receive_pm1( &pm_data )) != 0)
+ if ((rval = pm_receive_pm1(&pm_data)) != 0)
break;
pmdata->command = pm_data;
/* receive number of PM data */
- if ((rval = pm_receive_pm1( &pm_data )) != 0)
- break; /* timeout */
+ if ((rval = pm_receive_pm1(&pm_data)) != 0)
+ break; /* timeout */
num_pm_data = pm_data;
pmdata->num_data = num_pm_data;
/* receive PM data */
pm_buf = (u_char *)pmdata->r_buf;
- for( i=0; i<num_pm_data; i++ ) {
- if ((rval = pm_receive_pm1( &pm_data )) != 0)
- break; /* timeout */
+ for (i = 0; i < num_pm_data; i++) {
+ if ((rval = pm_receive_pm1(&pm_data)) != 0)
+ break; /* timeout */
pm_buf[i] = pm_data;
}
@@ -489,19 +524,19 @@ pm_pmgrop_pm1(pmdata)
if (s != 0x81815963)
splx(s);
- return( rval );
+ return rval;
}
/*
- * My PM interrupt routine for PB100-series
+ * My PM interrupt routine for PB1XX series
*/
-void
-pm_intr_pm1(void)
+int
+pm_intr_pm1(void *arg)
{
- int s;
- int rval;
- PMData pmdata;
+ int s;
+ int rval;
+ PMData pmdata;
s = splhigh();
@@ -513,30 +548,37 @@ pm_intr_pm1(void)
pmdata.data[0] = pmdata.data[1] = 0;
pmdata.s_buf = &pmdata.data[2];
pmdata.r_buf = &pmdata.data[2];
- rval = pm_pmgrop_pm1( &pmdata );
+ rval = pm_pmgrop_pm1(&pmdata);
if (rval != 0) {
-#ifdef PM_DEBUG
- printf( "pm: PM is not ready. error code=%08x\n", rval );
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("pm: PM is not ready. error code=%08x\n", rval);
#endif
splx(s);
- return;
}
if ((pmdata.data[2] & 0x10) == 0x10) {
- if ((pmdata.data[2] & 0x0f) == 0) { /* ADB data that were requested by TALK command */
+ if ((pmdata.data[2] & 0x0f) == 0) {
+ /* ADB data that were requested by TALK command */
pm_adb_get_TALK_result(&pmdata);
- } else if ((pmdata.data[2] & 0x08) == 0x8) { /* PM is requesting to poll */
+ } else if ((pmdata.data[2] & 0x08) == 0x8) {
+ /* PM is requesting to poll */
pm_adb_poll_next_device_pm1(&pmdata);
- } else if ((pmdata.data[2] & 0x04) == 0x4) { /* ADB device event */
+ } else if ((pmdata.data[2] & 0x04) == 0x4) {
+ /* ADB device event */
pm_adb_get_ADB_data(&pmdata);
}
} else {
-#ifdef PM_DEBUG
- pm_printerr( "driver does not supported this event.", rval, pmdata.num_data, pmdata.data );
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ pm_printerr("driver does not supported this event.",
+ rval, pmdata.num_data, pmdata.data);
#endif
}
splx(s);
+
+ return (1);
}
@@ -549,15 +591,14 @@ pm_intr_pm1(void)
* Receive data from PM for the PB Duo series and the PB 5XX series
*/
int
-pm_receive_pm2(data)
- u_char *data;
+pm_receive_pm2(u_char *data)
{
- int i;
- int rval;
+ int i;
+ int rval;
rval = 0xffffcd34;
- switch( 1 ) {
+ switch (1) {
default:
/* set VIA SR to input mode */
via_reg(VIA1, vACR) |= 0x0c;
@@ -582,7 +623,7 @@ pm_receive_pm2(data)
PM_SET_STATE_ACKON();
via_reg(VIA1, vACR) |= 0x1c;
- return( rval );
+ return rval;
}
@@ -591,33 +632,28 @@ pm_receive_pm2(data)
* Send data to PM for the PB Duo series and the PB 5XX series
*/
int
-pm_send_pm2(data)
- u_char data;
+pm_send_pm2(u_char data)
{
- int rval;
+ int rval;
via_reg(VIA1, vACR) |= 0x1c;
PM_SR() = data;
PM_SET_STATE_ACKOFF();
- rval = 0xffffcd36;
- if (pm_wait_busy((int)ADBDelay*32) != 0) {
+ if (pm_wait_busy((int)ADBDelay*32) == 0) {
PM_SET_STATE_ACKON();
-
- via_reg(VIA1, vACR) |= 0x1c;
-
- return( rval );
+ if (pm_wait_free((int)ADBDelay*32) != 0)
+ rval = 0;
+ else
+ rval = 0xffffcd35;
+ } else {
+ rval = 0xffffcd36;
}
PM_SET_STATE_ACKON();
- rval = 0xffffcd35;
- if (pm_wait_free((int)ADBDelay*32) != 0)
- rval = 0;
-
- PM_SET_STATE_ACKON();
via_reg(VIA1, vACR) |= 0x1c;
- return( rval );
+ return rval;
}
@@ -626,20 +662,19 @@ pm_send_pm2(data)
* My PMgrOp routine for the PB Duo series and the PB 5XX series
*/
int
-pm_pmgrop_pm2(pmdata)
- PMData *pmdata;
+pm_pmgrop_pm2(PMData *pmdata)
{
- int i;
- int s;
- u_char via1_vIER;
- int rval = 0;
- int num_pm_data = 0;
- u_char pm_cmd;
- short pm_num_rx_data;
- u_char pm_data;
- u_char *pm_buf;
-
- s=splhigh();
+ int i;
+ int s;
+ u_char via1_vIER;
+ int rval = 0;
+ int num_pm_data = 0;
+ u_char pm_cmd;
+ short pm_num_rx_data;
+ u_char pm_data;
+ u_char *pm_buf;
+
+ s = splhigh();
/* disable all inetrrupts but PM */
via1_vIER = 0x10;
@@ -648,47 +683,49 @@ pm_pmgrop_pm2(pmdata)
if (via1_vIER != 0x0)
via1_vIER |= 0x80;
- switch( pmdata->command ) {
+ switch (pmdata->command) {
default:
/* wait until PM is free */
pm_cmd = (u_char)(pmdata->command & 0xff);
rval = 0xcd38;
- if (pm_wait_free( ADBDelay * 4 ) == 0)
+ if (pm_wait_free(ADBDelay * 4) == 0)
break; /* timeout */
- if (HwCfgFlags3 & 0x00200000) { /* PB 160, PB 165(c), PB 180(c) ? */
- int delay = ADBDelay * 16;
+ if (HwCfgFlags3 & 0x00200000) {
+ /* PB 160, PB 165(c), PB 180(c)? */
+ int xdelay = ADBDelay * 16;
via_reg(VIA2, vDirA) = 0x00;
- while((via_reg(VIA2, 0x200) == 0x07) && (delay >= 0))
- delay--;
+ while ((via_reg(VIA2, 0x200) == 0x07) &&
+ (xdelay >= 0))
+ xdelay--;
- if (delay < 0) {
+ if (xdelay < 0) {
rval = 0xffffcd38;
break; /* timeout */
}
}
/* send PM command */
- if ((rval = pm_send_pm2( (u_char)(pm_cmd & 0xff) )))
+ if ((rval = pm_send_pm2((u_char)(pm_cmd & 0xff))))
break; /* timeout */
/* send number of PM data */
num_pm_data = pmdata->num_data;
if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */
if (pm_send_cmd_type[pm_cmd] < 0) {
- if ((rval = pm_send_pm2( (u_char)(num_pm_data & 0xff) )) != 0)
+ if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0)
break; /* timeout */
pmdata->command = 0;
}
} else { /* PB 1XX series ? */
- if ((rval = pm_send_pm2( (u_char)(num_pm_data & 0xff) )) != 0)
+ if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0)
break; /* timeout */
}
/* send PM data */
pm_buf = (u_char *)pmdata->s_buf;
- for( i=0; i<num_pm_data; i++ )
- if((rval = pm_send_pm2( pm_buf[i] )) != 0)
+ for (i = 0 ; i < num_pm_data; i++)
+ if ((rval = pm_send_pm2(pm_buf[i])) != 0)
break; /* timeout */
if (i != num_pm_data)
break; /* timeout */
@@ -707,13 +744,13 @@ pm_pmgrop_pm2(pmdata)
if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */
pm_num_rx_data--;
if (pm_num_rx_data == 0)
- if ((rval = pm_receive_pm2( &pm_data )) != 0) {
+ if ((rval = pm_receive_pm2(&pm_data)) != 0) {
rval = 0xffffcd37;
break;
}
pmdata->command = pm_data;
} else { /* PB 1XX series ? */
- if ((rval = pm_receive_pm2( &pm_data )) != 0) {
+ if ((rval = pm_receive_pm2(&pm_data)) != 0) {
rval = 0xffffcd37;
break;
}
@@ -723,14 +760,14 @@ pm_pmgrop_pm2(pmdata)
/* receive number of PM data */
if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */
if (pm_num_rx_data < 0) {
- if ((rval = pm_receive_pm2( &pm_data )) != 0)
+ if ((rval = pm_receive_pm2(&pm_data)) != 0)
break; /* timeout */
num_pm_data = pm_data;
} else
num_pm_data = pm_num_rx_data;
pmdata->num_data = num_pm_data;
} else { /* PB 1XX serias ? */
- if ((rval = pm_receive_pm2( &pm_data )) != 0)
+ if ((rval = pm_receive_pm2(&pm_data)) != 0)
break; /* timeout */
num_pm_data = pm_data;
pmdata->num_data = num_pm_data;
@@ -738,8 +775,8 @@ pm_pmgrop_pm2(pmdata)
/* receive PM data */
pm_buf = (u_char *)pmdata->r_buf;
- for( i=0; i<num_pm_data; i++ ) {
- if ((rval = pm_receive_pm2( &pm_data )) != 0)
+ for (i = 0; i < num_pm_data; i++) {
+ if ((rval = pm_receive_pm2(&pm_data)) != 0)
break; /* timeout */
pm_buf[i] = pm_data;
}
@@ -751,61 +788,56 @@ pm_pmgrop_pm2(pmdata)
via_reg(VIA1, vIER) = via1_vIER;
splx(s);
- return( rval );
+ return rval;
}
/*
* My PM interrupt routine for the PB Duo series and the PB 5XX series
*/
-void
-pm_intr_pm2(void)
+int
+pm_intr_pm2(void *arg)
{
- int s;
- int rval;
- PMData pmdata;
+ int s;
+ int rval;
+ PMData pmdata;
s = splhigh();
- PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */
- /* ask PM what happend */
+ PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */
+ /* ask PM what happend */
pmdata.command = 0x78;
pmdata.num_data = 0;
pmdata.s_buf = &pmdata.data[2];
pmdata.r_buf = &pmdata.data[2];
- rval = pm_pmgrop_pm2( &pmdata );
+ rval = pm_pmgrop_pm2(&pmdata);
if (rval != 0) {
-#ifdef PM_DEBUG
- printf( "pm: PM is not ready. error code: %08x\n", rval );
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ printf("pm: PM is not ready. error code: %08x\n", rval);
#endif
splx(s);
- return;
}
- switch( (u_int)(pmdata.data[2] & 0xff) ) {
- case 0x00: /* 1 sec interrupt? */
- {
+ switch ((u_int)(pmdata.data[2] & 0xff)) {
+ case 0x00: /* 1 sec interrupt? */
break;
- }
- case 0x80: /* 1 sec interrupt? */
- {
+ case 0x80: /* 1 sec interrupt? */
pm_counter++;
break;
- }
- case 0x08: /* Brightness/Contrast button on LCD panel */
- {
+ case 0x08: /* Brightness/Contrast button on LCD panel */
/* get brightness and contrast of the LCD */
pm_LCD_brightness = (u_int)pmdata.data[3] & 0xff;
pm_LCD_contrast = (u_int)pmdata.data[4] & 0xff;
/*
- pm_printerr( "#08", rval, pmdata.num_data, pmdata.data );
+ pm_printerr("#08", rval, pmdata.num_data, pmdata.data);
pmdata.command = 0x33;
pmdata.num_data = 1;
pmdata.s_buf = pmdata.data;
pmdata.r_buf = pmdata.data;
pmdata.data[0] = pm_LCD_contrast;
- rval = pm_pmgrop_pm2( &pmdata );
- pm_printerr( "#33", rval, pmdata.num_data, pmdata.data );
+ rval = pm_pmgrop_pm2(&pmdata);
+ pm_printerr("#33", rval, pmdata.num_data, pmdata.data);
*/
/* this is an experimental code */
pmdata.command = 0x41;
@@ -813,33 +845,35 @@ pm_intr_pm2(void)
pmdata.s_buf = pmdata.data;
pmdata.r_buf = pmdata.data;
pm_LCD_brightness = 0x7f - pm_LCD_brightness / 2;
- if (pm_LCD_brightness < 0x25) pm_LCD_brightness = 0x25;
- if (pm_LCD_brightness > 0x5a) pm_LCD_brightness = 0x7f;
+ if (pm_LCD_brightness < 0x25)
+ pm_LCD_brightness = 0x25;
+ if (pm_LCD_brightness > 0x5a)
+ pm_LCD_brightness = 0x7f;
pmdata.data[0] = pm_LCD_brightness;
- rval = pm_pmgrop_pm2( &pmdata );
+ rval = pm_pmgrop_pm2(&pmdata);
break;
- }
- /* ADB data that were requested by TALK command */
- case 0x10:
+ case 0x10: /* ADB data that were requested by TALK command */
case 0x14:
pm_adb_get_TALK_result(&pmdata);
break;
- /* ADB device event */
- case 0x16:
+ case 0x16: /* ADB device event */
case 0x18:
case 0x1e:
pm_adb_get_ADB_data(&pmdata);
break;
default:
- {
-#ifdef PM_DEBUG
- pm_printerr( "driver does not supported this event.", pmdata.data[2], pmdata.num_data, pmdata.data );
+#ifdef ADB_DEBUG
+ if (adb_debug)
+ pm_printerr("driver does not supported this event.",
+ pmdata.data[2], pmdata.num_data,
+ pmdata.data);
#endif
- }
break;
}
splx(s);
+
+ return (1);
}
@@ -847,18 +881,17 @@ pm_intr_pm2(void)
* MRG-based PMgrOp routine
*/
int
-pm_pmgrop_mrg(pmdata)
- PMData *pmdata;
+pm_pmgrop_mrg(PMData *pmdata)
{
u_int32_t rval=0;
- asm("
- movl %1, a0
- .word 0xa085
- movl d0, %0"
+ __asm __volatile(
+ " movl %1,a0 \n"
+ " .word 0xa085 \n"
+ " movl d0,%0"
: "=g" (rval)
: "g" (pmdata)
- : "a0", "d0" );
+ : "a0","d0");
return rval;
}
@@ -868,23 +901,18 @@ pm_pmgrop_mrg(pmdata)
* My PMgrOp routine
*/
int
-pmgrop(pmdata)
- PMData *pmdata;
+pmgrop(PMData *pmdata)
{
- switch( pmHardware ) {
+ switch (pmHardware) {
case PM_HW_PB1XX:
- {
- return( pm_pmgrop_pm1(pmdata) );
+ return (pm_pmgrop_pm1(pmdata));
break;
- }
case PM_HW_PB5XX:
- {
- return( pm_pmgrop_pm2(pmdata) );
+ return (pm_pmgrop_pm2(pmdata));
break;
- }
default:
-/* return( pmgrop_mrg(pmdata) ); */
- return( -1 );
+ /* return (pmgrop_mrg(pmdata)); */
+ return 1;
}
}
@@ -893,44 +921,54 @@ pmgrop(pmdata)
* My PM interrupt routine
*/
void
-pm_intr(void)
+pm_intr(void *arg)
{
- switch( pmHardware ) {
+ switch (pmHardware) {
case PM_HW_PB1XX:
- {
- pm_intr_pm1();
+ pm_intr_pm1(arg);
break;
- }
case PM_HW_PB5XX:
- {
- pm_intr_pm2();
+ pm_intr_pm2(arg);
break;
- }
default:
break;
}
}
+void
+pm_hw_setup(void)
+{
+ switch (pmHardware) {
+ case PM_HW_PB1XX:
+ via1_register_irq(4, pm_intr_pm1, NULL, NULL);
+ PM_VIA_CLR_INTR();
+ break;
+ case PM_HW_PB5XX:
+ via1_register_irq(4, pm_intr_pm2, NULL, NULL);
+ PM_VIA_CLR_INTR();
+ break;
+ default:
+ break;
+ }
+}
+
/*
* Synchronous ADBOp routine for the Power Manager
*/
int
-pm_adb_op(buffer, compRout, data, command)
- u_char *buffer;
- void *compRout;
- void *data;
- int command;
+pm_adb_op(u_char *buffer, void *compRout, void *data, int command)
{
- int i,len;
- int s;
- int rval;
- int delay;
- PMData pmdata;
+ int i;
+ int s;
+ int rval;
+ int xdelay;
+ PMData pmdata;
+ struct adbCommand packet;
if (adbWaiting == 1)
- return( -1 );
+ return 1;
s = splhigh();
via_reg(VIA1, vIER) = 0x10;
@@ -955,46 +993,72 @@ pm_adb_op(buffer, compRout, data, command)
if ((command & 0xc) == 0x8) { /* if the command is LISTEN, copy ADB data to PM buffer */
if ((buffer != (u_char *)0) && (buffer[0] <= 24)) {
pmdata.data[2] = buffer[0]; /* number of data */
- for( i=0; i<buffer[0]; i++ )
+ for (i = 0; i < buffer[0]; i++)
pmdata.data[3 + i] = buffer[1 + i];
} else
pmdata.data[2] = 0;
} else
pmdata.data[2] = 0;
- rval = pmgrop( &pmdata );
- if (rval != 0)
- return( -1 );
+ if ((command & 0xc) != 0xc) { /* if the command is not TALK */
+ /* set up stuff fNULLor adb_pass_up */
+ packet.data[0] = 1 + pmdata.data[2];
+ packet.data[1] = command;
+ for (i = 0; i < pmdata.data[2]; i++)
+ packet.data[i+2] = pmdata.data[i+3];
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.cmd = command;
+ packet.unsol = 0;
+ packet.ack_only = 1;
+ adb_polling = 1;
+ adb_pass_up(&packet);
+ adb_polling = 0;
+ }
- if (adbWaiting == 0) {
- adbWaiting = 1;
- adbWaitingCmd = command;
+ rval = pmgrop(&pmdata);
+ if (rval != 0) {
+ splx(s);
+ return 1;
}
+ adbWaiting = 1;
+ adbWaitingCmd = command;
+
PM_VIA_INTR_ENABLE();
- /* wait until the PM interrupt is occurred */
- delay = 0x80000;
- while(adbWaiting == 1) {
- if ((via_reg(VIA1, vIFR) & 0x10) == 0x10)
- pm_intr();
+ /* wait until the PM interrupt has occurred */
+ xdelay = 0x80000;
+ while (adbWaiting == 1) {
+ switch (mac68k_machine.machineid) {
+ case MACH_MACPB150:
+ case MACH_MACPB210:
+ case MACH_MACPB230: /* daishi tested with Duo230 */
+ case MACH_MACPB250:
+ case MACH_MACPB270:
+ case MACH_MACPB280:
+ case MACH_MACPB280C:
+ case MACH_MACPB190:
+ case MACH_MACPB190CS:
+ pm_intr((void *)0);
+ break;
+ default:
+ if ((via_reg(VIA1, vIFR) & 0x10) == 0x10)
+ pm_intr((void *)0);
+ break;
+ }
#ifdef PM_GRAB_SI
- (void)intr_dispatch(0x70);
+ (void)intr_dispatch(0x70); /* grab any serial interrupts */
#endif
- if ((--delay) < 0)
- return( -1 );
- }
-
- if (buffer != (u_char *)0) {
- len = adbInputBuffer[3];
- for (i=0; i<=len; i++)
- buffer[i] = adbInputBuffer[3 + i];
- if (len < 0)
- buffer[0] = 0;
+ if ((--xdelay) < 0) {
+ splx(s);
+ return 1;
+ }
}
- /* this command enables the interrupt by operating ADB devices */
- if (HwCfgFlags3 & 0x00020000) { /* PB Duo series, PB 500 series */
+ /* this command enables the interrupt by operating ADB devices */
+ if (HwCfgFlags3 & 0x00020000) { /* PB Duo series, PB 5XX series */
pmdata.command = 0x20;
pmdata.num_data = 4;
pmdata.s_buf = pmdata.data;
@@ -1003,7 +1067,7 @@ pm_adb_op(buffer, compRout, data, command)
pmdata.data[1] = 0x86; /* magic spell for awaking the PM */
pmdata.data[2] = 0x00;
pmdata.data[3] = 0x0c; /* each bit may express the existent ADB device */
- } else { /* PB 100-series */
+ } else { /* PB 1XX series */
pmdata.command = 0x20;
pmdata.num_data = 3;
pmdata.s_buf = pmdata.data;
@@ -1012,64 +1076,60 @@ pm_adb_op(buffer, compRout, data, command)
pmdata.data[1] = 0x04;
pmdata.data[2] = 0x00;
}
- rval = pmgrop( &pmdata );
+ rval = pmgrop(&pmdata);
splx(s);
- return( rval );
+ return rval;
}
void
-pm_adb_get_TALK_result(pmdata)
- PMData *pmdata;
+pm_adb_get_TALK_result(PMData *pmdata)
{
int i;
- int rx_pm_adb_cmd;
-
- rx_pm_adb_cmd = (u_int)pmdata->data[3] & 0xff;
-
- pmdata->data[2] &= 0xf;
- pmdata->data[1] = pmdata->data[3];
- pmdata->data[3] = pmdata->num_data - 2;
-
- adbInputBuffer[0] = pmdata->num_data + 1;
- for( i=1; i<pmdata->num_data+2; i++ )
- adbInputBuffer[i] = pmdata->data[i];
-
- if ((adbWaiting == 1) && (rx_pm_adb_cmd == adbWaitingCmd)) {
- if (adbStarting == 0)
- adb_complete( &pmdata->data[3] , (long)0, adbWaitingCmd );
- adbWaitingCmd = 0x0;
-
- adbWaiting = 0;
- adb_comp_exec();
- adbBuffer = (long)0;
- adbCompRout = (long)0;
- adbCompData = (long)0;
- }
+ struct adbCommand packet;
+
+ /* set up data for adb_pass_up */
+ packet.data[0] = pmdata->num_data-1;
+ packet.data[1] = pmdata->data[3];
+ for (i = 0; i <packet.data[0]-1; i++)
+ packet.data[i+2] = pmdata->data[i+4];
+
+ packet.saveBuf = adbBuffer;
+ packet.compRout = adbCompRout;
+ packet.compData = adbCompData;
+ packet.unsol = 0;
+ packet.ack_only = 0;
+ adb_polling = 1;
+ adb_pass_up(&packet);
+ adb_polling = 0;
+
+ adbWaiting = 0;
+ adbBuffer = (long)0;
+ adbCompRout = (long)0;
+ adbCompData = (long)0;
}
void
-pm_adb_get_ADB_data(pmdata)
- PMData *pmdata;
+pm_adb_get_ADB_data(PMData *pmdata)
{
int i;
-
- i = (u_int)pmdata->data[3] & 0xff;
- pmdata->data[2] &= 0xf;
- pmdata->data[1] = pmdata->data[3];
- pmdata->data[3] = pmdata->num_data - 2;
-
- adbInputBuffer[0] = pmdata->num_data + 1;
- if (adbStarting == 0)
- adb_complete( &pmdata->data[3] , (long)0, i );
+ struct adbCommand packet;
+
+ /* set up data for adb_pass_up */
+ packet.data[0] = pmdata->num_data-1; /* number of raw data */
+ packet.data[1] = pmdata->data[3]; /* ADB command */
+ for (i = 0; i <packet.data[0]-1; i++)
+ packet.data[i+2] = pmdata->data[i+4];
+ packet.unsol = 1;
+ packet.ack_only = 0;
+ adb_pass_up(&packet);
}
void
-pm_adb_poll_next_device_pm1(pmdata)
- PMData *pmdata;
+pm_adb_poll_next_device_pm1(PMData *pmdata)
{
int i;
int ndid;
@@ -1078,8 +1138,8 @@ pm_adb_poll_next_device_pm1(pmdata)
PMData tmp_pmdata;
/* find another existent ADB device to poll */
- for( i=1; i<16; i++ ) {
- ndid = (((pmdata->data[3] & 0xf0) >> 4) + i) & 0xf;
+ for (i = 1; i < 16; i++) {
+ ndid = (ADB_CMDADDR(pmdata->data[3]) + i) & 0xf;
bendid <<= ndid;
if ((pm_existent_ADB_devices & bendid) != 0)
break;
@@ -1093,7 +1153,5 @@ pm_adb_poll_next_device_pm1(pmdata)
tmp_pmdata.data[0] = (u_char)(ndid << 4) | 0xc;
tmp_pmdata.data[1] = 0x04; /* magic spell for awaking the PM */
tmp_pmdata.data[2] = 0x00;
- rval = pmgrop( &tmp_pmdata );
+ rval = pmgrop(&tmp_pmdata);
}
-
-
diff --git a/sys/arch/mac68k/dev/pm_direct.h b/sys/arch/mac68k/dev/pm_direct.h
index ec2b001e0f6..e19cc085182 100644
--- a/sys/arch/mac68k/dev/pm_direct.h
+++ b/sys/arch/mac68k/dev/pm_direct.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pm_direct.h,v 1.4 2005/02/11 20:09:30 martin Exp $ */
+/* $OpenBSD: pm_direct.h,v 1.5 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: pm_direct.h,v 1.1 1997/04/08 03:11:38 scottr Exp $ */
/*
@@ -30,6 +30,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* From: pm_direct.h 1.0 01/02/97 Takashi Hamada */
/*
* Public declarations that other routines may need.
@@ -45,10 +46,3 @@ typedef struct {
} PMData;
int pmgrop(PMData *);
-
-extern void pm_setup_adb(void);
-extern void pm_check_adb_devices(int);
-extern void pm_intr(void);
-extern int pm_adb_op(u_char *, void *, void *, int);
-extern void pm_init_adb_device(void);
-
diff --git a/sys/arch/mac68k/include/adbsys.h b/sys/arch/mac68k/include/adbsys.h
index cae638527fc..8b7b71f4ab9 100644
--- a/sys/arch/mac68k/include/adbsys.h
+++ b/sys/arch/mac68k/include/adbsys.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: adbsys.h,v 1.8 2005/08/07 14:43:53 martin Exp $ */
-/* $NetBSD: adbsys.h,v 1.5 1996/05/05 14:34:07 briggs Exp $ */
+/* $OpenBSD: adbsys.h,v 1.9 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: adbsys.h,v 1.13 2000/02/14 07:01:48 scottr Exp $ */
/*-
* Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo,
@@ -34,23 +34,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _MAC68K_ADBSYS_H_
-#define _MAC68K_ADBSYS_H_
-
-#include <sys/time.h>
-#include <sys/ioctl.h>
-
-/* Handy visual constants */
-#define ADB_MAX_HANDLERS 256
-#define ADB_MAX_DEVS 16
-
-/* Different ADB system types */
-enum adb_system_e {
- MacIIADB,
- MacIIsiADB,
- MacPBADB};
-extern enum adb_system_e adb_system_type;
-
+#ifndef _ADBSYS_MACHINE_
+#define _ADBSYS_MACHINE_
/* an ADB event */
typedef struct adb_event_s {
@@ -72,18 +57,13 @@ typedef struct adb_event_s {
} u; /* courtesy interpretation */
} adb_event_t;
-/* Descriptor of a device on the ADB bus */
-typedef struct adb_dev_s {
- int addr; /* current address */
- int default_addr; /* startup address */
- int handler_id; /* handler ID */
-} adb_dev_t;
-
-/* Interesting default addresses */
-#define ADBADDR_SECURE 1 /* Security dongles */
+ /* Interesting default addresses */
+#define ADBADDR_SECURE 1 /* Security dongles */
#define ADBADDR_MAP 2 /* Mapped devices (keyboards/pads) */
-#define ADBADDR_REL 3 /* Relative positioning devices */
-#define ADBADDR_ABS 4 /* Absolute positioning devices */
+#define ADBADDR_REL 3 /* Relative positioning devices
+ (mice, trackballs/pads) */
+#define ADBADDR_ABS 4 /* Absolute positioning devices
+ (graphics tablets) */
#define ADBADDR_DATATX 5
#define ADBADDR_RSRVD 6 /* Reserved by Apple */
#define ADBADDR_MISC 7 /* Miscellaneous appliances */
@@ -93,7 +73,8 @@ typedef struct adb_dev_s {
#define ADBADDR_TABLET ADBADDR_ABS
#define ADBADDR_MODEM ADBADDR_DATATX
-/* Interesting keyboard handler IDs */
+
+ /* Interesting keyboard handler IDs */
#define ADB_STDKBD 1
#define ADB_EXTKBD 2
#define ADB_ISOKBD 4
@@ -112,49 +93,24 @@ typedef struct adb_dev_s {
#define ADB_PBEXTKBD 24
#define ADB_DESIGNKBD 27 /* XXX Needs to be verified XXX */
#define ADB_PBJPKBD 30
+#define ADB_PBG4KBD 195
+#define ADB_IBITISOKBD 196
+#define ADB_PBG3JPKBD 201
-/* Interesting mouse handler IDs */
+ /* Interesting mouse handler IDs */
#define ADBMS_100DPI 1
#define ADBMS_200DPI 2
#define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */
#define ADBMS_EXTENDED 4 /* Extended mouse protocol */
-#define ADBMS_USPEED 47 /* MicroSpeed mouse */
-#define ADBMS_UCONTOUR 102 /* Contour mouse */
+#define ADBMS_USPEED 0x2f /* MicroSpeed mouse */
+#define ADBMS_UCONTOUR 0x66 /* Contour mouse */
+#define ADBMS_TURBO 50 /* Kensington Turbo Mouse */
-/* Interesting tablet handler ID */
+ /* Interesting tablet handler ID */
#define ADB_ARTPAD 58 /* WACOM ArtPad II tablet */
-/* Interesting miscellaneous handler ID */
+ /* Interesting miscellaneous handler ID */
#define ADB_POWERKEY 34 /* Sophisticated Circuits PowerKey */
+ /* (intelligent power tap) */
-/* Get device info from ADB system */
-typedef struct adb_devinfo_s {
- adb_dev_t dev[ADB_MAX_DEVS];
- /* [addr].addr == -1 if none */
-} adb_devinfo_t;
-#define ADBIOC_DEVSINFO _IOR('A', 128, adb_devinfo_t)
-
-
-/* Event auto-repeat */
-typedef struct adb_rptinfo_s {
- int delay_ticks; /* ticks before repeat */
- int interval_ticks; /* ticks between repeats */
-} adb_rptinfo_t;
-#define ADBIOC_GETREPEAT _IOR('A', 130, adb_rptinfo_t)
-#define ADBIOC_SETREPEAT _IOW('A', 131, adb_rptinfo_t)
-
-
-/* Reset and reinitialize */
-#define ADBIOC_RESET _IO('A', 132)
-
-typedef struct adb_listencmd_s {
- int address; /* device address */
- int reg; /* register to which to send bytes */
- int bytecnt; /* number of bytes */
- u_char bytes[8]; /* bytes */
-} adb_listencmd_t;
-#define ADBIOC_LISTENCMD _IOW('A', 133, adb_listencmd_t)
-
-void adb_init(void);
-
-#endif /* _MAC68K_ADBSYS_H_ */
+#endif /* _ADBSYS_MACHINE_ */
diff --git a/sys/arch/mac68k/include/grfioctl.h b/sys/arch/mac68k/include/grfioctl.h
deleted file mode 100644
index bbc3ae5a740..00000000000
--- a/sys/arch/mac68k/include/grfioctl.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* $OpenBSD: grfioctl.h,v 1.6 2005/08/06 19:51:44 martin Exp $ */
-/* $NetBSD: grfioctl.h,v 1.5 1995/07/02 05:26:45 briggs Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * from: Utah $Hdr: grfioctl.h 1.1 90/07/09$
- *
- * @(#)grfioctl.h 7.2 (Berkeley) 11/4/90
- */
-
-#ifndef _MAC68K_GRFIOCTL_H_
-#define _MAC68K_GRFIOCTL_H_
-
-struct grfmode {
- u_int8_t mode_id; /* Identifier for mode */
- caddr_t fbbase; /* Base of page of frame buffer */
- u_int32_t fbsize; /* Size of frame buffer */
- u_int16_t fboff; /* Offset of frame buffer from base */
- u_int16_t rowbytes; /* Screen rowbytes */
- u_int16_t width; /* Screen width */
- u_int16_t height; /* Screen height */
- u_int16_t hres; /* Horizontal resolution (dpi) */
- u_int16_t vres; /* Vertical resolution (dpi) */
- u_int16_t ptype; /* 0 = indexed, 0x10 = direct */
- u_int16_t psize; /* Screen depth */
- char pad[32]; /* Space for expansion */
-};
-
-struct grfmodes {
- int nmodes; /* Number of modes in modelist */
- struct grfmode *modelist; /* Pointer to space for modes */
-};
-
-/*
- * BSD ioctls (first few match HP-UX ioctl()s. In case we want
- * compatibility later, start our own at 16).
- */
-#define GRFIOCON _IO('G', 1) /* turn graphics on */
-#define GRFIOCOFF _IO('G', 2) /* turn graphics off */
-#define GRFIOCLISTMODES _IOWR('G', 16, struct grfmodes) /* Get list of modes */
-#define GRFIOCGETMODE _IOR('G', 17, int) /* Get list of modes */
-#define GRFIOCSETMODE _IOW('G', 18, int) /* Set to mode_id mode */
-#define GRFIOCGMODE _IOR('G', 19, struct grfmode) /* Get list of modes */
-
-#endif /* _MAC68K_GRFIOCTL_H_ */
diff --git a/sys/arch/mac68k/include/iteioctl.h b/sys/arch/mac68k/include/iteioctl.h
deleted file mode 100644
index a9f974ef5b4..00000000000
--- a/sys/arch/mac68k/include/iteioctl.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $OpenBSD: iteioctl.h,v 1.5 1997/11/30 06:12:28 gene Exp $ */
-/* $NetBSD: iteioctl.h,v 1.1 1994/12/03 23:34:31 briggs Exp $ */
-
-/*-
- * Copyright (C) 1994 Allen K. Briggs, Chris P. Caputo,
- * Michael L. Finch, Bradley A. Grantham, and
- * Lawrence A. Kesteloot
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Alice Group.
- * 4. The names of the Alice Group or any of its members may not be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 _MAC68K_ITEIOCTL_H_
-#define _MAC68K_ITEIOCTL_H_
-
-#include <sys/ioctl.h>
-
-struct bellparams {
- int freq; /* hertz frequency */
- int len; /* length in clock ticks */
- int vol; /* percentage volume */
-};
-
-
-#define ITEIOC_GETBELL _IOR('I', 128, struct bellparams)
-#define ITEIOC_SETBELL _IOW('I', 129, struct bellparams)
-#define ITEIOC_RINGBELL _IO('I', 130)
-
-#endif /* _MACH68K_ITEIOCTL_H_ */
diff --git a/sys/arch/mac68k/include/keyboard.h b/sys/arch/mac68k/include/keyboard.h
index bf3e22e8ae8..357d6bedc12 100644
--- a/sys/arch/mac68k/include/keyboard.h
+++ b/sys/arch/mac68k/include/keyboard.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: keyboard.h,v 1.5 1997/11/30 06:10:31 gene Exp $ */
-/* $NetBSD: keyboard.h,v 1.5 1996/02/23 05:43:48 scottr Exp $ */
+/* $OpenBSD: keyboard.h,v 1.6 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: keyboard.h,v 1.1 1998/05/15 10:15:54 tsubai Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@@ -34,9 +34,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _MAC68K_KEYBOARD_H_
-#define _MAC68K_KEYBOARD_H_
-
#define ADBK_LEFT 0x3B
#define ADBK_RIGHT 0x3C
#define ADBK_UP 0x3E
@@ -76,139 +73,145 @@
(((key) & 0x7f) == ADBK_OPTION))
#ifndef KEYBOARD_ARRAY
-extern unsigned char keyboard[128][3];
+extern unsigned char keyboard[128][4];
+#else
+unsigned char keyboard[128][4] = {
+ /* Scan code Normal Shifted Controlled XT */
+ { /* 0x00, */ 'a', 'A', 0x01, 30 },
+ { /* 0x01, */ 's', 'S', 0x13, 31 },
+ { /* 0x02, */ 'd', 'D', 0x04, 32 },
+ { /* 0x03, */ 'f', 'F', 0x06, 33 },
+ { /* 0x04, */ 'h', 'H', 0x08, 35 },
+ { /* 0x05, */ 'g', 'G', 0x07, 34 },
+ { /* 0x06, */ 'z', 'Z', 0x1A, 44 },
+ { /* 0x07, */ 'x', 'X', 0x18, 45 },
+ { /* 0x08, */ 'c', 'C', 0x03, 46 },
+ { /* 0x09, */ 'v', 'V', 0x16, 47 },
+#ifdef FIX_SV_X_KBDBUG
+ { /* 0x0A, */ 0x00, 0x00, 0x00, 41 },
#else
-unsigned char keyboard[128][3] = {
- /* Scan code Normal Shifted Controlled */
- { /* 0x00, */ 'a', 'A', 0x01 },
- { /* 0x01, */ 's', 'S', 0x13 },
- { /* 0x02, */ 'd', 'D', 0x04 },
- { /* 0x03, */ 'f', 'F', 0x06 },
- { /* 0x04, */ 'h', 'H', 0x08 },
- { /* 0x05, */ 'g', 'G', 0x07 },
- { /* 0x06, */ 'z', 'Z', 0x1A },
- { /* 0x07, */ 'x', 'X', 0x18 },
- { /* 0x08, */ 'c', 'C', 0x03 },
- { /* 0x09, */ 'v', 'V', 0x16 },
- { /* 0x0A, */ 0x00, 0x00, 0x00 },
- { /* 0x0B, */ 'b', 'B', 0x02 },
- { /* 0x0C, */ 'q', 'Q', 0x11 },
- { /* 0x0D, */ 'w', 'W', 0x17 },
- { /* 0x0E, */ 'e', 'E', 0x05 },
- { /* 0x0F, */ 'r', 'R', 0x12 },
- { /* 0x10, */ 'y', 'Y', 0x19 },
- { /* 0x11, */ 't', 'T', 0x14 },
- { /* 0x12, */ '1', '!', 0x00 },
- { /* 0x13, */ '2', '@', 0x00 },
- { /* 0x14, */ '3', '#', 0x00 },
- { /* 0x15, */ '4', '$', 0x00 },
- { /* 0x16, */ '6', '^', 0x1E },
- { /* 0x17, */ '5', '%', 0x00 },
- { /* 0x18, */ '=', '+', 0x00 },
- { /* 0x19, */ '9', '(', 0x00 },
- { /* 0x1A, */ '7', '&', 0x00 },
- { /* 0x1B, */ '-', '_', 0x1F },
- { /* 0x1C, */ '8', '*', 0x00 },
- { /* 0x1D, */ '0', ')', 0x00 },
- { /* 0x1E, */ ']', '}', 0x1D },
- { /* 0x1F, */ 'o', 'O', 0x0F },
- { /* 0x20, */ 'u', 'U', 0x15 },
- { /* 0x21, */ '[', '{', 0x1B },
- { /* 0x22, */ 'i', 'I', 0x09 },
- { /* 0x23, */ 'p', 'P', 0x10 },
- { /* 0x24, */ 0x0D, 0x0D, 0x0D },
- { /* 0x25, */ 'l', 'L', 0x0C },
- { /* 0x26, */ 'j', 'J', 0x0A },
- { /* 0x27, */ '\'', '"', 0x00 },
- { /* 0x28, */ 'k', 'K', 0x0B },
- { /* 0x29, */ ';', ':', 0x00 },
- { /* 0x2A, */ '\\', '|', 0x1C },
- { /* 0x2B, */ ',', '<', 0x00 },
- { /* 0x2C, */ '/', '?', 0x00 },
- { /* 0x2D, */ 'n', 'N', 0x0E },
- { /* 0x2E, */ 'm', 'M', 0x0D },
- { /* 0x2F, */ '.', '>', 0x00 },
- { /* 0x30, */ 0x09, 0x09, 0x09 },
- { /* 0x31, */ ' ', ' ', 0x00 },
- { /* 0x32, */ '`', '~', 0x00 },
- { /* 0x33, */ 0x7F, 0x7F, 0x7F }, /* Delete */
- { /* 0x34, */ 0x00, 0x00, 0x00 },
- { /* 0x35, */ 0x1B, 0x1B, 0x1B },
- { /* 0x36, */ 0x00, 0x00, 0x00 },
- { /* 0x37, */ 0x00, 0x00, 0x00 },
- { /* 0x38, */ 0x00, 0x00, 0x00 },
- { /* 0x39, */ 0x00, 0x00, 0x00 },
- { /* 0x3A, */ 0x00, 0x00, 0x00 },
- { /* 0x3B, */ 'h', 0x00, 0x00 }, /* Left */
- { /* 0x3C, */ 'l', 0x00, 0x00 }, /* Right */
- { /* 0x3D, */ 'j', 0x00, 0x00 }, /* Down */
- { /* 0x3E, */ 'k', 0x00, 0x00 }, /* Up */
- { /* 0x3F, */ 0x00, 0x00, 0x00 },
- { /* 0x40, */ 0x00, 0x00, 0x00 },
- { /* 0x41, */ '.', '.', 0x00 },
- { /* 0x42, */ 0x00, 0x00, 0x00 },
- { /* 0x43, */ '*', '*', 0x00 },
- { /* 0x44, */ 0x00, 0x00, 0x00 },
- { /* 0x45, */ '+', '+', 0x00 },
- { /* 0x46, */ 0x00, 0x00, 0x00 },
- { /* 0x47, */ 0x00, 0x00, 0x00 },
- { /* 0x48, */ 0x00, 0x00, 0x00 },
- { /* 0x49, */ 0x00, 0x00, 0x00 },
- { /* 0x4A, */ 0x00, 0x00, 0x00 },
- { /* 0x4B, */ '/', '/', 0x00 },
- { /* 0x4C, */ 0x0D, 0x0D, 0x0D },
- { /* 0x4D, */ 0x00, 0x00, 0x00 },
- { /* 0x4E, */ '-', '-', 0x00 },
- { /* 0x4F, */ 0x00, 0x00, 0x00 },
- { /* 0x50, */ 0x00, 0x00, 0x00 },
- { /* 0x51, */ '=', '=', 0x00 },
- { /* 0x52, */ '0', '0', 0x00 },
- { /* 0x53, */ '1', '1', 0x00 },
- { /* 0x54, */ '2', '2', 0x00 },
- { /* 0x55, */ '3', '3', 0x00 },
- { /* 0x56, */ '4', '4', 0x00 },
- { /* 0x57, */ '5', '5', 0x00 },
- { /* 0x58, */ '6', '6', 0x00 },
- { /* 0x59, */ '7', '7', 0x00 },
- { /* 0x5A, */ 0x00, 0x00, 0x00 },
- { /* 0x5B, */ '8', '8', 0x00 },
- { /* 0x5C, */ '9', '9', 0x00 },
- { /* 0x5D, */ 0x00, 0x00, 0x00 },
- { /* 0x5E, */ 0x00, 0x00, 0x00 },
- { /* 0x5F, */ 0x00, 0x00, 0x00 },
- { /* 0x60, */ 0x00, 0x00, 0x00 },
- { /* 0x61, */ 0x00, 0x00, 0x00 },
- { /* 0x62, */ 0x00, 0x00, 0x00 },
- { /* 0x63, */ 0x00, 0x00, 0x00 },
- { /* 0x64, */ 0x00, 0x00, 0x00 },
- { /* 0x65, */ 0x00, 0x00, 0x00 },
- { /* 0x66, */ 0x00, 0x00, 0x00 },
- { /* 0x67, */ 0x00, 0x00, 0x00 },
- { /* 0x68, */ 0x00, 0x00, 0x00 },
- { /* 0x69, */ 0x00, 0x00, 0x00 },
- { /* 0x6A, */ 0x00, 0x00, 0x00 },
- { /* 0x6B, */ 0x00, 0x00, 0x00 },
- { /* 0x6C, */ 0x00, 0x00, 0x00 },
- { /* 0x6D, */ 0x00, 0x00, 0x00 },
- { /* 0x6E, */ 0x00, 0x00, 0x00 },
- { /* 0x6F, */ 0x00, 0x00, 0x00 },
- { /* 0x70, */ 0x00, 0x00, 0x00 },
- { /* 0x71, */ 0x00, 0x00, 0x00 },
- { /* 0x72, */ 0x00, 0x00, 0x00 },
- { /* 0x73, */ 0x00, 0x00, 0x00 },
- { /* 0x74, */ 0x00, 0x00, 0x00 },
- { /* 0x75, */ 0x00, 0x00, 0x00 },
- { /* 0x76, */ 0x00, 0x00, 0x00 },
- { /* 0x77, */ 0x00, 0x00, 0x00 },
- { /* 0x78, */ 0x00, 0x00, 0x00 },
- { /* 0x79, */ 0x00, 0x00, 0x00 },
- { /* 0x7A, */ 0x00, 0x00, 0x00 },
- { /* 0x7B, */ 0x00, 0x00, 0x00 },
- { /* 0x7C, */ 0x00, 0x00, 0x00 },
- { /* 0x7D, */ 0x00, 0x00, 0x00 },
- { /* 0x7E, */ 0x00, 0x00, 0x00 },
- { /* 0x7F, */ 0x00, 0x00, 0x00 }
+ { /* 0x0A, */ 0x00, 0x00, 0x00, 86 },
+#endif
+ { /* 0x0B, */ 'b', 'B', 0x02, 48 },
+ { /* 0x0C, */ 'q', 'Q', 0x11, 16 },
+ { /* 0x0D, */ 'w', 'W', 0x17, 17 },
+ { /* 0x0E, */ 'e', 'E', 0x05, 18 },
+ { /* 0x0F, */ 'r', 'R', 0x12, 19 },
+ { /* 0x10, */ 'y', 'Y', 0x19, 21 },
+ { /* 0x11, */ 't', 'T', 0x14, 20 },
+ { /* 0x12, */ '1', '!', 0x00, 2 },
+ { /* 0x13, */ '2', '@', 0x00, 3 },
+ { /* 0x14, */ '3', '#', 0x00, 4 },
+ { /* 0x15, */ '4', '$', 0x00, 5 },
+ { /* 0x16, */ '6', '^', 0x1E, 7 },
+ { /* 0x17, */ '5', '%', 0x00, 6 },
+ { /* 0x18, */ '=', '+', 0x00, 13 },
+ { /* 0x19, */ '9', '(', 0x00, 10 },
+ { /* 0x1A, */ '7', '&', 0x00, 8 },
+ { /* 0x1B, */ '-', '_', 0x1F, 12 },
+ { /* 0x1C, */ '8', '*', 0x00, 9 },
+ { /* 0x1D, */ '0', ')', 0x00, 11 },
+ { /* 0x1E, */ ']', '}', 0x1D, 27 },
+ { /* 0x1F, */ 'o', 'O', 0x0F, 24 },
+ { /* 0x20, */ 'u', 'U', 0x15, 22 },
+ { /* 0x21, */ '[', '{', 0x1B, 26 },
+ { /* 0x22, */ 'i', 'I', 0x09, 23 },
+ { /* 0x23, */ 'p', 'P', 0x10, 25 },
+ { /* 0x24, */ 0x0D, 0x0D, 0x0D, 28 },
+ { /* 0x25, */ 'l', 'L', 0x0C, 38 },
+ { /* 0x26, */ 'j', 'J', 0x0A, 36 },
+ { /* 0x27, */ '\'', '"', 0x00, 40 },
+ { /* 0x28, */ 'k', 'K', 0x0B, 37 },
+ { /* 0x29, */ ';', ':', 0x00, 39 },
+ { /* 0x2A, */ '\\', '|', 0x1C, 43 },
+ { /* 0x2B, */ ',', '<', 0x00, 51 },
+ { /* 0x2C, */ '/', '?', 0x00, 53 },
+ { /* 0x2D, */ 'n', 'N', 0x0E, 49 },
+ { /* 0x2E, */ 'm', 'M', 0x0D, 50 },
+ { /* 0x2F, */ '.', '>', 0x00, 52 },
+ { /* 0x30, */ 0x09, 0x09, 0x09, 15 },
+ { /* 0x31, */ ' ', ' ', 0x00, 57 },
+#ifdef FIX_SV_X_KBDBUG
+ { /* 0x32, */ '`', '~', 0x00, 86 },
+#else
+ { /* 0x32, */ '`', '~', 0x00, 41 },
+#endif
+ { /* 0x33, */ 0x7F, 0x7F, 0x7F, 211 }, /* Delete */
+ { /* 0x34, */ 0x00, 0x00, 0x00, 105 }, /* MODE/KP_Enter */
+ { /* 0x35, */ 0x1B, 0x1B, 0x1B, 1 },
+ { /* 0x36, */ 0x00, 0x00, 0x00, 29 },
+ { /* 0x37, */ 0x00, 0x00, 0x00, 219 },
+ { /* 0x38, */ 0x00, 0x00, 0x00, 42 },
+ { /* 0x39, */ 0x00, 0x00, 0x00, 58 },
+ { /* 0x3A, */ 0x00, 0x00, 0x00, 56 }, /* L Alt */
+ { /* 0x3B, */ 'h', 0x00, 0x00, 203 }, /* Left */
+ { /* 0x3C, */ 'l', 0x00, 0x00, 205 }, /* Right */
+ { /* 0x3D, */ 'j', 0x00, 0x00, 208 }, /* Down */
+ { /* 0x3E, */ 'k', 0x00, 0x00, 200 }, /* Up */
+ { /* 0x3F, */ 0x00, 0x00, 0x00, 0 }, /* Fn */
+ { /* 0x40, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x41, */ '.', '.', 0x00, 83 },
+ { /* 0x42, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x43, */ '*', '*', 0x00, 55 },
+ { /* 0x44, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x45, */ '+', '+', 0x00, 78 },
+ { /* 0x46, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x47, */ 0x00, 0x00, 0x00, 69 },
+ { /* 0x48, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x49, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x4A, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x4B, */ '/', '/', 0x00, 181 },
+ { /* 0x4C, */ 0x0D, 0x0D, 0x0D, 156 },
+ { /* 0x4D, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x4E, */ '-', '-', 0x00, 74 },
+ { /* 0x4F, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x50, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x51, */ '=', '=', 0x00, 118 },
+ { /* 0x52, */ '0', '0', 0x00, 82 },
+ { /* 0x53, */ '1', '1', 0x00, 79 },
+ { /* 0x54, */ '2', '2', 0x00, 80 },
+ { /* 0x55, */ '3', '3', 0x00, 81 },
+ { /* 0x56, */ '4', '4', 0x00, 75 },
+ { /* 0x57, */ '5', '5', 0x00, 76 },
+ { /* 0x58, */ '6', '6', 0x00, 77 },
+ { /* 0x59, */ '7', '7', 0x00, 71 },
+ { /* 0x5A, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x5B, */ '8', '8', 0x00, 72 },
+ { /* 0x5C, */ '9', '9', 0x00, 73 },
+ { /* 0x5D, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x5E, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x5F, */ 0x00, 0x00, 0x00, 51 },
+ { /* 0x60, */ 0x00, 0x00, 0x00, 63 }, /* F5 */
+ { /* 0x61, */ 0x00, 0x00, 0x00, 64 }, /* F6 */
+ { /* 0x62, */ 0x00, 0x00, 0x00, 65 }, /* F7 */
+ { /* 0x63, */ 0x00, 0x00, 0x00, 61 }, /* F3 */
+ { /* 0x64, */ 0x00, 0x00, 0x00, 66 }, /* F8 */
+ { /* 0x65, */ 0x00, 0x00, 0x00, 67 }, /* F9 */
+ { /* 0x66, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x67, */ 0x00, 0x00, 0x00, 87 }, /* F11 */
+ { /* 0x68, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x69, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x6A, */ 0x00, 0x00, 0x00, 156 },
+ { /* 0x6B, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x6C, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x6D, */ 0x00, 0x00, 0x00, 68 }, /* F10 */
+ { /* 0x6E, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x6F, */ 0x00, 0x00, 0x00, 88 }, /* F12 */
+ { /* 0x70, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x71, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x72, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x73, */ 0x00, 0x00, 0x00, 199 },
+ { /* 0x74, */ 0x00, 0x00, 0x00, 201 },
+ { /* 0x75, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x76, */ 0x00, 0x00, 0x00, 62 }, /* F4 */
+ { /* 0x77, */ 0x00, 0x00, 0x00, 207 },
+ { /* 0x78, */ 0x00, 0x00, 0x00, 60 }, /* F2 */
+ { /* 0x79, */ 0x00, 0x00, 0x00, 209 },
+ { /* 0x7A, */ 0x00, 0x00, 0x00, 59 }, /* F1 */
+ { /* 0x7B, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x7C, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x7D, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x7E, */ 0x00, 0x00, 0x00, 0 },
+ { /* 0x7F, */ 0x00, 0x00, 0x00, 0 } /* pwr */
};
#endif /* KEYBOARD_ARRAY */
-
-#endif /* _MAC68K_KEYBOARD_H_ */
diff --git a/sys/arch/mac68k/mac68k/autoconf.c b/sys/arch/mac68k/mac68k/autoconf.c
index cbbdea0e3ce..0d71b1a2f0c 100644
--- a/sys/arch/mac68k/mac68k/autoconf.c
+++ b/sys/arch/mac68k/mac68k/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.22 2005/12/27 18:31:09 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.23 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.38 1996/12/18 05:46:09 scottr Exp $ */
/*
@@ -82,6 +82,7 @@ int getstr(char *, int);
void findbootdev(void);
int target_to_unit(u_long, u_long, u_long);
+void diskconf(void);
void setroot(void);
#ifdef RAMDISK_HOOKS
@@ -93,15 +94,21 @@ cpu_configure()
{
mrg_init(); /* Init Mac ROM Glue */
startrtclock(); /* start before adb_init() */
- adb_init(); /* ADB device subsystem & driver */
if (config_rootfound("mainbus", "mainbus") == NULL)
panic("No mainbus found!");
+ spl0();
findbootdev();
+ md_diskconf = diskconf;
+ cold = 0;
+}
+
+void
+diskconf()
+{
setroot();
dumpconf();
- cold = 0;
}
struct nam2blk {
diff --git a/sys/arch/mac68k/mac68k/conf.c b/sys/arch/mac68k/mac68k/conf.c
index 620a07ae38e..ea2e8766aec 100644
--- a/sys/arch/mac68k/mac68k/conf.c
+++ b/sys/arch/mac68k/mac68k/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.35 2004/02/10 01:31:21 millert Exp $ */
+/* $OpenBSD: conf.c,v 1.36 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: conf.c,v 1.41 1997/02/11 07:35:49 scottr Exp $ */
/*
@@ -76,8 +76,6 @@ struct bdevsw bdevsw[] =
};
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
-#include "ite.h"
-cdev_decl(ite);
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
@@ -85,15 +83,10 @@ cdev_decl(mm);
#include "ss.h"
#include "uk.h"
cdev_decl(fd);
-#include "grf.h"
-cdev_decl(grf);
-#define NADB 1 /* #include "adb.h" */
-cdev_decl(adb);
#include "zsc.h"
cdev_decl(zsc);
#include "zstty.h"
cdev_decl(zs);
-#include "ch.h"
#include "bpfilter.h"
#include "tun.h"
#include "asc.h"
@@ -103,6 +96,10 @@ cdev_decl(asc);
#include <xfs/nxfs.h>
cdev_decl(xfs_dev);
#endif
+#include "wsdisplay.h"
+#include "wskbd.h"
+#include "wsmouse.h"
+#include "wsmux.h"
#include "pf.h"
@@ -120,8 +117,8 @@ struct cdevsw cdevsw[] =
cdev_notdef(), /* 7 */
cdev_notdef(), /* 8 */
cdev_notdef(), /* 9 */
- cdev_fb_init(NGRF,grf), /* 10: frame buffer */
- cdev_tty_init(NITE,ite), /* 11: console terminal emulator */
+ cdev_notdef(), /* 10 was GRF */
+ cdev_notdef(), /* 11 was ITE */
cdev_tty_init(NZSTTY,zs), /* 12: 2 mac serial ports -- BG*/
cdev_disk_init(NSD,sd), /* 13: SCSI disk */
cdev_tape_init(NST,st), /* 14: SCSI tape */
@@ -133,7 +130,7 @@ struct cdevsw cdevsw[] =
cdev_disk_init(NCCD,ccd), /* 20: concatenated disk driver */
cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-device */
cdev_bpftun_init(NBPFILTER,bpf),/* 22: Berkeley packet filter */
- cdev_mouse_init(NADB,adb), /* 23: ADB event interface */
+ cdev_notdef(), /* 23 was ADB */
cdev_bpftun_init(NTUN,tun), /* 24: network tunnel */
cdev_lkm_init(NLKM,lkm), /* 25: loadable module driver */
cdev_lkm_dummy(), /* 26 */
@@ -148,10 +145,10 @@ struct cdevsw cdevsw[] =
cdev_pf_init(NPF,pf), /* 35: packet filter */
cdev_audio_init(NASC,asc), /* 36: ASC audio device */
cdev_ksyms_init(NKSYMS,ksyms), /* 37: Kernel symbols device */
- cdev_notdef(), /* 38 */
- cdev_notdef(), /* 39 */
- cdev_notdef(), /* 40 */
- cdev_notdef(), /* 41 */
+ cdev_wsdisplay_init(NWSDISPLAY, wsdisplay), /* 38: displays */
+ cdev_mouse_init(NWSKBD, wskbd), /* 39: keyboards */
+ cdev_mouse_init(NWSMOUSE, wsmouse), /* 40: mice */
+ cdev_mouse_init(NWSMUX, wsmux), /* 41: ws multiplexor */
cdev_notdef(), /* 42 */
cdev_notdef(), /* 43 */
cdev_notdef(), /* 44 */
@@ -238,14 +235,13 @@ int chrtoblktbl[] = {
};
int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
-#define itecnpollc nullcnpollc
-cons_decl(ite);
+cons_decl(ws);
#define zscnpollc nullcnpollc
cons_decl(zs);
struct consdev constab[] = {
-#if NITE > 0
- cons_init(ite),
+#if NWSDISPLAY > 0
+ cons_init(ws),
#endif
#if NZSTTY > 0
cons_init(zs),
diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s
index 3972f2fb50d..4f2fd335199 100644
--- a/sys/arch/mac68k/mac68k/locore.s
+++ b/sys/arch/mac68k/mac68k/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.48 2006/01/01 13:16:01 miod Exp $ */
+/* $OpenBSD: locore.s,v 1.49 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: locore.s,v 1.103 1998/07/09 06:02:50 scottr Exp $ */
/*
@@ -345,16 +345,10 @@ Lloaddone:
jeq Lnocache0 | yes, cache already on
movl #CACHE_ON,d0
movc d0,cacr | clear cache(s)
-#ifdef __notyet__
- tstl _C_LABEL(ectype)
- jeq Lnocache0
- | Enable external cache here
-#endif
Lnocache0:
/* Final setup for call to main(). */
jbsr _C_LABEL(mac68k_init)
- movw #PSL_LOWIPL,sr | lower SPL ; enable interrupts
/*
* Create a fake exception frame so that cpu_fork() can copy it.
@@ -1886,11 +1880,6 @@ GLOBAL(mmutype)
GLOBAL(cputype)
.long CPU_68020 | default to 68020 CPU
-#ifdef __notyet__
-GLOBAL(ectype)
- .long EC_NONE | external cache type, default to none
-#endif
-
GLOBAL(fputype)
.long FPU_68882 | default to 68882 FPU
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index 0710c332cf5..5f6cb1c863a 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.123 2006/01/01 13:16:01 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.124 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */
/*
@@ -114,19 +114,17 @@
#include <machine/pmap.h>
#include <net/netisr.h>
-void netintr(void);
-
#include <uvm/uvm_extern.h>
#include <sys/sysctl.h>
#include <dev/cons.h>
-#include <mac68k/mac68k/macrom.h>
#include <mac68k/dev/adbvar.h>
#include <machine/psc.h>
#include <machine/viareg.h>
-#include "ether.h"
+
+#include "wsdisplay.h"
/* The following is used externally (sysctl_hw) */
char machine[] = MACHINE; /* from <machine/param.h> */
@@ -152,8 +150,11 @@ u_long nblog[NBMAXRANGES]; /* Start logical addr of this range */
long nblen[NBMAXRANGES]; /* Length of this range If the length is */
/* negative, all phys addrs are the same. */
-extern u_long videoaddr; /* Addr used in kernel for video. */
-extern u_long videorowbytes; /* Used in kernel for video. */
+/* From Booter via locore */
+long videoaddr; /* Addr used in kernel for video. */
+long videorowbytes; /* Used in kernel for video. */
+long videobitdepth; /* Number of bihs per pixel */
+u_long videosize; /* height = 31:16, width 15:0 */
/*
* Values for IIvx-like internal video
@@ -296,21 +297,61 @@ consinit(void)
/*
* Generic console: sys/dev/cons.c
* Initializes either ite or ser as console.
- * Can be called from locore.s and init_main.c.
+ * Can be called from locore.s and init_main.c. (Ugh.)
*/
static int init; /* = 0 */
if (!init) {
cninit();
-#ifdef DDB
+#ifdef DDB
/*
* Initialize kernel debugger, if compiled in.
*/
ddb_init();
#endif
init = 1;
- } else
+ } else {
+#if NWSDISPLAY > 0
+ /*
+ * XXX This is an evil hack on top of an evil hack!
+ *
+ * With the graybar stuff, we've got a catch-22: we need
+ * to do at least some console setup really early on, even
+ * before we're running with the mappings we need. On
+ * the other hand, we're not nearly ready to do anything
+ * with wscons or the ADB driver at that point.
+ *
+ * To get around this, wscninit() ignores the first call
+ * it gets (from cninit(), if not on a serial console).
+ * Once we're here, we call wscninit() again, which sets
+ * up the console devices and does the appropriate wscons
+ * initialization.
+ */
+ if (mac68k_machine.serial_console == 0) {
+ cons_decl(ws);
+ wscninit(NULL);
+ }
+#endif
+
mac68k_calibrate_delay();
+
+#if NZSC > 0 && defined(KGDB)
+ zs_kgdb_init();
+#endif
+
+ if (boothowto & RB_KDB) {
+#ifdef KGDB
+ /* XXX - Ask on console for kgdb_dev? */
+ /* Note: this will just return if kgdb_dev==NODEV */
+ kgdb_connect(1);
+#else /* KGDB */
+#ifdef DDB
+ /* Enter DDB. We don't have a monitor PROM. */
+ Debugger();
+#endif /* DDB */
+#endif /* KGDB */
+ }
+ }
}
#define CURRENTBOOTERVER 111
@@ -455,6 +496,8 @@ cpu_startup(void)
printf("kernel does not support -c; continuing..\n");
#endif
}
+
+ /* Safe for extent allocation to use malloc now. */
iomem_malloc_safe = 1;
}
@@ -1078,7 +1121,7 @@ getenvvars(flag, buf)
u_long flag;
char *buf;
{
- extern u_long bootdev, videobitdepth, videosize;
+ extern u_long bootdev;
#if defined(DDB) || NKSYMS > 0
extern u_long end, esym;
#endif
@@ -1152,9 +1195,7 @@ getenvvars(flag, buf)
*/
#if defined(DDB) || NKSYMS > 0
esym = getenv("END_SYM");
-#ifndef SYMTAB_SPACE
if (esym == 0)
-#endif
esym = (long) &end;
#endif
@@ -2570,9 +2611,10 @@ check_video(id, limit, maxm)
{
u_long addr, phys;
- if (!get_physical(videoaddr, &phys))
- printf("get_mapping(): %s. False start.\n", id);
- else {
+ if (!get_physical(videoaddr, &phys)) {
+ if (mac68k_machine.do_graybars)
+ printf("get_mapping(): %s. False start.\n", id);
+ } else {
mac68k_vidlog = videoaddr;
mac68k_vidphys = phys;
mac68k_vidlen = 32768;
@@ -2582,21 +2624,24 @@ check_video(id, limit, maxm)
!= mac68k_vidlen)
break;
if (mac68k_vidlen + 32768 > limit) {
- printf("mapping: %s. Does it never end?\n",
- id);
- printf(" Forcing VRAM size ");
- printf("to a conservative %ldK.\n", maxm/1024);
+ if (mac68k_machine.do_graybars) {
+ printf("mapping: %s. Does it never end?\n",
+ id);
+ printf(" Forcing VRAM size ");
+ printf("to a conservative %ldK.\n",
+ maxm/1024);
+ }
mac68k_vidlen = maxm;
break;
}
mac68k_vidlen += 32768;
addr += 32768;
}
-#ifdef DIAGNOSTIC
- printf(" %s internal video at addr 0x%x (phys 0x%x), ",
- id, mac68k_vidlog, mac68k_vidphys);
- printf("len 0x%x.\n", mac68k_vidlen);
-#endif
+ if (mac68k_machine.do_graybars) {
+ printf(" %s internal video at addr 0x%x (phys 0x%x), ",
+ id, mac68k_vidlog, mac68k_vidphys);
+ printf("len 0x%x.\n", mac68k_vidlen);
+ }
}
}
@@ -2631,12 +2676,14 @@ get_mapping(void)
high[numranges - 1] = phys + NBPG;
}
}
-#ifdef DIAGNOSTIC
- printf("System RAM: %ld bytes in %ld pages.\n", addr, addr / NBPG);
- for (i = 0; i < numranges; i++) {
- printf(" Low = 0x%lx, high = 0x%lx\n", low[i], high[i]);
+ if (mac68k_machine.do_graybars) {
+ printf("System RAM: %ld bytes in %ld pages.\n",
+ addr, addr / NBPG);
+ for (i = 0; i < numranges; i++) {
+ printf(" Low = 0x%lx, high = 0x%lx\n",
+ low[i], high[i]);
+ }
}
-#endif
/*
* Find on-board video, if we have an idea of where to look
@@ -2675,10 +2722,9 @@ get_mapping(void)
* We've already figured out where internal video is.
* Tell the user what we know.
*/
-#ifdef DIAGNOSTIC
- printf("On-board video at addr 0x%lx (phys 0x%x), len 0x%x.\n",
- videoaddr, mac68k_vidphys, mac68k_vidlen);
-#endif
+ if (mac68k_machine.do_graybars)
+ printf("On-board video at addr 0x%lx (phys 0x%x), len 0x%x.\n",
+ videoaddr, mac68k_vidphys, mac68k_vidlen);
} else {
/*
* We should now look through all of NuBus space to find where
@@ -2704,9 +2750,8 @@ get_mapping(void)
}
len = nbnumranges == 0 ? 0 : nblen[nbnumranges - 1];
-#if 0
- printf ("0x%lx --> 0x%lx\n", addr, phys);
-#endif
+ if (mac68k_machine.do_graybars)
+ printf ("0x%lx --> 0x%lx\n", addr, phys);
if (nbnumranges > 0
&& addr == nblog[nbnumranges - 1] + len
&& phys == nbphys[nbnumranges - 1]) {
@@ -2725,8 +2770,9 @@ get_mapping(void)
same = 0;
}
if (nbnumranges == NBMAXRANGES) {
- printf("get_mapping(): "
- "Too many NuBus ranges.\n");
+ if (mac68k_machine.do_graybars)
+ printf("get_mapping(): "
+ "Too many NuBus ranges.\n");
break;
}
nbnumranges++;
@@ -2740,13 +2786,13 @@ get_mapping(void)
nblen[nbnumranges - 1] = -nblen[nbnumranges - 1];
same = 0;
}
-#if 0
- printf("Non-system RAM (nubus, etc.):\n");
- for (i = 0; i < nbnumranges; i++) {
- printf(" Log = 0x%lx, Phys = 0x%lx, Len = 0x%lx (%lu)\n",
- nblog[i], nbphys[i], nblen[i], nblen[i]);
+ if (mac68k_machine.do_graybars) {
+ printf("Non-system RAM (nubus, etc.):\n");
+ for (i = 0; i < nbnumranges; i++) {
+ printf(" Log = 0x%lx, Phys = 0x%lx, Len = 0x%lx (%lu)\n",
+ nblog[i], nbphys[i], nblen[i], nblen[i]);
+ }
}
-#endif
/*
* We must now find the logical address of internal video in the
@@ -2773,9 +2819,8 @@ get_mapping(void)
21888, 21888);
} else if (0x60000000 <= videoaddr &&
videoaddr < 0x70000000) {
-#ifdef DIAGNOSTIC
- printf("Checking for Internal Video ");
-#endif
+ if (mac68k_machine.do_graybars)
+ printf("Checking for Internal Video ");
/*
* Kludge for IIvx internal video (60b0 0000).
* PB 520 (6000 0000)
@@ -2797,19 +2842,18 @@ get_mapping(void)
check_video("AV video (0x50100100)",
1 * 1024 * 1024, 1 * 1024 * 1024);
} else {
-#ifdef DIAGNOSTIC
- printf( " no internal video at address 0 -- "
- "videoaddr is 0x%lx.\n", videoaddr);
-#endif
+ if (mac68k_machine.do_graybars)
+ printf( " no internal video at address 0 -- "
+ "videoaddr is 0x%lx.\n", videoaddr);
}
} else {
-#ifdef DIAGNOSTIC
- printf(" Video address = 0x%lx\n", videoaddr);
- printf(" Int video starts at 0x%x\n",
- mac68k_vidlog);
- printf(" Length = 0x%x (%d) bytes\n",
- mac68k_vidlen, mac68k_vidlen);
-#endif
+ if (mac68k_machine.do_graybars) {
+ printf(" Video address = 0x%lx\n", videoaddr);
+ printf(" Int video starts at 0x%x\n",
+ mac68k_vidlog);
+ printf(" Length = 0x%x (%d) bytes\n",
+ mac68k_vidlen, mac68k_vidlen);
+ }
}
}
diff --git a/sys/arch/mac68k/mac68k/macrom.c b/sys/arch/mac68k/mac68k/macrom.c
index 13e121ea88e..7e7adca2b1a 100644
--- a/sys/arch/mac68k/mac68k/macrom.c
+++ b/sys/arch/mac68k/mac68k/macrom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macrom.c,v 1.29 2005/05/22 19:40:51 art Exp $ */
+/* $OpenBSD: macrom.c,v 1.30 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: macrom.c,v 1.47 2000/11/15 07:15:36 scottr Exp $ */
/*-
@@ -58,8 +58,7 @@
#include <machine/frame.h>
#include <machine/viareg.h>
-#include <arch/mac68k/mac68k/macrom.h>
-#include <arch/mac68k/dev/adbvar.h>
+#include <mac68k/dev/adbvar.h>
/* trap modifiers (put it macrom.h) */
#define TRAP_TOOLBOX(a) ((a) & 0x800)
@@ -106,7 +105,7 @@ u_int32_t mrg_AVInitEgretJT[] = {
caddr_t mrg_romadbintr = (caddr_t)0; /* ROM ADB interrupt */
caddr_t mrg_rompmintr = 0; /* ROM PM (?) interrupt */
-char *mrg_romident = NULL; /* ident string for ROMs */
+const char *mrg_romident = NULL; /* ident string for ROMs */
caddr_t mrg_ADBAlternateInit = 0;
caddr_t mrg_InitEgret = 0;
caddr_t mrg_ADBIntrPtr = (caddr_t)0x0; /* ADB interrupt taken from MacOS vector table*/
@@ -686,8 +685,10 @@ mrg_aline_super(struct frame *frame)
"ToolBox", trapnum);
#endif
- /* Only OS Traps come to us; _alinetrap takes care of ToolBox
- traps, which are a horrible Frankenstein-esque abomination. */
+ /*
+ * Only OS Traps come to us; _alinetrap takes care of ToolBox
+ * traps, which are a horrible Frankenstein-esque abomination.
+ */
trapaddr = mrg_OStraps[trapnum];
#if defined(MRG_DEBUG)
diff --git a/sys/arch/mac68k/mac68k/macrom.h b/sys/arch/mac68k/mac68k/macrom.h
index 76c8aa97b27..9d89ed2b9e8 100644
--- a/sys/arch/mac68k/mac68k/macrom.h
+++ b/sys/arch/mac68k/mac68k/macrom.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: macrom.h,v 1.12 2005/02/20 18:08:08 martin Exp $ */
+/* $OpenBSD: macrom.h,v 1.13 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: macrom.h,v 1.12 2000/11/15 07:15:36 scottr Exp $ */
/*-
@@ -166,7 +166,7 @@ typedef struct rsrc_s {
} rsrc_t;
typedef struct romvec_s {
- char *romident; /* just to print it out */
+ const char *romident; /* just to print it out */
caddr_t adbintr; /* where is ADB interrupt */
caddr_t pmintr; /* where is ADB/PM interrupt, on machines */
/* that have it */
diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c
index 8a28b9bab45..4a10ffc3375 100644
--- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c
+++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.34 2005/10/23 19:00:26 martin Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.35 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */
/*
@@ -56,7 +56,11 @@
#include <mac68k/mac68k/clockreg.h>
#include <mac68k/mac68k/macrom.h>
+#include "zsc.h"
+
+#if NZSC > 0
extern int zsinited;
+#endif
/*
* These are used to map the RAM:
@@ -201,7 +205,9 @@ void
bootstrap_mac68k(tc)
int tc;
{
+#if NZSC > 0
extern void zs_init(void);
+#endif
extern caddr_t esym;
paddr_t nextpa;
caddr_t oldROMBase;
@@ -261,8 +267,10 @@ bootstrap_mac68k(tc)
* of this function (where we start using the MMU, so the new
* address is correct).
*/
+#if NZSC > 0
if (zsinited != 0)
zs_init();
+#endif
videoaddr = newvideoaddr;
}
diff --git a/sys/arch/mac68k/mac68k/pram.c b/sys/arch/mac68k/mac68k/pram.c
index 3715d4d653a..2ef1405c752 100644
--- a/sys/arch/mac68k/mac68k/pram.c
+++ b/sys/arch/mac68k/mac68k/pram.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pram.c,v 1.7 2003/05/11 19:41:10 deraadt Exp $ */
+/* $OpenBSD: pram.c,v 1.8 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: pram.c,v 1.11 1996/10/21 05:42:29 scottr Exp $ */
/*-
@@ -44,10 +44,11 @@
#include <machine/viareg.h>
-#include <arch/mac68k/mac68k/pram.h>
-#include <arch/mac68k/mac68k/macrom.h>
-#ifndef MRG_ADB
-#include <arch/mac68k/dev/adbvar.h>
+#include <mac68k/mac68k/pram.h>
+#ifdef MRG_ADB
+#include <mac68k/mac68k/macrom.h>
+#else
+#include <mac68k/dev/adbvar.h>
#endif
#if DEBUG
@@ -178,6 +179,7 @@ getPramTime(void)
return time;
case ADB_HW_IISI: /* access PRAM via pseudo-adb functions */
+ case ADB_HW_CUDA:
if (0 != adb_read_date_time(&time))
return 0;
else
@@ -208,6 +210,7 @@ setPramTime(unsigned long time)
return;
case ADB_HW_IISI: /* access PRAM via pseudo-adb functions */
+ case ADB_HW_CUDA:
adb_set_date_time(time);
return;
diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c
index 8569e020657..eb4b5ac53fa 100644
--- a/sys/arch/mac68k/mac68k/trap.c
+++ b/sys/arch/mac68k/mac68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.45 2005/09/12 10:07:29 martin Exp $ */
+/* $OpenBSD: trap.c,v 1.46 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */
/*
@@ -529,6 +529,12 @@ copyfault:
uvmexp.softs++;
mrg_execute_deferred();
}
+ if (ssir & SIR_ADB) {
+ void adb_soft_intr(void);
+ siroff(SIR_ADB);
+ uvmexp.softs++;
+ adb_soft_intr();
+ }
/*
* If this was not an AST trap, we are all done.
*/
diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c
index 4a523f5f802..dd619d0ae67 100644
--- a/sys/arch/mac68k/mac68k/via.c
+++ b/sys/arch/mac68k/mac68k/via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: via.c,v 1.23 2006/01/01 13:16:01 miod Exp $ */
+/* $OpenBSD: via.c,v 1.24 2006/01/04 20:39:05 miod Exp $ */
/* $NetBSD: via.c,v 1.62 1997/09/10 04:38:48 scottr Exp $ */
/*-
@@ -473,22 +473,21 @@ via1_register_irq(int irq, int (*irq_func)(void *), void *client_data,
ih = &via1intrs[irq];
/*
- * VIA1_T1 is special, since we need to temporary replace
- * the callback during bootstrap, to compute the delay
- * values.
- * To avoid a loop in evcount lists, only invoke
- * evcount_attach() if name is non-NULL, and have the two
- * replacements calls in clock.c pass a NULL pointer.
+ * VIA1 interrupts are special, since we start with temporary handlers,
+ * and later switch to better routines whenever possible.
+ * To avoid a loop in evcount lists, only invoke evcount_attach() if
+ * name is non-NULL, and have the replacements calls in adb_direct.c,
+ * clock.c and pm_direct.c pass a NULL pointer.
*/
#ifdef DIAGNOSTIC
- if (ih->ih_fn != NULL && irq != VIA1_T1)
- panic("via1_register_irq: attempt to share irq %d", irq);
+ if (ih->ih_fn != NULL && name != NULL)
+ panic("via1_register_irq: improper invocation");
#endif
ih->ih_fn = irq_func;
ih->ih_arg = client_data;
ih->ih_ipl = irq;
- if (name != NULL || irq != VIA1_T1)
+ if (name != NULL)
evcount_attach(&ih->ih_count, name, (void *)&ih->ih_ipl,
&evcount_intr);
}
diff --git a/sys/arch/mac68k/mac68k/wscons_machdep.c b/sys/arch/mac68k/mac68k/wscons_machdep.c
new file mode 100644
index 00000000000..baafb2e91bb
--- /dev/null
+++ b/sys/arch/mac68k/mac68k/wscons_machdep.c
@@ -0,0 +1,117 @@
+/* $OpenBSD: wscons_machdep.c,v 1.1 2006/01/04 20:39:05 miod Exp $ */
+/* $NetBSD: maccons.c,v 1.5 2005/01/15 16:00:59 chs Exp $ */
+
+/*
+ * Copyright (C) 1999 Scott Reynolds. 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/timeout.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <dev/cons.h>
+
+#include <dev/wscons/wskbdvar.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+#include <mac68k/dev/macfbvar.h>
+#include <mac68k/dev/akbdvar.h>
+
+#include "wsdisplay.h"
+#include "wskbd.h"
+
+cons_decl(ws);
+
+int maccons_initted = (-1);
+
+/* From Booter via locore */
+extern u_int32_t mac68k_vidphys;
+
+void
+wscnprobe(struct consdev *cp)
+{
+#if NWSDISPLAY > 0
+ int maj, unit;
+#endif
+
+ cp->cn_dev = NODEV;
+ cp->cn_pri = CN_NORMAL;
+
+#if NWSDISPLAY > 0
+ unit = 0;
+ for (maj = 0; maj < nchrdev; maj++)
+ if (cdevsw[maj].d_open == wsdisplayopen)
+ break;
+
+ if (maj != nchrdev) {
+ cp->cn_pri = CN_INTERNAL;
+ cp->cn_dev = makedev(maj, unit);
+ }
+#endif
+}
+
+void
+wscninit(struct consdev *cp)
+{
+ /*
+ * XXX evil hack; see consinit() for an explanation.
+ * note: maccons_initted is initialized to (-1).
+ */
+ if (++maccons_initted > 0) {
+ macfb_cnattach(mac68k_vidphys);
+ akbd_cnattach();
+ }
+}
+
+int
+wscngetc(dev_t dev)
+{
+#if NWSKBD > 0
+ return wskbd_cngetc(dev);
+#else
+ return 0;
+#endif
+}
+
+void
+wscnputc(dev_t dev, int c)
+{
+#if NWSDISPLAY > 0
+ wsdisplay_cnputc(dev,c);
+#endif
+}
+
+void
+wscnpollc(dev_t dev, int on)
+{
+#if NWSKBD > 0
+ wskbd_cnpollc(dev,on);
+#endif
+}