// kernel.h #ifndef _KERNEL_H_ #define _KERNEL_H_ // SYSTEM CONFIGURATION CONSTANTS /* these must be set correctly for the code to operate properly, ...or at all. */ #define KERNEL_ERROR_MSGS 1 //#define KDB_TRACE_LEVEL_1 1 //#define KDB_TRACE_LEVEL_2 1 #define KDB_CYCLES 4 #define RAM_SIZE 1536 #define DEFAULT_STACK_SIZE 64 #define DEFAULT_SHELL_STACK_SIZE 255 #define USED_RAM (DEFAULT_STACK_SIZE + 128) #define INITIAL_HEAP_SIZE (RAM_SIZE - USED_RAM) #define MAXTASKS 8 #define NUMRESOURCES 4 #define LOAD_SHELL 1 #define BUS_FREQ 4 #define SYSTEM_TICK_SIZE 65535 #define TIME_TICK_SIZE 1024 #define ONE_SECOND 1000000 #define TIME_TICKS_PER_SECOND (ONE_SECOND / TIME_TICK_SIZE) #define TIME_TICKS_PER_DAY (TIME_TICKS_PER_SECOND * 86400) // MACROS #ifndef COP_OPS // set COP to time out at 1 second #define COP_ON() COPCTL = 0xC6 #define COP_OFF() COPCTL = 0x00 #define COP_PET(x) COPRST = (x) #endif // ENUMERATIONS enum task_state { IDLE = 0, // capitalize all these PENDING = 1, RUNNING = 2, WAITING = 3, STOPPED = 4 }; enum resource_state { NOTBUSY = 0, BUSY = 1 }; enum message_box { STATE_FLAG = 0x01, // 0000 0001 PRIO_FLAG = 0x02 // 0000 0010 }; // =4, =8, =16, etc. enum message_box_data { STATE_BOX = 0, PRIO_BOX = 1 }; // =2, =3, =4, etc. // FUNCTION PROTOTYPES int get_task_address(char id); char get_task_id(void); char *get_task_name(unsigned char id); int get_task_state(unsigned char id); int get_task_priority(unsigned char id); int get_task_messages(unsigned char id); int set_task_state(unsigned char id, unsigned char state); int set_task_priority(unsigned char id, unsigned char priority); int create_task(char *name, void (*addr)(), unsigned char priority, int state, int stack); int get_resource_state(unsigned char id); int get_resource_owner(unsigned char id); int get_resource_queuelen(unsigned char id); int get_free_memory(void); unsigned long int get_sysTime(void); void set_sysTime(unsigned int hours, unsigned int minutes, unsigned int seconds); /* unsigned long get_time(void); void set_time(unsigned char hour, unsigned char min, unsigned char sec); char* get_os_version(); */ #endif