From: Markus G. <ger...@us...> - 2004-05-30 16:29:01
|
Update of /cvsroot/mpio/mpio/libmpio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24870/libmpio/src Modified Files: fat.c mpio.c Added Files: mmc.c mmc.h Log Message: added Roberts MMC code (step 1) --- NEW FILE: mmc.h --- /* * $Id: mmc.h,v 1.1 2004/05/30 16:28:52 germeier Exp $ * * libmpio - a library for accessing Digit@lways MPIO players * Copyright (C) 2004 Robert Kellington, Markus Germeier * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc.,g 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _MPIO_MMC_H_ #define _MPIO_MMC_H_ #include "defs.h" #ifdef __cplusplus extern "C" { #endif extern mpio_disk_phy_t MPIO_DISK_GEO_001; extern mpio_disk_phy_t MPIO_DISK_GEO_002; extern mpio_disk_phy_t MPIO_DISK_GEO_004; extern mpio_disk_phy_t MPIO_DISK_GEO_008; extern mpio_disk_phy_t MPIO_DISK_GEO_016; extern mpio_disk_phy_t MPIO_DISK_GEO_032; extern mpio_disk_phy_t MPIO_DISK_GEO_064; extern mpio_disk_phy_t MPIO_DISK_GEO_128; extern mpio_disk_phy_t MPIO_DISK_GEO_256; /* get our configuration for MMC cards right */ BYTE mpio_mmc_detect_memory(mpio_t *m, mpio_mem_t mem); #ifdef __cplusplus } #endif #endif /* _MPIO_MMC_H_ */ Index: mpio.c =================================================================== RCS file: /cvsroot/mpio/mpio/libmpio/src/mpio.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mpio.c 24 Apr 2004 16:09:58 -0000 1.15 --- mpio.c 30 May 2004 16:28:52 -0000 1.16 *************** *** 161,164 **** --- 161,165 ---- /* init main memory parameters */ + sm->mmc = 0; sm->manufacturer = m->version[i_offset]; sm->id = m->version[i_offset + 1]; *************** *** 250,261 **** BYTE e_offset = 0x20; /* heuristic to find the right offset for the external memory */ while((e_offset < 0x3a) && !(mpio_id_valid(m->version[e_offset]))) e_offset++; ! if ((mpio_id_valid(m->version[e_offset])) && ! (m->model != MPIO_MODEL_VP_02) && ! (m->model != MPIO_MODEL_FL100)) /* ignore external memory ATM until ! we know how to support it! */ { sm->manufacturer = m->version[e_offset]; --- 251,288 ---- BYTE e_offset = 0x20; + /* these players have a MMC/SD slot */ + if ((m->model != MPIO_MODEL_VP_02) && + (m->model != MPIO_MODEL_FL100)) { + debugn(0, "Trying to detect external MMC. This is work in progress. BEWARE!!\n"); + debugn(0, "Please report your findings to mpi...@li...\n"); + debugn(0, "and include the following information block\n"); + hexdumpn(0, m->version, 64); + + mpio_mmc_detect_memory(m, sm); + + if (sm->size) { + debugn(0, "You are lucky! ;-) I found a %d MB MMC card.\n", sm->size); + debugn(0, "disabling memory, because low-level routines \n" + "are not integrated, yet. Please stay tuned.\n"); + sm->size = 0; + } else { + debugn(0, "I'm sorry, I did not detect a MMC card.\n" + "If you think I should have, please report this to the mpio-devel list.\n"); + } + + return; + } else { + sm->mmc=0; + sm->manufacturer = 0; + sm->id = 0; + sm->chips = 0; + sm->size = 0; + } + /* heuristic to find the right offset for the external memory */ while((e_offset < 0x3a) && !(mpio_id_valid(m->version[e_offset]))) e_offset++; ! if ((mpio_id_valid(m->version[e_offset]))) { sm->manufacturer = m->version[e_offset]; *************** *** 418,426 **** /* read FAT/spare area */ ! if (new_mpio->internal.id) mpio_fat_read(new_mpio, MPIO_INTERNAL_MEM, progress_callback); /* read the spare area (for block mapping) */ ! if (new_mpio->external.id) { sm = &new_mpio->external; --- 445,453 ---- /* read FAT/spare area */ ! if (new_mpio->internal.size) mpio_fat_read(new_mpio, MPIO_INTERNAL_MEM, progress_callback); /* read the spare area (for block mapping) */ ! if (new_mpio->external.size) { sm = &new_mpio->external; *************** *** 524,549 **** snprintf(info->model, max, "%s", mpio_model_name[m->model]); ! if (!m->internal.id) { snprintf(info->mem_internal, max, "not available"); } else { ! if (m->internal.chips == 1) ! { ! snprintf(info->mem_internal, max, "%3dMB (%s)", ! mpio_id2mem(m->internal.id), ! mpio_id2manufacturer(m->internal.manufacturer)); ! } else { ! snprintf(info->mem_internal, max, "%3dMB (%s) - %d chips", ! mpio_id2mem(m->internal.id)*m->internal.chips, ! mpio_id2manufacturer(m->internal.manufacturer), ! m->internal.chips); ! } } ! if (m->external.id) { ! snprintf(info->mem_external, max, "%3dMB (%s)", ! mpio_id2mem(m->external.id), ! mpio_id2manufacturer(m->external.manufacturer)); } else { snprintf(info->mem_external, max, "not available"); --- 551,586 ---- snprintf(info->model, max, "%s", mpio_model_name[m->model]); ! if (!m->internal.size) { snprintf(info->mem_internal, max, "not available"); } else { ! if (m->internal.mmc) { ! snprintf(info->mem_internal, max, "%3dMB (MMC)", ! m->internal.size); ! } else { ! if (m->internal.chips == 1) ! { ! snprintf(info->mem_internal, max, "%3dMB (%s)", ! mpio_id2mem(m->internal.id), ! mpio_id2manufacturer(m->internal.manufacturer)); ! } else { ! snprintf(info->mem_internal, max, "%3dMB (%s) - %d chips", ! mpio_id2mem(m->internal.id)*m->internal.chips, ! mpio_id2manufacturer(m->internal.manufacturer), ! m->internal.chips); ! } ! } } ! if (m->external.size) { ! if (m->external.mmc) { ! snprintf(info->mem_external, max, "%3dMB (MMC)", ! m->external.size); ! } else { ! snprintf(info->mem_external, max, "%3dMB (%s)", ! mpio_id2mem(m->external.id), ! mpio_id2manufacturer(m->external.manufacturer)); ! } } else { snprintf(info->mem_external, max, "not available"); --- NEW FILE: mmc.c --- /* * $Id: mmc.c,v 1.1 2004/05/30 16:28:52 germeier Exp $ * * libmpio - a library for accessing Digit@lways MPIO players * Copyright (C) 2004 Robert Kellington, Markus Germeier * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc.,g 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <stdio.h> #include <stdlib.h> #include "mmc.h" #include "debug.h" /* This routine attempts to detect when mmc module is present and set some variables according to that size. If adding a new memory module do the following changes: 1. Add the appropriate switch below (size and geo need to be set). 2. Add the new module size and array data into the routines mmc_mpio_mbr_gen and mmc_mpio_pbr_gen for the memory formating. That should be all */ BYTE mpio_mmc_detect_memory(mpio_t *m, mpio_mem_t mem) { mpio_smartmedia_t *sm=0; int size; /* just in case we encounter a player with an internel mmc memory */ if (mem == MPIO_INTERNAL_MEM) sm = &m->internal; if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; if (!sm) { debug("error in memory selection, aborting\n"); exit (-1); } /*looking for likely markers*/ /* if((m->version[0x28] == 0x32) && (m->version[0x3a] == 0x01) && (m->version[0x3b] == 0x01) && (m->version[0x30] == 0xff) && (m->version[0x31] == 0xcf)) */ if((m->version[0x39] == 0x01) && (m->version[0x3b] == 0x01) && (m->version[0x20] == 0xff) && (m->version[0x21] == 0xff) && (m->version[0x22] == 0xff) && (m->version[0x23] == 0xff) && (m->version[0x24] == 0xff) && (m->version[0x25] == 0xff)) { switch(m->version[0x26]) { case 0x0e: /* 16 Mb */ /*NOTE: This size needs formating to be added and testing*/ sm->size = 16; sm->geo = MPIO_DISK_GEO_016; break; case 0x1e: /* 32 Mb */ sm->size = 32; sm->geo = MPIO_DISK_GEO_032; break; case 0x3b: /* 64 Mb */ sm->size = 64; sm->geo = MPIO_DISK_GEO_064; break; case 0x78: /* 128 Mb */ sm->size = 128; sm->geo = MPIO_DISK_GEO_128; break; case 0xf1: /* 256 Mb */ sm->size = 256; sm->geo = MPIO_DISK_GEO_256; break; default: debug("Found MMC memory markers but didn't recognize size\n"); sm->mmc = 0; sm->size = 0; return 0; } sm->mmc = 1; sm->chips = 1; sm->version = 0; sm->id = 0x78; /* Assigning my random id */ debug("Found MMC memory and all is OK so far\n"); return 1; } debug("Not recognized MMC memory\n"); return 0; } Index: fat.c =================================================================== RCS file: /cvsroot/mpio/mpio/libmpio/src/fat.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fat.c 19 Oct 2003 21:06:35 -0000 1.5 --- fat.c 30 May 2004 16:28:52 -0000 1.6 *************** *** 212,220 **** /* 128 MB need 2 Bytes instead of 1.5 */ ! if (sm->size != 128) { - temp = ((total_sector / 0x20 * 0x03 / 0x02 / 0x200) + 0x01); - } else { temp = ((total_sector / 0x20 * 0x02 / 0x200) + 0x01); } --- 212,220 ---- /* 128 MB need 2 Bytes instead of 1.5 */ ! if (sm->size >= 128) { temp = ((total_sector / 0x20 * 0x02 / 0x200) + 0x01); + } else { + temp = ((total_sector / 0x20 * 0x03 / 0x02 / 0x200) + 0x01); } *************** *** 542,546 **** ! if (sm->size == 128) { /* 2 Byte per entry */ e = f->entry * 2; --- 542,546 ---- ! if (sm->size >= 128) { /* 2 Byte per entry */ e = f->entry * 2; *************** *** 579,583 **** if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; ! if (sm->size == 128) { /* 2 Byte per entry */ --- 579,583 ---- if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; ! if (sm->size >= 128) { /* 2 Byte per entry */ *************** *** 754,758 **** f->entry = value; ! if (sm->size==128) { endvalue = 0xfff8; --- 754,758 ---- f->entry = value; ! if (sm->size>=128) { endvalue = 0xfff8; *************** *** 792,796 **** sm->fat[2] = 0xff; /* for FAT 16 */ ! if (sm->size == 128) sm->fat[3] = 0xff; } --- 792,796 ---- sm->fat[2] = 0xff; /* for FAT 16 */ ! if (sm->size >= 128) sm->fat[3] = 0xff; } |