/* * pcmcia.c - pcmcia functionality * * Erik Troan * Matt Wilson * Michael Fulbright * Jeremy Katz * Bill Nottingham * * Copyright 1999 - 2005 Red Hat, Inc. * * This software may be freely redistributed under the terms of the GNU * General 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. */ #include #include #include #include #include #include #include #include "loader.h" #include "loadermisc.h" #include "log.h" #include "modules.h" /* boot flags */ extern int flags; char * getPcicController() { struct device ** devices; static int probed = 0; static char * pcic = NULL; if (!probed) { probed = 1; devices = probeDevices(CLASS_SOCKET, BUS_UNSPEC, 0); if (devices) { int x; for (x = 0; devices[x]; x++) { if (devices[x]->driver) { char *tmp; logMessage(DEBUGLVL, "found pcmcia adapter %s", devices[x]->driver); if (!pcic) tmp = strdup(devices[x]->driver); else { tmp = sdupprintf("%s:%s",pcic,devices[x]->driver); free(pcic); } pcic = tmp; } } } if (!pcic) { logMessage(DEBUGLVL, "no pcic controller found"); } return pcic; } else { return pcic; } } int startupPcmciaControllers() { char *adj_io[] = { "0x00000100 - 0x000003af", "0x000003bb - 0x000004cf", "0x000004d8 - 0x000004ff", "0x00000a00 - 0x00000aff", "0x00000c00 - 0x00000cff", "0x00004000 - 0x00008fff", NULL }; char *adj_mem[] = { "0x000c0000 - 0x000fffff", "0x60000000 - 0x60ffffff", "0xa0000000 - 0xa0ffffff", "0xc0200000 - 0xcfffffff", "0xe8000000 - 0xefffffff", NULL }; char path[128]; int x; for (x = 0; ; x++) { int y; FILE *f; sprintf(path,"/sys/class/pcmcia_socket/pcmcia_socket%d/available_resources_io", x); f = fopen(path, "w"); if (!f) break; for (y = 0; adj_io[y]; y++) { fprintf(f, "%s\n", adj_io[y]); } fclose(f); sprintf(path,"/sys/class/pcmcia_socket/pcmcia_socket%d/available_resources_mem", x); f = fopen(path, "w"); if (!f) break; for (y = 0; adj_mem[y]; y++) { fprintf(f, "%s\n", adj_mem[y]); } fclose(f); sprintf(path,"/sys/class/pcmcia_socket/pcmcia_socket%d/available_resources_setup_done", x); f = fopen(path,"w"); if (!f) break; fprintf(f,"1\n"); fclose(f); } return 0; } int initializePcmciaController(moduleList modLoaded, moduleDeps modDeps, moduleInfoSet modInfo) { char * pcic = NULL; char * mods; if (FL_NOPCMCIA(flags) || FL_TESTING(flags)) return 0; pcic = getPcicController(); if (!pcic) return 0; mods = sdupprintf("pcmcia_core:%s:pcmcia", pcic); mlLoadModuleSet(mods, modLoaded, modDeps, modInfo); startupPcmciaControllers(); return 0; }