backdoor.hh revision 2512
12124SN/A/*
22124SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan
32124SN/A * All rights reserved.
42124SN/A *
52022SN/A * Redistribution and use in source and binary forms, with or without
62124SN/A * modification, are permitted provided that the following conditions are
72124SN/A * met: redistributions of source code must retain the above copyright
82124SN/A * notice, this list of conditions and the following disclaimer;
92124SN/A * redistributions in binary form must reproduce the above copyright
102124SN/A * notice, this list of conditions and the following disclaimer in the
112124SN/A * documentation and/or other materials provided with the distribution;
122124SN/A * neither the name of the copyright holders nor the names of its
132124SN/A * contributors may be used to endorse or promote products derived from
142124SN/A * this software without specific prior written permission.
152124SN/A *
162022SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172124SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182124SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192124SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202124SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212124SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222124SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232124SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242124SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252124SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262124SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272124SN/A */
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu/** @file
302665Ssaidi@eecs.umich.edu * System Console Interface
312022SN/A */
322649Ssaidi@eecs.umich.edu
332649Ssaidi@eecs.umich.edu#ifndef __ALPHA_CONSOLE_HH__
342649Ssaidi@eecs.umich.edu#define __ALPHA_CONSOLE_HH__
352649Ssaidi@eecs.umich.edu
362649Ssaidi@eecs.umich.edu#include "base/range.hh"
372022SN/A#include "dev/alpha_access.h"
382124SN/A#include "dev/io_device.hh"
392124SN/A#include "sim/host.hh"
402124SN/A#include "sim/sim_object.hh"
412124SN/A
422124SN/Aclass BaseCPU;
432124SN/Aclass SimConsole;
442124SN/Aclass AlphaSystem;
452124SN/Aclass SimpleDisk;
462124SN/Aclass MemoryController;
472124SN/A
482124SN/A/**
492124SN/A * Memory mapped interface to the system console. This device
502124SN/A * represents a shared data region between the OS Kernel and the
512239SN/A * System Console.
522124SN/A *
532124SN/A * The system console is a small standalone program that is initially
542124SN/A * run when the system boots.  It contains the necessary code to
552124SN/A * access the boot disk, to read/write from the console, and to pass
562124SN/A * boot parameters to the kernel.
572124SN/A *
582124SN/A * This version of the system console is very different from the one
592124SN/A * that would be found in a real system.  Many of the functions use
602124SN/A * some sort of backdoor to get their job done.  For example, reading
612124SN/A * from the boot device on a real system would require a minimal
622022SN/A * device driver to access the disk controller, but since we have a
632239SN/A * simulator here, we are able to bypass the disk controller and
642239SN/A * access the disk image directly.  There are also some things like
652239SN/A * reading the kernel off the disk image into memory that are normally
662239SN/A * taken care of by the console that are now taken care of by the
672239SN/A * simulator.
682239SN/A *
692124SN/A * These shortcuts are acceptable since the system console is
702022SN/A * primarily used doing boot before the kernel has loaded its device
712124SN/A * drivers.
722124SN/A */
732022SN/Aclass AlphaConsole : public BasePioDevice
742124SN/A{
752124SN/A  protected:
762124SN/A    struct Access : public AlphaAccess
772124SN/A    {
782124SN/A        void serialize(std::ostream &os);
792124SN/A        void unserialize(Checkpoint *cp, const std::string &section);
802022SN/A    };
812022SN/A
822124SN/A    union {
832022SN/A        Access *alphaAccess;
842124SN/A        uint8_t *consoleData;
852124SN/A    };
862124SN/A
872124SN/A    /** the disk must be accessed from the console */
882239SN/A    SimpleDisk *disk;
892124SN/A
902124SN/A    /** the system console (the terminal) is accessable from the console */
912022SN/A    SimConsole *console;
922022SN/A
932124SN/A    /** a pointer to the system we are running in */
942124SN/A    AlphaSystem *system;
952124SN/A
962124SN/A    /** a pointer to the CPU boot cpu */
972124SN/A    BaseCPU *cpu;
982124SN/A
992124SN/A  public:
1002124SN/A    struct Params : public BasePioDevice::Params
1012124SN/A    {
1022124SN/A        SimConsole *cons;
1032124SN/A        SimpleDisk *disk;
1042124SN/A        AlphaSystem *sys;
1052124SN/A        BaseCpu *cpu;
1062124SN/A    };
1072124SN/A  protected:
1082124SN/A    const Params *params() const {return (const Params *)_params; }
1092124SN/A
1102124SN/A  public:
1112124SN/A
1122124SN/A    /** Standard Constructor */
1132124SN/A    AlphaConsole(Params *p);
1142124SN/A
1152124SN/A    virtual void startup();
1162124SN/A
1172124SN/A    /**
1182124SN/A     * memory mapped reads and writes
1192124SN/A     */
1202124SN/A    virtual Tick read(Packet &pkt);
1212124SN/A    virtual Tick write(Packet &pkt);
1222124SN/A
1232124SN/A    /**
1242124SN/A     * standard serialization routines for checkpointing
1252124SN/A     */
1262124SN/A    virtual void serialize(std::ostream &os);
1272124SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
1282124SN/A
1292124SN/A  public:
1302124SN/A    Tick cacheAccess(MemReqPtr &req);
1312124SN/A};
1322124SN/A
1332124SN/A#endif // __ALPHA_CONSOLE_HH__
1342124SN/A