backdoor.hh revision 5480
12SN/A/*
21762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665SN/A *
282665SN/A * Authors: Nathan Binkert
292SN/A */
302SN/A
311722SN/A/** @file
325480Snate@binkert.org * System Console Backdoor Interface
332SN/A */
342SN/A
355480Snate@binkert.org#ifndef __DEV_ALPHA_BACKDOOR_HH__
365480Snate@binkert.org#define __DEV_ALPHA_BACKDOOR_HH__
372SN/A
38540SN/A#include "base/range.hh"
393534SN/A#include "dev/alpha/access.h"
40545SN/A#include "dev/io_device.hh"
415480Snate@binkert.org#include "params/AlphaBackdoor.hh"
4256SN/A#include "sim/host.hh"
43843SN/A#include "sim/sim_object.hh"
442SN/A
452SN/Aclass BaseCPU;
465478SN/Aclass Terminal;
472158SN/Aclass AlphaSystem;
482SN/Aclass SimpleDisk;
492SN/A
501722SN/A/**
512SN/A * Memory mapped interface to the system console. This device
522SN/A * represents a shared data region between the OS Kernel and the
535480Snate@binkert.org * System Console Backdoor.
542SN/A *
552SN/A * The system console is a small standalone program that is initially
562SN/A * run when the system boots.  It contains the necessary code to
572SN/A * access the boot disk, to read/write from the console, and to pass
582SN/A * boot parameters to the kernel.
592SN/A *
602SN/A * This version of the system console is very different from the one
612SN/A * that would be found in a real system.  Many of the functions use
622SN/A * some sort of backdoor to get their job done.  For example, reading
632SN/A * from the boot device on a real system would require a minimal
642SN/A * device driver to access the disk controller, but since we have a
652SN/A * simulator here, we are able to bypass the disk controller and
662SN/A * access the disk image directly.  There are also some things like
672SN/A * reading the kernel off the disk image into memory that are normally
682SN/A * taken care of by the console that are now taken care of by the
692SN/A * simulator.
702SN/A *
712SN/A * These shortcuts are acceptable since the system console is
722SN/A * primarily used doing boot before the kernel has loaded its device
732SN/A * drivers.
742SN/A */
755480Snate@binkert.orgclass AlphaBackdoor : public BasicPioDevice
762SN/A{
772SN/A  protected:
781804SN/A    struct Access : public AlphaAccess
791804SN/A    {
801804SN/A        void serialize(std::ostream &os);
811804SN/A        void unserialize(Checkpoint *cp, const std::string &section);
821804SN/A    };
831804SN/A
84934SN/A    union {
851804SN/A        Access *alphaAccess;
861310SN/A        uint8_t *consoleData;
87934SN/A    };
882SN/A
892SN/A    /** the disk must be accessed from the console */
902SN/A    SimpleDisk *disk;
912SN/A
922SN/A    /** the system console (the terminal) is accessable from the console */
935478SN/A    Terminal *terminal;
942SN/A
951634SN/A    /** a pointer to the system we are running in */
962158SN/A    AlphaSystem *system;
971634SN/A
981634SN/A    /** a pointer to the CPU boot cpu */
991634SN/A    BaseCPU *cpu;
1001634SN/A
1012512SN/A  public:
1025480Snate@binkert.org    typedef AlphaBackdoorParams Params;
1035480Snate@binkert.org    AlphaBackdoor(const Params *p);
1044762SN/A
1054762SN/A    const Params *
1064762SN/A    params() const
1072512SN/A    {
1084762SN/A        return dynamic_cast<const Params *>(_params);
1094762SN/A    }
1102SN/A
1111806SN/A    virtual void startup();
1121634SN/A
1132SN/A    /**
1142SN/A     * memory mapped reads and writes
1152SN/A     */
1163349SN/A    virtual Tick read(PacketPtr pkt);
1173349SN/A    virtual Tick write(PacketPtr pkt);
1182SN/A
1192SN/A    /**
1202SN/A     * standard serialization routines for checkpointing
1212SN/A     */
122217SN/A    virtual void serialize(std::ostream &os);
123237SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
1242SN/A};
1252SN/A
1265480Snate@binkert.org#endif // __DEV_ALPHA_BACKDOOR_HH__
127