/* file: stm.h * * Code for the simulated toy machine (STM), * a simulated architecture supporting variable-length partitions. * * FOR MOST OF OUR PROJECTS, YOU MUST NOT MODIFY THIS CODE * AS IT REPRESENTS OUR HARDWARE. * * Fall 2006: Operating Systems Class, Professor Yap * * THIS CODE IS modified from the original stm.c code, * with permission from Professor Ernie Davis * The original stm.c file is split into four files: * * stm.h, stm.c * sos.h sos.c * * SOS is the Simple Operating System, and is * linked to stm.o. * * VERSION CONVENTION: * Since we intend to change the hardware and software * throughout this course, we use this convention for versioning. * * stm1.h and stm1.c will be the name of the first modification of stm. * E.g., stm2.h and stm2.c will refer to the second, independent * modification of stm. * * If you extend stm1.h and stm1.c, then it should be named stm11.h, stm11.c. * E.g., If you extend stm213.h and stm213.c, then you should * name it stm2131.h, stm2131.c. * * Same principle for versioning of sos. * The slight complication is that sos must also * know which version of stm it is using. * REMARK: Basically, we use a single digit for each version. * The "0" digit is implicit if missing. * E.g., stm.h is really stm0.h and stm00.h. * Also, sos1.h is really sos10.h. * ***************************************************/ #ifndef H_STM #define H_STM #include #include #include /**************************************************** * Hardware Specs ****************************************************/ #define RAMSIZE 262144 /* 2**18 address space */ #define NUMREGS 16 /**************************************************** * Global variables for the simulated architecture ****************************************************/ extern int mem[RAMSIZE], /* Core memory */ regs[NUMREGS], /* Number of registers */ base, /* Base register */ limit; /* limit register */ extern char codes[16][4]; /* Op codes */ extern int debug, /* level of debugging */ error, /* error flag */ terminate; /* termination flag */ /**************************************************** * Convert a relative address to a physical address. Check that it * lies within bounds * Note: This is considered part of the "hardware" of the virtual machine. * You may not change it in any of the projects. ****************************************************/ extern int phys_address(int reladd); /* Display STM instruction for level-2 debugging */ extern void show_inst(int op, int ra, int ad, int rb, int rc, int rd); /* Decompose an STM instruction into its components * Note: This is considered part of the "hardware" of the virtual machine. * You may not change it in any of the projects. */ extern void get_inst(int inst, int* pop, int* pra, int* pad, int* prb, int* prc, int* prd); /* Execute an STM instruction. This is what does the actual work of * carrying out the STM code * Note: This is considered part of the "hardware" of the virtual machine. * You may not change it in any of the projects. */ extern int exec_inst(int op, int ra, int ad, int rb, int rc, int rd); /* Execute a trap */ extern void exec_stm(); /* stm version */ extern void STMversion(); #endif // END of stm.h