summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Brandt <michael.brandt@stericsson.com>2010-07-20 15:08:22 +0200
committerMichael BRANDT <michael.brandt@stericsson.com>2010-08-30 20:03:48 +0200
commit20503b61a7f73fad8ee97219f7a1e74de3a8a2ac (patch)
treeec58c1f830639a45462fe07219304a06a16b7b54 /include
parent3a5b27b58258ff61dfae3167bc46fed0146ddffd (diff)
Read/write VFAT support from Rockbox-3.3 FAT stack
Add read/write VFAT support from Rockbox-3.3 FAT stack. It should be also applicable to the unmodified 2009.11 U-Boot release. Note that is was taken as is from Rockbox and from a older U-Boot Rockbox patch. "checkpatch" shows very many coding style errors and warnings, but it is tedious work to clean this up. To make this patch work an additional mmc_block_write() board support routine and the errno variable are needed. Furthermore following defines in the board config header file: #define CONFIG_ROCKBOX_FAT 1 #define CONFIG_U_BOOT 1 #define CONFIG_SUPPORT_VFAT 1 #define CONFIG_CMD_TREE_FAT This will be added in a follow-up patch. This patch is based on the patch from Etienne Carriere <etienne.carriere@stericsson.com> for the U671x U-Boot: This commit adds FAT write support to u-boot native read-only FAT code. Commit initially applied on u-boot-v2009.01 (SHA1: 72d15e705bc3983884105cb7755c7ba80e74a0a5) Based on FAT stack dumped from Rockbox package v3.1 (www.rockbox.org). Based on initial Rockbox FAT stack integration in u-boot by Keith Outwater (outwater@comcast.net). Current porting is aligned with Rockbox v3.3 FAT stack. Enable upon config switches: CONFIG_CMD_FAT CONFIG_ROCKBOX_FAT CONFIG_CMD_TREE_FAT (recommended) CONFIG_SUPPORT_VFAT (recommended) C code APIs (from U-boot native FAT support): int fat_register_device(block_dev_desc_t *dev_desc, int part_no); long file_fat_read(const char *path, void *buf, unsigned long maxsize); int file_fat_ls(const char *dirname); int file_fat_detectfs(void); C code APIs (added by Rockbox FAT support): long file_fat_write(const char *path, void *buf, unsigned long maxsize); int file_fat_rm(const char *path); int file_fat_rmdir(const char *path); int file_fat_mkdir(const char *path); int file_fat_cd(const char *path); int file_fat_pwd(void); int file_fat_mv(const char *oldpath, const char *newpath); unsigned int rockbox_fat_free(unsigned long size_kbyte); unsigned int rockbox_fat_size(void); Use "help fat" from u-boot console to see available commands. ST-Ericsson ID: WP264488 Change-Id: I9afc29ecb80f9152bd8534bbf11e47e54cfad796 Signed-off-by: Michael Brandt <michael.brandt@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/3009
Diffstat (limited to 'include')
-rw-r--r--include/fat.h45
-rw-r--r--include/linux/string.h2
-rw-r--r--include/part.h2
-rw-r--r--include/rbunicode.h75
-rw-r--r--include/rockbox_dir.h128
-rw-r--r--include/rockbox_fat.h157
-rw-r--r--include/rockbox_file.h89
-rw-r--r--include/rockbox_mv.h47
8 files changed, 540 insertions, 5 deletions
diff --git a/include/fat.h b/include/fat.h
index c8b949362..26886fda0 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -3,6 +3,8 @@
*
* 2002-07-28 - rjones@nexus-tech.net - ported to ppcboot v1.1.6
* 2003-03-10 - kharris@nexus-tech.net - ported to u-boot
+ * 2006-01-18 - Keith Outwater (outwater@comcast.net) - added write support
+ * using FAT driver from rockbox project (www.rockbox.org)
*
* See file CREDITS for list of people who contributed to this
* project.
@@ -29,7 +31,9 @@
#include <asm/byteorder.h>
+#ifndef CONFIG_SUPPORT_VFAT
#define CONFIG_SUPPORT_VFAT
+#endif
#define SECTOR_SIZE FS_BLOCK_SIZE
@@ -57,12 +61,14 @@
#define SIGNLEN 8
/* File attributes */
+#ifndef CONFIG_ROCKBOX_FAT /* rockbox redefine these */
#define ATTR_RO 1
#define ATTR_HIDDEN 2
#define ATTR_SYS 4
#define ATTR_VOLUME 8
#define ATTR_DIR 16
#define ATTR_ARCH 32
+#endif
#define ATTR_VFAT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
@@ -80,7 +86,7 @@
#define LS_DIR 1
#define LS_ROOT 2
-#ifdef DEBUG
+#if (defined(DEBUG) || defined(FAT_DEBUG))
#define FAT_DPRINT(args...) printf(args)
#else
#define FAT_DPRINT(args...)
@@ -114,6 +120,14 @@
#define CHECK_CLUST(x, fatsize) ((x) <= 1 || \
(x) >= ((fatsize) != 32 ? 0xfff0 : 0xffffff0))
+#ifdef CONFIG_ROCKBOX_FAT
+/*
+ * Remember the current working directory for the four primary partitions.
+ */
+#define NUM_PARTS_WITH_CWD 4
+#define CWD_LEN 511
+#endif
+
typedef struct boot_sector {
__u8 ignored[3]; /* Bootstrap code */
char system_id[8]; /* Name of fs */
@@ -192,11 +206,20 @@ typedef struct {
int fatbufnum; /* Used by get_fatent, init to -1 */
} fsdata;
+/*
+ * This struct encapsulates partiton and device info for the currently active
+ * block device.
+ */
+typedef struct cur_block_dev {
+ block_dev_desc_t *cur_dev;
+ unsigned long part_offset;
+ int cur_part;
+} cur_block_dev_t;
+
typedef int (file_detectfs_func)(void);
typedef int (file_ls_func)(const char *dir);
typedef long (file_read_func)(const char *filename, void *buffer,
unsigned long maxsize);
-
struct filesystem {
file_detectfs_func *detect;
file_ls_func *ls;
@@ -209,12 +232,28 @@ file_detectfs_func file_fat_detectfs;
file_ls_func file_fat_ls;
file_read_func file_fat_read;
-/* Currently this doesn't check if the dir exists or is valid... */
+/*Currently this doesn't check if the dir exists or is valid */
int file_cd(const char *path);
+
int file_fat_detectfs(void);
int file_fat_ls(const char *dir);
long file_fat_read(const char *filename, void *buffer, unsigned long maxsize);
+#ifdef CONFIG_ROCKBOX_FAT
+long file_fat_write(const char *filename, void *buffer, unsigned long filesize);
+int file_fat_rm(const char *filename);
+int file_fat_mkdir(const char *dirname);
+int file_fat_rmdir(const char *dirname);
+int file_fat_pwd(void);
+int file_fat_cd(const char *dirname);
+int file_fat_mv(const char *oldname, const char *newname);
+#endif
const char *file_getfsname(int idx);
int fat_register_device(block_dev_desc_t *dev_desc, int part_no);
+#ifdef CONFIG_ROCKBOX_FAT
+#ifndef ROCKBOX_FAT_H
+#include <rockbox_fat.h>
+#endif
+#endif
+
#endif /* _FAT_H_ */
diff --git a/include/linux/string.h b/include/linux/string.h
index 62390399b..36aa5e910 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -13,7 +13,7 @@ extern char * strpbrk(const char *,const char *);
extern char * strtok(char *,const char *);
extern char * strsep(char **,const char *);
extern __kernel_size_t strspn(const char *,const char *);
-
+extern char * strtok_r(char *ptr, const char *sep, char **end);
/*
* Include machine specific inline routines
diff --git a/include/part.h b/include/part.h
index 3cdae0214..48aa816a7 100644
--- a/include/part.h
+++ b/include/part.h
@@ -105,7 +105,7 @@ block_dev_desc_t* mg_disk_get_dev(int dev);
/* disk/part.c */
int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part (block_dev_desc_t *dev_desc);
-void init_part (block_dev_desc_t *dev_desc);
+int init_part (block_dev_desc_t *dev_desc);
void dev_print(block_dev_desc_t *dev_desc);
diff --git a/include/rbunicode.h b/include/rbunicode.h
new file mode 100644
index 000000000..cecd9d780
--- /dev/null
+++ b/include/rbunicode.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * Copyright (c) 2004,2005 by Marcoen Hirschberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************
+ * Source file dumped from rockbox-3.1 distribution.
+ * $Id: rbunicode.h 19339 2008-12-04 22:00:12Z zagor $
+ * Copyright (c) 2004,2005 by Marcoen Hirschberg
+ *
+ * See file CREDITS for list of people who contributed to the U-boot
+ * project.
+ *
+ ****************************************************************************
+ * Some conversion functions for handling UTF-8
+ *
+ * I got all the info from:
+ * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ * and
+ * http://en.wikipedia.org/wiki/Unicode
+ ****************************************************************************
+ * 09-jan-2008 etienne.carriere@stnwireless.com - port from rockbox to U-boot
+ ****************************************************************************
+ */
+#ifndef _RBUNICODE_H_
+#define _RBUNICODE_H_
+
+/* not applicable for u-boot
+ * #ifndef __PCTOOL__
+ * #include "config.h"
+ * #endif
+ */
+
+#define MASK 0xC0 /* 11000000 */
+#define COMP 0x80 /* 10x */
+
+#ifdef HAVE_LCD_BITMAP
+
+enum codepages {
+ ISO_8859_1 = 0, ISO_8859_7, ISO_8859_8, WIN_1251,
+ ISO_8859_11, WIN_1256, ISO_8859_9, ISO_8859_2, WIN_1250,
+ SJIS, GB_2312, KSX_1001, BIG_5, UTF_8, NUM_CODEPAGES
+};
+
+#else /* !HAVE_LCD_BITMAP, reduced support */
+
+enum codepages {
+ ISO_8859_1 = 0, ISO_8859_7, WIN_1251, ISO_8859_9,
+ ISO_8859_2, WIN_1250, UTF_8, NUM_CODEPAGES
+};
+
+#endif
+
+/* Encode a UCS value as UTF-8 and return a pointer after this UTF-8 char. */
+unsigned char* utf8encode(unsigned long ucs, unsigned char *utf8);
+unsigned char* iso_decode(const unsigned char *latin1, unsigned char *utf8, int cp, int count);
+unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8, int count);
+unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8, int count);
+unsigned long utf8length(const unsigned char *utf8);
+const unsigned char* utf8decode(const unsigned char *utf8, unsigned short *ucs);
+void set_codepage(int cp);
+int utf8seek(const unsigned char* utf8, int offset);
+const char* get_codepage_name(int cp);
+#endif /* _RBUNICODE_H_ */
diff --git a/include/rockbox_dir.h b/include/rockbox_dir.h
new file mode 100644
index 000000000..b184fcc47
--- /dev/null
+++ b/include/rockbox_dir.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************
+ * Source file dumped from rockbox-3.1 distribution.
+ * $Id: dir.h 13741 2007-06-30 02:08:27Z jethead71 $
+ * Copyright (C) 2002 by Björn Stenberg
+ ****************************************************************************
+ * See file CREDITS for list of people who contributed to the U-boot
+ * project.
+ *
+ * 01/17/2006 Keith Outwater (outwater4@comcast.net) - port to U-Boot using
+ * CVS version 1.12 of 'firmware/common/dir.h' from rockbox CVS server.
+ * 01/07/2008 etienne.carriere@stnwireless.com - update u-boot port from rockbox-3.1
+ ***************************************************************************
+ */
+#ifndef _ROCKBOX_DIR_H_
+#define _ROCKBOX_DIR_H_
+
+#ifdef HAVE_DIRCACHE
+#error ""
+# include "dircache.h"
+# define DIR DIR_CACHED
+# define dirent dircache_entry
+# define opendir opendir_cached
+# define closedir closedir_cached
+# define readdir readdir_cached
+# define closedir closedir_cached
+# define mkdir mkdir_cached
+# define rmdir rmdir_cached
+#else
+/*#include "dir_uncached.h" U-boot port: dir-uncached.h and dir.h current melded */
+# define DIR DIR_UNCACHED
+# define dirent dirent_uncached
+# define opendir opendir_uncached
+# define closedir closedir_uncached
+# define readdir readdir_uncached
+# define closedir closedir_uncached
+# define mkdir mkdir_uncached
+# define rmdir rmdir_uncached
+#endif
+
+#include <stdbool.h>
+#include <rockbox_file.h>
+
+#define ATTR_READ_ONLY 0x01
+#define ATTR_HIDDEN 0x02
+#define ATTR_SYSTEM 0x04
+#define ATTR_VOLUME_ID 0x08
+#define ATTR_DIRECTORY 0x10
+#define ATTR_ARCHIVE 0x20
+#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
+
+#ifdef SIMULATOR
+#define dirent_uncached sim_dirent
+#define DIR_UNCACHED SIM_DIR
+#define opendir_uncached sim_opendir
+#define readdir_uncached sim_readdir
+#define closedir_uncached sim_closedir
+#define mkdir_uncached sim_mkdir
+#define rmdir_uncached sim_rmdir
+#endif
+#ifndef DIRENT_DEFINED
+
+struct dirent {
+ unsigned char d_name[MAX_PATH];
+ int attribute;
+ long size;
+ long startcluster;
+ unsigned short wrtdate; /* Last write date */
+ unsigned short wrttime; /* Last write time */
+};
+#endif
+
+#include <rockbox_fat.h>
+
+typedef struct {
+#ifndef SIMULATOR
+ bool busy;
+ long startcluster;
+ struct fat_dir fatdir;
+ struct fat_dir parent_dir;
+ struct dirent_uncached theent;
+#ifdef HAVE_MULTIVOLUME
+ int volumecounter; /* running counter for faked volume entries */
+#endif
+#else
+ /* simulator: */
+ void *dir; /* actually a DIR* dir */
+ char *name;
+#endif
+} DIR_UNCACHED;
+
+#ifdef HAVE_HOTSWAP
+char *get_volume_name(int volume);
+#endif
+
+#ifdef HAVE_MULTIVOLUME
+ int strip_volume(const char*, char*);
+#endif
+
+#ifndef DIRFUNCTIONS_DEFINED
+
+extern DIR_UNCACHED* opendir_uncached(const char* name);
+extern int closedir_uncached(DIR_UNCACHED* dir);
+extern int mkdir_uncached(const char* name);
+extern int rmdir_uncached(const char* name);
+
+extern struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir);
+
+extern int release_dirs(int volume);
+
+#endif /* DIRFUNCTIONS_DEFINED */
+
+#endif /* #ifndef _ROCKBOX_DIR_H_ */
diff --git a/include/rockbox_fat.h b/include/rockbox_fat.h
new file mode 100644
index 000000000..1b0da44b4
--- /dev/null
+++ b/include/rockbox_fat.h
@@ -0,0 +1,157 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************
+ * Source file dumped from rockbox-3.1 distribution.
+ * $Id: fat.h 18960 2008-11-01 16:14:28Z gevaerts $
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ ****************************************************************************
+ * See file CREDITS for list of people who contributed to the U-boot
+ * project.
+ *
+ * 01/17/2006 Keith Outwater (outwater4@comcast.net) - port to U-Boot using
+ * CVS version 1.13 of 'firmware/export/fat.h' from rockbox CVS server.
+ * 09-jan-2008 etienne.carriere@stnwireless.com - update from rockbox-3.1
+ ****************************************************************************
+ */
+#ifndef ROCKBOX_FAT_H
+#define ROCKBOX_FAT_H
+
+#include <stdbool.h>
+#include "rockbox_mv.h" /* for volume definitions */
+
+/* Check that sector size is 512 bytes */
+#ifndef SECTOR_SIZE
+#define SECTOR_SIZE 512
+#elif (SECTOR_SIZE != 512)
+#error "SECTOR_SIZE expected to be 512"
+#endif
+/*
+ * The max length of the current working dorectory.
+ */
+#define ROCKBOX_CWD_LEN 512
+
+/* Number of bytes reserved for a file name (including the trailing \0).
+ Since names are stored in the entry as UTF-8, we won't be able to
+ store all names allowed by FAT. In FAT, a name can have max 255
+ characters (not bytes!). Since the UTF-8 encoding of a char may take
+ up to 4 bytes, there will be names that we won't be able to store
+ completely. For such names, the short DOS name is used. */
+#define FAT_FILENAME_BYTES 256
+
+struct fat_direntry
+{
+ unsigned char name[FAT_FILENAME_BYTES]; /* UTF-8 encoded name plus \0 */
+ unsigned short attr; /* Attributes */
+ unsigned char crttimetenth; /* Millisecond creation
+ time stamp (0-199) */
+ unsigned short crttime; /* Creation time */
+ unsigned short crtdate; /* Creation date */
+ unsigned short lstaccdate; /* Last access date */
+ unsigned short wrttime; /* Last write time */
+ unsigned short wrtdate; /* Last write date */
+ unsigned long filesize; /* File size in bytes */
+ long firstcluster; /* fstclusterhi<<16 + fstcluslo */
+};
+
+#define FAT_ATTR_READ_ONLY 0x01
+#define FAT_ATTR_HIDDEN 0x02
+#define FAT_ATTR_SYSTEM 0x04
+#define FAT_ATTR_VOLUME_ID 0x08
+#define FAT_ATTR_DIRECTORY 0x10
+#define FAT_ATTR_ARCHIVE 0x20
+#define FAT_ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
+
+struct fat_file
+{
+ long firstcluster; /* first cluster in file */
+ long lastcluster; /* cluster of last access */
+ long lastsector; /* sector of last access */
+ long clusternum; /* current clusternum */
+ long sectornum; /* sector number in this cluster */
+ unsigned int direntry; /* short dir entry index from start of dir */
+ unsigned int direntries; /* number of dir entries used by this file */
+ long dircluster; /* first cluster of dir */
+ bool eof;
+#ifdef HAVE_MULTIVOLUME
+ int volume; /* file resides on which volume */
+#endif
+};
+
+struct fat_dir
+{
+ unsigned int entry;
+ unsigned int entrycount;
+ long sector;
+ struct fat_file file;
+ unsigned char sectorcache[3][SECTOR_SIZE];
+};
+
+#ifdef HAVE_HOTSWAP
+extern void fat_lock(void);
+extern void fat_unlock(void);
+#endif
+
+extern void fat_init(void);
+extern int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector);
+extern int fat_unmount(int volume, bool flush);
+extern void fat_size(IF_MV2(int volume,) /* public for info */
+ unsigned long* size,
+ unsigned long* free);
+extern int fat_check_free(IF_MV2(int volume,) unsigned long size);
+extern void fat_recalc_free(IF_MV_NONVOID(int volume)); /* public for debug info screen */
+extern int fat_create_dir(const char *name,
+ struct fat_dir* newdir,
+ struct fat_dir* dir);
+extern int fat_open(IF_MV2(int volume,)
+ long cluster,
+ struct fat_file* ent,
+ const struct fat_dir* dir);
+extern int fat_create_file(const char *name,
+ struct fat_file* ent,
+ struct fat_dir* dir);
+extern long fat_readwrite(struct fat_file *ent, long sectorcount,
+ void *buf, bool write);
+extern int fat_closewrite(struct fat_file *ent, long size, int attr);
+extern int fat_seek(struct fat_file *ent, unsigned long sector);
+extern int fat_remove(struct fat_file *ent);
+extern int fat_truncate(const struct fat_file *ent);
+extern int fat_rename(struct fat_file *file,
+ struct fat_dir *dir,
+ const unsigned char* newname,
+ long size, int attr);
+
+extern int fat_opendir(IF_MV2(int volume,)
+ struct fat_dir *ent, unsigned long currdir,
+ const struct fat_dir *parent_dir);
+extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);
+extern unsigned int fat_get_cluster_size(IF_MV_NONVOID(int volume)); /* public for debug info screen */
+extern bool fat_ismounted(int volume);
+
+#ifndef _ROCKBOX_FILE_H_
+#include <rockbox_file.h>
+#endif
+
+#ifndef _ROCKBOX_DIR_H
+#include <rockbox_dir.h>
+#endif
+
+/* Added to rockbox_wrapper.c */
+unsigned int rockbox_fat_size(void);
+unsigned int rockbox_fat_free(unsigned long size);
+
+
+#endif /* #ifndef ROCKBOX_FAT_H */
diff --git a/include/rockbox_file.h b/include/rockbox_file.h
new file mode 100644
index 000000000..063c04948
--- /dev/null
+++ b/include/rockbox_file.h
@@ -0,0 +1,89 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************
+ * Source file dumped from rockbox-3.1 distribution.
+ * $Id: file.h 17847 2008-06-28 18:10:04Z bagder $
+ * Copyright (C) 2002 by Björn Stenberg
+ ****************************************************************************
+ * See file CREDITS for list of people who contributed to the U-boot
+ * project.
+ *
+ * 01/07/2008 etienne.carriere@stnwireless.com - update u-boot port from rockbox-3.1
+ ***************************************************************************
+ */
+#ifndef _ROCKBOX_FILE_H_
+#define _ROCKBOX_FILE_H_
+
+#include <linux/types.h>
+
+#define MAX_PATH 260
+#define MAX_OPEN_FILES 11
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+#ifndef SEEK_END
+#define SEEK_END 2
+#endif
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#define O_WRONLY 1
+#define O_RDWR 2
+#define O_CREAT 4
+#define O_APPEND 8
+#define O_TRUNC 0x10
+#endif
+
+#ifdef SIMULATOR
+#define open(x,y) sim_open(x,y)
+#define creat(x) sim_creat(x)
+#define remove(x) sim_remove(x)
+#define rename(x,y) sim_rename(x,y)
+#define filesize(x) sim_filesize(x)
+#define fsync(x) sim_fsync(x)
+#define ftruncate(x,y) sim_ftruncate(x,y)
+#define lseek(x,y,z) sim_lseek(x,y,z)
+#define read(x,y,z) sim_read(x,y,z)
+#define write(x,y,z) sim_write(x,y,z)
+#define close(x) sim_close(x)
+#endif
+
+typedef int (*open_func)(const char* pathname, int flags);
+typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
+typedef int (*creat_func)(const char *pathname);
+typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
+typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
+ int(*_compar)(const void *, const void *));
+
+extern int open(const char *pathname, int flags);
+extern int close(int fd);
+extern int fsync(int fd);
+extern ssize_t read(int fd, void *buf, size_t count);
+extern off_t lseek(int fildes, off_t offset, int whence);
+extern int creat(const char *pathname);
+extern ssize_t write(int fd, const void *buf, size_t count);
+extern int remove(const char *pathname);
+extern int rename(const char *path, const char *newname);
+extern int ftruncate(int fd, off_t length);
+extern off_t filesize(int fd);
+extern int release_files(int volume);
+
+#endif /* #ifndef _ROCKBOX_FILE_H_ */
diff --git a/include/rockbox_mv.h b/include/rockbox_mv.h
new file mode 100644
index 000000000..98bd15a98
--- /dev/null
+++ b/include/rockbox_mv.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************
+ * Source file dumped from rockbox-3.1 distribution.
+ * Copyright (C) 2008 by Frank Gevaerts
+ ****************************************************************************
+ * See file CREDITS for list of people who contributed to the U-boot
+ * project.
+ *
+ * 01-jan-2008 etienne.carriere@stnwireless.com - Port to U-boot from rockbox-3.1
+ ***************************************************************************
+ */
+#ifndef __MV_H__
+#define __MV_H__
+
+/* 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.
+ * U-boot port: well do not support HAVE_MULTIVOLUME !!!
+ * that not U-boot config switch syntax: keep it like that to easy next upgrade...
+ */
+#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
+
+#endif