parent
fda840672d
commit
b2c5310d4d
2
Makefile
2
Makefile
|
@ -880,7 +880,7 @@ depend dep:
|
|||
CLEAN_DIRS += $(MODVERDIR)
|
||||
CLEAN_FILES += uboot System.map \
|
||||
.tmp_kallsyms* .tmp_version .tmp_uboot* .tmp_System.map \
|
||||
uboot.bin uboot.S
|
||||
uboot.bin uboot.S $(uboot-lds)
|
||||
|
||||
# Directories & files removed with 'make mrproper'
|
||||
MRPROPER_DIRS += include/config include2 usr/include
|
||||
|
|
|
@ -13,6 +13,10 @@ config CACHELINE_SIZE
|
|||
int
|
||||
default 32 if MPC5200
|
||||
|
||||
config HAS_REGINFO
|
||||
bool
|
||||
default y if MPC5200
|
||||
|
||||
choice
|
||||
prompt "Select your board"
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# U-Boot version: 2.0.0-trunk
|
||||
# Fri Jun 29 15:39:05 2007
|
||||
# Sun Jul 1 14:40:26 2007
|
||||
#
|
||||
CONFIG_TEXT_BASE="0x0"
|
||||
CONFIG_TEXT_BASE="0x1000000"
|
||||
CONFIG_ARCH_MPC5200=y
|
||||
CONFIG_MPC5200=y
|
||||
CONFIG_CACHELINE_SIZE=32
|
||||
CONFIG_MACH_PHYCORE_MPC5200B_TINY=y
|
||||
CONFIG_MACH_PHYCORE_MPC5200B_TINY_REV_1=y
|
||||
CONFIG_ZLIB=y
|
||||
CONFIG_GREGORIAN_CALENDER=y
|
||||
|
||||
#
|
||||
|
@ -25,13 +24,15 @@ CONFIG_MAXARGS=16
|
|||
CONFIG_HUSH_PARSER=y
|
||||
CONFIG_PROMPT_HUSH_PS2="> "
|
||||
CONFIG_ZERO_BOOTDELAY_CHECK=y
|
||||
CONFIG_DYNAMIC_CRC_TABLE=y
|
||||
CONFIG_ERRNO_MESSAGES=y
|
||||
CONFIG_TIMESTAMP=y
|
||||
# CONFIG_CONSOLE_ACTIVATE_FIRST is not set
|
||||
CONFIG_CONSOLE_ACTIVATE_ALL=y
|
||||
CONFIG_CONSOLE_ACTIVATE_FIRST=y
|
||||
CONFIG_OF_FLAT_TREE=y
|
||||
|
||||
#
|
||||
# Debugging
|
||||
#
|
||||
|
||||
#
|
||||
# Commands
|
||||
#
|
||||
|
@ -82,11 +83,9 @@ CONFIG_CMD_FLASH=y
|
|||
#
|
||||
CONFIG_CMD_BOOTM=y
|
||||
CONFIG_CMD_BOOTM_ZLIB=y
|
||||
# CONFIG_CMD_BOOTM_BZLIB is not set
|
||||
|
||||
#
|
||||
# Debugging
|
||||
#
|
||||
CONFIG_CMD_BOOTM_BZLIB=y
|
||||
CONFIG_CMD_RESET=y
|
||||
CONFIG_CMD_GO=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NET_BOOTP=y
|
||||
CONFIG_NET_DHCP=y
|
||||
|
@ -130,9 +129,13 @@ CONFIG_DRIVER_NET_MPC5200=y
|
|||
CONFIG_HAS_CFI=y
|
||||
CONFIG_DRIVER_CFI=y
|
||||
# CONFIG_DRIVER_CFI_NEW is not set
|
||||
CONFIG_CFI_BUFFER_WRITE=y
|
||||
# CONFIG_CFI_BUFFER_WRITE is not set
|
||||
|
||||
#
|
||||
# Filesystem support
|
||||
#
|
||||
CONFIG_FS_CRAMFS=y
|
||||
CONFIG_ZLIB=y
|
||||
CONFIG_BZLIB=y
|
||||
CONFIG_CRC32=y
|
||||
CONFIG_DYNAMIC_CRC_TABLE=y
|
||||
|
|
|
@ -8,6 +8,6 @@ obj-y += ppcstring.o
|
|||
obj-y += ticks.o
|
||||
obj-y += time.o
|
||||
obj-y += misc.o
|
||||
obj-y += ppclinux.o
|
||||
obj-$(CONFIG_CMD_BOOTM) += ppclinux.o
|
||||
obj-y += board_data.o
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <driver.h>
|
||||
#include <cfi_flash.h>
|
||||
#include <init.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <pci.h>
|
||||
#include <asm/arch/fec.h>
|
||||
#include <types.h>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
config REGINFO
|
||||
bool
|
||||
|
||||
menu "Commands "
|
||||
|
||||
menu "scripting "
|
||||
|
@ -25,6 +28,49 @@ config CMD_HELP
|
|||
|
||||
endmenu
|
||||
|
||||
menu "file commands "
|
||||
|
||||
config CMD_LS
|
||||
bool
|
||||
prompt "ls"
|
||||
|
||||
config CMD_RM
|
||||
bool
|
||||
prompt "rm"
|
||||
|
||||
config CMD_CAT
|
||||
bool
|
||||
prompt "cat"
|
||||
|
||||
config CMD_MKDIR
|
||||
bool
|
||||
prompt "mkdir"
|
||||
|
||||
config CMD_RMDIR
|
||||
bool
|
||||
prompt "rmdir"
|
||||
|
||||
config CMD_CP
|
||||
bool
|
||||
prompt "cp"
|
||||
|
||||
config CMD_PWD
|
||||
bool
|
||||
prompt "pwd"
|
||||
|
||||
config CMD_CD
|
||||
bool
|
||||
prompt "cd"
|
||||
|
||||
config CMD_MOUNT
|
||||
bool
|
||||
prompt "mount"
|
||||
|
||||
config CMD_UMOUNT
|
||||
bool
|
||||
prompt "umount"
|
||||
|
||||
endmenu
|
||||
|
||||
menu "console "
|
||||
|
||||
|
@ -151,4 +197,14 @@ config CMD_GO
|
|||
|
||||
endmenu
|
||||
|
||||
config CMD_PARTITION
|
||||
bool
|
||||
prompt "addpart/delpart"
|
||||
|
||||
config CMD_REGINFO
|
||||
depends on HAS_REGINFO
|
||||
select REGINFO
|
||||
bool
|
||||
prompt "reginfo"
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -2,7 +2,6 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
|
|||
obj-$(CONFIG_CMD_LOADB) += loadb.o xyzModem.o
|
||||
obj-$(CONFIG_CMD_LOADS) += loads.o
|
||||
obj-$(CONFIG_CMD_ECHO) += echo.o
|
||||
#obj-$(CONFIG_CMD_FLASH) += flash.o
|
||||
obj-$(CONFIG_CMD_MEMORY) += mem.o
|
||||
obj-$(CONFIG_CMD_MII) += mii.o
|
||||
obj-$(CONFIG_CMD_I2C) += i2c.o
|
||||
|
@ -15,6 +14,16 @@ obj-$(CONFIG_CMD_SLEEP) += sleep.o
|
|||
obj-$(CONFIG_CMD_RESET) += reset.o
|
||||
obj-$(CONFIG_CMD_GO) += go.o
|
||||
obj-$(CONFIG_CMD_ENVIRONMENT) += environment.o
|
||||
obj-y += fs.o
|
||||
obj-$(CONFIG_NET) += net.o
|
||||
obj-$(CONFIG_CMD_PARTITION) += partition.o
|
||||
obj-$(CONFIG_CMD_LS) += ls.o
|
||||
obj-$(CONFIG_CMD_CD) += cd.o
|
||||
obj-$(CONFIG_CMD_PWD) += pwd.o
|
||||
obj-$(CONFIG_CMD_MKDIR) += mkdir.o
|
||||
obj-$(CONFIG_CMD_RMDIR) += rmdir.o
|
||||
obj-$(CONFIG_CMD_CP) += cp.o
|
||||
obj-$(CONFIG_CMD_RM) += rm.o
|
||||
obj-$(CONFIG_CMD_CAT) += cat.o
|
||||
obj-$(CONFIG_CMD_MOUNT) += mount.o
|
||||
obj-$(CONFIG_CMD_UMOUNT) += umount.o
|
||||
obj-$(CONFIG_CMD_REGINFO) += reginfo.o
|
||||
|
|
|
@ -632,24 +632,6 @@ do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
|
|||
}
|
||||
#endif
|
||||
|
||||
int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int rcode = 0;
|
||||
#ifndef CONFIG_HUSH_PARSER
|
||||
if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1;
|
||||
#else
|
||||
if (parse_string_outer(getenv("bootcmd"),
|
||||
FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1;
|
||||
#endif
|
||||
return rcode;
|
||||
}
|
||||
|
||||
U_BOOT_CMD_START(boot)
|
||||
.maxargs = 1,
|
||||
.cmd = do_bootd,
|
||||
.usage = "boot default, i.e., run 'bootcmd'",
|
||||
U_BOOT_CMD_END
|
||||
|
||||
#if 0
|
||||
int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <errno.h>
|
||||
#include <xfuncs.h>
|
||||
#include <malloc.h>
|
||||
|
||||
static int do_cat(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int fd, i;
|
||||
char *buf;
|
||||
int err = 0;
|
||||
int args = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
perror("cat");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf = xmalloc(1024);
|
||||
|
||||
while (args < argc) {
|
||||
fd = open(argv[args], 0);
|
||||
if (fd < 0) {
|
||||
printf("could not open %s: %s\n", argv[args], errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
while((ret = read(fd, buf, 1024)) > 0) {
|
||||
for(i = 0; i < ret; i++) {
|
||||
if (isprint(buf[i]) || buf[i] == '\n' || buf[i] == '\t')
|
||||
putc(buf[i]);
|
||||
else
|
||||
putc('.');
|
||||
}
|
||||
if(ctrlc()) {
|
||||
err = 1;
|
||||
close(fd);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
args++;
|
||||
}
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cat_help[] =
|
||||
"Usage: cat [FILES]\n"
|
||||
"Concatenate files on stdout. Currently only printable characters\n"
|
||||
"and \\n and \\t are printed, but this should be optional\n";
|
||||
|
||||
U_BOOT_CMD_START(cat)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_cat,
|
||||
.usage = "concatenate file(s)",
|
||||
U_BOOT_CMD_HELP(cmd_cat_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,32 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int do_cd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (argc == 1)
|
||||
ret = chdir("/");
|
||||
else
|
||||
ret = chdir(argv[1]);
|
||||
|
||||
if (ret) {
|
||||
perror("chdir");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cd_help[] =
|
||||
"Usage: cd [directory]\n"
|
||||
"change to directory. If called without argument, change to /\n";
|
||||
|
||||
U_BOOT_CMD_START(cd)
|
||||
.maxargs = 2,
|
||||
.cmd = do_cd,
|
||||
.usage = "change working directory",
|
||||
U_BOOT_CMD_HELP(cmd_cd_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,68 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <xfuncs.h>
|
||||
|
||||
#define RW_BUF_SIZE (ulong)4096
|
||||
|
||||
int do_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int r, w, ret = 1;
|
||||
int src = 0, dst = 0;
|
||||
char *rw_buf = NULL;
|
||||
|
||||
rw_buf = xmalloc(RW_BUF_SIZE);
|
||||
|
||||
src = open(argv[1], O_RDONLY);
|
||||
if (src < 0) {
|
||||
printf("could not open %s: %s\n", src, errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
dst = open(argv[2], O_WRONLY | O_CREAT);
|
||||
if ( dst < 0) {
|
||||
printf("could not open %s: %s\n", dst, errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
r = read(src, rw_buf, RW_BUF_SIZE);
|
||||
if (read < 0) {
|
||||
perror("read");
|
||||
goto out;
|
||||
}
|
||||
if (!r)
|
||||
break;
|
||||
w = write(dst, rw_buf, r);
|
||||
if (w < 0) {
|
||||
perror("write");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
out:
|
||||
free(rw_buf);
|
||||
if (src)
|
||||
close(src);
|
||||
if (dst)
|
||||
close(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cp_help[] =
|
||||
"Usage: cp <source> <destination>\n"
|
||||
"cp copies file <source> to <destination>.\n"
|
||||
"Currently only this form is supported and you have to specify the exact target\n"
|
||||
"filename (not a target directory).\n"
|
||||
"Note: This command was previously used as memory copy. Currently there is no\n"
|
||||
"equivalent command for this. This must be fixed of course.\n";
|
||||
|
||||
U_BOOT_CMD_START(cp)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_cp,
|
||||
.usage = "copy files",
|
||||
U_BOOT_CMD_HELP(cmd_cp_help)
|
||||
U_BOOT_CMD_END
|
|
@ -97,7 +97,7 @@ out:
|
|||
#ifdef __U_BOOT__
|
||||
int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int ret, fd;
|
||||
char *filename, *dirname;
|
||||
|
||||
printf("saving environment\n");
|
||||
|
@ -110,9 +110,24 @@ int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||
else
|
||||
filename = argv[1];
|
||||
|
||||
fd = open(filename, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
printf("could not open %s: %s", filename, errno_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = erase(fd, ~0, 0);
|
||||
if (ret && errno != -EINVAL) {
|
||||
printf("could not erase %s: %s\n", filename, errno_str());
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = envfs_save(filename, dirname);
|
||||
if (ret)
|
||||
printf("saveenv failed\n");
|
||||
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
391
commands/fs.c
391
commands/fs.c
|
@ -1,391 +0,0 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <linux/stat.h>
|
||||
#include <xfuncs.h>
|
||||
|
||||
static void ls_one(const char *path, struct stat *s)
|
||||
{
|
||||
char modestr[11];
|
||||
unsigned long namelen = strlen(path);
|
||||
|
||||
mkmodestr(s->st_mode, modestr);
|
||||
printf("%s %8d %*.*s\n",modestr, s->st_size, namelen, namelen, path);
|
||||
}
|
||||
|
||||
int ls(const char *path, ulong flags)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
char tmp[PATH_MAX];
|
||||
struct stat s;
|
||||
|
||||
if (flags & LS_SHOWARG)
|
||||
printf("%s:\n", path);
|
||||
|
||||
if (stat(path, &s)) {
|
||||
perror("stat");
|
||||
return errno;
|
||||
}
|
||||
|
||||
if (!(s.st_mode & S_IFDIR)) {
|
||||
ls_one(path, &s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
return errno;
|
||||
|
||||
while ((d = readdir(dir))) {
|
||||
sprintf(tmp, "%s/%s", path, d->d_name);
|
||||
if (stat(tmp, &s))
|
||||
goto out;
|
||||
ls_one(d->d_name, &s);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
if (!(flags & LS_RECURSIVE))
|
||||
return 0;
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir) {
|
||||
errno = -ENOENT;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
while ((d = readdir(dir))) {
|
||||
sprintf(tmp, "%s/%s", path, d->d_name);
|
||||
normalise_path(tmp);
|
||||
if (stat(tmp, &s))
|
||||
goto out;
|
||||
if (!strcmp(d->d_name, "."))
|
||||
continue;
|
||||
if (!strcmp(d->d_name, ".."))
|
||||
continue;
|
||||
if (s.st_mode & S_IFDIR)
|
||||
ls(tmp, flags);
|
||||
}
|
||||
out:
|
||||
closedir(dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret, opt;
|
||||
ulong flags = 0;
|
||||
|
||||
getopt_reset();
|
||||
|
||||
while((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch(opt) {
|
||||
case 'R':
|
||||
flags |= LS_RECURSIVE | LS_SHOWARG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind > 1)
|
||||
flags |= LS_SHOWARG;
|
||||
|
||||
if (optind == argc) {
|
||||
ret = ls(getcwd(), flags);
|
||||
return ret ? 1 : 0;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
ret = ls(argv[optind], flags);
|
||||
if (ret) {
|
||||
perror("ls");
|
||||
return 1;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_ls_help[] =
|
||||
"Usage: ls [OPTION]... [FILE]...\n"
|
||||
"List information about the FILEs (the current directory by default).\n"
|
||||
" -R list subdirectories recursively\n";
|
||||
|
||||
U_BOOT_CMD_START(ls)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_ls,
|
||||
.usage = "list a file or directory",
|
||||
U_BOOT_CMD_HELP(cmd_ls_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_cd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (argc == 1)
|
||||
ret = chdir("/");
|
||||
else
|
||||
ret = chdir(argv[1]);
|
||||
|
||||
if (ret) {
|
||||
perror("chdir");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cd_help[] =
|
||||
"Usage: cd [directory]\n"
|
||||
"change to directory. If called without argument, change to /\n";
|
||||
|
||||
U_BOOT_CMD_START(cd)
|
||||
.maxargs = 2,
|
||||
.cmd = do_cd,
|
||||
.usage = "change working directory",
|
||||
U_BOOT_CMD_HELP(cmd_cd_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_pwd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
printf("%s\n", getcwd());
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD_START(pwd)
|
||||
.maxargs = 2,
|
||||
.cmd = do_pwd,
|
||||
.usage = "print working directory",
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_mkdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (mkdir(argv[i])) {
|
||||
printf("could not create %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_mkdir_help[] =
|
||||
"Usage: mkdir [directories]\n"
|
||||
"Create new directories\n";
|
||||
|
||||
U_BOOT_CMD_START(mkdir)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_mkdir,
|
||||
.usage = "make directories",
|
||||
U_BOOT_CMD_HELP(cmd_mkdir_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_rm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (unlink(argv[i])) {
|
||||
printf("could not remove %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_rm_help[] =
|
||||
"Usage: rm [FILES]\n"
|
||||
"Remove files\n";
|
||||
|
||||
U_BOOT_CMD_START(rm)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_rm,
|
||||
.usage = "remove files",
|
||||
U_BOOT_CMD_HELP(cmd_rm_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_rmdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (rmdir(argv[i])) {
|
||||
printf("could not remove %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_rmdir_help[] =
|
||||
"Usage: rmdir [directories]\n"
|
||||
"Remove directories. The directories have to be empty.\n";
|
||||
|
||||
U_BOOT_CMD_START(rmdir)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_rmdir,
|
||||
.usage = "remove directorie(s)",
|
||||
U_BOOT_CMD_HELP(cmd_rmdir_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_mount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
struct mtab_entry *entry = NULL;
|
||||
|
||||
if (argc == 1) {
|
||||
do {
|
||||
entry = mtab_next_entry(entry);
|
||||
if (entry) {
|
||||
printf("%s on %s type %s\n",
|
||||
entry->parent_device ? entry->parent_device->id : "none",
|
||||
entry->path,
|
||||
entry->dev->name);
|
||||
}
|
||||
} while (entry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc != 4) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ret = mount(argv[1], argv[2], argv[3]))) {
|
||||
perror("mount");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_mount_help[] =
|
||||
"Usage: mount: list mounted filesystems\n"
|
||||
"or: mount <device> <fstype> <mountpoint>\n"
|
||||
"\n"
|
||||
"Mount a filesystem of a given type to a mountpoint.\n"
|
||||
"<device> can be one of /dev/* or some arbitrary string if no\n"
|
||||
"device is needed for this driver (for example ramfs).\n"
|
||||
"<fstype> is the filesystem driver to use. Try the 'devinfo' command\n"
|
||||
"for a list of available drivers.\n"
|
||||
"<mountpoint> must be an empty directory descending directly from the\n"
|
||||
"root directory.\n";
|
||||
|
||||
U_BOOT_CMD_START(mount)
|
||||
.maxargs = 4,
|
||||
.cmd = do_mount,
|
||||
.usage = "mount a filesystem to a device",
|
||||
U_BOOT_CMD_HELP(cmd_mount_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_umount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ret = umount(argv[1]))) {
|
||||
perror("umount");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_umount_help[] =
|
||||
"Usage: umount <mountpoint>\n"
|
||||
"umount a filesystem mounted on a specific mountpoint\n";
|
||||
|
||||
U_BOOT_CMD_START(umount)
|
||||
.maxargs = 2,
|
||||
.cmd = do_umount,
|
||||
.usage = "umount a filesystem",
|
||||
U_BOOT_CMD_HELP(cmd_umount_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int do_cat(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int fd, i;
|
||||
char *buf;
|
||||
int err = 0;
|
||||
int args = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
perror("cat");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf = xmalloc(1024);
|
||||
|
||||
while (args < argc) {
|
||||
fd = open(argv[args], 0);
|
||||
if (fd < 0) {
|
||||
printf("could not open %s: %s\n", argv[args], errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
while((ret = read(fd, buf, 1024)) > 0) {
|
||||
for(i = 0; i < ret; i++) {
|
||||
if (isprint(buf[i]) || buf[i] == '\n' || buf[i] == '\t')
|
||||
putc(buf[i]);
|
||||
else
|
||||
putc('.');
|
||||
}
|
||||
if(ctrlc()) {
|
||||
err = 1;
|
||||
close(fd);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
args++;
|
||||
}
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cat_help[] =
|
||||
"Usage: cat [FILES]\n"
|
||||
"Concatenate files on stdout. Currently only printable characters\n"
|
||||
"and \\n and \\t are printed, but this should be optional\n";
|
||||
|
||||
U_BOOT_CMD_START(cat)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_cat,
|
||||
.usage = "concatenate file(s)",
|
||||
U_BOOT_CMD_HELP(cmd_cat_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,122 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <linux/stat.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
|
||||
static void ls_one(const char *path, struct stat *s)
|
||||
{
|
||||
char modestr[11];
|
||||
unsigned long namelen = strlen(path);
|
||||
|
||||
mkmodestr(s->st_mode, modestr);
|
||||
printf("%s %8d %*.*s\n",modestr, s->st_size, namelen, namelen, path);
|
||||
}
|
||||
|
||||
int ls(const char *path, ulong flags)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
char tmp[PATH_MAX];
|
||||
struct stat s;
|
||||
|
||||
if (flags & LS_SHOWARG)
|
||||
printf("%s:\n", path);
|
||||
|
||||
if (stat(path, &s)) {
|
||||
perror("stat");
|
||||
return errno;
|
||||
}
|
||||
|
||||
if (!(s.st_mode & S_IFDIR)) {
|
||||
ls_one(path, &s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
return errno;
|
||||
|
||||
while ((d = readdir(dir))) {
|
||||
sprintf(tmp, "%s/%s", path, d->d_name);
|
||||
if (stat(tmp, &s))
|
||||
goto out;
|
||||
ls_one(d->d_name, &s);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
if (!(flags & LS_RECURSIVE))
|
||||
return 0;
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir) {
|
||||
errno = -ENOENT;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
while ((d = readdir(dir))) {
|
||||
sprintf(tmp, "%s/%s", path, d->d_name);
|
||||
normalise_path(tmp);
|
||||
if (stat(tmp, &s))
|
||||
goto out;
|
||||
if (!strcmp(d->d_name, "."))
|
||||
continue;
|
||||
if (!strcmp(d->d_name, ".."))
|
||||
continue;
|
||||
if (s.st_mode & S_IFDIR)
|
||||
ls(tmp, flags);
|
||||
}
|
||||
out:
|
||||
closedir(dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret, opt;
|
||||
ulong flags = 0;
|
||||
|
||||
getopt_reset();
|
||||
|
||||
while((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch(opt) {
|
||||
case 'R':
|
||||
flags |= LS_RECURSIVE | LS_SHOWARG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind > 1)
|
||||
flags |= LS_SHOWARG;
|
||||
|
||||
if (optind == argc) {
|
||||
ret = ls(getcwd(), flags);
|
||||
return ret ? 1 : 0;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
ret = ls(argv[optind], flags);
|
||||
if (ret) {
|
||||
perror("ls");
|
||||
return 1;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_ls_help[] =
|
||||
"Usage: ls [OPTION]... [FILE]...\n"
|
||||
"List information about the FILEs (the current directory by default).\n"
|
||||
" -R list subdirectories recursively\n";
|
||||
|
||||
U_BOOT_CMD_START(ls)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_ls,
|
||||
.usage = "list a file or directory",
|
||||
U_BOOT_CMD_HELP(cmd_ls_help)
|
||||
U_BOOT_CMD_END
|
103
commands/mem.c
103
commands/mem.c
|
@ -427,60 +427,6 @@ U_BOOT_CMD(
|
|||
);
|
||||
#endif
|
||||
|
||||
int do_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int r, w, ret = 1;
|
||||
int src, dst;
|
||||
|
||||
src = open(argv[1], O_RDONLY);
|
||||
if (src < 0) {
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dst = open(argv[2], O_WRONLY | O_CREAT);
|
||||
if ( dst < 0) {
|
||||
perror("open");
|
||||
close(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
r = read(src, rw_buf, RW_BUF_SIZE);
|
||||
if (read < 0) {
|
||||
perror("read");
|
||||
goto out;
|
||||
}
|
||||
if (!r)
|
||||
break;
|
||||
w = write(dst, rw_buf, r);
|
||||
if (w < 0) {
|
||||
perror("write");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
out:
|
||||
close(src);
|
||||
close(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_cp_help[] =
|
||||
"Usage: cp <source> <destination>\n"
|
||||
"cp copies file <source> to <destination>.\n"
|
||||
"Currently only this form is supported and you have to specify the exact target\n"
|
||||
"filename (not a target directory).\n"
|
||||
"Note: This command was previously used as memory copy. Currently there is no\n"
|
||||
"equivalent command for this. This must be fixed of course.\n";
|
||||
|
||||
U_BOOT_CMD_START(cp)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_cp,
|
||||
.usage = "copy files",
|
||||
U_BOOT_CMD_HELP(cmd_cp_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
#ifndef CONFIG_CRC32_VERIFY
|
||||
|
||||
int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
|
@ -566,55 +512,6 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||
}
|
||||
#endif /* CONFIG_CRC32_VERIFY */
|
||||
|
||||
static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize)
|
||||
{
|
||||
ulong dst = (ulong)_dst;
|
||||
ulong src = (ulong)_src;
|
||||
|
||||
/* no rwsize specification given. Do whatever memcpy likes best */
|
||||
if (!rwsize) {
|
||||
memcpy(_dst, _src, count);
|
||||
return;
|
||||
}
|
||||
|
||||
rwsize = rwsize >> O_RWSIZE_SHIFT;
|
||||
|
||||
count /= rwsize;
|
||||
|
||||
while (count-- > 0) {
|
||||
switch (rwsize) {
|
||||
case 1:
|
||||
*((u_char *)dst) = *((u_char *)src);
|
||||
break;
|
||||
case 2:
|
||||
*((ushort *)dst) = *((ushort *)src);
|
||||
break;
|
||||
case 4:
|
||||
*((ulong *)dst) = *((ulong *)src);
|
||||
break;
|
||||
}
|
||||
dst += rwsize;
|
||||
src += rwsize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags)
|
||||
{
|
||||
ulong size;
|
||||
size = min(count, dev->size - offset);
|
||||
printf("mem_read: dev->map_base: %p size: %d offset: %d\n",dev->map_base, size, offset);
|
||||
memcpy_sz(buf, (void *)(dev->map_base + offset), size, flags & O_RWSIZE_MASK);
|
||||
return size;
|
||||
}
|
||||
|
||||
ssize_t mem_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags)
|
||||
{
|
||||
ulong size;
|
||||
size = min(count, dev->size - offset);
|
||||
memcpy_sz((void *)(dev->map_base + offset), buf, size, flags & O_RWSIZE_MASK);
|
||||
return size;
|
||||
}
|
||||
|
||||
static struct device_d mem_dev = {
|
||||
.name = "mem",
|
||||
.id = "mem",
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int do_mkdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (mkdir(argv[i])) {
|
||||
printf("could not create %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_mkdir_help[] =
|
||||
"Usage: mkdir [directories]\n"
|
||||
"Create new directories\n";
|
||||
|
||||
U_BOOT_CMD_START(mkdir)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_mkdir,
|
||||
.usage = "make directories",
|
||||
U_BOOT_CMD_HELP(cmd_mkdir_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,53 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int do_mount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
struct mtab_entry *entry = NULL;
|
||||
|
||||
if (argc == 1) {
|
||||
do {
|
||||
entry = mtab_next_entry(entry);
|
||||
if (entry) {
|
||||
printf("%s on %s type %s\n",
|
||||
entry->parent_device ? entry->parent_device->id : "none",
|
||||
entry->path,
|
||||
entry->dev->name);
|
||||
}
|
||||
} while (entry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc != 4) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ret = mount(argv[1], argv[2], argv[3]))) {
|
||||
perror("mount");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_mount_help[] =
|
||||
"Usage: mount: list mounted filesystems\n"
|
||||
"or: mount <device> <fstype> <mountpoint>\n"
|
||||
"\n"
|
||||
"Mount a filesystem of a given type to a mountpoint.\n"
|
||||
"<device> can be one of /dev/* or some arbitrary string if no\n"
|
||||
"device is needed for this driver (for example ramfs).\n"
|
||||
"<fstype> is the filesystem driver to use. Try the 'devinfo' command\n"
|
||||
"for a list of available drivers.\n"
|
||||
"<mountpoint> must be an empty directory descending directly from the\n"
|
||||
"root directory.\n";
|
||||
|
||||
U_BOOT_CMD_START(mount)
|
||||
.maxargs = 4,
|
||||
.cmd = do_mount,
|
||||
.usage = "mount a filesystem to a device",
|
||||
U_BOOT_CMD_HELP(cmd_mount_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,15 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
|
||||
static int do_pwd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
printf("%s\n", getcwd());
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD_START(pwd)
|
||||
.maxargs = 2,
|
||||
.cmd = do_pwd,
|
||||
.usage = "print working directory",
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,14 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
|
||||
int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
reginfo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD_START(reginfo)
|
||||
.maxargs = 1,
|
||||
.cmd = do_reginfo,
|
||||
.usage = "print register information",
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,30 @@
|
|||
static int do_rm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (unlink(argv[i])) {
|
||||
printf("could not remove %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_rm_help[] =
|
||||
"Usage: rm [FILES]\n"
|
||||
"Remove files\n";
|
||||
|
||||
U_BOOT_CMD_START(rm)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_rm,
|
||||
.usage = "remove files",
|
||||
U_BOOT_CMD_HELP(cmd_rm_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,35 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int do_rmdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (argc < 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (rmdir(argv[i])) {
|
||||
printf("could not remove %s: %s\n", argv[i], errno_str());
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_rmdir_help[] =
|
||||
"Usage: rmdir [directories]\n"
|
||||
"Remove directories. The directories have to be empty.\n";
|
||||
|
||||
U_BOOT_CMD_START(rmdir)
|
||||
.maxargs = CONFIG_MAXARGS,
|
||||
.cmd = do_rmdir,
|
||||
.usage = "remove directorie(s)",
|
||||
U_BOOT_CMD_HELP(cmd_rmdir_help)
|
||||
U_BOOT_CMD_END
|
|
@ -0,0 +1,31 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int do_umount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
u_boot_cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ret = umount(argv[1]))) {
|
||||
perror("umount");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_umount_help[] =
|
||||
"Usage: umount <mountpoint>\n"
|
||||
"umount a filesystem mounted on a specific mountpoint\n";
|
||||
|
||||
U_BOOT_CMD_START(umount)
|
||||
.maxargs = 2,
|
||||
.cmd = do_umount,
|
||||
.usage = "umount a filesystem",
|
||||
U_BOOT_CMD_HELP(cmd_umount_help)
|
||||
U_BOOT_CMD_END
|
|
@ -56,10 +56,14 @@ config PROMPT_HUSH_PS2
|
|||
prompt "hush PS2"
|
||||
default "> "
|
||||
|
||||
config ZERO_BOOTDELAY_CHECK
|
||||
config DYNAMIC_CRC_TABLE
|
||||
bool
|
||||
prompt "Enable stop boot process with bootdelay = 0"
|
||||
depends on CRC32
|
||||
prompt "Generate the crc32 table dynamically"
|
||||
default y
|
||||
help
|
||||
Saying yes to this option saves around 800 bytes of binary size.
|
||||
If unsure say yes.
|
||||
|
||||
config ERRNO_MESSAGES
|
||||
bool
|
||||
|
|
|
@ -6,7 +6,6 @@ obj-$(CONFIG_OF_FLAT_TREE) += ft_build.o
|
|||
obj-y += main.o
|
||||
obj-y += dlmalloc.o
|
||||
obj-y += clock.o
|
||||
# obj-y += flash.o
|
||||
obj-y += command.o
|
||||
obj-y += console.o
|
||||
obj-y += partition.o
|
||||
|
|
|
@ -1,297 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2004
|
||||
* esd gmbh <www.esd-electronics.com>
|
||||
* Reinhard Arlt <reinhard.arlt@esd-electronics.com>
|
||||
*
|
||||
* made from cmd_reiserfs by
|
||||
*
|
||||
* (C) Copyright 2003 - 2004
|
||||
* Sysgo Real-Time Solutions, AG <www.elinos.com>
|
||||
* Pavel Bartusek <pba@sysgo.com>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ext2fs support
|
||||
*/
|
||||
#include <common.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_EXT2)
|
||||
#include <config.h>
|
||||
#include <command.h>
|
||||
#include <image.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <ext2fs.h>
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
|
||||
#include <usb.h>
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DOS_PARTITION
|
||||
#error DOS partition support must be selected
|
||||
#endif
|
||||
|
||||
/* #define EXT2_DEBUG */
|
||||
|
||||
#ifdef EXT2_DEBUG
|
||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
static block_dev_desc_t *get_dev (char* ifname, int dev)
|
||||
{
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
|
||||
if (strncmp(ifname,"ide",3)==0) {
|
||||
extern block_dev_desc_t * ide_get_dev(int dev);
|
||||
return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
|
||||
if (strncmp(ifname,"scsi",4)==0) {
|
||||
extern block_dev_desc_t * scsi_get_dev(int dev);
|
||||
return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
|
||||
if (strncmp(ifname,"usb",3)==0) {
|
||||
extern block_dev_desc_t * usb_stor_get_dev(int dev);
|
||||
return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_MMC)
|
||||
if (strncmp(ifname,"mmc",3)==0) {
|
||||
extern block_dev_desc_t * mmc_get_dev(int dev);
|
||||
return((dev >= 1) ? NULL : mmc_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_SYSTEMACE)
|
||||
if (strcmp(ifname,"ace")==0) {
|
||||
extern block_dev_desc_t * systemace_get_dev(int dev);
|
||||
return((dev >= 1) ? NULL : systemace_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = "/";
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
int part_length;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return(1);
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
|
||||
if (dev_desc == NULL) {
|
||||
printf ("\n** Block device %s %d not supported\n", argv[1], dev);
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return(1);
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
|
||||
if (argc == 4) {
|
||||
filename = argv[3];
|
||||
}
|
||||
|
||||
PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
|
||||
|
||||
if ((part_length = ext2fs_set_blk_dev(dev_desc, part)) == 0) {
|
||||
printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (!ext2fs_mount(part_length)) {
|
||||
printf ("** Bad ext2 partition or disk - %s %d:%d **\n", argv[1], dev, part);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (ext2fs_ls (filename)) {
|
||||
printf ("** Error ext2fs_ls() **\n");
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
};
|
||||
|
||||
ext2fs_close();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
ext2ls, 4, 1, do_ext2ls,
|
||||
"ext2ls - list files in a directory (default /)\n",
|
||||
"<interface> <dev[:part]> [directory]\n"
|
||||
" - list files from 'dev' on 'interface' in a 'directory'\n"
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
* Ext2fs boot command intepreter. Derived from diskboot
|
||||
*/
|
||||
int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = NULL;
|
||||
char *ep;
|
||||
int dev, part = 1;
|
||||
ulong addr = 0, part_length, filelen;
|
||||
disk_partition_t info;
|
||||
block_dev_desc_t *dev_desc = NULL;
|
||||
char buf [12];
|
||||
unsigned long count;
|
||||
char *addr_str;
|
||||
|
||||
switch (argc) {
|
||||
case 3:
|
||||
addr_str = getenv("loadaddr");
|
||||
if (addr_str != NULL) {
|
||||
addr = simple_strtoul (addr_str, NULL, 16);
|
||||
} else {
|
||||
addr = CFG_LOAD_ADDR;
|
||||
}
|
||||
filename = getenv ("bootfile");
|
||||
count = 0;
|
||||
break;
|
||||
case 4:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = getenv ("bootfile");
|
||||
count = 0;
|
||||
break;
|
||||
case 5:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = argv[4];
|
||||
count = 0;
|
||||
break;
|
||||
case 6:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = argv[4];
|
||||
count = simple_strtoul (argv[5], NULL, 16);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (!filename) {
|
||||
puts ("\n** No boot file defined **\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
printf ("\n** Block device %s %d not supported\n", argv[1], dev);
|
||||
return(1);
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return(1);
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
|
||||
PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
|
||||
|
||||
if (part != 0) {
|
||||
if (get_partition_info (dev_desc, part, &info)) {
|
||||
printf ("** Bad partition %d **\n", part);
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) {
|
||||
printf ("\n** Invalid partition type \"%.32s\""
|
||||
" (expect \"" BOOT_PART_TYPE "\")\n",
|
||||
info.type);
|
||||
return(1);
|
||||
}
|
||||
PRINTF ("\nLoading from block device %s device %d, partition %d: "
|
||||
"Name: %.32s Type: %.32s File:%s\n",
|
||||
argv[1], dev, part, info.name, info.type, filename);
|
||||
} else {
|
||||
PRINTF ("\nLoading from block device %s device %d, File:%s\n",
|
||||
argv[1], dev, filename);
|
||||
}
|
||||
|
||||
|
||||
if ((part_length = ext2fs_set_blk_dev(dev_desc, part)) == 0) {
|
||||
printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (!ext2fs_mount(part_length)) {
|
||||
printf ("** Bad ext2 partition or disk - %s %d:%d **\n", argv[1], dev, part);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
|
||||
filelen = ext2fs_open(filename);
|
||||
if (filelen < 0) {
|
||||
printf("** File not found %s\n", filename);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
if ((count < filelen) && (count != 0)) {
|
||||
filelen = count;
|
||||
}
|
||||
|
||||
if (ext2fs_read((char *)addr, filelen) != filelen) {
|
||||
printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
|
||||
ext2fs_close();
|
||||
return(1);
|
||||
}
|
||||
|
||||
ext2fs_close();
|
||||
|
||||
/* Loading ok, update default load address */
|
||||
load_addr = addr;
|
||||
|
||||
printf ("\n%ld bytes read\n", filelen);
|
||||
sprintf(buf, "%lX", filelen);
|
||||
setenv("filesize", buf);
|
||||
|
||||
return(filelen);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
ext2load, 6, 0, do_ext2load,
|
||||
"ext2load- load binary file from a Ext2 filesystem\n",
|
||||
"<interface> <dev[:part]> [addr] [filename] [bytes]\n"
|
||||
" - load binary file 'filename' from 'dev' on 'interface'\n"
|
||||
" to address 'addr' from ext2 filesystem\n"
|
||||
);
|
||||
|
||||
#endif /* CONFIG_COMMANDS & CFG_CMD_EXT2 */
|
362
common/cmd_fat.c
362
common/cmd_fat.c
|
@ -1,362 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* Richard Jones, rjones@nexus-tech.net
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Boot support
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <s_record.h>
|
||||
#include <net.h>
|
||||
#include <ata.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_FAT)
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
#include <fat.h>
|
||||
|
||||
|
||||
block_dev_desc_t *get_dev (char* ifname, int dev)
|
||||
{
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
|
||||
if (strncmp(ifname,"ide",3)==0) {
|
||||
extern block_dev_desc_t * ide_get_dev(int dev);
|
||||
return(ide_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
|
||||
if (strncmp(ifname,"scsi",4)==0) {
|
||||
extern block_dev_desc_t * scsi_get_dev(int dev);
|
||||
return(scsi_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
|
||||
if (strncmp(ifname,"usb",3)==0) {
|
||||
extern block_dev_desc_t * usb_stor_get_dev(int dev);
|
||||
return(usb_stor_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_MMC)
|
||||
if (strncmp(ifname,"mmc",3)==0) {
|
||||
extern block_dev_desc_t * mmc_get_dev(int dev);
|
||||
return(mmc_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_SYSTEMACE)
|
||||
if (strcmp(ifname,"ace")==0) {
|
||||
extern block_dev_desc_t * systemace_get_dev(int dev);
|
||||
return(systemace_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
long size;
|
||||
unsigned long offset;
|
||||
unsigned long count;
|
||||
char buf [12];
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
|
||||
if (argc < 5) {
|
||||
printf ("usage: fatload <interface> <dev[:part]> <addr> <filename> [bytes]\n");
|
||||
return 1;
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatload **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
offset = simple_strtoul (argv[3], NULL, 16);
|
||||
if (argc == 6)
|
||||
count = simple_strtoul (argv[5], NULL, 16);
|
||||
else
|
||||
count = 0;
|
||||
size = file_fat_read (argv[4], (unsigned char *) offset, count);
|
||||
|
||||
if(size==-1) {
|
||||
printf("\n** Unable to read \"%s\" from %s %d:%d **\n",argv[4],argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("\n%ld bytes read\n", size);
|
||||
|
||||
sprintf(buf, "%lX", size);
|
||||
setenv("filesize", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatload, 6, 0, do_fat_fsload,
|
||||
"fatload - load binary file from a dos filesystem\n",
|
||||
"<interface> <dev[:part]> <addr> <filename> [bytes]\n"
|
||||
" - load binary file 'filename' from 'dev' on 'interface'\n"
|
||||
" to address 'addr' from dos filesystem\n"
|
||||
);
|
||||
|
||||
int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = "/";
|
||||
int ret;
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("usage: fatls <interface> <dev[:part]> [directory]\n");
|
||||
return (0);
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatls **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 4)
|
||||
ret = file_fat_ls (argv[3]);
|
||||
else
|
||||
ret = file_fat_ls (filename);
|
||||
|
||||
if(ret!=0)
|
||||
printf("No Fat FS detected\n");
|
||||
return (ret);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatls, 4, 1, do_fat_ls,
|
||||
"fatls - list files in a directory (default /)\n",
|
||||
"<interface> <dev[:part]> [directory]\n"
|
||||
" - list files from 'dev' on 'interface' in a 'directory'\n"
|
||||
);
|
||||
|
||||
int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
|
||||
if (argc < 2) {
|
||||
printf ("usage: fatinfo <interface> <dev[:part]>\n");
|
||||
return (0);
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatinfo **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
return (file_fat_detectfs ());
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatinfo, 3, 1, do_fat_fsinfo,
|
||||
"fatinfo - print information about filesystem\n",
|
||||
"<interface> <dev[:part]>\n"
|
||||
" - print information about filesystem from 'dev' on 'interface'\n"
|
||||
);
|
||||
|
||||
#ifdef NOT_IMPLEMENTED_YET
|
||||
/* find first device whose first partition is a DOS filesystem */
|
||||
int find_fat_partition (void)
|
||||
{
|
||||
int i, j;
|
||||
block_dev_desc_t *dev_desc;
|
||||
unsigned char *part_table;
|
||||
unsigned char buffer[ATA_BLOCKSIZE];
|
||||
|
||||
for (i = 0; i < CFG_IDE_MAXDEVICE; i++) {
|
||||
dev_desc = ide_get_dev (i);
|
||||
if (!dev_desc) {
|
||||
debug ("couldn't get ide device!\n");
|
||||
return (-1);
|
||||
}
|
||||
if (dev_desc->part_type == PART_TYPE_DOS) {
|
||||
if (dev_desc->
|
||||
block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) {
|
||||
debug ("can't perform block_read!\n");
|
||||
return (-1);
|
||||
}
|
||||
part_table = &buffer[0x1be]; /* start with partition #4 */
|
||||
for (j = 0; j < 4; j++) {
|
||||
if ((part_table[4] == 1 || /* 12-bit FAT */
|
||||
part_table[4] == 4 || /* 16-bit FAT */
|
||||
part_table[4] == 6) && /* > 32Meg part */
|
||||
part_table[0] == 0x80) { /* bootable? */
|
||||
curr_dev = i;
|
||||
part_offset = part_table[11];
|
||||
part_offset <<= 8;
|
||||
part_offset |= part_table[10];
|
||||
part_offset <<= 8;
|
||||
part_offset |= part_table[9];
|
||||
part_offset <<= 8;
|
||||
part_offset |= part_table[8];
|
||||
debug ("found partition start at %ld\n", part_offset);
|
||||
return (0);
|
||||
}
|
||||
part_table += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug ("no valid devices found!\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
do_fat_dump (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
|
||||
{
|
||||
__u8 block[1024];
|
||||
int ret;
|
||||
int bknum;
|
||||
|
||||
ret = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
printf ("needs an argument!\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
bknum = simple_strtoul (argv[1], NULL, 10);
|
||||
|
||||
if (disk_read (0, bknum, block) != 0) {
|
||||
printf ("Error: reading block\n");
|
||||
return -1;
|
||||
}
|
||||
printf ("FAT dump: %d\n", bknum);
|
||||
hexdump (512, block);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int disk_read (__u32 startblock, __u32 getsize, __u8 *bufptr)
|
||||
{
|
||||
ulong tot;
|
||||
block_dev_desc_t *dev_desc;
|
||||
|
||||
if (curr_dev < 0) {
|
||||
if (find_fat_partition () != 0)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
dev_desc = ide_get_dev (curr_dev);
|
||||
if (!dev_desc) {
|
||||
debug ("couldn't get ide device\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
tot = dev_desc->block_read (0, startblock + part_offset,
|
||||
getsize, (ulong *) bufptr);
|
||||
|
||||
/* should we do this here?
|
||||
flush_cache ((ulong)buf, cnt*ide_dev_desc[device].blksz);
|
||||
*/
|
||||
|
||||
if (tot == getsize)
|
||||
return (0);
|
||||
|
||||
debug ("unable to read from device!\n");
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
static int isprint (unsigned char ch)
|
||||
{
|
||||
if (ch >= 32 && ch < 127)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
void hexdump (int cnt, unsigned char *data)
|
||||
{
|
||||
int i;
|
||||
int run;
|
||||
int offset;
|
||||
|
||||
offset = 0;
|
||||
while (cnt) {
|
||||
printf ("%04X : ", offset);
|
||||
if (cnt >= 16)
|
||||
run = 16;
|
||||
else
|
||||
run = cnt;
|
||||
cnt -= run;
|
||||
for (i = 0; i < run; i++)
|
||||
printf ("%02X ", (unsigned int) data[i]);
|
||||
printf (": ");
|
||||
for (i = 0; i < run; i++)
|
||||
printf ("%c", isprint (data[i]) ? data[i] : '.');
|
||||
printf ("\n");
|
||||
data = &data[16];
|
||||
offset += run;
|
||||
}
|
||||
}
|
||||
#endif /* NOT_IMPLEMENTED_YET */
|
||||
|
||||
#endif /* CFG_CMD_FAT */
|
2195
common/cmd_jffs2.c
2195
common/cmd_jffs2.c
File diff suppressed because it is too large
Load Diff
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Misc functions
|
||||
*/
|
||||
#include <malloc.h>
|
||||
#include <readkey.h>
|
||||
|
||||
#ifdef CONFIG_CMD_SLEEP
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_CLEAR
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_MEMINFO
|
||||
#endif
|
||||
|
||||
/* Implemented in $(CPU)/interrupts.c */
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IRQ)
|
||||
int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
|
||||
U_BOOT_CMD_START(irqinfo)
|
||||
.maxargs = 1,
|
||||
.cmd = do_irqinfo,
|
||||
.usage = "print information about IRQs",
|
||||
U_BOOT_CMD_END
|
||||
#endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2000
|
||||
* Subodh Nijsure, SkyStream Networks, snijsure@skystream.com
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#if defined(CONFIG_8xx)
|
||||
#include <mpc8xx.h>
|
||||
#elif defined (CONFIG_405GP) || defined(CONFIG_405EP)
|
||||
#include <asm/processor.h>
|
||||
#elif defined (CONFIG_5xx)
|
||||
#include <mpc5xx.h>
|
||||
#elif defined (CONFIG_MPC5200)
|
||||
#include <mpc5xxx.h>
|
||||
#endif
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_REGINFO)
|
||||
|
||||
int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
#if defined(CONFIG_8xx)
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
volatile sysconf8xx_t *sysconf = &immap->im_siu_conf;
|
||||
volatile sit8xx_t *timers = &immap->im_sit;
|
||||
|
||||
/* Hopefully more PowerPC knowledgable people will add code to display
|
||||
* other useful registers
|
||||
*/
|
||||
|
||||
printf ("\nSystem Configuration registers\n"
|
||||
|
||||
"\tIMMR\t0x%08X\n", get_immr(0));
|
||||
|
||||
printf("\tSIUMCR\t0x%08X", sysconf->sc_siumcr);
|
||||
printf("\tSYPCR\t0x%08X\n",sysconf->sc_sypcr);
|
||||
|
||||
printf("\tSWT\t0x%08X", sysconf->sc_swt);
|
||||
printf("\tSWSR\t0x%04X\n", sysconf->sc_swsr);
|
||||
|
||||
printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X\n",
|
||||
sysconf->sc_sipend, sysconf->sc_simask);
|
||||
printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X\n",
|
||||
sysconf->sc_siel, sysconf->sc_sivec);
|
||||
printf("\tTESR\t0x%08X\tSDCR\t0x%08X\n",
|
||||
sysconf->sc_tesr, sysconf->sc_sdcr);
|
||||
|
||||
printf ("Memory Controller Registers\n"
|
||||
|
||||
"\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0);
|
||||
printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1);
|
||||
printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2);
|
||||
printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3);
|
||||
printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", memctl->memc_br4, memctl->memc_or4);
|
||||
printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", memctl->memc_br5, memctl->memc_or5);
|
||||
printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", memctl->memc_br6, memctl->memc_or6);
|
||||
printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", memctl->memc_br7, memctl->memc_or7);
|
||||
printf ("\n"
|
||||
"\tmamr\t0x%08X\tmbmr\t0x%08X \n",
|
||||
memctl->memc_mamr, memctl->memc_mbmr );
|
||||
printf("\tmstat\t0x%08X\tmptpr\t0x%08X \n",
|
||||
memctl->memc_mstat, memctl->memc_mptpr );
|
||||
printf("\tmdr\t0x%08X \n", memctl->memc_mdr);
|
||||
|
||||
printf ("\nSystem Integration Timers\n"
|
||||
"\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n",
|
||||
timers->sit_tbscr, timers->sit_rtcsc);
|
||||
printf("\tPISCR\t0x%08X \n", timers->sit_piscr);
|
||||
|
||||
/*
|
||||
* May be some CPM info here?
|
||||
*/
|
||||
|
||||
#elif defined (CONFIG_405GP)
|
||||
printf ("\n405GP registers; MSR=%08x\n",mfmsr());
|
||||
printf ("\nUniversal Interrupt Controller Regs\n"
|
||||
"uicsr uicsrs uicer uiccr uicpr uictr uicmsr uicvr uicvcr"
|
||||
"\n"
|
||||
"%08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
mfdcr(uicsr),
|
||||
mfdcr(uicsrs),
|
||||
mfdcr(uicer),
|
||||
mfdcr(uiccr),
|
||||
mfdcr(uicpr),
|
||||
mfdcr(uictr),
|
||||
mfdcr(uicmsr),
|
||||
mfdcr(uicvr),
|
||||
mfdcr(uicvcr));
|
||||
|
||||
puts ("\nMemory (SDRAM) Configuration\n"
|
||||
"besra besrsa besrb besrsb bear mcopt1 rtr pmit\n");
|
||||
|
||||
mtdcr(memcfga,mem_besra); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrsa); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrb); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrsb); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_bear); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
puts ("\n"
|
||||
"mb0cf mb1cf mb2cf mb3cf sdtr1 ecccf eccerr\n");
|
||||
mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb2cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb3cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_ecccf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_eccerr); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
printf ("\n\n"
|
||||
"DMA Channels\n"
|
||||
"dmasr dmasgc dmaadr\n"
|
||||
"%08x %08x %08x\n"
|
||||
"dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n"
|
||||
"%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n"
|
||||
"%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr),
|
||||
mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0),
|
||||
mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1));
|
||||
|
||||
printf (
|
||||
"dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2),
|
||||
mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) );
|
||||
|
||||
puts ("\n"
|
||||
"External Bus\n"
|
||||
"pbear pbesr0 pbesr1 epcr\n");
|
||||
mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n");
|
||||
mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb4cr pb4ap pb5cr bp5ap pb6cr pb6ap pb7cr pb7ap\n");
|
||||
mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb5cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb5ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb6cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb6ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb7cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb7ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n\n");
|
||||
|
||||
#elif defined(CONFIG_405EP)
|
||||
printf ("\n405EP registers; MSR=%08x\n",mfmsr());
|
||||
printf ("\nUniversal Interrupt Controller Regs\n"
|
||||
"uicsr uicer uiccr uicpr uictr uicmsr uicvr uicvcr"
|
||||
"\n"
|
||||
"%08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
mfdcr(uicsr),
|
||||
mfdcr(uicer),
|
||||
mfdcr(uiccr),
|
||||
mfdcr(uicpr),
|
||||
mfdcr(uictr),
|
||||
mfdcr(uicmsr),
|
||||
mfdcr(uicvr),
|
||||
mfdcr(uicvcr));
|
||||
|
||||
puts ("\nMemory (SDRAM) Configuration\n"
|
||||
"mcopt1 rtr pmit mb0cf mb1cf sdtr1\n");
|
||||
|
||||
mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
printf ("\n\n"
|
||||
"DMA Channels\n"
|
||||
"dmasr dmasgc dmaadr\n" "%08x %08x %08x\n"
|
||||
"dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr),
|
||||
mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0),
|
||||
mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1));
|
||||
|
||||
printf (
|
||||
"dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2),
|
||||
mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) );
|
||||
|
||||
puts ("\n"
|
||||
"External Bus\n"
|
||||
"pbear pbesr0 pbesr1 epcr\n");
|
||||
mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n");
|
||||
mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb4cr pb4ap\n");
|
||||
mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n\n");
|
||||
#elif defined(CONFIG_5xx)
|
||||
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl5xx_t *memctl = &immap->im_memctl;
|
||||
volatile sysconf5xx_t *sysconf = &immap->im_siu_conf;
|
||||
volatile sit5xx_t *timers = &immap->im_sit;
|
||||
volatile car5xx_t *car = &immap->im_clkrst;
|
||||
volatile uimb5xx_t *uimb = &immap->im_uimb;
|
||||
|
||||
puts ("\nSystem Configuration registers\n");
|
||||
printf("\tIMMR\t0x%08X\tSIUMCR\t0x%08X \n", get_immr(0), sysconf->sc_siumcr);
|
||||
printf("\tSYPCR\t0x%08X\tSWSR\t0x%04X \n" ,sysconf->sc_sypcr, sysconf->sc_swsr);
|
||||
printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X \n", sysconf->sc_sipend, sysconf->sc_simask);
|
||||
printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X \n", sysconf->sc_siel, sysconf->sc_sivec);
|
||||
printf("\tTESR\t0x%08X\n", sysconf->sc_tesr);
|
||||
|
||||
puts ("\nMemory Controller Registers\n");
|
||||
printf("\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0);
|
||||
printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1);
|
||||
printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2);
|
||||
printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3);
|
||||
printf("\tDMBR\t0x%08X\tDMOR\t0x%08X \n", memctl->memc_dmbr, memctl->memc_dmor );
|
||||
printf("\tMSTAT\t0x%08X\n", memctl->memc_mstat);
|
||||
|
||||
puts ("\nSystem Integration Timers\n");
|
||||
printf("\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n", timers->sit_tbscr, timers->sit_rtcsc);
|
||||
printf("\tPISCR\t0x%08X \n", timers->sit_piscr);
|
||||
|
||||
puts ("\nClocks and Reset\n");
|
||||
printf("\tSCCR\t0x%08X\tPLPRCR\t0x%08X \n", car->car_sccr, car->car_plprcr);
|
||||
|
||||
puts ("\nU-Bus to IMB3 Bus Interface\n");
|
||||
printf("\tUMCR\t0x%08X\tUIPEND\t0x%08X \n", uimb->uimb_umcr, uimb->uimb_uipend);
|
||||
puts ("\n\n");
|
||||
|
||||
#elif defined(CONFIG_MPC5200)
|
||||
puts ("\nMPC5200 registers\n");
|
||||
printf ("MBAR=%08x\n", CFG_MBAR);
|
||||
puts ("Memory map registers\n");
|
||||
printf ("\tCS0: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS0_START,
|
||||
*(volatile ulong*)MPC5XXX_CS0_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS0_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00010000) ? 1 : 0);
|
||||
printf ("\tCS1: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS1_START,
|
||||
*(volatile ulong*)MPC5XXX_CS1_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS1_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00020000) ? 1 : 0);
|
||||
printf ("\tCS2: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS2_START,
|
||||
*(volatile ulong*)MPC5XXX_CS2_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS2_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00040000) ? 1 : 0);
|
||||
printf ("\tCS3: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS3_START,
|
||||
*(volatile ulong*)MPC5XXX_CS3_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS3_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00080000) ? 1 : 0);
|
||||
printf ("\tCS4: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS4_START,
|
||||
*(volatile ulong*)MPC5XXX_CS4_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS4_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00100000) ? 1 : 0);
|
||||
printf ("\tCS5: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS5_START,
|
||||
*(volatile ulong*)MPC5XXX_CS5_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS5_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00200000) ? 1 : 0);
|
||||
printf ("\tCS6: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS6_START,
|
||||
*(volatile ulong*)MPC5XXX_CS6_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS6_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x04000000) ? 1 : 0);
|
||||
printf ("\tCS7: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS7_START,
|
||||
*(volatile ulong*)MPC5XXX_CS7_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS7_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x08000000) ? 1 : 0);
|
||||
printf ("\tBOOTCS: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_START,
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_STOP,
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x02000000) ? 1 : 0);
|
||||
printf ("\tSDRAMCS0: %08X\n",
|
||||
*(volatile ulong*)MPC5XXX_SDRAM_CS0CFG);
|
||||
printf ("\tSDRAMCS1: %08X\n",
|
||||
*(volatile ulong*)MPC5XXX_SDRAM_CS1CFG);
|
||||
#endif /* CONFIG_MPC5200 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_COMMANDS & CFG_CMD_REGINFO */
|
||||
|
||||
|
||||
/**************************************************/
|
||||
|
||||
#if ( defined(CONFIG_8xx) || defined(CONFIG_405GP) || \
|
||||
defined(CONFIG_405EP) || defined(CONFIG_MPC5200) ) && \
|
||||
(CONFIG_COMMANDS & CFG_CMD_REGINFO)
|
||||
|
||||
U_BOOT_CMD(
|
||||
reginfo, 2, 1, do_reginfo,
|
||||
"reginfo - print register information\n",
|
||||
);
|
||||
#endif
|
|
@ -1,277 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2003 - 2004
|
||||
* Sysgo Real-Time Solutions, AG <www.elinos.com>
|
||||
* Pavel Bartusek <pba@sysgo.com>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Reiserfs support
|
||||
*/
|
||||
#include <common.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_REISER)
|
||||
#include <config.h>
|
||||
#include <command.h>
|
||||
#include <image.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <reiserfs.h>
|
||||
|
||||
#ifndef CONFIG_DOS_PARTITION
|
||||
#error DOS partition support must be selected
|
||||
#endif
|
||||
|
||||
/* #define REISER_DEBUG */
|
||||
|
||||
#ifdef REISER_DEBUG
|
||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
static block_dev_desc_t *get_dev (char* ifname, int dev)
|
||||
{
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
|
||||
if (strncmp(ifname,"ide",3)==0) {
|
||||
extern block_dev_desc_t * ide_get_dev(int dev);
|
||||
return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
|
||||
if (strncmp(ifname,"scsi",4)==0) {
|
||||
extern block_dev_desc_t * scsi_get_dev(int dev);
|
||||
return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
|
||||
if (strncmp(ifname,"usb",3)==0) {
|
||||
extern block_dev_desc_t * usb_stor_get_dev(int dev);
|
||||
return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_MMC)
|
||||
if (strncmp(ifname,"mmc",3)==0) {
|
||||
extern block_dev_desc_t * mmc_get_dev(int dev);
|
||||
return((dev >= 1) ? NULL : mmc_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_SYSTEMACE)
|
||||
if (strcmp(ifname,"ace")==0) {
|
||||
extern block_dev_desc_t * systemace_get_dev(int dev);
|
||||
return((dev >= 1) ? NULL : systemace_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = "/";
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
int part_length;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
|
||||
if (dev_desc == NULL) {
|
||||
printf ("\n** Block device %s %d not supported\n", argv[1], dev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
|
||||
if (argc == 4) {
|
||||
filename = argv[3];
|
||||
}
|
||||
|
||||
PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
|
||||
|
||||
if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
|
||||
printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!reiserfs_mount(part_length)) {
|
||||
printf ("** Bad Reisefs partition or disk - %s %d:%d **\n", argv[1], dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (reiserfs_ls (filename)) {
|
||||
printf ("** Error reiserfs_ls() **\n");
|
||||
return 1;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
reiserls, 4, 1, do_reiserls,
|
||||
"reiserls- list files in a directory (default /)\n",
|
||||
"<interface> <dev[:part]> [directory]\n"
|
||||
" - list files from 'dev' on 'interface' in a 'directory'\n"
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
* Reiserfs boot command intepreter. Derived from diskboot
|
||||
*/
|
||||
int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = NULL;
|
||||
char *ep;
|
||||
int dev, part = 0;
|
||||
ulong addr = 0, part_length, filelen;
|
||||
disk_partition_t info;
|
||||
block_dev_desc_t *dev_desc = NULL;
|
||||
char buf [12];
|
||||
unsigned long count;
|
||||
char *addr_str;
|
||||
|
||||
switch (argc) {
|
||||
case 3:
|
||||
addr_str = getenv("loadaddr");
|
||||
if (addr_str != NULL) {
|
||||
addr = simple_strtoul (addr_str, NULL, 16);
|
||||
} else {
|
||||
addr = CFG_LOAD_ADDR;
|
||||
}
|
||||
filename = getenv ("bootfile");
|
||||
count = 0;
|
||||
break;
|
||||
case 4:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = getenv ("bootfile");
|
||||
count = 0;
|
||||
break;
|
||||
case 5:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = argv[4];
|
||||
count = 0;
|
||||
break;
|
||||
case 6:
|
||||
addr = simple_strtoul (argv[3], NULL, 16);
|
||||
filename = argv[4];
|
||||
count = simple_strtoul (argv[5], NULL, 16);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!filename) {
|
||||
puts ("\n** No boot file defined **\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
printf ("\n** Block device %s %d not supported\n", argv[1], dev);
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
|
||||
PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
|
||||
|
||||
if (part != 0) {
|
||||
if (get_partition_info (dev_desc, part, &info)) {
|
||||
printf ("** Bad partition %d **\n", part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp(info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) {
|
||||
printf ("\n** Invalid partition type \"%.32s\""
|
||||
" (expect \"" BOOT_PART_TYPE "\")\n",
|
||||
info.type);
|
||||
return 1;
|
||||
}
|
||||
PRINTF ("\nLoading from block device %s device %d, partition %d: "
|
||||
"Name: %.32s Type: %.32s File:%s\n",
|
||||
argv[1], dev, part, info.name, info.type, filename);
|
||||
} else {
|
||||
PRINTF ("\nLoading from block device %s device %d, File:%s\n",
|
||||
argv[1], dev, filename);
|
||||
}
|
||||
|
||||
|
||||
if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
|
||||
printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!reiserfs_mount(part_length)) {
|
||||
printf ("** Bad Reisefs partition or disk - %s %d:%d **\n", argv[1], dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
filelen = reiserfs_open(filename);
|
||||
if (filelen < 0) {
|
||||
printf("** File not found %s\n", filename);
|
||||
return 1;
|
||||
}
|
||||
if ((count < filelen) && (count != 0)) {
|
||||
filelen = count;
|
||||
}
|
||||
|
||||
if (reiserfs_read((char *)addr, filelen) != filelen) {
|
||||
printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Loading ok, update default load address */
|
||||
load_addr = addr;
|
||||
|
||||
printf ("\n%ld bytes read\n", filelen);
|
||||
sprintf(buf, "%lX", filelen);
|
||||
setenv("filesize", buf);
|
||||
|
||||
return filelen;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
reiserload, 6, 0, do_reiserload,
|
||||
"reiserload- load binary file from a Reiser filesystem\n",
|
||||
"<interface> <dev[:part]> [addr] [filename] [bytes]\n"
|
||||
" - load binary file 'filename' from 'dev' on 'interface'\n"
|
||||
" to address 'addr' from dos filesystem\n"
|
||||
);
|
||||
|
||||
#endif /* CONFIG_COMMANDS & CFG_CMD_REISER */
|
|
@ -2019,7 +2019,7 @@ void malloc_stats()
|
|||
See descriptions of tunable parameters above.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __U_BOOT__
|
||||
#if __STD_C
|
||||
int mALLOPt(int param_number, int value)
|
||||
#else
|
||||
|
@ -2041,7 +2041,7 @@ int mALLOPt(param_number, value) int param_number; int value;
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
||||
History:
|
||||
|
|
|
@ -41,7 +41,7 @@ void *sbrk (ptrdiff_t increment)
|
|||
int errno;
|
||||
|
||||
#ifndef CONFIG_ERRNO_MESSAGES
|
||||
static char errno_str[5];
|
||||
static char errno_string[5];
|
||||
#endif
|
||||
|
||||
const char *errno_str(void)
|
||||
|
@ -116,8 +116,8 @@ const char *errno_str(void)
|
|||
|
||||
return str;
|
||||
#else
|
||||
sprintf(errno_str, "%d", errno);
|
||||
return errno_str;
|
||||
sprintf(errno_string, "%d", errno);
|
||||
return errno_string;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <init.h>
|
||||
#include <driver.h>
|
||||
#include <malloc.h>
|
||||
|
@ -35,190 +34,6 @@ struct device_d *dev_add_partition(struct device_d *dev, unsigned long offset, s
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void dev_del_partitions(struct device_d *physdev)
|
||||
{
|
||||
struct device_d *dev;
|
||||
char buf[MAX_DRIVER_NAME];
|
||||
int i = 0;
|
||||
|
||||
/* This is lame. Devices should to able to have children */
|
||||
while (1) {
|
||||
sprintf(buf, "%s.%d", physdev->id, i);
|
||||
dev = device_from_spec_str(buf, NULL);
|
||||
if (dev) {
|
||||
struct partition *part = dev->type_data;
|
||||
unregister_device(dev);
|
||||
free(part);
|
||||
}
|
||||
else
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int mtd_part_do_parse_one (struct partition *part, const char *str, char **endp)
|
||||
{
|
||||
ulong size;
|
||||
char *end;
|
||||
char buf[MAX_DRIVER_NAME];
|
||||
|
||||
memset(buf, 0, MAX_DRIVER_NAME);
|
||||
|
||||
if (*str == '-') {
|
||||
size = part->physdev->size - part->offset;
|
||||
end = (char *)str + 1;
|
||||
} else {
|
||||
size = strtoul_suffix(str, &end, 0);
|
||||
}
|
||||
|
||||
if (size + part->offset > part->physdev->size) {
|
||||
printf("partition end is beyond device\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
str = end;
|
||||
|
||||
if (*str == '(') {
|
||||
str++;
|
||||
end = strchr(str, ')');
|
||||
if (!end) {
|
||||
printf("could not find matching ')'\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (end - str >= MAX_DRIVER_NAME) {
|
||||
printf("device name too long\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(part->name, str, end - str);
|
||||
end++;
|
||||
}
|
||||
|
||||
str = end;
|
||||
|
||||
if (*str == 'r' && *(str + 1) == 'o') {
|
||||
part->readonly = 1;
|
||||
end = (char *)(str + 2);
|
||||
}
|
||||
|
||||
if (endp)
|
||||
*endp = end;
|
||||
|
||||
strcpy(part->device.name, "partition");
|
||||
part->device.size = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_addpart ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
struct partition *part;
|
||||
struct device_d *dev;
|
||||
char *endp;
|
||||
int num = 0;
|
||||
unsigned long offset;
|
||||
|
||||
if (argc != 2) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = device_from_spec_str(argv[1], &endp);
|
||||
if (!dev) {
|
||||
printf("no such device: %s\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev_del_partitions(dev);
|
||||
|
||||
offset = 0;
|
||||
|
||||
while (1) {
|
||||
part = xzalloc(sizeof(struct partition));
|
||||
|
||||
part->offset = offset;
|
||||
part->physdev = dev;
|
||||
part->num = num;
|
||||
part->device.map_base = dev->map_base + offset;
|
||||
|
||||
if(mtd_part_do_parse_one(part, endp, &endp)) {
|
||||
dev_del_partitions(dev);
|
||||
free(part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
offset += part->device.size;
|
||||
|
||||
part->device.type_data = part;
|
||||
|
||||
sprintf(part->device.id, "%s.%d", dev->id, num);
|
||||
register_device(&part->device);
|
||||
num++;
|
||||
|
||||
if(!*endp)
|
||||
break;
|
||||
if(*endp != ',') {
|
||||
printf("parse error\n");
|
||||
return 1;
|
||||
}
|
||||
endp++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_addpart_help[] =
|
||||
"Usage: addpart <partition description>\n"
|
||||
"addpart adds a partition description to a device. The partition description\n"
|
||||
"has the form\n"
|
||||
"dev:size1(name1)[ro],size2(name2)[ro],...\n"
|
||||
"<dev> is the device name under /dev. Size can be given in decimal or if\n"
|
||||
"prefixed with 0x in hex. Sizes can have an optional suffix K,M,G. The size\n"
|
||||
"of the last partition can be specified as '-' for the remaining space of the\n"
|
||||
"device.\n"
|
||||
"This format is the same as used in the Linux kernel for cmdline mtd partitions.\n"
|
||||
"Note That this command has to be reworked and will probably change it's API.";
|
||||
|
||||
U_BOOT_CMD_START(addpart)
|
||||
.maxargs = 2,
|
||||
.cmd = do_addpart,
|
||||
.usage = "add a partition table to a device",
|
||||
U_BOOT_CMD_HELP(cmd_addpart_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
int do_delpart ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
struct device_d *dev;
|
||||
|
||||
if (argc != 2) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = device_from_spec_str(argv[1], NULL);
|
||||
if (!dev) {
|
||||
printf("no such device: %s\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev_del_partitions(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused char cmd_delpart_help[] =
|
||||
"Usage: delpart <dev>\n"
|
||||
"Delete partitions previously added to a device with addpart.\n"
|
||||
"Note: You have to specify the device as 'devid', _not_ as '/dev/devid'. This\n"
|
||||
"will likely change soon.\n";
|
||||
|
||||
U_BOOT_CMD_START(delpart)
|
||||
.maxargs = 2,
|
||||
.cmd = do_delpart,
|
||||
.usage = "delete a partition table from a device",
|
||||
U_BOOT_CMD_HELP(cmd_delpart_help)
|
||||
U_BOOT_CMD_END
|
||||
|
||||
static int part_erase(struct device_d *dev, size_t count, unsigned long offset)
|
||||
{
|
||||
struct partition *part = dev->type_data;
|
||||
|
|
|
@ -123,10 +123,10 @@ void start_uboot (void)
|
|||
|
||||
display_banner();
|
||||
|
||||
run_command("mount none ramfs /", 0);
|
||||
run_command("mkdir /dev", 0);
|
||||
run_command("mkdir /env", 0);
|
||||
run_command("mount none devfs /dev", 0);
|
||||
mount("none", "ramfs", "/");
|
||||
mkdir("/dev");
|
||||
mkdir("/env");
|
||||
mount("none", "devfs", "/dev");
|
||||
run_command("loadenv", 0);
|
||||
|
||||
if (!stat("/env/init", &s)) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include <common.h>
|
||||
|
||||
void reginfo(void)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl5xx_t *memctl = &immap->im_memctl;
|
||||
volatile sysconf5xx_t *sysconf = &immap->im_siu_conf;
|
||||
volatile sit5xx_t *timers = &immap->im_sit;
|
||||
volatile car5xx_t *car = &immap->im_clkrst;
|
||||
volatile uimb5xx_t *uimb = &immap->im_uimb;
|
||||
|
||||
puts ("\nSystem Configuration registers\n");
|
||||
printf("\tIMMR\t0x%08X\tSIUMCR\t0x%08X \n", get_immr(0), sysconf->sc_siumcr);
|
||||
printf("\tSYPCR\t0x%08X\tSWSR\t0x%04X \n" ,sysconf->sc_sypcr, sysconf->sc_swsr);
|
||||
printf("\tSIPEND\t0x%08X\tSIMASK\t0x%08X \n", sysconf->sc_sipend, sysconf->sc_simask);
|
||||
printf("\tSIEL\t0x%08X\tSIVEC\t0x%08X \n", sysconf->sc_siel, sysconf->sc_sivec);
|
||||
printf("\tTESR\t0x%08X\n", sysconf->sc_tesr);
|
||||
|
||||
puts ("\nMemory Controller Registers\n");
|
||||
printf("\tBR0\t0x%08X\tOR0\t0x%08X \n", memctl->memc_br0, memctl->memc_or0);
|
||||
printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", memctl->memc_br1, memctl->memc_or1);
|
||||
printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", memctl->memc_br2, memctl->memc_or2);
|
||||
printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", memctl->memc_br3, memctl->memc_or3);
|
||||
printf("\tDMBR\t0x%08X\tDMOR\t0x%08X \n", memctl->memc_dmbr, memctl->memc_dmor );
|
||||
printf("\tMSTAT\t0x%08X\n", memctl->memc_mstat);
|
||||
|
||||
puts ("\nSystem Integration Timers\n");
|
||||
printf("\tTBSCR\t0x%08X\tRTCSC\t0x%08X \n", timers->sit_tbscr, timers->sit_rtcsc);
|
||||
printf("\tPISCR\t0x%08X \n", timers->sit_piscr);
|
||||
|
||||
puts ("\nClocks and Reset\n");
|
||||
printf("\tSCCR\t0x%08X\tPLPRCR\t0x%08X \n", car->car_sccr, car->car_plprcr);
|
||||
|
||||
puts ("\nU-Bus to IMB3 Bus Interface\n");
|
||||
printf("\tUMCR\t0x%08X\tUIPEND\t0x%08X \n", uimb->uimb_umcr, uimb->uimb_uipend);
|
||||
puts ("\n\n");
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
obj-y += cpu.o
|
||||
obj-y += cpu_init.o
|
||||
obj-$(CONFIG_DRIVER_NET_MPC5200) += firmware_sc_task_bestcomm.impl.o
|
||||
obj-y += cpu.o
|
||||
obj-y += cpu_init.o
|
||||
obj-y += ide.o
|
||||
obj-y += loadtask.o
|
||||
obj-y += pci_mpc5200.o
|
||||
obj-y += speed.o
|
||||
obj-y += traps.o
|
||||
extra-y += start.o
|
||||
obj-$(CONFIG_MPC5200) += firmware_sc_task_bestcomm.impl.o
|
||||
obj-$(CONFIG_INTERRUPTS) += interrupts.o
|
||||
obj-$(CONFIG_REGINFO) += reginfo.o
|
||||
|
||||
#obj-y += firmware_sc_task.impl.o
|
||||
obj-y += ide.o
|
||||
obj-$(CONFIG_INTERRUPTS) += interrupts.o
|
||||
#obj-y += io.o
|
||||
obj-y += loadtask.o
|
||||
obj-y += pci_mpc5200.o
|
||||
obj-y += speed.o
|
||||
extra-y += start.o
|
||||
obj-y += traps.o
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <asm/processor.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <init.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <types.h>
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <types.h>
|
||||
|
||||
/* BestComm/SmartComm microcode */
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#include <stdio.h>
|
||||
#include <config.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
|
||||
void reginfo(void)
|
||||
{
|
||||
puts ("\nMPC5200 registers\n");
|
||||
printf ("MBAR=%08x\n", CFG_MBAR);
|
||||
puts ("Memory map registers\n");
|
||||
printf ("\tCS0: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS0_START,
|
||||
*(volatile ulong*)MPC5XXX_CS0_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS0_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00010000) ? 1 : 0);
|
||||
printf ("\tCS1: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS1_START,
|
||||
*(volatile ulong*)MPC5XXX_CS1_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS1_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00020000) ? 1 : 0);
|
||||
printf ("\tCS2: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS2_START,
|
||||
*(volatile ulong*)MPC5XXX_CS2_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS2_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00040000) ? 1 : 0);
|
||||
printf ("\tCS3: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS3_START,
|
||||
*(volatile ulong*)MPC5XXX_CS3_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS3_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00080000) ? 1 : 0);
|
||||
printf ("\tCS4: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS4_START,
|
||||
*(volatile ulong*)MPC5XXX_CS4_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS4_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00100000) ? 1 : 0);
|
||||
printf ("\tCS5: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS5_START,
|
||||
*(volatile ulong*)MPC5XXX_CS5_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS5_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x00200000) ? 1 : 0);
|
||||
printf ("\tCS6: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS6_START,
|
||||
*(volatile ulong*)MPC5XXX_CS6_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS6_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x04000000) ? 1 : 0);
|
||||
printf ("\tCS7: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_CS7_START,
|
||||
*(volatile ulong*)MPC5XXX_CS7_STOP,
|
||||
*(volatile ulong*)MPC5XXX_CS7_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x08000000) ? 1 : 0);
|
||||
printf ("\tBOOTCS: start %08X\tstop %08X\tconfig %08X\ten %d\n",
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_START,
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_STOP,
|
||||
*(volatile ulong*)MPC5XXX_BOOTCS_CFG,
|
||||
(*(volatile ulong*)MPC5XXX_ADDECR & 0x02000000) ? 1 : 0);
|
||||
printf ("\tSDRAMCS0: %08X\n",
|
||||
*(volatile ulong*)MPC5XXX_SDRAM_CS0CFG);
|
||||
printf ("\tSDRAMCS1: %08X\n",
|
||||
*(volatile ulong*)MPC5XXX_SDRAM_CS1CFG);
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <init.h>
|
||||
#include <asm/processor.h>
|
||||
#include <types.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* U-Boot - Startup Code for MPC5xxx CPUs
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <ppc_asm.tmpl>
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#include <common.h>
|
||||
|
||||
void reginfo(void)
|
||||
printf ("\n405EP registers; MSR=%08x\n",mfmsr());
|
||||
printf ("\nUniversal Interrupt Controller Regs\n"
|
||||
"uicsr uicer uiccr uicpr uictr uicmsr uicvr uicvcr"
|
||||
"\n"
|
||||
"%08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
mfdcr(uicsr),
|
||||
mfdcr(uicer),
|
||||
mfdcr(uiccr),
|
||||
mfdcr(uicpr),
|
||||
mfdcr(uictr),
|
||||
mfdcr(uicmsr),
|
||||
mfdcr(uicvr),
|
||||
mfdcr(uicvcr));
|
||||
|
||||
puts ("\nMemory (SDRAM) Configuration\n"
|
||||
"mcopt1 rtr pmit mb0cf mb1cf sdtr1\n");
|
||||
|
||||
mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
printf ("\n\n"
|
||||
"DMA Channels\n"
|
||||
"dmasr dmasgc dmaadr\n" "%08x %08x %08x\n"
|
||||
"dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr),
|
||||
mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0),
|
||||
mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1));
|
||||
|
||||
printf (
|
||||
"dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2),
|
||||
mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) );
|
||||
|
||||
puts ("\n"
|
||||
"External Bus\n"
|
||||
"pbear pbesr0 pbesr1 epcr\n");
|
||||
mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n");
|
||||
mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb4cr pb4ap\n");
|
||||
mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n\n");
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
#include <common.h>
|
||||
|
||||
void reginfo(void)
|
||||
{
|
||||
printf ("\n405GP registers; MSR=%08x\n",mfmsr());
|
||||
printf ("\nUniversal Interrupt Controller Regs\n"
|
||||
"uicsr uicsrs uicer uiccr uicpr uictr uicmsr uicvr uicvcr"
|
||||
"\n"
|
||||
"%08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
mfdcr(uicsr),
|
||||
mfdcr(uicsrs),
|
||||
mfdcr(uicer),
|
||||
mfdcr(uiccr),
|
||||
mfdcr(uicpr),
|
||||
mfdcr(uictr),
|
||||
mfdcr(uicmsr),
|
||||
mfdcr(uicvr),
|
||||
mfdcr(uicvcr));
|
||||
|
||||
puts ("\nMemory (SDRAM) Configuration\n"
|
||||
"besra besrsa besrb besrsb bear mcopt1 rtr pmit\n");
|
||||
|
||||
mtdcr(memcfga,mem_besra); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrsa); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrb); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_besrsb); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_bear); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mcopt1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_rtr); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_pmit); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
puts ("\n"
|
||||
"mb0cf mb1cf mb2cf mb3cf sdtr1 ecccf eccerr\n");
|
||||
mtdcr(memcfga,mem_mb0cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb1cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb2cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_mb3cf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_sdtr1); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_ecccf); printf ("%08x ", mfdcr(memcfgd));
|
||||
mtdcr(memcfga,mem_eccerr); printf ("%08x ", mfdcr(memcfgd));
|
||||
|
||||
printf ("\n\n"
|
||||
"DMA Channels\n"
|
||||
"dmasr dmasgc dmaadr\n"
|
||||
"%08x %08x %08x\n"
|
||||
"dmacr_0 dmact_0 dmada_0 dmasa_0 dmasb_0\n"
|
||||
"%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_1 dmact_1 dmada_1 dmasa_1 dmasb_1\n"
|
||||
"%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmasr), mfdcr(dmasgc),mfdcr(dmaadr),
|
||||
mfdcr(dmacr0), mfdcr(dmact0),mfdcr(dmada0), mfdcr(dmasa0), mfdcr(dmasb0),
|
||||
mfdcr(dmacr1), mfdcr(dmact1),mfdcr(dmada1), mfdcr(dmasa1), mfdcr(dmasb1));
|
||||
|
||||
printf (
|
||||
"dmacr_2 dmact_2 dmada_2 dmasa_2 dmasb_2\n" "%08x %08x %08x %08x %08x\n"
|
||||
"dmacr_3 dmact_3 dmada_3 dmasa_3 dmasb_3\n" "%08x %08x %08x %08x %08x\n",
|
||||
mfdcr(dmacr2), mfdcr(dmact2),mfdcr(dmada2), mfdcr(dmasa2), mfdcr(dmasb2),
|
||||
mfdcr(dmacr3), mfdcr(dmact3),mfdcr(dmada3), mfdcr(dmasa3), mfdcr(dmasb3) );
|
||||
|
||||
puts ("\n"
|
||||
"External Bus\n"
|
||||
"pbear pbesr0 pbesr1 epcr\n");
|
||||
mtdcr(ebccfga,pbear); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr0); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pbesr1); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,epcr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb0cr pb0ap pb1cr pb1ap pb2cr pb2ap pb3cr pb3ap\n");
|
||||
mtdcr(ebccfga,pb0cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb0ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb1ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb2ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb3ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n"
|
||||
"pb4cr pb4ap pb5cr bp5ap pb6cr pb6ap pb7cr pb7ap\n");
|
||||
mtdcr(ebccfga,pb4cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb4ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb5cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb5ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb6cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb6ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb7cr); printf ("%08x ", mfdcr(ebccfgd));
|
||||
mtdcr(ebccfga,pb7ap); printf ("%08x ", mfdcr(ebccfgd));
|
||||
|
||||
puts ("\n\n");
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc5xxx.h>
|
||||
#include <asm/arch/mpc5xxx.h>
|
||||
#include <driver.h>
|
||||
#include <init.h>
|
||||
#include <console.h>
|
||||
|
|
54
fs/fs.c
54
fs/fs.c
|
@ -485,7 +485,11 @@ int erase(int fd, size_t count, unsigned long offset)
|
|||
|
||||
if (f->pos + count > f->size)
|
||||
count = f->size - f->pos;
|
||||
errno = fsdrv->erase(dev, f, count, offset);
|
||||
|
||||
if (fsdrv->erase)
|
||||
errno = fsdrv->erase(dev, f, count, offset);
|
||||
else
|
||||
errno = -EINVAL;
|
||||
|
||||
return errno;
|
||||
}
|
||||
|
@ -749,3 +753,51 @@ out:
|
|||
return errno;
|
||||
}
|
||||
|
||||
static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize)
|
||||
{
|
||||
ulong dst = (ulong)_dst;
|
||||
ulong src = (ulong)_src;
|
||||
|
||||
/* no rwsize specification given. Do whatever memcpy likes best */
|
||||
if (!rwsize) {
|
||||
memcpy(_dst, _src, count);
|
||||
return;
|
||||
}
|
||||
|
||||
rwsize = rwsize >> O_RWSIZE_SHIFT;
|
||||
|
||||
count /= rwsize;
|
||||
|
||||
while (count-- > 0) {
|
||||
switch (rwsize) {
|
||||
case 1:
|
||||
*((u_char *)dst) = *((u_char *)src);
|
||||
break;
|
||||
case 2:
|
||||
*((ushort *)dst) = *((ushort *)src);
|
||||
break;
|
||||
case 4:
|
||||
*((ulong *)dst) = *((ulong *)src);
|
||||
break;
|
||||
}
|
||||
dst += rwsize;
|
||||
src += rwsize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags)
|
||||
{
|
||||
ulong size;
|
||||
size = min(count, dev->size - offset);
|
||||
debug("mem_read: dev->map_base: %p size: %d offset: %d\n",dev->map_base, size, offset);
|
||||
memcpy_sz(buf, (void *)(dev->map_base + offset), size, flags & O_RWSIZE_MASK);
|
||||
return size;
|
||||
}
|
||||
|
||||
ssize_t mem_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags)
|
||||
{
|
||||
ulong size;
|
||||
size = min(count, dev->size - offset);
|
||||
memcpy_sz((void *)(dev->map_base + offset), buf, size, flags & O_RWSIZE_MASK);
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -74,14 +74,7 @@ typedef void (interrupt_handler_t)(void *);
|
|||
* Function Prototypes
|
||||
*/
|
||||
void do_reset(void);
|
||||
|
||||
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
|
||||
void serial_buffered_init (void);
|
||||
void serial_buffered_putc (const char);
|
||||
void serial_buffered_puts (const char *);
|
||||
int serial_buffered_getc (void);
|
||||
int serial_buffered_tstc (void);
|
||||
#endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
|
||||
void reginfo(void);
|
||||
|
||||
void hang (void) __attribute__ ((noreturn));
|
||||
|
||||
|
|
|
@ -7,13 +7,5 @@ config BZLIB
|
|||
config CRC32
|
||||
bool
|
||||
|
||||
config DYNAMIC_CRC_TABLE
|
||||
bool
|
||||
prompt "Generate the crc32 table dynamically"
|
||||
default y
|
||||
help
|
||||
Saying yes to this option saves around 800 bytes of binary size.
|
||||
If unsure say yes.
|
||||
|
||||
config CRC16
|
||||
bool
|
||||
|
|
|
@ -7,7 +7,6 @@ obj-y += div64.o
|
|||
obj-y += misc.o
|
||||
obj-y += driver.o
|
||||
obj-y += parameter.o
|
||||
obj-y += global.o
|
||||
obj-y += xfuncs.o
|
||||
obj-y += getopt.o
|
||||
obj-y += readkey.o
|
||||
|
|
35
lib/global.c
35
lib/global.c
|
@ -1,35 +0,0 @@
|
|||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <init.h>
|
||||
#include <driver.h>
|
||||
#include <malloc.h>
|
||||
#include <errno.h>
|
||||
|
||||
static struct device_d global_dev;
|
||||
|
||||
int global_add_param(struct param_d *param)
|
||||
{
|
||||
return dev_add_param(&global_dev, param);
|
||||
}
|
||||
|
||||
static struct device_d global_dev = {
|
||||
.name = "global",
|
||||
.id = "env",
|
||||
.map_base = 0,
|
||||
.size = 0,
|
||||
};
|
||||
|
||||
static struct driver_d global_driver = {
|
||||
.name = "global",
|
||||
.probe = dummy_probe,
|
||||
};
|
||||
|
||||
static int global_init(void)
|
||||
{
|
||||
register_device(&global_dev);
|
||||
register_driver(&global_driver);
|
||||
return 0;
|
||||
}
|
||||
|
||||
coredevice_initcall(global_init);
|
||||
|
28
lib/misc.c
28
lib/misc.c
|
@ -1,36 +1,8 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <driver.h>
|
||||
#include <init.h>
|
||||
#include <malloc.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fs.h>
|
||||
#include <net.h>
|
||||
|
||||
int cmd_get_data_size(char* arg, int default_size)
|
||||
{
|
||||
/* Check for a size specification .b, .w or .l.
|
||||
*/
|
||||
int len = strlen(arg);
|
||||
if (len > 2 && arg[len-2] == '.') {
|
||||
switch(arg[len-1]) {
|
||||
case 'b':
|
||||
return 1;
|
||||
case 'w':
|
||||
return 2;
|
||||
case 'l':
|
||||
return 4;
|
||||
case 's':
|
||||
return -2;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return default_size;
|
||||
}
|
||||
|
||||
|
||||
unsigned long strtoul_suffix(const char *str, char **endp, int base)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ const char *dev_get_param(struct device_d *dev, const char *name)
|
|||
return param->value;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
IPaddr_t dev_get_param_ip(struct device_d *dev, char *name)
|
||||
{
|
||||
return string_to_ip(dev_get_param(dev, name));
|
||||
|
@ -45,6 +46,7 @@ int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip)
|
|||
|
||||
return dev_set_param(dev, name, ipstr);
|
||||
}
|
||||
#endif
|
||||
|
||||
int dev_set_param(struct device_d *dev, const char *name, const char *val)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue