URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/ecos-2.0/packages/io/pcmcia
- from Rev 1254 to Rev 1765
- ↔ Reverse comparison
Rev 1254 → Rev 1765
/v2_0/cdl/io_pcmcia.cdl
0,0 → 1,75
# ==================================================================== |
# |
# io_pcmcia.cdl |
# |
# eCos IO configuration data |
# |
# ==================================================================== |
#####ECOSGPLCOPYRIGHTBEGIN#### |
## ------------------------------------------- |
## This file is part of eCos, the Embedded Configurable Operating System. |
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
## |
## eCos is free software; you can redistribute it and/or modify it under |
## the terms of the GNU General Public License as published by the Free |
## Software Foundation; either version 2 or (at your option) any later version. |
## |
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
## for more details. |
## |
## You should have received a copy of the GNU General Public License along |
## with eCos; if not, write to the Free Software Foundation, Inc., |
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
## |
## As a special exception, if other files instantiate templates or use macros |
## or inline functions from this file, or you compile this file and link it |
## with other works to produce a work based on this file, this file does not |
## by itself cause the resulting work to be covered by the GNU General Public |
## License. However the source code for this file must still be made available |
## in accordance with section (3) of the GNU General Public License. |
## |
## This exception does not invalidate any other reasons why a work based on |
## this file might be covered by the GNU General Public License. |
## |
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
## at http://sources.redhat.com/ecos/ecos-license/ |
## ------------------------------------------- |
#####ECOSGPLCOPYRIGHTEND#### |
# ==================================================================== |
######DESCRIPTIONBEGIN#### |
# |
# Author(s): gthomas |
# Original data: gthomas |
# Contributors: |
# Date: 2000-07-06 |
# |
#####DESCRIPTIONEND#### |
# |
# ==================================================================== |
|
cdl_package CYGPKG_IO_PCMCIA { |
display "PCMCIA device drivers" |
include_dir cyg/io |
description " |
This option enables drivers for basic I/O services on |
pcmcia devices." |
doc ref/io.html |
|
compile pcmcia.c |
|
define_proc { |
puts $::cdl_header "#include <pkgconf/system.h>" |
puts $::cdl_header "#ifdef CYGDAT_IO_PCMCIA_DEVICE_HEADER" |
puts $::cdl_header "# include CYGDAT_IO_PCMCIA_DEVICE_HEADER" |
puts $::cdl_header "#endif " |
} |
|
cdl_interface CYGHWR_IO_PCMCIA_DEVICE { |
display "Hardware PCMCIA device drivers" |
description " |
This option enables the hardware device drivers |
for the current platform." |
} |
} |
/v2_0/include/pcmcia.h
0,0 → 1,133
#ifndef CYGONCE_PCMCIA_H |
#define CYGONCE_PCMCIA_H |
// ==================================================================== |
// |
// pcmcia.h |
// |
// Device I/O |
// |
// ==================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
// ==================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-06 |
// Purpose: Interfaces for PCMCIA I/O drivers |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
// ==================================================================== |
|
// PCMCIA I/O interfaces |
|
#include <pkgconf/system.h> |
#include <pkgconf/io_pcmcia.h> |
|
#include <cyg/infra/cyg_type.h> |
#include <cyg/hal/drv_api.h> |
|
struct cf_irq_handler { |
void (*handler)(int, int, void *); |
void *param; |
}; |
|
// Basic information about a slot/device |
struct cf_slot { |
int index; // In case hardware layer needs it |
int state; |
unsigned char *attr; |
int attr_length; |
unsigned char *io; |
int io_length; |
unsigned char *mem; |
int mem_length; |
int int_num; // Hardware interrupt number |
struct cf_irq_handler irq_handler; |
}; |
|
#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_MAX_IO_ADDRS 8 |
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; |
}; |
|
// Corresponds to CISTPL_CFTABLE_ENTRY |
struct cf_cftable { |
unsigned char cor; // Value to write to COR register |
unsigned char interface; |
unsigned char feature_select; |
struct cf_io_space io_space; |
}; |
|
// Corresponds to CISTPL_CONFIG |
struct cf_config { |
unsigned long base; |
int mask_length; |
unsigned char mask[16]; |
}; |
|
// Function prototypes |
|
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_clear_interrupt(struct cf_slot *); |
void cf_init(void); |
|
void cf_hwr_poll(struct cf_slot *); |
|
#endif // CYGONCE_PCMCIA_H |
/v2_0/ChangeLog
0,0 → 1,71
2003-02-24 Jonathan Larmour <jifl@eCosCentric.com> |
|
* cdl/io_pcmcia.cdl: Fix doc link. |
|
2002-04-12 Gary Thomas <gthomas@redhat.com> |
|
* include/pcmcia.h: Add prototype(s) to remove warnings. |
|
2000-09-17 Gary Thomas <gthomas@redhat.com> |
|
* include/pcmcia.h: |
* src/pcmcia.c (cf_register_handler): Interrupt handler must look |
just like a DSR and will be called using the same calling conventions. |
|
2000-08-23 Gary Thomas <gthomas@redhat.com> |
|
* src/pcmcia.c: |
* include/pcmcia.h: Export new function to forceably clear interrupts |
on a card [slot]. Use in non-kernel environments. |
|
2000-07-16 Gary Thomas <gthomas@redhat.com> |
|
* cdl/io_pcmcia.cdl: |
* include/pcmcia.h: |
* src/pcmcia.c: Remove dependency on generic I/O package. |
|
2000-07-15 Gary Thomas <gthomas@redhat.com> |
|
* include/pcmcia.h: |
* src/pcmcia.c: Change notion of interrupts to be slot oriented. |
This fits with more hardware. Now need to "register" an IRQ |
handler when initializing a card device. |
|
2000-07-11 Gary Thomas <gthomas@redhat.com> |
|
* src/pcmcia.c: Remove noisy messages. |
|
//=========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//=========================================================================== |
/v2_0/src/pcmcia.c
0,0 → 1,304
//========================================================================== |
// |
// io/pcmcia/pcmcia.c |
// |
// PCMCIA support (Card Services) |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-06 |
// Purpose: PCMCIA support |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include <pkgconf/io_pcmcia.h> |
|
#include <cyg/io/pcmcia.h> |
#include <cyg/infra/diag.h> |
|
#if CYGHWR_IO_PCMCIA_DEVICE == 0 |
#error Need hardware package for PCMCIA support |
#endif |
|
#define CF_NUM_SLOTS CYGHWR_IO_PCMCIA_DEVICE |
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_clear_interrupt(struct cf_slot *slot); |
|
bool |
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) { |
break; |
} |
if (*cis == id) { |
size = *(cis+2) + 2; |
for (i = 0; i < size; i++) { |
*buf++ = *cis; |
cis += 2; |
} |
*len = size; |
*ptr = (unsigned long)(cis - slot->attr); |
return true; |
} else { |
// Skip to next entry |
cis += (*(cis+2) * 2) + 4; |
} |
} |
return false; |
} |
|
void |
cf_set_COR(struct cf_slot *slot, unsigned long cor, unsigned char val) |
{ |
volatile unsigned char *cfg = slot->attr; |
cfg[cor] = val; |
} |
|
static void |
cf_parse_power_structure(unsigned char **buf) |
{ |
unsigned char *bp = *buf; |
unsigned char tpce_pd = *bp++; |
unsigned char settings; |
int indx; |
for (indx = 6; indx >= 0; indx--) { |
if (tpce_pd & (1<<indx)) { |
settings = *bp++; // main value |
if (settings & 0x80) { |
bp++; // extension byte - FIXME |
} |
} |
} |
*buf = bp; |
} |
|
static void |
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); |
bp++; |
} |
if ((tpce_td & 0x03) != 0x03) { |
// diag_printf("WAIT = %x.%x\n",(tpce_td & 0x03)>>0, *bp); |
bp++; |
} |
*buf = bp; |
} |
|
static void |
cf_parse_IO_space_structure(unsigned char **buf, struct cf_io_space *io_space) |
{ |
unsigned char *bp = *buf; |
unsigned char tpce_io = *bp++; |
unsigned char rd; |
unsigned long base = 0, length = 0; |
int i; |
io_space->mode = (tpce_io & 0x60) >> 5; |
if (tpce_io & 0x80) { |
rd = *bp++; |
io_space->num_addrs = (rd & 0x0F) + 1; |
for (i = 0; i < io_space->num_addrs; i++) { |
// Address |
switch ((rd & 0x30) >> 4) { |
case 0: |
break; // Not present (shouldn't happen) |
case 1: |
base = *bp++; |
break; |
case 2: |
base = (bp[1] << 8) | bp[0]; |
bp += 2; |
break; |
case 3: |
base = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0]; |
bp += 4; |
break; |
} |
io_space->base[i] = base; |
// Length |
switch ((rd & 0xC0) >> 6) { |
case 0: |
break; // Not present (shouldn't happen) |
case 1: |
length = *bp++; |
break; |
case 2: |
length = (bp[1] << 8) | bp[0]; |
bp += 2; |
break; |
case 3: |
length = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0]; |
bp += 4; |
break; |
} |
length++; |
io_space->size[i] = length; |
// diag_printf("IO addr %d - base: %x, length: %x\n", i, base, length); |
} |
} |
*buf = bp; |
} |
|
bool |
cf_parse_cftable(unsigned char *buf, int len, struct cf_cftable *cftable) |
{ |
unsigned char tpce_indx, tpce_fs; |
if (*buf++ != CF_CISTPL_CFTABLE_ENTRY) { |
diag_printf("%s - called with invalid CIS: %x\n", __FUNCTION__, *--buf); |
return false; |
} |
buf++; // Skip length/link |
tpce_indx = *buf++; |
cftable->cor = tpce_indx & 0x3F; |
if (tpce_indx & 0x80) { |
cftable->interface = *buf++; |
} |
cftable->feature_select = tpce_fs = *buf++; |
if (tpce_fs & 0x01) { |
cf_parse_power_structure(&buf); |
} |
if (tpce_fs & 0x02) { |
cf_parse_power_structure(&buf); |
} |
if (tpce_fs & 0x04) { |
cf_parse_timing_structure(&buf); |
} |
if (tpce_fs & 0x08) { |
cf_parse_IO_space_structure(&buf, &cftable->io_space); |
} |
return true; |
} |
|
bool |
cf_parse_config(unsigned char *buf, int len, struct cf_config *config) |
{ |
unsigned char tpcc_sz; |
int i; |
if (*buf++ != CF_CISTPL_CONFIG) { |
diag_printf("%s - called with invalid CIS: %x\n", __FUNCTION__, *--buf); |
return false; |
} |
buf++; // Skip length/link |
tpcc_sz = *buf++; |
buf++; // Skip 'last' pointer |
config->base = 0; |
for (i = (tpcc_sz & 0x03); i >= 0; i--) { |
config->base = (config->base << 8) | buf[i]; |
} |
buf += (tpcc_sz & 0x03) + 1; |
config->mask_length = ((tpcc_sz & 0x3C) >> 2) + 1; |
for (i = 0; i < config->mask_length; i++) { |
config->mask[i] = *buf++; |
} |
return true; |
} |
|
// |
// Return a pointer to the slot descriptor for a given slot |
// |
struct cf_slot * |
cf_get_slot(int indx) |
{ |
if ((indx >= 0) && (indx < CF_NUM_SLOTS)) { |
return &cf_slots[indx]; |
} else { |
diag_printf("PCMCIA: Invalid slot %d\n", indx); |
return (struct cf_slot *)0; |
} |
} |
|
// |
// Initialize all PCMCIA (Compact Flash) slots |
// |
void |
cf_init(void) |
{ |
int i; |
for (i = 0; i < CF_NUM_SLOTS; i++) { |
cf_slots[i].index = i; |
cf_hwr_init(&cf_slots[i]); |
} |
} |
|
// |
// Transition a card/slot |
// |
void |
cf_change_state(struct cf_slot *slot, int desired_state) |
{ |
cf_hwr_change_state(slot, desired_state); |
} |
|
// |
// Register an interrupt handler |
// |
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; |
} |
|
// |
// Allow interrupt function to acknowledge interrupt |
// |
void |
cf_clear_interrupt(struct cf_slot *slot) |
{ |
cf_hwr_clear_interrupt(slot); |
} |
|