[BACK]Return to sboot.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvme88k / stand / sboot

Annotation of sys/arch/mvme88k/stand/sboot/sboot.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: sboot.c,v 1.4 2006/05/16 22:52:26 miod Exp $  */
                      2:
                      3: /*
                      4:  * Copyright (c) 1995 Theo de Raadt
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     18:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
                     19:  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     21:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25:  * SUCH DAMAGE.
                     26:  *
                     27:  * Copyright (c) 1995 Charles D. Cranor and Seth Widoff
                     28:  * All rights reserved.
                     29:  *
                     30:  * Redistribution and use in source and binary forms, with or without
                     31:  * modification, are permitted provided that the following conditions
                     32:  * are met:
                     33:  * 1. Redistributions of source code must retain the above copyright
                     34:  *    notice, this list of conditions and the following disclaimer.
                     35:  * 2. Redistributions in binary form must reproduce the above copyright
                     36:  *    notice, this list of conditions and the following disclaimer in the
                     37:  *    documentation and/or other materials provided with the distribution.
                     38:  * 3. All advertising materials mentioning features or use of this software
                     39:  *    must display the following acknowledgement:
                     40:  *      This product includes software developed by Charles D. Cranor
                     41:  *     and Seth Widoff.
                     42:  * 4. The name of the author may not be used to endorse or promote products
                     43:  *    derived from this software without specific prior written permission.
                     44:  *
                     45:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     46:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     47:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     48:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     49:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     50:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     51:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     52:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     53:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     54:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     55:  */
                     56:
                     57: #include <sys/cdefs.h>
                     58: #include "sboot.h"
                     59:
                     60: void
                     61: main()
                     62: {
                     63:        char    buf[128];
                     64:
                     65:        buf[0] = '0';
                     66:        printf("\nsboot: MVME147 bootstrap program\n");
                     67:        while (1) {
                     68:                printf(">>> ");
                     69:                gets(buf);
                     70:                do_cmd(buf);
                     71:        }
                     72:        /* not reached */
                     73: }
                     74:
                     75: /*
                     76:  * exit to rom
                     77:  */
                     78: void
                     79: callrom()
                     80: {
                     81:        asm("trap #15; .word 0x0063");
                     82: }
                     83:
                     84: /*
                     85:  * do_cmd: do a command
                     86:  */
                     87: void
                     88: do_cmd(buf)
                     89:        char   *buf;
                     90: {
                     91:        switch (*buf) {
                     92:        case '\0':
                     93:                break;
                     94:        case 'a':
                     95:                if (rev_arp()) {
                     96:                        printf("My ip address is: %d.%d.%d.%d\n", myip[0],
                     97:                            myip[1], myip[2], myip[3]);
                     98:                        printf("Server ip address is: %d.%d.%d.%d\n", servip[0],
                     99:                            servip[1], servip[2], servip[3]);
                    100:                } else {
                    101:                        printf("Failed.\n");
                    102:                }
                    103:                break;
                    104:        case 'q':
                    105:                printf("exiting to ROM\n");
                    106:                callrom();
                    107:                break;
                    108:        case 'f':
                    109:                if (do_get_file() == 1) {
                    110:                        printf("Download Failed\n");
                    111:                } else {
                    112:                        printf("Download was a success!\n");
                    113:                }
                    114:                break;
                    115:        case 'b':
                    116:                le_init();
                    117:                if (rev_arp()) {
                    118:                        printf("client IP address %d.%d.%d.%d\n", myip[0],
                    119:                            myip[1], myip[2], myip[3]);
                    120:                        printf("server IP address %d.%d.%d.%d\n", servip[0],
                    121:                            servip[1], servip[2], servip[3]);
                    122:                } else {
                    123:                        printf("REVARP: Failed.\n");
                    124:                        return;
                    125:                }
                    126:                if (do_get_file() == 1) {
                    127:                        printf("Download Failed\n");
                    128:                        return;
                    129:                } else {
                    130:                        printf("received secondary boot program.\n");
                    131:                }
                    132:                if (*++buf == '\0')
                    133:                        buf = "bsd";
                    134:                go(buf);
                    135:                break;
                    136:        case 'h':
                    137:        case '?':
                    138:                printf("valid commands\n");
                    139:                printf("a - send a RARP\n");
                    140:                printf("b - boot the system\n");
                    141:                printf("q - exit to ROM\n");
                    142:                printf("f - ftp the boot file\n");
                    143:                printf("g - execute the boot file\n");
                    144:                printf("h - help\n");
                    145:                printf("i - init LANCE enet chip\n");
                    146:                break;
                    147:        case 'i':
                    148:                le_init();
                    149:                break;
                    150:        case 'g':
                    151:                go(buf);
                    152:                break;
                    153:        default:
                    154:                printf("sboot: %s: Unknown command\n", buf);
                    155:        }
                    156: }
                    157:
                    158: go(buf)
                    159:        char *buf;
                    160: {
                    161:        void (*entry)() = (void (*))LOAD_ADDR;
                    162:
                    163:        printf("jumping to boot program at 0x%x.\n", entry);
                    164:
                    165:        asm("clrl d0; clrl d1");        /* XXX network device */
                    166:        asm("movl %0, a3" : : "a" (buf) : "a3");
                    167:        asm("movl %0, a4" : : "a" (buf + strlen(buf)) : "a4");
                    168:        asm("jmp %0@" : : "a" (entry));
                    169: }

CVSweb