www.pudn.com > efs.rar > fs_hotplug.h
/***********************************************************************
* fs_hotplug.h
*
* Filesystem hotplug manager.
* Copyright (C) 2005 2006 QUALCOMM, Inc.
*
* The EFS hotplug task responds to events indicating insertion and removal
* of removable media. It is also responsible for periodic polling of
* devices that do not self detect.
*
***********************************************************************/
/*===========================================================================
EDIT HISTORY FOR MODULE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
$Header: //depot/asic/MSMSHARED/services/efs/MSM_EFS.01.02/fs_hotplug.h#17 $ $DateTime: 2006/11/13 14:44:34 $ $Author: davidb $
when who what, where, why
---------- --- ---------------------------------------------------------
2006-11-09 sch Added CPRM specific definitions
2006-10-16 s h hotplug_set_polling_interval returns prior value.
2006-10-16 s h Change lock/unlock functions to return int status.
2006-10-10 s h Export hotplug_find_dev_by_type() as public.
2006-09-20 s h Export hotplug_find_dev_by_path() as public.
2006-05-16 s h Added hotplug_dev_is_mounted()
2006-05-11 s h Renamed efs_hotplug_... to hotplug_...
2006-05-10 s h Removed mount/unmount access functions
2006-05-10 s h Replaced DRV_GEOMETRY_DESC with block size & count
2006-05-10 s h Added device access functions
2006-05-05 s h Brought in DEFAULT_POLL_INTERVAL_MS
2006-05-03 s h Made lock_card device-specific
2006-04-22 s h Moved all private definitions into fs_hotplug_i.h
2006-04-17 s h Improved comments
2006-04-17 s h Added external prototypes for lock/unlock card.
2006-04-13 s h Code review feedback implemented.
2006-04-13 s h Allow compliation without USB features
2006-03-10 s h Added USB CLOSED state
2006-03-10 sch Added USB specific functionality
2005-09-20 dlb Create
===========================================================================*/
#ifndef __FS_HOTPLUG_H__
#define __FS_HOTPLUG_H__
#include "comdef.h"
#include "customer.h"
/* EFS2 supports removable media (MMC/SD, USB Mass storage) through the
* notion of a hotplug manager. This task keeps track of devices in the
* system, and performs auto mounting and unmounting of the appropriate
* mountpoints, so that these devices appear in the filesystem namespace.
*
* Some devices, such as USB mass storage, are able to notify us on
* significant events, such as enumeration and device removal.
* Automounting these devices is merely a matter of responding to the
* appropriate events, and mounting or unmounting the device at the
* appropriate time.
*
* Other devices, such as MMC/SD do not have a consistent way of detecting
* card insertion. A design may implement card detection with DAT3, power
* drain detection, or a physical insertion switch. The design may also
* opt to do only software polling. This module needs to be flexible to
* these differing needs.
*
* Because power consumption is a significant concern in a mobile device,
* the hotplug manager provides calls to enable and disable this periodic
* polling. Some suggestions are to enable and disable polling in a
* similar manner to that used for the backlight. When the user isn't
* pressing keys, polling can be disabled.
*
* The entire hotplug manager is featurized on FEATURE_EFS_HOTPLUG.
*/
/* The hotplug device is an internal (private) data structure.
* Here is an anonymous declaration so we can talk about pointers to
* this structure. */
struct hotplug_device;
/***************************************************
* CONFIGURATION OPTIONS
*
* Targets can override these values as needed
****************************************************/
/*
* This is the starting interval (in milliseconds) to use for polling
* any external media. (It is actually the time between polls, so if
* the poll takes a while (MMC takes 600ms+), the overall interval
* will be this plus the poll time.)
*
* The target can set this value in cust, which allows a different
* default to be used without changing this file. This default value
* will be used if none is previously defined.
*
* This interval is used at startup, until a call to
* efs_hotplug_set_polling_interval() changes it.
*/
#ifndef FS_HOTPLUG_DEFAULT_POLL_INTERVAL_MS
#define FS_HOTPLUG_DEFAULT_POLL_INTERVAL_MS 10000 /* 10 seconds */
#endif
/***************************************************
* EXTERNAL INTERFACE
*
* These functions can be called from AMSS
****************************************************/
/*
* Set the frequency at which Hotplug task will poll ALL devices for changes.
*
* Too small a value, and the task will run frequently, keeping the SD
* interface active or other busywork.
*
* Too slow, and the phone will be sluggish in detecting new media.
*
* Set to 0 to inhibit polling entirely, perhaps for sleep or low-current
* scenarios.
*
* A poll interval of two to five seconds is reasonable.
*
* Returns the previous value of the polling interval.
*/
unsigned int hotplug_set_polling_interval (unsigned int milliseconds);
/* Since we did release one VU that called it by this unfortunate
* name, add a define to make migration easy.
* This name is DEPRECATED. */
#define efs_hotplug_set_polling_interval(x) hotplug_set_polling_interval(x)
/*
* Initialize the hotplug manager, and start its task.
* This must be called once during startup.
* EFS2 must be initialized first.
* EFS currently calls this after its own startup.
*/
void hotplug_init (void);
/*
* Format new media with a fresh filesystem, completely DESTROYING
* the previous contents.
*
* The provided pathname is the directory under which the media would
* normally be mounted by Hotplug
*/
int hotplug_format (const char *dirname);
int hotplug_format_dev (struct hotplug_device *hdev);
/*
* Lock/Unlock all media access on one device. While media access is
* "locked", hotplug will stay off the device and ignore any media.
* Hotplug will forcibly unmount the device and disable polling, so
* the device will not be auto-mounted.
*
* The device remains useable through direct read/write calls, but
* Hotplug itself will not attempt to (FAT) mount it.
*
* This is used during Cardreader mode, CPRM, and other
* exclusive-access applications.
*
* Return 0 on success, -1 on failure.
*/
int hotplug_unlock_dev (struct hotplug_device *hdev);
int hotplug_lock_dev (struct hotplug_device *hdev);
/* Old names for the above (DEPRECATED, Do not use!) */
void fs_sfat_lock_card (void);
void fs_sfat_unlock_card (void);
/* Get a device entry by index/"drive number".
*
* The drive number is an arbitrary number associated with a
* particular hotplug device. It's impossible for an application to
* predict which device is associated with a particular drive number,
* so it's best to use this only when a drive number is derived from
* an hdev handle during runtime.
*
* Returns NULL if no device was found with that drive number.
*/
struct hotplug_device *hotplug_hdev (int16 driveno);
/*
* Each Hotplug device has a "type" that identifies the device handler
* for this particular device.
*/
typedef enum
{
HOTPLUG_TYPE_MMC = 1, /* SD or MMC */
HOTPLUG_TYPE_REMOTE = 2, /* Device hosted on other processor */
HOTPLUG_TYPE_USB_MS = 3, /* USB Host Mass Storage (thumdrive) */
HOTPLUG_TYPE_DEVNULL = 4, /* NULL (nop) device */
HOTPLUG_TYPE_FTL = 5, /* Flash Translation Layer (FAT-on-NAND) */
HOTPLUG_TYPE_SD_CPRM = 6 /* Protected area of SD card (for CPRM) */
} hotplug_dev_type;
/*
* hotplug_find_dev_by_type() returns a handle to the next device of
* this "type", or the first one of this type if the value of last ==
* NULL. It returns 'NULL' when there are no more devices of that
* type.
*
* This could be used to iterate through all devices of TYPE_MMC, for
* example. It's generally called with 'NULL' the first time, and
* then each returned hdev pointer is passed back in to find the next
* one.
*
* Example:
* first = hotplug_find_dev_by_type (HOTPLUG_TYPE_MMC, NULL);
* hdev = hotplug_find_dev_by_type (HOTPLUG_TYPE_MMC, first);
*/
struct hotplug_device *
hotplug_find_dev_by_type (hotplug_dev_type type,
struct hotplug_device *last);
/*
* Find a device that would be mounted under this pathname.
*
* Example:
* hotplug_find_dev_by_path ("/mmc1");
*
* Returns the hdev handle, or 'NULL' if no device exists with this name.
* The path is required, and the leading slash is optional.
*/
struct hotplug_device *
hotplug_find_dev_by_path (const char *path);
/* ----- Device Access Functions -----
*
* Once a hotplug 'hdev' handle is retrieved, it can be passed
* to these functions to perform direct device access.
*/
/* Open the device for use */
int hotplug_dev_open (struct hotplug_device *);
/* Close the device */
int hotplug_dev_close (struct hotplug_device *);
/* Read one or more blocks */
int hotplug_dev_read (struct hotplug_device *,
uint32, unsigned char *, uint16);
/* Write one or more blocks */
int hotplug_dev_write (struct hotplug_device *,
uint32, unsigned char *, uint16);
/* Write one or more blocks of user data */
int hotplug_dev_write_udata (struct hotplug_device *,
uint32, unsigned char *, uint16);
/* Erase one or more blocks */
int hotplug_dev_erase (struct hotplug_device *, uint32, uint16);
/* Get the size (number of blocks and size of each block */
int hotplug_dev_get_size (struct hotplug_device *, uint32 *, uint16 *);
/* Return TRUE if the device is present and useable */
int hotplug_dev_is_present (struct hotplug_device *);
/* Return TRUE if hotplug currently has this device mounted */
int hotplug_dev_is_mounted (struct hotplug_device *);
#endif /* not __FS_HOTPLUG_H__ */