backdoor.hh revision 3534
12391SN/A/*
28931Sandreas.hansson@arm.com * Copyright (c) 2001-2005 The Regents of The University of Michigan
38931Sandreas.hansson@arm.com * All rights reserved.
48931Sandreas.hansson@arm.com *
58931Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68931Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78931Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88931Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98931Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108931Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118931Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128931Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138931Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142391SN/A * this software without specific prior written permission.
152391SN/A *
162391SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172391SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182391SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192391SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202391SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212391SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222391SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232391SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242391SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252391SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262391SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272391SN/A *
282391SN/A * Authors: Nathan Binkert
292391SN/A */
302391SN/A
312391SN/A/** @file
322391SN/A * System Console Interface
332391SN/A */
342391SN/A
352391SN/A#ifndef __ALPHA_CONSOLE_HH__
362391SN/A#define __ALPHA_CONSOLE_HH__
372391SN/A
382391SN/A#include "base/range.hh"
392665SN/A#include "dev/alpha/access.h"
402665SN/A#include "dev/io_device.hh"
418931Sandreas.hansson@arm.com#include "sim/host.hh"
422391SN/A#include "sim/sim_object.hh"
432391SN/A
448931Sandreas.hansson@arm.comclass BaseCPU;
458931Sandreas.hansson@arm.comclass SimConsole;
468931Sandreas.hansson@arm.comclass AlphaSystem;
472391SN/Aclass SimpleDisk;
482391SN/A
498931Sandreas.hansson@arm.com/**
508931Sandreas.hansson@arm.com * Memory mapped interface to the system console. This device
512391SN/A * represents a shared data region between the OS Kernel and the
522462SN/A * System Console.
538931Sandreas.hansson@arm.com *
548719SN/A * The system console is a small standalone program that is initially
552462SN/A * run when the system boots.  It contains the necessary code to
569053Sdam.sunwoo@arm.com * access the boot disk, to read/write from the console, and to pass
579053Sdam.sunwoo@arm.com * boot parameters to the kernel.
589053Sdam.sunwoo@arm.com *
598931Sandreas.hansson@arm.com * This version of the system console is very different from the one
609293Sandreas.hansson@arm.com * that would be found in a real system.  Many of the functions use
619293Sandreas.hansson@arm.com * some sort of backdoor to get their job done.  For example, reading
629293Sandreas.hansson@arm.com * from the boot device on a real system would require a minimal
639293Sandreas.hansson@arm.com * device driver to access the disk controller, but since we have a
649293Sandreas.hansson@arm.com * simulator here, we are able to bypass the disk controller and
659293Sandreas.hansson@arm.com * access the disk image directly.  There are also some things like
669293Sandreas.hansson@arm.com * reading the kernel off the disk image into memory that are normally
679293Sandreas.hansson@arm.com * taken care of by the console that are now taken care of by the
689293Sandreas.hansson@arm.com * simulator.
699293Sandreas.hansson@arm.com *
709293Sandreas.hansson@arm.com * These shortcuts are acceptable since the system console is
719293Sandreas.hansson@arm.com * primarily used doing boot before the kernel has loaded its device
729293Sandreas.hansson@arm.com * drivers.
739293Sandreas.hansson@arm.com */
749293Sandreas.hansson@arm.comclass AlphaConsole : public BasicPioDevice
759293Sandreas.hansson@arm.com{
769293Sandreas.hansson@arm.com  protected:
779293Sandreas.hansson@arm.com    struct Access : public AlphaAccess
789293Sandreas.hansson@arm.com    {
799293Sandreas.hansson@arm.com        void serialize(std::ostream &os);
809293Sandreas.hansson@arm.com        void unserialize(Checkpoint *cp, const std::string &section);
819293Sandreas.hansson@arm.com    };
829293Sandreas.hansson@arm.com
839293Sandreas.hansson@arm.com    union {
849293Sandreas.hansson@arm.com        Access *alphaAccess;
859293Sandreas.hansson@arm.com        uint8_t *consoleData;
869293Sandreas.hansson@arm.com    };
879293Sandreas.hansson@arm.com
889293Sandreas.hansson@arm.com    /** the disk must be accessed from the console */
899293Sandreas.hansson@arm.com    SimpleDisk *disk;
909293Sandreas.hansson@arm.com
919293Sandreas.hansson@arm.com    /** the system console (the terminal) is accessable from the console */
929293Sandreas.hansson@arm.com    SimConsole *console;
939293Sandreas.hansson@arm.com
949293Sandreas.hansson@arm.com    /** a pointer to the system we are running in */
959293Sandreas.hansson@arm.com    AlphaSystem *system;
969293Sandreas.hansson@arm.com
978931Sandreas.hansson@arm.com    /** a pointer to the CPU boot cpu */
988931Sandreas.hansson@arm.com    BaseCPU *cpu;
998931Sandreas.hansson@arm.com
1008931Sandreas.hansson@arm.com  public:
1018931Sandreas.hansson@arm.com    struct Params : public BasicPioDevice::Params
1028931Sandreas.hansson@arm.com    {
1038931Sandreas.hansson@arm.com        SimConsole *cons;
1042391SN/A        SimpleDisk *disk;
1056107SN/A        AlphaSystem *alpha_sys;
1066107SN/A        BaseCPU *cpu;
1078931Sandreas.hansson@arm.com    };
1089235Sandreas.hansson@arm.com  protected:
1092413SN/A    const Params *params() const {return (const Params *)_params; }
1108931Sandreas.hansson@arm.com
1118931Sandreas.hansson@arm.com  public:
1122413SN/A
1138931Sandreas.hansson@arm.com    /** Standard Constructor */
1148931Sandreas.hansson@arm.com    AlphaConsole(Params *p);
1152413SN/A
1168931Sandreas.hansson@arm.com    virtual void startup();
1178931Sandreas.hansson@arm.com
1183170SN/A    /**
1193170SN/A     * memory mapped reads and writes
1203170SN/A     */
1213170SN/A    virtual Tick read(PacketPtr pkt);
1223170SN/A    virtual Tick write(PacketPtr pkt);
1233170SN/A
1243170SN/A    /**
1254626SN/A     * standard serialization routines for checkpointing
1263170SN/A     */
1273170SN/A    virtual void serialize(std::ostream &os);
1283170SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
1293170SN/A};
1304626SN/A
1313170SN/A#endif // __ALPHA_CONSOLE_HH__
1323170SN/A