Screen regen buffer at 0x00b8000

From: Richard B. Johnson
Date: Fri May 20 2005 - 09:10:17 EST



Why can't I consistantly write to the VGA screen regen buffer
and have it appear on the screen????

It looks like access there is cached??? One needs to change
VT consoles to make it appear!!

The screen-regen buffer at this address is hardware, in the
chip! It should not be cached!




#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <sys/mman.h>


#define ERRORS(s) do { \
fprintf(stderr,"Error from line %d, file %s, call %s, (%s)\n",\
__LINE__,__FILE__,(s), strerror(errno)); \
exit(EXIT_FAILURE); } while(0)

#define TYPE (MAP_FIXED|MAP_SHARED|MAP_FILE|MAP_LOCKED)
#define PROT (PROT_READ|PROT_WRITE)

#define SCREEN 0x000b8000
#define ATTRIB 0x1700
#define COL 64
#define FAIL -1

static const char ln[]=" Link is ";
static const char up[]="up ";
static const char dn[]="down ";

int dummy;

int link_stat() // Dummy for testing
{
dummy ^= 1;
return dummy;
} // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

int main(int args, char *argv[])
{
unsigned short upmsg[sizeof(up) + sizeof(ln)];
unsigned short dnmsg[sizeof(dn) + sizeof(ln)];
size_t i, j, len;
int fd;
unsigned short *sp, *rp;
#if 0
if(fork())
return 0;
#endif

len = getpagesize();
if((fd = open("/dev/mem", O_RDWR)) == FAIL)
ERRORS("open");
if((sp = mmap((void *)SCREEN, len, PROT, TYPE, fd, SCREEN))==MAP_FAILED)
ERRORS("mmap");
for(i=0; i< sizeof(ln)-1; i++)
{
upmsg[i] = (unsigned short) ln[i] | ATTRIB;
dnmsg[i] = (unsigned short) ln[i] | ATTRIB;
}
for(j=0; j< sizeof(up)-1; j++)
{
upmsg[i] = (unsigned short) up[j] | ATTRIB;
dnmsg[i] = (unsigned short) dn[j] | ATTRIB;
i++;
}
i *= sizeof(unsigned short);
rp = &sp[COL];
(void)nice(20);
for(;;)
{
if(link_stat())
memcpy(rp, upmsg, i);
else
memcpy(rp, dnmsg, i);
usleep(500000);
}
return 0; // Not reached
}


Cheers,
Dick Johnson
Penguin : Linux version 2.6.11.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/