e820.cc revision 7087:fb8d5786ff30
16184SN/A/* 26184SN/A * Copyright (c) 2008 The Hewlett-Packard Development Company 36184SN/A * All rights reserved. 46184SN/A * 56184SN/A * The license below extends only to copyright in the software and shall 66184SN/A * not be construed as granting a license to any other intellectual 76184SN/A * property including but not limited to intellectual property relating 86184SN/A * to a hardware implementation of the functionality of the software 96184SN/A * licensed hereunder. You may use the software subject to the license 106184SN/A * terms below provided that you ensure that this notice is replicated 116184SN/A * unmodified and in its entirety in all distributions of the software, 126184SN/A * modified or unmodified, in source code or in binary form. 136184SN/A * 146184SN/A * Redistribution and use in source and binary forms, with or without 156184SN/A * modification, are permitted provided that the following conditions are 166184SN/A * met: redistributions of source code must retain the above copyright 176184SN/A * notice, this list of conditions and the following disclaimer; 186184SN/A * redistributions in binary form must reproduce the above copyright 196184SN/A * notice, this list of conditions and the following disclaimer in the 206184SN/A * documentation and/or other materials provided with the distribution; 216184SN/A * neither the name of the copyright holders nor the names of its 226184SN/A * contributors may be used to endorse or promote products derived from 236184SN/A * this software without specific prior written permission. 246184SN/A * 256184SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 266184SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 276184SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 286184SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 296184SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 306184SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 316226Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 326184SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 336184SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 346184SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 356184SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 366184SN/A * 376184SN/A * Authors: Gabe Black 387720Sgblack@eecs.umich.edu */ 396184SN/A 406184SN/A#include "arch/x86/bios/e820.hh" 416184SN/A#include "arch/x86/isa_traits.hh" 426184SN/A#include "mem/port.hh" 436184SN/A#include "sim/byteswap.hh" 446184SN/A 456184SN/Ausing namespace std; 466227Snate@binkert.orgusing namespace X86ISA; 477720Sgblack@eecs.umich.edu 486184SN/Atemplate<class T> 496184SN/Avoid writeVal(T val, Port * port, Addr &addr) 506184SN/A{ 517720Sgblack@eecs.umich.edu T guestVal = htog(val); 526184SN/A port->writeBlob(addr, (uint8_t *)&guestVal, sizeof(T)); 536184SN/A addr += sizeof(T); 546184SN/A} 556184SN/A 566184SN/Avoid X86ISA::E820Table::writeTo(Port * port, Addr countAddr, Addr addr) 576184SN/A{ 586184SN/A uint8_t e820Nr = entries.size(); 596184SN/A 606184SN/A // Make sure the number of entries isn't bigger than what the kernel 616184SN/A // would be capable of handling. 626184SN/A assert(e820Nr <= 128); 636184SN/A 646184SN/A uint8_t guestE820Nr = htog(e820Nr); 656184SN/A 666184SN/A port->writeBlob(countAddr, (uint8_t *)&guestE820Nr, sizeof(guestE820Nr)); 676184SN/A 686184SN/A for (int i = 0; i < e820Nr; i++) { 696184SN/A writeVal(entries[i]->addr, port, addr); 706184SN/A writeVal(entries[i]->size, port, addr); 716184SN/A writeVal(entries[i]->type, port, addr); 726184SN/A } 736184SN/A} 747720Sgblack@eecs.umich.edu 756184SN/AE820Table * 766184SN/AX86E820TableParams::create() 776184SN/A{ 787720Sgblack@eecs.umich.edu return new E820Table(this); 796184SN/A} 80 81E820Entry * 82X86E820EntryParams::create() 83{ 84 return new E820Entry(this); 85} 86