#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asm/types.h>
#include <unistd.h>
//#include <asm/io.h>
#include <sys/io.h>

#define LP_BASE 0x260

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

	__u8 portdata;
        unsigned int port;

	if(argc < 3) {
		fprintf(stderr, "Must supply a value to send to port...\n");
		exit(1);
	}

	/* attempt to reserve region in io space */
	if(ioperm(LP_BASE, 3, 1) < 0) {
		fprintf(stderr, "Cannot reserve region in io space, aborting...\n");
		exit(1);
	}

        portdata = strtol(argv[1], (char**)NULL, 16);
        port= strtol(argv[2], (char**)NULL, 16);

printf("portdata=%x, port=%x\n", portdata, port);
 
        outb(portdata, port);
//        outb(0x1, 0x3bc);

	/* attempt to release reserved region in io space */
	if(ioperm(LP_BASE, 3, 0) < 0) {
		fprintf(stderr, "Cannot release region in io space, aborting...\n");
		exit(1);
	}

	return(0);  /* just to be nice ;) */

}
