⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdcons.c

📁 open bsd stand lib of sys
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)qdcons.c	7.5 (Berkeley) 12/16/90 *//* *	derived from: @(#)qdcons.c  4.1 (ULTRIX    11/23/87 *//**************************************************************************	ULTRIX QDSS STANDALONE BOOT DEVICE DRIVER...*	device driver to boot system with QDSS as console**************************************************************************//*************************************************************************									**			Copyright (c) 1985 by				**		Digital Equipment Corporation, Maynard, MA		**			All rights reserved.				**									**   This software is furnished under a license and may be used and	**   copied  only  in accordance with the terms of such license and	**   with the  inclusion  of  the  above  copyright  notice.   This	**   software  or  any  other copies thereof may not be provided or	**   otherwise made available to any other person.  No title to and	**   ownership of the software is hereby transferred.			**									**   The information in this software is subject to change  without	**   notice  and should not be construed as a commitment by Digital	**   Equipment Corporation.						**									**   Digital assumes no responsibility for the use  or  reliability	**   of its software on equipment which is not supplied by Digital.	**									*************************************************************************** revision history: (should be moved into sccs comments)*************************************************************************** 09 oct 85  longo  added uVAXII console ROM cursor reset to bottom of*		    the screen.  Also spruced up qdputc() & scroll_up()* 02 oct 85  longo  changed references to ADDRESS to be ADDRESS_COMPLETE* 23 aug 85  longo  changed I/O page CSR address to be 0x1F00* 20 aug 85  longo  created*************************************************************************/#include "sys/types.h"#include "../include/cpu.h"#define KERNEL#include "../uba/qdioctl.h"#include "../uba/qevent.h"#include "../uba/qduser.h"#include "../uba/qdreg.h"#undef KERNEL/*-----------------------------------------------------------------------* constants used to set VAX ROM's cursor to bottom the of the screen  */#define NVR_ADRS	0x200B8024#define CURRENT_ROW	0x4C	/* these are offsets to the ROM's scratch.. */#define ROW_MIN		0x4D    /* ..RAM start adrs as picked up out of NVR */#define ROW_MAX		0x4E#define CURRENT_COL	0x50#define COL_MIN		0x51#define COL_MAX		0x52/*----------------------------------------* LK201 keyboard state tracking struct */	struct q_keyboard {	    int shift;			/* state variables	*/	    int cntrl;	    int lock;	    char last;			/* last character	*/	 } q_keyboard;	int qdputc(), qdgetc();	extern (*v_putc)(),(*v_getc)();/*----------------------------* general purpose defines  */#define BAD	-1#define GOOD	0/*----------------------------------------------* console cursor bitmap (block cursor type)  */	short cons_cursor[32] = {      /* white block cursor */ /* A */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 	 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, /* B */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,         0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF	};/*-------------------------------------* constants used in font operations */#define CHARS		95			/* # of chars in the font */#define CHAR_HEIGHT	15			/* char height in pixels */#define CHAR_WIDTH	8			/* char width in pixels*/#define FONT_WIDTH	(CHAR_WIDTH * CHARS)    /* font width in pixels */#define ROWS  		CHAR_HEIGHT#define FONT_X		0			/* font's off screen adrs */#define FONT_Y		(2047 - CHAR_HEIGHT) /*#define FONT_Y		200*/	extern char q_font[];		/* reference font object code */	extern  char q_key[];		/* reference key xlation tables */	extern  char q_shift_key[];	extern  char *q_special[];/*----------------------------* console cursor structure */	struct cons_cur {	    int x;	    int y;	} cursor;/*------------------------------------------* MicroVAX-II q-bus addressing constants */#define QMEMBASE 0x30000000#define QDSSCSR  0x20001F00#define CHUNK     (64 * 1024)#define QMEMSIZE  (1024 * 1024 * 4)#define	QDBASE    (QMEMBASE + QMEMSIZE - CHUNK)/*------------------------------------------------------------------* QDSS register address offsets from start of QDSS address space */#define QDSIZE 	 (52 * 1024)	/* size of entire QDSS foot print */#define TMPSIZE  (16 * 1024)	/* template RAM is 8k SHORT WORDS */#define TMPSTART 0x8000		/* offset of template RAM from base adrs */#define REGSIZE	 (5 * 512)	/* regs touch 2.5k (5 pages) of addr space */#define REGSTART 0xC000		/* offset of reg pages from base adrs */#define ADDER	(REGSTART+0x000)#define DGA	(REGSTART+0x200)#define DUART	(REGSTART+0x400)#define MEMCSR  (REGSTART+0x800)#define	CLRSIZE  (3 * 512)		/* color map size */#define CLRSTART (REGSTART+0xA00)	/* color map start offset from base */					/*  0x0C00 really */#define RED	(CLRSTART+0x000)#define BLUE	(CLRSTART+0x200)#define GREEN	(CLRSTART+0x400)/*---------------------------------------* QDSS register address map structure */	struct qdmap qdmap;/****************************************************************************************************************************************************************************************************************************	EXTERNALLY CALLED ROUTINES START HERE:***************************************************************************************************************************************************************************************************************************//**************************************************************************	qd_init()... init the QDSS into a physical memory system*************************************************************************/qd_init(){	register char *ROM_console;	register short *NVR;	register int i;	caddr_t qdaddr;	struct dga *dga;	extern int cpu; 	qdaddr = (caddr_t) QDSSCSR;        if (badaddr(qdaddr, sizeof(short)))            return(0);	*(short *)qdaddr = (short) (QDBASE >> 16);/*----------------------------------------------------------------------* load qdmap struct with the physical addresses of the QDSS elements */	qdmap.template = (caddr_t) QDBASE + TMPSTART;	qdmap.adder = (caddr_t) QDBASE + ADDER;	qdmap.dga = (caddr_t) QDBASE + DGA;	qdmap.duart = (caddr_t) QDBASE + DUART;	qdmap.memcsr = (caddr_t) QDBASE + MEMCSR;	qdmap.red = (caddr_t) QDBASE + RED;	qdmap.blue = (caddr_t) QDBASE + BLUE;	qdmap.green = (caddr_t) QDBASE + GREEN;/*--------------------------* no interrupts allowed! */	dga = (struct dga *) qdmap.dga;	dga->csr = HALT;	dga->csr |= CURS_ENB;/*----------------------------* init the default values  */	q_keyboard.shift = 0;		/* init keyboard state tracking */	q_keyboard.lock = 0;	q_keyboard.cntrl = 0;	q_keyboard.last = 0;	cursor.x = 0;			/* init cursor to top left */	cursor.y = 0;	set_defaults();		        /* setup the default device */	ldfont();			/* PtoB the font into off-screen *//*--------------------------------------------------------------------* tell the VAX ROM that the cursor is at the bottom of the screen  */	if (cpu == VAX_630) {		NVR = (short *) NVR_ADRS;		i = *NVR++ & 0xFF;		i |= (*NVR++ & 0xFF) << 8;		i |= (*NVR++ & 0xFF) << 16;		i |= (*NVR++ & 0xFF) << 24;		ROM_console = (char *) i;		ROM_console[CURRENT_COL] = ROM_console[COL_MIN];		ROM_console[CURRENT_ROW] = ROM_console[ROW_MAX];	}/*----------------------------------------------------------* smash system virtual console service routine addresses */	printf("switching console to QDSS display...\n");	v_getc = qdgetc;	v_putc = qdputc;	return(1);} /* qd_init *//******************************************************************* **	qdputc()... output a character to the QDSS screen***********************************************************************	calling convention:**		qdputc(chr);*		char chr; 		;character to be displayed*********/qdputc(chr)char chr;{	register struct adder *adder;	register struct dga *dga;	register int i;	short x;	adder = (struct adder *) qdmap.adder;	dga = (struct dga *) qdmap.dga;/*---------------------------* non display character?  */	chr &= 0x7F;	switch (chr) {	    case '\r':			/* return char */	        cursor.x = 0;		dga->x_cursor = TRANX(cursor.x);	    	return(0);	    case '\t':			/* tab char */	    	for (i = 8 - ((cursor.x >> 3) & 0x07); i > 0; --i) {	    	    qdputc(' ');		}		return(0);	    case '\n':			/* line feed char */	        if ((cursor.y += CHAR_HEIGHT) > (863 - CHAR_HEIGHT)) {		    cursor.y -= CHAR_HEIGHT;		    scroll_up(adder);		}		dga->y_cursor = TRANY(cursor.y);		return(0);	    case '\b':			/* backspace char */	        if (cursor.x > 0) {	    	    cursor.x -= CHAR_WIDTH;		    qdputc(' ');		    cursor.x -= CHAR_WIDTH;		    dga->x_cursor = TRANX(cursor.x);		}		return(0);	    default:		if (chr < ' ' || chr > '~') {		    return(0);		}	}/*------------------------------------------* setup VIPER operand control registers  */	write_ID(adder, CS_UPDATE_MASK, 0x0001);  /* select plane #0 */	write_ID(adder, SRC1_OCR_B, 			EXT_NONE | INT_SOURCE | ID | BAR_SHIFT_DELAY);	write_ID(adder, CS_UPDATE_MASK, 0x00FE);  /* select other planes */	write_ID(adder, SRC1_OCR_B, 			EXT_SOURCE | INT_NONE | NO_ID | BAR_SHIFT_DELAY);	write_ID(adder, CS_UPDATE_MASK, 0x00FF);  /* select all planes */	write_ID(adder, DST_OCR_B, 			EXT_NONE | INT_NONE | NO_ID | NO_BAR_SHIFT_DELAY);	write_ID(adder, MASK_1, 0xFFFF);	write_ID(adder, VIPER_Z_LOAD | FOREGROUND_COLOR_Z, 1);	write_ID(adder, VIPER_Z_LOAD | BACKGROUND_COLOR_Z, 0);/*----------------------------------------* load DESTINATION origin and vectors  */	adder->fast_dest_dy = 0;	adder->slow_dest_dx = 0;	adder->error_1 = 0;	adder->error_2 = 0;	adder->rasterop_mode = DST_WRITE_ENABLE | NORMAL;	wait_status(adder, RASTEROP_COMPLETE);	adder->destination_x = cursor.x;	adder->fast_dest_dx = CHAR_WIDTH;	adder->destination_y = cursor.y;	adder->slow_dest_dy = CHAR_HEIGHT;/*-----------------------------------* load SOURCE origin and vectors  */	adder->source_1_x = FONT_X + ((chr - ' ') * CHAR_WIDTH);	adder->source_1_y = FONT_Y;	adder->source_1_dx = CHAR_WIDTH;	adder->source_1_dy = CHAR_HEIGHT;	write_ID(adder, LU_FUNCTION_R1, FULL_SRC_RESOLUTION | LF_SOURCE);	adder->cmd = RASTEROP | OCRB | 0 | S1E | DTE;/*-------------------------------------* update console cursor coordinates */	cursor.x += CHAR_WIDTH;	dga->x_cursor = TRANX(cursor.x);        if (cursor.x > (1024 - CHAR_WIDTH)) {	    qdputc('\r');	    qdputc('\n');	}} /* qdputc */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -