Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch

just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code).  Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
  • Loading branch information...
commit cf3da37cab0cb5af2928817aad82875069544fc7 1 parent 48c5aac
itojun authored
View
282 sys/arch/mac68k/conf/GENERIC
@@ -1,51 +1,231 @@
-machine "mac"
-cpu "mc68020"
-ident GENERIC
-timezone 5 dst
-
-options INET
-options NS
-#options KADB
-#options QUOTA
-#options FIFO
-#options NFS
-options MFS
-options DIAGNOSTIC
-options "TCP_COMPAT_42"
-options "COMPAT_43"
-options "COMPAT_42"
-options KTRACE
-options SCSI
-options SWAPPAGER
-options VNODEPAGER
-#options GATEWAY # slip needs this for packet forwarding
-
-# OSI stuff:
-#options ISO
-#options TPIP
-#options EON
-
-options MAPMEM,SYSVSHM
-
-maxusers 8
-maxfdescs 1024
-
-config netbsd root on sd0 swap on sd0
-
-pseudo-device ser 2
-pseudo-device con 6
-
-master ncr0
-disk sd0 at ncr0 flags 0 drive ?
-disk sd1 at ncr0 flags 0 drive ?
-disk sd2 at ncr0 flags 0 drive ?
-disk sd3 at ncr0 flags 0 drive ?
-disk sd4 at ncr0 flags 0 drive ?
-disk sd5 at ncr0 flags 0 drive ?
-disk sd6 at ncr0 flags 0 drive ?
-tape st0 at ncr0 flags 1 drive ?
-disk cd0 at ncr0 flags 2 drive ?
-
-pseudo-device pty 16
-pseudo-device loop
-pseudo-device ether
+# $NetBSD: GENERIC,v 1.85.8.1 1999/11/30 13:32:26 itojun Exp $
+#
+# GENERIC
+
+include "arch/mac68k/conf/std.mac68k"
+
+maxusers 16 # estimated number of users
+
+# CPU support. At least one is REQUIRED.
+options M68040
+options M68030
+options M68020 # Note: must have 68851 PMMU
+
+# CPU-related options.
+options FPSP
+options FPU_EMULATE
+
+# Standard system options
+
+options UCONSOLE # users can use TIOCCONS (for xconsole)
+options INSECURE # disable kernel security levels
+
+options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
+#options NTP # NTP phase/frequency locked loop
+
+options KTRACE # system call tracing via ktrace(1)
+
+options SYSVMSG # System V-like message queues
+options SYSVSEM # System V-like semaphores
+options SYSVSHM # System V-like memory sharing
+#options SHMMAXPGS=1024 # 1024 pages is the default
+
+options LKM # loadable kernel modules
+
+# Diagnostic/debugging support options
+options DIAGNOSTIC # cheap kernel consistency checks
+#options DEBUG # expensive debugging checks/support
+options KMEMSTATS # kernel memory statistics (vmstat -m)
+options DDB # in-kernel debugger
+#options DDB_HISTORY_SIZE=100 # enable history editing in DDB
+#options KGDB # remote debugger
+#options KGDBDEV=0xc01 # kgdb device number (dev_t)
+#options KGDBRATE=38400 # baud rate
+#makeoptions DEBUG="-g" # compile full symbol table
+
+# Compatibility options
+#options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
+#options COMPAT_09 # NetBSD 0.9,
+options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
+options COMPAT_12 # NetBSD 1.2,
+options COMPAT_13 # NetBSD 1.3,
+options COMPAT_43 # and 4.3BSD
+
+options COMPAT_SUNOS # compatibility with SunOS 4.x binaries
+#options COMPAT_M68K4K # compatibility with NetBSD/m68k4k binaries
+#options COMPAT_LINUX # compatibility with Linux/m68k binaries
+#options EXEC_ELF32 # 32-bit ELF executables (Linux)
+
+# File systems
+file-system FFS # UFS
+file-system EXT2FS # second extended file system (linux)
+file-system LFS # log-structured file system
+file-system MFS # memory file system
+file-system NFS # Network File System client
+file-system CD9660 # ISO 9660 + Rock Ridge file system
+file-system MSDOSFS # MS-DOS file system
+file-system FDESC # /dev/fd
+file-system KERNFS # /kern
+file-system NULLFS # loopback file system
+file-system PORTAL # portal filesystem (still experimental)
+file-system PROCFS # /proc
+file-system UMAPFS # NULLFS + uid and gid remapping
+file-system UNION # union file system
+
+# File system options
+options QUOTA # UFS quotas
+#options FFS_EI # FFS Endian Independant support
+options NFSSERVER # Network File System server
+#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
+ # immutable) behave as system flags.
+
+# Networking options
+options GATEWAY # packet forwarding
+options INET # IP + ICMP + TCP + UDP
+#options MROUTING # IP multicast routing
+options NS # XNS
+#options NSIP # XNS tunneling over IP
+options ISO,TPIP # OSI
+options EON # OSI tunneling over IP
+options CCITT,LLC,HDLC # X.25
+options NETATALK # AppleTalk networking protocols
+#options PPP_BSDCOMP # BSD-Compress compression support for PPP
+#options PPP_DEFLATE # Deflate compression support for PPP
+#options PPP_FILTER # Active filter support for PPP (requires bpf)
+#options PFIL_HOOKS # pfil(9) packet filter hooks
+
+# Compatibility with 4.2BSD implementation of TCP/IP. Not recommended.
+#options TCP_COMPAT_42
+
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+options SCSIVERBOSE # human readable SCSI error messages
+
+# Mac-specific options
+#options ALTXBUTTONS # Map Opt-{1,2,3} to mouse buttons
+#options DISABLE_EXT_CACHE # If really paranoid, disable IIci ext. cache
+options GRF_COMPAT # Include grf compatibility code
+#options MRG_ADB # Use ROM-based ADB driver
+options ZS_CONSOLE_ABORT
+
+options NFS_BOOT_BOOTP
+
+# Kernel root file system and dump configuration.
+config netbsd root on ? type ?
+
+#
+# Device configuration
+#
+
+mainbus0 at root
+
+fpu0 at mainbus? # Floating-Point Coprocessor support
+
+
+# Basic Bus Support
+
+# On-board I/O bus support
+obio0 at mainbus?
+
+# NuBus support
+nubus0 at mainbus?
+
+
+# Console Devices
+
+# Apple Desktop Bus interface
+adb0 at obio?
+aed* at adb? # ADB event device
+kbd* at adb? # ADB keyboard
+ms* at adb? # ADB mouse
+
+# Basic frame buffer support
+intvid0 at obio? # Internal video hardware
+macvid* at nubus? # NuBus video card
+
+# Device-independent frame buffer interface
+grf* at intvid?
+grf* at macvid?
+
+# Integrated Terminal Emulator (console) support
+ite0 at grf?
+
+
+# Serial Devices
+
+# On-board serial interface
+zsc0 at obio?
+zstty* at zsc? channel ?
+
+
+# SCSI Controllers and Devices
+
+# SCSI controllers
+# XXX - use only one of ncrscsi or sbc
+ncrscsi0 at obio? # SCSI NCR 5380
+#sbc0 at obio? flags 0x1 # MI SCSI NCR 5380
+esp0 at obio? # SCSI NCR 53C9x
+esp1 at obio? # SCSI NCR 53C9x
+
+# SCSI bus support
+scsibus* at scsi?
+
+# SCSI devices
+sd* at scsibus? target ? lun ? # SCSI disk drives
+st* at scsibus? target ? lun ? # SCSI tape drives
+cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
+ch* at scsibus? target ? lun ? # SCSI autochangers
+se* at scsibus? target ? lun ? # SCSI ethernet
+ss* at scsibus? target ? lun ? # SCSI scanners
+uk* at scsibus? target ? lun ? # SCSI unknown
+
+
+# Miscellaneous mass storage devices
+
+# IWM floppy disk controller
+iwm0 at obio? # Sony driver (800K GCR)
+fd* at iwm? drive ?
+
+
+# Network Interfaces
+
+# On-board Ethernet controllers
+sn* at obio? # SONIC-based (DP83932, DP83916)
+mc* at obio? # MACE-based
+
+# NuBus Ethernet controllers
+ae* at nubus? # DP8390-based
+sn* at nubus? # SONIC-based (DP83932, DP83916)
+
+
+# Audio Devices
+
+# On-board audio hardware
+asc0 at obio? # ASC/EASC audio
+
+# Pseudo-Devices
+
+# disk/mass storage pseudo-devices
+pseudo-device ccd 4 # concatenated/striped disk devices
+#pseudo-device raid 4 # RAIDframe disk driver
+pseudo-device md 1 # memory disk device (ramdisk)
+pseudo-device vnd 4 # disk-like interface to files
+
+# network pseudo-devices
+pseudo-device bpfilter 12 # Berkeley packet filter
+pseudo-device ipfilter # IP filter (firewall) and NAT
+pseudo-device loop # network loopback
+pseudo-device ppp 2 # Point-to-Point Protocol
+pseudo-device sl 2 # Serial Line IP
+#pseudo-device strip 2 # Starmode Radio IP (Metricom)
+pseudo-device tun 2 # network tunneling over tty
+#pseudo-device gre 2 # generic L3 over IP tunnel
+
+# miscellaneous pseudo-devices
+pseudo-device pty 64 # pseudo-terminals
+#pseudo-device tb 1 # tablet line discipline
+
+# rnd is EXPERIMENTAL at this point.
+#pseudo-device rnd # /dev/random and in-kernel generator
+#options RND_COM # use "com" randomness as well (BROKEN)
View
478 sys/arch/mac68k/mac68k/clock.c
@@ -1,3 +1,5 @@
+/* $NetBSD: clock.c,v 1.36.16.1 1999/11/30 13:32:33 itojun Exp $ */
+
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -68,86 +70,98 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-#ident "$Id: clock.c,v 1.1.1.1 1993/09/29 06:09:19 briggs Exp $"
-
/*
*
* from: Utah $Hdr: clock.c 1.18 91/01/21$
*
- * @(#)clock.c 7.6 (Berkeley) 5/7/91
+ * @(#)clock.c 7.6 (Berkeley) 5/7/91
*/
-#if !defined(STANDALONE)
-#include "param.h"
-#include "kernel.h"
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
-#include "machine/psl.h"
-#include "machine/cpu.h"
+#include <machine/autoconf.h>
+#include <machine/psl.h>
+#include <machine/cpu.h>
+#include <machine/limits.h>
#if defined(GPROF) && defined(PROFTIMER)
-#include "sys/gprof.h"
+#include <sys/gprof.h>
#endif
-#else /* STANDALONE */
-#include "stand.h"
-#endif /* STANDALONE */
+#include <mac68k/mac68k/pram.h>
+#include <mac68k/mac68k/clockreg.h>
+#include <machine/viareg.h>
-#include "clockreg.h"
-#include "via.h"
+#ifdef DEBUG
+int clock_debug = 0;
+#endif
-static int month_days[12] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
+void rtclock_intr __P((void));
-#define DIFF19041970 2082844800
+#define DIFF19041970 2082844800
+#define DIFF19701990 630720000
+#define DIFF19702010 1261440000
/*
* Mac II machine-dependent clock routines.
*/
-
/*
- Start the real-time clock; i.e. set timer latches and boot timer.
-
- We use VIA1 timer 1.
-
+ * Start the real-time clock; i.e. set timer latches and boot timer.
+ *
+ * We use VIA1 timer 1.
*/
-void startrtclock(void)
+void
+startrtclock()
{
-/* BARF MF startrt clock is called twice in init_main, configure,
- the reason why is doced in configure */
-
- /* be certain clock interrupts are off */
- via_reg(VIA1, vIER) = V1IF_T1;
-
- /* set timer latch */
- via_reg(VIA1, vACR) |= ACR_T1LATCH;
+/*
+ * BARF MF startrt clock is called twice in init_main, configure,
+ * the reason why is doced in configure
+ */
+ /* be certain clock interrupts are off */
+ via_reg(VIA1, vIER) = V1IF_T1;
- /* set VIA timer 1 latch to 60 Hz (100 Hz) */
- via_reg(VIA1, vT1L) = CLK_INTL;
- via_reg(VIA1, vT1LH) = CLK_INTH;
+ /* set timer latch */
+ via_reg(VIA1, vACR) |= ACR_T1LATCH;
- /* set VIA timer 1 counter started for 60(100) Hz */
- via_reg(VIA1, vT1C) = CLK_INTL;
- via_reg(VIA1, vT1CH) = CLK_INTH;
+ /* set VIA timer 1 latch to 60 Hz (100 Hz) */
+ via_reg(VIA1, vT1L) = CLK_INTL;
+ via_reg(VIA1, vT1LH) = CLK_INTH;
+ /* set VIA timer 1 counter started for 60(100) Hz */
+ via_reg(VIA1, vT1C) = CLK_INTL;
+ via_reg(VIA1, vT1CH) = CLK_INTH;
}
-
-void enablertclock(void)
+void
+enablertclock()
{
- /* clear then enable clock interrupt. */
- via_reg(VIA1, vIFR) |= V1IF_T1;
- via_reg(VIA1, vIER) = 0x80 | (V1IF_ADBRDY | V1IF_T1);
+ /* clear then enable clock interrupt. */
+ via_reg(VIA1, vIFR) |= V1IF_T1;
+ via_reg(VIA1, vIER) = 0x80 | V1IF_T1;
}
+void
+cpu_initclocks()
+{
+ enablertclock();
+}
-void disablertclock(void)
+void
+setstatclockrate(rateinhz)
+ int rateinhz;
{
- /* disable clock interrupt */
- via_reg(VIA1, vIER) = V1IF_T1;
}
+void
+disablertclock()
+{
+ /* disable clock interrupt */
+ via_reg(VIA1, vIER) = V1IF_T1;
+}
/*
* Returns number of usec since last clock tick/interrupt.
@@ -155,20 +169,21 @@ void disablertclock(void)
* Check high byte twice to prevent missing a roll-over.
* (race condition?)
*/
-u_long clkread()
+u_long
+clkread()
{
- register int high, high2, low;
+ int high, high2, low;
- high = via_reg(VIA1, vT1CH);
- low = via_reg(VIA1, vT1C);
+ high = via_reg(VIA1, vT1CH);
+ low = via_reg(VIA1, vT1C);
- high2 = via_reg(VIA1, vT1CH);
- if(high != high2)
- high = high2;
+ high2 = via_reg(VIA1, vT1CH);
+ if (high != high2)
+ high = high2;
- /* return count left in timer / 1.27 */
- /* return((CLK_INTERVAL - (high << 8) - low) / CLK_SPEED); */
- return((CLK_INTERVAL - (high << 8) - low) * 10000 / 12700);
+ /* return count left in timer / 1.27 */
+ /* return((CLK_INTERVAL - (high << 8) - low) / CLK_SPEED); */
+ return ((CLK_INTERVAL - (high << 8) - low) * 10000 / 12700);
}
@@ -181,47 +196,51 @@ u_long clkread()
* be cranked higher than the real-time clock's resolution, to prevent
* aliasing and allow higher accuracy.
*/
-int profint = PRF_INTERVAL; /* Clock ticks between interrupts */
-int profinthigh;
-int profintlow;
-int profscale = 0; /* Scale factor from sys clock to prof clock */
-char profon = 0; /* Is profiling clock on? */
+int profint = PRF_INTERVAL; /* Clock ticks between interrupts */
+int profinthigh;
+int profintlow;
+int profscale = 0; /* Scale factor from sys clock to prof clock */
+char profon = 0; /* Is profiling clock on? */
/* profon values - do not change, locore.s assumes these values */
-#define PRF_NONE 0x00
-#define PRF_USER 0x01
-#define PRF_KERNEL 0x80
+#define PRF_NONE 0x00
+#define PRF_USER 0x01
+#define PRF_KERNEL 0x80
-void initprofclock(void)
+void
+initprofclock()
{
- /* profile interval must be even divisor of system clock interval */
- if(profint > CLK_INTERVAL)
- profint = CLK_INTERVAL;
- else if(CLK_INTERVAL % profint != 0)
- /* try to intelligently fix clock interval */
- profint = CLK_INTERVAL / (CLK_INTERVAL / profint);
-
- profscale = CLK_INTERVAL / profint;
-
- profinthigh = profint >> 8;
- profintlow = profint & 0xff;
+ /* profile interval must be even divisor of system clock interval */
+ if (profint > CLK_INTERVAL)
+ profint = CLK_INTERVAL;
+ else
+ if (CLK_INTERVAL % profint != 0)
+ /* try to intelligently fix clock interval */
+ profint = CLK_INTERVAL / (CLK_INTERVAL / profint);
+
+ profscale = CLK_INTERVAL / profint;
+
+ profinthigh = profint >> 8;
+ profintlow = profint & 0xff;
}
-void startprofclock(void)
+void
+startprofclock()
{
- via_reg(VIA2, vT1L) = (profint - 1) & 0xff;
- via_reg(VIA2, vT1LH) = (profint - 1) >> 8;
- via_reg(VIA2, vACR) |= ACR_T1LATCH;
- via_reg(VIA2, vT1C) = (profint - 1) & 0xff;
- via_reg(VIA2, vT1CH) = (profint - 1) >> 8;
+ via_reg(VIA2, vT1L) = (profint - 1) & 0xff;
+ via_reg(VIA2, vT1LH) = (profint - 1) >> 8;
+ via_reg(VIA2, vACR) |= ACR_T1LATCH;
+ via_reg(VIA2, vT1C) = (profint - 1) & 0xff;
+ via_reg(VIA2, vT1CH) = (profint - 1) >> 8;
}
-void stopprofclock(void)
+void
+stopprofclock()
{
- via_reg(VIA2, vT1L) = 0;
- via_reg(VIA2, vT1LH) = 0;
- via_reg(VIA2, vT1C) = 0;
- via_reg(VIA2, vT1CH) = 0;
+ via_reg(VIA2, vT1L) = 0;
+ via_reg(VIA2, vT1LH) = 0;
+ via_reg(VIA2, vT1C) = 0;
+ via_reg(VIA2, vT1CH) = 0;
}
#ifdef GPROF
@@ -231,107 +250,246 @@ void stopprofclock(void)
* profclock() is expanded in line in lev6intr() unless profiling kernel.
* Assumes it is called with clock interrupts blocked.
*/
-void profclock(pc, ps)
- caddr_t pc;
- int ps;
+void
+profclock(pclk)
+ clockframe *pclk;
{
- /*
- * Came from user mode.
- * If this process is being profiled record the tick.
- */
- if (USERMODE(ps)) {
- if (p->p_stats.p_prof.pr_scale)
- addupc(pc, &curproc->p_stats.p_prof, 1);
- }
- /*
- * Came from kernel (supervisor) mode.
- * If we are profiling the kernel, record the tick.
- */
- else if (profiling < 2) {
- register int s = pc - s_lowpc;
-
- if (s < s_textsize)
- kcount[s / (HISTFRACTION * sizeof (*kcount))]++;
- }
- /*
- * Kernel profiling was on but has been disabled.
- * Mark as no longer profiling kernel and if all profiling done,
- * disable the clock.
- */
- if (profiling && (profon & PRF_KERNEL)) {
- profon &= ~PRF_KERNEL;
- if (profon == PRF_NONE)
- stopprofclock();
- }
+ /*
+ * Came from user mode.
+ * If this process is being profiled record the tick.
+ */
+ if (USERMODE(pclk->ps)) {
+ if (p->p_stats.p_prof.pr_scale)
+ addupc_task(&curproc, pclk->pc, 1);
+ }
+ /*
+ * Came from kernel (supervisor) mode.
+ * If we are profiling the kernel, record the tick.
+ */
+ else
+ if (profiling < 2) {
+ int s = pclk->pc - s_lowpc;
+
+ if (s < s_textsize)
+ kcount[s / (HISTFRACTION * sizeof(*kcount))]++;
+ }
+ /*
+ * Kernel profiling was on but has been disabled.
+ * Mark as no longer profiling kernel and if all profiling done,
+ * disable the clock.
+ */
+ if (profiling && (profon & PRF_KERNEL)) {
+ profon &= ~PRF_KERNEL;
+ if (profon == PRF_NONE)
+ stopprofclock();
+ }
}
#endif
#endif
-#if defined(BARF_ON_YOUR_SHOES)
-static int got_timezone = 0;
-#endif
+static u_long ugmt_2_pramt __P((u_long));
+static u_long pramt_2_ugmt __P((u_long));
/*
- * convert a Mac PRAM time value to GMT, using /etc/TIMEZONE.
+ * Convert GMT to Mac PRAM time, using rtc_offset
+ * GMT bias adjustment is done elsewhere.
*/
-u_long ugmt_2_pramt(u_long t)
+static u_long
+ugmt_2_pramt(t)
+ u_long t;
{
- /* don't know how to open a file properly. */
- /* assume compiled timezone is correct. */
+ /* don't know how to open a file properly. */
+ /* assume compiled timezone is correct. */
- return(t = t + DIFF19041970 - tz.tz_minuteswest );
+ return (t = t + DIFF19041970 - 60 * rtc_offset);
}
/*
- * convert GMT to Mac PRAM time, using global timezone
+ * Convert a Mac PRAM time value to GMT, using rtc_offset
+ * GMT bias adjustment is done elsewhere.
*/
-u_long pramt_2_ugmt(u_long t)
+static u_long
+pramt_2_ugmt(t)
+ u_long t;
{
- return(t = t - DIFF19041970 + tz.tz_minuteswest);
+ return (t = t - DIFF19041970 + 60 * rtc_offset);
}
/*
+ * Time from the booter.
+ */
+u_long macos_boottime;
+
+/*
+ * Bias in minutes east from GMT (also from booter).
+ */
+long macos_gmtbias;
+
+/*
+ * Flag for whether or not we can trust the PRAM. If we don't
+ * trust it, we don't write to it, and we take the MacOS value
+ * that is passed from the booter (which will only be a second
+ * or two off by now).
+ */
+int mac68k_trust_pram = 1;
+
+/*
* Set global GMT time register, using a file system time base for comparison
* and sanity checking.
*/
-void inittodr(time_t base)
+void
+inittodr(base)
+ time_t base;
{
- u_long timbuf;
- u_long pramtime;
-
- pramtime = pram_readtime();
- timbuf = pramt_2_ugmt(pramtime);
-
- if (base < 5*SECYR) {
- printf("WARNING: file system time earlier than 1975\n");
- printf(" -- CHECK AND RESET THE DATE!\n");
- base = 21 * SECYR; /* 1991 is our sane date */
- }
-
- if (base > 40*SECYR) {
- printf("WARNING: file system time later than 2010\n");
- printf(" -- CHECK AND RESET THE DATE!\n");
- base = 21 * SECYR; /* 1991 is our sane date */
- }
-
- if(timbuf < base){
- printf("WARNING: Battery clock has earlier time than UNIX fs.\n");
- if(((u_long)base) < (40 * SECYR)) /* the year 2010. Let's hope MacBSD */
- /* doesn't run that long! */
- timbuf = base;
- }
-
- time.tv_sec = timbuf;
- time.tv_usec = 0; /* clear usec; Mac's PRAM clock stores only seconds */
+ u_long timbuf;
+
+ timbuf = pramt_2_ugmt(pram_readtime());
+ if ((timbuf - (macos_boottime + 60 * rtc_offset)) > 10 * 60) {
+#if DIAGNOSTIC
+ printf(
+ "PRAM time does not appear to have been read correctly.\n");
+ printf("PRAM: 0x%lx, macos_boottime: 0x%lx.\n",
+ timbuf, macos_boottime + 60 * rtc_offset);
+#endif
+ timbuf = macos_boottime;
+ mac68k_trust_pram = 0;
+ }
+#ifdef DIAGNOSTIC
+ else
+ printf("PRAM: 0x%lx, macos_boottime: 0x%lx.\n",
+ timbuf, macos_boottime);
+#endif
+
+ /*
+ * GMT bias is passed in from Booter
+ * To get GMT, *subtract* GMTBIAS from *our* time
+ * (gmtbias is in minutes, mult by 60)
+ */
+ timbuf -= macos_gmtbias * 60;
+
+ if (base < 5 * SECYR) {
+ printf("WARNING: file system time earlier than 1975\n");
+ printf(" -- CHECK AND RESET THE DATE!\n");
+ base = 21 * SECYR; /* 1991 is our sane date */
+ }
+ /*
+ * Check sanity against the year 2010. Let's hope NetBSD/mac68k
+ * doesn't run that long!
+ */
+ if (base > 40 * SECYR) {
+ printf("WARNING: file system time later than 2010\n");
+ printf(" -- CHECK AND RESET THE DATE!\n");
+ base = 21 * SECYR; /* 1991 is our sane date */
+ }
+ if (timbuf < base) {
+ printf(
+ "WARNING: Battery clock has earlier time than UNIX fs.\n");
+ if (((u_long) base) < (40 * SECYR))
+ timbuf = base;
+ }
+ time.tv_sec = timbuf;
+ time.tv_usec = 0;
}
/*
* Set battery backed clock to a new time, presumably after someone has
* changed system time.
*/
-void resettodr(void)
+void
+resettodr()
+{
+ if (mac68k_trust_pram)
+ /*
+ * GMT bias is passed in from the Booter.
+ * To get *our* time, add GMTBIAS to GMT.
+ * (gmtbias is in minutes, multiply by 60).
+ */
+ pram_settime(ugmt_2_pramt(time.tv_sec + macos_gmtbias * 60));
+#ifdef DEBUG
+ else if (clock_debug)
+ printf("NetBSD/mac68k does not trust itself to try and write "
+ "to the PRAM on this system.\n");
+#endif
+}
+
+
+/*
+ * The Macintosh timers decrement once every 1.2766 microseconds.
+ * MGFH2, p. 180
+ */
+#define CLK_RATE 12766
+
+#define DELAY_CALIBRATE (0xffffff << 7) /* Large value for calibration */
+
+u_int delay_factor = DELAY_CALIBRATE;
+volatile int delay_flag = 1;
+
+int _delay __P((u_int));
+static void delay_timer1_irq __P((void *));
+
+static void
+delay_timer1_irq(dummy)
+ void *dummy;
{
- if(!pram_settime(ugmt_2_pramt(time.tv_sec)))
- printf("WARNING: cannot set battery-backed clock.\n");
+ delay_flag = 0;
}
+/*
+ * Calibrate delay_factor with VIA1 timer T1.
+ */
+void
+mac68k_calibrate_delay()
+{
+ u_int sum, n;
+
+ /* Disable VIA1 timer 1 interrupts and set up service routine */
+ via_reg(VIA1, vIER) = V1IF_T1;
+ via1_register_irq(VIA1_T1, delay_timer1_irq, NULL);
+
+ /* Set the timer for one-shot mode, then clear and enable interrupts */
+ via_reg(VIA1, vACR) &= ~ACR_T1LATCH;
+ via_reg(VIA1, vIFR) = V1IF_T1; /* (this is needed for IIsi) */
+ via_reg(VIA1, vIER) = 0x80 | V1IF_T1;
+
+#ifdef DEBUG
+ if (clock_debug)
+ printf("mac68k_calibrate_delay(): entering timing loop\n");
+#endif
+
+ for (sum = 0, n = 8; n > 0; n--) {
+ delay_flag = 1;
+ via_reg(VIA1, vT1C) = 0; /* 1024 clock ticks */
+ via_reg(VIA1, vT1CH) = 4; /* (approx 1.3 msec) */
+ sum += ((delay_factor >> 7) - _delay(1));
+ }
+
+ /* Disable timer interrupts and reset service routine */
+ via_reg(VIA1, vIER) = V1IF_T1;
+ via1_register_irq(VIA1_T1, (void (*)(void *))rtclock_intr, NULL);
+
+ /*
+ * If this weren't integer math, the following would look
+ * a lot prettier. It should really be something like
+ * this:
+ * delay_factor = ((sum / 8) / (1024 * 1.2766)) * 128;
+ * That is, average the sum, divide by the number of usec,
+ * and multiply by a scale factor of 128.
+ *
+ * We can accomplish the same thing by simplifying and using
+ * shifts, being careful to avoid as much loss of precision
+ * as possible. (If the sum exceeds UINT_MAX/10000, we need
+ * to rearrange the calculation slightly to do this.)
+ */
+ if (sum > (UINT_MAX / 10000)) /* This is a _fast_ machine! */
+ delay_factor = (((sum >> 3) * 10000) / CLK_RATE) >> 3;
+ else
+ delay_factor = (((sum * 10000) >> 3) / CLK_RATE) >> 3;
+
+ /* Reset the delay_flag for normal use */
+ delay_flag = 1;
+
+#ifdef DEBUG
+ if (clock_debug)
+ printf("mac68k_calibrate_delay(): delay_factor calibrated\n");
+#endif
+}
View
3,538 sys/arch/mac68k/mac68k/locore.s
1,401 additions, 2,137 deletions not shown
View
3,895 sys/arch/mac68k/mac68k/machdep.c
2,365 additions, 1,530 deletions not shown
View
337 sys/arch/mac68k/nubus/nubus.h
@@ -1,8 +1,7 @@
-/*-
- * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
- * Michael L. Finch, Bradley A. Grantham, and
- * Lawrence A. Kesteloot
- * All rights reserved.
+/* $NetBSD: nubus.h,v 1.44.12.1 1999/11/30 13:32:42 itojun Exp $ */
+
+/*
+ * Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -14,74 +13,290 @@
* 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 product includes software developed by Allen Briggs.
+ * 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 ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
+ * 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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * 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.
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Nubus cards in Macintoshes are identified by 4 16-bit numbers:
+ * Category: What is the main purpose of this card?
+ * Type: Within this overall category, what kind of card?
+ * DrSW: What software interface does it use?
+ * DrHW: What specific hardware is it?
*
+ * For example, the "Toby Frame Buffer" display card is
+ * Category 3 (display)
+ * Type 1 (video)
+ * DrSW 1 (Apple)
+ * and DrHW 1 (TFB).
*/
-#ident "$Id: nubus.h,v 1.1.1.1 1993/09/29 06:09:25 briggs Exp $"
-
-#define NUBUS_VIDEO 3
-#define NUBUS_NETWORK 4
-#define NUBUS_MOTHERBOARD 0x0a
-
-struct imagedata{
- long whatTheHellIsThis;
- long offset;
- short rowbytes;
- short top;
- short left;
- short right;
- short bottom;
- short version;
- short packType;
- short packSize;
- long hRes;
- long vRes;
- short pixelType;
- short pixelSize;
-};
+#include <machine/cpu.h>
+
+#define NUBUS_CATEGORY_BOARD 0x0001
+
+#define NUBUS_CATEGORY_DISPLAY 0x0003
+#define NUBUS_TYPE_VIDEO 0x0001
+#define NUBUS_TYPE_LCD 0x0002
+#define NUBUS_DRSW_APPLE 0x0001
+#define NUBUS_DRHW_TFB 0x0001 /* Apple Toby Frame Buffer */
+#define NUBUS_DRHW_WVC 0x0006 /* Apple Workstation Video Card */
+#define NUBUS_DRHW_COLORMAX 0x0007 /* Sigma Designs ColorMax */
+#define NUBUS_DRHW_SE30 0x0009 /* Apple SE/30 pseudo-slot video */
+#define NUBUS_DRHW_M2HRVC 0x0013 /* Apple Mac II High-Res Video Card */
+#define NUBUS_DRHW_PVC 0x0017 /* Apple Mac II Portrait Video Card */
+#define NUBUS_DRHW_MDC 0x0019 /* Apple Macintosh Display Card */
+#define NUBUS_DRHW_SUPRGFX 0x0105 /* SuperMac GFX */
+#define NUBUS_DRHW_FORMAC 0x013A /* Formac color card II */
+#define NUBUS_DRHW_CB264 0x013B /* RasterOps ColorBoard 264 */
+#define NUBUS_DRHW_MICRON 0x0146
+#define NUBUS_DRHW_SPECTRM8 0x017b /* SuperMac Spectrum/8 Series III */
+#define NUBUS_DRHW_SPECTRUM 0x017c /* SuperMac Spectrum/24 Series III */
+#define NUBUS_DRHW_VIMAGE 0x026E /* Interware Co., Ltd. Vimage */
+#define NUBUS_DRHW_CB364 0x026F /* RasterOps ColorBoard 364 */
+#define NUBUS_DRHW_RPC8 0x0291 /* Radius PrecisionColor 8 */
+#define NUBUS_DRHW_LAPIS 0x0292 /* SE/30 Lapis ProColorServer 8 PDS */
+#define NUBUS_DRHW_ROPS24LXI 0x02A0 /* RasterOps 8/24 XLi */
+#define NUBUS_DRHW_FUTURASX 0x02AE /* E-Machines Futura-SX */
+#define NUBUS_DRHW_ROPS24XLTV 0x02B7 /* E-Machines Futura-SX */
+#define NUBUS_DRHW_THUNDER24 0x02CB /* SuperMac Thunder/24 */
+#define NUBUS_DRHW_GVIMAGE 0x03FB /* Interware Co., Ltd. Grand Vimage */
+#define NUBUS_DRHW_RPC24XP 0x0406 /* Radius PrecisionColor 24Xp */
+#define NUBUS_DRHW_RPC24X 0x040A /* Radius PrecisionColor 24X */
+#define NUBUS_DRHW_RPC8XJ 0x040B /* Radius PrecisionColor 8xj */
+#define NUBUS_DRHW_FIILX 0x0417 /* Futura II LX */
+#define NUBUS_DRHW_FIISXDSP 0x042F /* Futura II SX/DSP */
+#define NUBUS_DRHW_MC2124NB 0x0462 /* MicroConversions 2124NB II */
+
+/* False DrHW values for video cards masquerading as other cards */
+#define NUBUS_DRHW_SAM768 0x10000 /* Cornerstone/Samsung 768x1006 */
+
+#define NUBUS_CATEGORY_NETWORK 0x0004
+#define NUBUS_TYPE_ETHERNET 0x0001
+#define NUBUS_DRSW_3COM 0x0000
+#define NUBUS_DRSW_CABLETRON 0x0001
+#define NUBUS_DRSW_GATOR 0x0103
+#define NUBUS_DRSW_ASANTE 0x0104
+#define NUBUS_DRSW_TECHWORKS 0x0109
+#define NUBUS_DRSW_DAYNA 0x010B
+#define NUBUS_DRSW_FARALLON 0x010C
+#define NUBUS_DRSW_DAYNA2 0x0115
+#define NUBUS_DRSW_FOCUS 0x011A
+#define NUBUS_DRSW_TFLLAN 0x011E
+#define NUBUS_DRHW_INTERLAN 0x0100
+#define NUBUS_DRHW_KINETICS 0x0106
+#define NUBUS_DRHW_CABLETRON 0x0109
+#define NUBUS_DRHW_ASANTE_LC 0x010F
+#define NUBUS_DRHW_SONIC 0x0110
+#define NUBUS_DRHW_TECHWORKS 0x0112
+#define NUBUS_DRHW_APPLE_SNT 0x0118
+#define NUBUS_DRHW_APPLE_SN 0x0119
+
+#define NUBUS_CATEGORY_COMMUNICATIONS 0x0006
+#define NUBUS_TYPE_RS232 0x0002
+#define NUBUS_DRSW_HDS 0x0102
+#define NUBUS_DRHW_HDS 0x0102
+
+#define NUBUS_CATEGORY_FONT 0x0009 /* KanjiTalk Font Card? */
+
+#define NUBUS_CATEGORY_CPU 0x000A
+#define NUBUS_TYPE_68000 0x0002
+#define NUBUS_TYPE_68020 0x0003
+#define NUBUS_TYPE_68030 0x0004
+#define NUBUS_TYPE_68040 0x0005
+
+#define NUBUS_CATEGORY_INTBUS 0x000C
+#define NUBUS_TYPE_SCSI 0x0008
+#define NUBUS_DRSW_PLI 0x0108
+#define NUBUS_DRHW_PLI 0x0100
+
+/*
+ * This is the same as Apple's Format Block for a card, with the
+ * addition of a pointer to the base of the NuBUS slot.
+ *
+ * This basically describes a nubus card--this structure is held in the last
+ * N bytes of each valid card's declaration ROM.
+ */
+typedef struct _nubus_slot {
+ u_long top;
+ u_int8_t slot;
+ u_int8_t bytelanes;
+ u_int8_t step;
+ u_int32_t test_pattern;
+ u_int8_t format;
+ u_int8_t revision_level;
+ u_int32_t crc;
+ u_int32_t length;
+ u_int32_t directory_offset;
+} nubus_slot;
+
+/*
+ * Just a structure to ease comparison of type for drivers, etc.
+ */
+typedef struct _nubus_type {
+ u_int16_t category;
+ u_int16_t type;
+ u_int16_t drsw;
+ u_int16_t drhw;
+} nubus_type;
+
+/*
+ * nubus_dir is a structure that describes a nubus directory.
+ * The nubus*dir() functions should be used to traverse this.
+ */
+typedef struct _nubus_dir {
+ u_int32_t dirbase;
+ u_int32_t curr_ent;
+} nubus_dir;
+
+/*
+ * This is the equivalent of an Apple sResource directory entry
+ * with the addition of a pointer to itself (essentially) for easy
+ * calculation of jump to indirect data.
+ */
+typedef struct _nubus_dirent {
+ u_int32_t myloc;
+ u_int8_t rsrc_id;
+ u_int32_t offset;
+} nubus_dirent;
+
+/*
+ * This is the equivalent of an Apple sResource with the addition of
+ * a pointer back to the sResource directory from whence we came.
+ *
+ * According to the Apple documentation, each sResource is of one of the
+ * following forms:
+ * all: bits 31-24 Identification number
+ *
+ * offset: bits 23-0 Offset to long data, cString, sBlock, etc.
+ * word: bits 23-16 0x00
+ * bits 15-0 word data
+ * byte: bits 23-8 0x0000
+ * bits 7-0 byte data
+ *
+ * The last resource has id = 0xff and data = 0x000000.
+ */
+typedef struct _nubus_rsrc {
+ u_int32_t myloc;
+ u_int8_t id;
+ u_int32_t data;
+} nubus_rsrc;
+
+/* Resource IDs for NUBUS_CATEGORY_* (All) */
+#define NUBUS_RSRC_TYPE 0x01 /* Type (required) */
+#define NUBUS_RSRC_NAME 0x02 /* Name (required) */
+#define NUBUS_RSRC_ICON 0x03 /* Icon */
+#define NUBUS_RSRC_DRVRDIR 0x04 /* Driver directory */
+#define NUBUS_RSRC_LOADREC 0x05 /* Load record for resource */
+#define NUBUS_RSRC_BOOTREC 0x06 /* Boot record */
+#define NUBUS_RSRC_FLAGS 0x07 /* sResource Flags */
+#define NUBUS_RSRC_HWDEVID 0x08 /* Hardware device ID */
+#define NUBUS_RSRC_MINOR_BASEOS 0x0A /* Offset to hw in std space */
+#define NUBUS_RSRC_MINOR_LENGTH 0x0B /* Length of std space */
+#define NUBUS_RSRC_MAJOR_BASEOS 0x0C /* Offset to hw in super space */
+#define NUBUS_RSRC_MAJOR_LENGTH 0x0D /* Length of super space */
+#define NUBUS_RSRC_CICN 0x0F /* Color icon */
+#define NUBUS_RSRC_ICL8 0x10 /* 8-bit icon data */
+#define NUBUS_RSRC_ICL4 0x11 /* 4-bit icon data */
+
+/* Resource IDs for NUBUS_CATEGORY_DISPLAY */
+#define NUBUS_RSRC_GAMMADIR 0x40 /* ID for gamma directory */
+#define NUBUS_RSRC_VIDNAMES 0x41 /* ID for video name directory */
+#define NUBUS_RSRC_FIRSTMODE 0x80 /* ID for first mode (1-bit) */
+#define NUBUS_RSRC_SECONDMODE 0x81 /* ID for 2nd mode (2-bit) */
+#define NUBUS_RSRC_THIRDMODE 0x82 /* ID for 3rd mode (4-bit) */
+#define NUBUS_RSRC_FOURTHMODE 0x83 /* ID for 4th mode (8-bit) */
+#define NUBUS_RSRC_FIFTHMODE 0x84 /* ID for 5th mode (16-bit) */
+#define NUBUS_RSRC_SIXTHMODE 0x85 /* ID for 6th mode (32-bit) */
+
+/* Resource IDs for NUBUS_CATEGORY_BOARD */
+#define NUBUS_RSRC_BOARDID 0x20 /* Board ID */
+#define NUBUS_RSRC_PRAMINITDATA 0x21 /* Private board data for PRAM */
+#define NUBUS_RSRC_PRIMARYINIT 0x22 /* Primary init record */
+#define NUBUS_RSRC_TIMEOUTCONST 0x23 /* Timeout constant */
+#define NUBUS_RSRC_VENDORINFO 0x24 /* Vendor info list */
+#define NUBUS_RSRC_BOARDFLAGS 0x25 /* Board flags */
+#define NUBUS_RSRC_SECONDINIT 0x26 /* Secondary init record */
-/* this is the main data structure that points to good stuff */
-struct header {
- long offset;
- long length;
- long crc;
- char romrev;
- char format;
- long tst;
- char reserved;
- char bytelane;
-} ;
-
-
-/* this is what the directory entries contain */
-struct dir {
- unsigned char rsrc;
- unsigned long offset;
- unsigned long base;
+#define NUBUS_RSRC_VEND_ID 0x01 /* Card vendor's design ID */
+#define NUBUS_RSRC_VEND_SERIAL 0x02 /* Card's serial number */
+#define NUBUS_RSRC_VEND_REV 0x03 /* Card design's revision level */
+#define NUBUS_RSRC_VEND_PART 0x04 /* Card part number */
+#define NUBUS_RSRC_VEND_DATE 0x05 /* Card revision date */
+
+typedef struct _NUBUS_DRIVER {
+ u_int8_t drvr_id;
+ u_int32_t offset;
+} NUBUS_DRIVER;
+
+typedef struct _NUBUS_BLOCK {
+ u_int32_t size; /* Size of block of data */
+ caddr_t data; /* Pointer to data */
+} NUBUS_BLOCK;
+
+typedef struct _NUBUS_EXEC_BLOCK {
+ u_int32_t size; /* Size of total block - 4 */
+ u_int8_t revision; /* Always 0x2 */
+ u_int8_t cpu; /* Which processor? */
+ u_int32_t code_offset; /* Offset base to start of code */
+ caddr_t code; /* pointer to base of code. */
+} NUBUS_EXEC_BLOCK;
+
+#define NUBUS_EXEC_CPU_68000 1
+#define NUBUS_EXEC_CPU_68020 2
+#define NUBUS_EXEC_CPU_68030 3
+#define NUBUS_EXEC_CPU_68040 4
+
+#define NUBUS_MIN_SLOT 0x9
+#define NUBUS_MAX_SLOT 0xE
+#define NUBUS_ROM_TEST_PATTERN 0x5A932BC7
+
+#define NUBUS_SLOT2PA(x) (0xf9000000 + \
+ ((((x) - NUBUS_MIN_SLOT) & 0xf) << 24))
+
+struct nubus_attach_args {
+ bus_space_tag_t na_tag;
+ int slot;
+ int rsrcid;
+ u_int16_t category;
+ u_int16_t type;
+ u_int16_t drsw;
+ u_int16_t drhw;
+ nubus_slot *fmt;
};
-/* describe a single slot */
-struct slot {
- int size;
- struct header head;
- struct dir mainDir[15];
- long type;
- char name[40];
- char manufacturer[40];
+struct nubus_softc {
+ struct device sc_dev;
};
+void nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
+void nubus_get_dir_from_rsrc __P((nubus_slot *slot, nubus_dirent *dirent,
+ nubus_dir *dir_return));
+
+int nubus_find_rsrc __P((bus_space_tag_t, bus_space_handle_t,
+ nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
+ nubus_dirent *dirent_return));
+int nubus_get_ind_data __P((bus_space_tag_t, bus_space_handle_t,
+ nubus_slot *slot, nubus_dirent *dirent,
+ caddr_t data_return, int nbytes));
+int nubus_get_c_string __P((bus_space_tag_t, bus_space_handle_t,
+ nubus_slot *slot, nubus_dirent *dirent,
+ caddr_t data_return, int max_bytes));
+
+char *nubus_get_vendor __P((bus_space_tag_t, bus_space_handle_t,
+ nubus_slot *slot, int rsrc));
+char *nubus_get_card_name __P((bus_space_tag_t, bus_space_handle_t,
+ nubus_slot *slot));
+void nubus_scan_slot __P((bus_space_tag_t, int));
Please sign in to comment.
Something went wrong with that request. Please try again.