4 * User Console Interface
12 #include "base/circlebuf.hh"
13 #include "cpu/intr_control.hh"
14 #include "base/pollevent.hh"
15 #include "base/socket.hh"
16 #include "sim/sim_object.hh"
18 class ConsoleListener;
19 class SimConsole : public SimObject
22 class Event : public PollEvent
28 Event(SimConsole *c, int fd, int e);
29 void process(int revent);
41 ConsoleListener *listener;
44 SimConsole(const std::string &name, const std::string &file, int num);
50 std::ostream *outfile;
56 ///////////////////////
59 void attach(int fd, ConsoleListener *l = NULL) { attach(fd, fd, l); }
60 void attach(int in, int out, ConsoleListener *l = NULL);
66 void read(uint8_t &c) { read(&c, 1); }
67 size_t read(uint8_t *buf, size_t len);
68 void write(uint8_t c) { write(&c, 1); }
69 size_t write(const uint8_t *buf, size_t len);
74 // interrupt status/enable
80 // Platform so we can post interrupts
87 // Get a character from the console.
88 bool in(uint8_t &value);
90 // get a character from the console in the console specific format
91 // corresponds to GETC:
93 // 000: success: character received
94 // 001: success: character received, more pending
95 // 100: failure: no character ready
96 // 110: failure: character received with error
97 // 111: failure: character received with error, more pending
99 // character read from console
101 // Interrupts are cleared when the buffer is empty.
102 uint64_t console_in();
104 // Send a character to the console
105 void out(char c, bool raise_int = true);
108 TransmitInterrupt = 1,
112 // Read the current interrupt status of this console.
113 int intStatus() { return _status; }
115 // Set the interrupt enable bits.
117 void raiseInt(int i);
119 void initInt(IntrControl *i);
120 void setInt(int bits);
122 void setPlatform(Platform *p);
124 virtual void serialize(std::ostream &os);
125 virtual void unserialize(Checkpoint *cp, const std::string §ion);
128 class ConsoleListener : public SimObject
131 class Event : public PollEvent
134 ConsoleListener *listener;
137 Event(ConsoleListener *l, int fd, int e)
138 : PollEvent(fd, e), listener(l) {}
139 void process(int revent);
145 typedef std::list<SimConsole *> list_t;
146 typedef list_t::iterator iter_t;
150 ListenSocket listener;
153 ConsoleListener(const std::string &name);
156 void add(SimConsole *cons);
159 void listen(int port);
162 #endif // __CONSOLE_HH__