From 1167e3c72f5d0d581b81fd2cb8f2580a1524ca5a Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sat, 30 Jun 2007 02:08:27 +0000 Subject: Accept FS#7134 - Sansa: external sd card support by Antonius Hellmann with some tweaks. All testers have given the green light. (Now for the RED ?? ;). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13741 a1c6a512-1295-4272-9138-f99709370657 --- firmware/hotswap.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 firmware/hotswap.c (limited to 'firmware/hotswap.c') diff --git a/firmware/hotswap.c b/firmware/hotswap.c new file mode 100644 index 0000000000..5620edf10b --- /dev/null +++ b/firmware/hotswap.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2004 by Jens Arnold + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include "config.h" +#ifdef TARGET_TREE +#include "hotswap-target.h" +#else +#include "ata_mmc.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 = start / 32; + unsigned int bit_index = start % 32; + unsigned long result; + + 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; +} + +#ifdef TARGET_TREE +bool card_detect(void) +{ + return card_detect_target(); +} + +tCardInfo *card_get_info(int card_no) +{ + return card_get_info_target(card_no); +} +#endif -- cgit v1.2.3