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