| 1 | #include <iostream> |
|---|
| 2 | #include "../include/Sim2OS.h" |
|---|
| 3 | |
|---|
| 4 | using namespace std; |
|---|
| 5 | using namespace environment; |
|---|
| 6 | using namespace environment::sim2os; |
|---|
| 7 | |
|---|
| 8 | #ifdef SYSTEMC |
|---|
| 9 | int sc_main (int argc, char * argv[]) |
|---|
| 10 | #else |
|---|
| 11 | int main (int argc, char * argv[]) |
|---|
| 12 | #endif |
|---|
| 13 | { |
|---|
| 14 | cout << "<main> Begin" << endl; |
|---|
| 15 | |
|---|
| 16 | SOCLIB_SEGMENT_TABLE * segtable = new SOCLIB_SEGMENT_TABLE; |
|---|
| 17 | segtable->setMSBNumber (8); |
|---|
| 18 | segtable->setDefaultTarget(0,0); |
|---|
| 19 | |
|---|
| 20 | //shared data segment |
|---|
| 21 | |
|---|
| 22 | const int TEXT_BASE = 0x1000; |
|---|
| 23 | const int DATA_CACHED_BASE = 0x2000; |
|---|
| 24 | const int DATA_UNCACHED_BASE = 0x3000; |
|---|
| 25 | const int STACK_BASE = 0x4000; |
|---|
| 26 | const int TTY_BASE = 0x5000; |
|---|
| 27 | const int SIM2OS_BASE = 0x6000; |
|---|
| 28 | const int RAMLOCK_BASE = 0x7000; |
|---|
| 29 | |
|---|
| 30 | const int TEXT_SIZE = 0x100; |
|---|
| 31 | const int DATA_CACHED_SIZE = 0x100; |
|---|
| 32 | const int DATA_UNCACHED_SIZE = 0x100; |
|---|
| 33 | const int STACK_SIZE = 0x100; |
|---|
| 34 | const int TTY_SIZE = 0x100; |
|---|
| 35 | const int SIM2OS_SIZE = 0x100; |
|---|
| 36 | const int RAMLOCK_SIZE = 0x100; |
|---|
| 37 | |
|---|
| 38 | // Add a segment :name , address of base , size , global index , local index, uncache |
|---|
| 39 | segtable->addSegment("text" , TEXT_BASE , TEXT_SIZE , 0 ,0 , false); |
|---|
| 40 | segtable->addSegment("data" , DATA_CACHED_BASE , DATA_CACHED_SIZE , 0 ,0 , false); |
|---|
| 41 | segtable->addSegment("data_unc" , DATA_UNCACHED_BASE , DATA_UNCACHED_SIZE , 0 ,0 , true ); |
|---|
| 42 | segtable->addSegment("stack" , STACK_BASE , STACK_SIZE , 0 ,0 , false); |
|---|
| 43 | segtable->addSegment("tty" , TTY_BASE , TTY_SIZE , 0 ,0 , true ); |
|---|
| 44 | segtable->addSegment("sim2os" , SIM2OS_BASE , SIM2OS_SIZE , 0 ,0 , true ); |
|---|
| 45 | segtable->addSegment("ramlock" , RAMLOCK_BASE , RAMLOCK_SIZE , 0 ,0 , true ); |
|---|
| 46 | |
|---|
| 47 | segtable->print(); |
|---|
| 48 | |
|---|
| 49 | Parameters * param = new Parameters (segtable); |
|---|
| 50 | |
|---|
| 51 | Sim2OS * my_sim2os = new Sim2OS ("my_sim2os",param); |
|---|
| 52 | |
|---|
| 53 | cout << *my_sim2os << endl; |
|---|
| 54 | |
|---|
| 55 | my_sim2os->transition(); |
|---|
| 56 | my_sim2os->transition(); |
|---|
| 57 | my_sim2os->transition(); |
|---|
| 58 | my_sim2os->transition(); |
|---|
| 59 | my_sim2os->transition(); |
|---|
| 60 | my_sim2os->transition(); |
|---|
| 61 | my_sim2os->transition(); |
|---|
| 62 | my_sim2os->transition(); // cycle 8 |
|---|
| 63 | |
|---|
| 64 | my_sim2os->parameter(1,(void*) 21071981); |
|---|
| 65 | my_sim2os->parameter(2,(void*)0xdeadbeef); |
|---|
| 66 | my_sim2os->parameter(0,(void*)5); // SERVICE_CLOCK |
|---|
| 67 | |
|---|
| 68 | cout << *my_sim2os << endl; |
|---|
| 69 | my_sim2os->execute(); |
|---|
| 70 | cout << *my_sim2os << endl; |
|---|
| 71 | |
|---|
| 72 | // char * pathname = "toto.txt"; |
|---|
| 73 | // int flags = O_CREAT; |
|---|
| 74 | // mode_t mode = 0777; |
|---|
| 75 | |
|---|
| 76 | // my_sim2os->parameter(1,(void*)pathname); |
|---|
| 77 | // my_sim2os->parameter(2,(void*)flags ); |
|---|
| 78 | // my_sim2os->parameter(3,(void*)mode ); |
|---|
| 79 | // my_sim2os->parameter(0,(void*)0 ); |
|---|
| 80 | |
|---|
| 81 | // cout << *my_sim2os << endl; |
|---|
| 82 | // my_sim2os->execute(); |
|---|
| 83 | // cout << *my_sim2os << endl; |
|---|
| 84 | |
|---|
| 85 | delete my_sim2os; |
|---|
| 86 | delete param; |
|---|
| 87 | delete segtable; |
|---|
| 88 | |
|---|
| 89 | cout << "<main> End" << endl; |
|---|
| 90 | |
|---|
| 91 | return EXIT_SUCCESS; |
|---|
| 92 | } |
|---|