From 2f8a0081c64534da23fc0fa9cc685eb7454fd9c9 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 1 Nov 2008 16:14:28 +0000 Subject: Apply FS#9500. This adds a storage_*() abstraction to replace ata_*(). To do that, it also introduces sd_*, nand_*, and mmc_*. This should be a good first step to allow multi-driver targets, like the Elio (ATA/SD), or the D2 (NAND/SD). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18960 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/ata.h | 55 ++++++++++++++++++--------------------- firmware/export/ata_idle_notify.h | 24 ++++++++--------- firmware/export/disk.h | 2 +- firmware/export/fat.h | 2 +- firmware/export/nand_id.h | 2 +- 5 files changed, 41 insertions(+), 44 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 164261a40a..f09a4630d3 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h @@ -23,43 +23,40 @@ #include #include "config.h" /* for HAVE_MULTIVOLUME or not */ +#include "mv.h" /* for IF_MV() and friends */ -/* FixMe: These macros are a bit nasty and perhaps misplaced here. - We'll get rid of them once decided on how to proceed with multivolume. */ -#ifdef HAVE_MULTIVOLUME -#define IF_MV(x) x /* optional volume/drive parameter */ -#define IF_MV2(x,y) x,y /* same, for a list of arguments */ -#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ -#define NUM_VOLUMES 2 -#else /* empty definitions if no multi-volume */ -#define IF_MV(x) -#define IF_MV2(x,y) -#define IF_MV_NONVOID(x) void -#define NUM_VOLUMES 1 -#endif +struct storage_info; -extern void ata_enable(bool on); -extern void ata_spindown(int seconds); -extern void ata_sleep(void); -extern void ata_sleepnow(void); +void ata_enable(bool on); +void ata_spindown(int seconds); +void ata_sleep(void); +void ata_sleepnow(void); /* NOTE: DO NOT use this to poll for disk activity. If you are waiting for the disk to become active before doing something use ata_idle_notify.h */ -extern bool ata_disk_is_active(void); -extern int ata_hard_reset(void); -extern int ata_soft_reset(void); -extern int ata_init(void); -extern void ata_close(void); -extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); -extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); -extern void ata_spin(void); +bool ata_disk_is_active(void); +int ata_hard_reset(void); +int ata_soft_reset(void); +int ata_init(void); +void ata_close(void); +int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +void ata_spin(void); #if (CONFIG_LED == LED_REAL) -extern void ata_set_led_enabled(bool enabled); +void ata_set_led_enabled(bool enabled); +#endif +unsigned short* ata_get_identify(void); +void ata_get_info(IF_MV2(int drive,) struct storage_info *info); +#ifdef HAVE_HOTSWAP +bool ata_removable(IF_MV_NONVOID(int drive)); +bool ata_present(IF_MV_NONVOID(int drive)); #endif -extern unsigned short* ata_get_identify(void); -extern long last_disk_activity; -extern int ata_spinup_time; /* ticks */ + + +long ata_last_disk_activity(void); +int ata_spinup_time(void); /* ticks */ + #endif diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index aea2c92b06..ceba2eeda4 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h @@ -26,15 +26,15 @@ #include "events.h" /* - NOTE: ata_idle_notify usage notes.. + NOTE: storage_idle_notify usage notes.. 1) The callbacks are called in the ata thread, not main/your thread. 2) Asynchronous callbacks (like the buffer refill) should be avoided. - If you must use an async callback, remember to check ata_is_active() before + If you must use an async callback, remember to check storage_is_active() before accessing the disk, and do not call any functions between that check and the disk access which may cause a yield (lcd_update() does this!). 3) Do not call any yielding functions in the callback. -4) Do not call ata_sleep in the callbacks. +4) Do not call storage_sleep in the callbacks. 5) Don't Panic! */ @@ -43,21 +43,21 @@ enum { DISK_EVENT_SPINUP = (EVENT_CLASS_DISK|1), }; -#define USING_ATA_CALLBACK !defined(SIMULATOR) \ +#define USING_STORAGE_CALLBACK !defined(SIMULATOR) \ && ! ((CONFIG_STORAGE & STORAGE_NAND) \ && (CONFIG_NAND & NAND_IFP7XX)) \ && !defined(BOOTLOADER) -typedef bool (*ata_idle_notify)(void); +typedef bool (*storage_idle_notify)(void); -extern void register_ata_idle_func(ata_idle_notify function); -#if USING_ATA_CALLBACK -extern void unregister_ata_idle_func(ata_idle_notify function, bool run); -extern bool call_ata_idle_notifys(bool force); +extern void register_storage_idle_func(storage_idle_notify function); +#if USING_STORAGE_CALLBACK +extern void unregister_storage_idle_func(storage_idle_notify function, bool run); +extern bool call_storage_idle_notifys(bool force); #else -#define unregister_ata_idle_func(f,r) -#define call_ata_idle_notifys(f) -#define ata_idle_notify_init(s) +#define unregister_storage_idle_func(f,r) +#define call_storage_idle_notifys(f) +#define storage_idle_notify_init(s) #endif #endif /* __ATACALLBACK_H__ */ diff --git a/firmware/export/disk.h b/firmware/export/disk.h index 8d440befaf..cec9bfa3fc 100644 --- a/firmware/export/disk.h +++ b/firmware/export/disk.h @@ -21,7 +21,7 @@ #ifndef _DISK_H_ #define _DISK_H_ -#include "ata.h" /* for volume definitions */ +#include "mv.h" /* for volume definitions */ struct partinfo { unsigned long start; /* first sector (LBA) */ diff --git a/firmware/export/fat.h b/firmware/export/fat.h index 0e83ca8b4d..c99a1a75f8 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h @@ -23,7 +23,7 @@ #define FAT_H #include -#include "ata.h" /* for volume definitions */ +#include "mv.h" /* for volume definitions */ #include "config.h" #define SECTOR_SIZE 512 diff --git a/firmware/export/nand_id.h b/firmware/export/nand_id.h index a47a38eea2..188b6c161a 100644 --- a/firmware/export/nand_id.h +++ b/firmware/export/nand_id.h @@ -5,7 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: ata.h 17847 2008-06-28 18:10:04Z bagder $ + * $Id: $ * * Copyright (C) 2002 by Alan Korr * -- cgit v1.2.3