diff options
Diffstat (limited to 'mdk-stage1/pcmcia')
26 files changed, 1220 insertions, 4586 deletions
diff --git a/mdk-stage1/pcmcia/Makefile b/mdk-stage1/pcmcia/Makefile index e2e670146..6b8bf0cb8 100644 --- a/mdk-stage1/pcmcia/Makefile +++ b/mdk-stage1/pcmcia/Makefile @@ -1,8 +1,8 @@ #****************************************************************************** # - # Guillaume Cottenceau (gc@mandrakesoft.com) + # Guillaume Cottenceau (gc) # - # Copyright 2000 MandrakeSoft + # Copyright 2001 Mandriva # # This software may be freely redistributed under the terms of the GNU # public license. @@ -13,22 +13,40 @@ # #***************************************************************************** +# startup.c is based on pcmcia-socket-startup from pcmciautils-013 + top_dir = .. include $(top_dir)/Makefile.common +TARGET = libpcmcia.a +YFLAGS := -d -all: libpcmcia.a +all: $(TARGET) pcmcia_probe.o clean: - rm -f *.o libpcmcia.a + rm -f *.o $(TARGET) lex_config.c yacc_config.c yacc_config.h + +FLAGS = -D__linux__ -Wall -Werror -Wno-deprecated-declarations -Os -fomit-frame-pointer -pipe -c -I.. -D_DEFAULT_SOURCE +# (blino) make sure yynewerror and yyerrlab are uselessly used +FLAGS += -Dlint +LFLAGS += --nounput + + +OBJS = probe.o startup.o yacc_config.o lex_config.o + -FLAGS = -Wall -Werror -Os -fomit-frame-pointer -pipe -c -I.. +%.c %.h : %.y + $(YACC) $(YFLAGS) $< + mv y.tab.c $*.c + mv y.tab.h $*.h -libpcmcia.a: pcmcia_probe.o cardmgr.o lex_config.o yacc_config.o +$(TARGET): $(OBJS) yacc_config.h ar -cru $@ $^ ranlib $@ -.c.o: - gcc $(FLAGS) $(GLIBC_INCLUDES) $< +$(OBJS): %.o: %.c + gcc $(FLAGS) $(INCLUDES) -c $< -o $@ +pcmcia_probe.o: probe.c + gcc -fPIC $(FLAGS) $(INCLUDES) -c $< -o $@ diff --git a/mdk-stage1/pcmcia/bulkmem.h b/mdk-stage1/pcmcia/bulkmem.h index 1b0bcbd1e..7748d4432 100644 --- a/mdk-stage1/pcmcia/bulkmem.h +++ b/mdk-stage1/pcmcia/bulkmem.h @@ -1,7 +1,7 @@ /* * Definitions for bulk memory services * - * bulkmem.h 1.12 2000/06/12 21:55:41 + * bulkmem.h 1.13 2001/08/24 12:16:12 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -18,8 +18,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by diff --git a/mdk-stage1/pcmcia/cardmgr.c b/mdk-stage1/pcmcia/cardmgr.c deleted file mode 100644 index 1899d04b8..000000000 --- a/mdk-stage1/pcmcia/cardmgr.c +++ /dev/null @@ -1,805 +0,0 @@ -/* - * Guillaume Cottenceau (gc@mandrakesoft.com) - * - * Copyright 2000 MandrakeSoft - * - * This software may be freely redistributed under the terms of the GNU - * public license. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* Code comes from /anonymous@projects.sourceforge.net:/pub/pcmcia-cs/pcmcia-cs-3.1.23.tar.bz2 - * - * Licence of this code follows: - - PCMCIA Card Manager daemon - - cardmgr.c 1.150 2000/12/14 17:12:59 - - The contents of this file are subject to the Mozilla Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The initial developer of the original code is David A. Hinds - <dahinds@users.sourceforge.net>. Portions created by David A. Hinds - are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - - Alternatively, the contents of this file may be used under the - terms of the GNU Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the - above. If you wish to allow the use of your version of this file - only under the terms of the GPL and not to allow others to use - your version of this file under the MPL, indicate your decision - by deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the MPL or the GPL. - - */ - - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <signal.h> -#include <sys/time.h> -#include <sys/ioctl.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include <sys/utsname.h> -#include <sys/file.h> - -#include <pcmcia/version.h> -#include <pcmcia/config.h> -#include <pcmcia/cs_types.h> -#include <pcmcia/cs.h> -#include <pcmcia/cistpl.h> -#include <pcmcia/ds.h> - -#include "../log.h" -#include "modules.h" - -#include "cardmgr.h" -#include "pcmcia.h" - -/*====================================================================*/ - -typedef struct socket_info_t { - int fd; - int state; - card_info_t *card; - bind_info_t *bind[MAX_BINDINGS]; - mtd_ident_t *mtd[2*CISTPL_MAX_DEVICES]; -} socket_info_t; - -#define SOCKET_PRESENT 0x01 -#define SOCKET_READY 0x02 -#define SOCKET_BOUND 0x04 - -/* Linked list of resource adjustments */ -struct adjust_list_t *root_adjust = NULL; - -/* Linked list of device definitions */ -struct device_info_t *root_device = NULL; - -/* Special pointer to "anonymous" card definition */ -struct card_info_t *blank_card = NULL; - -/* Linked list of card definitions */ -struct card_info_t *root_card = NULL; - -/* Linked list of function definitions */ -struct card_info_t *root_func = NULL; - -/* Linked list of MTD definitions */ -struct mtd_ident_t *root_mtd = NULL; - -/* Default MTD */ -struct mtd_ident_t *default_mtd = NULL; - -static int sockets; -static struct socket_info_t socket[MAX_SOCKS]; - -static char *configpath = "/etc/pcmcia"; - -/* Default path for socket info table */ -static char *stabfile; - -/*====================================================================*/ - -static int major = 0; - -static int lookup_dev(char *name) -{ - FILE *f; - int n; - char s[32], t[32]; - - f = fopen("/proc/devices", "r"); - if (f == NULL) - return -errno; - while (fgets(s, 32, f) != NULL) { - if (sscanf(s, "%d %s", &n, t) == 2) - if (strcmp(name, t) == 0) - break; - } - fclose(f); - if (strcmp(name, t) == 0) - return n; - else - return -ENODEV; -} - -static int open_dev(dev_t dev, int mode) -{ - char *fn; - int fd; - if ((fn = tmpnam(NULL)) == NULL) - return -1; - if (mknod(fn, mode, dev) != 0) - return -1; - fd = open(fn, (mode&S_IWRITE) ? O_RDWR : O_RDONLY); - if (fd < 0) - fd = open(fn, O_NONBLOCK|((mode&S_IWRITE) ? O_RDWR : O_RDONLY)); - unlink(fn); - return fd; -} - -static int open_sock(int sock, int mode) -{ - dev_t dev = (major<<8) + sock; - return open_dev(dev, mode); -} - -/*====================================================================== - - xlate_scsi_name() is a sort-of-hack used to deduce the minor - device numbers of SCSI devices, from the information available to - the low-level driver. - -======================================================================*/ - - -#include <linux/major.h> -#include <scsi/scsi.h> - -static int xlate_scsi_name(bind_info_t *bind) -{ - int i, fd, mode, minor; - u_long arg[2], id1, id2; - - id1 = strtol(bind->name+3, NULL, 16); - if ((bind->major == SCSI_DISK0_MAJOR) || - (bind->major == SCSI_CDROM_MAJOR)) - mode = S_IREAD|S_IFBLK; - else - mode = S_IREAD|S_IFCHR; - - for (i = 0; i < 16; i++) { - minor = (bind->major == SCSI_DISK0_MAJOR) ? (i<<4) : i; - fd = open_dev((bind->major<<8)+minor, mode); - if (fd < 0) - continue; - if (ioctl(fd, SCSI_IOCTL_GET_IDLUN, arg) == 0) { - id2 = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) + - ((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000); - if (id1 == id2) { - close(fd); - switch (bind->major) { - case SCSI_DISK0_MAJOR: - case SCSI_GENERIC_MAJOR: - sprintf(bind->name+2, "%c", 'a'+i); break; - case SCSI_CDROM_MAJOR: - sprintf(bind->name, "scd%d", i); break; - case SCSI_TAPE_MAJOR: - sprintf(bind->name+2, "%d", i); break; - } - bind->minor = minor; - return 0; - } - } - close(fd); - } - return -1; -} - - -/*====================================================================*/ - -static void write_stab(void) -{ - int i, j, k; - FILE *f; - socket_info_t *s; - bind_info_t *bind; - - f = fopen(stabfile, "w"); - if (f == NULL) { - log_message("CM: fopen(stabfile) failed: %m"); - return; - } - if (flock(fileno(f), LOCK_EX) != 0) { - log_message("CM: flock(stabfile) failed: %m"); - return; - } - for (i = 0; i < sockets; i++) { - s = &socket[i]; - if (!(s->state & SOCKET_PRESENT)) - fprintf(f, "Socket %d: empty\n", i); - else if (!s->card) - fprintf(f, "Socket %d: unsupported card\n", i); - else { - fprintf(f, "Socket %d: %s\n", i, s->card->name); - for (j = 0; j < s->card->bindings; j++) - for (k = 0, bind = s->bind[j]; - bind != NULL; - k++, bind = bind->next) { - char *class = s->card->device[j]->class; - fprintf(f, "%d\t%s\t%s\t%d\t%s", - i, (class ? class : "none"), - bind->dev_info, k, bind->name); - if (bind->major) - fprintf(f, "\t%d\t%d\n", - bind->major, bind->minor); - else - fputc('\n', f); - } - } - } - fflush(f); - fclose(f); -} - -/*====================================================================*/ - -static int get_tuple(int ns, cisdata_t code, ds_ioctl_arg_t *arg) -{ - socket_info_t *s = &socket[ns]; - - arg->tuple.DesiredTuple = code; - arg->tuple.Attributes = 0; - if (ioctl(s->fd, DS_GET_FIRST_TUPLE, arg) != 0) - return -1; - arg->tuple.TupleOffset = 0; - if (ioctl(s->fd, DS_GET_TUPLE_DATA, arg) != 0) { - log_message("CM: error reading CIS data on socket %d: %m", ns); - return -1; - } - if (ioctl(s->fd, DS_PARSE_TUPLE, arg) != 0) { - log_message("CM: error parsing CIS on socket %d: %m", ns); - return -1; - } - return 0; -} - -/*====================================================================*/ - -typedef struct { - u_short vendor, device; -} pci_id_t; - - -static card_info_t *lookup_card(int ns) -{ - socket_info_t *s = &socket[ns]; - card_info_t *card = NULL; - ds_ioctl_arg_t arg; - cistpl_vers_1_t *vers = NULL; - cistpl_manfid_t manfid = { 0, 0 }; - pci_id_t pci_id = { 0, 0 }; - cistpl_funcid_t funcid = { 0xff, 0xff }; - cs_status_t status; - config_info_t config; - int i, ret, match; - int has_cis = 0; - - /* Do we have a CIS structure? */ - ret = ioctl(s->fd, DS_VALIDATE_CIS, &arg); - has_cis = ((ret == 0) && (arg.cisinfo.Chains > 0)); - - /* Try to read VERS_1, MANFID tuples */ - if (has_cis) { - /* rule of thumb: cards with no FUNCID, but with common memory - device geometry information, are probably memory cards */ - if (get_tuple(ns, CISTPL_FUNCID, &arg) == 0) - memcpy(&funcid, &arg.tuple_parse.parse.funcid, - sizeof(funcid)); - else if (get_tuple(ns, CISTPL_DEVICE_GEO, &arg) == 0) - funcid.func = CISTPL_FUNCID_MEMORY; - if (get_tuple(ns, CISTPL_MANFID, &arg) == 0) - memcpy(&manfid, &arg.tuple_parse.parse.manfid, - sizeof(manfid)); - if (get_tuple(ns, CISTPL_VERS_1, &arg) == 0) - vers = &arg.tuple_parse.parse.version_1; - - match = 0; - for (card = root_card; card; card = card->next) { - switch (card->ident_type) { - - case VERS_1_IDENT: - if (vers == NULL) - break; - for (i = 0; i < card->id.vers.ns; i++) { - if (strcmp(card->id.vers.pi[i], "*") == 0) - continue; - if (i >= vers->ns) - break; - if (strcmp(card->id.vers.pi[i], - vers->str+vers->ofs[i]) != 0) - break; - } - if (i < card->id.vers.ns) - break; - match = 1; - break; - - case MANFID_IDENT: - if ((manfid.manf == card->id.manfid.manf) && - (manfid.card == card->id.manfid.card)) - match = 1; - break; - - case TUPLE_IDENT: - arg.tuple.DesiredTuple = card->id.tuple.code; - arg.tuple.Attributes = 0; - ret = ioctl(s->fd, DS_GET_FIRST_TUPLE, &arg); - if (ret != 0) break; - arg.tuple.TupleOffset = card->id.tuple.ofs; - ret = ioctl(s->fd, DS_GET_TUPLE_DATA, &arg); - if (ret != 0) break; - if (strncmp((char *)arg.tuple_parse.data, - card->id.tuple.info, - strlen(card->id.tuple.info)) != 0) - break; - match = 1; - break; - - default: - /* Skip */ - break; - } - if (match) break; - } - } - - /* Check PCI vendor/device info */ - status.Function = config.Function = config.ConfigBase = 0; - if ((ioctl(s->fd, DS_GET_CONFIGURATION_INFO, &config) == 0) && - (config.IntType == INT_CARDBUS)) { - pci_id.vendor = config.ConfigBase & 0xffff; - pci_id.device = config.ConfigBase >> 16; - if (!card) { - for (card = root_card; card; card = card->next) - if ((card->ident_type == PCI_IDENT) && - (pci_id.vendor == card->id.manfid.manf) && - (pci_id.device == card->id.manfid.card)) - break; - } - } - - /* Try for a FUNCID match */ - if (!card && (funcid.func != 0xff)) { - for (card = root_func; card; card = card->next) - if (card->id.func.funcid == funcid.func) - break; - } - - if (card) { - log_message("CM: socket %d: %s", ns, card->name); - return card; - } - - status.Function = 0; - if (!blank_card || (status.CardState & CS_EVENT_CB_DETECT) || - manfid.manf || manfid.card || pci_id.vendor || vers) { - log_message("CM: unsupported card in socket %d", ns); - return NULL; - } else { - card = blank_card; - log_message("CM: socket %d: %s", ns, card->name); - return card; - } -} - - -static void cardmgr_fail(void) -{ - log_message("CM: cardmgr: failed"); -} - -/*====================================================================*/ - -static int load_config(void) -{ - if (chdir(configpath)) { - log_message("CM: chdir to %s failed: %m", configpath); - return -1; - } - - if (parse_configfile("config")) - return -1; - - if (!root_device) - log_message("CM: no device drivers defined"); - - if (!root_card && !root_func) - log_message("CM: no cards defined"); - - return 0; -} - - -/*====================================================================*/ - -static void install_module(char *mod, char *opts) -{ - my_insmod(mod, ANY_DRIVER_TYPE, opts); -} - -/*====================================================================*/ - -static mtd_ident_t *lookup_mtd(region_info_t *region) -{ - mtd_ident_t *mtd; - int match = 0; - - for (mtd = root_mtd; mtd; mtd = mtd->next) { - switch (mtd->mtd_type) { - case JEDEC_MTD: - if ((mtd->jedec_mfr == region->JedecMfr) && - (mtd->jedec_info == region->JedecInfo)) { - match = 1; - break; - } - case DTYPE_MTD: - break; - default: - break; - } - if (match) break; - } - if (mtd) - return mtd; - else - return default_mtd; -} - -/*====================================================================*/ - -static void bind_mtd(int sn) -{ - socket_info_t *s = &socket[sn]; - region_info_t region; - bind_info_t bind; - mtd_info_t mtd_info; - mtd_ident_t *mtd; - int i, attr, ret, nr; - - nr = 0; - for (attr = 0; attr < 2; attr++) { - region.Attributes = attr; - ret = ioctl(s->fd, DS_GET_FIRST_REGION, ®ion); - while (ret == 0) { - mtd = lookup_mtd(®ion); - if (mtd) { - /* Have we seen this MTD before? */ - for (i = 0; i < nr; i++) - if (s->mtd[i] == mtd) break; - if (i == nr) { - install_module(mtd->module, mtd->opts); - s->mtd[nr] = mtd; - mtd->refs++; - nr++; - } - log_message("CM: %s memory region at 0x%lx: %s", - attr ? "Attribute" : "Common", (long unsigned int) region.CardOffset, - mtd->name); - /* Bind MTD to this region */ - strcpy(mtd_info.dev_info, s->mtd[i]->module); - mtd_info.Attributes = region.Attributes; - mtd_info.CardOffset = region.CardOffset; - if (ioctl(s->fd, DS_BIND_MTD, &mtd_info) != 0) { - log_message( "bind MTD '%s' to region at 0x%lx failed: %m", - (char *)mtd_info.dev_info, (long unsigned int) region.CardOffset); - } - } - ret = ioctl(s->fd, DS_GET_NEXT_REGION, ®ion); - } - } - s->mtd[nr] = NULL; - - /* Now bind each unique MTD as a normal client of this socket */ - for (i = 0; i < nr; i++) { - strcpy(bind.dev_info, s->mtd[i]->module); - bind.function = 0; - if (ioctl(s->fd, DS_BIND_REQUEST, &bind) != 0) - log_message("CM: bind MTD '%s' to socket %d failed: %m", - (char *)bind.dev_info, sn); - } -} - -/*====================================================================*/ - -static void update_cis(socket_info_t *s) -{ - cisdump_t cis; - FILE *f = fopen(s->card->cis_file, "r"); - if (f == NULL) - log_message("CM: could not open '%s': %m", s->card->cis_file); - else { - cis.Length = fread(cis.Data, 1, CISTPL_MAX_CIS_SIZE, f); - fclose(f); - if (ioctl(s->fd, DS_REPLACE_CIS, &cis) != 0) - log_message("CM: could not replace CIS: %m"); - } -} - -/*====================================================================*/ - -static void do_insert(int sn) -{ - socket_info_t *s = &socket[sn]; - card_info_t *card; - device_info_t **dev; - bind_info_t *bind, **tail; - int i, j, ret; - - /* Already identified? */ - if (s->card && (s->card != blank_card)) - return; - - log_message("CM: initializing socket %d", sn); - card = lookup_card(sn); - /* Make sure we've learned something new before continuing */ - if (card == s->card) - return; - s->card = card; - card->refs++; - if (card->cis_file) - update_cis(s); - - dev = card->device; - - /* Set up MTD's */ - for (i = 0; i < card->bindings; i++) - if (dev[i]->needs_mtd) - break; - - if (i < card->bindings) - bind_mtd(sn); - - /* Install kernel modules */ - for (i = 0; i < card->bindings; i++) { - dev[i]->refs++; - for (j = 0; j < dev[i]->modules; j++) - install_module(dev[i]->module[j], dev[i]->opts[j]); - } - - /* Bind drivers by their dev_info identifiers */ - for (i = 0; i < card->bindings; i++) { - bind = calloc(1, sizeof(bind_info_t)); - strcpy((char *)bind->dev_info, (char *)dev[i]->dev_info); - if (strcmp(bind->dev_info, "cb_enabler") == 0) - bind->function = BIND_FN_ALL; - else - bind->function = card->dev_fn[i]; - if (ioctl(s->fd, DS_BIND_REQUEST, bind) != 0) { - if (errno == EBUSY) { - log_message("CM: '%s' already bound to socket %d", - (char *)bind->dev_info, sn); - } else { - log_message("CM: bind '%s' to socket %d failed: %m", - (char *)bind->dev_info, sn); - write_stab(); - return; - } - } - - for (ret = j = 0; j < 10; j++) { - ret = ioctl(s->fd, DS_GET_DEVICE_INFO, bind); - if ((ret == 0) || (errno != EAGAIN)) - break; - usleep(100000); - } - if (ret != 0) { - log_message("CM: get dev info on socket %d failed: %m", - sn); - ioctl(s->fd, DS_UNBIND_REQUEST, bind); - write_stab(); - return; - } - tail = &s->bind[i]; - while (ret == 0) { - bind_info_t *old; - if ((strlen(bind->name) > 3) && (bind->name[2] == '#')) - xlate_scsi_name(bind); - old = *tail = bind; tail = (bind_info_t **)&bind->next; - bind = (bind_info_t *)malloc(sizeof(bind_info_t)); - memcpy(bind, old, sizeof(bind_info_t)); - ret = ioctl(s->fd, DS_GET_NEXT_DEVICE, bind); - } - *tail = NULL; free(bind); - write_stab(); - } -} - -/*====================================================================*/ - -static void wait_for_pending(void) -{ - cs_status_t status; - int i; - status.Function = 0; - for (;;) { - usleep(100000); - for (i = 0; i < sockets; i++) - if ((ioctl(socket[i].fd, DS_GET_STATUS, &status) == 0) && (status.CardState & CS_EVENT_CARD_INSERTION)) - break; - if (i == sockets) - break; - } -} - -/*====================================================================*/ - -static void adjust_resources(void) -{ - adjust_list_t *al; - int ret; - char tmp[64]; - int fd = socket[0].fd; - - for (al = root_adjust; al; al = al->next) { - ret = ioctl(fd, DS_ADJUST_RESOURCE_INFO, &al->adj); - if (ret != 0) { - switch (al->adj.Resource) { - case RES_MEMORY_RANGE: - sprintf(tmp, "memory %#lx-%#lx", - al->adj.resource.memory.Base, - al->adj.resource.memory.Base + - al->adj.resource.memory.Size - 1); - break; - case RES_IO_RANGE: - sprintf(tmp, "IO ports %#x-%#x", - al->adj.resource.io.BasePort, - al->adj.resource.io.BasePort + - al->adj.resource.io.NumPorts - 1); - break; - case RES_IRQ: - sprintf(tmp, "irq %u", al->adj.resource.irq.IRQ); - break; - } - log_message("CM: could not adjust resource: %s: %m", tmp); - } - } -} - -/*====================================================================*/ - -static int init_sockets(void) -{ - int fd, i; - servinfo_t serv; - - major = lookup_dev("pcmcia"); - if (major < 0) { - if (major == -ENODEV) - log_message("CM: no pcmcia driver in /proc/devices"); - else - log_message("CM: could not open /proc/devices: %m"); - return -1; - } - - for (fd = -1, i = 0; i < MAX_SOCKS; i++) { - fd = open_sock(i, S_IFCHR|S_IREAD|S_IWRITE); - if (fd < 0) - break; - socket[i].fd = fd; - socket[i].state = 0; - } - - if ((fd < 0) && (errno != ENODEV) && (errno != ENOENT)) - log_message("CM: open_sock(socket %d) failed: %m", i); - sockets = i; - if (sockets == 0) { - log_message("CM: no sockets found!"); - return -1; - } else - log_message("CM: found %d sockets", sockets); - - if (ioctl(socket[0].fd, DS_GET_CARD_SERVICES_INFO, &serv) == 0) { - if (serv.Revision != CS_RELEASE_CODE) - log_message("CM: warning, Card Services release does not match kernel"); - } else { - log_message("CM: could not get CS revision info!"); - return -1; - } - adjust_resources(); - return 0; -} - -/*====================================================================*/ - -int cardmgr_call(void) -{ - int i, max_fd, ret, event; - struct timeval tv; - fd_set fds; - - stabfile = "/var/run/stab"; - - log_message("CM: cardmgr/hacked starting, version is " CS_RELEASE); - - if (load_config()) { - cardmgr_fail(); - return -1; - } - - if (init_sockets()) { - cardmgr_fail(); - return -1; - } - - /* If we've gotten this far, then clean up pid and stab at exit */ - write_stab(); - - for (i = max_fd = 0; i < sockets; i++) - max_fd = (socket[i].fd > max_fd) ? socket[i].fd : max_fd; - - /* First select() call: poll, don't wait */ - tv.tv_sec = tv.tv_usec = 0; - - /* Wait for sockets in setup-pending state to settle */ - wait_for_pending(); - - - FD_ZERO(&fds); - for (i = 0; i < sockets; i++) - FD_SET(socket[i].fd, &fds); - - if (select(max_fd+1, &fds, NULL, NULL, &tv) < 0) { - log_perror("CM: select fails"); - return -1; - } - - for (i = 0; i < sockets; i++) { - if (!FD_ISSET(socket[i].fd, &fds)) - continue; - ret = read(socket[i].fd, &event, 4); - if ((ret == -1) && (errno != EAGAIN)) - log_message("CM: read(%d): %m\n", i); - if (ret != 4) - continue; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - case CS_EVENT_INSERTION_REQUEST: - socket[i].state |= SOCKET_PRESENT; - case CS_EVENT_CARD_RESET: - socket[i].state |= SOCKET_READY; - do_insert(i); - break; - case CS_EVENT_RESET_PHYSICAL: - socket[i].state &= ~SOCKET_READY; - break; - } - - } - - return 0; - -} diff --git a/mdk-stage1/pcmcia/cardmgr.h b/mdk-stage1/pcmcia/cardmgr.h deleted file mode 100644 index fe04044e5..000000000 --- a/mdk-stage1/pcmcia/cardmgr.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * cardmgr.h 1.35 2000/06/12 21:33:03 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License - * at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and - * limitations under the License. - * - * The initial developer of the original code is David A. Hinds - * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the - * above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use - * your version of this file under the MPL, indicate your decision by - * deleting the provisions above and replace them with the notice and - * other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file - * under either the MPL or the GPL. - */ - -#define MAX_SOCKS 8 -#define MAX_BINDINGS 4 -#define MAX_MODULES 4 - -typedef struct adjust_list_t { - adjust_t adj; - struct adjust_list_t *next; -} adjust_list_t; - -typedef struct func_ident_t { - u_char funcid; -} func_ident_t; - -typedef struct manfid_ident_t { - u_short manf; - u_short card; -} manfid_ident_t; - -typedef struct vers_ident_t { - int ns; - char *pi[4]; -} vers_ident_t; - -typedef struct tuple_ident_t { - cisdata_t code; - long ofs; - char *info; -} tuple_ident_t; - -typedef struct device_info_t { - dev_info_t dev_info; - int needs_mtd; - int modules; - char *module[MAX_MODULES]; - char *opts[MAX_MODULES]; - char *class; - int refs; - struct device_info_t *next; -} device_info_t; - -typedef struct card_info_t { - char *name; - enum { - VERS_1_IDENT=1, MANFID_IDENT, TUPLE_IDENT, FUNC_IDENT, - BLANK_IDENT, PCI_IDENT - } ident_type; - union { - vers_ident_t vers; - manfid_ident_t manfid; - tuple_ident_t tuple; - func_ident_t func; - } id; - int bindings; - device_info_t *device[MAX_BINDINGS]; - int dev_fn[MAX_BINDINGS]; - char *cis_file; - int refs; - struct card_info_t *next; -} card_info_t; - -typedef struct mtd_ident_t { - char *name; - enum { - JEDEC_MTD=1, DTYPE_MTD, DEFAULT_MTD - } mtd_type; - int dtype, jedec_mfr, jedec_info; - char *module, *opts; - int refs; - struct mtd_ident_t *next; -} mtd_ident_t; - -extern adjust_list_t *root_adjust; -extern device_info_t *root_device; -extern card_info_t *blank_card; -extern card_info_t *root_card, *root_func; -extern mtd_ident_t *root_mtd, *default_mtd; - -int parse_configfile(char *fn); diff --git a/mdk-stage1/pcmcia/cirrus.h b/mdk-stage1/pcmcia/cirrus.h index b7aad5894..78f73b26d 100644 --- a/mdk-stage1/pcmcia/cirrus.h +++ b/mdk-stage1/pcmcia/cirrus.h @@ -1,5 +1,5 @@ /* - * cirrus.h 1.9 2000/06/12 21:29:37 + * cirrus.h 1.10 2001/08/24 12:15:33 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -48,11 +48,6 @@ #define PD67_EXT_INDEX 0x2e /* Extension index */ #define PD67_EXT_DATA 0x2f /* Extension data */ -#define pd67_ext_get(s, r) \ - (i365_set(s, PD67_EXT_INDEX, r), i365_get(s, PD67_EXT_DATA)) -#define pd67_ext_set(s, r, v) \ - (i365_set(s, PD67_EXT_INDEX, r), i365_set(s, PD67_EXT_DATA, v)) - /* PD6722 extension registers -- indexed in PD67_EXT_INDEX */ #define PD67_DATA_MASK0 0x01 /* Data mask 0 */ #define PD67_DATA_MASK1 0x02 /* Data mask 1 */ @@ -125,10 +120,6 @@ #define PD67_EC1_INV_MGMT_IRQ 0x10 #define PD67_EC1_PULLUP_CTL 0x20 -/* Fields in PD67_EXTERN_DATA */ -#define PD67_EXD_VS1(s) (0x01 << ((s)<<1)) -#define PD67_EXD_VS2(s) (0x02 << ((s)<<1)) - /* Fields in PD67_MISC_CTL_3 */ #define PD67_MC3_IRQ_MASK 0x03 #define PD67_MC3_IRQ_PCPCI 0x00 @@ -163,20 +154,4 @@ /* Socket Number Register */ #define PD6832_SOCKET_NUMBER 0x004c /* 8 bit */ -/* Data structure for tracking vendor-specific state */ -typedef struct cirrus_state_t { - u_char misc1; /* PD67_MISC_CTL_1 */ - u_char misc2; /* PD67_MISC_CTL_2 */ - u_char ectl1; /* PD67_EXT_CTL_1 */ - u_char timer[6]; /* PD67_TIME_* */ -} cirrus_state_t; - -#define CIRRUS_PCIC_ID \ - IS_PD6729, IS_PD6730, IS_PD6832 - -#define CIRRUS_PCIC_INFO \ - { "Cirrus PD6729", IS_CIRRUS|IS_PCI, ID(CIRRUS, 6729) }, \ - { "Cirrus PD6730", IS_CIRRUS|IS_PCI, PCI_VENDOR_ID_CIRRUS, -1 }, \ - { "Cirrus PD6832", IS_CIRRUS|IS_CARDBUS, ID(CIRRUS, 6832) } - #endif /* _LINUX_CIRRUS_H */ diff --git a/mdk-stage1/pcmcia/cistpl.h b/mdk-stage1/pcmcia/cistpl.h index a4b16a6e4..1d4cac20e 100644 --- a/mdk-stage1/pcmcia/cistpl.h +++ b/mdk-stage1/pcmcia/cistpl.h @@ -1,5 +1,5 @@ /* - * cistpl.h 1.34 2000/06/19 23:18:12 + * cistpl.h 1.35 2001/08/24 12:16:12 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by diff --git a/mdk-stage1/pcmcia/config.h b/mdk-stage1/pcmcia/config.h deleted file mode 100644 index 4ad8fe81a..000000000 --- a/mdk-stage1/pcmcia/config.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Automatically generated by 'make config' -- don't edit! -*/ -#ifndef _PCMCIA_CONFIG_H -#define _PCMCIA_CONFIG_H - -#define AUTOCONF_INCLUDED -#define __IN_PCMCIA_PACKAGE__ - -#define LINUX "/home/gc/rpm/BUILD/linux" -#define PREFIX "/home/gc/rpm/tmp/kernel-2.4.0-build" -#define CC "/usr/bin/kgcc" -#define LD "ld" -#define KFLAGS "" -#define UFLAGS "" -#define PCDEBUG "" -#define USE_PM 1 -#define UNSAFE_TOOLS 1 -#define CONFIG_CARDBUS 1 -#undef CONFIG_PNP_BIOS -#define MODDIR "/lib/modules/2.4.0-6mdk" - -/* Options from /home/gc/rpm/BUILD/linux/.config */ -#define CONFIG_MODULES 1 -#undef CONFIG_PCMCIA -#undef CONFIG_SMP -#define CONFIG_PCI 1 -#define CONFIG_PCI_QUIRKS 1 -#define CONFIG_PM 1 -#define CONFIG_SCSI 1 -#define CONFIG_IEEE1394 1 -#define CONFIG_INET 1 -#define CONFIG_NET_PCMCIA_RADIO 1 -#define CONFIG_TR 1 -#undef CONFIG_NET_FASTROUTE -#undef CONFIG_NET_DIVERT -#define CONFIG_MODVERSIONS 1 -#define CONFIG_X86_L1_CACHE_BYTES 32 -#define CONFIG_X86_L1_CACHE_SHIFT 5 -#define CONFIG_PROC_FS 1 -#define ARCH "i386" -#define HOST_ARCH "i386" -#define AFLAGS "" -#define CONFIG_ISA 1 -#define CONFIG_UID16 1 - -#define UTS_RELEASE "2.4.0-6mdk" -#define UTS_VERSION "#1 Wed Jan 24 16:10:16 CET 2001" -#define LINUX_VERSION_CODE 132096 -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) - -#define HAS_PROC_BUS 1 -#define SYSV_INIT 1 -#define RC_DIR "/etc/rc.d" -#undef HAS_FORMS -#define MANDIR "/usr/share/man" -#define XMANDIR "/usr/X11R6/man" - -#endif /* _PCMCIA_CONFIG_H */ diff --git a/mdk-stage1/pcmcia/cs.h b/mdk-stage1/pcmcia/cs.h index be6f92d65..9abeac216 100644 --- a/mdk-stage1/pcmcia/cs.h +++ b/mdk-stage1/pcmcia/cs.h @@ -1,5 +1,5 @@ /* - * cs.h 1.71 2000/08/29 00:54:20 + * cs.h 1.73 2001/08/24 12:16:12 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -49,8 +49,8 @@ typedef struct adjust_t { u_int Attributes; union { struct memory { - u_long Base; - u_long Size; + unsigned long Base; + unsigned long Size; } memory; struct io { ioaddr_t BasePort; @@ -181,6 +181,7 @@ typedef struct config_req_t { #define INT_MEMORY 0x01 #define INT_MEMORY_AND_IO 0x02 #define INT_CARDBUS 0x04 +#define INT_ZOOMED_VIDEO 0x08 /* For RequestIO and ReleaseIO */ typedef struct io_req_t { @@ -266,7 +267,7 @@ typedef struct modwin_t { /* For RequestWindow */ typedef struct win_req_t { u_int Attributes; - u_long Base; + unsigned long Base; u_int Size; u_int AccessSpeed; } win_req_t; @@ -397,14 +398,6 @@ typedef struct mtd_bind_t { #ifdef __KERNEL__ /* - * Calls to set up low-level "Socket Services" drivers - */ - -typedef int (*ss_entry_t)(u_int sock, u_int cmd, void *arg); -extern int register_ss_entry(int nsock, ss_entry_t entry); -extern void unregister_ss_entry(ss_entry_t entry); - -/* * The main Card Services entry point */ @@ -435,30 +428,6 @@ extern int CardServices(int func, void *a1, void *a2, void *a3); extern int CardServices(int func, ...); #endif -#ifdef __BEOS__ -#define SS_MODULE_NAME(s) ("busses/pcmcia/" s "/v1") -#define MTD_MODULE_NAME(s) ("busses/pcmcia/" s "/v1") -#define CS_CLIENT_MODULE_NAME "bus_managers/pcmcia_cs/client/v1" -typedef struct cs_client_module_info { - bus_manager_info binfo; - int (*_CardServices)(int, ...); - int (*_MTDHelperEntry)(int, ...); - void (*_add_timer)(struct timer_list *); - void (*_del_timer)(struct timer_list *); -} cs_client_module_info; -#define CS_SOCKET_MODULE_NAME "bus_managers/pcmcia_cs/socket/v1" -typedef struct cs_socket_module_info { - bus_manager_info binfo; - int (*_register_ss_entry)(int, ss_entry_t); - void (*_unregister_ss_entry)(ss_entry_t); - void (*_add_timer)(struct timer_list *); - void (*_del_timer)(struct timer_list *); - int (*register_resource)(int, u_long, u_long); - int (*release_resource)(int, u_long, u_long); - int (*check_resource)(int, u_long, u_long); -} cs_socket_module_info; -#endif - #endif /* __KERNEL__ */ #endif /* _LINUX_CS_H */ diff --git a/mdk-stage1/pcmcia/cs_types.h b/mdk-stage1/pcmcia/cs_types.h index 40cf84b51..4598d7f48 100644 --- a/mdk-stage1/pcmcia/cs_types.h +++ b/mdk-stage1/pcmcia/cs_types.h @@ -1,5 +1,5 @@ /* - * cs_types.h 1.18 2000/06/12 21:55:40 + * cs_types.h 1.19 2001/08/24 12:16:12 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -38,8 +38,13 @@ #endif #endif -typedef u_short socket_t; +#ifdef __arm__ +typedef u_int ioaddr_t; +#else typedef u_short ioaddr_t; +#endif + +typedef u_short socket_t; typedef u_int event_t; typedef u_char cisdata_t; typedef u_short page_t; diff --git a/mdk-stage1/pcmcia/driver_ops.h b/mdk-stage1/pcmcia/driver_ops.h index 00cde3336..2f0a066d3 100644 --- a/mdk-stage1/pcmcia/driver_ops.h +++ b/mdk-stage1/pcmcia/driver_ops.h @@ -1,5 +1,5 @@ /* - * driver_ops.h 1.15 2000/06/12 21:55:40 + * driver_ops.h 1.16 2001/08/24 12:16:13 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -68,15 +68,6 @@ typedef struct driver_operations { int register_driver(struct driver_operations *ops); void unregister_driver(struct driver_operations *ops); -#ifdef __BEOS__ -#define CB_ENABLER_MODULE_NAME "bus_managers/cb_enabler/v1" -typedef struct cb_enabler_module_info { - bus_manager_info binfo; - int (*register_driver)(struct driver_operations *ops); - void (*unregister_driver)(struct driver_operations *ops); -} cb_enabler_module_info; -#endif /* __BEOS__ */ - #endif /* __KERNEL__ */ #endif /* _LINUX_DRIVER_OPS_H */ diff --git a/mdk-stage1/pcmcia/ds.h b/mdk-stage1/pcmcia/ds.h index 975ba596a..29db7b415 100644 --- a/mdk-stage1/pcmcia/ds.h +++ b/mdk-stage1/pcmcia/ds.h @@ -1,5 +1,5 @@ /* - * ds.h 1.56 2000/06/12 21:55:40 + * ds.h 1.57 2001/08/24 12:16:13 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -30,8 +30,8 @@ #ifndef _LINUX_DS_H #define _LINUX_DS_H -#include <pcmcia/driver_ops.h> -#include <pcmcia/bulkmem.h> +#include <pcmcia_/driver_ops.h> +#include <pcmcia_/bulkmem.h> typedef struct tuple_parse_t { tuple_t tuple; @@ -143,21 +143,6 @@ int unregister_pccard_driver(dev_info_t *dev_info); #define register_pcmcia_driver register_pccard_driver #define unregister_pcmcia_driver unregister_pccard_driver -#ifdef __BEOS__ -#define DS_MODULE_NAME "bus_managers/pcmcia_ds/v1" -typedef struct ds_module_info { - bus_manager_info binfo; - int (*_register_pccard_driver)(dev_info_t *, - dev_link_t *(*)(void), - void (*)(dev_link_t *)); - int (*_unregister_pccard_driver)(dev_info_t *); - struct driver_info_t **root_driver; - int *sockets; - struct socket_info_t **socket_table; - sem_id *list_sem; -} ds_module_info; -#endif /* __BEOS__ */ - #endif /* __KERNEL__ */ #endif /* _LINUX_DS_H */ diff --git a/mdk-stage1/pcmcia/i82365.h b/mdk-stage1/pcmcia/i82365.h index 15e8e2540..38ff167fb 100644 --- a/mdk-stage1/pcmcia/i82365.h +++ b/mdk-stage1/pcmcia/i82365.h @@ -1,5 +1,5 @@ /* - * i82365.h 1.20 2000/07/20 23:00:27 + * i82365.h 1.21 2001/08/24 12:15:33 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -97,7 +97,6 @@ #define I365_CSC_GPI 0x10 /* Flags for I365_ADDRWIN */ -#define I365_ADDR_MEMCS16 0x20 #define I365_ENA_IO(map) (0x40 << (map)) #define I365_ENA_MEM(map) (0x01 << (map)) @@ -131,24 +130,6 @@ #define I365_MEM_WRPROT 0x8000 /* In offset high byte */ #define I365_MEM_REG 0x4000 -#define I365_REG(slot, reg) (((slot) << 6) | (reg)) - -/* Default ISA interrupt mask */ -#define I365_ISA_IRQ_MASK 0xdeb8 /* irq's 3-5,7,9-12,14,15 */ - -/* Device ID's for PCI-to-PCMCIA bridges */ - -#ifndef PCI_VENDOR_ID_INTEL -#define PCI_VENDOR_ID_INTEL 0x8086 -#endif -#ifndef PCI_DEVICE_ID_INTEL_82092AA_0 -#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 -#endif -#ifndef PCI_VENDOR_ID_OMEGA -#define PCI_VENDOR_ID_OMEGA 0x119b -#endif -#ifndef PCI_DEVICE_ID_OMEGA_82C092G -#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221 -#endif +#define I365_REG(slot, reg) (((slot) << 6) + reg) #endif /* _LINUX_I82365_H */ diff --git a/mdk-stage1/pcmcia/lex_config.c b/mdk-stage1/pcmcia/lex_config.c deleted file mode 100644 index b374c8bf4..000000000 --- a/mdk-stage1/pcmcia/lex_config.c +++ /dev/null @@ -1,2008 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include <stdio.h> - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> -#include <unistd.h> - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 45 -#define YY_END_OF_BUFFER 46 -static yyconst short int yy_accept[247] = - { 0, - 5, 5, 2, 2, 46, 44, 5, 4, 5, 44, - 6, 41, 41, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 3, - 2, 45, 5, 5, 6, 0, 43, 0, 6, 41, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, - 0, 0, 3, 2, 0, 43, 0, 42, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 18, 0, 0, 0, 0, 23, 0, 0, 0, - - 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, - 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 0, 0, 14, 0, 0, 0, 0, - 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 31, 0, 0, 0, 0, 0, 13, 0, - 0, 0, 0, 20, 21, 22, 0, 0, 0, 28, - 0, 0, 0, 1, 0, 0, 0, 0, 12, 15, - 0, 0, 17, 0, 0, 0, 0, 29, 0, 0, - - 32, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 39, 7, 0, 0, 24, 0, 0, - 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 34, 0, 0, 0, 40, 0, - 0, 35, 37, 0, 38, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 1, 5, 6, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 1, 6, 1, - 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 10, 1, 1, 11, 1, 12, 13, 14, 15, - - 16, 17, 18, 1, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[36] = - { 0, - 1, 2, 3, 2, 1, 1, 4, 4, 4, 1, - 1, 4, 4, 4, 4, 4, 4, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst short int yy_base[253] = - { 0, - 0, 0, 34, 37, 293, 294, 40, 294, 41, 41, - 0, 41, 45, 31, 273, 42, 40, 257, 38, 34, - 274, 47, 273, 262, 53, 271, 57, 35, 60, 0, - 79, 294, 82, 83, 0, 83, 294, 87, 0, 87, - 0, 263, 260, 260, 255, 253, 269, 74, 245, 265, - 244, 253, 262, 248, 259, 249, 249, 256, 255, 80, - 239, 240, 248, 238, 80, 236, 236, 232, 294, 236, - 233, 245, 0, 97, 95, 97, 108, 0, 230, 234, - 242, 241, 294, 226, 242, 234, 226, 229, 234, 235, - 226, 294, 231, 229, 220, 213, 294, 228, 209, 212, - - 228, 294, 209, 219, 221, 217, 216, 206, 211, 203, - 215, 219, 194, 294, 294, 199, 196, 212, 209, 193, - 208, 192, 190, 206, 200, 190, 195, 187, 190, 294, - 192, 294, 188, 184, 200, 198, 195, 192, 188, 181, - 191, 181, 294, 181, 186, 294, 186, 189, 180, 183, - 294, 182, 161, 179, 183, 165, 170, 167, 158, 177, - 166, 171, 294, 161, 174, 172, 158, 152, 294, 165, - 165, 154, 162, 294, 166, 294, 153, 154, 158, 294, - 157, 157, 160, 294, 146, 157, 140, 136, 294, 294, - 147, 141, 294, 150, 133, 151, 139, 294, 148, 133, - - 294, 143, 142, 127, 126, 294, 142, 138, 140, 140, - 124, 124, 136, 294, 294, 126, 118, 294, 130, 118, - 113, 114, 115, 294, 125, 127, 108, 116, 99, 87, - 294, 90, 87, 86, 294, 96, 78, 74, 294, 75, - 64, 294, 294, 46, 294, 294, 118, 122, 126, 130, - 134, 64 - } ; - -static yyconst short int yy_def[253] = - { 0, - 246, 1, 247, 247, 246, 246, 246, 246, 246, 248, - 249, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 250, - 246, 246, 246, 246, 249, 248, 246, 251, 249, 246, - 252, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 250, 246, 248, 248, 251, 252, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 0, 246, 246, 246, 246, - 246, 246 - } ; - -static yyconst short int yy_nxt[330] = - { 0, - 6, 7, 8, 9, 10, 11, 12, 13, 6, 6, - 6, 14, 15, 16, 17, 18, 19, 6, 20, 21, - 6, 6, 22, 23, 24, 25, 6, 26, 27, 28, - 6, 29, 6, 6, 6, 31, 32, 31, 31, 32, - 31, 33, 33, 33, 34, 37, 35, 40, 40, 42, - 38, 40, 40, 45, 43, 48, 51, 53, 56, 69, - 46, 54, 57, 47, 62, 70, 63, 78, 52, 49, - 66, 58, 67, 245, 41, 71, 59, 64, 72, 244, - 74, 68, 74, 33, 33, 33, 34, 37, 35, 36, - 85, 76, 38, 40, 40, 98, 77, 104, 74, 37, - - 74, 37, 243, 242, 38, 86, 38, 241, 105, 99, - 36, 240, 76, 239, 238, 237, 236, 77, 30, 30, - 30, 30, 36, 36, 36, 36, 39, 39, 235, 39, - 73, 234, 233, 73, 75, 75, 75, 75, 232, 231, - 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, - 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, - 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, - 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, - 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, - 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, - - 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, - 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, - 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, - 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, - 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, - 110, 109, 108, 107, 106, 103, 102, 101, 100, 97, - 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, - 84, 83, 82, 81, 80, 79, 65, 61, 60, 55, - 50, 44, 246, 5, 246, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246 - } ; - -static yyconst short int yy_chk[330] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 3, 3, 4, 4, - 4, 7, 9, 7, 9, 10, 9, 12, 12, 14, - 10, 13, 13, 16, 14, 17, 19, 20, 22, 28, - 16, 20, 22, 16, 25, 28, 25, 252, 19, 17, - 27, 22, 27, 244, 12, 29, 22, 25, 29, 241, - 31, 27, 31, 33, 34, 33, 34, 36, 34, 38, - 48, 38, 36, 40, 40, 60, 38, 65, 74, 75, - - 74, 76, 240, 238, 75, 48, 76, 237, 65, 60, - 77, 236, 77, 234, 233, 232, 230, 77, 247, 247, - 247, 247, 248, 248, 248, 248, 249, 249, 229, 249, - 250, 228, 227, 250, 251, 251, 251, 251, 226, 225, - 223, 222, 221, 220, 219, 217, 216, 213, 212, 211, - 210, 209, 208, 207, 205, 204, 203, 202, 200, 199, - 197, 196, 195, 194, 192, 191, 188, 187, 186, 185, - 183, 182, 181, 179, 178, 177, 175, 173, 172, 171, - 170, 168, 167, 166, 165, 164, 162, 161, 160, 159, - 158, 157, 156, 155, 154, 153, 152, 150, 149, 148, - - 147, 145, 144, 142, 141, 140, 139, 138, 137, 136, - 135, 134, 133, 131, 129, 128, 127, 126, 125, 124, - 123, 122, 121, 120, 119, 118, 117, 116, 113, 112, - 111, 110, 109, 108, 107, 106, 105, 104, 103, 101, - 100, 99, 98, 96, 95, 94, 93, 91, 90, 89, - 88, 87, 86, 85, 84, 82, 81, 80, 79, 72, - 71, 70, 68, 67, 66, 64, 63, 62, 61, 59, - 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, - 47, 46, 45, 44, 43, 42, 26, 24, 23, 21, - 18, 15, 5, 246, 246, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 246, 246, 246, 246, 246, 246, 246, 246 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "lex_config.l" -#define INITIAL 0 -/* Special state for handling include files */ -#define src 1 - -#line 5 "lex_config.l" -/* - * lex_config.l 1.39 2000/06/12 21:33:02 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License - * at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and - * limitations under the License. - * - * The initial developer of the original code is David A. Hinds - * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the - * above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use - * your version of this file under the MPL, indicate your decision by - * deleting the provisions above and replace them with the notice and - * other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file - * under either the MPL or the GPL. - */ - -#undef src -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <syslog.h> -#include <glob.h> -#define src 1 - -#include <pcmcia/cs_types.h> -#include <pcmcia/cs.h> - -#include "yacc_config.h" - -/* For assembling nice error messages */ -char *current_file; -int current_lineno; - -static int lex_number(char *s); -static int lex_string(char *s); -static void do_source(char *fn); -static int do_eof(void); - - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 63 "lex_config.l" - - - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 247 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 294 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 65 "lex_config.l" -BEGIN(src); - YY_BREAK -case 2: -YY_RULE_SETUP -#line 66 "lex_config.l" -/* skip */ ; - YY_BREAK -case 3: -YY_RULE_SETUP -#line 67 "lex_config.l" -do_source(yytext); BEGIN(INITIAL); - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(src): -#line 68 "lex_config.l" -if (do_eof()) yyterminate(); - YY_BREAK -case 4: -YY_RULE_SETUP -#line 70 "lex_config.l" -current_lineno++; - YY_BREAK -case 5: -YY_RULE_SETUP -#line 71 "lex_config.l" -/* skip */ ; - YY_BREAK -case 6: -YY_RULE_SETUP -#line 72 "lex_config.l" -/* skip */ ; - YY_BREAK -case 7: -YY_RULE_SETUP -#line 74 "lex_config.l" -return ANONYMOUS; - YY_BREAK -case 8: -YY_RULE_SETUP -#line 75 "lex_config.l" -return BIND; - YY_BREAK -case 9: -YY_RULE_SETUP -#line 76 "lex_config.l" -return CIS; - YY_BREAK -case 10: -YY_RULE_SETUP -#line 77 "lex_config.l" -return CARD; - YY_BREAK -case 11: -YY_RULE_SETUP -#line 78 "lex_config.l" -return CLASS; - YY_BREAK -case 12: -YY_RULE_SETUP -#line 79 "lex_config.l" -return DEFAULT; - YY_BREAK -case 13: -YY_RULE_SETUP -#line 80 "lex_config.l" -return DEVICE; - YY_BREAK -case 14: -YY_RULE_SETUP -#line 81 "lex_config.l" -return DTYPE; - YY_BREAK -case 15: -YY_RULE_SETUP -#line 82 "lex_config.l" -return EXCLUDE; - YY_BREAK -case 16: -YY_RULE_SETUP -#line 83 "lex_config.l" -return FUNCTION; - YY_BREAK -case 17: -YY_RULE_SETUP -#line 84 "lex_config.l" -return INCLUDE; - YY_BREAK -case 18: -YY_RULE_SETUP -#line 85 "lex_config.l" -return IRQ_NO; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 86 "lex_config.l" -return JEDEC; - YY_BREAK -case 20: -YY_RULE_SETUP -#line 87 "lex_config.l" -return MANFID; - YY_BREAK -case 21: -YY_RULE_SETUP -#line 88 "lex_config.l" -return MEMORY; - YY_BREAK -case 22: -YY_RULE_SETUP -#line 89 "lex_config.l" -return MODULE; - YY_BREAK -case 23: -YY_RULE_SETUP -#line 90 "lex_config.l" -return MTD; - YY_BREAK -case 24: -YY_RULE_SETUP -#line 91 "lex_config.l" -return NEEDS_MTD; - YY_BREAK -case 25: -YY_RULE_SETUP -#line 92 "lex_config.l" -return OPTS; - YY_BREAK -case 26: -YY_RULE_SETUP -#line 93 "lex_config.l" -return PCI; - YY_BREAK -case 27: -YY_RULE_SETUP -#line 94 "lex_config.l" -return PORT; - YY_BREAK -case 28: -YY_RULE_SETUP -#line 95 "lex_config.l" -return REGION; - YY_BREAK -case 29: -YY_RULE_SETUP -#line 96 "lex_config.l" -return RESERVE; - YY_BREAK -case 30: -YY_RULE_SETUP -#line 97 "lex_config.l" -return TO; - YY_BREAK -case 31: -YY_RULE_SETUP -#line 98 "lex_config.l" -return TUPLE; - YY_BREAK -case 32: -YY_RULE_SETUP -#line 99 "lex_config.l" -return VERSION; - YY_BREAK -case 33: -YY_RULE_SETUP -#line 101 "lex_config.l" -return lex_number("1"); - YY_BREAK -case 34: -YY_RULE_SETUP -#line 102 "lex_config.l" -return lex_number("2"); - YY_BREAK -case 35: -YY_RULE_SETUP -#line 103 "lex_config.l" -return lex_number("3"); - YY_BREAK -case 36: -YY_RULE_SETUP -#line 104 "lex_config.l" -return lex_number("4"); - YY_BREAK -case 37: -YY_RULE_SETUP -#line 105 "lex_config.l" -return lex_number("5"); - YY_BREAK -case 38: -YY_RULE_SETUP -#line 106 "lex_config.l" -return lex_number("6"); - YY_BREAK -case 39: -YY_RULE_SETUP -#line 107 "lex_config.l" -return lex_number("7"); - YY_BREAK -case 40: -YY_RULE_SETUP -#line 108 "lex_config.l" -return lex_number("8"); - YY_BREAK -case 41: -YY_RULE_SETUP -#line 110 "lex_config.l" -return lex_number(yytext); - YY_BREAK -case 42: -YY_RULE_SETUP -#line 112 "lex_config.l" -return lex_number(yytext); - YY_BREAK -case 43: -YY_RULE_SETUP -#line 114 "lex_config.l" -return lex_string(yytext); - YY_BREAK -case 44: -YY_RULE_SETUP -#line 116 "lex_config.l" -return yytext[0]; - YY_BREAK -case 45: -YY_RULE_SETUP -#line 118 "lex_config.l" -ECHO; - YY_BREAK - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 247 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 247 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 246); - - return yy_is_jam ? 0 : yy_current_state; - } - - - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 118 "lex_config.l" - - -#ifndef yywrap -int yywrap() { return 1; } -#endif - -/*====================================================================== - - Stuff to parse basic data types - -======================================================================*/ - -static int lex_number(char *s) -{ - yylval.num = strtoul(s, NULL, 0); - return NUMBER; -} - -static int lex_string(char *s) -{ - int n = strlen(s); - yylval.str = malloc(n-1); - strncpy(yylval.str, s+1, n-2); - yylval.str[n-2] = '\0'; - return STRING; -} - -/*====================================================================== - - Code to support nesting of configuration files - -======================================================================*/ - -#define MAX_SOURCE_DEPTH 4 -struct source_stack { - YY_BUFFER_STATE buffer; - char *filename; - int lineno, fileno; - FILE *file; - glob_t glob; -} source_stack[MAX_SOURCE_DEPTH]; -static int source_stack_ptr = 0; -static int parse_env = 0; - -static int get_glob(void) -{ - struct source_stack *s = &source_stack[source_stack_ptr]; - while (s->fileno < s->glob.gl_pathc) { - char *fn = s->glob.gl_pathv[s->fileno]; - s->file = fopen(fn, "r"); - if (s->file == NULL) { - if (strpbrk(fn, "?*[") == NULL) - syslog(LOG_INFO, "could not open '%s': %m", fn); - s->fileno++; - } else { - current_lineno = 1; - current_file = strdup(fn); - yy_switch_to_buffer(yy_create_buffer(s->file, YY_BUF_SIZE)); - source_stack_ptr++; - s->fileno++; - return 0; - } - } - return -1; -} - -static void do_source(char *fn) -{ - struct source_stack *s = &source_stack[source_stack_ptr]; - - if (source_stack_ptr >= MAX_SOURCE_DEPTH) { - syslog(LOG_INFO, "source depth limit exceeded"); - return; - } - glob(fn, GLOB_NOCHECK, NULL, &s->glob); - s->fileno = 0; - s->buffer = YY_CURRENT_BUFFER; - s->lineno = current_lineno; - s->filename = current_file; - get_glob(); -} - -static int do_eof(void) -{ - struct source_stack *s = &source_stack[--source_stack_ptr]; - if (source_stack_ptr < 0) { - if (parse_env == 0) { - char *t = getenv("PCMCIA_OPTS"); - if (t == NULL) return -1; - parse_env = 1; - source_stack_ptr = 0; - current_file = "PCMCIA_OPTS"; - current_lineno = 1; - yy_scan_string(t); - return 0; - } else - return -1; - } - fclose(s->file); - free(current_file); - yy_delete_buffer(YY_CURRENT_BUFFER); - if (get_glob() != 0) { - yy_switch_to_buffer(s->buffer); - current_lineno = s->lineno; - current_file = s->filename; - } - return 0; -} - -/*====================================================================== - - The main entry point... returns -1 if the file can't be accessed. - -======================================================================*/ -int yyparse(void); - -int parse_configfile(char *fn) -{ - FILE *f; - - f = fopen(fn, "r"); - if (!f) { - syslog(LOG_INFO, "could not open '%s': %m", fn); - return -1; - } - current_lineno = 1; - current_file = fn; - source_stack_ptr = 0; - yyrestart(f); - yyparse(); - fclose(f); - return 0; -} - diff --git a/mdk-stage1/pcmcia/lex_config.l b/mdk-stage1/pcmcia/lex_config.l new file mode 100644 index 000000000..54500c446 --- /dev/null +++ b/mdk-stage1/pcmcia/lex_config.l @@ -0,0 +1,224 @@ +/* Special state for handling include files */ +%x src + +%{ +/* + * Startup tool for non statically mapped PCMCIA sockets + * + * (C) 2005 Dominik Brodowski <linux@brodo.de> + * + * The initial developer of the original code is David A. Hinds + * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * License: GPL v2 + */ + +#undef src + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <syslog.h> + +#ifdef HAS_WORDEXP +#include <wordexp.h> +#else +#include <glob.h> +#endif + +#define src 1 + +#include "yacc_config.h" + +#define YY_NO_INPUT 1 /* mdk-stage1 */ +#define YY_NO_UNPUT 1 /* mdk-stage1 */ +extern int yyparse(void); /* mdk-stage1 */ + +/* For assembling nice error messages */ +char *current_file; +int current_lineno; + +static int lex_number(char *s); +static int lex_string(char *s); +static void do_source(char *fn); +static int do_eof(void); + +%} + +int [0-9]+ +hex 0x[0-9a-fA-F]+ +str \"([^"]|\\.)*\" + +%% + +source[ \t]+ BEGIN(src); return SOURCE; +<src>[^\n]+ do_source(yytext); BEGIN(INITIAL); +<<EOF>> if (do_eof()) yyterminate(); + +\n current_lineno++; +[ \t]* /* skip */ ; +[ ]*[#;].* /* skip */ ; + +exclude return EXCLUDE; +include return INCLUDE; +irq return IRQ_NO; +port return PORT; +memory return MEMORY; +module /* skip */ ; + +{int} return lex_number(yytext); + +{hex} return lex_number(yytext); + +{str} return lex_string(yytext); + +. return yytext[0]; + +%% + +#ifndef yywrap +int yywrap() { return 1; } +#endif + +/*====================================================================== + + Stuff to parse basic data types + +======================================================================*/ + +static int lex_number(char *s) +{ + yylval.num = strtoul(s, NULL, 0); + return NUMBER; +} + +static int lex_string(char *s) +{ + int n = strlen(s); + yylval.str = malloc(n-1); + strncpy(yylval.str, s+1, n-2); + yylval.str[n-2] = '\0'; + return STRING; +} + +/*====================================================================== + + Code to support nesting of configuration files + +======================================================================*/ + +#define MAX_SOURCE_DEPTH 4 +struct source_stack { + YY_BUFFER_STATE buffer; + char *filename; + int lineno, fileno; + FILE *file; +#ifdef HAS_WORDEXP + wordexp_t word; +#else + glob_t glob; +#endif +} source_stack[MAX_SOURCE_DEPTH]; +static int source_stack_ptr = 0; +static int parse_env = 0; + +static int get_glob(void) +{ + struct source_stack *s = &source_stack[source_stack_ptr]; +#ifdef HAS_WORDEXP + while (s->fileno < s->word.we_wordc) { + char *fn = s->word.we_wordv[s->fileno]; +#else + while (s->fileno < s->glob.gl_pathc) { + char *fn = s->glob.gl_pathv[s->fileno]; +#endif + s->file = fopen(fn, "r"); + if (s->file == NULL) { + if (strpbrk(fn, "?*[") == NULL) + syslog(LOG_ERR, "could not open '%s': %m", fn); + s->fileno++; + } else { + current_lineno = 1; + current_file = strdup(fn); + yy_switch_to_buffer(yy_create_buffer(s->file, YY_BUF_SIZE)); + source_stack_ptr++; + s->fileno++; + return 0; + } + } + return -1; +} + +static void do_source(char *fn) +{ + struct source_stack *s = &source_stack[source_stack_ptr]; + + if (source_stack_ptr >= MAX_SOURCE_DEPTH) { + syslog(LOG_ERR, "source depth limit exceeded"); + return; + } +#ifdef HAS_WORDEXP + wordexp(fn, &s->word, 0); +#else + glob(fn, GLOB_NOCHECK, NULL, &s->glob); +#endif + s->fileno = 0; + s->buffer = YY_CURRENT_BUFFER; + s->lineno = current_lineno; + s->filename = current_file; + get_glob(); +} + +static int do_eof(void) +{ + struct source_stack *s = &source_stack[--source_stack_ptr]; + if (source_stack_ptr < 0) { + if (parse_env == 0) { + char *t = getenv("PCMCIA_OPTS"); + if (t == NULL) return -1; + parse_env = 1; + source_stack_ptr = 0; + current_file = "PCMCIA_OPTS"; + current_lineno = 1; + yy_scan_string(t); + return 0; + } else + return -1; + } + fclose(s->file); + free(current_file); + yy_delete_buffer(YY_CURRENT_BUFFER); + if (get_glob() != 0) { + yy_switch_to_buffer(s->buffer); + current_lineno = s->lineno; + current_file = s->filename; + } + return 0; +} + +/*====================================================================== + + The main entry point... returns -1 if the file can't be accessed. + +======================================================================*/ + +int parse_configfile(char *fn) +{ + FILE *f; + + f = fopen(fn, "r"); + if (!f) { + syslog(LOG_ERR, "could not open '%s': %m", fn); + return -1; + } + current_lineno = 1; + current_file = fn; + source_stack_ptr = 0; + yyrestart(f); + yyparse(); + fclose(f); + return 0; +} + diff --git a/mdk-stage1/pcmcia/merge_from_pcitable b/mdk-stage1/pcmcia/merge_from_pcitable new file mode 100755 index 000000000..bb127640c --- /dev/null +++ b/mdk-stage1/pcmcia/merge_from_pcitable @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +# This program will show on stdout yenta_socket stuff from pcitable +# which is not in probe.c + +use MDK::Common; +use lib qw(/usr/lib/libDrakX); +use run_program; +use c; + +my %probes; +foreach (cat_('probe.c')) { + if (/^pci_id_t pci_id\[\] = {/ ... /^};/) { + /^\s*{\s*0x([\da-f]+),\s*0x([\da-f]+),\s*"([^"]*)",\s*"([^"]*)"\s*}/ + and $probes{"$1$2"} = { vendor => $1, device => $2, driver => $3, name => $4 }; + } +} + +require '/usr/bin/merge2pcitable.pl'; + +my %pcitable; +my @yenta_socket_ids = grep { $_ } map { + /.*pci:v0000(....).*d0000(....).*/; + my $key = lc("$1$2"); + $pcitable{$key} = { vendor => $1, device => $2 }; + $key; + } grep { /^alias/ } run_program::get_stdout('/sbin/modinfo', 'yenta_socket'); + + +if (my @missing_in_probe_c = difference2(\@yenta_socket_ids, [ keys %probes ])) { + print "Missing in `probe.c':\n", + map { + my $p = $pcitable{$_}; + my $name = c::get_pci_description(hex($p->{vendor}), hex($p->{device})); + qq( { 0x$p->{vendor}, 0x$p->{device}, "yenta_socket", "$name" },\n); + } sort @missing_in_probe_c; +} diff --git a/mdk-stage1/pcmcia/pcmcia.h b/mdk-stage1/pcmcia/pcmcia.h index 1967b3497..ae7db247b 100644 --- a/mdk-stage1/pcmcia/pcmcia.h +++ b/mdk-stage1/pcmcia/pcmcia.h @@ -1,7 +1,7 @@ /* - * Guillaume Cottenceau (gc@mandrakesoft.com) + * Guillaume Cottenceau (gc) * - * Copyright 2000 MandrakeSoft + * Copyright 2000 Mandriva * * This software may be freely redistributed under the terms of the GNU * public license. @@ -16,6 +16,6 @@ #define _PCMCIA_CARDMGR_INTERFACE_H_ char * pcmcia_probe(void); -int cardmgr_call(void); +void pcmcia_socket_startup(int socket_no); #endif diff --git a/mdk-stage1/pcmcia/pcmcia_probe.c b/mdk-stage1/pcmcia/pcmcia_probe.c deleted file mode 100644 index 57651d75f..000000000 --- a/mdk-stage1/pcmcia/pcmcia_probe.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Guillaume Cottenceau (gc@mandrakesoft.com) - * - * Copyright 2000 MandrakeSoft - * - * This software may be freely redistributed under the terms of the GNU - * public license. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* Code comes from /anonymous@projects.sourceforge.net:/pub/pcmcia-cs/pcmcia-cs-3.1.23.tar.bz2 - * - * Licence of this code follows: - - PCMCIA controller probe - - probe.c 1.52 2000/06/12 21:33:02 - - The contents of this file are subject to the Mozilla Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The initial developer of the original code is David A. Hinds - <dahinds@users.sourceforge.net>. Portions created by David A. Hinds - are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - - Alternatively, the contents of this file may be used under the - terms of the GNU Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the - above. If you wish to allow the use of your version of this file - only under the terms of the GPL and not to allow others to use - your version of this file under the MPL, indicate your decision - by deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the MPL or the GPL. - -======================================================================*/ - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> - -#include <pcmcia/config.h> - -#include "../log.h" -#include "pcmcia.h" - -/*====================================================================*/ - -typedef struct { - u_short vendor, device; - char *tag; - char *name; -} pci_id_t; - -pci_id_t pci_id[] = { - { 0x1013, 0x1100, "Cirrus Logic CL 6729", "Cirrus PD6729" }, - { 0x1013, 0x1110, "Cirrus Logic PD 6832", "Cirrus PD6832" }, - { 0x10b3, 0xb106, "SMC 34C90", "SMC 34C90" }, - { 0x1180, 0x0465, "Ricoh RL5C465", "Ricoh RL5C465" }, - { 0x1180, 0x0466, "Ricoh RL5C466", "Ricoh RL5C466" }, - { 0x1180, 0x0475, "Ricoh RL5C475", "Ricoh RL5C475" }, - { 0x1180, 0x0476, "Ricoh RL5C476", "Ricoh RL5C476" }, - { 0x1180, 0x0478, "Ricoh RL5C478", "Ricoh RL5C478" }, - { 0x104c, 0xac12, "Texas Instruments PCI1130", "TI 1130" }, - { 0x104c, 0xac13, "Texas Instruments PCI1031", "TI 1031" }, - { 0x104c, 0xac15, "Texas Instruments PCI1131", "TI 1131" }, - { 0x104c, 0xac16, "Texas Instruments PCI1250", "TI 1250A" }, - { 0x104c, 0xac17, "Texas Instruments PCI1220", "TI 1220" }, - { 0x104c, 0xac19, "Texas Instruments PCI1221", "TI 1221" }, - { 0x104c, 0xac1a, "Texas Instruments PCI1210", "TI 1210" }, - { 0x104c, 0xac1d, "Texas Instruments PCI1251A", "TI 1251A" }, - { 0x104c, 0xac1f, "Texas Instruments PCI1251B", "TI 1251B" }, - { 0x104c, 0xac1b, "Texas Instruments PCI1450", "TI 1450" }, - { 0x104c, 0xac1c, "Texas Instruments PCI1225", "TI 1225" }, - { 0x104c, 0xac1e, "Texas Instruments PCI1211", "TI 1211" }, - { 0x104c, 0xac50, "Texas Instruments PCI1410", "TI 1410" }, - { 0x104c, 0xac51, "Texas Instruments PCI1420", "TI 1420" }, - { 0x1217, 0x6729, "O2 Micro 6729", "O2Micro OZ6729" }, - { 0x1217, 0x673a, "O2 Micro 6730", "O2Micro OZ6730" }, - { 0x1217, 0x6832, "O2 Micro 6832/6833", "O2Micro OZ6832/OZ6833" }, - { 0x1217, 0x6836, "O2 Micro 6836/6860", "O2Micro OZ6836/OZ6860" }, - { 0x1217, 0x6872, "O2 Micro 6812", "O2Micro OZ6812" }, - { 0x1179, 0x0603, "Toshiba ToPIC95-A", "Toshiba ToPIC95-A" }, - { 0x1179, 0x060a, "Toshiba ToPIC95-B", "Toshiba ToPIC95-B" }, - { 0x1179, 0x060f, "Toshiba ToPIC97", "Toshiba ToPIC97" }, - { 0x1179, 0x0617, "Toshiba ToPIC100", "Toshiba ToPIC100" }, - { 0x119b, 0x1221, "Omega Micro 82C092G", "Omega Micro 82C092G" }, - { 0x8086, 0x1221, "Intel 82092AA", "Intel 82092AA" } -}; -#define PCI_COUNT (sizeof(pci_id)/sizeof(pci_id_t)) - -static int pci_probe(void) -{ - char s[256], *name = NULL; - u_int device, vendor, i; - FILE *f; - - log_message("PCMCIA: probing PCI bus.."); - - f = fopen("/proc/bus/pci/devices", "r"); - - if (!f) { - log_message("where are you going without /proc/bus/pci/devices ??"); - return -1; - } - - while (fgets(s, 256, f) != NULL) { - u_int n = strtoul(s+5, NULL, 16); - vendor = (n >> 16); device = (n & 0xffff); - for (i = 0; i < PCI_COUNT; i++) - if ((vendor == pci_id[i].vendor) && - (device == pci_id[i].device)) break; - if (i < PCI_COUNT) { - name = pci_id[i].name; - break; - } - } - - fclose(f); - - if (name) { - log_message("\t%s found, 2 sockets.", name); - return 0; - } else { - log_message("\tnot found."); - return -ENODEV; - } -} - -/*====================================================================*/ - -#include <sys/io.h> -typedef u_short ioaddr_t; - -#include "i82365.h" -#include "cirrus.h" -#include "vg468.h" - -static ioaddr_t i365_base = 0x03e0; - -static u_char i365_get(u_short sock, u_short reg) -{ - u_char val = I365_REG(sock, reg); - outb(val, i365_base); val = inb(i365_base+1); - return val; -} - -static void i365_set(u_short sock, u_short reg, u_char data) -{ - u_char val = I365_REG(sock, reg); - outb(val, i365_base); outb(data, i365_base+1); -} - -static void i365_bset(u_short sock, u_short reg, u_char mask) -{ - u_char d = i365_get(sock, reg); - d |= mask; - i365_set(sock, reg, d); -} - -static void i365_bclr(u_short sock, u_short reg, u_char mask) -{ - u_char d = i365_get(sock, reg); - d &= ~mask; - i365_set(sock, reg, d); -} - -static int i365_probe(void) -{ - int val, sock, done; - char *name = "i82365sl"; - - log_message("PCMCIA: probing for Intel PCIC (ISA).."); - - sock = done = 0; - ioperm(i365_base, 4, 1); - ioperm(0x80, 1, 1); - for (; sock < 2; sock++) { - val = i365_get(sock, I365_IDENT); - switch (val) { - case 0x82: - name = "i82365sl A step"; - break; - case 0x83: - name = "i82365sl B step"; - break; - case 0x84: - name = "VLSI 82C146"; - break; - case 0x88: case 0x89: case 0x8a: - name = "IBM Clone"; - break; - case 0x8b: case 0x8c: - break; - default: - done = 1; - } - if (done) break; - } - - if (sock == 0) { - log_message("\tnot found."); - return -ENODEV; - } - - if ((sock == 2) && (strcmp(name, "VLSI 82C146") == 0)) - name = "i82365sl DF"; - - /* Check for Vadem chips */ - outb(0x0e, i365_base); - outb(0x37, i365_base); - i365_bset(0, VG468_MISC, VG468_MISC_VADEMREV); - val = i365_get(0, I365_IDENT); - if (val & I365_IDENT_VADEM) { - if ((val & 7) < 4) - name = "Vadem VG-468"; - else - name = "Vadem VG-469"; - i365_bclr(0, VG468_MISC, VG468_MISC_VADEMREV); - } - - /* Check for Cirrus CL-PD67xx chips */ - i365_set(0, PD67_CHIP_INFO, 0); - val = i365_get(0, PD67_CHIP_INFO); - if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) { - val = i365_get(0, PD67_CHIP_INFO); - if ((val & PD67_INFO_CHIP_ID) == 0) { - if (val & PD67_INFO_SLOTS) - name = "Cirrus CL-PD672x"; - else { - name = "Cirrus CL-PD6710"; - sock = 1; - } - i365_set(0, PD67_EXT_INDEX, 0xe5); - if (i365_get(0, PD67_EXT_INDEX) != 0xe5) - name = "VIA VT83C469"; - } - } - - log_message("\t%s found, %d sockets.", name, sock); - return 0; - -} /* i365_probe */ - - -/*====================================================================*/ - -#include "tcic.h" - -static u_char tcic_getb(ioaddr_t base, u_char reg) -{ - u_char val = inb(base+reg); - return val; -} - -static void tcic_setb(ioaddr_t base, u_char reg, u_char data) -{ - outb(data, base+reg); -} - -static u_short tcic_getw(ioaddr_t base, u_char reg) -{ - u_short val = inw(base+reg); - return val; -} - -static void tcic_setw(ioaddr_t base, u_char reg, u_short data) -{ - outw(data, base+reg); -} - -static u_short tcic_aux_getw(ioaddr_t base, u_short reg) -{ - u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; - tcic_setb(base, TCIC_MODE, mode); - return tcic_getw(base, TCIC_AUX); -} - -static void tcic_aux_setw(ioaddr_t base, u_short reg, u_short data) -{ - u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; - tcic_setb(base, TCIC_MODE, mode); - tcic_setw(base, TCIC_AUX, data); -} - -static int get_tcic_id(ioaddr_t base) -{ - u_short id; - tcic_aux_setw(base, TCIC_AUX_TEST, TCIC_TEST_DIAG); - id = tcic_aux_getw(base, TCIC_AUX_ILOCK); - id = (id & TCIC_ILOCKTEST_ID_MASK) >> TCIC_ILOCKTEST_ID_SH; - tcic_aux_setw(base, TCIC_AUX_TEST, 0); - return id; -} - -static int tcic_probe_at(ioaddr_t base) -{ - int i; - u_short old; - - /* Anything there?? */ - for (i = 0; i < 0x10; i += 2) - if (tcic_getw(base, i) == 0xffff) - return -1; - - log_message("\tat %#3.3x: ", base); - - /* Try to reset the chip */ - tcic_setw(base, TCIC_SCTRL, TCIC_SCTRL_RESET); - tcic_setw(base, TCIC_SCTRL, 0); - - /* Can we set the addr register? */ - old = tcic_getw(base, TCIC_ADDR); - tcic_setw(base, TCIC_ADDR, 0); - if (tcic_getw(base, TCIC_ADDR) != 0) { - tcic_setw(base, TCIC_ADDR, old); - return -2; - } - - tcic_setw(base, TCIC_ADDR, 0xc3a5); - if (tcic_getw(base, TCIC_ADDR) != 0xc3a5) - return -3; - - return 2; -} - -static int tcic_probe(void) -{ - int sock, id; - - log_message("PCMCIA: probing for Databook TCIC-2 (ISA).."); - - ioperm(TCIC_BASE, 16, 1); - ioperm(0x80, 1, 1); - sock = tcic_probe_at(TCIC_BASE); - - if (sock <= 0) { - log_message("\tnot found."); - return -ENODEV; - } - - id = get_tcic_id(TCIC_BASE); - switch (id) { - case TCIC_ID_DB86082: - log_message("DB86082"); break; - case TCIC_ID_DB86082A: - log_message("DB86082A"); break; - case TCIC_ID_DB86084: - log_message("DB86084"); break; - case TCIC_ID_DB86084A: - log_message("DB86084A"); break; - case TCIC_ID_DB86072: - log_message("DB86072"); break; - case TCIC_ID_DB86184: - log_message("DB86184"); break; - case TCIC_ID_DB86082B: - log_message("DB86082B"); break; - default: - log_message("Unknown TCIC-2 ID 0x%02x", id); - } - log_message("\tfound at %#6x, %d sockets.\n", TCIC_BASE, sock); - - return 0; - -} /* tcic_probe */ - - -/*====================================================================*/ - -char * pcmcia_probe(void) -{ - if (!pci_probe()) - return "i82365"; - else if (!i365_probe()) - return "i82365"; - else if (!tcic_probe()) - return "tcic"; - else - return NULL; -} diff --git a/mdk-stage1/pcmcia/probe.c b/mdk-stage1/pcmcia/probe.c new file mode 100644 index 000000000..240fe3a17 --- /dev/null +++ b/mdk-stage1/pcmcia/probe.c @@ -0,0 +1,426 @@ +/* + * Guillaume Cottenceau (gc) + * + * Copyright 2000-2001 Mandriva + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * Code comes from /anonymous@projects.sourceforge.net:/pub/pcmcia-cs/pcmcia-cs-3.1.29.tar.bz2 + * + * FIXME: resync with latest pcmcia-cs-3.2.8 or with pcmciautils-0.18 (which uses sysfs) + * + */ + +/*====================================================================== + + PCMCIA controller probe + + probe.c 1.55 2001/08/24 12:19:20 + + The contents of this file are subject to the Mozilla Public + License Version 1.1 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS + IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + implied. See the License for the specific language governing + rights and limitations under the License. + + The initial developer of the original code is David A. Hinds + <dahinds@users.sourceforge.net>. Portions created by David A. Hinds + are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + + Alternatively, the contents of this file may be used under the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the + above. If you wish to allow the use of your version of this file + only under the terms of the GPL and not to allow others to use + your version of this file under the MPL, indicate your decision + by deleting the provisions above and replace them with the notice + and other provisions required by the GPL. If you do not delete + the provisions above, a recipient may use your version of this + file under either the MPL or the GPL. + +======================================================================*/ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> + +#include "log.h" +#include "pcmcia.h" + +/*====================================================================*/ + +typedef struct { + u_short vendor, device; + char *modname; + char *name; +} pci_id_t; + +pci_id_t pci_id[] = { + { 0x1013, 0x1100, "pd6729", "Cirrus Logic CL 6729" }, + { 0x1013, 0x1110, "yenta_socket", "Cirrus Logic PD 6832" }, + { 0x104c, 0x8011, "yenta_socket", "" }, + { 0x104c, 0x8031, "yenta_socket", "Texas Instruments|PCIxx21/x515 Cardbus Controller" }, + { 0x104c, 0x8036, "yenta_socket", "Texas Instruments|PCI6515 Cardbus Controller" }, + { 0x104c, 0x8039, "yenta_socket", "Texas Instruments|PCIxx12 Cardbus Controller " }, + { 0x104c, 0xac12, "yenta_socket", "Texas Instruments PCI1130" }, + { 0x104c, 0xac13, "yenta_socket", "Texas Instruments PCI1031" }, + { 0x104c, 0xac15, "yenta_socket", "Texas Instruments PCI1131" }, + { 0x104c, 0xac16, "yenta_socket", "Texas Instruments PCI1250" }, + { 0x104c, 0xac17, "yenta_socket", "Texas Instruments PCI1220" }, + { 0x104c, 0xac19, "yenta_socket", "Texas Instruments PCI1221" }, + { 0x104c, 0xac1a, "yenta_socket", "Texas Instruments PCI1210" }, + { 0x104c, 0xac1b, "yenta_socket", "Texas Instruments PCI1450" }, + { 0x104c, 0xac1c, "yenta_socket", "Texas Instruments PCI1225" }, + { 0x104c, 0xac1d, "yenta_socket", "Texas Instruments PCI1251A" }, + { 0x104c, 0xac1e, "yenta_socket", "Texas Instruments PCI1211" }, + { 0x104c, 0xac1f, "yenta_socket", "Texas Instruments PCI1251B" }, + { 0x104c, 0xac40, "yenta_socket", "Texas Instruments PCI4450" }, + { 0x104c, 0xac41, "yenta_socket", "Texas Instruments PCI4410" }, + { 0x104c, 0xac42, "yenta_socket", "Texas Instruments PCI4451" }, + { 0x104c, 0xac44, "yenta_socket", "Texas Instruments PCI4510" }, + { 0x104c, 0xac46, "yenta_socket", "Texas Instruments PCI4520" }, + { 0x104c, 0xac47, "yenta_socket", "Texas Instruments PCI7510" }, + { 0x104c, 0xac48, "yenta_socket", "Texas Instruments PCI7610" }, + { 0x104c, 0xac49, "yenta_socket", "Texas Instruments PCI7410" }, + { 0x104c, 0xac50, "yenta_socket", "Texas Instruments PCI1410" }, + { 0x104c, 0xac51, "yenta_socket", "Texas Instruments PCI1420" }, + { 0x104c, 0xac52, "yenta_socket", "Texas Instruments PCI1451" }, + { 0x104c, 0xac54, "yenta_socket", "Texas Instruments PCI1620" }, + { 0x104c, 0xac55, "yenta_socket", "Texas Instruments PCI1520" }, + { 0x104c, 0xac56, "yenta_socket", "Texas Instruments PCI1510" }, + { 0x104c, 0xac8d, "yenta_socket", "Texas Instruments|PCI7620" }, + { 0x104c, 0xac8e, "yenta_socket", "Texas Instruments|PCI7420 CardBus Controller" }, + { 0x104c, 0xac8e, "yenta_socket", "Texas Instruments PCI7420" }, + { 0x10b3, 0xb106, "yenta_socket", "SMC 34C90" }, + { 0x1179, 0x0603, "pd6729", "Toshiba ToPIC95-A" }, + { 0x1179, 0x060a, "yenta_socket", "Toshiba ToPIC95-B" }, + { 0x1179, 0x060f, "yenta_socket", "Toshiba ToPIC97" }, + { 0x1179, 0x0617, "yenta_socket", "Toshiba ToPIC100" }, + { 0x1180, 0x0465, "yenta_socket", "Ricoh RL5C465" }, + { 0x1180, 0x0466, "yenta_socket", "Ricoh RL5C466" }, + { 0x1180, 0x0475, "yenta_socket", "Ricoh RL5C475" }, + { 0x1180, 0x0476, "yenta_socket", "Ricoh RL5C476" }, + { 0x1180, 0x0477, "yenta_socket", "Ricoh RL5C477" }, + { 0x1180, 0x0478, "yenta_socket", "Ricoh RL5C478" }, + { 0x119b, 0x1221, "pd6729", "Omega Micro 82C092G" }, + { 0x1524, 0x1211, "yenta_socket", "ENE 1211" }, + { 0x1524, 0x1225, "yenta_socket", "ENE 1225" }, + { 0x1524, 0x1410, "yenta_socket", "ENE 1410" }, + { 0x1524, 0x1411, "yenta_socket", "ENE Technology CB1411" }, + { 0x1524, 0x1412, "yenta_socket", "ENE Technology Inc|CB-712/4 Cardbus Controller " }, + { 0x1524, 0x1420, "yenta_socket", "ENE 1420" }, + { 0x1524, 0x1421, "yenta_socket", "ENE Technology Inc|CB-720/2/4 Cardbus Controller" }, + { 0x1524, 0x1422, "yenta_socket", "ENE Technology Inc|CB-722/4 Cardbus Controller" }, + { 0x8086, 0x1221, "i82092", "Intel 82092AA_0" }, + { 0x8086, 0x1222, "i82092", "Intel 82092AA_1" }, +}; +#define PCI_COUNT (sizeof(pci_id)/sizeof(pci_id_t)) + +char * driver = NULL; + +static int pci_probe(void) +{ + char s[256], *name = NULL; + u_int device, vendor, i; + FILE *f; + + log_message("PCMCIA: probing PCI bus.."); + + if ((f = fopen("/proc/bus/pci/devices", "r")) != NULL) { + while (fgets(s, 256, f) != NULL) { + u_int n = strtoul(s+5, NULL, 16); + vendor = (n >> 16); device = (n & 0xffff); + if (vendor == 0x1217) { + driver = "yenta_socket"; + name = "O2 Micro|PCMCIA Controller"; + break; + } + for (i = 0; i < PCI_COUNT; i++) + if ((vendor == pci_id[i].vendor) && + (device == pci_id[i].device)) break; + if (i < PCI_COUNT) { + name = pci_id[i].name; + driver = pci_id[i].modname; + } + } + } + fclose(f); + + if (name) { + log_message("\t%s found, 2 sockets (driver %s).", name, driver); + return 0; + } else { + log_message("\tnot found."); + return -ENODEV; + } +} + +/*====================================================================*/ + +#include <sys/io.h> +typedef u_short ioaddr_t; + +#include "i82365.h" +#include "cirrus.h" +#include "vg468.h" + +static ioaddr_t i365_base = 0x03e0; + +static u_char i365_get(u_short sock, u_short reg) +{ + u_char val = I365_REG(sock, reg); + outb(val, i365_base); val = inb(i365_base+1); + return val; +} + +static void i365_set(u_short sock, u_short reg, u_char data) +{ + u_char val = I365_REG(sock, reg); + outb(val, i365_base); outb(data, i365_base+1); +} + +static void i365_bset(u_short sock, u_short reg, u_char mask) +{ + u_char d = i365_get(sock, reg); + d |= mask; + i365_set(sock, reg, d); +} + +static void i365_bclr(u_short sock, u_short reg, u_char mask) +{ + u_char d = i365_get(sock, reg); + d &= ~mask; + i365_set(sock, reg, d); +} + +int i365_probe(void) +{ + int val, sock, done; + char *name = "i82365sl"; + + log_message("PCMCIA: probing for Intel PCIC (ISA).."); + + sock = done = 0; + if (ioperm(i365_base, 4, 1)) { + log_perror("PCMCIA: ioperm"); + return -1; + } + ioperm(0x80, 1, 1); + for (; sock < 2; sock++) { + val = i365_get(sock, I365_IDENT); + switch (val) { + case 0x82: + name = "i82365sl A step"; + break; + case 0x83: + name = "i82365sl B step"; + break; + case 0x84: + name = "VLSI 82C146"; + break; + case 0x88: case 0x89: case 0x8a: + name = "IBM Clone"; + break; + case 0x8b: case 0x8c: + break; + default: + done = 1; + } + if (done) break; + } + + if (sock == 0) { + log_message("\tnot found."); + return -ENODEV; + } + + if ((sock == 2) && (strcmp(name, "VLSI 82C146") == 0)) + name = "i82365sl DF"; + + /* Check for Vadem chips */ + outb(0x0e, i365_base); + outb(0x37, i365_base); + i365_bset(0, VG468_MISC, VG468_MISC_VADEMREV); + val = i365_get(0, I365_IDENT); + if (val & I365_IDENT_VADEM) { + if ((val & 7) < 4) + name = "Vadem VG-468"; + else + name = "Vadem VG-469"; + i365_bclr(0, VG468_MISC, VG468_MISC_VADEMREV); + } + + /* Check for Cirrus CL-PD67xx chips */ + i365_set(0, PD67_CHIP_INFO, 0); + val = i365_get(0, PD67_CHIP_INFO); + if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) { + val = i365_get(0, PD67_CHIP_INFO); + if ((val & PD67_INFO_CHIP_ID) == 0) { + if (val & PD67_INFO_SLOTS) + name = "Cirrus CL-PD672x"; + else { + name = "Cirrus CL-PD6710"; + sock = 1; + } + i365_set(0, PD67_EXT_INDEX, 0xe5); + if (i365_get(0, PD67_EXT_INDEX) != 0xe5) + name = "VIA VT83C469"; + } + } + + printf("\t%s found, %d sockets.\n", name, sock); + return 0; + +} /* i365_probe */ + +/*====================================================================*/ + +#include "tcic.h" + +static u_char tcic_getb(ioaddr_t base, u_char reg) +{ + u_char val = inb(base+reg); + return val; +} + +static void tcic_setb(ioaddr_t base, u_char reg, u_char data) +{ + outb(data, base+reg); +} + +static u_short tcic_getw(ioaddr_t base, u_char reg) +{ + u_short val = inw(base+reg); + return val; +} + +static void tcic_setw(ioaddr_t base, u_char reg, u_short data) +{ + outw(data, base+reg); +} + +static u_short tcic_aux_getw(ioaddr_t base, u_short reg) +{ + u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; + tcic_setb(base, TCIC_MODE, mode); + return tcic_getw(base, TCIC_AUX); +} + +static void tcic_aux_setw(ioaddr_t base, u_short reg, u_short data) +{ + u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; + tcic_setb(base, TCIC_MODE, mode); + tcic_setw(base, TCIC_AUX, data); +} + +static int get_tcic_id(ioaddr_t base) +{ + u_short id; + tcic_aux_setw(base, TCIC_AUX_TEST, TCIC_TEST_DIAG); + id = tcic_aux_getw(base, TCIC_AUX_ILOCK); + id = (id & TCIC_ILOCKTEST_ID_MASK) >> TCIC_ILOCKTEST_ID_SH; + tcic_aux_setw(base, TCIC_AUX_TEST, 0); + return id; +} + +int tcic_probe_at(ioaddr_t base) +{ + int i; + u_short old; + + /* Anything there?? */ + for (i = 0; i < 0x10; i += 2) + if (tcic_getw(base, i) == 0xffff) + return -1; + + log_message("\tat %#3.3x: ", base); fflush(stdout); + + /* Try to reset the chip */ + tcic_setw(base, TCIC_SCTRL, TCIC_SCTRL_RESET); + tcic_setw(base, TCIC_SCTRL, 0); + + /* Can we set the addr register? */ + old = tcic_getw(base, TCIC_ADDR); + tcic_setw(base, TCIC_ADDR, 0); + if (tcic_getw(base, TCIC_ADDR) != 0) { + tcic_setw(base, TCIC_ADDR, old); + return -2; + } + + tcic_setw(base, TCIC_ADDR, 0xc3a5); + if (tcic_getw(base, TCIC_ADDR) != 0xc3a5) + return -3; + + return 2; +} + +int tcic_probe(void) +{ + int sock, id; + + log_message("PCMCIA: probing for Databook TCIC-2 (ISA).."); fflush(stdout); + + if (ioperm(TCIC_BASE, 16, 1)) { + log_perror("PCMCIA: ioperm"); + return -1; + } + ioperm(0x80, 1, 1); + sock = tcic_probe_at(TCIC_BASE); + + if (sock <= 0) { + log_message("\tnot found."); + return -ENODEV; + } + + id = get_tcic_id(TCIC_BASE); + switch (id) { + case TCIC_ID_DB86082: + log_message("DB86082"); break; + case TCIC_ID_DB86082A: + log_message("DB86082A"); break; + case TCIC_ID_DB86084: + log_message("DB86084"); break; + case TCIC_ID_DB86084A: + log_message("DB86084A"); break; + case TCIC_ID_DB86072: + log_message("DB86072"); break; + case TCIC_ID_DB86184: + log_message("DB86184"); break; + case TCIC_ID_DB86082B: + log_message("DB86082B"); break; + default: + log_message("Unknown TCIC-2 ID 0x%02x", id); + } + log_message(" found at %#6x, %d sockets.", TCIC_BASE, sock); + return 0; + +} /* tcic_probe */ + + +char * pcmcia_probe(void) +{ + if (!pci_probe()) + return driver; +#if !defined(__x86_64__) + else if (!i365_probe()) + return "pd6729"; + else if (!tcic_probe()) + return "tcic"; +#endif + else + return NULL; +} diff --git a/mdk-stage1/pcmcia/startup.c b/mdk-stage1/pcmcia/startup.c new file mode 100644 index 000000000..e9004484a --- /dev/null +++ b/mdk-stage1/pcmcia/startup.c @@ -0,0 +1,271 @@ +/* + * Startup tool for non statically mapped PCMCIA sockets + * + * (C) 2005 Dominik Brodowski <linux@brodo.de> + * + * The initial developer of the original code is David A. Hinds + * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * License: GPL v2 + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <syslog.h> +#include <unistd.h> + +#include <sysfs/libsysfs.h> + +#include "startup.h" + +/* uncomment for debug output */ +#ifdef DEBUG +#define dprintf printf +#else +#define dprintf(...) do { } while(0); +#endif + +/* Linked list of resource adjustments */ +struct adjust_list_t *root_adjust = NULL; + +/* path for config file, device scripts */ +static char *configpath = "/etc/pcmcia"; + +enum { + RESOURCE_MEM, + RESOURCE_IO, + MAX_RESOURCE_FILES +}; + + +static const char *resource_files[MAX_RESOURCE_FILES] = { + [RESOURCE_MEM] = "available_resources_mem", + [RESOURCE_IO] = "available_resources_io", +}; + +#define PATH_TO_SOCKET "/sys/class/pcmcia_socket/" + + +static int add_available_resource(unsigned int socket_no, unsigned int type, + unsigned int action, + unsigned long start, unsigned long end) +{ + char file[SYSFS_PATH_MAX]; + char content[SYSFS_PATH_MAX]; + struct sysfs_attribute *attr; + int ret; + size_t len; + + if (type >= MAX_RESOURCE_FILES) + return -EINVAL; + + if (end <= start) + return -EINVAL; + + dprintf("%d %d %d 0x%lx 0x%lx\n", socket_no, type, action, start, end); + + snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%u/%s", + socket_no, resource_files[type]); + + switch(action) { + case ADD_MANAGED_RESOURCE: + len = snprintf(content, SYSFS_PATH_MAX, + "0x%08lx - 0x%08lx", start, end); + break; + + case REMOVE_MANAGED_RESOURCE: + len = snprintf(content, SYSFS_PATH_MAX, + "- 0x%08lx - 0x%08lx", start, end); + break; + + default: + return -EINVAL; + } + + dprintf("content is %s\n", content); + + dprintf("file is %s\n", file); + + attr = sysfs_open_attribute(file); + if (!attr) + return -ENODEV; + + dprintf("open, len %d\n", len); + + ret = sysfs_write_attribute(attr, content, len); + + dprintf("ret is %d\n", ret); + + sysfs_close_attribute(attr); + + return (ret); +} + +static int setup_done(unsigned int socket_no) +{ + int ret; + char file[SYSFS_PATH_MAX]; + struct sysfs_attribute *attr; + + snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET + "pcmcia_socket%u/available_resources_setup_done", + socket_no); + + attr = sysfs_open_attribute(file); + if (!attr) + return -ENODEV; + + ret = sysfs_write_attribute(attr, "42", 2); + + sysfs_close_attribute(attr); + + return (ret); +} + + +static int disallow_irq(unsigned int socket_no, unsigned int irq) +{ + char file[SYSFS_PATH_MAX]; + char content[SYSFS_PATH_MAX]; + struct sysfs_attribute *attr; + unsigned int mask = 0xfff; + unsigned int new_mask; + int ret; + size_t len; + + if (irq >= 32) + return -EINVAL; + + len = snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET + "pcmcia_socket%u/card_irq_mask", + socket_no); + dprintf("file is %s\n", file); + + attr = sysfs_open_attribute(file); + if (!attr) + return -ENODEV; + + dprintf("open, len %d\n", len); + + ret = sysfs_read_attribute(attr); + if (ret) { + ret = -EINVAL; + goto out; + } + + if (!attr->value || (attr->len < 6)) { + ret = -EIO; + goto out; + } + + ret = sscanf(attr->value, "0x%x\n", &mask); + + new_mask = 1 << irq; + + mask &= ~new_mask; + + len = snprintf(content, SYSFS_PATH_MAX, "0x%04x", mask); + + dprintf("content is %s\n", content); + + ret = sysfs_write_attribute(attr, content, len); + + out: + sysfs_close_attribute(attr); + + return (ret); +} + + +static void load_config(void) +{ + if (chdir(configpath) != 0) { + syslog(LOG_ERR, "chdir to %s failed: %m", configpath); + exit(EXIT_FAILURE); + } + parse_configfile("config.opts"); + return; +} + + +static void adjust_resources(unsigned int socket_no) +{ + adjust_list_t *al; + + for (al = root_adjust; al; al = al->next) { + switch (al->adj.Resource) { + case RES_MEMORY_RANGE: + add_available_resource(socket_no, RESOURCE_MEM, + al->adj.Action, + al->adj.resource.memory.Base, + al->adj.resource.memory.Base + + al->adj.resource.memory.Size - 1); + break; + case RES_IO_RANGE: + add_available_resource(socket_no, RESOURCE_IO, + al->adj.Action, + al->adj.resource.io.BasePort, + al->adj.resource.io.BasePort + + al->adj.resource.io.NumPorts - 1); + break; + case RES_IRQ: + if(al->adj.Action == REMOVE_MANAGED_RESOURCE) + disallow_irq(socket_no, al->adj.resource.irq.IRQ); + break; + } + } +} + +/* mdk-stage1 +int main(int argc, char *argv[]) +{ + char *socket_no; + unsigned long socket, i; + unsigned int all_sockets = 0; + + + if ((socket_no = getenv("SOCKET_NO"))) { + socket = strtoul(socket_no, NULL, 0); + } else if (argc == 2) { + socket = strtoul(argv[1], NULL, 0); + } else if (argc == 1) { + socket = 0; + all_sockets = 1; + } else { + return -EINVAL; + } + + load_config(); + + for (i = 0; i < MAX_SOCKS; i++) { + if ((socket != i) && (!all_sockets)) + continue; + + adjust_resources(i); + setup_done(i); + } + + return 0; +} +*/ + +void pcmcia_socket_startup(int socket_no) { + unsigned long i; + unsigned int all_sockets = 0; + + if (socket_no == -1) + all_sockets = 1; + + load_config(); + + for (i = 0; i < MAX_SOCKS; i++) { + if ((socket_no != i) && (!all_sockets)) + continue; + + adjust_resources(i); + setup_done(i); + } +} diff --git a/mdk-stage1/pcmcia/startup.h b/mdk-stage1/pcmcia/startup.h new file mode 100644 index 000000000..ba6af2c15 --- /dev/null +++ b/mdk-stage1/pcmcia/startup.h @@ -0,0 +1,54 @@ +/* + * Startup tool for non statically mapped PCMCIA sockets + * + * The initial developer of the original code is David A. Hinds + * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * License: GPL v2 + * + */ + +#define MAX_SOCKS 8 +#define MAX_BINDINGS 4 +#define MAX_MODULES 4 + +/* for AdjustResourceInfo */ +typedef struct adjust_t { + unsigned int Action; + unsigned int Resource; + unsigned int Attributes; + union { + struct memory { + unsigned long Base; + unsigned long Size; + } memory; + struct io { + unsigned long BasePort; + unsigned long NumPorts; + unsigned int IOAddrLines; + } io; + struct irq { + unsigned int IRQ; + } irq; + } resource; +} adjust_t; + + +typedef struct adjust_list_t { + adjust_t adj; + struct adjust_list_t *next; +} adjust_list_t; + + +extern adjust_list_t *root_adjust; + +int parse_configfile(char *fn); + + +#define RES_MEMORY_RANGE 1 +#define RES_IO_RANGE 2 +#define RES_IRQ 3 +#define RES_RESERVED 0x10 +#define REMOVE_MANAGED_RESOURCE 1 +#define ADD_MANAGED_RESOURCE 2 diff --git a/mdk-stage1/pcmcia/tcic.h b/mdk-stage1/pcmcia/tcic.h index 92347cef6..cad193885 100644 --- a/mdk-stage1/pcmcia/tcic.h +++ b/mdk-stage1/pcmcia/tcic.h @@ -1,5 +1,5 @@ /* - * tcic.h 1.14 2000/06/12 21:29:37 + * tcic.h 1.15 2001/08/24 12:15:34 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by diff --git a/mdk-stage1/pcmcia/version.h b/mdk-stage1/pcmcia/version.h index 7a567ea2c..3be8f28bc 100644 --- a/mdk-stage1/pcmcia/version.h +++ b/mdk-stage1/pcmcia/version.h @@ -1,4 +1,4 @@ -/* version.h 1.95 2000/11/07 22:55:28 (David Hinds) */ +/* version.h 1.101 2001/08/09 12:29:14 (David Hinds) */ -#define CS_RELEASE "3.1.23" -#define CS_RELEASE_CODE 0x3117 +#define CS_RELEASE "3.1.29" +#define CS_RELEASE_CODE 0x311d diff --git a/mdk-stage1/pcmcia/vg468.h b/mdk-stage1/pcmcia/vg468.h index bb5faae87..23890cd07 100644 --- a/mdk-stage1/pcmcia/vg468.h +++ b/mdk-stage1/pcmcia/vg468.h @@ -1,5 +1,5 @@ /* - * vg468.h 1.13 2000/06/12 21:29:37 + * vg468.h 1.14 2001/08/24 12:15:34 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -103,10 +103,4 @@ /* Flags for VG469_EXT_MODE_B */ #define VG469_MODE_B_3V 0x01 /* 3.3v for socket B */ -/* Data structure for tracking vendor-specific state */ -typedef struct vg46x_state_t { - u_char ctl; /* VG468_CTL */ - u_char ema; /* VG468_EXT_MODE_A */ -} vg46x_state_t; - #endif /* _LINUX_VG468_H */ diff --git a/mdk-stage1/pcmcia/yacc_config.c b/mdk-stage1/pcmcia/yacc_config.c deleted file mode 100644 index e68e17cb3..000000000 --- a/mdk-stage1/pcmcia/yacc_config.c +++ /dev/null @@ -1,1017 +0,0 @@ -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING (yyerrflag!=0) -#define YYPREFIX "yy" -#line 2 "yacc_config.y" -/* - * yacc_config.y 1.51 2000/06/12 21:33:02 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License - * at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and - * limitations under the License. - * - * The initial developer of the original code is David A. Hinds - * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * Alternatively, the contents of this file may be used under the - * terms of the GNU Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the - * above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use - * your version of this file under the MPL, indicate your decision by - * deleting the provisions above and replace them with the notice and - * other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file - * under either the MPL or the GPL. - */ - -#include <stdlib.h> -#include <stdarg.h> -#include <stdio.h> -#include <string.h> -#include <syslog.h> -#include <sys/types.h> - -#include <pcmcia/cs_types.h> -#include <pcmcia/cs.h> -#include <pcmcia/cistpl.h> -#include <pcmcia/ds.h> - -#include "cardmgr.h" - -/* If bison: generate nicer error messages */ -#define YYERROR_VERBOSE 1 - -/* from lex_config, for nice error messages */ -extern char *current_file; -extern int current_lineno; - -void yyerror(char *msg, ...); - -static int add_binding(card_info_t *card, char *name, int fn); -static int add_module(device_info_t *card, char *name); - -#line 65 "yacc_config.y" -typedef union { - char *str; - u_long num; - struct device_info_t *device; - struct card_info_t *card; - struct mtd_ident_t *mtd; - struct adjust_list_t *adjust; -} YYSTYPE; -#line 77 "y.tab.c" -#define DEVICE 257 -#define CARD 258 -#define ANONYMOUS 259 -#define TUPLE 260 -#define MANFID 261 -#define VERSION 262 -#define FUNCTION 263 -#define PCI 264 -#define BIND 265 -#define CIS 266 -#define TO 267 -#define NEEDS_MTD 268 -#define MODULE 269 -#define OPTS 270 -#define CLASS 271 -#define REGION 272 -#define JEDEC 273 -#define DTYPE 274 -#define DEFAULT 275 -#define MTD 276 -#define INCLUDE 277 -#define EXCLUDE 278 -#define RESERVE 279 -#define IRQ_NO 280 -#define PORT 281 -#define MEMORY 282 -#define STRING 283 -#define NUMBER 284 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 2, 2, 2, 3, 3, 3, 3, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 9, - 10, 11, 12, 12, 13, 15, 14, 14, 14, 14, - 4, 21, 5, 5, 5, 6, 16, 16, 16, 16, - 18, 17, 19, 20, 20, 22, -}; -short yylen[] = { 2, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 3, 2, 4, 4, 2, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 7, - 5, 5, 3, 3, 3, 3, 3, 5, 3, 5, - 2, 4, 3, 3, 3, 3, 2, 1, 1, 1, - 3, 4, 2, 3, 3, 4, -}; -short yydefred[] = { 1, - 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 17, 0, 19, 0, 21, 22, 23, 24, - 0, 26, 0, 28, 0, 49, 48, 50, 0, 6, - 7, 16, 20, 0, 47, 0, 0, 0, 0, 9, - 10, 11, 0, 41, 0, 0, 0, 0, 29, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 0, 0, 0, 0, 13, 0, 0, 12, 43, - 46, 44, 45, 0, 0, 33, 35, 0, 0, 36, - 34, 0, 0, 51, 54, 55, 42, 56, 0, 0, - 0, 0, 0, 0, 0, 52, 14, 15, 0, 31, - 32, 38, 40, 0, 30, -}; -short yydgoto[] = { 1, - 11, 40, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, -}; -short yysindex[] = { 0, - -250, 0, -279, -278, -274, -265, -259, -242, -242, -242, - -10, -248, 0, -44, 0, -249, 0, 0, 0, 0, - -9, 0, -3, 0, -243, 0, 0, 0, -233, 0, - 0, 0, 0, -228, 0, -227, -240, -238, -237, 0, - 0, 0, -242, 0, -235, -232, -231, -230, 0, -234, - -229, -226, -225, -224, -222, -221, -220, -219, -218, -217, - 0, -215, -213, -212, -211, 0, 9, 11, 0, 0, - 0, 0, 0, 14, 21, 0, 0, 30, -192, 0, - 0, -191, -207, 0, 0, 0, 0, 0, -206, -205, - -204, -203, -202, -201, -200, 0, 0, 0, 41, 0, - 0, 0, 0, -197, 0, -}; -short yyrindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 107, 149, 0, 90, 0, 124, 0, 0, 0, 0, - 49, 0, 73, 0, 0, 0, 0, 0, 141, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; -short yygindex[] = { 0, - 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#define YYTABLESIZE 428 -short yytable[] = { 48, - 37, 41, 42, 32, 33, 2, 3, 4, 34, 49, - 50, 51, 52, 53, 54, 55, 56, 35, 5, 44, - 45, 6, 46, 36, 39, 7, 8, 9, 10, 59, - 60, 61, 62, 43, 57, 69, 63, 37, 38, 39, - 58, 64, 65, 66, 37, 67, 68, 70, 25, 74, - 71, 72, 73, 89, 75, 90, 76, 91, 77, 78, - 79, 80, 81, 82, 92, 83, 84, 85, 39, 86, - 87, 88, 27, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 0, 0, 0, 18, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 0, 0, 37, - 0, 0, 37, 0, 0, 0, 37, 37, 37, 37, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 0, 0, 39, 0, 0, 39, 0, 0, 0, - 39, 39, 39, 39, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 0, 0, 25, 0, 0, - 25, 0, 0, 0, 25, 25, 25, 25, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, - 0, 27, 0, 0, 27, 18, 18, 18, 27, 27, - 27, 27, 0, 0, 0, 0, 0, 18, 18, 0, - 18, 18, 2, 2, 2, 18, 18, 18, 18, 0, - 0, 0, 0, 0, 0, 2, 0, 0, 2, 5, - 5, 5, 2, 2, 2, 2, 0, 0, 0, 0, - 0, 0, 5, 0, 0, 5, 4, 4, 4, 5, - 5, 5, 5, 0, 3, 3, 3, 0, 0, 4, - 0, 0, 4, 0, 0, 0, 4, 4, 4, 4, - 3, 0, 0, 0, 3, 3, 3, 3, -}; -short yycheck[] = { 44, - 0, 9, 10, 283, 283, 256, 257, 258, 283, 259, - 260, 261, 262, 263, 264, 265, 266, 283, 269, 268, - 269, 272, 271, 283, 0, 276, 277, 278, 279, 273, - 274, 275, 276, 44, 44, 43, 270, 280, 281, 282, - 44, 270, 270, 284, 44, 284, 284, 283, 0, 284, - 283, 283, 283, 45, 284, 45, 283, 44, 284, 284, - 283, 283, 283, 283, 44, 284, 284, 283, 44, 283, - 283, 283, 0, 44, 267, 267, 284, 284, 284, 284, - 284, 284, 284, 284, 44, 283, -1, -1, -1, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 270, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, - 260, 261, 262, 263, 264, 265, 266, -1, -1, 269, - -1, -1, 272, -1, -1, -1, 276, 277, 278, 279, - 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, - 266, -1, -1, 269, -1, -1, 272, -1, -1, -1, - 276, 277, 278, 279, 256, 257, 258, 259, 260, 261, - 262, 263, 264, 265, 266, -1, -1, 269, -1, -1, - 272, -1, -1, -1, 276, 277, 278, 279, 256, 257, - 258, 259, 260, 261, 262, 263, 264, 265, 266, -1, - -1, 269, -1, -1, 272, 256, 257, 258, 276, 277, - 278, 279, -1, -1, -1, -1, -1, 268, 269, -1, - 271, 272, 256, 257, 258, 276, 277, 278, 279, -1, - -1, -1, -1, -1, -1, 269, -1, -1, 272, 256, - 257, 258, 276, 277, 278, 279, -1, -1, -1, -1, - -1, -1, 269, -1, -1, 272, 256, 257, 258, 276, - 277, 278, 279, -1, 256, 257, 258, -1, -1, 269, - -1, -1, 272, -1, -1, -1, 276, 277, 278, 279, - 272, -1, -1, -1, 276, 277, 278, 279, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 284 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,"','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"DEVICE","CARD", -"ANONYMOUS","TUPLE","MANFID","VERSION","FUNCTION","PCI","BIND","CIS","TO", -"NEEDS_MTD","MODULE","OPTS","CLASS","REGION","JEDEC","DTYPE","DEFAULT","MTD", -"INCLUDE","EXCLUDE","RESERVE","IRQ_NO","PORT","MEMORY","STRING","NUMBER", -}; -char *yyrule[] = { -"$accept : list", -"list :", -"list : list adjust", -"list : list device", -"list : list mtd", -"list : list card", -"list : list opts", -"list : list mtd_opts", -"list : list error", -"adjust : INCLUDE resource", -"adjust : EXCLUDE resource", -"adjust : RESERVE resource", -"adjust : adjust ',' resource", -"resource : IRQ_NO NUMBER", -"resource : PORT NUMBER '-' NUMBER", -"resource : MEMORY NUMBER '-' NUMBER", -"device : DEVICE STRING", -"device : needs_mtd", -"device : module", -"device : class", -"card : CARD STRING", -"card : anonymous", -"card : tuple", -"card : manfid", -"card : pci", -"card : version", -"card : function", -"card : bind", -"card : cis", -"anonymous : card ANONYMOUS", -"tuple : card TUPLE NUMBER ',' NUMBER ',' STRING", -"manfid : card MANFID NUMBER ',' NUMBER", -"pci : card PCI NUMBER ',' NUMBER", -"version : card VERSION STRING", -"version : version ',' STRING", -"function : card FUNCTION NUMBER", -"cis : card CIS STRING", -"bind : card BIND STRING", -"bind : card BIND STRING TO NUMBER", -"bind : bind ',' STRING", -"bind : bind ',' STRING TO NUMBER", -"needs_mtd : device NEEDS_MTD", -"opts : MODULE STRING OPTS STRING", -"module : device MODULE STRING", -"module : module OPTS STRING", -"module : module ',' STRING", -"class : device CLASS STRING", -"region : REGION STRING", -"region : dtype", -"region : jedec", -"region : default", -"dtype : region DTYPE NUMBER", -"jedec : region JEDEC NUMBER NUMBER", -"default : region DEFAULT", -"mtd : region MTD STRING", -"mtd : mtd OPTS STRING", -"mtd_opts : MTD STRING OPTS STRING", -}; -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#line 468 "yacc_config.y" -void yyerror(char *msg, ...) -{ - va_list ap; - char str[256]; - - va_start(ap, msg); - sprintf(str, "config error, file '%s' line %d: ", - current_file, current_lineno); - vsprintf(str+strlen(str), msg, ap); -#if YYDEBUG - fprintf(stderr, "%s\n", str); -#else - syslog(LOG_ERR, "%s", str); -#endif - va_end(ap); -} - -static int add_binding(card_info_t *card, char *name, int fn) -{ - device_info_t *dev = root_device; - if (card->bindings == MAX_BINDINGS) { - yyerror("too many bindings\n"); - return -1; - } - for (; dev; dev = dev->next) - if (strcmp((char *)dev->dev_info, name) == 0) break; - if (dev == NULL) { - yyerror("unknown device: %s", name); - return -1; - } - card->device[card->bindings] = dev; - card->dev_fn[card->bindings] = fn; - card->bindings++; - free(name); - return 0; -} - -static int add_module(device_info_t *dev, char *name) -{ - if (dev->modules == MAX_MODULES) { - yyerror("too many modules"); - return -1; - } - dev->module[dev->modules] = name; - dev->opts[dev->modules] = NULL; - dev->modules++; - return 0; -} - -int yylex(void); - -#if YYDEBUG -adjust_list_t *root_adjust = NULL; -device_info_t *root_device = NULL; -card_info_t *root_card = NULL, *blank_card = NULL, *root_func = NULL; -mtd_ident_t *root_mtd = NULL, *default_mtd = NULL; - - -void main(int argc, char *argv[]) -{ - yydebug = 1; - if (argc > 1) - parse_configfile(argv[1]); -} -#endif -#line 426 "y.tab.c" -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse(void) -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate])) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 2: -#line 84 "yacc_config.y" -{ - adjust_list_t **tail = &root_adjust; - while (*tail != NULL) tail = &(*tail)->next; - *tail = yyvsp[0].adjust; - } -break; -case 3: -#line 90 "yacc_config.y" -{ - yyvsp[0].device->next = root_device; - root_device = yyvsp[0].device; - } -break; -case 4: -#line 95 "yacc_config.y" -{ - if (yyvsp[0].mtd->mtd_type == 0) { - yyerror("no ID method for this card"); - YYERROR; - } - if (yyvsp[0].mtd->module == NULL) { - yyerror("no MTD module specified"); - YYERROR; - } - yyvsp[0].mtd->next = root_mtd; - root_mtd = yyvsp[0].mtd; - } -break; -case 5: -#line 108 "yacc_config.y" -{ - if (yyvsp[0].card->ident_type == 0) { - yyerror("no ID method for this card"); - YYERROR; - } - if (yyvsp[0].card->bindings == 0) { - yyerror("no function bindings"); - YYERROR; - } - if (yyvsp[0].card->ident_type == FUNC_IDENT) { - yyvsp[0].card->next = root_func; - root_func = yyvsp[0].card; - } else { - yyvsp[0].card->next = root_card; - root_card = yyvsp[0].card; - } - } -break; -case 9: -#line 131 "yacc_config.y" -{ - yyvsp[0].adjust->adj.Action = ADD_MANAGED_RESOURCE; - yyval.adjust = yyvsp[0].adjust; - } -break; -case 10: -#line 136 "yacc_config.y" -{ - yyvsp[0].adjust->adj.Action = REMOVE_MANAGED_RESOURCE; - yyval.adjust = yyvsp[0].adjust; - } -break; -case 11: -#line 141 "yacc_config.y" -{ - yyvsp[0].adjust->adj.Action = ADD_MANAGED_RESOURCE; - yyvsp[0].adjust->adj.Attributes |= RES_RESERVED; - yyval.adjust = yyvsp[0].adjust; - } -break; -case 12: -#line 147 "yacc_config.y" -{ - yyvsp[0].adjust->adj.Action = yyvsp[-2].adjust->adj.Action; - yyvsp[0].adjust->adj.Attributes = yyvsp[-2].adjust->adj.Attributes; - yyvsp[0].adjust->next = yyvsp[-2].adjust; - yyval.adjust = yyvsp[0].adjust; - } -break; -case 13: -#line 156 "yacc_config.y" -{ - yyval.adjust = calloc(sizeof(adjust_list_t), 1); - yyval.adjust->adj.Resource = RES_IRQ; - yyval.adjust->adj.resource.irq.IRQ = yyvsp[0].num; - } -break; -case 14: -#line 162 "yacc_config.y" -{ - if ((yyvsp[0].num < yyvsp[-2].num) || (yyvsp[0].num > 0xffff)) { - yyerror("invalid port range"); - YYERROR; - } - yyval.adjust = calloc(sizeof(adjust_list_t), 1); - yyval.adjust->adj.Resource = RES_IO_RANGE; - yyval.adjust->adj.resource.io.BasePort = yyvsp[-2].num; - yyval.adjust->adj.resource.io.NumPorts = yyvsp[0].num - yyvsp[-2].num + 1; - } -break; -case 15: -#line 173 "yacc_config.y" -{ - if (yyvsp[0].num < yyvsp[-2].num) { - yyerror("invalid address range"); - YYERROR; - } - yyval.adjust = calloc(sizeof(adjust_list_t), 1); - yyval.adjust->adj.Resource = RES_MEMORY_RANGE; - yyval.adjust->adj.resource.memory.Base = yyvsp[-2].num; - yyval.adjust->adj.resource.memory.Size = yyvsp[0].num - yyvsp[-2].num + 1; - } -break; -case 16: -#line 186 "yacc_config.y" -{ - yyval.device = calloc(sizeof(device_info_t), 1); - yyval.device->refs = 1; - strcpy(yyval.device->dev_info, yyvsp[0].str); - free(yyvsp[0].str); - } -break; -case 20: -#line 198 "yacc_config.y" -{ - yyval.card = calloc(sizeof(card_info_t), 1); - yyval.card->refs = 1; - yyval.card->name = yyvsp[0].str; - } -break; -case 29: -#line 214 "yacc_config.y" -{ - if (yyvsp[-1].card->ident_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - if (blank_card) { - yyerror("Anonymous card already defined"); - YYERROR; - } - yyvsp[-1].card->ident_type = BLANK_IDENT; - blank_card = yyvsp[-1].card; - } -break; -case 30: -#line 229 "yacc_config.y" -{ - if (yyvsp[-6].card->ident_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - yyvsp[-6].card->ident_type = TUPLE_IDENT; - yyvsp[-6].card->id.tuple.code = yyvsp[-4].num; - yyvsp[-6].card->id.tuple.ofs = yyvsp[-2].num; - yyvsp[-6].card->id.tuple.info = yyvsp[0].str; - } -break; -case 31: -#line 242 "yacc_config.y" -{ - if (yyvsp[-4].card->ident_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - yyvsp[-4].card->ident_type = MANFID_IDENT; - yyvsp[-4].card->id.manfid.manf = yyvsp[-2].num; - yyvsp[-4].card->id.manfid.card = yyvsp[0].num; - } -break; -case 32: -#line 253 "yacc_config.y" -{ - if (yyvsp[-4].card->ident_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - yyvsp[-4].card->ident_type = PCI_IDENT; - yyvsp[-4].card->id.manfid.manf = yyvsp[-2].num; - yyvsp[-4].card->id.manfid.card = yyvsp[0].num; - } -break; -case 33: -#line 264 "yacc_config.y" -{ - if (yyvsp[-2].card->ident_type != 0) { - yyerror("ID method already defined\n"); - YYERROR; - } - yyvsp[-2].card->ident_type = VERS_1_IDENT; - yyvsp[-2].card->id.vers.ns = 1; - yyvsp[-2].card->id.vers.pi[0] = yyvsp[0].str; - } -break; -case 34: -#line 274 "yacc_config.y" -{ - if (yyvsp[-2].card->id.vers.ns == 4) { - yyerror("too many version strings"); - YYERROR; - } - yyvsp[-2].card->id.vers.pi[yyvsp[-2].card->id.vers.ns] = yyvsp[0].str; - yyvsp[-2].card->id.vers.ns++; - } -break; -case 35: -#line 285 "yacc_config.y" -{ - if (yyvsp[-2].card->ident_type != 0) { - yyerror("ID method already defined\n"); - YYERROR; - } - yyvsp[-2].card->ident_type = FUNC_IDENT; - yyvsp[-2].card->id.func.funcid = yyvsp[0].num; - } -break; -case 36: -#line 296 "yacc_config.y" -{ yyvsp[-2].card->cis_file = strdup(yyvsp[0].str); } -break; -case 37: -#line 300 "yacc_config.y" -{ - if (add_binding(yyvsp[-2].card, yyvsp[0].str, 0) != 0) - YYERROR; - } -break; -case 38: -#line 305 "yacc_config.y" -{ - if (add_binding(yyvsp[-4].card, yyvsp[-2].str, yyvsp[0].num) != 0) - YYERROR; - } -break; -case 39: -#line 310 "yacc_config.y" -{ - if (add_binding(yyvsp[-2].card, yyvsp[0].str, 0) != 0) - YYERROR; - } -break; -case 40: -#line 315 "yacc_config.y" -{ - if (add_binding(yyvsp[-4].card, yyvsp[-2].str, yyvsp[0].num) != 0) - YYERROR; - } -break; -case 41: -#line 322 "yacc_config.y" -{ - yyvsp[-1].device->needs_mtd = 1; - } -break; -case 42: -#line 328 "yacc_config.y" -{ - device_info_t *d; - int i, found = 0; - for (d = root_device; d; d = d->next) { - for (i = 0; i < d->modules; i++) - if (strcmp(yyvsp[-2].str, d->module[i]) == 0) break; - if (i < d->modules) { - if (d->opts[i]) - free(d->opts[i]); - d->opts[i] = strdup(yyvsp[0].str); - found = 1; - } - } - free(yyvsp[-2].str); free(yyvsp[0].str); - if (!found) { - yyerror("module name not found!"); - YYERROR; - } - } -break; -case 43: -#line 350 "yacc_config.y" -{ - if (add_module(yyvsp[-2].device, yyvsp[0].str) != 0) - YYERROR; - } -break; -case 44: -#line 355 "yacc_config.y" -{ - if (yyvsp[-2].device->opts[yyvsp[-2].device->modules-1] == NULL) { - yyvsp[-2].device->opts[yyvsp[-2].device->modules-1] = yyvsp[0].str; - } else { - yyerror("too many options"); - YYERROR; - } - } -break; -case 45: -#line 364 "yacc_config.y" -{ - if (add_module(yyvsp[-2].device, yyvsp[0].str) != 0) - YYERROR; - } -break; -case 46: -#line 371 "yacc_config.y" -{ - if (yyvsp[-2].device->class != NULL) { - yyerror("extra class string"); - YYERROR; - } - yyvsp[-2].device->class = yyvsp[0].str; - } -break; -case 47: -#line 381 "yacc_config.y" -{ - yyval.mtd = calloc(sizeof(mtd_ident_t), 1); - yyval.mtd->refs = 1; - yyval.mtd->name = yyvsp[0].str; - } -break; -case 51: -#line 392 "yacc_config.y" -{ - if (yyvsp[-2].mtd->mtd_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - yyvsp[-2].mtd->mtd_type = DTYPE_MTD; - yyvsp[-2].mtd->dtype = yyvsp[0].num; - } -break; -case 52: -#line 403 "yacc_config.y" -{ - if (yyvsp[-3].mtd->mtd_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - yyvsp[-3].mtd->mtd_type = JEDEC_MTD; - yyvsp[-3].mtd->jedec_mfr = yyvsp[-1].num; - yyvsp[-3].mtd->jedec_info = yyvsp[0].num; - } -break; -case 53: -#line 415 "yacc_config.y" -{ - if (yyvsp[-1].mtd->mtd_type != 0) { - yyerror("ID method already defined"); - YYERROR; - } - if (default_mtd) { - yyerror("Default MTD already defined"); - YYERROR; - } - yyvsp[-1].mtd->mtd_type = DEFAULT_MTD; - default_mtd = yyvsp[-1].mtd; - } -break; -case 54: -#line 430 "yacc_config.y" -{ - if (yyvsp[-2].mtd->module != NULL) { - yyerror("extra MTD entry"); - YYERROR; - } - yyvsp[-2].mtd->module = yyvsp[0].str; - } -break; -case 55: -#line 438 "yacc_config.y" -{ - if (yyvsp[-2].mtd->opts == NULL) { - yyvsp[-2].mtd->opts = yyvsp[0].str; - } else { - yyerror("too many options"); - YYERROR; - } - } -break; -case 56: -#line 449 "yacc_config.y" -{ - mtd_ident_t *m; - int found = 0; - for (m = root_mtd; m; m = m->next) - if (strcmp(yyvsp[-2].str, m->module) == 0) break; - if (m) { - if (m->opts) free(m->opts); - m->opts = strdup(yyvsp[0].str); - found = 1; - } - free(yyvsp[-2].str); free(yyvsp[0].str); - if (!found) { - yyerror("MTD name not found!"); - YYERROR; - } - } -break; -#line 966 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/mdk-stage1/pcmcia/yacc_config.h b/mdk-stage1/pcmcia/yacc_config.h deleted file mode 100644 index b4902c8e6..000000000 --- a/mdk-stage1/pcmcia/yacc_config.h +++ /dev/null @@ -1,37 +0,0 @@ -#define DEVICE 257 -#define CARD 258 -#define ANONYMOUS 259 -#define TUPLE 260 -#define MANFID 261 -#define VERSION 262 -#define FUNCTION 263 -#define PCI 264 -#define BIND 265 -#define CIS 266 -#define TO 267 -#define NEEDS_MTD 268 -#define MODULE 269 -#define OPTS 270 -#define CLASS 271 -#define REGION 272 -#define JEDEC 273 -#define DTYPE 274 -#define DEFAULT 275 -#define MTD 276 -#define INCLUDE 277 -#define EXCLUDE 278 -#define RESERVE 279 -#define IRQ_NO 280 -#define PORT 281 -#define MEMORY 282 -#define STRING 283 -#define NUMBER 284 -typedef union { - char *str; - u_long num; - struct device_info_t *device; - struct card_info_t *card; - struct mtd_ident_t *mtd; - struct adjust_list_t *adjust; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/mdk-stage1/pcmcia/yacc_config.y b/mdk-stage1/pcmcia/yacc_config.y new file mode 100644 index 000000000..c33f397d6 --- /dev/null +++ b/mdk-stage1/pcmcia/yacc_config.y @@ -0,0 +1,133 @@ +%{ +/* + * Startup tool for non statically mapped PCMCIA sockets - config file parsing + * + * (C) 2005 Dominik Brodowski <linux@brodo.de> + * + * The initial developer of the original code is David A. Hinds + * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * License: GPL v2 + */ + +#include <stdlib.h> +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <syslog.h> +#include <sys/types.h> + +#include "startup.h" + +/* If bison: generate nicer error messages */ +#define YYERROR_VERBOSE 1 + +/* from lex_config, for nice error messages */ +extern char *current_file; +extern int current_lineno; + +extern int yylex(void); /* mdk-stage1 */ + +void yyerror(const char *msg, ...); + +%} + +%token DEVICE CARD ANONYMOUS TUPLE MANFID VERSION FUNCTION PCI +%token BIND CIS TO NEEDS_MTD MODULE OPTS CLASS +%token REGION JEDEC DTYPE DEFAULT MTD +%token INCLUDE EXCLUDE RESERVE IRQ_NO PORT MEMORY +%token STRING NUMBER SOURCE + +%union { + char *str; + u_long num; + struct adjust_list_t *adjust; +} + +%type <str> STRING +%type <num> NUMBER +%type <adjust> adjust resource +%% +list: /* nothing */ + | list adjust + { + adjust_list_t **tail = &root_adjust; + while (*tail != NULL) tail = &(*tail)->next; + *tail = $2; + } + ; + +adjust: INCLUDE resource + { + $2->adj.Action = ADD_MANAGED_RESOURCE; + $$ = $2; + } + | EXCLUDE resource + { + $2->adj.Action = REMOVE_MANAGED_RESOURCE; + $$ = $2; + } + | RESERVE resource + { + $2->adj.Action = ADD_MANAGED_RESOURCE; + $2->adj.Attributes |= RES_RESERVED; + $$ = $2; + } + | adjust ',' resource + { + $3->adj.Action = $1->adj.Action; + $3->adj.Attributes = $1->adj.Attributes; + $3->next = $1; + $$ = $3; + } + ; + +resource: IRQ_NO NUMBER + { + $$ = calloc(sizeof(adjust_list_t), 1); + $$->adj.Resource = RES_IRQ; + $$->adj.resource.irq.IRQ = $2; + } + | PORT NUMBER '-' NUMBER + { + if (($4 < $2) || ($4 > 0xffff)) { + yyerror("invalid port range 0x%x-0x%x", $2, $4); + YYERROR; + } + $$ = calloc(sizeof(adjust_list_t), 1); + $$->adj.Resource = RES_IO_RANGE; + $$->adj.resource.io.BasePort = $2; + $$->adj.resource.io.NumPorts = $4 - $2 + 1; + } + | MEMORY NUMBER '-' NUMBER + { + if ($4 < $2) { + yyerror("invalid address range 0x%x-0x%x", $2, $4); + YYERROR; + } + $$ = calloc(sizeof(adjust_list_t), 1); + $$->adj.Resource = RES_MEMORY_RANGE; + $$->adj.resource.memory.Base = $2; + $$->adj.resource.memory.Size = $4 - $2 + 1; + } + ; + +%% +void yyerror(const char *msg, ...) +{ + va_list ap; + char str[256]; + + va_start(ap, msg); + sprintf(str, "error in file '%s' line %d: ", + current_file, current_lineno); + vsprintf(str+strlen(str), msg, ap); +#if YYDEBUG + fprintf(stderr, "%s\n", str); +#else + syslog(LOG_ERR, "%s", str); +#endif + va_end(ap); +} + |
