Support for Intel Core Duo and Core 2 Duo (tm) CPUs.
[coreboot.git] / src / cpu / x86 / car / copy_and_run.c
1 /* by yhlu 6.2005 
2         moved from nrv2v.c and some lines from crt0.S
3    2006/05/02 - stepan: move nrv2b to an extra file.
4 */
5
6 #if CONFIG_COMPRESS
7 #define ENDIAN   0
8 #define BITSIZE 32
9 #include "lib/nrv2b.c"
10 #endif
11
12 static void copy_and_run(unsigned cpu_reset)
13 {
14         uint8_t *src, *dst; 
15 #if !CONFIG_COMPRESS
16         unsigned long dst_len;
17 #endif
18         unsigned long ilen, olen;
19
20
21 #if !CONFIG_COMPRESS 
22         print_debug("Copying coreboot to RAM.\r\n");
23         __asm__ volatile (
24                 "leal _liseg, %0\n\t"
25                 "leal _iseg, %1\n\t"
26                 "leal _eiseg, %2\n\t"
27                 "subl %1, %2\n\t"
28                 : "=a" (src), "=b" (dst), "=c" (dst_len)
29         );
30         memcpy(src, dst, dst_len);
31 #else 
32         print_debug("Uncompressing coreboot to RAM.\r\n");
33
34         __asm__ volatile (
35                 "leal _liseg, %0\n\t"
36                 "leal _iseg,  %1\n\t"
37                 : "=a" (src) , "=b" (dst)
38         );
39
40 #if CONFIG_USE_INIT             
41         printk_spew("src=%08x\r\n",src); 
42         printk_spew("dst=%08x\r\n",dst);
43 #else
44         print_spew("src="); print_spew_hex32((uint32_t)src); print_spew("\r\n");
45         print_spew("dst="); print_spew_hex32((uint32_t)dst); print_spew("\r\n");
46 #endif
47         
48 //      dump_mem(src, src+0x100);
49
50         olen = unrv2b(src, dst, &ilen);
51
52 #endif
53 //      dump_mem(dst, dst+0x100);
54 #if CONFIG_USE_INIT
55         printk_spew("coreboot_ram.bin length = %08x\r\n", olen);
56 #else
57         print_spew("coreboot_ram.bin length = "); print_spew_hex32(olen); print_spew("\r\n");
58 #endif
59         print_debug("Jumping to coreboot.\r\n");
60
61         if(cpu_reset == 1 ) {
62                 __asm__ volatile (
63                         "movl $0xffffffff, %ebp\n\t"
64                 );
65         }
66         else {
67                 __asm__ volatile (
68                         "xorl %ebp, %ebp\n\t"
69                 );
70         }
71         
72         __asm__ volatile (
73                 "cli\n\t"
74                 "leal    _iseg, %edi\n\t"
75                 "jmp     *%edi\n\t"
76         );
77
78 }