2 * 2006.3 yhlu add copy data from CAR to ram
4 #include "cpu/amd/car/disable_cache_as_ram.c"
6 #include "cpu/amd/car/clear_init_ram.c"
8 static inline void print_debug_pcar(const char *strval, uint32_t val)
11 printk_debug("%s%08x\r\n", strval, val);
13 print_debug(strval); print_debug_hex32(val); print_debug("\r\n");
17 static void inline __attribute__((always_inline)) memcopy(void *dest, const void *src, unsigned long bytes)
23 : "S" (src), "D" (dest), "c" ((bytes)>>2)
27 static void post_cache_as_ram(void)
32 /* Check value of esp to verify if we have enough rom for stack in Cache as RAM */
38 print_debug_pcar("v_esp=", v_esp);
42 unsigned testx = 0x5a5a5a5a;
43 print_debug_pcar("testx = ", testx);
45 /* copy data from cache as ram to
46 ram need to set CONFIG_LB_MEM_TOPK to 2048 and use var mtrr instead.
48 #if CONFIG_LB_MEM_TOPK <= 1024
49 #error "You need to set CONFIG_LB_MEM_TOPK greater than 1024"
52 set_init_ram_access();
54 print_debug("Copying data from cache to ram -- switching to use ram as stack... ");
56 /* from here don't store more data in CAR */
60 memcopy((CONFIG_LB_MEM_TOPK<<10)-DCACHE_RAM_SIZE, DCACHE_RAM_BASE, DCACHE_RAM_SIZE); //inline
62 /* set new esp */ /* before _RAMBASE */
65 ::"a"( (DCACHE_RAM_BASE + DCACHE_RAM_SIZE)- (CONFIG_LB_MEM_TOPK<<10) )
66 ); // We need to push %eax to the stack (CAR) before copy stack and pop it later after copy stack and change esp
70 /* We can put data to stack again */
72 /* only global variable sysinfo in cache need to be offset */
73 print_debug("Done\r\n");
74 print_debug_pcar("testx = ", testx);
76 print_debug("Disabling cache as ram now \r\n");
77 disable_cache_as_ram_bsp();
79 print_debug("Clearing initial memory region: ");
80 clear_init_ram(); //except the range from [(CONFIG_LB_MEM_TOPK<<10) - DCACHE_RAM_SIZE, (CONFIG_LB_MEM_TOPK<<10)), that is used as stack in ram
81 print_debug("Done\r\n");
83 /*copy and execute linuxbios_ram */
85 /* We will not return */
87 print_debug("should not be here -\r\n");