From ThirdMartini

Contents

[edit] Introduction

Linux32io is a shim driver and library to allow usermode hardware access, including irq, port mapping and dma to isa and pci devices. It was originally written as a simple replacement for "windriver" on any linux platform. This driver is designed for embedded application use, as it allows FULL hardware access from usermode applications.

[edit] Limitations

This version of the software only works for ISA based devices. If anyone is interested I can add the necessary PCI device support.

[edit] Example


#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include "Linux32io.h"
 
// declare our io object
Linux32io io;

// This is our IrqService routine
//  it will be called when an irq occurs
void IrqService(LPVOID datum){
    printf("MAIN:: IRQ RECEIVED!!!\n");
    io._inpw(0x300);
    io._inpw(0x304);
}

int main(void){
    BYTE bRet;
    char test[112];
    int i;

    bRet=io.Open();
    printf("io.Open()==%s\n",io.getErrorString(bRet));

    // Read and write some bytes to our device
    io._inpw(0x300);
    io._inpw(0x304);
    io._outpw(0x308,0x00FF);
    io._outpw(0x300,0x0000);
	
    // Register an IRQ resource
    // IRQ 5, no options, irq is sharable
    bRet=io.addIRQresource(5,0,1);
    printf("io.addIrqResource()==%s\n",io.getErrorString(bRet));
    // install our handler, this will cause the IrqService call to be
    // executed when we discover an irq
    io.installHandler(IrqService,test);
    if(io.enableIRQ()==0){
         usleep(100000);
         printf("IRQ ENABLED!\n");
         scanf("%s",test);
         printf("GOTCHA\n");
    }else{
         printf("IRQ NOT ENABLED!\n");
         io.waitIRQ();
    }

    io.disableIRQ();
    bRet=io.rmIRQresource(5,0,1);
    printf("io.rmIrqResource()==%s\n",io.getErrorString(bRet));

    bRet=io.Close();
    printf("io.Close()==%s\n",io.getErrorString(bRet));
    return 0;
}


[edit] Download:

    Filename Version Description
    Linux32io Driver 2.4.26-1 Linux Usermode Driver Library for ISA devices
    Personal tools