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

📄 suncons.c

📁 arm平台上的uclinux系统全部源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		con_fb_base=sparc_alloc_io ((void*) cg3+CG3_RAM, 0,                    fbinfo [slot].type.fb_size, "cg3_ram", cg3_io, 0);	}}/* OBio addresses for the bwtwo registers */#define BWTWO_REGISTER_OFFSET 0x400000struct bwtwo_regs {	char          unknown [16];#define BWTWO_ENABLE_VIDEO 0x40	unsigned char control;	char          unknown2 [15];};static intbwtwo_mmap (struct inode *inode, struct file *file, struct vm_area_struct *vma, long base, void *xx){	unsigned int size, map_offset, r;	fbinfo_t *fb = (fbinfo_t *) xx;	int map_size;		map_size = size = vma->vm_end - vma->vm_start;		if (vma->vm_offset & ~PAGE_MASK)		return -ENXIO;	/* To stop the swapper from even considering these pages */	vma->vm_flags |= FB_MMAP_VM_FLAGS;	printk ("base=%8.8xl start=%8.8xl size=%x offset=%8.8x\n",		(unsigned int) base,		(unsigned int) vma->vm_start, size,		(unsigned int) vma->vm_offset);	/* This routine should also map the register if asked for, but we don't do that yet */	map_offset = get_phys ((uint) con_fb_base);	r = io_remap_page_range (vma->vm_start, map_offset, map_size, vma->vm_page_prot,				 fb->space);	if (r) return -EAGAIN;	vma->vm_inode = inode;	inode->i_count++;	return 0;}static voidbwtwo_blank (void *xx){	fbinfo_t *fb = (fbinfo_t *) xx;	fb->info.bwtwo.regs->control &= ~BWTWO_ENABLE_VIDEO;}static voidbwtwo_unblank (void *xx){	fbinfo_t *fb = (fbinfo_t *) xx;	fb->info.bwtwo.regs->control |= BWTWO_ENABLE_VIDEO;}static voidbwtwo_setup (int slot, unsigned int bwtwo, int bw2_io){	printk ("bwtwo%d at 0x%8.8x\n", slot, bwtwo);	fbinfo [slot].type.fb_cmsize = 2;	fbinfo [slot].mmap = bwtwo_mmap;	fbinfo [slot].loadcmap = 0;	fbinfo [slot].ioctl = 0;	fbinfo [slot].blank = bwtwo_blank;	fbinfo [slot].unblank = bwtwo_unblank;	fbinfo [slot].info.bwtwo.regs = sparc_alloc_io ((void *) bwtwo+BWTWO_REGISTER_OFFSET,		0, sizeof (struct bwtwo_regs), "bwtwo_regs", bw2_io, 0);}static voidcg14_setup (int slot, unsigned int cg14, int cg14_io){	printk ("cgfourteen%d at 0x%8.8x\n", slot, cg14);	fbinfo [slot].type.fb_cmsize = 256;	fbinfo [slot].mmap =  0;	fbinfo [slot].loadcmap = 0;	fbinfo [slot].ioctl = 0;	fbinfo [slot].blank = 0;	fbinfo [slot].unblank = 0;}static char *known_cards [] = {	"cgsix", "cgthree", "bwtwo", "SUNW,tcx", "cgfourteen", 0};static intknown_card (char *name){	int i;	for (i = 0; known_cards [i]; i++)		if (strcmp (name, known_cards [i]) == 0)			return 1;	return 0;}static struct {	int depth;	int resx, resy;	int x_margin, y_margin;} scr_def [] = {	{ 1, 1152, 900,  8,  18 },	{ 8, 1152, 900,  64, 18 },	{ 8, 1280, 1024, 96, 80 },	{ 8, 1024, 768,  0,  0 },	{ 0 },};static intcg14_present(void){	int root, n;	prom_printf ("Looking for cg14\n");	root = prom_getchild (prom_root_node);	if ((n = prom_searchsiblings (root, "obio")) == 0)		return 0;	n = prom_getchild (n);	if ((n = prom_searchsiblings (n, "cgfourteen")) == 0)		return 0;	prom_printf ("Cg14 found!\n");	return n;}static intsparc_console_probe(void){	int propl, con_node, i;	struct linux_sbus_device *sbdp;	unsigned int fbbase = 0xb001b001;	int fbiospace = 0;	int cg14 = 0;	/* XXX The detection code needs to support multiple video cards in one system */	con_node = 0;	switch(prom_vers) {	case PROM_V0:		/* V0 proms are at sun4c only. Can skip many checks. */		con_type = FBTYPE_NOTYPE;		if(SBus_chain == 0) {			prom_printf("SBUS chain is NULL, bailing out...\n");			prom_halt();		}		for_each_sbusdev(sbdp, SBus_chain) {			con_node = sbdp->prom_node;			/* If no "address" than it is not the PROM console. */			if(sbdp->num_vaddrs) {				if(!strncmp(sbdp->prom_name, "cgsix", 5)) {					con_type = FBTYPE_SUNFAST_COLOR;					fbbase = (uint) sbdp->reg_addrs [0].phys_addr;					fbiospace = sbdp->reg_addrs[0].which_io;					break;				} else if(!strncmp(sbdp->prom_name, "cgthree", 7)) {					con_type = FBTYPE_SUN3COLOR;					fbbase = (uint) sbdp->reg_addrs [0].phys_addr;					fbiospace = sbdp->reg_addrs[0].which_io;					break;				} else if (!strncmp(sbdp->prom_name, "bwtwo", 5)) {					con_type = FBTYPE_SUN2BW;					fbbase = (uint) sbdp->reg_addrs [0].phys_addr;					fbiospace = sbdp->reg_addrs[0].which_io;					break;				}			}		}		if(con_type == FBTYPE_NOTYPE) return -1;		con_fb_base = (unsigned char *) sbdp->sbus_vaddrs[0];		strncpy(con_name, sbdp->prom_name, sizeof (con_name));		break;	case PROM_V2:	case PROM_V3:	case PROM_P1275:		for_each_sbusdev(sbdp, SBus_chain) {		        prom_printf ("Trying: %s\n", sbdp->prom_name);			if (known_card (sbdp->prom_name))				break;		}		if (!sbdp){			if (!(cg14 = cg14_present ())){				prom_printf ("Could not find a known video card on this machine\n");				prom_halt ();			} 		}		if (!cg14){			prom_apply_sbus_ranges (&sbdp->reg_addrs [0], sbdp->num_registers);			fbbase = (long) sbdp->reg_addrs [0].phys_addr;			fbiospace = sbdp->reg_addrs[0].which_io;			con_node = (*romvec->pv_v2devops.v2_inst2pkg)				(*romvec->pv_v2bootargs.fd_stdout);			/*			 * Determine the type of hardware accelerator.			 */			propl = prom_getproperty(con_node, "emulation", con_name, sizeof (con_name));			if (propl < 0 || propl >= sizeof (con_name)) {				/* Early cg3s had no "emulation". */				propl = prom_getproperty(con_node, "name", con_name, sizeof (con_name));				if (propl < 0) {					prom_printf("console: no device name!!\n");					return -1;				}			}			if(!strncmp(con_name, "cgsix", sizeof (con_name))) {				con_type = FBTYPE_SUNFAST_COLOR;			} else if(!strncmp(con_name, "cgthree", sizeof (con_name))) {				con_type = FBTYPE_SUN3COLOR;			} else if(!strncmp(con_name, "cgfourteen", sizeof (con_name))) {				con_type = FBTYPE_MDICOLOR;			} else if(!strncmp(con_name, "bwtwo", sizeof (con_name))) {				con_type = FBTYPE_SUN2BW;			} else if(!strncmp(con_name,"SUNW,tcx", sizeof (con_name))){				con_type = FBTYPE_SUN3COLOR;			} else {				prom_printf("console: \"%s\" is unsupported\n", con_name);				return -1;			}			propl = prom_getproperty(con_node, "address", (char *) &con_fb_base, 4);			if (propl != 4) {				con_fb_base = 0;			}		} else {			int bases [2];			con_node = cg14;			prom_printf ("Found a cg14\n");			propl = prom_getproperty (cg14, "address",						  (char *) &bases[0], 8);			prom_printf ("Size=%d, %x\n", propl, bases [1]);			con_fb_base = (unsigned char *) bases [1];			con_type = FBTYPE_MDICOLOR;		}		break;	default:		return -1;	};	/* Get the device geometry */	con_linebytes = prom_getintdefault(con_node, "linebytes", 1152);	con_width = prom_getintdefault(con_node, "width", 1152);	con_height = prom_getintdefault(con_node, "height", 900);	/* Currently we just support 1-bit and 8-bit depth displays */	if (con_type == FBTYPE_SUN2BW) {		con_depth = 1;	} else {		con_depth = 8;	}	for (i = 0; scr_def [i].depth; i++){		if (scr_def [i].resx != con_width || scr_def [i].resy != con_height)			continue;		if (scr_def [i].depth != con_depth)		        continue;		x_margin = scr_def [i].x_margin;		y_margin = scr_def [i].y_margin;		chars_per_line = (con_width * con_depth) / 8;		skip_bytes = chars_per_line * y_margin;		ints_per_line = chars_per_line / 4;		bytes_per_row = CHAR_HEIGHT * chars_per_line;		break;	}	if (!scr_def [i].depth){		x_margin = y_margin = 0;		prom_printf ("PenguinCon: unknown video resolution %dx%d may be slow\n", con_width, con_height);		prom_halt ();	}	/* P3: I fear this strips 15inch 1024/768 PC-like monitors out. */	if ((con_linebytes*8) / con_depth != con_width) {		prom_printf("console: UNUSUAL VIDEO, linebytes=%d, width=%d, depth=%d\n",			con_linebytes, con_width, con_depth);		return -1;	}	/* Negate the font table on 1 bit depth cards so we have white on black */	if (con_depth == 1)		for(i=0; i<(16 * 256); i++)			vga_font[i] = ~vga_font[i];	/* Fill in common fb information */	fbinfo [0].type.fb_type   = con_type;	fbinfo [0].type.fb_height = con_height;	fbinfo [0].type.fb_width  = con_width;	fbinfo [0].type.fb_depth  = con_depth;	fbinfo [0].type.fb_size   = PAGE_ALIGN((con_linebytes) * (con_height));	fbinfo [0].space = fbiospace;	fbinfo [0].blanked = 0;	/* Should be filled in for supported video cards */	fbinfo [0].mmap = 0; 	fbinfo [0].loadcmap = 0;	fbinfo [0].ioctl = 0;	fbinfo [0].blank = 0;	fbinfo [0].unblank = 0;	if (fbbase == 0xb001b001){		printk ("Mail miguel@nuclecu.unam.mx video_card=%d (%s)\n", con_type, con_name);	}	/* Per card setup */	switch (con_type){	case FBTYPE_SUN3COLOR:		cg3_setup (0, fbbase, fbiospace);		break;	case FBTYPE_SUNFAST_COLOR:		cg6_setup (0, fbbase, fbiospace);		break;	case FBTYPE_SUN2BW:		bwtwo_setup (0, fbbase, fbiospace);		break;	case FBTYPE_MDICOLOR:		cg14_setup (0, fbbase, fbiospace);		break;	default:		break;	}	if (!con_fb_base){		prom_printf ("PROM does not have an 'address' property for this\n"			     "frame buffer and the Linux drivers do not know how\n"			     "to map the video of this device\n");		prom_halt ();	}	fbinfo [0].base = (long) con_fb_base;		/* Register the frame buffer device */	if (register_chrdev (GRAPHDEV_MAJOR, "graphics", &graphdev_fops)){		printk ("Could not register graphics device\n");		return -EIO;	}	return 0; /* success */}/* video init code, called from within the SBUS bus scanner at * boot time. */voidsun_console_init(void){	if(serial_console)		return;	if(sparc_console_probe()) {		prom_printf("Could not probe console, bailing out...\n");		prom_halt();	}	sun_clear_screen();}/* * sun_blitc * * Displays an ASCII character at a specified character cell *  position. * * Called from scr_writew() when the destination is *  the "shadow" screen */static unsigned intfontmask_bits[16] = {    0x00000000,    0x000000ff,    0x0000ff00,    0x0000ffff,    0x00ff0000,    0x00ff00ff,    0x00ffff00,    0x00ffffff,    0xff000000,    0xff0000ff,    0xff00ff00,    0xff00ffff,    0xffff0000,    0xffff00ff,    0xffffff00,    0xffffffff};int

⌨️ 快捷键说明

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