summaryrefslogtreecommitdiffstats
path: root/u-boot/include
diff options
context:
space:
mode:
authorH. Nikolaus Schaller <hns@goldelico.com>2013-01-10 16:42:11 +0100
committerH. Nikolaus Schaller <hns@goldelico.com>2013-01-10 16:42:11 +0100
commit1d18c95643416cc9f1577755922e6593b508e8da (patch)
tree3d30910058cbfbddc388357d29307aaa0a615e90 /u-boot/include
parent2f7f1bd2415b74d98cfb8e0a0cd5e6436261de4a (diff)
downloadbootable_bootloader_goldelico_gta04-1d18c95643416cc9f1577755922e6593b508e8da.zip
bootable_bootloader_goldelico_gta04-1d18c95643416cc9f1577755922e6593b508e8da.tar.gz
bootable_bootloader_goldelico_gta04-1d18c95643416cc9f1577755922e6593b508e8da.tar.bz2
made ext4 and new general ls/load commands work
Diffstat (limited to 'u-boot/include')
-rw-r--r--u-boot/include/common.h87
-rw-r--r--u-boot/include/config_defaults.h1
-rw-r--r--u-boot/include/configs/omap3_beagle.h2
-rw-r--r--u-boot/include/configs/omap3_gta04.h14
-rwxr-xr-x[-rw-r--r--]u-boot/include/fat.h32
-rwxr-xr-xu-boot/include/fs.h65
-rwxr-xr-x[-rw-r--r--]u-boot/include/part.h44
7 files changed, 217 insertions, 28 deletions
diff --git a/u-boot/include/common.h b/u-boot/include/common.h
index d8c912d..d5ec64d 100644
--- a/u-boot/include/common.h
+++ b/u-boot/include/common.h
@@ -750,4 +750,91 @@ int cpu_release(int nr, int argc, char * const argv[]);
#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+/*
+ * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It
+ * is used to align DMA buffers.
+ */
+#ifndef __ASSEMBLY__
+// #include <asm/cache.h>
+#define ARCH_DMA_MINALIGN 64 // for ARM
+#endif
+
+/*
+ * The ALLOC_CACHE_ALIGN_BUFFER macro is used to allocate a buffer on the
+ * stack that meets the minimum architecture alignment requirements for DMA.
+ * Such a buffer is useful for DMA operations where flushing and invalidating
+ * the cache before and after a read and/or write operation is required for
+ * correct operations.
+ *
+ * When called the macro creates an array on the stack that is sized such
+ * that:
+ *
+ * 1) The beginning of the array can be advanced enough to be aligned.
+ *
+ * 2) The size of the aligned portion of the array is a multiple of the minimum
+ * architecture alignment required for DMA.
+ *
+ * 3) The aligned portion contains enough space for the original number of
+ * elements requested.
+ *
+ * The macro then creates a pointer to the aligned portion of this array and
+ * assigns to the pointer the address of the first element in the aligned
+ * portion of the array.
+ *
+ * Calling the macro as:
+ *
+ * ALLOC_CACHE_ALIGN_BUFFER(uint32_t, buffer, 1024);
+ *
+ * Will result in something similar to saying:
+ *
+ * uint32_t buffer[1024];
+ *
+ * The following differences exist:
+ *
+ * 1) The resulting buffer is guaranteed to be aligned to the value of
+ * ARCH_DMA_MINALIGN.
+ *
+ * 2) The buffer variable created by the macro is a pointer to the specified
+ * type, and NOT an array of the specified type. This can be very important
+ * if you want the address of the buffer, which you probably do, to pass it
+ * to the DMA hardware. The value of &buffer is different in the two cases.
+ * In the macro case it will be the address of the pointer, not the address
+ * of the space reserved for the buffer. However, in the second case it
+ * would be the address of the buffer. So if you are replacing hard coded
+ * stack buffers with this macro you need to make sure you remove the & from
+ * the locations where you are taking the address of the buffer.
+ *
+ * Note that the size parameter is the number of array elements to allocate,
+ * not the number of bytes.
+ *
+ * This macro can not be used outside of function scope, or for the creation
+ * of a function scoped static buffer. It can not be used to create a cache
+ * line aligned global buffer.
+ */
+#define ALLOC_ALIGN_BUFFER(type, name, size, align) \
+char __##name[ROUND(size * sizeof(type), align) + (align - 1)]; \
+\
+type *name = (type *) ALIGN((uintptr_t)__##name, align)
+#define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \
+ALLOC_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
+
+/*
+ * DEFINE_CACHE_ALIGN_BUFFER() is similar to ALLOC_CACHE_ALIGN_BUFFER, but it's
+ * purpose is to allow allocating aligned buffers outside of function scope.
+ * Usage of this macro shall be avoided or used with extreme care!
+ */
+#define DEFINE_ALIGN_BUFFER(type, name, size, align) \
+static char __##name[roundup(size * sizeof(type), align)] \
+__attribute__((aligned(align))); \
+\
+static type *name = (type *)__##name
+#define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) \
+DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
+
+/* Pull in stuff for the build system */
+#ifdef DO_DEPS_ONLY
+# include <environment.h>
+#endif
+
+
#endif /* __COMMON_H_ */
diff --git a/u-boot/include/config_defaults.h b/u-boot/include/config_defaults.h
index abdf3be..c822bbd 100644
--- a/u-boot/include/config_defaults.h
+++ b/u-boot/include/config_defaults.h
@@ -17,5 +17,6 @@
#define CONFIG_GZIP 1
#define CONFIG_ZLIB 1
+#define CONFIG_PARTITIONS 1
#endif
diff --git a/u-boot/include/configs/omap3_beagle.h b/u-boot/include/configs/omap3_beagle.h
index 519da79..9866d49 100644
--- a/u-boot/include/configs/omap3_beagle.h
+++ b/u-boot/include/configs/omap3_beagle.h
@@ -322,7 +322,7 @@
#define CONFIG_ENV_OFFSET boot_flash_off
#define CONFIG_ENV_ADDR SMNAND_ENV_OFFSET
-#define CONFIG_START_WITH_DEFAULT_ENVIRONMENT 1
+//#define CONFIG_START_WITH_DEFAULT_ENVIRONMENT 1
#ifndef __ASSEMBLY__
extern unsigned int boot_flash_base;
diff --git a/u-boot/include/configs/omap3_gta04.h b/u-boot/include/configs/omap3_gta04.h
index c6269af..69eb055 100644
--- a/u-boot/include/configs/omap3_gta04.h
+++ b/u-boot/include/configs/omap3_gta04.h
@@ -31,15 +31,13 @@
#define CONFIG_CMD_UNZIP 1 /* for reducing size of splash image */
-// #undef CONFIG_CMD_JFFS2
-// #define CONFIG_CMD_JFFS2 1 /* to access the rootfs in NAND flash */
-// FIXME: needs to add configs for the partitions so that JFFS2 runs in the correct NAND partition
-
-#define CONFIG_CMD_UBIFS 1
-
-#define CONFIG_CMD_EXT2 1
-#define CONFIG_CMD_EXT4 1
+// #define CONFIG_CMD_UBIFS 1 // broken
+#define CONFIG_FS_FAT 1
+#define CONFIG_FS_EXT2 1
+#define CONFIG_FS_EXT4 1
+#define CONFIG_CMD_FS 1
+#define CONFIG_CMD_EXT4 1
#undef CONFIG_SYS_PROMPT
#define CONFIG_SYS_PROMPT "GTA04 # "
diff --git a/u-boot/include/fat.h b/u-boot/include/fat.h
index afb2116..706cd7a 100644..100755
--- a/u-boot/include/fat.h
+++ b/u-boot/include/fat.h
@@ -33,22 +33,15 @@
/* Maximum Long File Name length supported here is 128 UTF-16 code units */
#define VFAT_MAXLEN_BYTES 256 /* Maximum LFN buffer in bytes */
#define VFAT_MAXSEQ 9 /* Up to 9 of 13 2-byte UTF-16 entries */
-#define LINEAR_PREFETCH_SIZE (SECTOR_SIZE*2) /* Prefetch buffer size */
-
-#define SECTOR_SIZE FS_BLOCK_SIZE
-
-#define FS_BLOCK_SIZE 512
-
-#if FS_BLOCK_SIZE != SECTOR_SIZE
-#error FS_BLOCK_SIZE != SECTOR_SIZE - This code needs to be fixed!
-#endif
+#define PREFETCH_BLOCKS 2
#define MAX_CLUSTSIZE 65536
-#define DIRENTSPERBLOCK (FS_BLOCK_SIZE/sizeof(dir_entry))
-#define DIRENTSPERCLUST ((mydata->clust_size*SECTOR_SIZE)/sizeof(dir_entry))
+#define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry))
+#define DIRENTSPERCLUST ((mydata->clust_size * mydata->sect_size) / \
+ sizeof(dir_entry))
#define FATBUFBLOCKS 6
-#define FATBUFSIZE (FS_BLOCK_SIZE*FATBUFBLOCKS)
+#define FATBUFSIZE (mydata->sect_size * FATBUFBLOCKS)
#define FAT12BUFSIZE ((FATBUFSIZE*2)/3)
#define FAT16BUFSIZE (FATBUFSIZE/2)
#define FAT32BUFSIZE (FATBUFSIZE/4)
@@ -106,6 +99,8 @@
#endif
#define TOLOWER(c) if((c) >= 'A' && (c) <= 'Z'){(c)+=('a' - 'A');}
+#define TOUPPER(c) if ((c) >= 'a' && (c) <= 'z') \
+ (c) -= ('a' - 'A');
#define START(dent) (FAT2CPU16((dent)->start) \
+ (mydata->fatsize != 32 ? 0 : \
(FAT2CPU16((dent)->starthi) << 16)))
@@ -181,13 +176,14 @@ typedef struct dir_slot {
* (see FAT32 accesses)
*/
typedef struct {
- __u8 fatbuf[FATBUFSIZE]; /* Current FAT buffer */
+ __u8 *fatbuf; /* Current FAT buffer */
int fatsize; /* Size of FAT in bits */
- __u16 fatlength; /* Length of FAT in sectors */
+ __u32 fatlength; /* Length of FAT in sectors */
__u16 fat_sect; /* Starting sector of the FAT */
- __u16 rootdir_sect; /* Start sector of root directory */
+ __u32 rootdir_sect; /* Start sector of root directory */
+ __u16 sect_size; /* Size of sectors in bytes */
__u16 clust_size; /* Size of clusters in sectors */
- short data_begin; /* The sector of the first cluster, can be negative */
+ int data_begin; /* The sector of the first cluster, can be negative */
int fatbufnum; /* Used by get_fatent, init to -1 */
} fsdata;
@@ -212,8 +208,12 @@ file_read_func file_fat_read;
int file_cd(const char *path);
int file_fat_detectfs(void);
int file_fat_ls(const char *dir);
+long file_fat_read_at(const char *filename, unsigned long pos, void *buffer,
+ unsigned long maxsize);
long file_fat_read(const char *filename, void *buffer, unsigned long maxsize);
const char *file_getfsname(int idx);
+int fat_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
int fat_register_device(block_dev_desc_t *dev_desc, int part_no);
+int file_fat_write(const char *filename, void *buffer, unsigned long maxsize);
#endif /* _FAT_H_ */
diff --git a/u-boot/include/fs.h b/u-boot/include/fs.h
new file mode 100755
index 0000000..4f30a38
--- /dev/null
+++ b/u-boot/include/fs.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _FS_H
+#define _FS_H
+
+#include <common.h>
+
+#define FS_TYPE_ANY 0
+#define FS_TYPE_FAT 1
+#define FS_TYPE_EXT 2
+
+/*
+ * Tell the fs layer which block device an partition to use for future
+ * commands. This also internally identifies the filesystem that is present
+ * within the partition. The identification process may be limited to a
+ * specific filesystem type by passing FS_* in the fstype parameter.
+ *
+ * Returns 0 on success.
+ * Returns non-zero if there is an error accessing the disk or partition, or
+ * no known filesystem type could be recognized on it.
+ */
+int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);
+
+/*
+ * Print the list of files on the partition previously set by fs_set_blk_dev(),
+ * in directory "dirname".
+ *
+ * Returns 0 on success. Returns non-zero on error.
+ */
+int fs_ls(const char *dirname);
+
+/*
+ * Read file "filename" from the partition previously set by fs_set_blk_dev(),
+ * to address "addr", starting at byte offset "offset", and reading "len"
+ * bytes. "offset" may be 0 to read from the start of the file. "len" may be
+ * 0 to read the entire file. Note that not all filesystem types support
+ * either/both offset!=0 or len!=0.
+ *
+ * Returns number of bytes read on success. Returns <= 0 on error.
+ */
+int fs_read(const char *filename, ulong addr, int offset, int len);
+
+/*
+ * Common implementation for various filesystem commands, optionally limited
+ * to a specific filesystem type via the fstype parameter.
+ */
+int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype, int cmdline_base);
+int do_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+ int fstype);
+
+#endif /* _FS_H */
diff --git a/u-boot/include/part.h b/u-boot/include/part.h
index 3cdae02..27ea283 100644..100755
--- a/u-boot/include/part.h
+++ b/u-boot/include/part.h
@@ -36,7 +36,7 @@ typedef struct block_dev_desc {
#ifdef CONFIG_LBA48
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
#endif
- lbaint_t lba; /* number of blocks */
+ lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */
char vendor [40+1]; /* IDE model, SCSI Vendor */
char product[20+1]; /* IDE Serial no, SCSI product */
@@ -49,6 +49,9 @@ typedef struct block_dev_desc {
unsigned long start,
lbaint_t blkcnt,
const void *buffer);
+ unsigned long (*block_erase)(int dev,
+ unsigned long start,
+ lbaint_t blkcnt);
void *priv; /* driver private struct pointer */
}block_dev_desc_t;
@@ -90,10 +93,15 @@ typedef struct disk_partition {
ulong blksz; /* block size in bytes */
uchar name[32]; /* partition name */
uchar type[32]; /* string type description */
+ int bootable; /* Active/Bootable flag is set */
+#ifdef CONFIG_PARTITION_UUIDS
+ char uuid[37]; /* filesystem UUID as string, if exists */
+#endif
} disk_partition_t;
/* Misc _get_dev functions */
-block_dev_desc_t* get_dev(char* ifname, int dev);
+#ifdef CONFIG_PARTITIONS
+block_dev_desc_t *get_dev(const char *ifname, int dev);
block_dev_desc_t* ide_get_dev(int dev);
block_dev_desc_t* sata_get_dev(int dev);
block_dev_desc_t* scsi_get_dev(int dev);
@@ -107,7 +115,37 @@ int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t
void print_part (block_dev_desc_t *dev_desc);
void init_part (block_dev_desc_t *dev_desc);
void dev_print(block_dev_desc_t *dev_desc);
-
+int get_device(const char *ifname, const char *dev_str,
+ block_dev_desc_t **dev_desc);
+int get_device_and_partition(const char *ifname, const char *dev_part_str,
+ block_dev_desc_t **dev_desc,
+ disk_partition_t *info, int allow_whole_dev);
+#else
+static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
+{ return NULL; }
+static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
+
+static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
+ disk_partition_t *info) { return -1; }
+static inline void print_part (block_dev_desc_t *dev_desc) {}
+static inline void init_part (block_dev_desc_t *dev_desc) {}
+static inline void dev_print(block_dev_desc_t *dev_desc) {}
+static inline int get_device(const char *ifname, const char *dev_str,
+ block_dev_desc_t **dev_desc)
+{ return -1; }
+static inline int get_device_and_partition(const char *ifname,
+ const char *dev_part_str,
+ block_dev_desc_t **dev_desc,
+ disk_partition_t *info,
+ int allow_whole_dev)
+{ *dev_desc = NULL; return -1; }
+#endif
#ifdef CONFIG_MAC_PARTITION
/* disk/part_mac.c */