Simple Usermode Test Driver

Listing 25.1 is a very simple program that just causes the stepper motor to slowly make a number of revolutions. This tests for correct hookup of a single stepper motor (Motor 0) and demonstrates the use of iopl() and outb().

Listing 25.1 Simple Usermode Driver

/* Must be compiled with -O for outb to be inlined, */

/* otherwise link error /

#include <stdlib.h>

#include <stdio.h>

#include <unistd.h>

int base=0x378;

void verbose_outb(int port, int value) {

printf("outb(%02X,%04X)\n",port,value); outb(port,value);

unsigned char steptable[8]={0x01,0x05,0x04,0x06,0x02,0x0A,0x08,0x09};



int i; int inval; int outval;

printf("this program must be run as root\n"); iopl(3); /* Enable i/o (if root) */ slow_sweep();

Chapter 25

Was this article helpful?

0 0

Post a comment