Changeset 5153


Ignore:
Timestamp:
Feb 23, 2010 10:43:42 PM (3 years ago)
Author:
oxygene
Message:

Clobber registers as appropriate in AMD CAR code, and
build a better barrier for gcc to reflush all registers
when moving the stack. memcpy was taken from Linux.

Signed-off-by: Rudolf Marek <r.marek@…>
Acked-by: Patrick Georgi <patrick.georgi@…>

Location:
trunk/src/cpu/amd/car
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cpu/amd/car/disable_cache_as_ram.c

    r4381 r5153  
    33static inline __attribute__((always_inline)) void disable_cache_as_ram(void) 
    44{ 
    5  
    6         __asm__ volatile ( 
    7  
     5        __asm__ __volatile__ ( 
    86        /* We don't need cache as ram for now on */ 
    97        /* disable cache */ 
    10         "movl    %cr0, %eax\n\t" 
    11         "orl    $(0x1<<30),%eax\n\t" 
    12         "movl    %eax, %cr0\n\t" 
     8        "movl    %%cr0, %%eax\n\t" 
     9        "orl    $(0x1<<30),%%eax\n\t" 
     10        "movl    %%eax, %%cr0\n\t" 
    1311 
    1412        /* clear sth */ 
    15         "movl    $0x269, %ecx\n\t"  /* fix4k_c8000*/ 
    16         "xorl    %edx, %edx\n\t" 
    17         "xorl    %eax, %eax\n\t" 
     13        "movl    $0x269, %%ecx\n\t"  /* fix4k_c8000*/ 
     14        "xorl    %%edx, %%edx\n\t" 
     15        "xorl    %%eax, %%eax\n\t" 
    1816        "wrmsr\n\t" 
    1917#if CONFIG_DCACHE_RAM_SIZE > 0x8000 
    20         "movl    $0x268, %ecx\n\t"  /* fix4k_c0000*/ 
     18        "movl    $0x268, %%ecx\n\t"  /* fix4k_c0000*/ 
    2119        "wrmsr\n\t" 
    2220#endif 
    2321 
    2422        /* disable fixed mtrr from now on, it will be enabled by coreboot_ram again*/ 
    25         "movl    $0xC0010010, %ecx\n\t" 
     23        "movl    $0xC0010010, %%ecx\n\t" 
    2624//        "movl    $SYSCFG_MSR, %ecx\n\t" 
    2725        "rdmsr\n\t" 
    28         "andl    $(~(3<<18)), %eax\n\t" 
     26        "andl    $(~(3<<18)), %%eax\n\t" 
    2927//        "andl    $(~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)), %eax\n\t" 
    3028        "wrmsr\n\t" 
    3129 
    3230        /* Set the default memory type and disable fixed and enable variable MTRRs */ 
    33         "movl    $0x2ff, %ecx\n\t" 
     31        "movl    $0x2ff, %%ecx\n\t" 
    3432//        "movl    $MTRRdefType_MSR, %ecx\n\t" 
    35         "xorl    %edx, %edx\n\t" 
     33        "xorl    %%edx, %%edx\n\t" 
    3634        /* Enable Variable and Disable Fixed MTRRs */ 
    37         "movl    $0x00000800, %eax\n\t" 
     35        "movl    $0x00000800, %%eax\n\t" 
    3836        "wrmsr\n\t" 
    3937 
    4038        /* enable cache */ 
    41         "movl    %cr0, %eax\n\t" 
    42         "andl    $0x9fffffff,%eax\n\t" 
    43         "movl    %eax, %cr0\n\t" 
    44  
     39        "movl    %%cr0, %%eax\n\t" 
     40        "andl    $0x9fffffff,%%eax\n\t" 
     41        "movl    %%eax, %%cr0\n\t" 
     42        ::: "memory", "eax", "ecx", "edx" 
    4543        ); 
    4644} 
     
    4846static void disable_cache_as_ram_bsp(void) 
    4947{ 
    50         __asm__ volatile ( 
    51 //              "pushl %eax\n\t" 
    52                 "pushl %edx\n\t" 
    53                 "pushl %ecx\n\t" 
    54         ); 
    55  
    5648        disable_cache_as_ram(); 
    57         __asm__ volatile ( 
    58                 "popl %ecx\n\t" 
    59                 "popl %edx\n\t" 
    60 //                "popl %eax\n\t" 
    61         ); 
    6249} 
    6350 
  • trunk/src/cpu/amd/car/post_cache_as_ram.c

    r4856 r5153  
    1111} 
    1212 
     13/* from linux kernel 2.6.32 asm/string_32.h */ 
     14 
    1315static void inline __attribute__((always_inline))  memcopy(void *dest, const void *src, unsigned long bytes) 
    1416{ 
    15         __asm__ volatile( 
    16                 "cld\n\t" 
    17                 "rep; movsl\n\t" 
    18                 : /* No outputs */ 
    19                 : "S" (src), "D" (dest), "c" ((bytes)>>2) 
    20                 ); 
     17        int d0, d1, d2; 
     18        asm volatile("cld ; rep ; movsl\n\t" 
     19                        "movl %4,%%ecx\n\t" 
     20                        "andl $3,%%ecx\n\t" 
     21                        "jz 1f\n\t" 
     22                        "rep ; movsb\n\t" 
     23                        "1:" 
     24                        : "=&c" (d0), "=&D" (d1), "=&S" (d2) 
     25                        : "0" (bytes / 4), "g" (bytes), "1" ((long)dest), "2" ((long)src) 
     26                        : "memory", "cc"); 
    2127} 
    2228/* Disable Erratum 343 Workaround, see RevGuide for Fam10h, Pub#41322 Rev 3.33 */ 
     
    6773        vErrata343(); 
    6874 
    69 #if 0 
    70         __asm__ volatile ( 
    71                 "pushl  %eax\n\t" 
    72         ); 
    73 #endif 
    74  
    7575        memcopy((void *)((CONFIG_RAMTOP)-CONFIG_DCACHE_RAM_SIZE), (void *)CONFIG_DCACHE_RAM_BASE, CONFIG_DCACHE_RAM_SIZE); //inline 
    7676//        dump_mem((CONFIG_RAMTOP) - 0x8000, (CONFIG_RAMTOP) - 0x7c00); 
     
    7878        __asm__ volatile ( 
    7979                /* set new esp */ /* before CONFIG_RAMBASE */ 
    80                 "subl   %0, %%ebp\n\t" 
    8180                "subl   %0, %%esp\n\t" 
    8281                ::"a"( (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)- (CONFIG_RAMTOP) ) 
    83         ); // We need to push %eax to the stack (CAR) before copy stack and pop it later after copy stack and change esp 
    84 #if 0 
    85         __asm__ volatile ( 
    86                 "popl   %eax\n\t" 
     82                /* discard all registers (eax is used for %0), so gcc redo everything 
     83                   after the stack is moved */ 
     84                : "cc", "memory", "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp" 
    8785        ); 
    88 #endif 
    89  
    9086 
    9187        /* We can put data to stack again */ 
Note: See TracChangeset for help on using the changeset viewer.