Annotation of Gnu-Mach/chips/sfb_hdw.c, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1992 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     File: sfb_hdw.c
        !            28:  *     Author: Alessandro Forin, Carnegie Mellon University
        !            29:  *     Date:   11/92
        !            30:  *
        !            31:  *     Driver for the Smart Color Frame Buffer Display,
        !            32:  *     hardware-level operations.
        !            33:  */
        !            34: 
        !            35: #include <sfb.h>
        !            36: #if    (NSFB > 0)
        !            37: #include <platforms.h>
        !            38: 
        !            39: #include <machine/machspl.h>
        !            40: #include <mach/std_types.h>
        !            41: #include <chips/busses.h>
        !            42: #include <chips/screen_defs.h>
        !            43: #include <chips/pm_defs.h>
        !            44: #include <machine/machspl.h>
        !            45: 
        !            46: typedef pm_softc_t     sfb_softc_t;
        !            47: 
        !            48: #ifdef DECSTATION
        !            49: #include <mips/PMAX/pmagb_ba.h>
        !            50: #include <mips/PMAX/tc.h>
        !            51: #endif
        !            52: 
        !            53: #ifdef FLAMINGO
        !            54: #include <mips/PMAX/pmagb_ba.h>                /* XXXX fixme */
        !            55: #include <alpha/DEC/tc.h>
        !            56: #define sparsify(x)    ((1L << 28) | (((x) & 0x7ffffff) << 1) | \
        !            57:                         ((x) & ~0x7ffffffL))
        !            58: #endif
        !            59: 
        !            60: #ifndef        sparsify
        !            61: #define sparsify(x) x
        !            62: #endif
        !            63: 
        !            64: /*
        !            65:  * Definition of the driver for the auto-configuration program.
        !            66:  */
        !            67: 
        !            68: int    sfb_probe(), sfb_intr();
        !            69: void   sfb_attach();
        !            70: 
        !            71: vm_offset_t    sfb_std[NSFB] = { 0 };
        !            72: struct bus_device *sfb_info[NSFB];
        !            73: struct bus_driver sfb_driver = 
        !            74:         { sfb_probe, 0, sfb_attach, 0, sfb_std, "sfb", sfb_info,
        !            75:          0, 0, BUS_INTR_DISABLED};
        !            76: 
        !            77: /*
        !            78:  * Probe/Attach functions
        !            79:  */
        !            80: 
        !            81: sfb_probe(
        !            82:        vm_offset_t     addr,
        !            83:        struct bus_device *device)
        !            84: {
        !            85:        static probed_once = 0;
        !            86: 
        !            87:        /*
        !            88:         * Probing was really done sweeping the TC long ago
        !            89:         */
        !            90:        if (tc_probe("sfb") == 0)
        !            91:                return 0;
        !            92:        if (probed_once++ > 1) {
        !            93:                printf("[mappable] ");
        !            94:                device->address = addr;
        !            95:        }
        !            96:        return 1;
        !            97: }
        !            98: 
        !            99: void sfb_attach(
        !           100:        struct bus_device *ui)
        !           101: {
        !           102:        /* ... */
        !           103:        printf(": smart frame buffer");
        !           104: }
        !           105: 
        !           106: 
        !           107: /*
        !           108:  * Interrupt routine
        !           109:  */
        !           110: 
        !           111: sfb_intr(
        !           112:        int     unit,
        !           113:        spl_t   spllevel)
        !           114: {
        !           115:        register volatile char *ack;
        !           116: 
        !           117:        /* acknowledge interrupt */
        !           118:        ack = (volatile char *) sfb_info[unit]->address + SFB_OFFSET_ICLR;
        !           119:        *ack = 0;
        !           120: 
        !           121: #if    mips
        !           122:        splx(spllevel);
        !           123: #endif
        !           124:        lk201_led(unit);
        !           125: }
        !           126: 
        !           127: sfb_vretrace(
        !           128:        sfb_softc_t     *sfb,
        !           129:        boolean_t       on)
        !           130: {
        !           131:        sfb_regs        *regs;
        !           132: 
        !           133:        regs = (sfb_regs *) ((char *)sfb->framebuffer - SFB_OFFSET_VRAM + SFB_OFFSET_REGS);
        !           134: 
        !           135:        regs->intr_enable = (on) ? 1 : 0;
        !           136: }
        !           137: 
        !           138: /*
        !           139:  * Boot time initialization: must make device
        !           140:  * usable as console asap.
        !           141:  */
        !           142: #define sfb_set_status                 cfb_set_status
        !           143: 
        !           144: extern int
        !           145:        sfb_soft_reset(), sfb_set_status(),
        !           146:        sfb_pos_cursor(), bt459_video_on(),
        !           147:        bt459_video_off(), sfb_vretrace(),
        !           148:        pm_get_status(), pm_char_paint(),
        !           149:        pm_insert_line(), pm_remove_line(),
        !           150:        pm_clear_bitmap(), pm_map_page();
        !           151: 
        !           152: static struct screen_switch sfb_sw = {
        !           153:        screen_noop,            /* graphic_open */
        !           154:        sfb_soft_reset,         /* graphic_close */
        !           155:        sfb_set_status,         /* set_status */
        !           156:        pm_get_status,          /* get_status */
        !           157:        pm_char_paint,          /* char_paint */
        !           158:        sfb_pos_cursor,         /* pos_cursor */
        !           159:        pm_insert_line,         /* insert_line */
        !           160:        pm_remove_line,         /* remove_line */
        !           161:        pm_clear_bitmap,        /* clear_bitmap */
        !           162:        bt459_video_on,         /* video_on */
        !           163:        bt459_video_off,        /* video_off */
        !           164:        sfb_vretrace,           /* intr_enable */
        !           165:        pm_map_page             /* map_page */
        !           166: };
        !           167: 
        !           168: sfb_cold_init(
        !           169:        int             unit,
        !           170:        user_info_t     *up)
        !           171: {
        !           172:        sfb_softc_t     *sfb;
        !           173:        screen_softc_t  sc = screen(unit);
        !           174:        vm_offset_t     base = tc_probe("sfb");
        !           175:        int             hor_p, ver_p;
        !           176:        boolean_t       makes_sense;
        !           177: 
        !           178:        bcopy(&sfb_sw, &sc->sw, sizeof(sc->sw));
        !           179:        sc->flags |= COLOR_SCREEN;
        !           180: 
        !           181:        /*
        !           182:         * I am confused here by the documentation.  One document
        !           183:         * sez there are three boards:
        !           184:         *      "PMAGB-BA" can do 1280x1024 @66Hz or @72Hz
        !           185:         *      "PMAGB-BC" can do 1024x864  @60Hz or 1280x1024 @72Hz
        !           186:         *      "PMAGB-BE" can do 1024x768  @72Hz or 1280x1024 @72Hz
        !           187:         * Another document sez things differently:
        !           188:         *      "PMAGB-BB" can do 1024x768  @72Hz
        !           189:         *      "PMAGB-BD" can do 1024x864  @60Hz or 1280x1024 @72Hz
        !           190:         *
        !           191:         * I would be inclined to believe the first one, which came
        !           192:         * with an actual piece of hardware attached (a PMAGB-BA).
        !           193:         * But I could swear I got a first board (which blew up
        !           194:         * instantly) and it was calling itself PMAGB-BB...
        !           195:         *
        !           196:         * Since I have not seen any other hardware I will make
        !           197:         * this code as hypothetical as I can.  Should work :-))
        !           198:         */
        !           199: 
        !           200:        makes_sense = FALSE;
        !           201: 
        !           202:        {
        !           203:                sfb_regs        *regs;
        !           204: 
        !           205:                regs = (sfb_regs *) ((char *)base + SFB_OFFSET_REGS);
        !           206:                hor_p = (regs->vhor_setup & 0x1ff) * 4;
        !           207:                ver_p = regs->vvert_setup & 0x7ff;
        !           208: 
        !           209:                if (((hor_p == 1280) && (ver_p == 1024)) ||
        !           210:                    ((hor_p == 1024) && (ver_p == 864)) ||
        !           211:                    ((hor_p == 1024) && (ver_p == 768)))
        !           212:                        makes_sense = TRUE;
        !           213:        }       
        !           214: 
        !           215:        if (makes_sense) {
        !           216:                sc->frame_scanline_width = hor_p;
        !           217:                sc->frame_height = ver_p;
        !           218:                sc->frame_visible_width = hor_p;
        !           219:                sc->frame_visible_height = ver_p;
        !           220:        } else {
        !           221:                sc->frame_scanline_width = 1280;
        !           222:                sc->frame_height = 1024;
        !           223:                sc->frame_visible_width = 1280;
        !           224:                sc->frame_visible_height = 1024;
        !           225:        }
        !           226: 
        !           227:        pm_init_screen_params(sc,up);
        !           228:        (void) screen_up(unit, up);
        !           229: 
        !           230:        sfb = pm_alloc( unit, sparsify(base + SFB_OFFSET_BT459),
        !           231:                        base + SFB_OFFSET_VRAM, -1);
        !           232: 
        !           233:        screen_default_colors(up);
        !           234: 
        !           235:        sfb_soft_reset(sc);
        !           236: 
        !           237:        /*
        !           238:         * Clearing the screen at boot saves from scrolling
        !           239:         * much, and speeds up booting quite a bit.
        !           240:         */
        !           241:        screen_blitc( unit, 'C'-'@');/* clear screen */
        !           242: }
        !           243: 
        !           244: #if    0       /* this is how you find out about a new screen */
        !           245: fill(addr,n,c)
        !           246:        char *addr;
        !           247: {
        !           248:        while (n-- > 0) *addr++ = c;
        !           249: }
        !           250: #endif
        !           251: 
        !           252: 
        !           253: #endif (NSFB > 0)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.