Initial. Don't... just don't ask.

This commit is contained in:
Ryan McGrath 2011-02-24 00:22:00 -08:00
commit 00bae13bba
586 changed files with 129057 additions and 0 deletions

253
obsolete/svpmi/parse.c Normal file
View file

@ -0,0 +1,253 @@
/*
* This is a quickly hacked program to convert an SVPMI (Super VGA Protected
* Mode Interface) data file to an svgalib driver. Feedback is
* very welcome.
*
* Initial version (Mar 94 HH). Doesn't do much yet.
* Assumes textmode is last defined mode.
* End with ctrl-c. Correct resulting files by hand.
* (add "}" to modetable.svpmi)
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void parse ();
void
main ()
{
parse ();
}
/* Return pointer to line red from stdin, end marked by CR or CR/LF.
* Initial spaces are removed. */
char *
getline ()
{
static char linebuf[128];
int i, length, spaces;
i = 0;
for (;;)
{
int c;
c = fgetc (stdin);
if (feof (stdin))
return NULL;
if (c == 13)
continue; /* Skip. */
if (c == 10)
break;
linebuf[i] = c;
i++;
}
length = i;
linebuf[i] = 0;
/* Remove initial spaces. */
spaces = 0;
i = 0;
while (i < length)
{
if (linebuf[i] != ' ')
break;
i++;
spaces++;
}
return linebuf + spaces;
}
/* Skip lines until left side of line matches string s. */
char *
getthisline (char *s)
{
char buf[128];
int n;
n = strlen (s);
for (;;)
{
char *line;
line = getline ();
if (strncmp (line, s, n) == 0)
return line;
}
}
/* Get the (n + 1)th word delimited by ' ' and ';' in string s. */
char *
getword (char *s, int n)
{
int i;
char *word;
int mode, wcount;
word = s;
mode = 0; /* Whitespace. */
wcount = 0;
i = 0;
for (i = 0; s[i] != 0; i++)
{
if (s[i] == ' ' || s[i] == ';')
if (mode == 0)
continue;
else
{
s[i] = 0;
if (wcount == n)
return word;
wcount++;
mode = 0;
}
else if (mode == 1)
continue;
else
{
word = &s[i];
mode = 1;
}
}
return NULL;
}
/* Write lines to file until left part matches string s. */
void
writetofileuntilthisline (char *s, FILE * f)
{
int n;
n = strlen (s);
for (;;)
{
char *line;
line = getline ();
if (strncmp (line, s, n) == 0)
break;
fprintf (f, "%s\n", line);
}
}
void
writetofileuntilend (FILE * f)
{
for (;;)
{
char *line;
line = getline ();
if (line == NULL)
return;
fprintf (f, "%s\n", line);
}
}
void
parse ()
{
char *line;
char s[128];
char modename[40];
int modenumber;
FILE *f, *g;
printf ("SVPMI to svgalib driver converter.\n\n");
/* Read header. */
getthisline ("[ADAPTER]");
line = getline ();
printf ("Graphics Adapter string: %s\n", line);
/* Read modes. */
modenumber = 0;
g = fopen ("modetable.svpmi", "wb");
f = fopen ("modes.svpmi", "wb");
fprintf (g, "/* svgalib SVPMI mode table. */\n\n");
fprintf (g, "static svpmi_modeentry svpmi_modes[] = {\n");
for (;;)
{
int XResolution; /* SVPMI modeinfo fields. */
int YResolution;
int BitsPerPixel;
int BytesPerScanline;
int WinAGranularity;
int WinASize;
int WinABase;
int ModeAttributes;
getthisline ("[MODEINFO]");
line = getthisline ("ModeAttributes");
ModeAttributes = atoi (getword (line, 2));
line = getthisline ("WinAGranularity");
WinAGranularity = atoi (getword (line, 2));
line = getthisline ("WinASize");
WinASize = atoi (getword (line, 2));
line = getthisline ("WinABase");
WinABase = atoi (getword (line, 2));
#if 0
if (WinABase != 0xa0000)
{
printf ("Window is not at 0xa0000.\n");
exit (-1);
}
#endif
line = getthisline ("BytesPerScanline");
BytesPerScanline = atoi (getword (line, 2));
line = getthisline ("XResolution");
XResolution = atoi (getword (line, 2));
line = getthisline ("YResolution");
YResolution = atoi (getword (line, 2));
line = getthisline ("BitsPerPixel");
BitsPerPixel = atoi (getword (line, 2));
if (ModeAttributes == 0x07)
{
/* Text mode. */
printf ("Textmode found.\n");
getthisline ("[SETMODE]");
fprintf (f, "static void svpmi_setmode_text() {\n");
writetofileuntilend (f);
fprintf (f, "}\n\n\n");
fprintf (g, "}\n");
fclose (f);
fclose (g);
exit (0);
}
printf ("Mode found: %d x %d, %dbpp %d bpl gran A %d\n",
XResolution, YResolution, BitsPerPixel,
BytesPerScanline, WinAGranularity);
sprintf (modename, "%dx%dx%d", XResolution, YResolution,
1 << BitsPerPixel);
getthisline ("[SETMODE]");
fprintf (f, "static void svpmi_setmode_%s() {\n", modename);
writetofileuntilthisline ("[SETCOLOR]", f);
fprintf (f, "}\n\n\n");
getthisline ("[SETWINDOW]");
fprintf (f, "static void svpmi_setwindow_%s( int r0 ) {\n", modename);
writetofileuntilthisline ("[MODE]", f);
fprintf (f, "}\n\n\n");
fprintf (g, "{ %d, %d, %d, %d, %d, svpmi_setmode_%s, svpmi_setwindow_%s },\n",
XResolution, YResolution, BitsPerPixel,
BytesPerScanline, WinAGranularity, modename, modename);
fflush (f);
fflush (g);
modenumber++;
}
fprintf (g, "}\n");
fclose (f);
fclose (g);
}

185
obsolete/svpmi/svpmi.c Normal file
View file

@ -0,0 +1,185 @@
/* This library is free software; you can redistribute it and/or */
/* modify it without any restrictions. This library is distributed */
/* in the hope that it will be useful, but without any warranty. */
/* Copyright (C) 1994 Harm Hanemaayer */
/*
Basic initial untested SVPMI skeleton driver.
Includes computer-generated mode setting/bank switching
routines and mode information table.
Untested, may not be finished.
A better way to do this would be to have a seperate svpmi server
program set modes. This way there would be no need to recompile
the shared library. For performance it would be nice to move the
bank-switching over to svgalib. I imagine one way to do this would
be to encode the SVPMI procedure code (simple as it is, just a few
outs and a few basic bit operations) and have the svgalib driver
interpret that. This could also be used for mode setting.
*/
#include <stdio.h>
#include "../vga.h"
#include "../libvga.h"
#include "../driver.h"
#include "svpmi.h"
#include "modes.svpmi"
#include "modetable.svpmi"
static svpmi_currentmode = NULL;
static svpmi_modeentry *
svpmi_lookupmode (int w, int h, int colors)
{
int i;
for (i = 0; i < sizeof (svpmi_modes); i++)
if (w == svpmi_modes[i].width && h == svpmi_modes[i].height &&
colors = (1 << svpmi_mode[i].bitsperpixel))
return &svpmi_modes[i];
return NULL;
}
static int
svpmi_getmodeinfo (int mode, vga_modeinfo * modeinfo)
{
modeinfo->maxlogicalwidth = modeinfo->width;
modeinfo->startaddressrange = 0;
modeinfo->haveblit = 0;
modeinfo->flags &= ~HAVE_RWPAGE;
return 0;
}
/* Return non-zero if mode is available */
static int
svpmi_modeavailable (int mode)
{
struct info *info;
svpmi_modeentry *sm;
if (mode < 10)
return vga_chipsetfunctions[CHIPSET_MODEAVAILABLE] (mode);
if (mode == 32)
return 0;
sm = svpmi_lookupmode (modeinfo->width, modeinfo->height,
modeinfo->colors);
return (sm != NULL)
}
/* Set a mode */
static int
svpmi_setmode (int mode, int prv_mode)
{
svpmi_modeentry *sm;
if (mode == TEXT)
{
svpmi_setmode_text ();
return 0;
}
if (!SVGAMODE (mode))
/* Let the standard VGA driver set standard VGA modes. */
return vga_chipsetfunctions[CHIPSET_SETMODE] (mode);
sm = svpmi_lookupmode (infotable[mode].width, infotable[mode].height,
infotable[mode].colors);
if (sm == NULL)
return 1; /* No match. */
sm->setmode (); /* Call the SVPMI mode setting code. */
svpmi_currentmode = sm;
/* Hack similar to what the ATI mach32 driver does for some */
/* truecolor modes. I think S3 uses only a few fixed scanline */
/* widths (e.g. 1024, 1280) so may happen a lot. */
infotable[mode].xbytes = sm->bytesperscanline;
}
/* Indentify chipset; return non-zero if detected */
static int
svpmi_test ()
{
/* Detection with environment variable -- better change into */
/* config file option. */
if (getenv ("SVGALIB_SVPMI"))
return 1;
return 0;
}
/* Bank switching function - set 64K bank number */
static void
svpmi_setpage (int page)
{
svpmi_currentmode->setwindow (page *
(64 / svpmi_currentmode->windowgranularity));
}
/* Set display start address (not for 16 color modes) */
static int
svpmi_setdisplaystart (int address)
{
}
/* Set logical scanline length (usually multiple of 8) */
/* Multiples of 8 to 2040 */
static int
svpmi_setlogicalwidth (int width)
{
outw (0x3d4, 0x13 + (width >> 3) * 256); /* lw3-lw11 */
return 0;
}
static int
nothing ()
{
}
/* Function table (exported) */
int (*svpmi_chipsetfunctions[]) () =
{
(int (*)()) nothing, /* saveregs */
(int (*)()) nothing, /* setregs */
(int (*)()) nothing, /* unlock */
(int (*)()) nothing, /* lock */
svpmi_test,
svpmi_init,
(int (*)()) svpmi_setpage,
(int (*)()) nothing,
(int (*)()) nothing,
svpmi_setmode,
svpmi_modeavailable,
nothing, /* setdisplaystart */
svmi_setlogicalwidth,
svpmi_getmodeinfo
};
/* Initialize chipset (called after detection) */
static int
svpmi_init (int force, int par1, int par2)
{
/* Not required. */
}

40
obsolete/svpmi/svpmi.h Normal file
View file

@ -0,0 +1,40 @@
typdef struct
{
int width;
int height;
int bitsperpixel;
int bytesperscanline;
int windowgranularity;
void *setmode ();
void *setwindow (int);
}
svpmi_modeentry;
static void
wait (int x)
{
int i;
for (i = 0; i < 10; i++);
}
static unsigned char r0, r1, r2, r3, r4, r5, r6, r7;
static unsigned char r8, r9, r10, r11, r12, r13, r14, r15;
static unsigned char r16, r17, r18, r19, r20, r21, r22, r23;
static unsigned char r24, r25, r26, r27, r28, r29, r30, r31;
#define boutb(n, p1, p2) __boutb(0, n, p1 p2)
#define __boutp(i, n, p1, p2) \
#if n != 0 \
outb(p1, i); outb(p2, r##i); \
boutb((i + 1), (n - 1), p1, p2); \
#endif
#define inb(r, p) port_in(p)
#define and(r, v) r &= v;
#define or(r, v) r |= v;
#define xor(r, v) r ^= v;
#define shr(r, v) r >>= v;
#define shl(r, v) r <<= v;