summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@nokia.com>2010-01-04 20:53:08 +0200
committerTiago Vignatti <tiago.vignatti@nokia.com>2010-01-04 20:53:08 +0200
commitcd3a35fb27b26824e3c539ff64462eb3db2babe6 (patch)
tree2f3bb0769febc391e90ace9ae6d274b35cc9e85b
parent96f7ad1d03c28e4147e190900a5021f1ad2a210b (diff)
vm86: do BIOS and VRAM mapping internally
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
-rw-r--r--src/lrmi/backend-vm86.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/lrmi/backend-vm86.c b/src/lrmi/backend-vm86.c
index 266b1a9..558a913 100644
--- a/src/lrmi/backend-vm86.c
+++ b/src/lrmi/backend-vm86.c
@@ -28,7 +28,12 @@ OTHER DEALINGS IN THE SOFTWARE.
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <inttypes.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+
#include "libx86.h"
#include "common.h"
@@ -93,12 +98,59 @@ set_bit(unsigned int bit, void *array)
a[bit / 8] |= (1 << (bit % 8));
}
+#ifdef __sparc__
+#define DEV_MEM "/dev/fb"
+#else
+#define DEV_MEM "/dev/mem"
+#endif
void
LRMI_init(xf86Int10InfoPtr pInt)
{
+ int fd;
+ static void* vidMem = NULL;
+ static void* sysMem = NULL;
+
+
+ /* TODO: should put this in common interface and to just run once instead
+ * use the "hack" of static variables */
+ if ((!vidMem) || (!sysMem)) {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (!sysMem) {
+ if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
+ PROT_READ | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
+ == MAP_FAILED) {
+ fprintf(stderr, "Cannot map SYS BIOS\n");
+ close(fd);
+ goto error;
+ }
+ }
+ if (!vidMem) {
+ if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_RAM))
+ == MAP_FAILED) {
+ fprintf(stderr, "Cannot map V_RAM\n");
+ close(fd);
+ goto error;
+ }
+ }
+ close(fd);
+ } else {
+ fprintf(stderr, "Cannot open %s\n", DEV_MEM);
+ goto error;
+ }
+ }
+
xxxf86Int10ExecSetup(pInt);
pInt->mem = &linuxMem;
+
+ return;
+
+error:
+ free(pInt);
+ return;
#if 0
void *m;