This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / cpu / amd / car / copy_and_run.c
index b81297c14986cc87a360c0e3814d47adffa6abe2..f495f6dbbade4a8ddcac207e209e1181a4880a84 100644 (file)
@@ -3,63 +3,61 @@
    2006/05/02 - stepan: move nrv2b to an extra file.
 */
 
-static inline void print_debug_cp_run(const char *strval, uint32_t val)
+#if CONFIG_CBFS == 1
+void cbfs_and_run_core(char*, unsigned ebp);
+
+static void copy_and_run(void)
 {
-#if CONFIG_USE_INIT
-        printk_debug("%s%08x\r\n", strval, val);
-#else
-        print_debug(strval); print_debug_hex32(val); print_debug("\r\n");
-#endif
+# if CONFIG_USE_FALLBACK_IMAGE == 1
+       cbfs_and_run_core("fallback/coreboot_ram", 0);
+# else
+       cbfs_and_run_core("normal/coreboot_ram", 0);
+# endif
 }
 
-#if CONFIG_COMPRESS
-#define ENDIAN   0
-#define BITSIZE 32
-#include "lib/nrv2b.c"
+#if CONFIG_AP_CODE_IN_CAR == 1
+
+static void copy_and_run_ap_code_in_car(unsigned ret_addr)
+{
+# if CONFIG_USE_FALLBACK_IMAGE == 1
+       cbfs_and_run_core("fallback/coreboot_apc", ret_addr);
+# else
+       cbfs_and_run_core("normal/coreboot_apc", ret_addr);
+# endif
+}
 #endif
 
+#else
+void copy_and_run_core(u8 *src, u8 *dst, unsigned long ilen, unsigned ebp);
+
+extern u8 _liseg, _iseg, _eiseg;
 
 static void copy_and_run(void)
 {
        uint8_t *src, *dst; 
-        unsigned long ilen, olen;
+        unsigned long ilen;
 
-       print_debug("Copying LinuxBIOS to ram.\r\n");
+       src = &_liseg;
+       dst = &_iseg;
+       ilen = &_eiseg - dst;
 
-#if !CONFIG_COMPRESS 
-       __asm__ volatile (
-               "leal _liseg, %0\n\t"
-               "leal _iseg, %1\n\t"
-               "leal _eiseg, %2\n\t"
-               "subl %1, %2\n\t"
-               : "=a" (src), "=b" (dst), "=c" (olen)
-       );
-       memcpy(dst, src, olen);
-#else 
-
-        __asm__ volatile (
-               "leal  _liseg, %0\n\t"
-               "leal  _iseg,  %1\n\t"
-                : "=a" (src) , "=b" (dst)
-        );
-
-       print_debug_cp_run("src=",(uint32_t)src); 
-       print_debug_cp_run("dst=",(uint32_t)dst);
-
-       olen = unrv2b(src, dst, &ilen);
-       print_debug_cp_run("linxbios_ram.nrv2b length = ", ilen);
+       copy_and_run_core(src, dst, ilen, 0);
+}
 
-#endif
+#if CONFIG_AP_CODE_IN_CAR == 1
 
-       print_debug_cp_run("linxbios_ram.bin   length = ", olen);
+extern u8 _liseg_apc, _iseg_apc, _eiseg_apc;
 
-       print_debug("Jumping to LinuxBIOS.\r\n");
+static void copy_and_run_ap_code_in_car(unsigned ret_addr)
+{
+        uint8_t *src, *dst;
+        unsigned long ilen;
 
-        __asm__ volatile (
-                "xorl %ebp, %ebp\n\t" /* cpu_reset for hardwaremain dummy */
-               "cli\n\t"
-               "leal    _iseg, %edi\n\t"
-               "jmp     *%edi\n\t"
-       );
+       src = &_liseg_apc;
+       dst = &_iseg_apc;
+       ilen = &_eiseg_apc - dst;
 
+       copy_and_run_core(src, dst, ilen, ret_addr);
 }
+#endif
+#endif