4 * User Console Interface
12 #include "circlebuf.hh"
13 #include "intr_control.hh"
14 #include "pollevent.hh"
16 #include "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;
53 ///////////////////////
56 void attach(int fd, ConsoleListener *l = NULL) { attach(fd, fd, l); }
57 void attach(int in, int out, ConsoleListener *l = NULL);
63 void read(uint8_t &c) { read(&c, 1); }
64 size_t read(uint8_t *buf, size_t len);
65 void write(uint8_t c) { write(&c, 1); }
66 size_t write(const uint8_t *buf, size_t len);
71 // interrupt status/enable
82 // Input a character from the console. Returns the character (if
83 // any) or -1 if there is no character pending on this console. If
84 // no further characters are pending, the (input) interrupt is
88 // Output a character to the console. This never fails, as this
89 // device doesn't model finite buffering capacity.
94 TransmitInterrupt = 1,
98 // Read the current interrupt status of this console.
101 // Set the interrupt enable bits.
103 void raiseInt(int i);
105 void initInt(IntrControl *i);
106 void setInt(int bits);
108 virtual void serialize();
109 virtual void unserialize(IniFile &db, const std::string &category,
113 class ConsoleListener : public SimObject
116 class Event : public PollEvent
119 ConsoleListener *listener;
122 Event(ConsoleListener *l, int fd, int e)
123 : PollEvent(fd, e), listener(l) {}
124 void process(int revent);
130 typedef std::list<SimConsole *> list_t;
131 typedef list_t::iterator iter_t;
135 ListenSocket listener;
138 ConsoleListener(const std::string &name);
141 void add(SimConsole *cons);
144 void listen(int port);
147 #endif // __CONSOLE_HH__