[U-Boot] [PATCH 1/5] Add h8300 architecture part1 - core

Yoshinori Sato ysato at users.sourceforge.jp
Wed Mar 2 08:39:53 CET 2011


This part of h8300 cpu support

Signed-off-by: Yoshinori Sato <ysato at users.sourceforge.jp>
---
 arch/h8300/config.mk               |   35 ++++++++
 arch/h8300/cpu/h8300s/Makefile     |   53 ++++++++++++
 arch/h8300/cpu/h8300s/config.mk    |   26 ++++++
 arch/h8300/cpu/h8300s/cpu.c        |   83 +++++++++++++++++++
 arch/h8300/cpu/h8300s/interrupts.c |   38 +++++++++
 arch/h8300/cpu/h8300s/start.S      |   87 ++++++++++++++++++++
 arch/h8300/cpu/h8300s/watchdog.c   |   36 ++++++++
 arch/h8300/lib/Makefile            |   43 ++++++++++
 arch/h8300/lib/board.c             |  158 ++++++++++++++++++++++++++++++++++++
 arch/h8300/lib/bootm.c             |   70 ++++++++++++++++
 arch/h8300/lib/time.c              |   87 ++++++++++++++++++++
 11 files changed, 716 insertions(+), 0 deletions(-)
 create mode 100644 arch/h8300/config.mk
 create mode 100644 arch/h8300/cpu/h8300s/Makefile
 create mode 100644 arch/h8300/cpu/h8300s/config.mk
 create mode 100644 arch/h8300/cpu/h8300s/cpu.c
 create mode 100644 arch/h8300/cpu/h8300s/interrupts.c
 create mode 100644 arch/h8300/cpu/h8300s/start.S
 create mode 100644 arch/h8300/cpu/h8300s/watchdog.c
 create mode 100644 arch/h8300/lib/Makefile
 create mode 100644 arch/h8300/lib/board.c
 create mode 100644 arch/h8300/lib/bootm.c
 create mode 100644 arch/h8300/lib/time.c

diff --git a/arch/h8300/config.mk b/arch/h8300/config.mk
new file mode 100644
index 0000000..11c6a01
--- /dev/null
+++ b/arch/h8300/config.mk
@@ -0,0 +1,35 @@
+#
+# (C) Copyright 2000-2002
+# 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
+#
+
+ifneq ($(CONFIG_H8300S),)
+PLATFORM_CPPFLAGS += -ms -mint32
+PLATFORM_LDFLAGS += -mh8300self
+STANDALONE_LOAD_ADDR = 0x00000000 -mh8300self
+endif
+ifneq ($(CONFIG_H8300H),)
+PLATFORM_CPPFLAGS += -mh -mint32
+PLATFORM_LDFLAGS += -mh8300helf
+STANDALONE_LOAD_ADDR = 0x00000000 -mh8300helf
+endif
+
+SYM_PREFIX = _
\ No newline at end of file
diff --git a/arch/h8300/cpu/h8300s/Makefile b/arch/h8300/cpu/h8300s/Makefile
new file mode 100644
index 0000000..4f2ee79
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/Makefile
@@ -0,0 +1,53 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2011 Yoshinori Sato
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+SOBJS	= start.o
+COBJS	= cpu.o interrupts.o watchdog.o
+
+SRCS    := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS    := $(addprefix $(obj),$(COBJS))
+SOBJS   := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(OBJS) $(SOBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+	rm -f $(SOBJS) $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/arch/h8300/cpu/h8300s/config.mk b/arch/h8300/cpu/h8300s/config.mk
new file mode 100644
index 0000000..eee3234
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/config.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+#
+# 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
+#
+#
+PLATFORM_CPPFLAGS += -ms
+USE_PRIVATE_LIBGCC = $(shell dirname `$(CC) $(CFLAGS) -ms -mint32 -print-libgcc-file-name`)
+LDEMUL = -mh8300self
+LDFLAGS += $(LDEMUL)
diff --git a/arch/h8300/cpu/h8300s/cpu.c b/arch/h8300/cpu/h8300s/cpu.c
new file mode 100644
index 0000000..dfae6db
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/cpu.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+ *
+ * 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>
+#include <asm/processor.h>
+#include <asm/io.h>
+
+int checkcpu(void)
+{
+	puts("CPU: H8300S\n");
+	return 0;
+}
+
+int cpu_init(void)
+{
+	/* TMR and SCI enable */
+	outb(0xf0, 0xffff41);
+	return 0;
+}
+
+int cleanup_before_linux(void)
+{
+	disable_interrupts();
+	return 0;
+}
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	disable_interrupts();
+	reset_cpu(0);
+	return 0;
+}
+
+void flush_cache(unsigned long addr, unsigned long size)
+{
+
+}
+
+void icache_enable(void)
+{
+}
+
+void icache_disable(void)
+{
+}
+
+int icache_status(void)
+{
+	return 0;
+}
+
+void dcache_enable(void)
+{
+}
+
+void dcache_disable(void)
+{
+}
+
+int dcache_status(void)
+{
+	return 0;
+}
diff --git a/arch/h8300/cpu/h8300s/interrupts.c b/arch/h8300/cpu/h8300s/interrupts.c
new file mode 100644
index 0000000..7e3adb5
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/interrupts.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+ *
+ * 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>
+
+int interrupt_init(void)
+{
+	return 0;
+}
+
+void enable_interrupts(void)
+{
+
+}
+
+int disable_interrupts(void)
+{
+	return 0;
+}
diff --git a/arch/h8300/cpu/h8300s/start.S b/arch/h8300/cpu/h8300s/start.S
new file mode 100644
index 0000000..620c147
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/start.S
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+
+ * 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 <config.h>
+#include <version.h>
+
+	.h8300s
+
+	.section	.vector,"ax"
+	.long	0x200
+	.long	0x200
+vector	=	2
+	.rept	126
+	.long	__ram_vec + (vector * 4)
+vector	=	vector + 1
+	.endr
+
+	.global	_start
+	.text
+	.align	2
+_start:
+	mov.l	#__init_stack,sp
+	bsr	1f
+1:
+	mov.l	@sp+,er0
+	mov.l	#_lowlevel_init,er1
+	sub.l	#1b,er1
+	add.l	er1,er0
+	jsr	@er0
+
+#if !defined(CONFIG_H8300_SIM)
+#if defined(CONFIG_SYS_NO_FLASH)
+	/* .data setup */
+	mov.l	#__fdata,er5
+	mov.l	#__ram_data,er6
+	mov.l	#__sizeof_data,er4
+	eepmov.w
+#else
+	/* relocate */
+	bsr	1f
+1:	
+	mov.l	@sp+,er5
+	sub.l	#1b-_start,er5
+	mov.l	#CONFIG_SYS_TEXT_BASE,er6
+	mov.l	#_bss_start,er4
+	sub.l	er6,er4
+	shlr	#2,er4
+1:	mov.l	@er5,er0
+	mov.l	er0, at er6
+	adds	#4,er5
+	adds	#4,er6
+	dec.l	#1,er4
+	bne	1b
+#endif
+	mov.l	#_bss_start,er4
+	mov.l	#_bss_end,er5
+	sub	er4,er5
+	shlr.l	#2,er5
+	mov	#0,er0
+1:	mov.l	er0, at er4		/* bss clear */
+	adds	#4,er4
+	dec.l	#1,er5
+	bne	1b
+#endif
+	mov.l	#CONFIG_SYS_LOAD_ADDR - CONFIG_SYS_GBL_DATA_SIZE - CONFIG_SYS_MALLOC_LEN,er0
+	mov.l	er0,sp
+	jsr	@_h8300_generic_init
+	bra	.
+
+	.end
+
diff --git a/arch/h8300/cpu/h8300s/watchdog.c b/arch/h8300/cpu/h8300s/watchdog.c
new file mode 100644
index 0000000..77ce264
--- /dev/null
+++ b/arch/h8300/cpu/h8300s/watchdog.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+ *
+ * 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 <asm/processor.h>
+#include <asm/io.h>
+
+int watchdog_init(void)
+{
+	return 0;
+}
+
+void reset_cpu(unsigned long ignored)
+{
+	__raw_writew(0x5a80, 0xffffbc);
+	__raw_writew(0x5a40, 0xffffbe);
+	__raw_writew(0xa578, 0xffffbc);
+	while (1)
+		;
+}
diff --git a/arch/h8300/lib/Makefile b/arch/h8300/lib/Makefile
new file mode 100644
index 0000000..14f93e5
--- /dev/null
+++ b/arch/h8300/lib/Makefile
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(ARCH).o
+
+SOBJS-y	+=
+
+COBJS-y	+= board.o
+COBJS-y	+= bootm.o
+COBJS-y	+= time.o
+
+SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/arch/h8300/lib/board.c b/arch/h8300/lib/board.c
new file mode 100644
index 0000000..54df901
--- /dev/null
+++ b/arch/h8300/lib/board.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+ *
+ * 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>
+#include <malloc.h>
+#include <stdio_dev.h>
+#include <timestamp.h>
+#include <version.h>
+#include <watchdog.h>
+#include <net.h>
+#include <environment.h>
+
+extern int cpu_init(void);
+extern int board_init(void);
+extern int dram_init(void);
+extern int timer_init(void);
+
+const char version_string[] = U_BOOT_VERSION" ("U_BOOT_DATE" - "U_BOOT_TIME")";
+
+#ifndef CONFIG_SYS_NO_FLASH
+extern int __bss_start;
+unsigned long monitor_flash_len = &__bss_start;
+#endif
+
+#if defined(CONFIG_WATCHDOG)
+extern int watchdog_init(void);
+extern int watchdog_disable(void);
+# define INIT_FUNC_WATCHDOG_INIT	watchdog_init,
+# define WATCHDOG_DISABLE       	watchdog_disable
+#else
+# define INIT_FUNC_WATCHDOG_INIT
+# define WATCHDOG_DISABLE
+#endif /* CONFIG_WATCHDOG */
+
+#if defined(CONFIG_CMD_IDE)
+# include <ide.h>
+# define INIT_FUNC_IDE_INIT	ide_init,
+#else
+# define INIT_FUNC_IDE_INIT
+#endif /* CONFIG_CMD_IDE */
+
+gd_t *gd;
+
+typedef int (init_fnc_t) (void);
+
+static init_fnc_t * const init_sequence[] =
+{
+	cpu_init,		/* basic cpu dependent setup */
+	board_init,		/* basic board dependent setup */
+	interrupt_init,	/* set up exceptions */
+	env_init,		/* event init */
+	serial_init,	/* SCI init */
+	INIT_FUNC_WATCHDOG_INIT	/* watchdog init */
+	console_init_f,
+	display_options,
+	checkcpu,
+	checkboard,		/* Check support board */
+	dram_init,
+	timer_init,
+	interrupt_init,
+	NULL			/* Terminate this list */
+};
+
+
+void h8300_generic_init(gd_t *_gd)
+{
+	bd_t *bd;
+	init_fnc_t * const *init_fnc_ptr;
+	gd = _gd;
+	memset(gd, 0, CONFIG_SYS_GBL_DATA_SIZE);
+
+	gd->bd = (bd_t *)(gd + 1);	/* At end of global data */
+	gd->flags = GD_FLG_RELOC;
+	gd->baudrate = CONFIG_BAUDRATE;
+
+	gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
+
+	bd = gd->bd;
+#if defined(CONFIG_SYS_SDRAM_BASE)
+	bd->bi_memstart	= CONFIG_SYS_SDRAM_BASE;
+	bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
+#else
+	bd->bi_memstart	= CONFIG_SYS_DRAM_BASE;
+	bd->bi_memsize = CONFIG_SYS_DRAM_SIZE;
+#endif
+#if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
+	bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
+	bd->bi_sramsize	= CONFIG_SYS_SRAM_SIZE;
+#endif
+	bd->bi_baudrate	= CONFIG_BAUDRATE;
+
+	mem_malloc_init((unsigned long)gd + CONFIG_SYS_GBL_DATA_SIZE,
+			CONFIG_SYS_MALLOC_LEN);
+	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+		WATCHDOG_RESET();
+		if ((*init_fnc_ptr) () != 0)
+			hang();
+	}
+#if !defined(CONFIG_SYS_NO_FLASH)
+	bd->bi_flashsize = flash_init();
+#endif
+	env_relocate();
+	stdio_init();
+	console_init_r();
+
+#ifdef CONFIG_WATCHDOG
+	/* disable watchdog if environment is set */
+	{
+		char *s = getenv("watchdog");
+		if (s != NULL)
+			if (strncmp(s, "off", 3) == 0)
+				WATCHDOG_DISABLE();
+	}
+#endif /* CONFIG_WATCHDOG*/
+
+#if defined(CONFIG_CMD_NET)
+	{
+		char *s;
+		puts("Net:   ");
+		eth_initialize(gd->bd);
+
+		s = getenv("bootfile");
+		if (s != NULL)
+			copy_filename(BootFile, s, sizeof(BootFile));
+	}
+#endif /* CONFIG_CMD_NET */
+
+	while (1) {
+		WATCHDOG_RESET();
+		main_loop();
+	}
+}
+
+/***********************************************************************/
+
+void hang(void)
+{
+	puts("Board ERROR\n");
+	for (;;)
+		;
+}
diff --git a/arch/h8300/lib/bootm.c b/arch/h8300/lib/bootm.c
new file mode 100644
index 0000000..ae1f869
--- /dev/null
+++ b/arch/h8300/lib/bootm.c
@@ -0,0 +1,70 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro at renesas.com>
+ * (c) Copyright 2008 Renesas Solutions Corp.
+ *
+ * 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>
+#include <asm/byteorder.h>
+
+#ifdef CONFIG_SYS_DEBUG
+static void hexdump(unsigned char *buf, int len)
+{
+	int i;
+
+	for (i = 0; i < len; i++) {
+		if ((i % 16) == 0)
+			printf("%s%08x: ", i ? "\n" : "",
+							(unsigned int)&buf[i]);
+		printf("%02x ", buf[i]);
+	}
+	printf("\n");
+}
+#endif
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+	/* Linux kernel load address */
+	void (*kernel) (void) = (void (*)(void))images->ep;
+	/* empty_zero_page */
+	unsigned char *param
+		= (unsigned char *)image_get_load(images->legacy_hdr_os);
+	/* Linux kernel command line */
+	char *cmdline = (char *)param + 0x100;
+	/* PAGE_SIZE */
+	unsigned long size = images->ep - (unsigned long)param;
+	char *bootargs = getenv("bootargs");
+
+	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+		return 1;
+
+	/* Setup parameters */
+	memset(param, 0, size);	/* Clear zero page */
+	strcpy(cmdline, bootargs);
+
+	kernel();
+	/* does not return */
+
+	return 1;
+}
diff --git a/arch/h8300/lib/time.c b/arch/h8300/lib/time.c
new file mode 100644
index 0000000..5f741a6
--- /dev/null
+++ b/arch/h8300/lib/time.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Yoshinori Sato <ysato at users.sourceforge.jp>
+ *
+ * (C) Copyright 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 <asm/io.h>
+#include <asm/processor.h>
+
+#define TCR0  (CONFIG_TIMER_BASE + 0)
+#define TCR1  (CONFIG_TIMER_BASE + 1)
+#define TCSR0 (CONFIG_TIMER_BASE + 2)
+#define TCSR1 (CONFIG_TIMER_BASE + 3)
+#define TCNT0 (CONFIG_TIMER_BASE + 8)
+#define TCNT1 (CONFIG_TIMER_BASE + 9)
+
+static unsigned long long tick;
+static unsigned short last;
+
+int timer_init(void)
+{
+	outb(0x04, TCR0);	/* 16bit free running */
+	outb(0x01, TCR1);	/* clk / 8 */
+	return 0;
+}
+
+unsigned long long get_ticks(void)
+{
+	unsigned short now = inw(TCNT0);
+	if (now < last)
+		tick += (0x10000 - last) + now;
+	else
+		tick += now - last;
+	last = now;
+	return tick;
+}
+
+ulong get_timer(ulong base)
+{
+	return get_ticks() / (CONFIG_SYS_CLK_FREQ / 1000) - base;
+}
+
+void set_timer(ulong t)
+{
+	outw((u16) t, TCNT0);
+}
+
+void reset_timer(void)
+{
+	last = 0;
+	outb(0x00, TCR1);
+	outw(0, TCNT0);
+	outb(0x01, TCR1);
+}
+
+void __udelay(unsigned long usec)
+{
+	unsigned long long end = get_ticks() + 
+		(usec * (CONFIG_SYS_CLK_FREQ / 8000000));
+
+	while (get_ticks() < end);
+}
+
+unsigned long get_tbclk(void)
+{
+	return CONFIG_SYS_CLK_FREQ / 8;
+}
-- 
1.7.2.3




More information about the U-Boot mailing list