A Data Acquisition System for Linux 
by Dhananjay V. Gadre and Sunu Engineer



Listing One
/* testport.c */
/* compile as: gcc -O testport.c */
/* Execution is possible only as a superuser*/

#include <asm/io.h>
#include <asm/segment.h>
#include <asm/system.h>
#include <unistd.h>

int ioperm();

#define port_add 0x378

void main()
{
unsigned char test_value;
int ret_value;
ret_value=ioperm(data_port, 3, 1); 

if ( ret_value == -1 ) 
                     {
                     printf("Cannot get I/O permission\n");
                     exit(-1);
                     }
outb(0x55,port_add);

test_value=inb(port_add);
printf("\nValue at Data port= %x\n", test_value);
test_value=inb(port_add+1);
printf("\nValue at the Status Port= %x\n", test_value);
test_value=inb(port_add+2);
printf("\nValue at Control Port= %x\n", test_value);
}


Listing Two
/* linux/drivers/char/mem.c
 *  Copyright (C) 1991, 1992  Linus Torvalds
 */
  ...
int chr_dev_init(void)
{
    if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
        printk("unable to get major %d for memory devs\n", MEM_MAJOR);
    rand_initialize();
    tty_init();
#ifdef CONFIG_PRINTER
    lp_init();
#endif
#if defined (CONFIG_BUSMOUSE) || defined (CONFIG_82C710_MOUSE) || \
    defined (CONFIG_PSMOUSE) || defined (CONFIG_MS_BUSMOUSE) || \
    defined (CONFIG_ATIXL_BUSMOUSE)
   mouse_init();
#endif
#ifdef CONFIG_SOUND
    soundcard_init();
#endif
#if CONFIG_QIC02_TAPE
    qic02_tape_init();
#endif
#ifdef  CONFIG_SANSON_ADC
    adc_init(); /* Here is where our device driver is initalized */
#endif
    return 0;
}
 ...



2


