bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: colortext patch


From: Marcus Brinkmann
Subject: Re: colortext patch
Date: Tue, 2 Oct 2001 20:57:29 +0200
User-agent: Mutt/1.3.22i

On Tue, Oct 02, 2001 at 09:43:37AM -0500, Kevin Kreamer wrote:
> For anyone trying to build colortext, you have to grab pio.h from the 
> gnumach/oskit-mach sources.  screen.c tries to include it as 
> <mach/machine/pio.h>, but the mach's (or machen or whatever) no longer 
> install that header.

Yeah, my patch was very sloppy, sorry.  Here is a new one.  You only need the
outb() function, actually.  I am glad someone tries this.

--- colortext-0.3/screen.c      Mon Oct 11 17:05:47 1999
+++ colortext/screen.c  Tue Oct  2 20:56:45 2001
@@ -19,11 +19,14 @@
 #define _GNU_SOURCE
 #include "screen.h"
 #include <hurd/ports.h>
-#include <device/device.h>     /* device_open */
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
 #include <error.h>             /* error */
 #include <assert.h>            /* assert */
 #include <string.h>            /* memmove */
-#include <mach/machine/pio.h>  /* outb */
+#include <paths.h>             /* _PATH_MEM */
 #include "util.h"              /* xmalloc */
 #if 0
 # include "mach_i386.h"                /* i386_io_port_add */
@@ -39,7 +42,6 @@
 
 #define VIDMMAP_BEGIN 0xB8000
 #define VIDMMAP_SIZE (0xC0000 - 0xB8000)
-#define VIDMMAP_KDOFS 0xA0000 /* == kd_bitmap_start in mach/i386/i386at/kd.c */
 
 void
 screen_init_thread (void)
@@ -59,39 +61,21 @@
 map_videomem (void)
 {
   error_t err;
-  device_t device_master = MACH_PORT_NULL;
-  memory_object_t kd_mem = MACH_PORT_NULL;
-  vm_address_t mapped;
+  int mem;
   
   if (videomem)
     return;                    /* already mapped */
 
-  err = get_privileged_ports (0, &device_master);
-  if (err)
-    error (EXIT_FAILURE, err, "get_privileged_ports");
-
-  err = device_open (device_master, D_WRITE, "kd", &kd_device);
-  if (err)
-    error (EXIT_FAILURE, err, "device_open");
-
-  err = device_map (kd_device, VM_PROT_READ | VM_PROT_WRITE,
-                   VIDMMAP_BEGIN - VIDMMAP_KDOFS, VIDMMAP_SIZE,
-                   &kd_mem, 0);
-  if (err)
-    error (EXIT_FAILURE, err, "device_map");
-
-  err = vm_map (mach_task_self (), &mapped, VIDMMAP_SIZE,
-               0, 1, kd_mem, VIDMMAP_BEGIN - VIDMMAP_KDOFS, 0,
-               VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ | VM_PROT_WRITE,
-               VM_INHERIT_NONE);
-  if (err)
-    error (EXIT_FAILURE, err, "vm_map");
+  mem = open (_PATH_MEM, O_RDWR);
+  if (mem < 0)
+    error (EXIT_FAILURE, errno, "opening " _PATH_MEM);
+
+  videomem = mmap (0, VIDMMAP_SIZE, PROT_READ | PROT_WRITE,
+                  MAP_SHARED, mem, VIDMMAP_BEGIN);
+  close (mem);
 
-  videomem = (uint16_t *) mapped;
-  assert (videomem != NULL);
-
-  mach_port_deallocate (mach_task_self (), device_master);
-  mach_port_deallocate (mach_task_self (), kd_mem);
+  if (videomem < 0)
+    error (EXIT_FAILURE, errno, "mmap");
 }
 
 struct screen *
@@ -119,6 +103,12 @@
   videomem[y * screen->width + x] = attr_ch;
 }
 
+static __inline void
+outb (unsigned char value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
+}
+
 void
 screen_move_cursor (struct screen *screen, int x, int y)
 {
@@ -126,10 +116,11 @@
   /* Hope nothing else uses these ports at the same time!  */
   /* TODO: Write 16 bits at once?  That would make things safe on
      single-processor machines.  But do all cards support that?  */
-  outb (0x3D4, 0x0E);
-  outb (0x3D5, cursor >> 8);
-  outb (0x3D4, 0x0F);
-  outb (0x3D5, cursor & 0xFF);
+
+  outb (0x0E, 0x3D4);
+  outb (cursor >> 8, 0x3D5);
+  outb (0x0F, 0x3D4);
+  outb (cursor & 0xFF, 0x3D5);
 }
 
 void
@@ -146,10 +137,10 @@
     [CURSOR_STANDOUT]  = { 0x00, 0x0F }
   };
   /* Hope nothing else uses these ports at the same time!  */
-  outb (0x3D4, 0x0A);
-  outb (0x3D5, sizes[style].start);
-  outb (0x3D4, 0x0B);
-  outb (0x3D5, sizes[style].end);
+  outb (0x0A, 0x3D4);
+  outb (sizes[style].start, 0x3D5);
+  outb (0x0B, 0x3D4);
+  outb (sizes[style].end, 0x3D5);
 }
 
 /* Like memset, but with 16-bit integers rather than chars.  */



-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]