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

Annotation of sys/arch/alpha/stand/prom.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: prom.c,v 1.5 1997/01/24 19:58:07 niklas Exp $ */
        !             2: /*     $NetBSD: prom.c,v 1.2 1996/11/25 16:18:16 cgd Exp $     */
        !             3:
        !             4: /*
        !             5:  * Mach Operating System
        !             6:  * Copyright (c) 1992 Carnegie Mellon University
        !             7:  * All Rights Reserved.
        !             8:  *
        !             9:  * Permission to use, copy, modify and distribute this software and its
        !            10:  * documentation is hereby granted, provided that both the copyright
        !            11:  * notice and this permission notice appear in all copies of the
        !            12:  * software, derivative works or modified versions, and any portions
        !            13:  * thereof, and that both notices appear in supporting documentation.
        !            14:  *
        !            15:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            16:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            17:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            18:  *
        !            19:  * Carnegie Mellon requests users of this software to return to
        !            20:  *
        !            21:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
        !            22:  *  School of Computer Science
        !            23:  *  Carnegie Mellon University
        !            24:  *  Pittsburgh PA 15213-3890
        !            25:  *
        !            26:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            27:  * the rights to redistribute these changes.
        !            28:  */
        !            29:
        !            30: #include <sys/types.h>
        !            31:
        !            32: #include <machine/rpb.h>
        !            33: #include <machine/prom.h>
        !            34:
        !            35: int console;
        !            36:
        !            37: void
        !            38: init_prom_calls()
        !            39: {
        !            40:        extern struct prom_vec prom_dispatch_v;
        !            41:        struct rpb *r;
        !            42:        struct crb *c;
        !            43:        char buf[4];
        !            44:
        !            45:        r = (struct rpb *)HWRPB_ADDR;
        !            46:        c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off);
        !            47:
        !            48:        prom_dispatch_v.routine_arg = c->crb_v_dispatch;
        !            49:        prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
        !            50:
        !            51:        /* Look for console tty. */
        !            52:        prom_getenv(PROM_E_TTY_DEV, buf, 4);
        !            53:        console = buf[0] - '0';
        !            54: }
        !            55:
        !            56: int
        !            57: getchar()
        !            58: {
        !            59:        prom_return_t ret;
        !            60:
        !            61:        for (;;) {
        !            62:                ret.bits = prom_dispatch(PROM_R_GETC, console);
        !            63:                if (ret.u.status == 0 || ret.u.status == 1)
        !            64:                        return (ret.u.retval);
        !            65:        }
        !            66: }
        !            67:
        !            68: void
        !            69: putchar(c)
        !            70:        int c;
        !            71: {
        !            72:        prom_return_t ret;
        !            73:        char cbuf;
        !            74:
        !            75:        if (c == '\r' || c == '\n') {
        !            76:                cbuf = '\r';
        !            77:                do {
        !            78:                        ret.bits = prom_dispatch(PROM_R_PUTS, console,
        !            79:                            &cbuf, 1);
        !            80:                } while ((ret.u.retval & 1) == 0);
        !            81:                cbuf = '\n';
        !            82:        } else
        !            83:                cbuf = c;
        !            84:        do {
        !            85:                ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
        !            86:        } while ((ret.u.retval & 1) == 0);
        !            87: }
        !            88:
        !            89: int
        !            90: prom_getenv(id, buf, len)
        !            91:        int id, len;
        !            92:        char *buf;
        !            93: {
        !            94:        prom_return_t ret;
        !            95:
        !            96:        ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1);
        !            97:        if (ret.u.status & 0x4)
        !            98:                ret.u.retval = 0;
        !            99:        buf[ret.u.retval] = '\0';
        !           100:
        !           101:        return (ret.u.retval);
        !           102: }
        !           103:
        !           104: int
        !           105: prom_open(dev, len)
        !           106:        char *dev;
        !           107:        int len;
        !           108: {
        !           109:        prom_return_t ret;
        !           110:
        !           111:        ret.bits = prom_dispatch(PROM_R_OPEN, dev, len);
        !           112:        if (ret.u.status & 0x4)
        !           113:                return (-1);
        !           114:        else
        !           115:                return (ret.u.retval);
        !           116: }

CVSweb