mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-23 13:27:29 -04:00
simX openfile working
This commit is contained in:
parent
dcf9cd3c80
commit
3bc2f449e4
16 changed files with 93315 additions and 120639 deletions
12553
emulator/emulator.debug
Normal file
12553
emulator/emulator.debug
Normal file
File diff suppressed because it is too large
Load diff
|
@ -53,32 +53,32 @@ namespace Harp {
|
|||
};
|
||||
|
||||
class Core;
|
||||
class ConsoleMemDevice : public MemDevice {
|
||||
public:
|
||||
ConsoleMemDevice(Size wS, std::ostream &o, Core &core, bool batch = false);
|
||||
~ConsoleMemDevice() {}
|
||||
// class ConsoleMemDevice : public MemDevice {
|
||||
// public:
|
||||
// ConsoleMemDevice(Size wS, std::ostream &o, Core &core, bool batch = false);
|
||||
// ~ConsoleMemDevice() {}
|
||||
|
||||
//virtual Size wordSize() const { return wordSize; }
|
||||
virtual Size size() const { return wordSize; }
|
||||
virtual Word read(Addr) { pthread_mutex_lock(&cBufLock);
|
||||
char c = cBuf.front();
|
||||
cBuf.pop();
|
||||
pthread_mutex_unlock(&cBufLock);
|
||||
return Word(c); }
|
||||
virtual void write(Addr a, Word w) { output << char(w); }
|
||||
// //virtual Size wordSize() const { return wordSize; }
|
||||
// virtual Size size() const { return wordSize; }
|
||||
// virtual Word read(Addr) { pthread_mutex_lock(&cBufLock);
|
||||
// char c = cBuf.front();
|
||||
// cBuf.pop();
|
||||
// pthread_mutex_unlock(&cBufLock);
|
||||
// return Word(c); }
|
||||
// virtual void write(Addr a, Word w) { output << char(w); }
|
||||
|
||||
void poll();
|
||||
// void poll();
|
||||
|
||||
friend void *Harp::consoleInputThread(void *);
|
||||
// friend void *Harp::consoleInputThread(void *);
|
||||
|
||||
private:
|
||||
std::ostream &output;
|
||||
Size wordSize;
|
||||
Core &core;
|
||||
// private:
|
||||
// std::ostream &output;
|
||||
// Size wordSize;
|
||||
// Core &core;
|
||||
|
||||
std::queue<char> cBuf;
|
||||
pthread_mutex_t cBufLock;
|
||||
};
|
||||
// std::queue<char> cBuf;
|
||||
// pthread_mutex_t cBufLock;
|
||||
// };
|
||||
|
||||
class DiskControllerMemDevice : public MemDevice {
|
||||
public:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
// #include <pthread.h>
|
||||
|
||||
#include "include/debug.h"
|
||||
#include "include/types.h"
|
||||
|
@ -205,37 +205,6 @@ void MemoryUnit::tlbRm(Addr va) {
|
|||
if (tlb.find(va/pageSize) != tlb.end()) tlb.erase(tlb.find(va/pageSize));
|
||||
}
|
||||
|
||||
void *Harp::consoleInputThread(void* arg_vp) {
|
||||
ConsoleMemDevice *arg = (ConsoleMemDevice *)arg_vp;
|
||||
char c;
|
||||
while (cin) {
|
||||
c = cin.get();
|
||||
pthread_mutex_lock(&arg->cBufLock);
|
||||
arg->cBuf.push(c);
|
||||
pthread_mutex_unlock(&arg->cBufLock);
|
||||
}
|
||||
cout << "Console input ended. Exiting.\n";
|
||||
exit(4);
|
||||
}
|
||||
|
||||
ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core,
|
||||
bool batch) :
|
||||
wordSize(wS), output(o), core(core), cBuf()
|
||||
{
|
||||
// Create a console input thread if we are running in interactive mode.
|
||||
if (!batch) {
|
||||
pthread_t *thread = new pthread_t;
|
||||
pthread_create(thread, NULL, consoleInputThread, (void*)this);
|
||||
}
|
||||
pthread_mutex_init(&cBufLock, NULL);
|
||||
}
|
||||
|
||||
void ConsoleMemDevice::poll() {
|
||||
pthread_mutex_lock(&cBufLock);
|
||||
if (!cBuf.empty()) core.interrupt(8);
|
||||
pthread_mutex_unlock(&cBufLock);
|
||||
}
|
||||
|
||||
Word DiskControllerMemDevice::read(Addr a) {
|
||||
switch (a/8) {
|
||||
case 0: return curDisk;
|
||||
|
|
|
@ -2,3 +2,4 @@ echo start > results.txt
|
|||
|
||||
# echo ../kernel/vortex_test.hex
|
||||
./harptool -E -a rv32i --core ../runtime/mains/nativevecadd/vx_pocl_main.hex -s -b 1> emulator.debug
|
||||
# ./harptool -E -a rv32i --core ../runtime/mains/vector_test/vx_vector_main.hex -s -b 1> emulator.debug
|
||||
|
|
|
@ -137,10 +137,11 @@ int main (int argc, char **argv) {
|
|||
printf("\n\n******** Fixing fileio START Native Vecadd running ********\n\n");
|
||||
|
||||
FILE *fp;
|
||||
char buff[255];
|
||||
char buff[1024];
|
||||
|
||||
fp = fopen("reading_data.txt", "r");
|
||||
fscanf(fp, "%s", buff);
|
||||
fp = fopen("/home/fares/Desktop/Vortex/simX/reading_data.txt", "r");
|
||||
// fscanf(fp, "%s %s %s %s", buff);
|
||||
fgets(buff, 41, (FILE*)fp);
|
||||
printf("1 : %s\n", buff );
|
||||
|
||||
exit(0);
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -67,7 +67,7 @@ void download(char ** ptr, char * drain)
|
|||
int size;
|
||||
|
||||
// size = *((int *) src);
|
||||
char * size_ptr = (char *) size;
|
||||
char * size_ptr = (char *) &size;
|
||||
size_ptr[0] = src[0];
|
||||
size_ptr[1] = src[1];
|
||||
size_ptr[2] = src[2];
|
||||
|
@ -127,7 +127,7 @@ int _fstat(int file, struct stat * st)
|
|||
// download((char **) &read_buffer, (char *) &value);
|
||||
// st->st_blocks = value;
|
||||
|
||||
vx_print_str("Hello from fstat\n");
|
||||
// vx_print_str("Hello from fstat\n");
|
||||
// // st->st_mode = 33279;
|
||||
|
||||
// vx_printf("st_mode: ", st->st_mode);
|
||||
|
@ -158,10 +158,24 @@ void _lseek()
|
|||
vx_print_str("Hello from _lseek\n");
|
||||
}
|
||||
|
||||
void _read()
|
||||
int _read (int file, char *ptr, int len)
|
||||
{
|
||||
|
||||
vx_print_str("Hello from _read\n");
|
||||
char * write_buffer = (char *) FILE_IO_WRITE;
|
||||
char * read_buffer = (char *) FILE_IO_READ;
|
||||
|
||||
int cmd_id = READ;
|
||||
|
||||
upload((char **) &write_buffer, (char *) &cmd_id, sizeof(int));
|
||||
upload((char **) &write_buffer, (char *) &file , sizeof(int));
|
||||
upload((char **) &write_buffer, (char *) &ptr , sizeof(int));
|
||||
upload((char **) &write_buffer, (char *) &len , sizeof(int));
|
||||
|
||||
trap_to_simulator();
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
int _write (int file, char *buf, int nbytes)
|
||||
|
@ -178,7 +192,7 @@ int _write (int file, char *buf, int nbytes)
|
|||
|
||||
trap_to_simulator();
|
||||
|
||||
vx_print_str("Hello from _write\n");
|
||||
// vx_print_str("Hello from _write\n");
|
||||
|
||||
// int i;
|
||||
|
||||
|
@ -243,24 +257,24 @@ void _exit(int val)
|
|||
|
||||
int _open(const char *name, int flags, int mode)
|
||||
{
|
||||
// vx_print_str("ERROR: _open not yet implemented\n");
|
||||
char * write_buffer = (char *) FILE_IO_WRITE;
|
||||
char * read_buffer = (char *) FILE_IO_READ;
|
||||
|
||||
int cmd_id = OPEN;
|
||||
|
||||
upload((char **) &write_buffer, (char *) &cmd_id, sizeof(int));
|
||||
upload((char **) &write_buffer, (char *) &name , sizeof (char *));
|
||||
upload((char **) &write_buffer, (char *) &flags , sizeof(int));
|
||||
upload((char **) &write_buffer, (char *) & mode , sizeof(int));
|
||||
|
||||
|
||||
// char * write_buffer = (char *) FILE_IO_WRITE;
|
||||
trap_to_simulator();
|
||||
|
||||
// int cmd_id = OPEN;
|
||||
|
||||
// upload((char **) &write_buffer, (char *) &cmd_id, sizeof(int));
|
||||
// upload((char **) &write_buffer, (char *) &name, sizeof (char *));
|
||||
// upload((char **) &write_buffer, (char *) &flags , sizeof(int));
|
||||
// upload((char **) &write_buffer, (char *) & mode , nbytes);
|
||||
int fd;
|
||||
download((char **) &read_buffer, (char *) &fd);
|
||||
|
||||
|
||||
// trap_to_simulator();
|
||||
|
||||
vx_print_str("Hello from _write\n");
|
||||
|
||||
return 0;
|
||||
return fd;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ COMP=--compiler gcc
|
|||
LIB=
|
||||
CF=-CFLAGS '-std=c++11 -fPIC -O3'
|
||||
|
||||
LIGHTW=-Wno-UNOPTFLAT -Wno-BLKLOOPINIT
|
||||
LIGHTW=-Wno-UNOPTFLAT
|
||||
DEB=--trace --prof-cfuncs -DVL_DEBUG=1
|
||||
EXE=--exe $(LIB_OBJS)
|
||||
|
||||
|
|
|
@ -579,20 +579,27 @@ void Core::writeback()
|
|||
// cout << "WRITEBACK SERVICED EXE\n";
|
||||
}
|
||||
|
||||
if ((inst_in_lsu.rd > 0) && (inst_in_lsu.mem_stall_cycles == 0))
|
||||
if (inst_in_lsu.is_sw)
|
||||
{
|
||||
if (serviced_exe)
|
||||
{
|
||||
cout << "$$$$$$$$$$$$$$$$$$$$ Stalling LSU because EXE is being used\n";
|
||||
inst_in_lsu.stalled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviced_mem = true;
|
||||
CPY_TRACE(inst_in_wb, inst_in_lsu);
|
||||
INIT_TRACE(inst_in_lsu);
|
||||
INIT_TRACE(inst_in_lsu);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((inst_in_lsu.rd > 0) && (inst_in_lsu.mem_stall_cycles == 0))
|
||||
{
|
||||
if (serviced_exe)
|
||||
{
|
||||
cout << "$$$$$$$$$$$$$$$$$$$$ Stalling LSU because EXE is being used\n";
|
||||
inst_in_lsu.stalled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviced_mem = true;
|
||||
CPY_TRACE(inst_in_wb, inst_in_lsu);
|
||||
INIT_TRACE(inst_in_lsu);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!serviced_exe && !serviced_mem) INIT_TRACE(inst_in_wb);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <pthread.h>
|
||||
// #include <pthread.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
@ -53,32 +53,32 @@ namespace Harp {
|
|||
};
|
||||
|
||||
class Core;
|
||||
class ConsoleMemDevice : public MemDevice {
|
||||
public:
|
||||
ConsoleMemDevice(Size wS, std::ostream &o, Core &core, bool batch = false);
|
||||
~ConsoleMemDevice() {}
|
||||
// class ConsoleMemDevice : public MemDevice {
|
||||
// public:
|
||||
// ConsoleMemDevice(Size wS, std::ostream &o, Core &core, bool batch = false);
|
||||
// ~ConsoleMemDevice() {}
|
||||
|
||||
//virtual Size wordSize() const { return wordSize; }
|
||||
virtual Size size() const { return wordSize; }
|
||||
virtual Word read(Addr) { pthread_mutex_lock(&cBufLock);
|
||||
char c = cBuf.front();
|
||||
cBuf.pop();
|
||||
pthread_mutex_unlock(&cBufLock);
|
||||
return Word(c); }
|
||||
virtual void write(Addr a, Word w) { output << char(w); }
|
||||
// //virtual Size wordSize() const { return wordSize; }
|
||||
// virtual Size size() const { return wordSize; }
|
||||
// virtual Word read(Addr) { pthread_mutex_lock(&cBufLock);
|
||||
// char c = cBuf.front();
|
||||
// cBuf.pop();
|
||||
// pthread_mutex_unlock(&cBufLock);
|
||||
// return Word(c); }
|
||||
// virtual void write(Addr a, Word w) { output << char(w); }
|
||||
|
||||
void poll();
|
||||
// void poll();
|
||||
|
||||
friend void *Harp::consoleInputThread(void *);
|
||||
// friend void *Harp::consoleInputThread(void *);
|
||||
|
||||
private:
|
||||
std::ostream &output;
|
||||
Size wordSize;
|
||||
Core &core;
|
||||
// private:
|
||||
// std::ostream &output;
|
||||
// Size wordSize;
|
||||
// Core &core;
|
||||
|
||||
std::queue<char> cBuf;
|
||||
pthread_mutex_t cBufLock;
|
||||
};
|
||||
// std::queue<char> cBuf;
|
||||
// pthread_mutex_t cBufLock;
|
||||
// };
|
||||
|
||||
class DiskControllerMemDevice : public MemDevice {
|
||||
public:
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#ifdef EMU_INSTRUMENTATION
|
||||
#include "include/qsim-harp.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
using namespace Harp;
|
||||
|
@ -83,7 +84,7 @@ Word signExt(Word w, Size bit, Word mask) {
|
|||
void upload(unsigned * addr, char * src, int size, Warp & c)
|
||||
{
|
||||
|
||||
cerr << "WRITING FINAL: " << *src << " size: " << size << "\n";
|
||||
// cerr << "WRITING FINAL: " << *src << " size: " << size << "\n";
|
||||
|
||||
unsigned current_addr = *addr;
|
||||
|
||||
|
@ -94,11 +95,13 @@ void upload(unsigned * addr, char * src, int size, Warp & c)
|
|||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
unsigned value = src[i] & 0x000000FF;
|
||||
cerr << "UPLOAD: (" << hex << current_addr << dec << ") = " << hex << ( value) << dec << "\n";
|
||||
// cerr << "UPLOAD: (" << hex << current_addr << dec << ") = " << hex << ( value) << dec << "\n";
|
||||
c.core->mem.write(current_addr, value, c.supervisorMode, 1);
|
||||
current_addr += 1;
|
||||
}
|
||||
|
||||
current_addr += (current_addr % 4);
|
||||
|
||||
*addr = current_addr;
|
||||
}
|
||||
|
||||
|
@ -120,6 +123,8 @@ void download(unsigned * addr, char * drain, Warp & c)
|
|||
current_addr += 1;
|
||||
}
|
||||
|
||||
current_addr += (current_addr % 4);
|
||||
|
||||
*addr = current_addr;
|
||||
}
|
||||
|
||||
|
@ -151,6 +156,7 @@ void downloadAlloc(unsigned * addr, char ** drain_ptr, int & size, Warp & c)
|
|||
#define READ 4
|
||||
#define WRITE 5
|
||||
#define FSTAT 6
|
||||
#define OPEN 7
|
||||
|
||||
void trap_to_simulator(Warp & c)
|
||||
{
|
||||
|
@ -173,7 +179,7 @@ void trap_to_simulator(Warp & c)
|
|||
int command;
|
||||
download(&read_buffer, (char *) &command, c);
|
||||
|
||||
cerr << "Command: " << hex << command << dec << '\n';
|
||||
// cerr << "Command: " << hex << command << dec << '\n';
|
||||
|
||||
switch (command)
|
||||
{
|
||||
|
@ -197,7 +203,27 @@ void trap_to_simulator(Warp & c)
|
|||
case (READ):
|
||||
{
|
||||
|
||||
cerr << "trap_to_simulator: READ not supported yet\n";
|
||||
// cerr << "trap_to_simulator: READ not supported yet\n";
|
||||
int file;
|
||||
unsigned ptr;
|
||||
int len;
|
||||
|
||||
download(&read_buffer, (char *) &file , c);
|
||||
download(&read_buffer, (char *) &ptr , c);
|
||||
download(&read_buffer, (char *) &len , c);
|
||||
|
||||
char * buff = (char *) malloc(len);
|
||||
|
||||
int ret = read(file, buff, len);
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
c.core->mem.write(ptr, buff[i], c.supervisorMode, 1);
|
||||
ptr++;
|
||||
}
|
||||
// c.core->mem.write(ptr, 0, c.supervisorMode, 1);
|
||||
free(buff);
|
||||
|
||||
}
|
||||
break;
|
||||
case (WRITE):
|
||||
|
@ -211,7 +237,7 @@ void trap_to_simulator(Warp & c)
|
|||
char * buf;
|
||||
downloadAlloc(&read_buffer, &buf, size, c);
|
||||
|
||||
write(file, buf, size);
|
||||
int e = write(file, buf, size);
|
||||
free(buf);
|
||||
}
|
||||
break;
|
||||
|
@ -224,18 +250,18 @@ void trap_to_simulator(Warp & c)
|
|||
struct stat st;
|
||||
fstat(file, &st);
|
||||
|
||||
// fprintf(stderr, "------------------------\n");
|
||||
// fprintf(stderr, "Size of struct: %x\n", sizeof(struct stat));
|
||||
// fprintf(stderr, "st_mode: %x\n", st.st_mode);
|
||||
// fprintf(stderr, "st_dev: %x\n", st.st_dev);
|
||||
// fprintf(stderr, "st_ino: %x\n", st.st_ino);
|
||||
// fprintf(stderr, "st_uid: %x\n", st.st_uid);
|
||||
// fprintf(stderr, "st_gid: %x\n", st.st_gid);
|
||||
// fprintf(stderr, "st_rdev: %x\n", st.st_rdev);
|
||||
// fprintf(stderr, "st_size: %x\n", st.st_size);
|
||||
// fprintf(stderr, "st_blksize: %x\n", st.st_blksize);
|
||||
// fprintf(stderr, "st_blocks: %x\n", st.st_blocks);
|
||||
// fprintf(stderr, "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
|
||||
fprintf(stderr, "------------------------\n");
|
||||
fprintf(stderr, "Size of struct: %x\n", sizeof(struct stat));
|
||||
fprintf(stderr, "st_mode: %x\n", st.st_mode);
|
||||
fprintf(stderr, "st_dev: %x\n", st.st_dev);
|
||||
fprintf(stderr, "st_ino: %x\n", st.st_ino);
|
||||
fprintf(stderr, "st_uid: %x\n", st.st_uid);
|
||||
fprintf(stderr, "st_gid: %x\n", st.st_gid);
|
||||
fprintf(stderr, "st_rdev: %x\n", st.st_rdev);
|
||||
fprintf(stderr, "st_size: %x\n", st.st_size);
|
||||
fprintf(stderr, "st_blksize: %x\n", st.st_blksize);
|
||||
fprintf(stderr, "st_blocks: %x\n", st.st_blocks);
|
||||
fprintf(stderr, "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
|
||||
|
||||
upload(&write_buffer, (char *) &st.st_mode , sizeof(st.st_mode), c);
|
||||
upload(&write_buffer, (char *) &st.st_dev , sizeof(st.st_dev), c);
|
||||
|
@ -255,6 +281,46 @@ void trap_to_simulator(Warp & c)
|
|||
unsigned data_read = c.core->mem.read(new_addr, c.supervisorMode);
|
||||
cerr << hex << new_addr << ": " << data_read << "\n";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (OPEN):
|
||||
{
|
||||
// cerr << "$$$$$$$$$$$$$$$$$$$$$$$$$ OPEN FROM simX\n";
|
||||
unsigned name_ptr;
|
||||
unsigned flags;
|
||||
unsigned mode;
|
||||
|
||||
download(&read_buffer, (char *) &name_ptr, c);
|
||||
download(&read_buffer, (char *) &flags , c);
|
||||
download(&read_buffer, (char *) &mode , c);
|
||||
|
||||
char buffer[255];
|
||||
unsigned read_word;
|
||||
char read_byte;
|
||||
|
||||
int curr_ind = 0;
|
||||
|
||||
read_word = c.core->mem.read(name_ptr, c.supervisorMode);
|
||||
read_byte = (char) (read_word & 0x000000FF);
|
||||
while (read_byte != 0)
|
||||
{
|
||||
buffer[curr_ind] = read_byte;
|
||||
|
||||
name_ptr++;
|
||||
curr_ind++;
|
||||
read_word = c.core->mem.read(name_ptr, c.supervisorMode);
|
||||
read_byte = (char) (read_word & 0x000000FF);
|
||||
}
|
||||
buffer[curr_ind] = 0;
|
||||
|
||||
|
||||
int fd = open(buffer, flags, mode);
|
||||
|
||||
// fprintf(stderr, "Name: --%s-- and fd: %d\n", buffer, fd);
|
||||
|
||||
upload(&write_buffer, (char *) &fd, sizeof(int), c);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
54
simX/mem.cpp
54
simX/mem.cpp
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
// #include <pthread.h>
|
||||
|
||||
#include "include/debug.h"
|
||||
#include "include/types.h"
|
||||
|
@ -206,35 +206,35 @@ void MemoryUnit::tlbRm(Addr va) {
|
|||
}
|
||||
|
||||
void *Harp::consoleInputThread(void* arg_vp) {
|
||||
ConsoleMemDevice *arg = (ConsoleMemDevice *)arg_vp;
|
||||
char c;
|
||||
while (cin) {
|
||||
c = cin.get();
|
||||
pthread_mutex_lock(&arg->cBufLock);
|
||||
arg->cBuf.push(c);
|
||||
pthread_mutex_unlock(&arg->cBufLock);
|
||||
}
|
||||
cout << "Console input ended. Exiting.\n";
|
||||
exit(4);
|
||||
// ConsoleMemDevice *arg = (ConsoleMemDevice *)arg_vp;
|
||||
// char c;
|
||||
// while (cin) {
|
||||
// c = cin.get();
|
||||
// pthread_mutex_lock(&arg->cBufLock);
|
||||
// arg->cBuf.push(c);
|
||||
// pthread_mutex_unlock(&arg->cBufLock);
|
||||
// }
|
||||
// cout << "Console input ended. Exiting.\n";
|
||||
// exit(4);
|
||||
}
|
||||
|
||||
ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core,
|
||||
bool batch) :
|
||||
wordSize(wS), output(o), core(core), cBuf()
|
||||
{
|
||||
// Create a console input thread if we are running in interactive mode.
|
||||
if (!batch) {
|
||||
pthread_t *thread = new pthread_t;
|
||||
pthread_create(thread, NULL, consoleInputThread, (void*)this);
|
||||
}
|
||||
pthread_mutex_init(&cBufLock, NULL);
|
||||
}
|
||||
// ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core,
|
||||
// bool batch) :
|
||||
// wordSize(wS), output(o), core(core), cBuf()
|
||||
// {
|
||||
// // Create a console input thread if we are running in interactive mode.
|
||||
// if (!batch) {
|
||||
// pthread_t *thread = new pthread_t;
|
||||
// pthread_create(thread, NULL, consoleInputThread, (void*)this);
|
||||
// }
|
||||
// pthread_mutex_init(&cBufLock, NULL);
|
||||
// }
|
||||
|
||||
void ConsoleMemDevice::poll() {
|
||||
pthread_mutex_lock(&cBufLock);
|
||||
if (!cBuf.empty()) core.interrupt(8);
|
||||
pthread_mutex_unlock(&cBufLock);
|
||||
}
|
||||
// void ConsoleMemDevice::poll() {
|
||||
// pthread_mutex_lock(&cBufLock);
|
||||
// if (!cBuf.empty()) core.interrupt(8);
|
||||
// pthread_mutex_unlock(&cBufLock);
|
||||
// }
|
||||
|
||||
Word DiskControllerMemDevice::read(Addr a) {
|
||||
switch (a/8) {
|
||||
|
|
1
simX/reading_data.txt
Normal file
1
simX/reading_data.txt
Normal file
|
@ -0,0 +1 @@
|
|||
hello this is the data read from a file!
|
|
@ -98,9 +98,9 @@ int emu_main(int argc, char **argv) {
|
|||
// old_ram.loadHexImpl(tests[t]);
|
||||
// MemDevice * memory = &old_ram;
|
||||
|
||||
ConsoleMemDevice console(arch.getWordSize(), cout, core, batch);
|
||||
// ConsoleMemDevice console(arch.getWordSize(), cout, core, batch);
|
||||
mu.attach(old_ram, 0);
|
||||
mu.attach(console, 1ll<<(arch.getWordSize()*8 - 1));
|
||||
// mu.attach(console, 1ll<<(arch.getWordSize()*8 - 1));
|
||||
// mu.attach(console, 0xf0000000);
|
||||
|
||||
// core.w[0].pc = 0x8000007c; // If I want to start at a specific location
|
||||
|
@ -127,7 +127,7 @@ int emu_main(int argc, char **argv) {
|
|||
struct stat hello;
|
||||
fstat(0, &hello);
|
||||
|
||||
while (core.running()) { console.poll(); core.step(); }
|
||||
while (core.running()) {core.step(); }
|
||||
|
||||
if (showStats) core.printStats();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue