se_translating_port_proxy.cc revision 2403
1/* 2 * Copyright (c) 2001-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <string> 30#include "mem/port.hh" 31#include "mem/translating_port.hh" 32#include "mem/page_table.hh" 33 34TranslatingPort::TranslatingPort(Port *_port, PageTable *p_table) 35 : port(_port), pTable(p_table) 36{ } 37 38TranslatingPort::~TranslatingPort() 39{ } 40 41Fault 42TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size) 43{ 44 Addr paddr; 45 46 //@todo Break up things larger than a page size 47 pTable->page_check(addr, size); 48 49 50 if (!pTable->translate(addr,paddr)) 51 return Machine_Check_Fault; 52 53 port->readBlobFunctional(paddr, p, size); 54 return No_Fault; 55} 56 57Fault 58TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size) 59{ 60 Addr paddr; 61 62 //@todo Break up things larger than a page size 63 pTable->page_check(addr, size); 64 65 if (!pTable->translate(addr,paddr)) 66 return Machine_Check_Fault; 67 68 port->writeBlobFunctional(paddr, p, size); 69 return No_Fault; 70} 71 72Fault 73TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size) 74{ 75 Addr paddr; 76 77 //@todo Break up things larger than a page size 78 //Use the Stever breakup code 79 pTable->page_check(addr, size); 80 81 if (!pTable->translate(addr,paddr)) 82 return Machine_Check_Fault; 83 84 port->memsetBlobFunctional(paddr, val, size); 85 return No_Fault; 86} 87 88Fault 89TranslatingPort::writeStringFunctional(Addr addr, const char *str) 90{ 91 Addr paddr,vaddr; 92 uint8_t c; 93 94 vaddr = addr; 95 96 do { 97 c = *str++; 98 if (!pTable->translate(vaddr++,paddr)) 99 return Machine_Check_Fault; 100 101 port->writeBlobFunctional(paddr, &c, 1); 102 } while (c); 103 104 return No_Fault; 105} 106 107Fault 108TranslatingPort::readStringFunctional(std::string &str, Addr addr) 109{ 110 Addr paddr,vaddr; 111 uint8_t c; 112 113 vaddr = addr; 114 115 do { 116 if (!pTable->translate(vaddr++,paddr)) 117 return Machine_Check_Fault; 118 119 port->readBlobFunctional(paddr, &c, 1); 120 str += c; 121 } while (c); 122 123 return No_Fault; 124} 125 126