Skip to contentSkip to conversation

MIPS Malta/YAMON SP initialization

PATCH New Alexander Voropay 1 participant 1 message Apr 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS Malta/YAMON SP initialization

Hi!

This patch adds SP initialization fot the Malta YAMON pseudo-loader.

It allows to run standalone (written in C) applications:

http://www.nwpi.ru/~alec/mips/yamon_test_salone.tgz

$ qemu-system-mipsel -nographic -M malta -kernel yamon_test.elf
Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal
error, but for better emulation accuracy either use a 2.6 host Linux kernel or
type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.
YAMON TEST
argc = 00000002
argv = 80002000
argv[00000000] = "yamon_test.elf"
argv[00000001] = ""
envp = 80002008
envp->name = "memsize"
envp->val = "134217728"
envp->name = "modetty0"
envp->val = "38400n8r"
memsize = 08000000

--
-=AV=-

hw/mips_malta.c renamed from qemu/hw/mips_malta.c +6 -0
@@ -39,6 +39,8 @@
 #define ENVP_ADDR (int32_t)0x80002000
 #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
 
+#define SP_ADDR (int32_t)0x80002000
+
 #define ENVP_NB_ENTRIES	 	16
 #define ENVP_ENTRY_SIZE	 	256
 
@@ -591,6 +593,10 @@
 #endif
     stl_raw(p++, 0xad280088);                                      /* sw t0, 0x0088(t1) */
 
+   /* initialize SP */
+    stl_raw(p++, 0x3c1d0000 | (((SP_ADDR - 64) >> 16) & 0xffff));  /* lui sp, high(ENVP_ADDR) */
+    stl_raw(p++, 0x37bd0000 | ((SP_ADDR - 64) & 0xffff));          /* ori sp, a0, low(ENVP_ADDR) */
+
     /* Jump to kernel code */
     stl_raw(p++, 0x3c1f0000 | ((kernel_entry >> 16) & 0xffff));    /* lui ra, high(kernel_entry) */
     stl_raw(p++, 0x37ff0000 | (kernel_entry & 0xffff));            /* ori ra, ra, low(kernel_entry) */