Re: Screen regen buffer at 0x00b8000

From: Marco Rogantini
Date: Fri May 20 2005 - 11:37:24 EST


On Fri, 20 May 2005, Richard B. Johnson wrote:

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

I wrote the following little program and understood the effect you are
seeing...

#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 SCREEN 0x000b8000
#define ATTRIB 0x1700

int main (int argc, char **argv) {

int fd;
void *va;
size_t page_size = getpagesize();
unsigned short c = ATTRIB | '0';
int i;

fd = open("/dev/mem", O_RDWR | O_SYNC);
if (!fd) {
perror("open");
exit(1);
}

va = mmap(0, page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, SCREEN);
if (va == (void *) -1) {
perror ("mmap");
exit(1);
}

/* first column of second line of the hardware buffer */
va += 160;

/* printing ascii '0' to '9' */
for (i = 0; i < 10; i++) {
*((unsigned short *) va) = c;
c += 1;
sleep(1);
}

return 0;
}


Do you remember that the linux console uses hardware buffers for
its scrolling capabilities (shift-pgup and shift-pgdown)?

When you hit enter to run your program the display line you are
addressing in your program has gone off by one so it is out of visual.

To see your line you must go to the begginning of the buffer in the
console (shift-pgup until at the top) since you write to the first
line in the hardware buffer.

Hope this helps

-marco
-
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/