coreboot-v3/arch/x86/via/stage1.c
<<
>>
Prefs
   1/*
   2 * This file is part of the coreboot project.
   3 *
   4 * Copyright (C) 2008 Carl-Daniel Hailfinger
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License as published by
   8 * the Free Software Foundation; either version 2 of the License, or
   9 * (at your option) any later version.
  10 *
  11 * This program is distributed in the hope that it will be useful,
  12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 * GNU General Public License for more details.
  15 *
  16 * You should have received a copy of the GNU General Public License
  17 * along with this program; if not, write to the Free Software
  18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  19 */
  20
  21#include <types.h>
  22#include <lib.h>
  23#include <console.h>
  24#include <msr.h>
  25#include <macros.h>
  26#include <cpu.h>
  27#include <stage1.h>
  28#include <globalvars.h>
  29#include <string.h>
  30#include <mtrr.h>
  31#include <via_c7.h>
  32
  33/**
  34 * Disable Cache As RAM (CAR) after memory is setup.
  35 */
  36void disable_car(void)
  37{
  38        printk(BIOS_DEBUG, "disable_car entry\n");
  39        /* Determine new global variable location. Stack organization from top
  40         * Top 4 bytes are reserved
  41         * Pointer to global variables
  42         * Global variables
  43         *
  44         * Align the result to 8 bytes
  45         */
  46        struct global_vars *const newlocation = (struct global_vars *)((RAM_STACK_BASE - sizeof(struct global_vars *) - sizeof(struct global_vars)) & ~0x7);
  47        /* Copy global variables to new location. */
  48        memcpy(newlocation, global_vars(), sizeof(struct global_vars));
  49        printk(BIOS_DEBUG, "disable_car global_vars copy done\n");
  50        /* Set the new global variable pointer. */
  51        *(struct global_vars **)(RAM_STACK_BASE - sizeof(struct global_vars *)) = newlocation;
  52
  53        printk(BIOS_DEBUG, "disable_car global_vars pointer adjusted\n");
  54        printk(BIOS_DEBUG, "entering asm code now\n");
  55
  56        __asm__ __volatile__(
  57        "       movl    %[newesp], %%esp        \n"
  58
  59        /* We don't need cache as ram for now on */
  60        /* disable cache */
  61        "       movl    %%cr0, %%eax            \n"
  62        "       orl    $(0x1<<30),%%eax         \n"
  63        "       movl    %%eax, %%cr0            \n"
  64
  65        /* disable fixed mtrr from now on, it will be enabled by coreboot_ram again*/
  66        /* clear sth */
  67        "       xorl    %%eax, %%eax            \n"
  68        "       xorl    %%edx, %%edx            \n"
  69        "       movl    $0x201, %%ecx           \n"
  70        "       wrmsr                           \n"
  71        "       movl    $0x200, %%ecx           \n"
  72        "       wrmsr                           \n"
  73
  74        /* Set the default memory type and disable fixed and enable variable MTRRs */
  75        "       movl    %[_MTRRdefType_MSR], %%ecx      \n"
  76        "       xorl    %%edx, %%edx            \n"
  77        /* Enable Variable and Disable Fixed MTRRs */
  78        "       movl    $0x00000800, %%eax      \n"
  79        "       wrmsr                           \n"
  80
  81        /* enable cache */
  82        "       movl    %%cr0, %%eax            \n"
  83        "       andl    $0x9fffffff,%%eax       \n"
  84        "       movl    %%eax, %%cr0            \n"
  85
  86        "       wbinvd                          \n"
  87
  88        "       call stage1_phase3              \n"
  89        :: [newesp] "i" (newlocation),
  90         [_MTRRdefType_MSR] "i" (MTRRdefType_MSR)
  91        : "memory");
  92}
  93
  94void stop_ap(void)
  95{
  96}
  97
  98
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.