[BACK]Return to machdep.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / ibmnws / ibmnws

Annotation of src/sys/arch/ibmnws/ibmnws/machdep.c, Revision 1.9.20.1

1.9.20.1! yamt        1: /*     $NetBSD: machdep.c,v 1.9 2007/10/17 19:55:01 garbled Exp $      */
1.1       matt        2:
                      3: /*
                      4:  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
                      5:  * Copyright (C) 1995, 1996 TooLs GmbH.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by TooLs GmbH.
                     19:  * 4. The name of TooLs GmbH may not be used to endorse or promote products
                     20:  *    derived from this software without specific prior written permission.
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
                     23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     25:  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     26:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     27:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     28:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     29:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     30:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                     31:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     32:  */
                     33:
1.9       garbled    34: #include <sys/cdefs.h>
1.9.20.1! yamt       35: __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2007/10/17 19:55:01 garbled Exp $");
1.9       garbled    36:
1.1       matt       37: #include "opt_compat_netbsd.h"
                     38:
                     39: #include <sys/param.h>
                     40: #include <sys/buf.h>
                     41: #include <sys/conf.h>
                     42: #include <sys/device.h>
                     43: #include <sys/exec.h>
                     44: #include <sys/extent.h>
                     45: #include <sys/kernel.h>
                     46: #include <sys/malloc.h>
                     47: #include <sys/mbuf.h>
                     48: #include <sys/mount.h>
                     49: #include <sys/msgbuf.h>
                     50: #include <sys/proc.h>
                     51: #include <sys/reboot.h>
                     52: #include <sys/syscallargs.h>
                     53: #include <sys/syslog.h>
                     54: #include <sys/systm.h>
                     55: #include <sys/user.h>
                     56:
                     57: #include <uvm/uvm_extern.h>
                     58:
                     59: #include <sys/sysctl.h>
                     60:
                     61: #include <net/netisr.h>
                     62:
                     63: #include <machine/autoconf.h>
                     64: #include <machine/bus.h>
                     65: #include <machine/intr.h>
                     66: #include <machine/pmap.h>
                     67: #include <machine/powerpc.h>
                     68: #include <machine/trap.h>
1.2       matt       69:
                     70: #include <powerpc/oea/bat.h>
1.9       garbled    71: #include <arch/powerpc/pic/picvar.h>
1.9.20.1! yamt       72: #include <arch/powerpc/include/pio.h>
        !            73: #include <dev/pci/pcivar.h>
        !            74: #include <dev/ic/ibm82660reg.h>
1.1       matt       75:
                     76: #include <dev/cons.h>
                     77:
                     78: void initppc(u_long, u_long, u_int, void *);
                     79: void dumpsys(void);
                     80: vaddr_t prep_intr_reg;                 /* PReP interrupt vector register */
                     81:
                     82: #define        OFMEMREGIONS    32
                     83: struct mem_region physmemr[OFMEMREGIONS], availmemr[OFMEMREGIONS];
                     84:
                     85: paddr_t avail_end;                     /* XXX temporary */
1.9       garbled    86: struct pic_ops *isa_pic;
                     87: int isa_pcmciamask = 0x8b28;
1.1       matt       88:
                     89: void
1.6       rjs        90: initppc(u_long startkernel, u_long endkernel, u_int args, void *btinfo)
1.1       matt       91: {
                     92:
1.9.20.1! yamt       93:        uint32_t sa, ea, banks;
        !            94:        u_long memsize = 0;
        !            95:        pcitag_t tag;
        !            96:
1.1       matt       97:        /*
1.9.20.1! yamt       98:         * Set memory region by reading the memory size from the PCI
        !            99:         * host bridge.
1.1       matt      100:         */
                    101:
1.9.20.1! yamt      102:        tag = genppc_pci_indirect_make_tag(NULL, 0, 0, 0);
        !           103:
        !           104:        out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK0_START);
        !           105:        sa = in32rb(PCI_MODE1_DATA_REG);
        !           106:
        !           107:        out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK0_END);
        !           108:        ea = in32rb(PCI_MODE1_DATA_REG);
        !           109:
        !           110:        /* Which memory banks are enabled? */
        !           111:        out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK_ENABLE);
        !           112:        banks = in32rb(PCI_MODE1_DATA_REG) & 0xFF;
        !           113:
        !           114:        /* Reset the register for the next call. */
        !           115:        out32rb(PCI_MODE1_ADDRESS_REG, 0);
        !           116:
        !           117:        if (banks & IBM_82660_MEM_BANK0_ENABLED)
        !           118:                memsize += IBM_82660_BANK0_ADDR(ea) - IBM_82660_BANK0_ADDR(sa) + 1;
        !           119:
        !           120:        if (banks & IBM_82660_MEM_BANK1_ENABLED)
        !           121:                memsize += IBM_82660_BANK1_ADDR(ea) - IBM_82660_BANK1_ADDR(sa) + 1;
        !           122:
        !           123:        if (banks & IBM_82660_MEM_BANK2_ENABLED)
        !           124:                memsize += IBM_82660_BANK2_ADDR(ea) - IBM_82660_BANK2_ADDR(sa) + 1;
        !           125:
        !           126:        if (banks & IBM_82660_MEM_BANK3_ENABLED)
        !           127:                memsize += IBM_82660_BANK3_ADDR(ea) - IBM_82660_BANK3_ADDR(sa) + 1;
        !           128:
        !           129:        memsize <<= 20;
        !           130:
        !           131:        physmemr[0].start = 0;
        !           132:        physmemr[0].size = memsize & ~PGOFSET;
        !           133:        availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
        !           134:        availmemr[0].size = memsize - availmemr[0].start;
1.1       matt      135:
                    136:        avail_end = physmemr[0].start + physmemr[0].size;    /* XXX temporary */
                    137:
                    138:        /*
                    139:         * Set CPU clock
                    140:         */
                    141:        {
                    142:                extern u_long ticks_per_sec, ns_per_tick;
                    143:
                    144:                ticks_per_sec = 16666666;               /* hardcoded */
                    145:                ns_per_tick = 1000000000 / ticks_per_sec;
                    146:        }
                    147:
                    148:        /*
                    149:         * boothowto
                    150:         */
                    151:        boothowto = 0;          /* XXX - should make this an option */
                    152:
1.9       garbled   153:        prep_initppc(startkernel, endkernel, args);
1.1       matt      154: }
                    155:
                    156: /*
                    157:  * Machine dependent startup code.
                    158:  */
                    159: void
1.6       rjs       160: cpu_startup(void)
1.1       matt      161: {
                    162:        /*
                    163:         * Mapping PReP interrput vector register.
                    164:         */
                    165:        prep_intr_reg = (vaddr_t) mapiodev(PREP_INTR_REG, PAGE_SIZE);
                    166:        if (!prep_intr_reg)
                    167:                panic("startup: no room for interrupt register");
1.9       garbled   168:        prep_intr_reg_off = INTR_VECTOR_REG;
1.1       matt      169:
                    170:        /*
                    171:         * Do common startup.
                    172:         */
                    173:        oea_startup("IBM NetworkStation 1000 (8362-XXX)");
                    174:
1.9.20.1! yamt      175:        pic_init();
1.9       garbled   176:        isa_pic = setup_prepivr(PIC_IVR_IBM);
                    177:
                    178:         oea_install_extint(pic_ext_intr);
                    179:
1.6       rjs       180:        /*
1.1       matt      181:         * Now allow hardware interrupts.
                    182:         */
                    183:        {
                    184:                int msr;
                    185:
                    186:                splraise(-1);
1.4       perry     187:                __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
1.1       matt      188:                              : "=r"(msr) : "K"(PSL_EE));
                    189:        }
                    190:
                    191:        /*
                    192:         * Now safe for bus space allocation to use malloc.
                    193:         */
                    194:        bus_space_mallocok();
                    195: }
                    196:
                    197: /*
                    198:  * Halt or reboot the machine after syncing/dumping according to howto.
                    199:  */
                    200: void
1.6       rjs       201: cpu_reboot(int howto, char *what)
1.1       matt      202: {
                    203:        static int syncing;
                    204:
                    205:        if (cold) {
                    206:                howto |= RB_HALT;
                    207:                goto halt_sys;
                    208:        }
                    209:
                    210:        boothowto = howto;
                    211:        if ((howto & RB_NOSYNC) == 0 && syncing == 0) {
                    212:                syncing = 1;
                    213:                vfs_shutdown();         /* sync */
                    214:                resettodr();            /* set wall clock */
                    215:        }
                    216:
                    217:        /* Disable intr */
                    218:        splhigh();
                    219:
                    220:        /* Do dump if requested */
                    221:        if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
                    222:                oea_dumpsys();
                    223:
                    224: halt_sys:
                    225:        doshutdownhooks();
                    226:
1.9.20.1! yamt      227:        pmf_system_shutdown(boothowto);
        !           228:
1.1       matt      229:        if (howto & RB_HALT) {
1.9.20.1! yamt      230:                 aprint_normal("\n");
        !           231:                 aprint_normal("The operating system has halted.\n");
        !           232:                 aprint_normal("Please press any key to reboot.\n\n");
1.1       matt      233:                 cnpollc(1);    /* for proper keyboard command handling */
                    234:                 cngetc();
                    235:                 cnpollc(0);
                    236:        }
                    237:
1.9.20.1! yamt      238:        aprint_normal("rebooting...\n\n");
1.1       matt      239:
                    240:
                    241:         {
                    242:            int msr;
                    243:            u_char reg;
                    244:
1.5       perry     245:            __asm volatile("mfmsr %0" : "=r"(msr));
1.1       matt      246:            msr |= PSL_IP;
1.5       perry     247:            __asm volatile("mtmsr %0" :: "r"(msr));
1.1       matt      248:
                    249:            reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
                    250:            reg &= ~1UL;
                    251:            *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
                    252:
1.5       perry     253:            __asm volatile("sync; eieio\n");
1.1       matt      254:
                    255:            reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
                    256:            reg |= 1;
                    257:            *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
                    258:
1.5       perry     259:            __asm volatile("sync; eieio\n");
1.1       matt      260:        }
                    261:
                    262:        for (;;)
                    263:                continue;
                    264:        /* NOTREACHED */
                    265: }

CVSweb <webmaster@jp.NetBSD.org>