freemyipod r634 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r633‎ | r634 | r635 >
Date:20:31, 20 February 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Add an API to request the number of total and free kilobytes on a volume
Modified paths:
  • /emcore/trunk/export/syscallapi.h (modified) (history)
  • /emcore/trunk/export/syscallwrappers.h (modified) (history)
  • /emcore/trunk/fat.c (modified) (history)
  • /emcore/trunk/fat.h (modified) (history)
  • /emcore/trunk/syscallapi.c (modified) (history)
  • /emcore/trunk/usb/usb.c (modified) (history)

Diff [purge]

Index: emcore/trunk/export/syscallwrappers.h
@@ -222,6 +222,7 @@
223223 #define read_battery_state __emcore_syscall->read_battery_state
224224 #define tlsf_realign __emcore_syscall->tlsf_realign
225225 #define realign __emcore_syscall->realign
 226+#define fat_size_mv __emcore_syscall->fat_size_mv
226227
227228
228229 #endif
Index: emcore/trunk/export/syscallapi.h
@@ -280,6 +280,7 @@
281281 typeof(read_battery_state) *read_battery_state;
282282 typeof(tlsf_realign) *tlsf_realign;
283283 typeof(realign) *realign;
 284+ typeof(fat_size_mv) *fat_size_mv;
284285 };
285286
286287
Index: emcore/trunk/syscallapi.c
@@ -244,5 +244,8 @@
245245 .read_input_mw = read_input_mw,
246246 .read_battery_state = read_battery_state,
247247 .tlsf_realign = tlsf_realign,
248 - .realign = realign
 248+ .realign = realign,
 249+#ifdef HAVE_STORAGE
 250+ .fat_size_mv = fat_size_mv
 251+#endif
249252 };
Index: emcore/trunk/usb/usb.c
@@ -629,6 +629,7 @@
630630 case 51: // DISK_UNMOUNT
631631 #endif
632632 case 58: // FAT_ENABLE_FLUSHING
 633+ case 59: // FAT_SIZE
633634 if (!set_dbgaction(DBGACTION_STORAGE, 0))
634635 memcpy(dbgasyncsendbuf, dbgrecvbuf, sizeof(dbgasyncsendbuf));
635636 break;
@@ -951,6 +952,11 @@
952953 fat_enable_flushing((bool)(dbgasyncsendbuf[1]));
953954 usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
954955 break;
 956+ case 59: // FAT_SIZE
 957+ dbgasyncsendbuf[0] = 1;
 958+ fat_size_mv(dbgasyncsendbuf[1], &dbgasyncsendbuf[1], &dbgasyncsendbuf[2]);
 959+ usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
 960+ break;
955961 }
956962 break;
957963 #endif
Index: emcore/trunk/fat.c
@@ -250,11 +250,8 @@
251251 + fat_bpb->firstdatasector;
252252 }
253253
254 -void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
 254+void fat_size_mv(int volume, unsigned long* size, unsigned long* free)
255255 {
256 -#ifndef HAVE_MULTIVOLUME
257 - const int volume = 0;
258 -#endif
259256 struct bpb* fat_bpb = &fat_bpbs[volume];
260257 if (size)
261258 *size = fat_bpb->dataclusters * (fat_bpb->bpb_secperclus * SECTOR_SIZE / 1024);
@@ -262,6 +259,14 @@
263260 *free = fat_bpb->fsinfo.freecount * (fat_bpb->bpb_secperclus * SECTOR_SIZE / 1024);
264261 }
265262
 263+void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
 264+{
 265+#ifndef HAVE_MULTIVOLUME
 266+ const int volume = 0;
 267+#endif
 268+ fat_size_mv(volume, size, free);
 269+}
 270+
266271 void fat_init(void)
267272 {
268273 unsigned int i;
Index: emcore/trunk/fat.h
@@ -19,13 +19,22 @@
2020 *
2121 ****************************************************************************/
2222
 23+
2324 #ifndef FAT_H
2425 #define FAT_H
2526
26 -#ifndef IN_APPLICATION_CODE
2727
2828 #include "global.h"
2929 #include "util.h"
 30+
 31+
 32+extern void fat_size_mv(int volume, unsigned long* size, unsigned long* free);
 33+extern void fat_enable_flushing(bool state);
 34+
 35+
 36+#ifndef IN_APPLICATION_CODE
 37+
 38+
3039 #include "mv.h" /* for volume definitions */
3140
3241 #ifndef SECTOR_SIZE
@@ -134,8 +143,8 @@
135144 extern void* fat_get_sector_buffer(void);
136145 extern void fat_release_sector_buffer(void);
137146
 147+
138148 #endif
139149
140 -extern void fat_enable_flushing(bool state);
141150
142151 #endif