6baf53ec8fb63bc319bc6a6d4286f715b63854d0
[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         unsigned long dst_len;
16         unsigned long ilen, olen;
17
18         print_debug("Copying LinuxBIOS to RAM.\r\n");
19
20 #if !CONFIG_COMPRESS 
21         __asm__ volatile (
22                 "leal _liseg, %0\n\t"
23                 "leal _iseg, %1\n\t"
24                 "leal _eiseg, %2\n\t"
25                 "subl %1, %2\n\t"
26                 : "=a" (src), "=b" (dst), "=c" (dst_len)
27         );
28         memcpy(src, dst, dst_len);
29 #else 
30
31         __asm__ volatile (
32                 "leal _liseg, %0\n\t"
33                 "leal _iseg,  %1\n\t"
34                 : "=a" (src) , "=b" (dst)
35         );
36
37 #if CONFIG_USE_INIT             
38         printk_debug("src=%08x\r\n",src); 
39         printk_debug("dst=%08x\r\n",dst);
40 #else
41         print_debug("src="); print_debug_hex32(src); print_debug("\r\n");
42         print_debug("dst="); print_debug_hex32(dst); print_debug("\r\n");
43 #endif
44         
45 //      dump_mem(src, src+0x100);
46
47         olen = unrv2b(src, dst, &ilen);
48
49 #endif
50 //      dump_mem(dst, dst+0x100);
51 #if CONFIG_USE_INIT
52         printk_debug("linxbios_ram.bin length = %08x\r\n", olen);
53 #else
54         print_debug("linxbios_ram.bin length = "); print_debug_hex32(olen); print_debug("\r\n");
55 #endif
56         print_debug("Jumping to LinuxBIOS.\r\n");
57
58         if(cpu_reset == 1 ) {
59                 __asm__ volatile (
60                         "movl $0xffffffff, %ebp\n\t"
61                 );
62         }
63         else {
64                 __asm__ volatile (
65                         "xorl %ebp, %ebp\n\t"
66                 );
67         }
68         
69         __asm__ volatile (
70                 "cli\n\t"
71                 "leal    _iseg, %edi\n\t"
72                 "jmp     %edi\n\t"
73         );
74
75 }