e820.cc revision 8852:c744483edfcf
12SN/A/* 21762SN/A * Copyright (c) 2008 The Hewlett-Packard Development Company 32SN/A * All rights reserved. 42SN/A * 52SN/A * The license below extends only to copyright in the software and shall 62SN/A * not be construed as granting a license to any other intellectual 72SN/A * property including but not limited to intellectual property relating 82SN/A * to a hardware implementation of the functionality of the software 92SN/A * licensed hereunder. You may use the software subject to the license 102SN/A * terms below provided that you ensure that this notice is replicated 112SN/A * unmodified and in its entirety in all distributions of the software, 122SN/A * modified or unmodified, in source code or in binary form. 132SN/A * 142SN/A * Redistribution and use in source and binary forms, with or without 152SN/A * modification, are permitted provided that the following conditions are 162SN/A * met: redistributions of source code must retain the above copyright 172SN/A * notice, this list of conditions and the following disclaimer; 182SN/A * redistributions in binary form must reproduce the above copyright 192SN/A * notice, this list of conditions and the following disclaimer in the 202SN/A * documentation and/or other materials provided with the distribution; 212SN/A * neither the name of the copyright holders nor the names of its 222SN/A * contributors may be used to endorse or promote products derived from 232SN/A * this software without specific prior written permission. 242SN/A * 252SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 262SN/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 292665Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 302665Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 312SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 322SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 332SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 342SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 352SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 362SN/A * 372SN/A * Authors: Gabe Black 382SN/A */ 391717SN/A 4056SN/A#include "arch/x86/bios/e820.hh" 412SN/A#include "arch/x86/isa_traits.hh" 4256SN/A#include "mem/port_proxy.hh" 4356SN/A#include "sim/byteswap.hh" 441696SN/A 452SN/Ausing namespace std; 462SN/Ausing namespace X86ISA; 472SN/A 482SN/Atemplate<class T> 492SN/Avoid writeVal(T val, PortProxy& proxy, Addr &addr) 502SN/A{ 512SN/A T guestVal = htog(val); 522SN/A proxy.writeBlob(addr, (uint8_t *)&guestVal, sizeof(T)); 532SN/A addr += sizeof(T); 54221SN/A} 552SN/A 562SN/Avoid X86ISA::E820Table::writeTo(PortProxy& proxy, Addr countAddr, Addr addr) 572SN/A{ 582SN/A uint8_t e820Nr = entries.size(); 592SN/A 602SN/A // Make sure the number of entries isn't bigger than what the kernel 612SN/A // would be capable of handling. 622SN/A assert(e820Nr <= 128); 632SN/A 642SN/A uint8_t guestE820Nr = htog(e820Nr); 652SN/A 662SN/A proxy.writeBlob(countAddr, (uint8_t *)&guestE820Nr, sizeof(guestE820Nr)); 672SN/A 682SN/A for (int i = 0; i < e820Nr; i++) { 692SN/A writeVal(entries[i]->addr, proxy, addr); 702SN/A writeVal(entries[i]->size, proxy, addr); 712SN/A writeVal(entries[i]->type, proxy, addr); 722SN/A } 732SN/A} 742SN/A 752SN/AE820Table * 762SN/AX86E820TableParams::create() 772SN/A{ 782SN/A return new E820Table(this); 792SN/A} 802SN/A 812SN/AE820Entry * 822SN/AX86E820EntryParams::create() 832SN/A{ 842SN/A return new E820Entry(this); 852SN/A} 862SN/A