/* program.c */ #include "asm.h" #include "dining.h" #include "display.h" #include "mips4kc.h" #include "process.h" #include "program.h" #include "scheduler.h" #include "string.h" #include "tty3.h" #include "types.h" #include "user.h" extern program program_table[PROGRAMS]; void add_program(char name[MAX_STR_LEN], uint32_t address, uint8_t standard_priority, int i) { string_memcpy(program_table[i].name, name); program_table[i].address = address; program_table[i].standard_priority = standard_priority; } uint32_t get_program_address(char name[MAX_STR_LEN]) { int i; for (i = 0; i < PROGRAMS; i++) { if (name_comp(name, program_table[i].name)) { return program_table[i].address; } } return 0; } uint8_t get_program_standard_priority(char name[MAX_STR_LEN]) { int i; for (i = 0; i < PROGRAMS; i++) { if (name_comp(name, program_table[i].name)) { return program_table[i].standard_priority; } } return 0; } int program_exists(char name[]) { int i; for (i = 0; i < PROGRAMS; i++) { if (name_comp(program_table[i].name, name)) { return 1; } } return 0; } void init_programs() { int i = 0; add_program("increment", (uint32_t)increment, 4, i++); add_program("console", (uint32_t)console, 3, i++); add_program("super", (uint32_t)super, 5, i++); add_program("ring", (uint32_t)ring, 5, i++); add_program("node", (uint32_t)node, 5, i++); add_program("fibonacci", (uint32_t)fibonacci, 4, i++); add_program("lcd", (uint32_t)lcd, 3, i++); add_program("malta", (uint32_t)prg_malta, 4, i++); add_program("ps", (uint32_t)pgr_ps, 4, i++); add_program("kill", (uint32_t)pgr_terminate, 4, i++); add_program("prio", (uint32_t)pgr_prio, 4, i++); add_program("dining", (uint32_t)dining, 4, i++); add_program("waiter", (uint32_t)waiter, 5, i++); add_program("phil", (uint32_t)phil, 5, i++); }