Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:40

0001 /*
0002  * RTEMS PC386 IDE harddisc driver tables
0003  *
0004  * This file contains the table of functions for the BSP layer
0005  * for IDE access below the libchip IDE harddisc driver.
0006  */
0007 
0008 /*
0009  * Copyright (c) 2003 IMD Ingenieurbuero fuer Microcomputertechnik
0010  * All rights reserved.
0011  *
0012  * The license and distribution terms for this file may be
0013  * found in the file LICENSE in this distribution or at
0014  * http://www.rtems.org/license/LICENSE.
0015  */
0016 
0017 #include <rtems.h>
0018 #include <bsp.h>
0019 #include <libchip/ide_ctrl.h>
0020 #include <libchip/ide_ctrl_cfg.h>
0021 #include <libchip/ide_ctrl_io.h>
0022 
0023 extern bool pc386_ide_show;
0024 
0025 /*
0026  * The following table configures the functions used for IDE drivers
0027  * in this BSP.
0028  */
0029 
0030 /*
0031  * The following table configures the IDE drivers used in this BSP.
0032  */
0033 extern ide_ctrl_fns_t pc386_ide_ctrl_fns;
0034 
0035 /* IDE controllers Table */
0036 ide_controller_bsp_table_t IDE_Controller_Table[] = {
0037   {"/dev/ide0",
0038    IDE_STD, /* standard IDE controller */
0039    &pc386_ide_ctrl_fns,
0040    NULL, /* probe for IDE standard registers */
0041    FALSE, /* not (yet) initialized */
0042    0x1f0,  /* base I/O address for first IDE controller */
0043    FALSE,0, /* not (yet) interrupt driven */
0044    NULL
0045   }
0046   , /* colon only needed when both interfaces present */
0047   {"/dev/ide1",
0048    IDE_STD, /* standard IDE controller */
0049    &pc386_ide_ctrl_fns,
0050    NULL, /* probe for IDE standard registers */
0051    FALSE, /* not (yet) initialized */
0052    0x170,  /* base I/O address for second IDE controller */
0053    FALSE,0, /* not (yet) interrupt driven */
0054    NULL
0055   }
0056 };
0057 
0058 /* Number of rows in IDE_Controller_Table. Default is 0. */
0059 unsigned long IDE_Controller_Count;
0060 
0061 #if IDE_USE_PRIMARY_INTERFACE
0062 #define IDE1_DEFAULT true
0063 #else
0064 #define IDE1_DEFAULT false
0065 #endif
0066 #if IDE_USE_SECONDARY_INTERFACE
0067 #define IDE2_DEFAULT true
0068 #else
0069 #define IDE2_DEFAULT false
0070 #endif
0071 
0072 void bsp_ide_cmdline_init(void)
0073 {
0074   const char* ide_disable;
0075 
0076   ide_disable = bsp_cmdline_arg ("--ide-disable");
0077 
0078   if (ide_disable == NULL) {
0079     bool ide1 = IDE1_DEFAULT;
0080     bool ide2 = IDE2_DEFAULT;
0081     const char* ide;
0082 
0083     /*
0084      * Can have:
0085      *  --ide=0,1
0086      */
0087     ide = bsp_cmdline_arg ("--ide=");
0088 
0089     if (ide)
0090     {
0091       int i;
0092       /*
0093        * If a command line option exists remove the defaults.
0094        */
0095       ide1 = ide2 = false;
0096 
0097       ide += sizeof ("--ide=") - 1;
0098 
0099       for (i = 0; i < 3; i++)
0100       {
0101         switch (ide[i])
0102         {
0103           case '0':
0104             ide1 = true;
0105             break;
0106           case '1':
0107             ide2 = true;
0108             break;
0109           case '2':
0110           case '3':
0111           case '4':
0112           case '5':
0113           case '6':
0114           case '7':
0115           case '8':
0116           case '9':
0117           case ',':
0118             break;
0119           default:
0120             break;
0121         }
0122       }
0123     }
0124 
0125     if (ide2 && !ide1)
0126       IDE_Controller_Table[0] = IDE_Controller_Table[1];
0127 
0128     if (ide1)
0129       IDE_Controller_Count++;
0130     if (ide2)
0131       IDE_Controller_Count++;
0132 
0133     /*
0134      * Allow the user to get the initialise to print probing
0135      * type information.
0136      */
0137     ide = bsp_cmdline_arg ("--ide-show");
0138 
0139     if (ide)
0140       pc386_ide_show = true;
0141   }
0142 }