[BACK]Return to bugio.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvmeppc / dev

Annotation of sys/arch/mvmeppc/dev/bugio.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: bugio.c,v 1.7 2004/11/15 11:01:35 miod Exp $  */
                      2:
                      3: /*
                      4:  * bug routines -- assumes that the necessary sections of memory
                      5:  * are preserved.
                      6:  */
                      7: #include <sys/param.h>
                      8: #include <sys/systm.h>
                      9: #include <sys/types.h>
                     10:
                     11: #include <machine/bugio.h>
                     12: #include <machine/cpu.h>
                     13:
                     14: int bugenvsz(void);
                     15:
                     16: /*
                     17:  * BUG register preserving
                     18:  */
                     19:
                     20: register_t sprg0, sprg1, sprg2, sprg3;
                     21: register_t bugsprg3;
                     22:
                     23: #define        BUGCTXT(msr) \
                     24:        do { \
                     25:                msr = ppc_mfmsr(); \
                     26:                sprg0 = ppc_mfsprg0(); \
                     27:                sprg1 = ppc_mfsprg1(); \
                     28:                sprg2 = ppc_mfsprg2(); \
                     29:                sprg3 = ppc_mfsprg3(); \
                     30:                ppc_mtsprg3(bugsprg3); \
                     31:                ppc_mtmsr(((msr | PSL_IP) & ~(PSL_EE | PSL_IR | PSL_DR))); \
                     32:        } while (0)
                     33:
                     34: #define        OSCTXT(msr) \
                     35:        do { \
                     36:                bugsprg3 = ppc_mfsprg3(); \
                     37:                ppc_mtsprg0(sprg0); \
                     38:                ppc_mtsprg1(sprg1); \
                     39:                ppc_mtsprg2(sprg2); \
                     40:                ppc_mtsprg3(sprg3); \
                     41:                ppc_mtmsr(msr); \
                     42:        } while (0)
                     43:
                     44: /* Invoke the BUG */
                     45: #define MVMEPROM_CALL(x)       \
                     46:        __asm__ __volatile__ ("addi %r10,%r0," __STRING(x)); \
                     47:        __asm__ __volatile__ ("sc");
                     48:
                     49: void
                     50: buginit()
                     51: {
                     52:        bugsprg3 = ppc_mfsprg3();
                     53: }
                     54:
                     55:
                     56: /* BUG - query board routines */
                     57: void
                     58: mvmeprom_brdid(id)
                     59:        struct mvmeprom_brdid *id;
                     60: {
                     61:        unsigned long msr;
                     62:
                     63:        BUGCTXT(msr);
                     64:        MVMEPROM_CALL(MVMEPROM_BRD_ID);
                     65:        asm volatile ("mr %0, 3": "=r" (id):);
                     66:        OSCTXT(msr);
                     67: }
                     68:
                     69: /* returns 0 if no characters ready to read */
                     70: int
                     71: mvmeprom_getchar()
                     72: {
                     73:        int ret;
                     74:        unsigned long msr;
                     75:
                     76:        BUGCTXT(msr);
                     77:        MVMEPROM_CALL(MVMEPROM_INCHR);
                     78:        asm volatile ("mr %0, 3" :  "=r" (ret));
                     79:        OSCTXT(msr);
                     80:        return ret;
                     81: }
                     82:
                     83: /* returns 0 if no characters ready to read */
                     84: int
                     85: mvmeprom_instat()
                     86: {
                     87:        int ret;
                     88:        unsigned long msr;
                     89:
                     90:        BUGCTXT(msr);
                     91:        MVMEPROM_CALL(MVMEPROM_INSTAT);
                     92:        asm volatile ("mr %0, 3" :  "=r" (ret));
                     93:        OSCTXT(msr);
                     94:        return (!(ret & 0x4));
                     95: }
                     96:
                     97: void
                     98: mvmeprom_outln(start, end)
                     99:        char *start, *end;
                    100: {
                    101:        unsigned long msr;
                    102:
                    103:        BUGCTXT(msr);
                    104:        asm volatile ("mr 3, %0": : "r" (start));
                    105:        asm volatile ("mr 4, %0": : "r" (end));
                    106:        MVMEPROM_CALL(MVMEPROM_OUTLN);
                    107:        OSCTXT(msr);
                    108: }
                    109:
                    110: void
                    111: mvmeprom_outstr(start, end)
                    112:        char *start, *end;
                    113: {
                    114:        unsigned long msr;
                    115:
                    116:        BUGCTXT(msr);
                    117:        asm volatile ("mr 3, %0": : "r" (start));
                    118:        asm volatile ("mr 4, %0": : "r" (end));
                    119:        MVMEPROM_CALL(MVMEPROM_OUTSTR);
                    120:        OSCTXT(msr);
                    121: }
                    122:
                    123: void
                    124: mvmeprom_outchar(c)
                    125:        int c;
                    126: {
                    127:        unsigned long msr;
                    128:
                    129:        BUGCTXT(msr);
                    130:        asm  volatile ("mr 3, %0" :: "r" (c));
                    131:        MVMEPROM_CALL(MVMEPROM_OUTCHR);
                    132:        OSCTXT(msr);
                    133: }
                    134:
                    135: /* BUG - return to bug routine */
                    136: void
                    137: mvmeprom_return()
                    138: {
                    139:        unsigned long msr;
                    140:
                    141:        BUGCTXT(msr);
                    142:        MVMEPROM_CALL(MVMEPROM_RETURN);
                    143:        OSCTXT(msr);
                    144:        /*NOTREACHED*/
                    145: }
                    146:
                    147:
                    148: void
                    149: mvmeprom_rtc_rd(ptime)
                    150:        struct mvmeprom_time *ptime;
                    151: {
                    152:        unsigned long msr;
                    153:
                    154:        BUGCTXT(msr);
                    155:        asm volatile ("mr 3, %0": : "r" (ptime));
                    156:        MVMEPROM_CALL(MVMEPROM_RTC_RD);
                    157:        OSCTXT(msr);
                    158: }
                    159:
                    160: int
                    161: bugenvsz(void)
                    162: {
                    163:        register int ret;
                    164:        char tmp[1];
                    165:        void *ptr = tmp;
                    166:        unsigned long msr;
                    167:
                    168:        BUGCTXT(msr);
                    169:        asm volatile ("mr 3, %0": : "r" (ptr));
                    170:        asm volatile ("li 5, 0x1");
                    171:        asm volatile ("li 5, 0x0"); /* get size */
                    172:        MVMEPROM_CALL(MVMEPROM_ENVIRON);
                    173:        asm volatile ("mr %0, 3" :  "=r" (ret));
                    174:        OSCTXT(msr);
                    175:
                    176:        return(ret);
                    177: }
                    178:
                    179: struct bugenviron bugenviron;
                    180: int bugenv_init = 0;
                    181: char bugenv_buf[1024];
                    182:
                    183: #ifdef BUG_DEBUG
                    184: void bug_printenv(void);
                    185:
                    186: void
                    187: bug_printenv(void)
                    188: {
                    189:        printf("Startup Mode: %c\n", bugenviron.s.s_mode);
                    190:        printf("Startup Menu: %c\n", bugenviron.s.s_menu);
                    191:        printf("Remote Start: %c\n", bugenviron.s.s_remotestart);
                    192:        printf("Probe Devs: %c\n", bugenviron.s.s_probe);
                    193:        printf("Negate Sysfail: %c\n", bugenviron.s.s_negsysfail);
                    194:        printf("Reset SCSI Bus: %c\n", bugenviron.s.s_resetscsi);
                    195:        printf("Ignore CFNA Block: %c\n", bugenviron.s.s_nocfblk);
                    196:        printf("SCSI sync method: %c\n", bugenviron.s.s_scsisync);
                    197:
                    198:        printf("Auto Boot Enable: %c\n", bugenviron.b.b_enable);
                    199:        printf("Auto Boot on power-up Only: %c\n", bugenviron.b.b_poweruponly);
                    200:        printf("Auto Boot CLUN: %02x\n", bugenviron.b.b_clun);
                    201:        printf("Auto Boot DLUN: %02x\n", bugenviron.b.b_dlun);
                    202:        printf("Auto Boot Delay: %02x\n", bugenviron.b.b_delay);
                    203:        printf("Auto Boot String: %s\n", bugenviron.b.b_string);
                    204:
                    205:        printf("ROM Boot Enable: %c\n", bugenviron.r.r_enable);
                    206:        printf("ROM Boot on power-up Only: %c\n", bugenviron.r.r_poweruponly);
                    207:        printf("ROM Boot Scan VME bus: %c\n", bugenviron.r.r_bootvme);
                    208:        printf("ROM Boot Delay: %02x\n", bugenviron.r.r_delay);
                    209:        printf("ROM Boot Start: %08x\n", bugenviron.r.r_start);
                    210:        printf("ROM Boot End: %08x\n", bugenviron.r.r_end);
                    211:
                    212:        printf("Net Boot Enable: %c\n", bugenviron.n.n_enable);
                    213:        printf("Net Boot on power-up Only: %c\n", bugenviron.n.n_poweruponly);
                    214:        printf("Net Boot CLUN: %02x\n", bugenviron.n.n_clun);
                    215:        printf("Net Boot DLUN: %02x\n", bugenviron.n.n_dlun);
                    216:        printf("Net Boot Delay: %02x\n", bugenviron.n.n_delay);
                    217:        printf("Net Boot CFG param pointer: %08x\n", bugenviron.n.n_param);
                    218:
                    219:        printf("Memory Size Enable: %c\n", bugenviron.m.m_sizeenable);
                    220:        printf("Memory Start: %08x\n", bugenviron.m.m_start);
                    221:        printf("Memory End: %08x\n", bugenviron.m.m_end);
                    222:
                    223:        Debugger();
                    224: }
                    225: #else
                    226: #define        bug_printenv()
                    227: #endif
                    228:
                    229: struct bugenviron *
                    230: mvmeprom_envrd(void)
                    231: {
                    232:        register int ret;
                    233:        char *ptr, *dptr, *ptr_end;
                    234:        int env_size = 0;
                    235:        int pkt_typ, pkt_len;
                    236:        unsigned long msr;
                    237:
                    238:        env_size = bugenvsz();
                    239:         bzero(&bugenviron, sizeof(struct bugenviron));
                    240:         bzero(&bugenv_buf[0], 1024);
                    241:        ptr = bugenv_buf;
                    242:
                    243:        if (ptr != NULL) {
                    244:
                    245:                BUGCTXT(msr);
                    246:                asm volatile ("mr 3, %0": : "r" (ptr));
                    247:                asm volatile ("mr 4, %0": : "r" (env_size));
                    248:                asm volatile ("li 5, 0x2");
                    249:                MVMEPROM_CALL(MVMEPROM_ENVIRON);
                    250:                asm volatile ("mr %0, 3" :  "=r" (ret));
                    251:                OSCTXT(msr);
                    252:
                    253:                if (ret)
                    254:                        return NULL;
                    255:
                    256:                ptr_end = ptr + env_size;
                    257:                while (ptr <= ptr_end) {
                    258:                        pkt_typ = *ptr++;
                    259:                        pkt_len = *ptr++;
                    260:                        dptr = ptr;
                    261:                        switch (pkt_typ) {
                    262:                        case BUG_ENV_END:
                    263:                                bugenv_init = 1; /* we have read the env */
                    264:                                bug_printenv();
                    265:                                return(&bugenviron);
                    266:                                break;
                    267:                        case BUG_STARTUP_PARAM:
                    268:                                /* All chars.  We can use bcopy. */
                    269:                                bcopy(dptr, &bugenviron.s.s_mode, pkt_len);
                    270:                                break;
                    271:                        case BUG_AUTOBOOT_INFO:
                    272:                                /* All chars.  We can use bcopy. */
                    273:                                bcopy(dptr, &bugenviron.b.b_enable, pkt_len);
                    274:                                break;
                    275:                        case BUG_ROMBOOT_INFO:
                    276:                                /* This data stream has integer info that
                    277:                                 * may not be word aligned.  We can't use
                    278:                                 * bcopy for the whole struct in this
                    279:                                 * instance. */
                    280:                                bcopy(dptr, &bugenviron.r.r_enable, 4);
                    281:                                dptr+=4;
                    282:                                bcopy(dptr, &bugenviron.r.r_start, 4);
                    283:                                dptr+=4;
                    284:                                bcopy(dptr, &bugenviron.r.r_end, 4);
                    285:                                break;
                    286:                        case BUG_NETBOOT_INFO:
                    287:                                /* This data stream has integer info that
                    288:                                 * may not be word aligned.  We can't use
                    289:                                 * bcopy for the whole struct in this
                    290:                                 * instance. */
                    291:                                bcopy(dptr, &bugenviron.n.n_enable, 5);
                    292:                                dptr+=5;
                    293:                                bcopy(dptr, &bugenviron.n.n_param, 4);
                    294:                                break;
                    295:                        case BUG_MEMORY_INFO:
                    296:                                 bugenviron.m.m_sizeenable = *dptr++;
                    297:                                bcopy(dptr, &bugenviron.m.m_start, 4);
                    298:                                dptr+=4;
                    299:                                bcopy(dptr, &bugenviron.m.m_end, 4);
                    300:                                break;
                    301:                        }
                    302:                        ptr += pkt_len;
                    303:                }
                    304:        }
                    305:        return NULL;
                    306: }

CVSweb