]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_ext4.c
ext4fs ls load support
[karo-tx-uboot.git] / common / cmd_ext4.c
1 /*
2  * (C) Copyright 2011 - 2012 Samsung Electronics
3  * EXT4 filesystem implementation in Uboot by
4  * Uma Shankar <uma.shankar@samsung.com>
5  * Manjunatha C Achar <a.manjunatha@samsung.com>
6  *
7  * Ext4fs support
8  * made from existing cmd_ext2.c file of Uboot
9  *
10  * (C) Copyright 2004
11  * esd gmbh <www.esd-electronics.com>
12  * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
13  *
14  * made from cmd_reiserfs by
15  *
16  * (C) Copyright 2003 - 2004
17  * Sysgo Real-Time Solutions, AG <www.elinos.com>
18  * Pavel Bartusek <pba@sysgo.com>
19  *
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License as
22  * published by the Free Software Foundation; either version 2 of
23  * the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33  * MA 02111-1307 USA
34  *
35  */
36
37 /*
38  * Changelog:
39  *      0.1 - Newly created file for ext4fs support. Taken from cmd_ext2.c
40  *              file in uboot. Added ext4fs ls load and write support.
41  */
42
43 #include <common.h>
44 #include <part.h>
45 #include <config.h>
46 #include <command.h>
47 #include <image.h>
48 #include <linux/ctype.h>
49 #include <asm/byteorder.h>
50 #include <ext_common.h>
51 #include <ext4fs.h>
52 #include <linux/stat.h>
53 #include <malloc.h>
54
55 #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
56 #include <usb.h>
57 #endif
58
59 #if !defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_EFI_PARTITION)
60 #error DOS or EFI partition support must be selected
61 #endif
62
63 uint64_t total_sector;
64 uint64_t part_offset;
65
66 #define DOS_PART_MAGIC_OFFSET           0x1fe
67 #define DOS_FS_TYPE_OFFSET              0x36
68 #define DOS_FS32_TYPE_OFFSET            0x52
69
70 int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc,
71                                                 char *const argv[])
72 {
73         if (do_ext_load(cmdtp, flag, argc, argv))
74                 return -1;
75
76         return 0;
77 }
78
79 int do_ext4_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
80 {
81         if (do_ext_ls(cmdtp, flag, argc, argv))
82                 return -1;
83
84         return 0;
85 }
86
87 U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls,
88            "list files in a directory (default /)",
89            "<interface> <dev[:part]> [directory]\n"
90            "      - list files from 'dev' on 'interface' in a 'directory'");
91
92 U_BOOT_CMD(ext4load, 6, 0, do_ext4_load,
93            "load binary file from a Ext4 filesystem",
94            "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
95            "      - load binary file 'filename' from 'dev' on 'interface'\n"
96            "             to address 'addr' from ext4 filesystem");