Changeset d5ed9e1 in rtems


Ignore:
Timestamp:
03/07/06 22:05:22 (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
77b0a73
Parents:
bea51c0
Message:

2006-03-07 Thomas Doerfler <Thomas.Doerfler@…>

PR 853/filesystem

  • libchip/ide/ata.c, libchip/ide/ide_controller.c: The ata driver should be modified to support the new exception scheme and to use the handle parameter.
Location:
c/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/ChangeLog

    rbea51c0 rd5ed9e1  
     12006-03-07      Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
     2
     3        PR 853/filesystem
     4        * libchip/ide/ata.c, libchip/ide/ide_controller.c: The ata driver
     5        should be modified to support the new exception scheme and to use the
     6        handle parameter.
     7
    182006-02-a32     Eric Norum <norume@aps.anl.gov>
    29
  • c/src/libchip/ide/ata.c

    rbea51c0 rd5ed9e1  
    2727#include "ata_internal.h"
    2828#include <libchip/ata.h>
    29 
    30 #define DEBUG
     29/* #define DEBUG */
    3130
    3231#ifdef DEBUG
    3332#include <stdio.h>
     33#endif
     34
     35/*
     36 * FIXME: make this better...
     37 * find out, which exception model is used
     38 * assume, that all i386 BSPs use new exception handling
     39 * assume, that some PPC BSPs use new exception handling
     40 * assume, that all other BSPs use old exception handling
     41 */
     42#if defined(_OLD_EXCEPTIONS) || (!defined(__i386__) && !defined(__PPC__))
     43
     44#define ATA_USE_OLD_EXCEPTIONS
     45#endif
     46
     47#if !defined(ATA_USE_OLD_EXCEPTIONS)
     48#include <bsp/irq.h>
     49#define ATA_IRQ_CHAIN_MAX_CNT 4 /* support up to 4 ATA devices */
     50typedef struct {
     51  rtems_irq_number name;
     52  Chain_Control irq_chain;
     53} ata_irq_chain_t;
     54
     55ata_irq_chain_t ata_irq_chain[ATA_IRQ_CHAIN_MAX_CNT];
     56int ata_irq_chain_cnt = 0;
    3457#endif
    3558
     
    96119static rtems_id ata_queue_id;
    97120
     121#if defined (ATA_USE_OLD_EXCEPTIONS)
    98122/* Mapping of interrupt vectors to devices */
    99123static Chain_Control ata_int_vec[ATA_MAX_RTEMS_INT_VEC_NUMBER + 1];
     124#endif
    100125
    101126static void
     
    555580    if (Chain_Has_only_one_node(&ata_ide_ctrls[ctrl_minor].reqs))
    556581    {
    557         uint16_t        val;
     582
    558583        ata_queue_msg_t msg;
    559584
    560585#ifdef DEBUG
     586        uint16_t      val;
    561587        /*
    562588         * read IDE_REGISTER_ALTERNATE_STATUS instead IDE_REGISTER_STATUS
     
    585611 *     NONE
    586612 */
     613#if defined(ATA_USE_OLD_EXCEPTIONS)
    587614rtems_isr
    588615ata_interrupt_handler(rtems_vector_number vec)
     
    608635    }
    609636}
     637#else
     638
     639void ata_interrupt_handler(rtems_irq_hdl_param handle)
     640{
     641  int ata_irq_chain_index = (int) handle;
     642    Chain_Node      *the_node =
     643      ata_irq_chain[ata_irq_chain_index].irq_chain.last;
     644    ata_queue_msg_t  msg;
     645    uint16_t       byte; /* emphasize that only 8 low bits is meaningful */
     646
     647
     648    for ( ; !Chain_Is_tail(&ata_irq_chain[ata_irq_chain_index].irq_chain,
     649                           the_node) ; )
     650    {
     651        /* if (1) - is temporary hack - currently I don't know how to identify
     652         * controller which asserted interrupt if few controllers share one
     653         * interrupt line
     654         */
     655        if (1)
     656        {
     657            msg.ctrl_minor = ((ata_int_st_t *)the_node)->ctrl_minor;
     658            ide_controller_read_register(msg.ctrl_minor, IDE_REGISTER_STATUS,
     659                                         &byte);
     660            ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, msg.ctrl_minor, 0);
     661        }
     662        the_node = the_node->next;
     663    }
     664}
     665
     666void ata_interrupt_on(const rtems_irq_connect_data *ptr)
     667  {
     668
     669    /* enable ATA device interrupt */
     670    ide_controller_write_register(0,
     671                                  IDE_REGISTER_DEVICE_CONTROL_OFFSET,
     672                                  0x00
     673                                 );
     674  }
     675
     676
     677void ata_interrupt_off(const rtems_irq_connect_data *ptr)
     678  {
     679
     680    /* disable ATA device interrupt */
     681    ide_controller_write_register(0,
     682                                  IDE_REGISTER_DEVICE_CONTROL_OFFSET,
     683                                  IDE_REGISTER_DEVICE_CONTROL_nIEN
     684                                 );
     685  }
     686
     687
     688int ata_interrupt_isOn(const rtems_irq_connect_data *ptr)
     689  {
     690  uint16_t byte; /* emphasize that only 8 low bits is meaningful */
     691
     692    /* return int. status od ATA device */
     693    ide_controller_read_register(0,
     694                                IDE_REGISTER_DEVICE_CONTROL_OFFSET,
     695                                &byte
     696                                );
     697
     698    return !(byte & IDE_REGISTER_DEVICE_CONTROL_nIEN);
     699  }
     700
     701
     702static rtems_irq_connect_data ata_irq_data =
     703  {
     704
     705    0, /* filled out before use... */
     706    (rtems_irq_hdl) ata_interrupt_handler,/* filled out before use... */
     707    (rtems_irq_hdl_param) NULL,
     708    (rtems_irq_enable) ata_interrupt_on,
     709    (rtems_irq_disable) ata_interrupt_off,
     710    (rtems_irq_is_enabled) ata_interrupt_isOn
     711  };
     712#endif
    610713
    611714/* ata_pio_in_protocol --
     
    811914
    812915                    default:
     916#ifdef DEBUG
    813917                        printf("ata_queue_task: non-supported command type\n");
     918#endif
    814919                        ata_request_done(areq, ctrl_minor,
    815920                                         RTEMS_UNSATISFIED,
     
    9081013    dev_t              device;
    9091014    ata_int_st_t      *int_st;
     1015#if defined(ATA_USE_OLD_EXCEPTIONS)
    9101016    rtems_isr_entry    old_isr;
     1017#else
     1018    int ata_irq_chain_use;
     1019#endif
    9111020
    9121021    if (ata_initialized)
     
    9771086        ata_devs[i].device = ATA_UNDEFINED_VALUE;
    9781087
     1088#if defined(ATA_USE_OLD_EXCEPTIONS)
    9791089    /* prepare ATA driver for handling  interrupt driven devices */
    9801090    for (i = 0; i < ATA_MAX_RTEMS_INT_VEC_NUMBER; i++)
    9811091        Chain_Initialize_empty(&ata_int_vec[i]);
     1092#else
     1093    for (i = 0; i < ATA_IRQ_CHAIN_MAX_CNT; i++) {
     1094      Chain_Initialize_empty(&(ata_irq_chain[i].irq_chain));
     1095    }
     1096#endif
    9821097
    9831098    /*
     
    10181133
    10191134            int_st->ctrl_minor = ctrl_minor;
    1020 
     1135#if defined(ATA_USE_OLD_EXCEPTIONS)
    10211136            status = rtems_interrupt_catch(
    10221137                         ata_interrupt_handler,
    10231138                         IDE_Controller_Table[ctrl_minor].int_vec,
    10241139                         &old_isr);
     1140#else
     1141            /*
     1142             * FIXME: check existing entries. if they use the same
     1143             * IRQ name, then append int_st to respective chain
     1144             * otherwise, use new ata_irq_chain entry
     1145             */
     1146            ata_irq_chain_use = -1;
     1147            for (i = 0;
     1148                 ((i < ata_irq_chain_cnt) &&
     1149                  (ata_irq_chain_use < 0));i++) {
     1150              if (ata_irq_chain[i].name ==
     1151                  IDE_Controller_Table[ctrl_minor].int_vec) {
     1152                ata_irq_chain_use = i;
     1153              }
     1154            }
     1155            if (ata_irq_chain_use < 0) {
     1156              /*
     1157               * no match found, try to use new channel entry
     1158               */
     1159              if (ata_irq_chain_cnt < ATA_IRQ_CHAIN_MAX_CNT) {
     1160                ata_irq_chain_use = ata_irq_chain_cnt++;
     1161
     1162                ata_irq_chain[ata_irq_chain_use].name =
     1163                  IDE_Controller_Table[ctrl_minor].int_vec;
     1164                ata_irq_data.name   =
     1165                  IDE_Controller_Table[ctrl_minor].int_vec;
     1166                ata_irq_data.hdl    = ata_interrupt_handler;
     1167                ata_irq_data.handle = ctrl_minor;
     1168
     1169                status = ((0 == BSP_install_rtems_irq_handler(&ata_irq_data))
     1170                          ? RTEMS_INVALID_NUMBER
     1171                          : RTEMS_SUCCESSFUL);
     1172              }
     1173              else {
     1174                status = RTEMS_TOO_MANY;
     1175              }
     1176            }
     1177#endif
    10251178            if (status != RTEMS_SUCCESSFUL)
    10261179            {
     
    10321185                return status;
    10331186            }
     1187#if defined(ATA_USE_OLD_EXCEPTIONS)
    10341188            Chain_Append(
    10351189                &ata_int_vec[IDE_Controller_Table[ctrl_minor].int_vec],
    10361190                &int_st->link);
     1191#else
     1192            Chain_Append(
     1193                &(ata_irq_chain[ata_irq_chain_use].irq_chain),
     1194                &int_st->link);
     1195#endif
    10371196
    10381197            /* disable interrupts */
     
    13111470
    13121471        default:
     1472#ifdef DEBUG
    13131473            printf("ata_queue_task: non-supported command type\n");
     1474#endif
    13141475            areq->breq->status = RTEMS_UNSATISFIED;
    13151476            areq->breq->error = RTEMS_NOT_IMPLEMENTED;
  • c/src/libchip/ide/ide_controller.c

    rbea51c0 rd5ed9e1  
    5252        IDE_Controller_Table[minor].status = IDE_CTRL_NON_INITIALIZED;
    5353
    54         if ((IDE_Controller_Table[minor].probe != NULL &&
    55              IDE_Controller_Table[minor].probe(minor)) ||
    56             IDE_Controller_Table[minor].fns->ctrl_probe(minor))
     54        if ((IDE_Controller_Table[minor].probe == NULL ||
     55             IDE_Controller_Table[minor].probe(minor)) &&
     56            (IDE_Controller_Table[minor].fns->ctrl_probe == NULL ||
     57             IDE_Controller_Table[minor].fns->ctrl_probe(minor)))
    5758        {
    5859            status = rtems_io_register_name(IDE_Controller_Table[minor].name,
Note: See TracChangeset for help on using the changeset viewer.