system.cc revision 7087:fb8d5786ff30
1695SN/A/* 21762SN/A * Copyright (c) 2007-2008 The Hewlett-Packard Development Company 3695SN/A * All rights reserved. 4695SN/A * 5695SN/A * The license below extends only to copyright in the software and shall 6695SN/A * not be construed as granting a license to any other intellectual 7695SN/A * property including but not limited to intellectual property relating 8695SN/A * to a hardware implementation of the functionality of the software 9695SN/A * licensed hereunder. You may use the software subject to the license 10695SN/A * terms below provided that you ensure that this notice is replicated 11695SN/A * unmodified and in its entirety in all distributions of the software, 12695SN/A * modified or unmodified, in source code or in binary form. 13695SN/A * 14695SN/A * Redistribution and use in source and binary forms, with or without 15695SN/A * modification, are permitted provided that the following conditions are 16695SN/A * met: redistributions of source code must retain the above copyright 17695SN/A * notice, this list of conditions and the following disclaimer; 18695SN/A * redistributions in binary form must reproduce the above copyright 19695SN/A * notice, this list of conditions and the following disclaimer in the 20695SN/A * documentation and/or other materials provided with the distribution; 21695SN/A * neither the name of the copyright holders nor the names of its 22695SN/A * contributors may be used to endorse or promote products derived from 23695SN/A * this software without specific prior written permission. 24695SN/A * 25695SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26695SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 272665Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 282665Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29695SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30695SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31695SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32695SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33695SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34695SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35695SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36695SN/A * 37695SN/A * Authors: Gabe Black 38695SN/A */ 39695SN/A 40695SN/A#include "arch/x86/intregs.hh" 41695SN/A#include "arch/x86/linux/system.hh" 421717SN/A#include "arch/vtophys.hh" 43695SN/A#include "base/trace.hh" 44695SN/A#include "cpu/thread_context.hh" 45695SN/A#include "mem/physical.hh" 46695SN/A#include "params/LinuxX86System.hh" 47729SN/A 48695SN/A 49729SN/Ausing namespace LittleEndianGuest; 50695SN/Ausing namespace X86ISA; 51695SN/A 52695SN/ALinuxX86System::LinuxX86System(Params *p) 53695SN/A : X86System(p), commandLine(p->boot_osflags), e820Table(p->e820_table) 544078Sbinkertn@umich.edu{ 55695SN/A} 56695SN/A 57695SN/ALinuxX86System::~LinuxX86System() 58695SN/A{ 59695SN/A} 60695SN/A 61695SN/Avoid 62695SN/ALinuxX86System::startup() 63695SN/A{ 64695SN/A X86System::startup(); 65695SN/A 66695SN/A // The location of the real mode data structure. 67695SN/A const Addr realModeData = 0x90200; 68695SN/A 69695SN/A // A port to write to memory. 70695SN/A FunctionalPort * physPort = threadContexts[0]->getPhysPort(); 711020SN/A 721020SN/A /* 731020SN/A * Deal with the command line stuff. 741020SN/A */ 751020SN/A 761020SN/A // A buffer to store the command line. 77695SN/A const Addr commandLineBuff = 0x90000; 78695SN/A // A pointer to the commandLineBuff stored in the real mode data. 795883Snate@binkert.org const Addr commandLinePointer = realModeData + 0x228; 805883Snate@binkert.org 815883Snate@binkert.org if (commandLine.length() + 1 > realModeData - commandLineBuff) 825883Snate@binkert.org panic("Command line \"%s\" is longer than %d characters.\n", 835883Snate@binkert.org commandLine, realModeData - commandLineBuff - 1); 845883Snate@binkert.org physPort->writeBlob(commandLineBuff, 855883Snate@binkert.org (uint8_t *)commandLine.c_str(), commandLine.length() + 1); 865883Snate@binkert.org 875883Snate@binkert.org // Generate a pointer of the right size and endianness to put into 885883Snate@binkert.org // commandLinePointer. 895883Snate@binkert.org uint32_t guestCommandLineBuff = 905883Snate@binkert.org X86ISA::htog((uint32_t)commandLineBuff); 915883Snate@binkert.org physPort->writeBlob(commandLinePointer, 925883Snate@binkert.org (uint8_t *)&guestCommandLineBuff, sizeof(guestCommandLineBuff)); 935883Snate@binkert.org 94695SN/A /* 95695SN/A * Screen Info. 96707SN/A */ 97695SN/A 98695SN/A // We'll skip on this for now because it's only needed for framebuffers, 99695SN/A // something we don't support at the moment. 100695SN/A 101695SN/A /* 102695SN/A * EDID info 103695SN/A */ 104695SN/A 105695SN/A // Skipping for now. 106695SN/A 107695SN/A /* 108707SN/A * Saved video mode 1091609SN/A */ 110707SN/A 111707SN/A // Skipping for now. 112707SN/A 113707SN/A /* 114695SN/A * Loader type. 1151020SN/A */ 116695SN/A 117695SN/A // Skipping for now. 118695SN/A 119695SN/A /* 120695SN/A * E820 memory map 121695SN/A */ 122695SN/A 123695SN/A // A pointer to the number of E820 entries there are. 124695SN/A const Addr e820MapNrPointer = realModeData + 0x1e8; 125695SN/A 126695SN/A // A pointer to the buffer for E820 entries. 127695SN/A const Addr e820MapPointer = realModeData + 0x2d0; 128707SN/A 129695SN/A e820Table->writeTo(physPort, e820MapNrPointer, e820MapPointer); 130695SN/A 131695SN/A /* 132695SN/A * Pass the location of the real mode data structure to the kernel 133695SN/A * using register %esi. We'll use %rsi which should be equivalent. 134695SN/A */ 135707SN/A threadContexts[0]->setIntReg(INTREG_RSI, realModeData); 136695SN/A} 137695SN/A 138695SN/ALinuxX86System * 139695SN/ALinuxX86SystemParams::create() 140695SN/A{ 141695SN/A return new LinuxX86System(this); 142695SN/A} 143695SN/A