Changeset 2fc4157 in multiio


Ignore:
Timestamp:
Jun 10, 2009, 6:06:38 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
master
Children:
da59d43
Parents:
6f4d6bd
Message:

2009-06-10 Joel Sherrill <joel.sherrill@…>

  • mio_io_rtems.c: All Linux functionality should be implemented now EXCEPT hooking the interrupt.
Location:
pcmmio/original
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pcmmio/original/ChangeLog

    r6f4d6bd r2fc4157  
     12009-06-10      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * mio_io_rtems.c: All Linux functionality should be implemented now
     4        EXCEPT hooking the interrupt.
     5
    162009-06-10      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • pcmmio/original/mio_io_rtems.c

    r6f4d6bd r2fc4157  
    1515#include <unistd.h>     /* exit */
    1616#include <sys/ioctl.h>  /* ioctl */
    17 
     17#include <stdlib.h>     /* for exit */
     18
     19#include <rtems.h>
    1820#include <i386_io.h>
    1921
    2022/*
    21  *  These have to be configured SOMEHOW
     23 *  These are configured by the initialization call.
    2224 */
    2325
     
    2628/* This holds the base addresses of the board */
    2729static unsigned short base_port = 0;
    28 
    29 /* for RTEMS */
    30 void pcmmio_initialize(
    31   unsigned short _base_port,
    32   unsigned short _irq
    33 )
    34 {
    35   base_port = _base_port;
    36   irq       = _irq;
    37 }
    3830
    3931/* Function prototypes for local functions */
     
    4234void clr_int(int bit_number);
    4335int get_int(void);
     36
     37/* RTEMS Ids for Wait Queues */
     38rtems_id wq_a2d_1;
     39rtems_id wq_a2d_2;
     40rtems_id wq_dac_1;
     41rtems_id wq_dac_2;
     42rtems_id wq_dio;
     43
     44void interruptible_sleep_on(
     45  rtems_id *id
     46);
     47void wake_up_interruptible(
     48  rtems_id *id
     49);
    4450
    4551///////////////////////////////////////////////////////////////////////////////
     
    326332}
    327333
     334int wait_adc_int(int adc_num)
     335{
     336  if (check_handle())   /* Check for chip available */
     337    return -1;
     338
     339  if (adc_num) {
     340    interruptible_sleep_on(&wq_a2d_1);
     341  } else {
     342    interruptible_sleep_on(&wq_a2d_2);
     343  }
     344
     345  return 0;
     346}
     347
     348
     349int wait_dac_int(int dac_num)
     350{
     351  if (check_handle())   /* Check for chip available */
     352    return -1;
     353
     354  if (dac_num) {
     355    interruptible_sleep_on(&wq_dac_1);
     356  } else {
     357    interruptible_sleep_on(&wq_dac_2);
     358  }
     359
     360  return 0;
     361}
     362
     363
     364int wait_dio_int(void)
     365{
     366  int i;
     367
     368  if (check_handle())   /* Check for chip available */
     369    return -1;
     370
     371  if((i = get_buffered_int()))
     372    return i;
     373
     374  interruptible_sleep_on(&wq_dio);
     375
     376  i = get_buffered_int();
     377
     378  return i;
     379}
     380
     381
    328382static int handle = 0; /* XXX move to lower */
    329 
    330 
    331 int wait_adc_int(int adc_num)
    332 {
    333   int c;
    334 
    335   if (check_handle())   /* Check for chip available */
    336     return -1;
    337 
    338   if (adc_num)
    339       c=ioctl(handle,WAIT_A2D_INT_1,NULL);
    340   else
    341       c=ioctl(handle,WAIT_A2D_INT_2,NULL);
    342 
    343 
    344   return (c & 0xff);
    345 
    346 }
    347 
    348 
    349 int wait_dac_int(int dac_num)
    350 {
    351   int c;
    352 
    353   if (check_handle())   /* Check for chip available */
    354     return -1;
    355 
    356   if (dac_num)
    357       c=ioctl(handle,WAIT_DAC_INT_1,NULL);
    358   else
    359       c=ioctl(handle,WAIT_DAC_INT_2,NULL);
    360 
    361   return (c & 0xff);
    362 
    363 }
    364 
    365 
    366 int wait_dio_int(void)
    367 {
    368   int c;
    369 
    370   if (check_handle())   /* Check for chip available */
    371     return -1;
    372 
    373   c=ioctl(handle,WAIT_DIO_INT,NULL);
    374 
    375   return (c & 0xff);
    376 
    377 }
    378 
    379383
    380384int check_handle(void)
     
    405409}
    406410
     411/*
     412 *  RTEMS barrier create helper
     413 */
     414void pcmmio_barrier_create(
     415  rtems_name  name,
     416  rtems_id   *id
     417)
     418{
     419  rtems_status_code rc;
     420
     421  rc = rtems_barrier_create( name, RTEMS_BARRIER_MANUAL_RELEASE, 0, id );
     422  if ( rc == RTEMS_SUCCESSFUL )
     423    return;
     424
     425 printk( "Unable to create PCMMIO Barrier\n" );
     426 exit(1);
     427}
     428
     429void interruptible_sleep_on(
     430  rtems_id *id
     431)
     432{
     433  rtems_status_code rc;
     434
     435  rc = rtems_barrier_wait(*id, 0);
     436}
     437
     438void wake_up_interruptible(
     439  rtems_id *id
     440)
     441{
     442  rtems_status_code rc;
     443  uint32_t          unblocked;
     444
     445  rc = rtems_barrier_release(*id, &unblocked);
     446}
     447
     448/*
     449 * RTEMS specific initialization routine
     450 */
     451void pcmmio_initialize(
     452  unsigned short _base_port,
     453  unsigned short _irq
     454)
     455{
     456  /* hardware configuration information */
     457  base_port = _base_port;
     458  irq       = _irq;
     459
     460  /* Create RTEMS Objects */
     461  pcmmio_barrier_create( rtems_build_name( 'a', '2', 'd', '1' ), &wq_a2d_1 );
     462  pcmmio_barrier_create( rtems_build_name( 'd', 'a', 'c', '1' ), &wq_dac_1 );
     463  pcmmio_barrier_create( rtems_build_name( 'd', 'a', 'c', '2' ), &wq_dac_2 );
     464  pcmmio_barrier_create( rtems_build_name( 'd', 'i', 'o', ' ' ), &wq_dio );
     465}
     466
    407467
    408468/*
     
    421481static int inptr = 0;
    422482static int outptr = 0;
     483
     484static unsigned char adc2_port_image;
     485
     486/* This is the common interrupt handler. It is called by the
     487 * actual hardware ISR.
     488 */
     489
     490void common_handler(void)
     491{
     492  unsigned char status;
     493  unsigned char int_num;
     494
     495  /* Read the interrupt ID register from ADC2 */
     496
     497  adc2_port_image = adc2_port_image | 0x20;
     498  outb(adc2_port_image,base_port + 0x0f);
     499
     500  status = inb(base_port + 0x0f);
     501  if (status & 1) {
     502    /* Clear ADC1 interrupt */
     503    inb(base_port+1);      /* Clear interrupt */
     504
     505    /* Wake up any holding processes */
     506    wake_up_interruptible(&wq_a2d_1);
     507  }
     508
     509  if (status & 2) {
     510    /* Clear ADC1 interrupt */
     511    inb(base_port+5);      /* Clear interrupt */
     512
     513    /* Wake up anybody waiting for ADC1 */
     514    wake_up_interruptible(&wq_a2d_2);
     515  }
     516
     517  if (status & 4) {
     518    /* Clear DAC1 interrupt */
     519    inb(base_port+9);    /* Clear interrupt */
     520
     521    /* Wake up if you're waiting on DAC1 */
     522    wake_up_interruptible(&wq_dac_1);
     523  }
     524
     525  if (status & 8) {
     526
     527    /* DIO interrupt. Find out which bit */
     528    int_num = get_int();
     529    if (int_num) {
     530      #ifdef DEBUG
     531        printk("<1>Buffering DIO interrupt on bit %d\n",int_num);
     532      #endif
     533
     534      /* Buffer the interrupt */
     535
     536      int_buffer[inptr++] = int_num;
     537      if (inptr == MAX_INTS)
     538        inptr = 0;
     539
     540        /* Clear the interrupt */
     541        clr_int(int_num);
     542    }
     543
     544    /* Wake up anybody waiting for a DIO interrupt */
     545    wake_up_interruptible(&wq_dio);
     546  }
     547
     548  if (status & 0x10) {
     549    /* Clear DAC2 Interrupt */
     550    inb(base_port+0x0d);    /* Clear interrupt */
     551
     552    /* Wake up DAC2 holding processes */
     553    wake_up_interruptible(&wq_dac_2);
     554  }
     555
     556  /* Reset the access to the interrupt ID register */
     557  adc2_port_image = adc2_port_image & 0xdf;
     558  outb(adc2_port_image,base_port+0x0f);
     559}
     560
    423561
    424562void clr_int(int bit_number)
Note: See TracChangeset for help on using the changeset viewer.