[BACK]Return to crt0.c CVS log [TXT][DIR] Up to [local] / sys / arch / i386 / stand / boot

Annotation of sys/arch/i386/stand/boot/crt0.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: crt0.c,v 1.5 2003/06/03 20:22:11 mickey Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1997-1998 Michael Shalayeff
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  *
        !            16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            18:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            19:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            20:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            21:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            22:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            24:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            25:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            26:  * SUCH DAMAGE.
        !            27:  *
        !            28:  */
        !            29:
        !            30:
        !            31: #include <sys/param.h>
        !            32: #include <sys/types.h>
        !            33: #include <sys/mman.h>
        !            34: #include <sys/syscall.h>
        !            35: #include <termios.h>
        !            36: #include "libsa.h"
        !            37: #include <lib/libsa/unixdev.h>
        !            38:
        !            39: void start(void) asm("start");
        !            40: void _rtt(void);
        !            41: extern int  boot(dev_t);
        !            42: static void domap(void);
        !            43: static void seterm(void);
        !            44:
        !            45: void
        !            46: start()
        !            47: {
        !            48:        domap();
        !            49:        seterm();
        !            50:        uexit(boot(0));
        !            51: }
        !            52:
        !            53: void
        !            54: _rtt()
        !            55: {
        !            56:        uexit(1);
        !            57: }
        !            58:
        !            59: #define ummap(a,l,p,f,fd,o) (caddr_t)syscall((quad_t)SYS_mmap,a,l,p,f,fd,0,o)
        !            60:
        !            61: static void
        !            62: domap()
        !            63: {
        !            64:        extern char end[];
        !            65:        register caddr_t p = (caddr_t)(((u_long)end + PGOFSET) & ~PGOFSET);
        !            66:
        !            67:        /* map heap */
        !            68:        if ( (p = ummap(p, 32*NBPG, PROT_READ|PROT_WRITE,
        !            69:                   MAP_FIXED|MAP_ANON, -1, 0)) == (caddr_t)-1) {
        !            70:                printf("mmap failed: %d\n", errno);
        !            71:                uexit(1);
        !            72:        }
        !            73: #ifdef DEBUG
        !            74:        else
        !            75:                printf("mmap==%p\n", p);
        !            76: #endif
        !            77:
        !            78:        /* map kernel */
        !            79:        if ( (p = ummap(0x100000, 0xf00000, PROT_READ|PROT_WRITE,
        !            80:                   MAP_FIXED|MAP_ANON, -1, 0)) == (caddr_t)-1) {
        !            81:                printf("mmap failed: %d\n", errno);
        !            82:                uexit(1);
        !            83:        }
        !            84: #ifdef DEBUG
        !            85:        else
        !            86:                printf("mmap==%p\n", p);
        !            87: #endif
        !            88:
        !            89: }
        !            90:
        !            91: void
        !            92: seterm()
        !            93: {
        !            94:        struct termios tc;
        !            95:
        !            96:        if (uioctl(0, TIOCGETA, (char *)&tc) < 0) {
        !            97:                printf("cannot get tty\n");
        !            98:                uexit(1);
        !            99:        }
        !           100:
        !           101:         tc.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
        !           102:         tc.c_oflag &= ~OPOST;
        !           103:         tc.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
        !           104:         tc.c_cflag &= ~(CSIZE|PARENB);
        !           105:         tc.c_cflag |= CS8;
        !           106:
        !           107:        if (uioctl(0, TIOCSETA, (char *)&tc) < 0) {
        !           108:                printf("cannot set tty\n");
        !           109:                uexit(1);
        !           110:        }
        !           111: }

CVSweb