system.cc revision 7532
12315SN/A/* 22332SN/A * Copyright (c) 2007-2008 The Hewlett-Packard Development Company 32315SN/A * All rights reserved. 42315SN/A * 52315SN/A * The license below extends only to copyright in the software and shall 62315SN/A * not be construed as granting a license to any other intellectual 72315SN/A * property including but not limited to intellectual property relating 82315SN/A * to a hardware implementation of the functionality of the software 92315SN/A * licensed hereunder. You may use the software subject to the license 102315SN/A * terms below provided that you ensure that this notice is replicated 112315SN/A * unmodified and in its entirety in all distributions of the software, 122315SN/A * modified or unmodified, in source code or in binary form. 132315SN/A * 142315SN/A * Redistribution and use in source and binary forms, with or without 152315SN/A * modification, are permitted provided that the following conditions are 162315SN/A * met: redistributions of source code must retain the above copyright 172315SN/A * notice, this list of conditions and the following disclaimer; 182315SN/A * redistributions in binary form must reproduce the above copyright 192315SN/A * notice, this list of conditions and the following disclaimer in the 202315SN/A * documentation and/or other materials provided with the distribution; 212315SN/A * neither the name of the copyright holders nor the names of its 222315SN/A * contributors may be used to endorse or promote products derived from 232315SN/A * this software without specific prior written permission. 242315SN/A * 252315SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 262315SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 272315SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 282315SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 292315SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 302315SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 312315SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 322315SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 332315SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 342315SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 352315SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 362669Sktlim@umich.edu * 372315SN/A * Authors: Gabe Black 382315SN/A */ 392315SN/A 402315SN/A#include "arch/x86/intregs.hh" 412315SN/A#include "arch/x86/linux/system.hh" 422315SN/A#include "arch/vtophys.hh" 432315SN/A#include "base/trace.hh" 442315SN/A#include "cpu/thread_context.hh" 452315SN/A#include "mem/physical.hh" 462315SN/A#include "params/LinuxX86System.hh" 472315SN/A 482315SN/A 492315SN/Ausing namespace LittleEndianGuest; 502315SN/Ausing namespace X86ISA; 512315SN/A 522315SN/ALinuxX86System::LinuxX86System(Params *p) 532315SN/A : X86System(p), commandLine(p->boot_osflags), e820Table(p->e820_table) 542315SN/A{ 552315SN/A} 562315SN/A 572315SN/ALinuxX86System::~LinuxX86System() 582315SN/A{ 592315SN/A} 602315SN/A 612315SN/Avoid 622315SN/ALinuxX86System::initState() 632680Sktlim@umich.edu{ 642315SN/A X86System::initState(); 652315SN/A 662669Sktlim@umich.edu // The location of the real mode data structure. 672332SN/A const Addr realModeData = 0x90200; 682315SN/A 692350SN/A // A port to write to memory. 702350SN/A FunctionalPort * physPort = threadContexts[0]->getPhysPort(); 712350SN/A 722350SN/A /* 732350SN/A * Deal with the command line stuff. 742350SN/A */ 752350SN/A 762350SN/A // A buffer to store the command line. 772350SN/A const Addr commandLineBuff = 0x90000; 782350SN/A // A pointer to the commandLineBuff stored in the real mode data. 792680Sktlim@umich.edu const Addr commandLinePointer = realModeData + 0x228; 802350SN/A 812680Sktlim@umich.edu if (commandLine.length() + 1 > realModeData - commandLineBuff) 822350SN/A panic("Command line \"%s\" is longer than %d characters.\n", 832680Sktlim@umich.edu commandLine, realModeData - commandLineBuff - 1); 842350SN/A physPort->writeBlob(commandLineBuff, 852315SN/A (uint8_t *)commandLine.c_str(), commandLine.length() + 1); 862315SN/A 872315SN/A // Generate a pointer of the right size and endianness to put into 882315SN/A // commandLinePointer. 892669Sktlim@umich.edu uint32_t guestCommandLineBuff = 902669Sktlim@umich.edu X86ISA::htog((uint32_t)commandLineBuff); 912315SN/A physPort->writeBlob(commandLinePointer, 922315SN/A (uint8_t *)&guestCommandLineBuff, sizeof(guestCommandLineBuff)); 932315SN/A 942315SN/A /* 952315SN/A * Screen Info. 962315SN/A */ 972315SN/A 982315SN/A // We'll skip on this for now because it's only needed for framebuffers, 992315SN/A // something we don't support at the moment. 1002315SN/A 1012315SN/A /* 1022315SN/A * EDID info 1032315SN/A */ 1042315SN/A 1052315SN/A // Skipping for now. 1062315SN/A 1072315SN/A /* 1082315SN/A * Saved video mode 1092315SN/A */ 1102315SN/A 1112679Sktlim@umich.edu // Skipping for now. 1122679Sktlim@umich.edu 1132669Sktlim@umich.edu /* 1142315SN/A * Loader type. 1152669Sktlim@umich.edu */ 1162315SN/A 1172315SN/A // Skipping for now. 1182315SN/A 1192315SN/A /* 1202315SN/A * E820 memory map 1212315SN/A */ 1222679Sktlim@umich.edu 1232679Sktlim@umich.edu // A pointer to the number of E820 entries there are. 1242679Sktlim@umich.edu const Addr e820MapNrPointer = realModeData + 0x1e8; 1252679Sktlim@umich.edu 1262679Sktlim@umich.edu // A pointer to the buffer for E820 entries. 1272679Sktlim@umich.edu const Addr e820MapPointer = realModeData + 0x2d0; 1282679Sktlim@umich.edu 1292679Sktlim@umich.edu e820Table->writeTo(physPort, e820MapNrPointer, e820MapPointer); 1302679Sktlim@umich.edu 1312315SN/A /* 1322315SN/A * Pass the location of the real mode data structure to the kernel 1332315SN/A * using register %esi. We'll use %rsi which should be equivalent. 1342315SN/A */ 1352680Sktlim@umich.edu threadContexts[0]->setIntReg(INTREG_RSI, realModeData); 1362315SN/A} 1372315SN/A 1382315SN/ALinuxX86System * 1392315SN/ALinuxX86SystemParams::create() 1402315SN/A{ 1412315SN/A return new LinuxX86System(this); 1422315SN/A} 1432315SN/A