system.cc revision 8852:c744483edfcf
18282SAli.Saidi@ARM.com/*
214082Stiago.muck@arm.com * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
38282SAli.Saidi@ARM.com * All rights reserved.
48282SAli.Saidi@ARM.com *
58282SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall
68282SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual
78282SAli.Saidi@ARM.com * property including but not limited to intellectual property relating
88282SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software
98282SAli.Saidi@ARM.com * licensed hereunder.  You may use the software subject to the license
108282SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated
118282SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software,
128282SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form.
138282SAli.Saidi@ARM.com *
148282SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
158282SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are
168282SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright
178282SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer;
188282SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright
198282SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the
208282SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution;
218282SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its
228282SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from
238282SAli.Saidi@ARM.com * this software without specific prior written permission.
248282SAli.Saidi@ARM.com *
258282SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
268282SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
278282SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
288282SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
298282SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
308282SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
318282SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
328282SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
338282SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
348282SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
358282SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
368282SAli.Saidi@ARM.com *
378282SAli.Saidi@ARM.com * Authors: Gabe Black
388282SAli.Saidi@ARM.com */
398282SAli.Saidi@ARM.com
4011793Sbrandon.potter@amd.com#include "arch/x86/linux/system.hh"
4111793Sbrandon.potter@amd.com#include "arch/x86/regs/int.hh"
428282SAli.Saidi@ARM.com#include "arch/x86/isa_traits.hh"
438282SAli.Saidi@ARM.com#include "arch/vtophys.hh"
448282SAli.Saidi@ARM.com#include "base/trace.hh"
458282SAli.Saidi@ARM.com#include "cpu/thread_context.hh"
468282SAli.Saidi@ARM.com#include "mem/port_proxy.hh"
478282SAli.Saidi@ARM.com#include "params/LinuxX86System.hh"
488282SAli.Saidi@ARM.com#include "sim/byteswap.hh"
499808Sstever@gmail.com
508282SAli.Saidi@ARM.comusing namespace LittleEndianGuest;
518282SAli.Saidi@ARM.comusing namespace X86ISA;
528282SAli.Saidi@ARM.com
538282SAli.Saidi@ARM.comLinuxX86System::LinuxX86System(Params *p)
548282SAli.Saidi@ARM.com    : X86System(p), commandLine(p->boot_osflags), e820Table(p->e820_table)
558282SAli.Saidi@ARM.com{
568282SAli.Saidi@ARM.com}
578282SAli.Saidi@ARM.com
588282SAli.Saidi@ARM.comLinuxX86System::~LinuxX86System()
598282SAli.Saidi@ARM.com{
608282SAli.Saidi@ARM.com}
618282SAli.Saidi@ARM.com
6213230Sgabeblack@google.comvoid
638282SAli.Saidi@ARM.comLinuxX86System::initState()
648282SAli.Saidi@ARM.com{
6510186Smatt.evans@arm.com    X86System::initState();
6610186Smatt.evans@arm.com
6710186Smatt.evans@arm.com    // The location of the real mode data structure.
6810186Smatt.evans@arm.com    const Addr realModeData = 0x90200;
6910186Smatt.evans@arm.com
7010186Smatt.evans@arm.com    /*
7110186Smatt.evans@arm.com     * Deal with the command line stuff.
7210186Smatt.evans@arm.com     */
7310186Smatt.evans@arm.com
7410186Smatt.evans@arm.com    // A buffer to store the command line.
758282SAli.Saidi@ARM.com    const Addr commandLineBuff = 0x90000;
7614082Stiago.muck@arm.com    // A pointer to the commandLineBuff stored in the real mode data.
778282SAli.Saidi@ARM.com    const Addr commandLinePointer = realModeData + 0x228;
7813230Sgabeblack@google.com
798282SAli.Saidi@ARM.com    if (commandLine.length() + 1 > realModeData - commandLineBuff)
808282SAli.Saidi@ARM.com        panic("Command line \"%s\" is longer than %d characters.\n",
818282SAli.Saidi@ARM.com                commandLine, realModeData - commandLineBuff - 1);
828282SAli.Saidi@ARM.com    physProxy.writeBlob(commandLineBuff, (uint8_t *)commandLine.c_str(),
838282SAli.Saidi@ARM.com                        commandLine.length() + 1);
848282SAli.Saidi@ARM.com
858282SAli.Saidi@ARM.com    // Generate a pointer of the right size and endianness to put into
868282SAli.Saidi@ARM.com    // commandLinePointer.
878282SAli.Saidi@ARM.com    uint32_t guestCommandLineBuff =
888282SAli.Saidi@ARM.com        X86ISA::htog((uint32_t)commandLineBuff);
898282SAli.Saidi@ARM.com    physProxy.writeBlob(commandLinePointer, (uint8_t *)&guestCommandLineBuff,
908282SAli.Saidi@ARM.com                        sizeof(guestCommandLineBuff));
918282SAli.Saidi@ARM.com
928282SAli.Saidi@ARM.com    /*
938282SAli.Saidi@ARM.com     * Screen Info.
948282SAli.Saidi@ARM.com     */
958282SAli.Saidi@ARM.com
968282SAli.Saidi@ARM.com    // We'll skip on this for now because it's only needed for framebuffers,
978282SAli.Saidi@ARM.com    // something we don't support at the moment.
988282SAli.Saidi@ARM.com
9912049Sgedare@rtems.org    /*
1008282SAli.Saidi@ARM.com     * EDID info
1018282SAli.Saidi@ARM.com     */
1028282SAli.Saidi@ARM.com
1038282SAli.Saidi@ARM.com    // Skipping for now.
1048282SAli.Saidi@ARM.com
1058282SAli.Saidi@ARM.com    /*
1068282SAli.Saidi@ARM.com     * Saved video mode
1078282SAli.Saidi@ARM.com     */
1088282SAli.Saidi@ARM.com
1098282SAli.Saidi@ARM.com    // Skipping for now.
1108282SAli.Saidi@ARM.com
111    /*
112     * Loader type.
113     */
114
115    // Skipping for now.
116
117    /*
118     * E820 memory map
119     */
120
121    // A pointer to the number of E820 entries there are.
122    const Addr e820MapNrPointer = realModeData + 0x1e8;
123
124    // A pointer to the buffer for E820 entries.
125    const Addr e820MapPointer = realModeData + 0x2d0;
126
127    e820Table->writeTo(physProxy, e820MapNrPointer, e820MapPointer);
128
129    /*
130     * Pass the location of the real mode data structure to the kernel
131     * using register %esi. We'll use %rsi which should be equivalent.
132     */
133    threadContexts[0]->setIntReg(INTREG_RSI, realModeData);
134}
135
136LinuxX86System *
137LinuxX86SystemParams::create()
138{
139    return new LinuxX86System(this);
140}
141