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

Annotation of src/sys/arch/amiga/amiga/machdep.c, Revision 1.239

1.239   ! rkujawa     1: /*     $NetBSD: machdep.c,v 1.238 2012/07/27 05:36:09 matt Exp $       */
1.40      cgd         2:
1.1       mw          3: /*
1.230     rmind       4:  * Copyright (c) 1988 University of Utah.
1.1       mw          5:  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to Berkeley by
                      9:  * the Systems Programming Group of the University of Utah Computer
                     10:  * Science Department.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
1.185     agc        20:  * 3. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  * from: Utah $Hdr: machdep.c 1.63 91/04/24$
                     37:  *
                     38:  *     @(#)machdep.c   7.16 (Berkeley) 6/3/91
                     39:  */
                     40:
1.116     jonathan   41: #include "opt_ddb.h"
1.120     jonathan   42: #include "opt_compat_netbsd.h"
1.182     martin     43: #include "opt_fpu_emulate.h"
                     44: #include "opt_lev6_defer.h"
                     45: #include "opt_m060sp.h"
1.215     apb        46: #include "opt_modular.h"
1.182     martin     47: #include "opt_panicbutton.h"
1.226     mrg        48: #include "opt_m68k_arch.h"
1.167     aymeric    49:
                     50: #include <sys/cdefs.h>
1.239   ! rkujawa    51: __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.238 2012/07/27 05:36:09 matt Exp $");
1.1       mw         52:
1.9       chopps     53: #include <sys/param.h>
                     54: #include <sys/systm.h>
1.148     thorpej    55: #include <sys/callout.h>
1.9       chopps     56: #include <sys/signalvar.h>
                     57: #include <sys/kernel.h>
                     58: #include <sys/proc.h>
                     59: #include <sys/buf.h>
                     60: #include <sys/reboot.h>
                     61: #include <sys/conf.h>
                     62: #include <sys/file.h>
                     63: #include <sys/malloc.h>
                     64: #include <sys/mbuf.h>
                     65: #include <sys/msgbuf.h>
1.23      chopps     66: #include <sys/vnode.h>
1.124     veego      67: #include <sys/device.h>
1.23      chopps     68: #include <sys/queue.h>
1.39      cgd        69: #include <sys/mount.h>
1.68      mhitch     70: #include <sys/core.h>
                     71: #include <sys/kcore.h>
1.181     ragge      72: #include <sys/ksyms.h>
1.227     tsutsui    73: #include <sys/module.h>
1.207     ad         74: #include <sys/cpu.h>
1.170     is         75: #include <sys/exec.h>
                     76:
1.159     is         77: #if defined(DDB) && defined(__ELF__)
                     78: #include <sys/exec_elf.h>
                     79: #endif
1.170     is         80:
                     81: #include <sys/exec_aout.h>
1.159     is         82:
1.155     cgd        83: #undef PS      /* XXX netccitt/pk.h conflict with machine/reg.h? */
1.154     mrg        84:
1.143     ragge      85: #define        MAXMEM  64*1024 /* XXX - from cmap.h */
1.121     mhitch     86: #include <uvm/uvm_extern.h>
                     87:
1.103     is         88: #include <sys/sysctl.h>
1.61      veego      89:
                     90: #include <machine/db_machdep.h>
                     91: #include <ddb/db_sym.h>
                     92: #include <ddb/db_extern.h>
                     93:
1.23      chopps     94: #include <machine/reg.h>
1.229     tsutsui    95: #include <machine/pcb.h>
1.23      chopps     96: #include <machine/psl.h>
                     97: #include <machine/pte.h>
1.68      mhitch     98: #include <machine/kcore.h>
1.23      chopps     99: #include <dev/cons.h>
1.234     rmind     100: #include <dev/mm.h>
1.23      chopps    101: #include <amiga/amiga/isr.h>
1.9       chopps    102: #include <amiga/amiga/custom.h>
1.66      is        103: #ifdef DRACO
                    104: #include <amiga/amiga/drcustom.h>
1.122     is        105: #include <m68k/include/asm_single.h>
1.66      is        106: #endif
1.9       chopps    107: #include <amiga/amiga/cia.h>
                    108: #include <amiga/amiga/cc.h>
                    109: #include <amiga/amiga/memlist.h>
1.237     phx       110: #include <amiga/amiga/device.h>
1.45      chopps    111:
1.17      chopps    112: #include "fd.h"
1.22      chopps    113: #include "ser.h"
1.181     ragge     114: #include "ksyms.h"
1.1       mw        115:
1.61      veego     116: /* prototypes */
1.166     aymeric   117: void identifycpu(void);
                    118: vm_offset_t reserve_dumppages(vm_offset_t);
                    119: void dumpsys(void);
                    120: void initcpu(void);
                    121: void straytrap(int, u_short);
                    122: void intrhand(int);
1.64      mhitch    123: #if NSER > 0
1.166     aymeric   124: void ser_outintr(void);
1.64      mhitch    125: #endif
                    126: #if NFD > 0
1.166     aymeric   127: void fdintr(int);
1.64      mhitch    128: #endif
1.165     aymeric   129:
                    130: volatile unsigned int interrupt_depth = 0;
1.61      veego     131:
1.163     chs       132: struct vm_map *phys_map = NULL;
1.121     mhitch    133:
1.202     christos  134: void * msgbufaddr;
1.141     is        135: paddr_t msgbufpa;
1.100     leo       136:
1.171     aymeric   137: int    machineid;
1.1       mw        138: int    maxmem;                 /* max memory per process */
1.239   ! rkujawa   139: extern int     physmem;        /* max supported memory, changes to actual */
1.220     phx       140:
1.1       mw        141: extern  int   freebufspace;
                    142: extern u_int lowram;
                    143:
                    144: /* used in init_main.c */
1.192     jandberg  145: const char *cpu_type = "m68k";
1.23      chopps    146: /* the following is used externally (sysctl_hw) */
1.91      veego     147: char   machine[] = MACHINE;    /* from <machine/param.h> */
1.151     thorpej   148:
                    149: /* Our exported CPU info; we can have only one. */
                    150: struct cpu_info cpu_info_store;
1.166     aymeric   151:
1.102     mhitch    152: /*
                    153:  * current open serial device speed;  used by some SCSI drivers to reduce
                    154:  * DMA transfer lengths.
                    155:  */
                    156: int    ser_open_speed;
1.172     matt      157:
                    158: #ifdef DRACO
                    159: vaddr_t DRCCADDR;
                    160:
                    161: volatile u_int8_t *draco_intena, *draco_intpen, *draco_intfrc;
                    162: volatile u_int8_t *draco_misc;
                    163: volatile struct drioct *draco_ioct;
                    164: #endif
1.102     mhitch    165:
1.5       mw        166:  /*
1.1       mw        167:  * Console initialization: called early on from main,
                    168:  * before vm init or startup.  Do enough configuration
                    169:  * to choose and initialize a console.
                    170:  */
                    171: void
1.218     cegger    172: consinit(void)
1.1       mw        173: {
1.5       mw        174:        /* initialize custom chip interface */
1.66      is        175: #ifdef DRACO
                    176:        if (is_draco()) {
                    177:                /* XXX to be done */
                    178:        } else
                    179: #endif
                    180:                custom_chips_init();
1.237     phx       181:
                    182:        /* preconfigure graphics cards */
                    183:        config_console();
                    184:
1.1       mw        185:        /*
                    186:         * Initialize the console before we print anything out.
                    187:         */
                    188:        cninit();
1.11      chopps    189:
1.210     ad        190: #if NKSYMS || defined(DDB) || defined(MODULAR)
1.114     tv        191:        {
1.115     mhitch    192:                extern int end[];
1.114     tv        193:                extern int *esym;
                    194:
1.212     martin    195:                ksyms_addsyms_elf((int)esym - (int)&end - sizeof(Elf32_Ehdr),
1.159     is        196:                    (void *)&end, esym);
1.181     ragge     197:        }
1.159     is        198: #endif
1.181     ragge     199: #ifdef DDB
1.11      chopps    200:         if (boothowto & RB_KDB)
                    201:                 Debugger();
                    202: #endif
1.1       mw        203: }
                    204:
                    205: /*
                    206:  * cpu_startup: allocate memory for variable-sized tables,
1.189     wiz       207:  * initialize CPU, and do autoconfiguration.
1.1       mw        208:  */
                    209: void
1.218     cegger    210: cpu_startup(void)
1.1       mw        211: {
1.188     pk        212:        u_int i;
1.1       mw        213: #ifdef DEBUG
                    214:        extern int pmapdebug;
                    215:        int opmapdebug = pmapdebug;
                    216: #endif
1.188     pk        217:        vaddr_t minaddr, maxaddr;
1.1       mw        218:
                    219:        /*
                    220:         * Initialize error message buffer (at end of core).
                    221:         */
                    222: #ifdef DEBUG
                    223:        pmapdebug = 0;
                    224: #endif
1.111     is        225:        /*
                    226:         * pmap_bootstrap has positioned this at the end of kernel
                    227:         * memory segment - map and initialize it now.
                    228:         */
                    229:
1.100     leo       230:        for (i = 0; i < btoc(MSGBUFSIZE); i++)
1.180     thorpej   231:                pmap_enter(pmap_kernel(), (vaddr_t)msgbufaddr + i * PAGE_SIZE,
                    232:                    msgbufpa + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE,
1.142     thorpej   233:                    VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED);
1.164     chris     234:        pmap_update(pmap_kernel());
1.100     leo       235:        initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE));
1.1       mw        236:
1.188     pk        237:        minaddr = 0;
1.1       mw        238:
                    239:        /*
                    240:         * Allocate a submap for physio
                    241:         */
1.121     mhitch    242:        phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
1.201     thorpej   243:                                   VM_PHYS_SIZE, 0, false, NULL);
1.1       mw        244:
1.232     mlelstv   245:        /*
                    246:         * Good {morning,afternoon,evening,night}.
                    247:         */
                    248:        banner();
                    249:
1.235     mlelstv   250:        /*
                    251:         * Get MMU/FPU type from bootstrap
                    252:         */
                    253:        identifycpu();
                    254:
1.1       mw        255: #ifdef DEBUG
                    256:        pmapdebug = opmapdebug;
                    257: #endif
1.166     aymeric   258:
1.29      chopps    259:        /*
                    260:         * display memory configuration passed from loadbsd
                    261:         */
                    262:        if (memlist->m_nseg > 0 && memlist->m_nseg < 16)
                    263:                for (i = 0; i < memlist->m_nseg; i++)
1.139     is        264:                        printf("memory segment %d at %08x size %08x\n", i,
1.166     aymeric   265:                            memlist->m_seg[i].ms_start,
1.29      chopps    266:                            memlist->m_seg[i].ms_size);
1.66      is        267:
1.78      thorpej   268: #ifdef DEBUG_KERNEL_START
1.80      christos  269:        printf("calling initcpu...\n");
1.66      is        270: #endif
1.1       mw        271:        /*
                    272:         * Set up CPU-specific registers, cache, etc.
                    273:         */
                    274:        initcpu();
                    275:
1.73      is        276: #ifdef DEBUG_KERNEL_START
1.80      christos  277:        printf("survived initcpu...\n");
1.66      is        278: #endif
1.1       mw        279: }
                    280:
                    281: /*
1.23      chopps    282:  * Info for CTL_HW
                    283:  */
                    284: char cpu_model[120];
1.81      is        285:
                    286: #if defined(M68060)
                    287: int m68060_pcr_init = 0x21;    /* make this patchable */
                    288: #endif
                    289:
1.166     aymeric   290:
1.61      veego     291: void
1.218     cegger    292: identifycpu(void)
1.1       mw        293: {
1.3       mw        294:         /* there's alot of XXX in here... */
1.192     jandberg  295:        const char *mach, *mmu, *fpu;
1.3       mw        296:
1.70      is        297: #ifdef M68060
                    298:        char cpubuf[16];
                    299:        u_int32_t pcr;
                    300: #endif
1.72      is        301:
1.66      is        302: #ifdef DRACO
                    303:        char machbuf[16];
                    304:
                    305:        if (is_draco()) {
1.80      christos  306:                sprintf(machbuf, "DraCo rev.%d", is_draco());
1.66      is        307:                mach = machbuf;
1.166     aymeric   308:        } else
1.66      is        309: #endif
1.23      chopps    310:        if (is_a4000())
                    311:                mach = "Amiga 4000";
                    312:        else if (is_a3000())
                    313:                mach = "Amiga 3000";
1.33      chopps    314:        else if (is_a1200())
                    315:                mach = "Amiga 1200";
1.228     phx       316:        else if (is_a600())
                    317:                mach = "Amiga 600";
1.3       mw        318:        else
1.23      chopps    319:                mach = "Amiga 500/2000";
1.1       mw        320:
1.31      chopps    321:        fpu = NULL;
1.72      is        322: #ifdef M68060
1.66      is        323:        if (machineid & AMIGA_68060) {
1.195     perry     324:                __asm(".word 0x4e7a,0x0808; movl %%d0,%0" : "=d"(pcr) : : "d0");
1.80      christos  325:                sprintf(cpubuf, "68%s060 rev.%d",
1.70      is        326:                    pcr & 0x10000 ? "LC/EC" : "", (pcr>>8)&0xff);
                    327:                cpu_type = cpubuf;
1.66      is        328:                mmu = "/MMU";
1.94      is        329:                if (pcr & 2) {
                    330:                        fpu = "/FPU disabled";
                    331:                        fputype = FPU_NONE;
                    332:                } else if (m68060_pcr_init & 2){
                    333:                        fpu = "/FPU will be disabled";
                    334:                        fputype = FPU_NONE;
                    335:                } else  if (machineid & AMIGA_FPU40) {
                    336:                        fpu = "/FPU";
                    337:                        fputype = FPU_68040; /* XXX */
                    338:                }
1.166     aymeric   339:        } else
1.72      is        340: #endif
                    341:        if (machineid & AMIGA_68040) {
1.5       mw        342:                cpu_type = "m68040";
1.23      chopps    343:                mmu = "/MMU";
1.24      chopps    344:                fpu = "/FPU";
1.81      is        345:                fputype = FPU_68040; /* XXX */
1.24      chopps    346:        } else if (machineid & AMIGA_68030) {
1.23      chopps    347:                cpu_type = "m68030";    /* XXX */
                    348:                mmu = "/MMU";
                    349:        } else {
                    350:                cpu_type = "m68020";
                    351:                mmu = " m68851 MMU";
                    352:        }
1.31      chopps    353:        if (fpu == NULL) {
1.52      chopps    354:                if (machineid & AMIGA_68882) {
1.24      chopps    355:                        fpu = " m68882 FPU";
1.52      chopps    356:                        fputype = FPU_68882;
                    357:                } else if (machineid & AMIGA_68881) {
1.24      chopps    358:                        fpu = " m68881 FPU";
1.52      chopps    359:                        fputype = FPU_68881;
                    360:                } else {
1.24      chopps    361:                        fpu = " no FPU";
1.52      chopps    362:                        fputype = FPU_NONE;
                    363:                }
1.24      chopps    364:        }
1.80      christos  365:        sprintf(cpu_model, "%s (%s CPU%s%s)", mach, cpu_type, mmu, fpu);
                    366:        printf("%s\n", cpu_model);
1.23      chopps    367: }
1.5       mw        368:
1.23      chopps    369: /*
                    370:  * machine dependent system variables.
                    371:  */
1.187     atatat    372: SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
1.23      chopps    373: {
1.1       mw        374:
1.190     atatat    375:        sysctl_createv(clog, 0, NULL, NULL,
                    376:                       CTLFLAG_PERMANENT,
1.187     atatat    377:                       CTLTYPE_NODE, "machdep", NULL,
                    378:                       NULL, 0, NULL, 0,
                    379:                       CTL_MACHDEP, CTL_EOL);
                    380:
1.190     atatat    381:        sysctl_createv(clog, 0, NULL, NULL,
                    382:                       CTLFLAG_PERMANENT,
1.187     atatat    383:                       CTLTYPE_STRUCT, "console_device", NULL,
                    384:                       sysctl_consdev, 0, NULL, sizeof(dev_t),
                    385:                       CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
1.1       mw        386: }
1.4       mw        387:
1.3       mw        388: static int waittime = -1;
1.1       mw        389:
1.3       mw        390: void
                    391: bootsync(void)
1.1       mw        392: {
1.21      chopps    393:        if (waittime < 0) {
1.1       mw        394:                waittime = 0;
1.121     mhitch    395:                vfs_shutdown();
1.1       mw        396:                /*
                    397:                 * If we've been adjusting the clock, the todr
                    398:                 * will be out of synch; adjust it now.
                    399:                 */
                    400:                resettodr();
                    401:        }
1.3       mw        402: }
                    403:
1.63      veego     404:
1.27      chopps    405: void
1.216     dsl       406: cpu_reboot(register int howto, char *bootstr)
1.3       mw        407: {
1.221     rmind     408:        struct pcb *pcb = lwp_getpcb(curlwp);
                    409:
1.3       mw        410:        /* take a snap shot before clobbering any registers */
1.221     rmind     411:        if (pcb != NULL)
                    412:                savectx(pcb);
1.3       mw        413:
                    414:        boothowto = howto;
1.61      veego     415:        if ((howto & RB_NOSYNC) == 0)
1.3       mw        416:                bootsync();
1.63      veego     417:
                    418:        /* Disable interrupts. */
                    419:        spl7();
                    420:
                    421:        /* If rebooting and a dump is requested do it. */
                    422:        if (howto & RB_DUMP)
                    423:                dumpsys();
                    424:
1.61      veego     425:        if (howto & RB_HALT) {
1.101     veego     426:                printf("\n");
                    427:                printf("The operating system has halted.\n");
                    428:                printf("Please press any key to reboot.\n\n");
                    429:                cngetc();
1.1       mw        430:        }
1.63      veego     431:
1.101     veego     432:        printf("rebooting...\n");
                    433:        DELAY(1000000);
1.63      veego     434:        doboot();
1.1       mw        435:        /*NOTREACHED*/
                    436: }
1.63      veego     437:
1.1       mw        438:
1.168     tsutsui   439: u_int32_t dumpmag = 0x8fca0101;        /* magic number for savecore */
1.1       mw        440: int    dumpsize = 0;           /* also for savecore */
                    441: long   dumplo = 0;
1.68      mhitch    442: cpu_kcore_hdr_t cpu_kcore_hdr;
1.1       mw        443:
1.193     chs       444: #define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)))
                    445: #define MDHDRSIZE roundup(CHDRSIZE, dbtob(1))
                    446:
1.61      veego     447: void
1.218     cegger    448: cpu_dumpconf(void)
1.1       mw        449: {
1.89      thorpej   450:        cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
                    451:        struct m68k_kcore_hdr *m = &h->un._m68k;
1.1       mw        452:        int nblks;
1.68      mhitch    453:        int i;
1.115     mhitch    454:        extern int end[];
1.89      thorpej   455:
1.219     cegger    456:        memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
1.89      thorpej   457:
                    458:        /*
                    459:         * Intitialize the `dispatcher' portion of the header.
                    460:         */
                    461:        strcpy(h->name, machine);
1.180     thorpej   462:        h->page_size = PAGE_SIZE;
1.89      thorpej   463:        h->kernbase = KERNBASE;
                    464:
                    465:        /*
                    466:         * Fill in information about our MMU configuration.
                    467:         */
                    468:        m->mmutype      = mmutype;
                    469:        m->sg_v         = SG_V;
                    470:        m->sg_frame     = SG_FRAME;
                    471:        m->sg_ishift    = SG_ISHIFT;
                    472:        m->sg_pmask     = SG_PMASK;
                    473:        m->sg40_shift1  = SG4_SHIFT1;
                    474:        m->sg40_mask2   = SG4_MASK2;
                    475:        m->sg40_shift2  = SG4_SHIFT2;
                    476:        m->sg40_mask3   = SG4_MASK3;
                    477:        m->sg40_shift3  = SG4_SHIFT3;
                    478:        m->sg40_addr1   = SG4_ADDR1;
                    479:        m->sg40_addr2   = SG4_ADDR2;
                    480:        m->pg_v         = PG_V;
                    481:        m->pg_frame     = PG_FRAME;
                    482:
                    483:        /*
                    484:         * Initialize the pointer to the kernel segment table.
                    485:         */
1.223     tsutsui   486:        m->sysseg_pa = (paddr_t)pmap_kernel()->pm_stpa;
1.89      thorpej   487:
                    488:        /*
                    489:         * Initialize relocation value such that:
                    490:         *
                    491:         *      pa = (va - KERNBASE) + reloc
                    492:         */
                    493:        m->reloc = lowram;
                    494:
                    495:        /*
                    496:         * Define the end of the relocatable range.
                    497:         */
1.115     mhitch    498:        m->relocend = (u_int32_t)&end;
1.1       mw        499:
1.68      mhitch    500:        /* XXX new corefile format, single segment + chipmem */
1.1       mw        501:        dumpsize = physmem;
1.89      thorpej   502:        m->ram_segs[0].start = lowram;
                    503:        m->ram_segs[0].size  = ctob(physmem);
1.68      mhitch    504:        for (i = 0; i < memlist->m_nseg; i++) {
                    505:                if ((memlist->m_seg[i].ms_attrib & MEMF_CHIP) == 0)
                    506:                        continue;
                    507:                dumpsize += btoc(memlist->m_seg[i].ms_size);
1.89      thorpej   508:                m->ram_segs[1].start = 0;
                    509:                m->ram_segs[1].size  = memlist->m_seg[i].ms_size;
1.68      mhitch    510:                break;
                    511:        }
1.236     mrg       512:        if (bdevsw_lookup(dumpdev) == NULL) {
1.197     mrg       513:                dumpdev = NODEV;
                    514:                return;
                    515:        }
1.236     mrg       516:        nblks = bdev_size(dumpdev);
                    517:        if (nblks > 0) {
1.1       mw        518:                if (dumpsize > btoc(dbtob(nblks - dumplo)))
                    519:                        dumpsize = btoc(dbtob(nblks - dumplo));
                    520:                else if (dumplo == 0)
1.68      mhitch    521:                        dumplo = nblks - btodb(ctob(dumpsize));
1.1       mw        522:        }
1.68      mhitch    523:        --dumplo;       /* XXX assume header fits in one block */
1.1       mw        524:        /*
1.180     thorpej   525:         * Don't dump on the first PAGE_SIZE (why PAGE_SIZE?)
1.1       mw        526:         * in case the dump device includes a disk label.
                    527:         */
1.180     thorpej   528:        if (dumplo < btodb(PAGE_SIZE))
                    529:                dumplo = btodb(PAGE_SIZE);
1.1       mw        530: }
                    531:
                    532: /*
                    533:  * Doadump comes here after turning off memory management and
                    534:  * getting on the dump stack, either when called above, or by
                    535:  * the auto-restart code.
                    536:  */
1.57      chopps    537: #define BYTES_PER_DUMP MAXPHYS /* Must be a multiple of pagesize XXX small */
1.55      chopps    538: static vm_offset_t dumpspace;
                    539:
                    540: vm_offset_t
1.216     dsl       541: reserve_dumppages(vm_offset_t p)
1.55      chopps    542: {
                    543:        dumpspace = p;
                    544:        return (p + BYTES_PER_DUMP);
                    545: }
                    546:
1.61      veego     547: void
1.218     cegger    548: dumpsys(void)
1.1       mw        549: {
1.68      mhitch    550:        unsigned bytes, i, n, seg;
1.55      chopps    551:        int     maddr, psize;
                    552:        daddr_t blkno;
1.202     christos  553:        int     (*dump)(dev_t, daddr_t, void *, size_t);
1.55      chopps    554:        int     error = 0;
1.68      mhitch    555:        kcore_seg_t *kseg_p;
                    556:        cpu_kcore_hdr_t *chdr_p;
1.193     chs       557:        char    dump_hdr[MDHDRSIZE];
1.174     gehenna   558:        const struct bdevsw *bdev;
1.1       mw        559:
                    560:        if (dumpdev == NODEV)
                    561:                return;
1.174     gehenna   562:        bdev = bdevsw_lookup(dumpdev);
                    563:        if (bdev == NULL || bdev->d_psize == NULL)
                    564:                return;
1.1       mw        565:        /*
                    566:         * For dumps during autoconfiguration,
                    567:         * if dump device has already configured...
                    568:         */
                    569:        if (dumpsize == 0)
1.85      gwr       570:                cpu_dumpconf();
1.108     mycroft   571:        if (dumplo <= 0) {
1.214     he        572:                printf("\ndump to dev %u,%u not possible\n", major(dumpdev),
1.108     mycroft   573:                    minor(dumpdev));
1.1       mw        574:                return;
1.108     mycroft   575:        }
1.214     he        576:        printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
1.108     mycroft   577:            minor(dumpdev), dumplo);
1.55      chopps    578:
1.236     mrg       579:        psize = bdev_size(dumpdev);
1.80      christos  580:        printf("dump ");
1.55      chopps    581:        if (psize == -1) {
1.80      christos  582:                printf("area unavailable.\n");
1.55      chopps    583:                return;
                    584:        }
1.68      mhitch    585:        kseg_p = (kcore_seg_t *)dump_hdr;
                    586:        chdr_p = (cpu_kcore_hdr_t *)&dump_hdr[ALIGN(sizeof(*kseg_p))];
1.219     cegger    587:        memset(dump_hdr, 0, sizeof(dump_hdr));
1.68      mhitch    588:
                    589:        /*
                    590:         * Generate a segment header
                    591:         */
                    592:        CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
1.193     chs       593:        kseg_p->c_size = MDHDRSIZE - ALIGN(sizeof(*kseg_p));
1.68      mhitch    594:
                    595:        /*
                    596:         * Add the md header
                    597:         */
                    598:
                    599:        *chdr_p = cpu_kcore_hdr;
                    600:
1.55      chopps    601:        bytes = ctob(dumpsize);
1.89      thorpej   602:        maddr = cpu_kcore_hdr.un._m68k.ram_segs[0].start;
1.68      mhitch    603:        seg = 0;
1.55      chopps    604:        blkno = dumplo;
1.174     gehenna   605:        dump = bdev->d_dump;
1.202     christos  606:        error = (*dump) (dumpdev, blkno, (void *)dump_hdr, sizeof(dump_hdr));
1.193     chs       607:        blkno += btodb(sizeof(dump_hdr));
1.68      mhitch    608:        for (i = 0; i < bytes && error == 0; i += n) {
1.55      chopps    609:                /* Print out how many MBs we have to go. */
                    610:                n = bytes - i;
                    611:                if (n && (n % (1024 * 1024)) == 0)
1.211     ad        612:                        printf_nolog("%d ", n / (1024 * 1024));
1.55      chopps    613:
                    614:                /* Limit size for next transfer. */
                    615:                if (n > BYTES_PER_DUMP)
                    616:                        n = BYTES_PER_DUMP;
                    617:
1.68      mhitch    618:                if (maddr == 0) {       /* XXX kvtop chokes on this */
1.180     thorpej   619:                        maddr += PAGE_SIZE;
                    620:                        n -= PAGE_SIZE;
                    621:                        i += PAGE_SIZE;
1.68      mhitch    622:                        ++blkno;        /* XXX skip physical page 0 */
                    623:                }
1.55      chopps    624:                (void) pmap_map(dumpspace, maddr, maddr + n, VM_PROT_READ);
1.202     christos  625:                error = (*dump) (dumpdev, blkno, (void *) dumpspace, n);
1.55      chopps    626:                if (error)
                    627:                        break;
                    628:                maddr += n;
                    629:                blkno += btodb(n);      /* XXX? */
1.89      thorpej   630:                if (maddr >= (cpu_kcore_hdr.un._m68k.ram_segs[seg].start +
                    631:                    cpu_kcore_hdr.un._m68k.ram_segs[seg].size)) {
1.68      mhitch    632:                        ++seg;
1.89      thorpej   633:                        maddr = cpu_kcore_hdr.un._m68k.ram_segs[seg].start;
                    634:                        if (cpu_kcore_hdr.un._m68k.ram_segs[seg].size == 0)
1.68      mhitch    635:                                break;
                    636:                }
1.55      chopps    637:        }
                    638:
                    639:        switch (error) {
1.1       mw        640:
                    641:        case ENXIO:
1.80      christos  642:                printf("device bad\n");
1.1       mw        643:                break;
                    644:
                    645:        case EFAULT:
1.80      christos  646:                printf("device not ready\n");
1.1       mw        647:                break;
                    648:
                    649:        case EINVAL:
1.80      christos  650:                printf("area improper\n");
1.1       mw        651:                break;
                    652:
                    653:        case EIO:
1.80      christos  654:                printf("i/o error\n");
1.1       mw        655:                break;
                    656:
                    657:        default:
1.80      christos  658:                printf("succeeded\n");
1.1       mw        659:                break;
                    660:        }
1.80      christos  661:        printf("\n\n");
1.55      chopps    662:        delay(5000000);         /* 5 seconds */
1.1       mw        663: }
                    664:
1.61      veego     665: void
1.218     cegger    666: initcpu(void)
1.1       mw        667: {
1.166     aymeric   668:        typedef void trapfun(void);
1.93      is        669:
1.67      is        670:        /* XXX should init '40 vecs here, too */
1.94      is        671: #if defined(M68060) || defined(M68040) || defined(DRACO) || defined(FPU_EMULATE)
1.93      is        672:        extern trapfun *vectab[256];
1.70      is        673: #endif
1.66      is        674:
1.90      is        675: #if defined(M68060) || defined(M68040)
1.93      is        676:        extern trapfun addrerr4060;
1.90      is        677: #endif
                    678:
1.72      is        679: #ifdef M68060
1.93      is        680:        extern trapfun buserr60;
1.69      is        681: #if defined(M060SP)
1.82      is        682:        /*extern u_int8_t I_CALL_TOP[];*/
1.93      is        683:        extern trapfun intemu60, fpiemu60, fpdemu60, fpeaemu60;
1.66      is        684:        extern u_int8_t FP_CALL_TOP[];
1.69      is        685: #else
1.93      is        686:        extern trapfun illinst;
1.72      is        687: #endif
1.93      is        688:        extern trapfun fpfault;
1.69      is        689: #endif
1.66      is        690:
1.90      is        691: #ifdef M68040
1.93      is        692:        extern trapfun buserr40;
1.90      is        693: #endif
                    694:
1.70      is        695: #ifdef DRACO
1.93      is        696:        extern trapfun DraCoIntr, DraCoLev1intr, DraCoLev2intr;
1.77      is        697:        u_char dracorev;
1.70      is        698: #endif
                    699:
1.94      is        700: #ifdef FPU_EMULATE
                    701:        extern trapfun fpemuli;
                    702: #endif
                    703:
1.70      is        704: #ifdef M68060
1.66      is        705:        if (machineid & AMIGA_68060) {
1.94      is        706:                if (machineid & AMIGA_FPU40 && m68060_pcr_init & 2) {
1.166     aymeric   707:                        /*
1.94      is        708:                         * in this case, we're about to switch the FPU off;
                    709:                         * do a FNOP to avoid stray FP traps later
                    710:                         */
                    711:                        __asm("fnop");
                    712:                        /* ... and mark FPU as absent for identifyfpu() */
                    713:                        machineid &= ~(AMIGA_FPU40|AMIGA_68882|AMIGA_68881);
                    714:                }
1.195     perry     715:                __asm volatile ("movl %0,%%d0; .word 0x4e7b,0x0808" : :
1.66      is        716:                        "d"(m68060_pcr_init):"d0" );
1.90      is        717:
                    718:                /* bus/addrerr vectors */
1.93      is        719:                vectab[2] = buserr60;
                    720:                vectab[3] = addrerr4060;
1.66      is        721: #if defined(M060SP)
                    722:
                    723:                /* integer support */
1.93      is        724:                vectab[61] = intemu60/*(trapfun *)&I_CALL_TOP[128 + 0x00]*/;
1.66      is        725:
                    726:                /* floating point support */
1.81      is        727:                /*
                    728:                 * XXX maybe we really should run-time check for the
                    729:                 * stack frame format here:
                    730:                 */
1.93      is        731:                vectab[11] = fpiemu60/*(trapfun *)&FP_CALL_TOP[128 + 0x30]*/;
1.81      is        732:
1.93      is        733:                vectab[55] = fpdemu60/*(trapfun *)&FP_CALL_TOP[128 + 0x38]*/;
                    734:                vectab[60] = fpeaemu60/*(trapfun *)&FP_CALL_TOP[128 + 0x40]*/;
1.66      is        735:
1.93      is        736:                vectab[54] = (trapfun *)&FP_CALL_TOP[128 + 0x00];
                    737:                vectab[52] = (trapfun *)&FP_CALL_TOP[128 + 0x08];
                    738:                vectab[53] = (trapfun *)&FP_CALL_TOP[128 + 0x10];
                    739:                vectab[51] = (trapfun *)&FP_CALL_TOP[128 + 0x18];
                    740:                vectab[50] = (trapfun *)&FP_CALL_TOP[128 + 0x20];
                    741:                vectab[49] = (trapfun *)&FP_CALL_TOP[128 + 0x28];
1.66      is        742:
                    743: #else
1.93      is        744:                vectab[61] = illinst;
1.66      is        745: #endif
1.93      is        746:                vectab[48] = fpfault;
1.66      is        747:        }
                    748: #endif
1.70      is        749:
1.81      is        750: /*
1.166     aymeric   751:  * Vector initialization for special motherboards
1.81      is        752:  */
1.90      is        753: #ifdef M68040
                    754: #ifdef M68060
                    755:        else
                    756: #endif
                    757:        if (machineid & AMIGA_68040) {
                    758:                /* addrerr vector */
1.93      is        759:                vectab[2] = buserr40;
                    760:                vectab[3] = addrerr4060;
1.90      is        761:        }
                    762: #endif
1.94      is        763:
                    764: #ifdef FPU_EMULATE
                    765:        if (!(machineid & (AMIGA_68881|AMIGA_68882|AMIGA_FPU40))) {
                    766:                vectab[11] = fpemuli;
                    767:                printf("FPU software emulation initialized.\n");
                    768:        }
                    769: #endif
                    770:
                    771: /*
1.166     aymeric   772:  * Vector initialization for special motherboards
1.94      is        773:  */
1.81      is        774:
1.70      is        775: #ifdef DRACO
1.77      is        776:        dracorev = is_draco();
                    777:        if (dracorev) {
                    778:                if (dracorev >= 4) {
1.93      is        779:                        vectab[24+1] = DraCoLev1intr;
                    780:                        vectab[24+2] = DraCoIntr;
1.77      is        781:                } else {
1.93      is        782:                        vectab[24+1] = DraCoIntr;
                    783:                        vectab[24+2] = DraCoLev2intr;
1.77      is        784:                }
1.93      is        785:                vectab[24+3] = DraCoIntr;
                    786:                vectab[24+4] = DraCoIntr;
                    787:                vectab[24+5] = DraCoIntr;
                    788:                vectab[24+6] = DraCoIntr;
1.70      is        789:        }
                    790: #endif
1.1       mw        791: }
                    792:
1.61      veego     793: void
1.216     dsl       794: straytrap(int pc, u_short evec)
1.1       mw        795: {
1.80      christos  796:        printf("unexpected trap format %x (vector offset %x) from %x\n",
1.66      is        797:               evec>>12, evec & 0xFFF, pc);
1.42      chopps    798: /*XXX*/        panic("straytrap");
1.1       mw        799: }
                    800:
                    801: int    *nofault;
                    802:
1.61      veego     803: int
1.216     dsl       804: badaddr(register void *addr)
1.1       mw        805: {
                    806:        register int i;
                    807:        label_t faultbuf;
                    808:
                    809: #ifdef lint
                    810:        i = *addr; if (i) return(0);
                    811: #endif
                    812:        nofault = (int *) &faultbuf;
                    813:        if (setjmp((label_t *)nofault)) {
                    814:                nofault = (int *) 0;
                    815:                return(1);
                    816:        }
                    817:        i = *(volatile short *)addr;
                    818:        nofault = (int *) 0;
                    819:        return(0);
                    820: }
                    821:
1.61      veego     822: int
1.216     dsl       823: badbaddr(register void *addr)
1.1       mw        824: {
                    825:        register int i;
                    826:        label_t faultbuf;
                    827:
                    828: #ifdef lint
                    829:        i = *addr; if (i) return(0);
                    830: #endif
                    831:        nofault = (int *) &faultbuf;
                    832:        if (setjmp((label_t *)nofault)) {
                    833:                nofault = (int *) 0;
                    834:                return(1);
                    835:        }
                    836:        i = *(volatile char *)addr;
                    837:        nofault = (int *) 0;
                    838:        return(0);
                    839: }
                    840:
1.45      chopps    841: struct isr *isr_ports;
1.66      is        842: #ifdef DRACO
                    843: struct isr *isr_slot3;
1.81      is        844: struct isr *isr_supio;
1.66      is        845: #endif
1.45      chopps    846: struct isr *isr_exter;
                    847:
                    848: void
1.216     dsl       849: add_isr(struct isr *isr)
1.45      chopps    850: {
                    851:        struct isr **p, *q;
                    852:
1.66      is        853: #ifdef DRACO
                    854:        switch (isr->isr_ipl) {
                    855:        case 2:
                    856:                p = &isr_ports;
                    857:                break;
                    858:        case 3:
                    859:                p = &isr_slot3;
                    860:                break;
1.81      is        861:        case 5:
                    862:                p = &isr_supio;
                    863:                break;
1.70      is        864:        default:        /* was case 6:; make gcc -Wall quiet */
1.66      is        865:                p = &isr_exter;
                    866:                break;
                    867:        }
                    868: #else
1.45      chopps    869:        p = isr->isr_ipl == 2 ? &isr_ports : &isr_exter;
1.66      is        870: #endif
1.45      chopps    871:        while ((q = *p) != NULL)
                    872:                p = &q->isr_forw;
                    873:        isr->isr_forw = NULL;
                    874:        *p = isr;
                    875:        /* enable interrupt */
1.66      is        876: #ifdef DRACO
                    877:        if (is_draco())
1.81      is        878:                switch(isr->isr_ipl) {
                    879:                        case 6:
1.122     is        880:                                single_inst_bset_b(*draco_intena, DRIRQ_INT6);
1.81      is        881:                                break;
                    882:                        case 2:
1.122     is        883:                                single_inst_bset_b(*draco_intena, DRIRQ_INT2);
1.81      is        884:                                break;
                    885:                        default:
                    886:                                break;
                    887:                }
1.166     aymeric   888:        else
1.66      is        889: #endif
1.166     aymeric   890:                custom.intena = isr->isr_ipl == 2 ?
1.66      is        891:                    INTF_SETCLR | INTF_PORTS :
                    892:                    INTF_SETCLR | INTF_EXTER;
1.45      chopps    893: }
                    894:
                    895: void
1.216     dsl       896: remove_isr(struct isr *isr)
1.45      chopps    897: {
                    898:        struct isr **p, *q;
                    899:
1.66      is        900: #ifdef DRACO
                    901:        switch (isr->isr_ipl) {
                    902:        case 2:
                    903:                p = &isr_ports;
                    904:                break;
                    905:        case 3:
                    906:                p = &isr_slot3;
                    907:                break;
1.81      is        908:        case 5:
                    909:                p = &isr_supio;
                    910:                break;
1.70      is        911:        default:        /* XXX to make gcc -Wall quiet, was 6: */
1.66      is        912:                p = &isr_exter;
                    913:                break;
                    914:        }
                    915: #else
1.45      chopps    916:        p = isr->isr_ipl == 6 ? &isr_exter : &isr_ports;
1.66      is        917: #endif
                    918:
1.45      chopps    919:        while ((q = *p) != NULL && q != isr)
                    920:                p = &q->isr_forw;
                    921:        if (q)
                    922:                *p = q->isr_forw;
                    923:        else
                    924:                panic("remove_isr: handler not registered");
                    925:        /* disable interrupt if no more handlers */
1.66      is        926: #ifdef DRACO
                    927:        switch (isr->isr_ipl) {
                    928:        case 2:
                    929:                p = &isr_ports;
                    930:                break;
                    931:        case 3:
                    932:                p = &isr_slot3;
                    933:                break;
1.81      is        934:        case 5:
                    935:                p = &isr_supio;
                    936:                break;
1.66      is        937:        case 6:
                    938:                p = &isr_exter;
                    939:                break;
                    940:        }
                    941: #else
1.45      chopps    942:        p = isr->isr_ipl == 6 ? &isr_exter : &isr_ports;
1.66      is        943: #endif
1.128     is        944:        if (*p == NULL) {
1.66      is        945: #ifdef DRACO
1.81      is        946:                if (is_draco()) {
                    947:                        switch(isr->isr_ipl) {
                    948:                                case 2:
1.122     is        949:                                        single_inst_bclr_b(*draco_intena,
                    950:                                            DRIRQ_INT2);
1.81      is        951:                                        break;
                    952:                                case 6:
1.122     is        953:                                        single_inst_bclr_b(*draco_intena,
                    954:                                            DRIRQ_INT6);
1.81      is        955:                                        break;
                    956:                                default:
                    957:                                        break;
                    958:                        }
                    959:                } else
1.66      is        960: #endif
1.166     aymeric   961:                        custom.intena = isr->isr_ipl == 6 ?
1.66      is        962:                            INTF_EXTER : INTF_PORTS;
1.128     is        963:        }
1.45      chopps    964: }
                    965:
1.207     ad        966: static int idepth;
                    967:
1.61      veego     968: void
1.216     dsl       969: intrhand(int sr)
1.1       mw        970: {
1.22      chopps    971:        register unsigned int ipl;
                    972:        register unsigned short ireq;
1.45      chopps    973:        register struct isr **p, *q;
1.1       mw        974:
1.207     ad        975:        idepth++;
1.22      chopps    976:        ipl = (sr >> 8) & 7;
1.66      is        977: #ifdef REALLYDEBUG
1.80      christos  978:        printf("intrhand: got int. %d\n", ipl);
1.66      is        979: #endif
                    980: #ifdef DRACO
                    981:        if (is_draco())
                    982:                ireq = ((ipl == 1)  && (*draco_intfrc & DRIRQ_SOFT) ?
                    983:                    INTF_SOFTINT : 0);
                    984:        else
                    985: #endif
                    986:                ireq = custom.intreqr;
1.1       mw        987:
1.22      chopps    988:        switch (ipl) {
                    989:        case 1:
1.66      is        990: #ifdef DRACO
                    991:                if (is_draco() && (draco_ioct->io_status & DRSTAT_KBDRECV))
                    992:                        drkbdintr();
                    993: #endif
1.22      chopps    994:                if (ireq & INTF_TBE) {
                    995: #if NSER > 0
                    996:                        ser_outintr();
                    997: #else
                    998:                        custom.intreq = INTF_TBE;
                    999: #endif
                   1000:                }
                   1001:
                   1002:                if (ireq & INTF_DSKBLK) {
1.17      chopps   1003: #if NFD > 0
1.22      chopps   1004:                        fdintr(0);
1.17      chopps   1005: #endif
1.22      chopps   1006:                        custom.intreq = INTF_DSKBLK;
                   1007:                }
                   1008:                if (ireq & INTF_SOFTINT) {
1.220     phx      1009:                        /* sicallback handling removed */
                   1010: #ifdef DEBUG
                   1011:                        printf("intrhand: SOFTINT ignored\n");
1.66      is       1012: #endif
1.220     phx      1013:                        custom.intreq = INTF_SOFTINT;
1.22      chopps   1014:                }
                   1015:                break;
                   1016:
                   1017:        case 2:
1.45      chopps   1018:                p = &isr_ports;
                   1019:                while ((q = *p) != NULL) {
                   1020:                        if ((q->isr_intr)(q->isr_arg))
                   1021:                                break;
                   1022:                        p = &q->isr_forw;
                   1023:                }
                   1024:                if (q == NULL)
                   1025:                        ciaa_intr ();
1.66      is       1026: #ifdef DRACO
                   1027:                if (is_draco())
1.122     is       1028:                        single_inst_bclr_b(*draco_intpen, DRIRQ_INT2);
1.66      is       1029:                else
                   1030: #endif
                   1031:                        custom.intreq = INTF_PORTS;
1.104     is       1032:
1.22      chopps   1033:                break;
1.104     is       1034:
                   1035: #ifdef DRACO
                   1036:        /* only handled here for DraCo */
                   1037:        case 6:
                   1038:                p = &isr_exter;
                   1039:                while ((q = *p) != NULL) {
                   1040:                        if ((q->isr_intr)(q->isr_arg))
                   1041:                                break;
                   1042:                        p = &q->isr_forw;
                   1043:                }
1.122     is       1044:                single_inst_bclr_b(*draco_intpen, DRIRQ_INT6);
1.104     is       1045:                break;
                   1046: #endif
                   1047:
1.166     aymeric  1048:        case 3:
1.104     is       1049:        /* VBL */
1.166     aymeric  1050:                if (ireq & INTF_BLIT)
1.22      chopps   1051:                        blitter_handler();
1.166     aymeric  1052:                if (ireq & INTF_COPER)
1.22      chopps   1053:                        copper_handler();
1.166     aymeric  1054:                if (ireq & INTF_VERTB)
1.22      chopps   1055:                        vbl_handler();
                   1056:                break;
1.81      is       1057: #ifdef DRACO
                   1058:        case 5:
                   1059:                p = &isr_supio;
                   1060:                while ((q = *p) != NULL) {
                   1061:                        if ((q->isr_intr)(q->isr_arg))
                   1062:                                break;
                   1063:                        p = &q->isr_forw;
                   1064:                }
                   1065:                break;
                   1066: #endif
1.3       mw       1067: #if 0
                   1068: /* now dealt with in locore.s for speed reasons */
1.22      chopps   1069:        case 5:
                   1070:                /* check RS232 RBF */
                   1071:                serintr (0);
                   1072:
                   1073:                custom.intreq = INTF_DSKSYNC;
                   1074:                break;
                   1075: #endif
                   1076:
                   1077:        case 4:
1.66      is       1078: #ifdef DRACO
                   1079: #include "drsc.h"
                   1080:                if (is_draco())
                   1081: #if NDRSC > 0
                   1082:                        drsc_handler();
                   1083: #else
1.122     is       1084:                        single_inst_bclr_b(*draco_intpen, DRIRQ_SCSI);
1.66      is       1085: #endif
                   1086:                else
                   1087: #endif
1.22      chopps   1088:                audio_handler();
                   1089:                break;
                   1090:        default:
1.80      christos 1091:                printf("intrhand: unexpected sr 0x%x, intreq = 0x%x\n",
1.22      chopps   1092:                    sr, ireq);
                   1093:                break;
                   1094:        }
1.66      is       1095: #ifdef REALLYDEBUG
1.80      christos 1096:        printf("intrhand: leaving.\n");
1.66      is       1097: #endif
1.207     ad       1098:        idepth--;
                   1099: }
                   1100:
                   1101: bool
                   1102: cpu_intr_p(void)
                   1103: {
                   1104:
                   1105:        return idepth != 0;
1.1       mw       1106: }
                   1107:
                   1108: #if defined(DEBUG) && !defined(PANICBUTTON)
                   1109: #define PANICBUTTON
                   1110: #endif
                   1111:
                   1112: #ifdef PANICBUTTON
                   1113: int panicbutton = 1;   /* non-zero if panic buttons are enabled */
                   1114: int crashandburn = 0;
                   1115: int candbdelay = 50;   /* give em half a second */
1.166     aymeric  1116: void candbtimer(void);
1.204     ad       1117: callout_t candbtimer_ch;
1.1       mw       1118:
1.61      veego    1119: void
1.218     cegger   1120: candbtimer(void)
1.1       mw       1121: {
                   1122:        crashandburn = 0;
                   1123: }
                   1124: #endif
                   1125:
                   1126: #if 0
                   1127: /*
                   1128:  * Level 7 interrupts can be caused by the keyboard or parity errors.
                   1129:  */
1.216     dsl      1130: nmihand(struct frame frame)
1.1       mw       1131: {
                   1132:        if (kbdnmi()) {
                   1133: #ifdef PANICBUTTON
                   1134:                static int innmihand = 0;
                   1135:
                   1136:                /*
                   1137:                 * Attempt to reduce the window of vulnerability for recursive
                   1138:                 * NMIs (e.g. someone holding down the keyboard reset button).
                   1139:                 */
                   1140:                if (innmihand == 0) {
                   1141:                        innmihand = 1;
1.80      christos 1142:                        printf("Got a keyboard NMI\n");
1.1       mw       1143:                        innmihand = 0;
                   1144:                }
                   1145:                if (panicbutton) {
                   1146:                        if (crashandburn) {
                   1147:                                crashandburn = 0;
                   1148:                                panic(panicstr ?
                   1149:                                      "forced crash, nosync" : "forced crash");
                   1150:                        }
                   1151:                        crashandburn++;
1.148     thorpej  1152:                        callout_reset(&candbtimer_ch, candbdelay,
                   1153:                            candbtimer, NULL);
1.1       mw       1154:                }
                   1155: #endif
                   1156:                return;
                   1157:        }
                   1158:        if (parityerror(&frame))
                   1159:                return;
                   1160:        /* panic?? */
1.80      christos 1161:        printf("unexpected level 7 interrupt ignored\n");
1.1       mw       1162: }
                   1163: #endif
                   1164:
1.31      chopps   1165: /*
                   1166:  * should only get here, if no standard executable. This can currently
                   1167:  * only mean, we're reading an old ZMAGIC file without MID, but since Amiga
                   1168:  * ZMAGIC always worked the `right' way (;-)) just ignore the missing
                   1169:  * MID and proceed to new zmagic code ;-)
                   1170:  */
1.61      veego    1171: int
1.216     dsl      1172: cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
1.1       mw       1173: {
1.31      chopps   1174:        int error = ENOEXEC;
1.71      veego    1175: #ifdef COMPAT_NOMID
1.31      chopps   1176:        struct exec *execp = epp->ep_hdr;
1.71      veego    1177: #endif
1.1       mw       1178:
                   1179: #ifdef COMPAT_NOMID
1.31      chopps   1180:        if (!((execp->a_midmag >> 16) & 0x0fff)
                   1181:            && execp->a_midmag == ZMAGIC)
1.194     christos 1182:                return(exec_aout_prep_zmagic(l, epp));
1.4       mw       1183: #endif
1.31      chopps   1184:        return(error);
1.4       mw       1185: }
1.162     is       1186:
1.210     ad       1187: #ifdef MODULAR
1.227     tsutsui  1188: /*
                   1189:  * Push any modules loaded by the bootloader etc.
                   1190:  */
                   1191: void
                   1192: module_init_md(void)
                   1193: {
                   1194: }
1.162     is       1195:
                   1196: int _spllkm6(void);
                   1197: int _spllkm7(void);
                   1198:
                   1199: #ifdef LEV6_DEFER
                   1200: int _spllkm6() {
                   1201:        return spl4();
                   1202: };
                   1203:
                   1204: int _spllkm7() {
                   1205:        return spl4();
                   1206: };
                   1207:
                   1208: #else
                   1209:
                   1210: int _spllkm6() {
                   1211:        return spl6();
                   1212: };
                   1213:
                   1214: int _spllkm7() {
                   1215:        return spl7();
1.166     aymeric  1216: };
1.162     is       1217:
                   1218: #endif
                   1219:
                   1220: #endif
1.200     yamt     1221:
                   1222: int ipl2spl_table[_NIPL] = {
                   1223:        [IPL_NONE] = PSL_IPL0|PSL_S,
                   1224:        [IPL_SOFTCLOCK] = PSL_IPL1|PSL_S,
                   1225:        [IPL_VM] = PSL_IPL4|PSL_S,
                   1226: #if defined(LEV6_DEFER)
1.222     mhitch   1227:        [IPL_SCHED] = PSL_IPL4|PSL_S,
1.200     yamt     1228:        [IPL_HIGH] = PSL_IPL4|PSL_S,
                   1229: #else /* defined(LEV6_DEFER) */
1.222     mhitch   1230:        [IPL_SCHED] = PSL_IPL6|PSL_S,
1.200     yamt     1231:        [IPL_HIGH] = PSL_IPL7|PSL_S,
                   1232: #endif /* defined(LEV6_DEFER) */
                   1233: };
1.234     rmind    1234:
                   1235: int
                   1236: mm_md_physacc(paddr_t pa, vm_prot_t prot)
                   1237: {
                   1238:
                   1239:        return (pa >= 0xfffffffc || pa < lowram) ? EFAULT : 0;
                   1240: }

CVSweb <webmaster@jp.NetBSD.org>