summaryrefslogtreecommitdiff
path: root/firmware/hotswap.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/hotswap.c')
-rw-r--r--firmware/hotswap.c58
1 files changed, 58 insertions, 0 deletions
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <stdbool.h>
20#include "config.h"
21#ifdef TARGET_TREE
22#include "hotswap-target.h"
23#else
24#include "ata_mmc.h"
25#endif
26
27/* helper function to extract n (<=32) bits from an arbitrary position.
28 counting from MSB to LSB */
29unsigned long card_extract_bits(
30 const unsigned long *p, /* the start of the bitfield array */
31 unsigned int start, /* bit no. to start reading */
32 unsigned int size) /* how many bits to read */
33{
34 unsigned int long_index = start / 32;
35 unsigned int bit_index = start % 32;
36 unsigned long result;
37
38 result = p[long_index] << bit_index;
39
40 if (bit_index + size > 32) /* crossing longword boundary */
41 result |= p[long_index+1] >> (32 - bit_index);
42
43 result >>= 32 - size;
44
45 return result;
46}
47
48#ifdef TARGET_TREE
49bool card_detect(void)
50{
51 return card_detect_target();
52}
53
54tCardInfo *card_get_info(int card_no)
55{
56 return card_get_info_target(card_no);
57}
58#endif