On Tue, Oct 16, 2001 at 04:16:42AM +0200, Marcus Brinkmann said:
> This is not so cool as Kalles cursor move program, so:
> 
> Exercise
> --------
> 
> Reimplement Kalles cursor move test program so that it works on OSKit-Mach
> with the patch.

Attached.

Thanks,
Kevin
-- 
Kevin Kreamer
FsckIt on openprojects.net
#define _GNU_SOURCE

#include <hurd.h>
#include <mach/i386/mach_i386_types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>		/* sleep */

#define outb(x, y) \
{ asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); }

int
main (int argc, char **argv)
{
    mach_port_t master;
    kern_return_t err;
    io_perm_t io_perm;

    err = get_privileged_ports(NULL, &master);
    if (err) 
      {
	fprintf(stderr,"Get priv ports failed\n");
	return err;
      }
    err = i386_io_perm_create (master, 0x3D0, (io_port_t) 0x400,
			       &io_perm);
    mach_port_deallocate(mach_task_self(), master);
    if (err) 
      {
	fprintf(stderr,"IO perm create failed\n");
	return err;
      }
    err = i386_io_perm_modify (mach_task_self(), io_perm, 1);
    mach_port_deallocate(mach_task_self(), io_perm);
    if (err) 
      {
	fprintf(stderr,"IO perm modify failed\n");
	return err;
      }
    
  outb (0x3D4, 0x0E);		/* cursor position high byte register */
  outb (0x3D5, 0);
  outb (0x3D4, 0x0F);		/* cursor position low byte register */
  outb (0x3D5, 0);
  
  /* When the program exits, the shell prints a new prompt and Mach
     moves the cursor.  So wait a moment.  */
  sleep (1);
  return 0;
}

Reply via email to