📄 c24.c
字号:
/* * Color24 * * Date: 06/14/88 * * Sundiag test for offboard 24 bit color frame buffers. This sysdiag test not * only verifies the hardware, but also the device independant driver * routines. This diagnostic locks suntools from writting to the screen * during this test. * * 06-14-88 BKA Created version 1.0. * * Released OS: 4.0 and higher. * * Drivers used: cgeight0. * * Compile line: * cc color24.c -O1 -Bstatic -o c24 -lsuntool -lsunwindow -lpixrect -lm -lc * * External files used: color24.h color24.icon */static char sccsid[] = "@(#)c24.c 1.1 92/07/30 SMI";#include <stdio.h>#include <fcntl.h>#include <signal.h>#include <sun/fbio.h>#include <sgtty.h>#include <math.h>#include <pixrect/pixrect_hs.h>#include <pixrect/pixrect.h>#include <pixrect/memreg.h>#include <pixrect/memvar.h>#include <pixrect/pr_planegroups.h>#include <sunwindow/win_cursor.h>#include <suntool/sunview.h>#include <suntool/gfx_hs.h>#include "color24.h"#ifndef PIXPG_24BIT_COLOR#define PIXPG_24BIT_COLOR 5#endif#ifndef FBTYPE_SUNROP_COLOR#define FBTYPE_SUNROP_COLOR 13#endif#ifndef FBTYPE_MEMCOLOR#define FBTYPE_MEMCOLOR 7#endif#ifndef PR_FORCE_UPDATE#define PR_FORCE_UPDATE (1 << 24)#endif#ifndef pr_getlut#define pr_getlut(pr, ind, cnt, red, grn, blu ) \ (*(pr)->pr_ops->pro_getcolormap)(pr, PR_FORCE_UPDATE | ind, cnt, red, grn, blu)#endif#ifndef pr_putlut#define pr_putlut(pr, ind, cnt, red, grn, blu ) \ (*(pr)->pr_ops->pro_putcolormap)(pr, PR_FORCE_UPDATE | ind, cnt, red, grn, blu)#endif#define PIXPG_COLOR PIXPG_24BIT_COLOR#define DEV_NOT_OPEN 3#define RED_FAILED 4#define GREEN_FAILED 5#define BLUE_FAILED 6#define FRAME_BUFFER_ERROR 7#define SIGBUS_ERROR 8#define SIGSEGV_ERROR 9#define SCREEN_NOT_OPEN 10#define END_ERROR 11#define SYNC_ERROR 12#include "sdrtns.h"#include "../../../lib/include/libonline.h"#define NO_FB 0#define MONO_ONLY 10#define CG_ONLY 2#define CG_MONO_AVAIL 12#define BUFSIZE 256#define NDOTS 10000extern char *getenv();struct fbtype fb_type;int rootfd, winfd, devtopfd, cg_type, tmpplane, width, height;int depth, iograb = FALSE, current_plane_group;char *cg_driver, msg[132];unsigned char red[256], green[256], blue[256];unsigned char tred[256], tgrn[256], tblue[256];struct screen new_screen;Pixrect *prfd, *sdpr, *sepr, *twentyfourdump, *twentyfourexp;Pixrect *oneexp, *onedump, *regionpr, *regionmm;short *sdi, *sde;int clr[] = {RED, GREEN, BLUE, YELLOW, BLACK, CYAN, MAGENTA, ORANGE, BROWN, DARKGREEN, GRAY, LIGHTGRAY, DARKGRAY, PURPLE, PINK, LIGHTGREEN};int cg9 = 0;int SpecialFlag, defaultfb = FALSE;struct sgttyb ttybuf;short orig_sg_flags; /* mode flags from stdin */int origsigs;int Colormap(), Rop(), Vector(), Putget(), Region(), Destroy(), Stencil();int verify_overlay_enable(), verify_clr_map(), verify_rw_memory(), verify_db_memory();char tmpbuf[BUFSIZE];/****************************************************//****************************************************//* Create variables ibisiconpr and ibisiconpr_data *//****************************************************//****************************************************/static short icondata[] = {#include "color24.icon"};mpr_static(ibisiconpr, 64, 64, 1, icondata);int dummy(){return FALSE;}/****************************************************//* Main *//* *//* Should I say more. *//* *//****************************************************/main(argc, argv)int argc;char **argv;{extern int process_my_args(); versionid = "1.1"; /* SCCS version id */ /* begin Sundiag test */ test_init(argc, argv, process_my_args, dummy, (char *)NULL); SpecialFlag = FALSE; setup_signals(); /* set driver and frame buffer type accordingly */ cg_driver = (cg9) ? "/dev/cgnine0" : "/dev/cgeight0"; cg_type = (cg9) ? FBTYPE_SUNROP_COLOR : FBTYPE_MEMCOLOR; device_name = cg_driver; if (probe_cg() == NO_FB) { clean_up(); exit(0); } setup_desktop(); initialize(); /* verify that all device independent */ /* routines are functioning correctly */ verify_drvr_fun(); /* verify color map using read /write */ /* tests. */ cg_lock_scr(verify_clr_map); /* verify overlay and enable memories */ cg_lock_scr(verify_overlay_enable); /* verify read / write of color, */ /* overlay, and enable memories. */ cg_lock_scr(verify_rw_memory); /* verify double buffering if cg9 */ if (cg9) cg_lock_scr(verify_db_memory); resetfb(); clean_up(); test_end(); /* Sundiag normal exit */}/****************************************//* Process_my_args *//* *//* Check the command line for the *//* argument 'diag'. If diag is present *//* enable XOR'ing of screen pixrect with *//* expected pixrect on failure. *//* *//****************************************/process_my_args(argv, index)char **argv;{ int match; match = FALSE; if (strncmp(argv[index], "diag", 4) == 0) SpecialFlag = match = TRUE; if (strncmp(argv[index], "9", 1) == 0) cg9 = match = TRUE; return (match);}/************************************************//* Initialize *//* *//* Create all memory pixrects to *//* verify against the screen pixrect *//* *//* GLOBAL VARIABLES: *//* *//* sdpr - XOR pixrect. *//* sepr - Memory pixrect (expected pixrect) *//* sdi - Image area of sdpr. *//* sde - Image area of sepr. *//* *//* twentyfourexp - 24 bit pixrect (expected) *//* twentyfourdump - 24 bit screen dump pixrect *//* oneexp - 1 bit pixrect (expected) *//* onedump - 1 bit screen dump pixrect *//* *//************************************************/initialize(){ struct mpr_data *temp; if (SpecialFlag) { if ((int) (sdpr = mem_create(width, height, depth)) == 0) Error(-DEV_NOT_OPEN, "Failed to create memory pixrect \n", FALSE); } else sdpr = prfd; if ((int) (sepr = mem_create(width, height, depth)) == 0) Error(-DEV_NOT_OPEN, "Failed to create memory pixrect \n", FALSE); twentyfourexp = sepr; twentyfourdump = sdpr; temp = (struct mpr_data *) sdpr->pr_data; sdi = temp->md_image; temp = (struct mpr_data *) sepr->pr_data; sde = temp->md_image; if ((int) (oneexp = mem_create(width, height, 1)) == 0) Error(-DEV_NOT_OPEN, "Failed to create memory pixrect \n", FALSE); if ((int) (onedump = mem_create(width, height, 1)) == 0) Error(-DEV_NOT_OPEN, "Failed to create memory pixrect \n", FALSE); if (cg9) { pr_dbl_set(prfd, PR_DBL_WRITE, PR_DBL_BOTH, PR_DBL_READ, PR_DBL_B, 0); }}/******************************************************//* Probe_cg *//* *//* Determine if cg8 is installed on system and *//* return the following codes: *//* *//* 0 No cg8 board *//* 2 cg8 installed *//* *//* GLOBAL VARIABLES: *//* *//* return_code - indicates cg8 installed or not. *//* *//******************************************************/probe_cg(){ int tmpfd, return_code; struct fbgattr fb; if ((tmpfd = open("/dev/fb", O_RDWR)) != -1) ioctl(tmpfd, FBIOGATTR, &fb); else return (tmpfd); return_code = NO_FB; fb_type.fb_type = fb.fbtype.fb_type; if ( cg9 ) if ( fb_type.fb_type == FBTYPE_SUN2GP ) cg_type = FBTYPE_SUN2GP;#ifdef NOWAY if ( fb_type.fb_type == cg_type ) { if ( ( prfd = pr_open (cg_driver) ) <= 0 ) syserror(-DEV_NOT_OPEN, "/dev/fb"); } else if ((prfd = pr_open(cg_driver)) <= 0) return_code = NO_FB;#else if ((prfd = pr_open (cg_driver) ) <= 0 ) return_code = NO_FB;#endif if ( prfd > 0 ) return_code = CG_ONLY; close(tmpfd); return (return_code);}/**********************************************************//* Setup_desktop *//* *//* Disable suntools, cursor, and mouse during the lapse *//* of this test. Save color look up table and enable all *//* color planes. *//* *//**********************************************************/setup_desktop(){ Cursor cursor; struct inputmask im; char *winname; u_long planes; if ((fb_type.fb_type == cg_type) && (winname = getenv("WINDOW_PARENT"))) { rootfd = open(winname, O_RDONLY); if (rootfd == 0) syserror(-DEV_NOT_OPEN, "rootfd"); winfd = win_getnewwindow(); if (winfd < 0) syserror(-SCREEN_NOT_OPEN, "winfd"); win_setlink(winfd, WL_PARENT, win_nametonumber(winname)); win_setlink(winfd, WL_OLDERSIB, win_getlink(rootfd, WL_YOUNGESTCHILD)); win_screenget(rootfd, &new_screen); win_setrect(winfd, &new_screen.scr_rect); input_imnull(&im); im.im_flags |= IM_ASCII; /* catch 0-127(CTRL-C == 3) */ win_set_kbd_mask(winfd, &im); win_insert(winfd); /* Prevent any cursor from display. * This must be done because the cursor * could sneak into the display. */ /* remove the new window cursor */ cursor = cursor_create((char *)0); win_getcursor(rootfd, cursor); cursor_set(cursor, CURSOR_SHOW_CURSOR, 0, 0); win_setcursor(rootfd, cursor); cursor_copy(cursor); cursor_destroy(cursor); win_grabio(winfd); check_input(); win_remove_input_device(rootfd, new_screen.scr_msname); iograb = TRUE; } enable_video(); width = prfd->pr_width; height = prfd->pr_height; depth = 32; /* prfd->pr_depth; */ pr_getattributes(prfd, &tmpplane); pr_getlut(prfd, 0, 256, tred, tgrn, tblue); planes = 0xFFFFFF; pr_putattributes(prfd, &planes);}/************************************************************//* Enable_video *//* *//* Turn on video if it is not already on. *//* *//************************************************************/enable_video(){ int fd, vid; vid = FBVIDEO_ON; fd = open(cg_driver, O_RDWR); if (fd) { ioctl(fd, FBIOSVIDEO, &vid, 0); close(fd); } else syserror(-DEV_NOT_OPEN, "could not turn on video");}/****************************************************//* Syserror *//* *//* Display error message when screen is unable to *//* open. *//* *//****************************************************/syserror(err, c) int err; char *c;{ perror(c); sprintf(msg, "could not create new screen for '%s'\n", cg_driver ); if (!exec_by_sundiag) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -