[U-Boot-Users] [PATCH] Add call command on PPC
Kumar Gala
galak at kernel.crashing.org
Fri Feb 15 06:42:29 CET 2008
The call command tries to mimic a function call in that the 'arg's to
the command are passed in registers according to the PPC ABI.
The prototype that call mimics is some variation of the following
depending on how many arguments are passed to the command:
void func(void)
void func(unsigned long r3)
void func(unsigned long r3, unsigned long r4)
...
void func(unsigned long r3, unsigned long r4, ... unsigned long r10)
The maximum number of 'arg's is 8. There are no arguments passed on
a stack, no floating point or vector arguments.
Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---
This is attempt to at the concept I was trying to get a w/the raw go
thread.
lib_ppc/Makefile | 4 ++-
lib_ppc/cmd_call.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletions(-)
create mode 100644 lib_ppc/cmd_call.c
diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile
index afbd5ca..a776052 100644
--- a/lib_ppc/Makefile
+++ b/lib_ppc/Makefile
@@ -25,9 +25,11 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(ARCH).a
+COBJS-$(CONFIG_CMD_CALL) += cmd_call.o
+
SOBJS = ppccache.o ppcstring.o ticks.o
-COBJS = board.o \
+COBJS = board.o $(COBJS-y) \
bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/lib_ppc/cmd_call.c b/lib_ppc/cmd_call.c
new file mode 100644
index 0000000..5476f27
--- /dev/null
+++ b/lib_ppc/cmd_call.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008 Freescale Semiconductor, Inc.
+ *
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, wd at 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
+ */
+
+#include <common.h>
+#include <command.h>
+
+int do_call (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ ulong addr, i;
+ ulong r[8] = { 0 };
+
+ void (*img)(ulong, ulong, ulong, ulong,
+ ulong, ulong, ulong, ulong);
+
+ if ((argc < 2) || (argc > 10)) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+
+ addr = simple_strtoul(argv[1], NULL, 16);
+
+ img = (void (*)(ulong, ulong, ulong, ulong,
+ ulong, ulong, ulong, ulong)) addr;
+
+ for (i = 2; i < argc; i++)
+ r[i-2] = simple_strtoul(argv[i], NULL, 16);
+
+ (*img)(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7]);
+
+ /* may not return */
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------- */
+
+U_BOOT_CMD(
+ call, CFG_MAXARGS, 1, do_call,
+ "call - jump to address 'addr'\n",
+ "addr [arg ...]\n - jump to address 'addr' passing 'arg's"
+ " as if it were a function call\n"
+);
--
1.5.3.8
More information about the U-Boot
mailing list