backdoor.hh revision 2512
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/** @file 30 * System Console Interface 31 */ 32 33#ifndef __ALPHA_CONSOLE_HH__ 34#define __ALPHA_CONSOLE_HH__ 35 36#include "base/range.hh" 37#include "dev/alpha_access.h" 38#include "dev/io_device.hh" 39#include "sim/host.hh" 40#include "sim/sim_object.hh" 41 42class BaseCPU; 43class SimConsole; 44class AlphaSystem; 45class SimpleDisk; 46class MemoryController; 47 48/** 49 * Memory mapped interface to the system console. This device 50 * represents a shared data region between the OS Kernel and the 51 * System Console. 52 * 53 * The system console is a small standalone program that is initially 54 * run when the system boots. It contains the necessary code to 55 * access the boot disk, to read/write from the console, and to pass 56 * boot parameters to the kernel. 57 * 58 * This version of the system console is very different from the one 59 * that would be found in a real system. Many of the functions use 60 * some sort of backdoor to get their job done. For example, reading 61 * from the boot device on a real system would require a minimal 62 * device driver to access the disk controller, but since we have a 63 * simulator here, we are able to bypass the disk controller and 64 * access the disk image directly. There are also some things like 65 * reading the kernel off the disk image into memory that are normally 66 * taken care of by the console that are now taken care of by the 67 * simulator. 68 * 69 * These shortcuts are acceptable since the system console is 70 * primarily used doing boot before the kernel has loaded its device 71 * drivers. 72 */ 73class AlphaConsole : public BasePioDevice 74{ 75 protected: 76 struct Access : public AlphaAccess 77 { 78 void serialize(std::ostream &os); 79 void unserialize(Checkpoint *cp, const std::string §ion); 80 }; 81 82 union { 83 Access *alphaAccess; 84 uint8_t *consoleData; 85 }; 86 87 /** the disk must be accessed from the console */ 88 SimpleDisk *disk; 89 90 /** the system console (the terminal) is accessable from the console */ 91 SimConsole *console; 92 93 /** a pointer to the system we are running in */ 94 AlphaSystem *system; 95 96 /** a pointer to the CPU boot cpu */ 97 BaseCPU *cpu; 98 99 public: 100 struct Params : public BasePioDevice::Params 101 { 102 SimConsole *cons; 103 SimpleDisk *disk; 104 AlphaSystem *sys; 105 BaseCpu *cpu; 106 }; 107 protected: 108 const Params *params() const {return (const Params *)_params; } 109 110 public: 111 112 /** Standard Constructor */ 113 AlphaConsole(Params *p); 114 115 virtual void startup(); 116 117 /** 118 * memory mapped reads and writes 119 */ 120 virtual Tick read(Packet &pkt); 121 virtual Tick write(Packet &pkt); 122 123 /** 124 * standard serialization routines for checkpointing 125 */ 126 virtual void serialize(std::ostream &os); 127 virtual void unserialize(Checkpoint *cp, const std::string §ion); 128 129 public: 130 Tick cacheAccess(MemReqPtr &req); 131}; 132 133#endif // __ALPHA_CONSOLE_HH__ 134