When autodetecting, don't segfault if no item was previously selected and a device...
[Rockbox.git] / firmware / export / hotswap.h
blob4a1b1717cafb2b70496173e0272a6bde576b28e0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2004 by Jens Arnold
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #ifndef __HOTSWAP_H__
20 #define __HOTSWAP_H__
22 typedef struct
24 int initialized;
25 unsigned char bitrate_register;
26 unsigned long read_timeout; /* n * 8 clock cycles */
27 unsigned long write_timeout; /* n * 8 clock cycles */
29 unsigned long ocr; /* OCR register */
30 unsigned long csd[4]; /* CSD register, 16 bytes */
31 unsigned long cid[4]; /* CID register, 16 bytes */
32 unsigned long speed; /* bit/s */
33 unsigned int nsac; /* clock cycles */
34 unsigned long tsac; /* n * 0.1 ns */
35 unsigned int r2w_factor;
36 unsigned long size; /* size in bytes */
37 unsigned long numblocks; /* size in flash blocks */
38 unsigned int blocksize; /* block size in bytes */
39 unsigned int block_exp; /* block size exponent */
40 } tCardInfo;
42 #ifdef TARGET_TREE
43 bool card_detect(void);
44 tCardInfo *card_get_info(int card_no);
45 #else /* HAVE_MMC */
46 #include "ata_mmc.h"
47 #define card_detect mmc_detect
48 #define card_get_info mmc_card_info
49 #define card_touched mmc_touched
50 #define card_enable_monitoring mmc_enable_monitoring
51 #endif
53 /* helper function to extract n (<=32) bits from an arbitrary position.
54 counting from MSB to LSB */
55 unsigned long card_extract_bits(
56 const unsigned long *p, /* the start of the bitfield array */
57 unsigned int start, /* bit no. to start reading */
58 unsigned int size); /* how many bits to read */
59 #endif