Captain's Universe Home
Captain's Universe Home
Cosmic Ray Muon DetectorTeleGarden Pages
Time on MarsBryophyllum Plants
Jupiter Radio AstronomyAncient Pages
Salzburg Tourist GuideEarth Magnetometer
  H O M E     AJAX & MORE     LINUX & MORE     RTAI     XENOMAI     ADEOS IPIPE      
    JAVA & BROWSERS     *NIX     ELECTRONICS     REVIEWS     ARTEMIA     FAIRY SHRIMP      



This document wasn't intended to be presented on the web, but since I have written down my notes and there isn't any other HOWTO on the web, here it is!

Parallel Port access on Sun Solaris 9 x86 free and Solaris 10 x86
How to get access to the parallel port from a freshly installed system

install gcc from sunfreeware.com:
Download gcc for Solaris and do:
# gunzip [package.gz]
# pkgadd -d [package]

Make symbolic links for:
# ln -s /usr/local/bin/gcc /bin/gcc
# ln -s /usr/ccs/bin/make /bin/make
# ln -s /usr/ccs/bin/ar /bin/ar
# ln -s /usr/ccs/bin/ld /bin/ld

Since it appears that direct access is not allowed, we need a kernel driver in order
to access the port:
Download libieee1284 (cross-platform library for parallel port access)
http://sourceforge.net/projects/libieee1284
unpack, configure and compile with:
# bunzip2 libieee1284-[version].tar.bz2
# tar xf libieee1284-[version].tar
# cd libieee1284-[version]
# ./configure
# make

Don't do "make install", since this didn't work for me and it's simple to add the kernel driver yourself:
# cp iop /kernel/drv/iop
# cp solaris_io/iop.conf /kernel/drv/iop.conf

Reboot the system and boot with:
b -r
This will rebuild the /devices directory

Now you should see iop@0:iop in /devices/pseudo
If the pseudo-device is missing, try:
# add_drv iop

You must be root to add the driver with add_drv and also be root to do port I/O!

Substitute functions for inb and outb:

int inb(int port) {
	iopbuf tmpbuf;
	tmpbuf.port_value = 0;
	tmpbuf.port = port;
	if(ioctl(fd, IOPREAD, &tmpbuf)) {
		perror("IOCTL failed\n");
		exit(1);
	}
	return tmpbuf.port_value;
}
int outb(int value, int port) {
	iopbuf tmpbuf;
	tmpbuf.port_value = value;
	tmpbuf.port = port;
	if(ioctl(fd, IOPWRITE, &tmpbuf)) {
		perror("IOCTL failed\n");
		exit(1);
	}
	return 1;
}





Example:

////////////////////////////////////////////////
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h> 

#define BASEPORT 0x378
#define IOPREAD 1
#define IOPWRITE 2

typedef struct iopbuf_struct {
	unsigned int port;
	unsigned char port_value;
} iopbuf;

int fd=0;

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

	// open the device - since we use a kernel driver, we not need to do ioperm like on linux
	if((fd=open("/devices/pseudo/iop@0:iop", O_RDWR)) < 0)
	{
		perror("OPEN failed\n");
		exit(1);
	}
	
	// do some inb and/or outb stuff
	//  outb(33, BASEPORT + 2); // set to input mode and make STROBE high 
	//  inb(BASEPORT);
	
	close(fd);

}

int inb(int port) {
	iopbuf tmpbuf;
	tmpbuf.port_value = 0;
	tmpbuf.port = port;
	if(ioctl(fd, IOPREAD, &tmpbuf)) {
		perror("IOCTL failed\n");
		exit(1);
	}
	return tmpbuf.port_value;
}
int outb(int value, int port) {
	iopbuf tmpbuf;
	tmpbuf.port_value = value;
	tmpbuf.port = port;
	if(ioctl(fd, IOPWRITE, &tmpbuf)) {
		perror("IOCTL failed\n");
		exit(1);
	}
	return 1;
}

////////////////////////////////////////////////

last update: 02-JAN-2004

Google
 
Web www.captain.at
go to top
© 1996-2010 . All rights reserved.
No reproduction, distribution, publishing or transmission of the copyrighted materials at this site is permitted. Policy
go to top