#include <errno.h>
#include <assert.h>
#include <stddef.h>
+#include <poll.h>
enum
{
send_packet(&p);
}
+void htif_t::poll()
+{
+ struct pollfd pfd;
+ pfd.fd = fromhost_fd;
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+
+ if (::poll(&pfd, 1, 0) > 0)
+ wait_for_packet();
+}
+
int htif_t::wait_for_packet()
{
while(1)
void wait_for_tohost_write();
void wait_for_fromhost_write();
+ // check to see if there's a pending packet and process it if so
+ void poll();
+
private:
sim_t* sim;
int tohost_fd;
// initalize simulator and run to completion
sim_t s(nprocs, &htif);
s.run(debug);
+ printf("graceful\n");
}
for(running = true; running; )
{
- if(!debug)
- step_all(100,100,false);
- else
- interactive();
+ for (int i = 0; i < 1000; i++)
+ {
+ if(!debug)
+ step_all(100,100,false);
+ else
+ interactive();
+ }
+
+ htif->poll();
}
}