Source-Changes-HG archive

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

[src/perseant-stdc-iso10646]: src/sys/arch/macppc/macppc 2551550



details:   https://anonhg.NetBSD.org/src/rev/d004c5c78877
branches:  perseant-stdc-iso10646
changeset: 850628:d004c5c78877
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Jul 14 21:36:20 2017 +0000

description:
2551550

diffstat:

 sys/arch/macppc/macppc/machdep.c |  489 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 489 insertions(+), 0 deletions(-)

diffs (truncated from 493 to 300 lines):

diff -r cf7a19e15c97 -r d004c5c78877 sys/arch/macppc/macppc/machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/macppc/machdep.c  Fri Jul 14 21:36:20 2017 +0000
@@ -0,0 +1,489 @@
+/*     $NetBSD: machdep.c,v 1.165.2.2 2017/07/14 21:36:20 macallan Exp $       */
+
+/*
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165.2.2 2017/07/14 21:36:20 macallan Exp $");
+
+#include "opt_compat_netbsd.h"
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_ipkdb.h"
+#include "opt_altivec.h"
+#include "opt_multiprocessor.h"
+#include "adb.h"
+#include "zsc.h"
+
+#include <sys/param.h>
+#include <sys/buf.h>
+#include <sys/boot_flag.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/exec.h>
+#include <sys/kernel.h>
+#include <sys/ksyms.h>
+#include <sys/mbuf.h>
+#include <sys/mount.h>
+#include <sys/msgbuf.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <sys/syscallargs.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+
+#ifdef DDB
+#include <powerpc/db_machdep.h>
+#include <ddb/db_extern.h>
+#endif
+
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
+ 
+#ifdef IPKDB
+#include <ipkdb/ipkdb.h>
+#endif
+
+#include <dev/ofw/openfirm.h>
+#include <dev/wsfb/genfbvar.h>
+
+#include <machine/autoconf.h>
+#include <machine/powerpc.h>
+
+#include <powerpc/trap.h>
+#include <powerpc/fpu.h>
+#include <powerpc/oea/bat.h>
+#include <powerpc/spr.h>
+#ifdef ALTIVEC
+#include <powerpc/altivec.h>
+#endif
+#include <powerpc/ofw_cons.h>
+
+#include <powerpc/pic/picvar.h>
+#ifdef MULTIPROCESSOR
+#include <powerpc/pic/ipivar.h>
+#endif
+
+#include <macppc/dev/adbvar.h>
+#include <macppc/dev/pmuvar.h>
+#include <macppc/dev/cudavar.h>
+#include <macppc/dev/smuvar.h>
+
+#include <macppc/macppc/static_edid.h>
+
+#include "ksyms.h"
+#include "pmu.h"
+#include "cuda.h"
+#include "smu.h"
+
+struct genfb_colormap_callback gfb_cb;
+struct genfb_parameter_callback gpc_backlight, gpc_brightness;
+
+/*
+ * OpenFirmware gives us no way to check the brightness level or the backlight
+ * state so we assume the backlight is on and about 4/5 up which seems 
+ * reasonable for most laptops
+ */
+
+int backlight_state = 1;
+int brightness_level = 200;
+
+static void of_set_palette(void *, int, int, int, int);
+static void add_model_specifics(prop_dictionary_t);
+static int of_get_backlight(void *, int *);
+static int of_set_backlight(void *, int);
+static int of_get_brightness(void *, int *);
+static int of_set_brightness(void *, int);
+static int of_upd_brightness(void *, int);
+
+void
+initppc(u_int startkernel, u_int endkernel, char *args)
+{
+       ofwoea_initppc(startkernel, endkernel, args);
+}
+
+/* perform model-specific actions at initppc() */
+void
+model_init(void)
+{
+}
+
+void
+consinit(void)
+{
+       ofwoea_consinit();
+}
+
+/*
+ * Machine dependent startup code.
+ */
+void
+cpu_startup(void)
+{
+       oea_startup(NULL);
+}
+
+/*
+ * Crash dump handling.
+ */
+
+void
+dumpsys(void)
+{
+       printf("dumpsys: TBD\n");
+}
+
+/*
+ * Halt or reboot the machine after syncing/dumping according to howto.
+ */
+void
+cpu_reboot(int howto, char *what)
+{
+       static int syncing;
+       static char str[256];
+       char *ap = str, *ap1 = ap;
+
+       /*
+        * Enable external interrupts in case someone is rebooting
+        * from a strange context via ddb.
+        */
+       mtmsr(mfmsr() | PSL_EE);
+
+       boothowto = howto;
+       if (!cold && !(howto & RB_NOSYNC) && !syncing) {
+               syncing = 1;
+               vfs_shutdown();         /* sync */
+               resettodr();            /* set wall clock */
+       }
+
+#ifdef MULTIPROCESSOR
+       /* Halt other CPU */
+       cpu_send_ipi(IPI_DST_NOTME, IPI_HALT);
+       delay(100000);  /* XXX */
+#endif
+
+       splhigh();
+
+       if (!cold && (howto & RB_DUMP))
+               dumpsys();
+
+       doshutdownhooks();
+
+       pmf_system_shutdown(boothowto);
+
+       if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
+               delay(1000000);
+#if NCUDA > 0
+               cuda_poweroff();
+#endif
+#if NPMU > 0
+               pmu_poweroff();
+#endif
+#if NADB > 0
+               adb_poweroff();
+               printf("WARNING: powerdown failed!\n");
+#endif
+#if NSMU > 0
+               smu_poweroff();
+#endif
+       }
+
+       if (howto & RB_HALT) {
+               printf("halted\n\n");
+
+               /* flush cache for msgbuf */
+               __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
+
+               ppc_exit();
+       }
+
+       printf("rebooting\n\n");
+       if (what && *what) {
+               if (strlen(what) > sizeof str - 5)
+                       printf("boot string too large, ignored\n");
+               else {
+                       strcpy(str, what);
+                       ap1 = ap = str + strlen(str);
+                       *ap++ = ' ';
+               }
+       }
+       *ap++ = '-';
+       if (howto & RB_SINGLE)
+               *ap++ = 's';
+       if (howto & RB_KDB)
+               *ap++ = 'd';
+       *ap++ = 0;
+       if (ap[-2] == '-')
+               *ap1 = 0;
+
+       /* flush cache for msgbuf */
+       __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
+
+#if NCUDA > 0
+       cuda_restart();
+#endif
+#if NPMU > 0
+       pmu_restart();
+#endif
+#if NADB > 0
+       adb_restart();  /* not return */
+#endif
+#if NSMU > 0
+       smu_restart();
+#endif
+       ppc_exit();
+}
+
+#if 0
+/*
+ * OpenFirmware callback routine
+ */
+void
+callback(void *p)
+{
+       panic("callback");      /* for now                      XXX */
+}
+#endif
+
+void
+copy_disp_props(device_t dev, int node, prop_dictionary_t dict)
+{
+       char name[32];
+       uint32_t temp;
+       uint64_t cmap_cb, backlight_cb, brightness_cb;
+       int have_backlight = 0;
+#ifdef PMAC_G5
+       int have_palette = 0;
+#else
+       int have_palette = 1;
+#endif
+       if (node != console_node) {
+               /*
+                * see if any child matches since OF attaches nodes for
+                * each head and /chosen/stdout points to the head
+                * rather than the device itself in this case
+                */
+               int sub;



Home | Main Index | Thread Index | Old Index