This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

io-pcmcia patch


Hi,

This patch adds the cf_remove_handler() function (counterpart to cf_register_handler). It also adds calls to cf_hwr_interrupt_enable() and cf_hwr_interrupt_disable(). Since these are new functions to be provided by the driver, some empty functions will need to be added in any existing drivers (e.g. devs/pcmcia/arm/cerf). I can provide a patch if you like, but I won't be able to test. I'll be providing a PCMCIA driver for the PowerPC MPC8xx shortly.

Shaun Louie
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' ecos.20080311/packages/io/pcmcia/current/ChangeLog ecos.20080311.io-pcmcia/packages/io/pcmcia/current/ChangeLog
--- ecos.20080311/packages/io/pcmcia/current/ChangeLog	2004-10-05 02:01:33.000000000 -0600
+++ ecos.20080311.io-pcmcia/packages/io/pcmcia/current/ChangeLog	2008-03-17 18:01:32.000000000 -0600
@@ -1,5 +1,12 @@
+2008-03-13  Shaun Louie  <sal@microplex.com>
+
+    * include/pcmcia.h:
+    * src/pcmcia.c: Added some useful defines. Added cf_hwr_interrupt_xxx
+    functions to enable/disable interrupt (nestable). Added a function to
+    remove and disable the interrupt handler (cf_remove_handler).
+
 2004-10-04  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/io_pcmcia.cdl: Require that the hardware implements PCMCIA
 
 2004-08-11  Mark Salter  <msalter@redhat.com>
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' ecos.20080311/packages/io/pcmcia/current/include/pcmcia.h ecos.20080311.io-pcmcia/packages/io/pcmcia/current/include/pcmcia.h
--- ecos.20080311/packages/io/pcmcia/current/include/pcmcia.h	2004-08-11 09:43:11.000000000 -0600
+++ ecos.20080311.io-pcmcia/packages/io/pcmcia/current/include/pcmcia.h	2008-03-17 18:03:17.000000000 -0600
@@ -2,11 +2,11 @@
 #define CYGONCE_PCMCIA_H
 // ====================================================================
 //
 //      pcmcia.h
 //
-//      Device I/O 
+//      Device I/O
 //
 // ====================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
@@ -75,47 +75,92 @@
     int            io_length;
     unsigned char *mem;
     int            mem_length;
     int            int_num;    // Hardware interrupt number
     struct cf_irq_handler irq_handler;
+    int            int_disable_nest_lvl; // allows nesting of disabling/enabling interrupt
 };
 
-#define CF_SLOT_STATE_Empty     0
-#define CF_SLOT_STATE_Inserted  1
-#define CF_SLOT_STATE_Powered   2
-#define CF_SLOT_STATE_Reset     3
-#define CF_SLOT_STATE_Ready     4
-#define CF_SLOT_STATE_Removed   5
-
-#define CF_CISTPL_VERS_1        0x15
-#define CF_CISTPL_CONFIG        0x1A
-#define CF_CISTPL_CFTABLE_ENTRY 0x1B
-#define CF_CISTPL_MANFID        0x20
-#define CF_CISTPL_FUNCID        0x21
+#define CF_SLOT_STATE_Empty                 0
+#define CF_SLOT_STATE_Inserted              1
+#define CF_SLOT_STATE_Powered               2
+#define CF_SLOT_STATE_Reset                 3
+#define CF_SLOT_STATE_Ready                 4
+#define CF_SLOT_STATE_Removed               5
+
+#define CF_SLOT_TYPE_MULTI                  0x00
+#define CF_SLOT_TYPE_MEMORY                 0x01
+#define CF_SLOT_TYPE_SERIAL_PORT            0x02
+#define CF_SLOT_TYPE_PARALLEL_PORT          0x03
+#define CF_SLOT_TYPE_FIXED_DISK             0x04
+#define CF_SLOT_TYPE_VIDEO                  0x05
+#define CF_SLOT_TYPE_NETWORK                0x06
+#define CF_SLOT_TYPE_AIMS                   0x07
+#define CF_SLOT_TYPE_VENDOR_SPEC            0xfe
+#define CF_SLOT_TYPE_UNKNOWN                0xff
+
+/* Layer 1 Basic compatibility Tuples */
+#define CF_CISTPL_NULL                      0x00
+#define CF_CISTPL_DEVICE                    0x01
+#define CF_CISTPL_LONGLINK_MFC              0x06
+#define CF_CISTPL_CHECKSUM                  0x10
+#define CF_CISTPL_LONGLINK_A                0x11
+#define CF_CISTPL_LONGLINK_C                0x12
+#define CF_CISTPL_LINKTARGET                0x13
+#define CF_CISTPL_NO_LINK                   0x14
+#define CF_CISTPL_VERS_1                    0x15
+#define CF_CISTPL_ALTSTR                    0x16
+#define CF_CISTPL_DEVICE_A                  0x17
+#define CF_CISTPL_JEDEC_C                   0x18
+#define CF_CISTPL_JEDEC_A                   0x19
+#define CF_CISTPL_CONFIG                    0x1A
+#define CF_CISTPL_CFTABLE_ENTRY             0x1B
+#define CF_CISTPL_DEVICE_OC                 0x1C
+#define CF_CISTPL_DEVICE_OA                 0x1D
+#define CF_CISTPL_DEVICE_GEO                0x1E
+#define CF_CISTPL_DEVICE_GEO_A              0x1F
+
+/* Layer 2 Data Recording format Tuples */
+#define CF_CISTPL_MANFID                    0x20
+#define CF_CISTPL_FUNCID                    0x21
+#define CF_CISTPL_FUNCE                     0x22
+#define CF_CISTPL_SWIL                      0x23
+#define CF_CISTPL_VERS_2                    0x40
+#define CF_CISTPL_FORMAT                    0x41
+#define CF_CISTPL_GEOMETRY                  0x42
+#define CF_CISTPL_BYTEORDER                 0x43
+#define CF_CISTPL_DATE                      0x44
+#define CF_CISTPL_BATTERY                   0x45
+
+/* Layer 3 Data Organization Tuples */
+#define CF_CISTPL_ORG                       0x46
+
+/* Layer 4 System-Specific Standard Tuples */
+#define CF_CISTPL_END                       0xFF
 
 // Configuration register offsets
-#define CF_CONFIG_COR           0x00
-#define CF_CONFIG_CCSR          0x02
-#define CF_CONFIG_PRR           0x04
-#define CF_CONFIG_SCR           0x06
-#define CF_CONFIG_ESR           0x08
-#define CF_CONFIG_IOBASE_0      0x0a
-#define CF_CONFIG_IOBASE_1      0x0c
-#define CF_CONFIG_IOBASE_2      0x0e
-#define CF_CONFIG_IOBASE_3      0x10
-#define CF_CONFIG_IOSIZE        0x12
+#define CF_CONFIG_COR                       0x00
+#define CF_CONFIG_CCSR                      0x02
+#define CF_CONFIG_PRR                       0x04
+#define CF_CONFIG_SCR                       0x06
+#define CF_CONFIG_ESR                       0x08
+#define CF_CONFIG_IOBASE_0                  0x0a
+#define CF_CONFIG_IOBASE_1                  0x0c
+#define CF_CONFIG_IOBASE_2                  0x0e
+#define CF_CONFIG_IOBASE_3                  0x10
+#define CF_CONFIG_IOSIZE                    0x12
 
 // Configuration Option Register bits
-#define CF_COR_FUNC_ENA         0x01
-#define CF_COR_ADDR_DECODE      0x02
-#define CF_COR_IREQ_ENA         0x04
-#define CF_COR_LEVEL_REQ        0x40
-#define CF_COR_SOFT_RESET       0x80
+#define CF_COR_FUNC_ENA                     0x01
+#define CF_COR_ADDR_DECODE                  0x02
+#define CF_COR_IREQ_ENA                     0x04
+#define CF_COR_LEVEL_REQ                    0x40
+#define CF_COR_SOFT_RESET                   0x80
 
 
 #define CF_MAX_IO_ADDRS      8
-struct cf_io_space {    
+struct cf_io_space {
     unsigned long base[CF_MAX_IO_ADDRS];     // Base address of I/O registers
     unsigned long size[CF_MAX_IO_ADDRS];     // Length(-1) of I/O registers
     int           num_addrs;
     unsigned char mode;
 };
@@ -135,18 +180,19 @@
     unsigned char mask[16];
 };
 
 // Function prototypes
 
-bool cf_get_CIS(struct cf_slot *slot, unsigned char id, 
+bool cf_get_CIS(struct cf_slot *slot, unsigned char id,
                 unsigned char *buf, int *len, int *ptr);
 void cf_set_COR(struct cf_slot *slot, unsigned long cor, unsigned char val);
 bool cf_parse_cftable(unsigned char *buf, int len, struct cf_cftable *cftable);
 bool cf_parse_config(unsigned char *buf, int len, struct cf_config *config);
 struct cf_slot *cf_get_slot(int indx);
 void cf_change_state(struct cf_slot *slot, int desired_state);
 void cf_register_handler(struct cf_slot *, void (*handler)(int, int, void *), void *);
+void cf_remove_handler(struct cf_slot *);
 void cf_clear_interrupt(struct cf_slot *);
 void cf_init(void);
 
 void cf_hwr_poll(struct cf_slot *);
 
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' ecos.20080311/packages/io/pcmcia/current/src/pcmcia.c ecos.20080311.io-pcmcia/packages/io/pcmcia/current/src/pcmcia.c
--- ecos.20080311/packages/io/pcmcia/current/src/pcmcia.c	2002-05-23 17:06:23.000000000 -0600
+++ ecos.20080311.io-pcmcia/packages/io/pcmcia/current/src/pcmcia.c	2008-03-17 18:01:32.000000000 -0600
@@ -42,11 +42,11 @@
 //
 // Author(s):    gthomas
 // Contributors: gthomas
 // Date:         2000-07-06
 // Purpose:      PCMCIA support
-// Description: 
+// Description:
 //
 //####DESCRIPTIONEND####
 //
 //==========================================================================
 
@@ -63,22 +63,24 @@
 static struct cf_slot cf_slots[CF_NUM_SLOTS];
 
 // Implementation routines
 void cf_hwr_init(struct cf_slot *slot);
 void cf_hwr_change_state(struct cf_slot *slot, int desired_state);
+void cf_hwr_interrupt_enable(struct cf_slot * slot);
+void cf_hwr_interrupt_disable(struct cf_slot * slot);
 void cf_hwr_clear_interrupt(struct cf_slot *slot);
 
 bool
-cf_get_CIS(struct cf_slot *slot, unsigned char id, 
+cf_get_CIS(struct cf_slot *slot, unsigned char id,
            unsigned char *buf, int *len, int *ptr)
 {
     int i, size;
     unsigned char *cis = slot->attr;
     unsigned char *cis_end = cis + slot->attr_length;
     cis += *ptr;
     while (cis < cis_end) {
-        if (*cis == 0xFF) {
+        if (*cis == CF_CISTPL_END) {
             break;
         }
         if (*cis == id) {
             size = *(cis+2) + 2;
             for (i = 0;  i < size;  i++) {
@@ -125,15 +127,15 @@
 cf_parse_timing_structure(unsigned char **buf)
 {
     unsigned char *bp = *buf;
     unsigned char tpce_td = *bp++;
     if ((tpce_td & 0x1C) != 0x1C) {
-//        diag_printf("READY = %x.%x\n",(tpce_td & 0x1C)>>2, *bp); 
+//        diag_printf("READY = %x.%x\n",(tpce_td & 0x1C)>>2, *bp);
         bp++;
     }
     if ((tpce_td & 0x03) != 0x03) {
-//        diag_printf("WAIT = %x.%x\n",(tpce_td & 0x03)>>0, *bp); 
+//        diag_printf("WAIT = %x.%x\n",(tpce_td & 0x03)>>0, *bp);
         bp++;
     }
     *buf = bp;
 }
 
@@ -159,11 +161,11 @@
                 break;
             case 2:
                 base = (bp[1] << 8) | bp[0];
                 bp += 2;
                 break;
-            case 3:                
+            case 3:
                 base = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0];
                 bp += 4;
                 break;
             }
             io_space->base[i] = base;
@@ -176,11 +178,11 @@
                 break;
             case 2:
                 length = (bp[1] << 8) | bp[0];
                 bp += 2;
                 break;
-            case 3:                
+            case 3:
                 length = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0];
                 bp += 4;
                 break;
             }
             length++;
@@ -282,18 +284,30 @@
 }
 
 //
 // Register an interrupt handler
 //
-void 
-cf_register_handler(struct cf_slot *slot, 
-                    void (*handler)(int, int, void *), 
+void
+cf_register_handler(struct cf_slot *slot,
+                    void (*handler)(int, int, void *),
                     void *param)
 {
     slot->irq_handler.handler = handler;
     slot->irq_handler.param = param;
-}
+    cf_hwr_interrupt_enable(slot);
+} /* cf_register_handler */
+
+//
+// Remove and disable an interrupt handler
+//
+void
+cf_remove_handler(struct cf_slot *slot)
+{
+    cf_hwr_interrupt_disable(slot);
+    slot->irq_handler.handler = NULL;
+    slot->irq_handler.param = 0;
+} /* cf_remove_handler */
 
 //
 // Allow interrupt function to acknowledge interrupt
 //
 void

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]