From a0557b23f0c984576fd5a72657593211df148ca4 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 5 Jun 2010 21:12:16 +0000 Subject: remane hotswap.* to sdmmc.*. The contents have nothing at all to do with hotswapping things git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26598 a1c6a512-1295-4272-9138-f99709370657 --- firmware/sdmmc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 firmware/sdmmc.c (limited to 'firmware/sdmmc.c') diff --git a/firmware/sdmmc.c b/firmware/sdmmc.c new file mode 100644 index 0000000000..f499ffae08 --- /dev/null +++ b/firmware/sdmmc.c @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2004 by Jens Arnold + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include "config.h" +#if (CONFIG_STORAGE & STORAGE_MMC) +#include "ata_mmc.h" +#else +#include "sdmmc.h" +#endif + +/* helper function to extract n (<=32) bits from an arbitrary position. + counting from MSB to LSB */ +unsigned long card_extract_bits( + const unsigned long *p, /* the start of the bitfield array */ + unsigned int start, /* bit no. to start reading */ + unsigned int size) /* how many bits to read */ +{ + unsigned int long_index, bit_index; + unsigned long result; + + /* we assume words of CSD/CID are stored most significant word first */ + start = 127 - start; + + long_index = start / 32; + bit_index = start % 32; + + result = p[long_index] << bit_index; + + if (bit_index + size > 32) /* crossing longword boundary */ + result |= p[long_index+1] >> (32 - bit_index); + + result >>= 32 - size; + + return result; +} -- cgit v1.2.3