summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/rtkload/hfload.c
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2012-09-13 00:40:35 +0300
committerRoman Yeryomin <roman@advem.lv>2012-12-03 00:13:21 +0200
commit5deb3317cb51ac52de922bb55f8492624018906d (patch)
treec2fbe6346699d9bb0f2100490c3029519bb8fde8 /target/linux/realtek/files/rtkload/hfload.c
parent0239d37124f9184b478a42de8a7fa1bc85a6a6fe (diff)
Add realtek target files
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/files/rtkload/hfload.c')
-rw-r--r--target/linux/realtek/files/rtkload/hfload.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/target/linux/realtek/files/rtkload/hfload.c b/target/linux/realtek/files/rtkload/hfload.c
new file mode 100644
index 000000000..05bdb4772
--- /dev/null
+++ b/target/linux/realtek/files/rtkload/hfload.c
@@ -0,0 +1,117 @@
+/* hfload.c
+ *
+ * This file is subject to the terms and conditions of the GNU
+ * General Public License. See the file "COPYING" in the main
+ * directory of this archive for more details.
+ *
+ * Copyright (C) 2000, Jay Carlson
+ */
+
+/*
+ * Boot loader main program.
+ */
+//#include <linux/config.h>
+#include <linux/autoconf.h>
+
+#include <unistd.h>
+//#include <linux/elf.h>
+#include "hfload.h"
+
+#define REG32(reg) (*(volatile unsigned int *)((unsigned int)reg))
+
+#if defined(CONFIG_RTL_819X)
+ #define BASE_ADDR 0xB8000000
+ #define set_io_port_base(base) \
+ do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
+
+ const unsigned long mips_io_port_base;
+#endif
+
+int file_offset;
+unsigned long kernelStartAddr;
+/*
+int old_stack_pointer;
+
+#define MAX_PHDRS_SIZE 8
+
+Elf32_Ehdr header;
+Elf32_Phdr phdrs[MAX_PHDRS_SIZE];
+*/
+extern void flush_cache(void);
+
+/*
+void
+zero_region(char *start, char *end)
+{
+ char *addr;
+ int count;
+
+ count = end - start;
+#ifndef __DO_QUIET__
+ printf("zeroing from %08x to to %08x, 0x%x bytes\n", start, end, count);
+#endif
+
+#ifndef FAKE_COPYING
+ memset(start, 0, count);
+#endif
+}
+
+void
+load_phdr(Elf32_Phdr *phdr)
+{
+ char *addr, *end;
+
+ seek_forward(phdr->p_offset);
+
+ addr = (char *)phdr->p_vaddr;
+ end = ((char *)addr) + phdr->p_memsz;
+
+ copy_to_region(addr, phdr->p_filesz);
+
+ addr = ((char *)addr) + phdr->p_filesz;
+
+ zero_region(addr, end);
+}
+*/
+
+int main(unsigned long stack_start_addr)
+{
+ int i;
+ //Elf32_Ehdr *pHdr;
+
+ file_offset = 0;
+
+#if defined(CONFIG_RTL_819X)
+ set_io_port_base(BASE_ADDR);
+#endif
+
+#ifndef __DO_QUIET__
+ printf("decompressing kernel:\n");
+#endif
+
+#ifdef CONFIG_RTL8197B_PANA
+ extern int is_vmlinux_checksum_ok();
+
+ REG32(0xB801900C) = REG32(0xB801900C) & (~0x0400); //SYSSR, AllSoftwareReady=0
+ if (!is_vmlinux_checksum_ok()) {
+ printf("Linux image corrupted!\n");
+ for (;;);
+ }
+#endif
+
+#ifndef BZ2_COMPRESS
+ decompress_kernel(UNCOMPRESS_OUT, stack_start_addr+4096, FREEMEM_END, 0);
+#else
+ decompress_kernel(UNCOMPRESS_OUT, stack_start_addr+4096, FREEMEM_END, 0);
+#endif
+
+#ifndef __DO_QUIET__
+ printf("done decompressing kernel.\n");
+#endif
+
+ flush_cache();
+
+ printf("start address: 0x%08x\n", kernelStartAddr);
+ start_kernel(kernelStartAddr);
+ //start_kernel(0x80000000);
+}