#ifndef __LINUX_COOPERATIVE_H__ #define __LINUX_COOPERATIVE_H__ #include #ifdef __KERNEL__ #ifndef CO_KERNEL #define CO_COLINUX_KERNEL #define CO_KERNEL #endif #endif #ifdef CONFIG_COOPERATIVE extern void co_debug(const char *fmt, ...); #include #define CO_BOOTPARAM_STRING_LENGTH 0x100 extern char co_boot_parameters[CO_BOOTPARAM_STRING_LENGTH]; typedef enum { CO_OPERATION_EMPTY=0, CO_OPERATION_START, CO_OPERATION_IDLE, CO_OPERATION_TERMINATE, CO_OPERATION_MESSAGE_TO_MONITOR, CO_OPERATION_MESSAGE_FROM_MONITOR, CO_OPERATION_FORWARD_INTERRUPT, CO_OPERATION_DEVICE, CO_OPERATION_GET_TIME, CO_OPERATION_DEBUG_LINE, } co_operation_t; #define CO_MODULE_MAX_CONET 16 #define CO_MODULE_MAX_COBD 8 typedef enum { CO_MODULE_LINUX, CO_MODULE_MONITOR, CO_MODULE_DAEMON, CO_MODULE_IDLE, CO_MODULE_KERNEL_SWITCH, CO_MODULE_USER_SWITCH, CO_MODULE_CONSOLE, CO_MODULE_PRINTK, CO_MODULE_CONET0, CO_MODULE_CONET_END=CO_MODULE_CONET0+CO_MODULE_MAX_CONET-1, CO_MODULE_COBD0, CO_MODULE_COBD_END=CO_MODULE_COBD0+CO_MODULE_MAX_COBD-1, } co_module_t; typedef enum { CO_PRIORITY_DISCARDABLE=0, CO_PRIORITY_IMPORTANT, } co_priority_t; typedef enum { CO_MESSAGE_TYPE_STRING=0, CO_MESSAGE_TYPE_OTHER=0, } co_message_type_t; typedef struct { co_module_t from; co_module_t to; co_priority_t priority; co_message_type_t type; unsigned long size; char data[0]; } co_message_t; typedef enum { CO_DEVICE_BLOCK=0, CO_DEVICE_CONSOLE, CO_DEVICE_KEYBOARD, CO_DEVICE_NETWORK, CO_DEVICE_TIMER, CO_DEVICE_POWER, CO_DEVICES_TOTAL, } co_device_t; typedef struct { unsigned char code; int down; } co_scan_code_t; typedef struct { co_device_t device; unsigned long unit; unsigned long size; char data[]; } co_linux_message_t; typedef enum { CO_TERMINATE_END=0, CO_TERMINATE_REBOOT, CO_TERMINATE_POWEROFF, CO_TERMINATE_PANIC, CO_TERMINATE_HALT, CO_TERMINATE_FORCED_OFF, CO_TERMINATE_FORCED_END, CO_TERMINATE_INVALID_OPERATION, } co_termination_reason_t; typedef void (*co_switcher_t)(co_arch_passage_page_t *page, unsigned char *from, unsigned char *to); #define co_passage_page_func_low(_from_,_to_) \ (((co_switcher_t)(co_passage_page->code)) \ (co_passage_page, \ (char *)&_from_.border2, \ (char *)&_to_.border2)) #define co_passage_page_func(_from_,_to_) \ co_passage_page_func_low(co_passage_page->_from_, co_passage_page->_to_) #ifdef CO_KERNEL # ifdef CO_COLINUX_KERNEL extern co_arch_passage_page_t *co_passage_page; # define co_current (co_passage_page->colx_state) # define co_other (co_passage_page->host_state) # else # define co_passage_page (cmon->passage_page) # define co_other (co_passage_page->colx_state) # define co_current (co_passage_page->host_state) # endif # define co_switch() co_passage_page_func_low(co_current, co_other) #endif /* * Defines operations on various virtual devices. */ typedef enum { CO_OPERATION_CONSOLE_STARTUP=0, CO_OPERATION_CONSOLE_INIT=1, CO_OPERATION_CONSOLE_DEINIT, CO_OPERATION_CONSOLE_CLEAR, CO_OPERATION_CONSOLE_PUTC, CO_OPERATION_CONSOLE_PUTCS, CO_OPERATION_CONSOLE_CURSOR_DRAW, CO_OPERATION_CONSOLE_CURSOR_ERASE, CO_OPERATION_CONSOLE_CURSOR_MOVE, CO_OPERATION_CONSOLE_SCROLL_UP, CO_OPERATION_CONSOLE_SCROLL_DOWN, CO_OPERATION_CONSOLE_BMOVE, CO_OPERATION_CONSOLE_SWITCH, CO_OPERATION_CONSOLE_BLANK, CO_OPERATION_CONSOLE_FONT_OP, CO_OPERATION_CONSOLE_SET_PALETTE, CO_OPERATION_CONSOLE_SCROLLDELTA, CO_OPERATION_CONSOLE_SET_ORIGIN, CO_OPERATION_CONSOLE_SAVE_SCREEN, CO_OPERATION_CONSOLE_INVERT_REGION, } co_operation_console_t; typedef char co_console_code; typedef unsigned char co_console_character; typedef unsigned short co_console_unit; typedef struct { co_console_unit x; co_console_unit y; co_console_unit height; } co_cursor_pos_t; typedef struct { co_operation_console_t type; union { struct { co_console_unit top; co_console_unit bottom; co_console_unit lines; } scroll; struct { co_console_unit y; co_console_unit x; co_console_unit count; co_console_code data[]; } putcs; struct { co_console_unit x; co_console_unit y; co_console_character charattr; } putc; struct { co_console_unit top; co_console_unit left; co_console_unit bottom; co_console_unit right; } clear; struct { co_console_unit y; co_console_unit x; co_console_unit count; } invert; struct { co_console_unit row; co_console_unit column; co_console_unit top; co_console_unit left; co_console_unit bottom; co_console_unit right; } bmove; co_cursor_pos_t cursor; }; } co_console_message_t; extern void co_printk(char *line); extern void co_callback(void); extern void co_switch_wrapper(void); extern void co_idle_processor(void); extern void co_terminate(co_termination_reason_t reason); extern void co_send_message(co_module_t from, co_module_t to, co_priority_t priority, co_message_type_t type, unsigned long size, char *data); extern co_message_t *co_send_message_save(unsigned long *flags); extern void co_send_message_restore(unsigned long flags); extern void co_handle_device_interrupt(co_linux_message_t *message); extern unsigned long co_bootmem_pages; extern unsigned long co_core_end; extern unsigned long co_memory_size; extern unsigned long co_rpptm_size; extern unsigned long co_get_host_time(void); extern void handle_keyboard_event(unsigned char scancode); typedef enum { CO_BLOCK_OPEN=0, CO_BLOCK_STAT, CO_BLOCK_READ, CO_BLOCK_WRITE, CO_BLOCK_CLOSE, } co_block_request_type_t; typedef enum { CO_NETWORK_GET_MAC=0, } co_network_request_type_t; #ifdef CO_KERNEL /* If we are compiling kernel code (Linux or Host Driver) */ # ifdef CO_COLINUX_KERNEL /* Inside Linux, vm_ptr_t considered a valid pointer in its virtual address space */ typedef void *vm_ptr_t; # else /* But inside the host, the type is considered not to be a pointer in its own address space */ typedef unsigned long vm_ptr_t; # endif typedef struct { co_block_request_type_t type; long rc; unsigned long long offset; unsigned long long size; vm_ptr_t address; unsigned long long disk_size; } __attribute__((packed)) co_block_request_t; typedef struct { co_network_request_type_t type; unsigned long unit; char mac_address[6]; } __attribute__((packed)) co_network_request_t; #endif #else #define co_terminate(reason) do {} while(0) #define co_debug(...args) do {} while(0) #endif #ifndef COLINUX_TRACE #define CO_TRACE_STOP #define CO_TRACE_CONTINUE #endif #endif