Copyright (c) 1986, 1987 by Hewlett-Packard Company
Copyright (c) 1986, 1987 by the Massachusetts Institute of Technology
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. Hewlett-Packard shall not be liable for errors
contained herein or direct, indirect, special, incidental or
consequential damages in connection with the furnishing,
performance, or use of this material.
This software is not subject to any license of the American
Telephone and Telegraph Company or of the Regents of the
University of California.
/*******************************************************************************
* Description: Multiple screen initialization
* Author: John Howard Palevich
* Created: April 22, 1987
* Modified: April 29, 1987 17:41:59 (John Howard Palevich)
* Status: Experimental (Do Not Distribute)
* (c) Copyright 1987, Hewlett-Packard, Inc., all rights reserved.
*******************************************************************************/
# include <sys/sysmacros.h>
# include <sys/graphics.h>
extern char *display
; /* display number as a string */
static char xscreens
[80];
static int ConfigFile
=FALSE
;
static char DefaultScreen
[]="/dev/crt";
static char DefaultScreen
[]="/dev/grf0";
* NewRule is an array of replacement rules. Given a replacement rule,
* colunm foreground pixel background pixel
u_char XHP_NewRule
[16][6] =
GXclear
, GXclear
, GXclear
, GXclear
, GXandInverted
,GXandInverted
,
GXclear
, GXandInverted
, GXand
, GXnoop
, GXnoop
, GXandInverted
,
GXclear
, GXnor
, GXandReverse
, GXinvert
,GXxor
, GXandInverted
,
GXclear
, GXcopyInverted
,GXcopy
, GXset
, GXor
, GXandInverted
,
GXnoop
, GXand
, GXandInverted
, GXclear
, GXandInverted
,GXnoop
,
GXnoop
, GXnoop
, GXnoop
, GXnoop
, GXnoop
, GXnoop
,
GXnoop
, GXequiv
, GXxor
, GXinvert
,GXxor
, GXnoop
,
GXnoop
, GXorInverted
, GXor
, GXset
, GXor
, GXnoop
,
GXinvert
,GXandReverse
, GXnor
, GXclear
, GXandInverted
,GXxor
,
GXinvert
,GXxor
, GXequiv
, GXnoop
, GXnoop
, GXxor
,
GXinvert
,GXinvert
, GXinvert
, GXinvert
,GXxor
, GXxor
,
GXinvert
,GXnand
, GXorReverse
, GXset
, GXor
, GXxor
,
GXset
, GXcopy
, GXcopyInverted
,GXclear
, GXandInverted
,GXor
,
GXset
, GXor
, GXorInverted
, GXnoop
, GXnoop
, GXor
,
GXset
, GXorReverse
, GXnand
, GXinvert
,GXxor
, GXor
,
GXset
, GXset
, GXset
, GXset
, GXor
, GXor
#define IOMAP_BASE 0xb00000
static unsigned char *iomapBase
;
int TopcatBrainDamage
= 0;
static PixmapFormatRec formats
[] = {
1, 1, BITMAP_SCANLINE_PAD
, /* 1-bit deep for all */
4, 4, BITMAP_SCANLINE_PAD
, /* 4-bit deep for Burgundy */
8, 8, BITMAP_SCANLINE_PAD
, /* 8-bit deep for most color displays */
16,16, BITMAP_SCANLINE_PAD
, /*16-bit deep for most color displays */
#define NUMFORMATS (sizeof formats)/(sizeof formats[0])
/* Pmap represents all 256 combinations of 8 bits of information. */
/* For example, if my byte of 8 pixels of information is 01010101 */
/* then the bytes that get written in memory are 00ff00ff,00ff00ff*/
/* The bytes are written using the current write enable and */
int XHP_pmap
[256][2]={0x00000000,0x00000000,
0xffffffff,0xffffffff}; /*XHP_pmap end*/
* routine to handle the bus error we might get in testing for the alignment
* restrictions of this cpu.
static ScreenTableRec
*FindScreen();
*-----------------------------------------------------------------------
* Initialize screenInfo for all actually accessible framebuffers.
* screenInfo init proc field set
*-----------------------------------------------------------------------
InitOutput(pScreenInfo
, argc
, argv
)
static int firstTime
= 1;
static ScreenTableRec
*FoundScreens
[MAXSCREENS
];
char *dispaddr
, *getenv();
* test for data alignment restriction of this cpu. If this cpu
* doesn't allow long-word writes on an odd address, then we assume
* that it requires quad-word alignment. This reduces our headaches
* to only two cases - 68020s (no restrictions) and others (e.g.
static struct sigvec timeout_vec
= { sigbusHandler
, 0, 0 };
test
= (int *) ((int)foo
| 3) + 1; /* generate an odd address */
#if defined(hp9000s300) || defined(hp300) /* check for 310 */
sigvector(SIGBUS
, &timeout_vec
, &old_vec
);
*test
= 1; /* generate a bus error on 68010s or Spectrums */
sigvector(SIGBUS
, &old_vec
, 0);
#else /* need word align on 800 */
iomapBase
= (unsigned char *) IOMAP_BASE
;
if (dispaddr
= getenv("SB_DISPLAY_ADDR"))
iomapBase
= (unsigned char *) strtol(dispaddr
, (char **)NULL
, 0);
pScreenInfo
->imageByteOrder
= IMAGE_BYTE_ORDER
;
pScreenInfo
->bitmapScanlineUnit
= BITMAP_SCANLINE_UNIT
;
pScreenInfo
->bitmapScanlinePad
= BITMAP_SCANLINE_PAD
;
pScreenInfo
->bitmapBitOrder
= BITMAP_BIT_ORDER
;
pScreenInfo
->numPixmapFormats
= NUMFORMATS
;
for (i
=0; i
< NUMFORMATS
; i
++)
pScreenInfo
->formats
[i
] = formats
[i
];
(void) sprintf(xscreens
, "%s/X%sscreens", LIBDIR
, display
);
if (NULL
== (in
= fopen (xscreens
, "r")))
ErrorF("Can't open screen configuration file, defaulting to %s.\n",
for (i
= 0; i
<MAXSCREENS
&& ((!ConfigFile
) ? TRUE
: ! feof(in
) ); i
++)
while (!(argc
= ReadLine(in
, argv
))) /* handle blank lines */
if (argc
== -1) /* eof */
ErrorF("InitOutput: %s: line %d: Too many fields.\n",
/* for compatibility with R2 screens tables */
if ((strcmp (argv
[0], "topcat") == 0) ||
(strcmp (argv
[0], "Topcat") == 0))
ErrorF ("InitOutput: %s, line %d: unsupported display type \"%s\".\n",
ErrorF("InitOutput: %s: line %d: Wrong number of fields.\n", xscreens
, i
+1);
if ((s
= FindScreen(argv
[0])) == NULL
)
ErrorF("InitOutput: %s: line %d: Unknown screen %s.\n",
/* munge new structure to match old argv structures */
/* BOGOSITY ALERT argv and argc are munged for subsequent calls */
argv
[0] = s
->productNickname
;
if (stat(argv
[2], &statbuf
) < 0)
ErrorF("InitOutput: %s: could not stat %s.\n",argv
[0],argv
[2]);
(void) sprintf(minornumber
, "%x", minor(statbuf
.st_rdev
));
(void) sprintf(minornumber
, "%d", minor(statbuf
.st_rdev
));
if (!(s
->InfoScreen
)(numScreens
, argv
, argc
))
ErrorF("InitOutput: %s: line %d: Couldn't find this screen %s.\n",
FoundScreens
[numScreens
++] = s
;
for (i
=0; i
<numScreens
; i
++)
if (AddScreen(s
->InitScreen
, argc
, argv
) < 0)
ErrorF("InitOutput: Couldn't add a screen.\n");
ErrorF("InitOutput: Couldn't initialize screens.\n");
static char line
[MAXSTRING
];
if (NULL
== fgets(line
, MAXSTRING
, in
))
for (state
= argc
= 0, s
= line
; argc
< MAXARG
; s
++)
#define STUPID_MOBERLY -1
/* Declare the ScreenInfo(), ScreenInit() and ScreenClose() functions here.
extern Bool
mobScreenInfo(), mobScreenInit();
extern Bool
gbxScreenInfo(), gbxScreenInit();
extern Bool
topcatScreenInfo(), topcatScreenInit();
extern Bool
mrtopcatScreenInfo(), mrtopcatScreenInit();
extern Bool
catseyeScreenInfo(), catseyeScreenInit();
extern Bool
renScreenInfo(), renScreenInit();
extern Bool
orenScreenInfo(), orenScreenInit();
extern Bool
davinciScreenInfo(), davinciScreenInit();
extern Bool
oDavinciScreenInit();
extern Bool
hyperScreenInfo(), hyperScreenInit();
* Table of known frame buffers
static ScreenTableRec screenTable
[] = {
{"98633", "moberly", mobScreenInfo
, mobScreenInit
},
{"98700", "gatorbox", gbxScreenInfo
, gbxScreenInit
},
{"98547", "topcat", topcatScreenInfo
, topcatScreenInit
},
{"98543", "mrtopcat", mrtopcatScreenInfo
, mrtopcatScreenInit
},
{"98550", "catseye", topcatScreenInfo
, topcatScreenInit
},
{"98720", "renaissance", renScreenInfo
, renScreenInit
},
{"98720", "orenaissance", orenScreenInfo
, orenScreenInit
},
{"98730", "davinci", davinciScreenInfo
, davinciScreenInit
},
{"98730", "odavinci", davinciScreenInfo
, oDavinciScreenInit
},
{"a1096a", "hyperion", hyperScreenInfo
, hyperScreenInit
},
{(char *) NULL
, (char *) NULL
, (Bool (*)()) NULL
, (Bool (*)()) NULL
}
if ((fd
= open(devname
, O_RDWR
)) < 0)
ErrorF("FindScreen couldn't open %s \n", devname
);
if (ioctl(fd
, GCON
, &gcon
) < 0 || ioctl(fd
, GCID
, &gcid
) < 0)
if (ioctl(fd
, GRFIOCGINFO
, &gi
) < 0 || ioctl(fd
, GRFIOCON
, 0) < 0)
strcpy(name
, "gatorbox");
ce
= (struct hp_grfreg
*) iomapBase
;
if (ioctl(fd
, GCMAP
, &ce
) < 0)
ErrorF("FindScreen: Error getting address of %s\n", devname
);
u_char
*Addr
= (u_char
*) 0;
if (ioctl (fd
, GRFIOCMAP
, &Addr
) < 0)
(void) ioctl (fd
, GRFIOCOFF
, 0);
ErrorF("FindScreen: Error getting address of %s\n", devname
);
ce
= (struct hp_grfreg
*) Addr
;
if (ce
->gr_id2
>= ID2_LCC
)
strcpy(name
, "mrtopcat");
if (ioctl(fd
, GCUNMAP
, &ce
) < 0)
ErrorF("FindScreen: Error freeing temp storage %s\n", devname
);
if (ioctl(fd
, GRFIOCUNMAP
, &ce
) < 0)
ErrorF("FindScreen: Error freeing temp storage %s\n", devname
);
if ((minor(buf
.st_rdev
)) & 0x000003)
strcpy(name
, "orenaissance");
strcpy(name
, "renaissance");
strcpy(name
, "hyperion");
if ((minor(buf
.st_rdev
)) & 0x000003)
strcpy(name
, "odavinci");
ErrorF("FindScreen: unknown screen type %s \n", devname
);
for (s
= screenTable
; s
->productNumber
!= NULL
; s
++)
if (strcmp(s
->productNumber
, name
) == 0 ||
strcmp(s
->productNickname
, name
) == 0)
unsigned char *base
= iomapBase
;
/* Round size to a 4K page */
size
= (size
+ 4095) & 0xfffff000;
* DDX - specific abort routine. Called by AbortServer().
/* Called by GiveUp(). */
ddxProcessArgument (argc
, argv
, i
)
if (strcmp (argv
[i
], "-tcbd") == 0)
if (strcmp (argv
[i
], "-catseyeMono") == 0)
ErrorF("-tcbd run in topcat braindamage mode\n");
ErrorF("-catseyeMono run 2bit deep catseyes in Monochrome\n");