void smk_init_console() { int i; console = (char*)_sysenter((SYS_CONSOLE|SYS_ONE),0,0,0,0,0); console_size = (int32)_sysenter((SYS_CONSOLE|SYS_TWO),0,0,0,0,0); // Last page of console. console_ld = (struct console_data*) ( (uint32)console + console_size - 4096 ); if ( console_ld->magic != CONSOLE_MAGIC ) { console_ld->magic = CONSOLE_MAGIC; console_ld->spinlock = 1; console_ld->mode = VC_MODE_BUFFER; console_ld->x = 0; console_ld->y = 0; console_ld->pid = -1; console_ld->port = -1; console_ld->attr = 7; for ( i = 0; i < (160*25); i+=2) { console[i] = 0; console[i+1] = console_ld->attr; } smk_release_spinlock( & (console_ld->spinlock) ); } }
int smk_create_port( int port, int tid ) { int ret; if ( (port < 0) || (port > 1024) ) return -1; ret = _sysenter( (SYS_PORT|SYS_ONE), port, tid, 0, 0, 0 ); return ret; }
/** Retrieves the LFB information from the kernel if it was * started up with GRUB in VBE mode. If there is no LFB information * kept by the kernel, the parameter ptr will be NULL. */ void smk_get_lfb( uint32_t** ptr, uint32_t *width, uint32_t *height ) { _sysenter( (SYS_MISC|SYS_THREE), (uint32_t)ptr, (uint32_t)width, (uint32_t)height, 0, 0 ); }
int smk_search_pci( uint16_t vendor_id, uint16_t device_id, int num, struct pci_cfg* cfg ) { return _sysenter( ( SYS_PCI | SYS_ONE ), vendor_id, device_id, num, ( uint32_t )cfg, 0 ); }
int smk_create_shmem( const unsigned char *name, int pages, unsigned int flags ) { return _sysenter( (SYS_SHMEM|SYS_ONE), (uint32_t)name, (uint32_t)pages, flags, 0,0 ); }
int smk_gettid() { int a,b; a = 10; b = 10; _sysenter( (SYS_PROCESS|SYS_ONE),(uint32_t)&a,(uint32_t)&b,0,0,0 ); return b; }
int smk_probe_pci( uint8_t bus, uint8_t unit, uint8_t function, struct pci_cfg* cfg ) { return _sysenter( (SYS_PCI|SYS_TWO) , bus, unit, function, (uint32_t)cfg, 0 ); }
int smk_grant_shmem( int id, int pid, unsigned int flags ) { return _sysenter( (SYS_SHMEM|SYS_THREE), 0, (uint32_t)id, (uint32_t)pid, (uint32_t)flags, 0 ); }
int smk_revoke_shmem( int id, int pid ) { return _sysenter( (SYS_SHMEM|SYS_THREE), 1, (uint32_t)id, (uint32_t)pid, 0, 0 ); }
int smk_request_shmem( int id, void **location, int *pages, unsigned int *flags ) { return _sysenter( (SYS_SHMEM|SYS_FOUR), 0, (uint32_t)id, (uint32_t)location, (uint32_t)pages, (uint32_t)flags ); }
int smk_get_shmem_info( int id, unsigned char *name, int *pid, int *pages, unsigned int *flags ) { return _sysenter( (SYS_SHMEM|SYS_SIX), (uint32_t)id, (uint32_t)name, (uint32_t)pid, (uint32_t)pages, (uint32_t)flags ); }
int smk_getenv_size( const char *name ) { int size; if ( _sysenter( (SYS_PROCESS|SYS_FIVE), 2, (uint32)name, (uint32)&size,0,0 ) == 0 ) return size; return -1; }
int smk_mem_exec( const char *name, uintptr_t start, uintptr_t end, const char *command_line) { return _sysenter( (SYS_EXEC|SYS_ONE), (uint32_t)name, (uint32_t)start, (uint32_t)end, (uint32_t)command_line, 0); }
int smk_set_event_hooks( int handler_tid, int target_pid, int target_tid ) { return _sysenter( (SYS_EVENTS|SYS_ONE), (uint32_t)handler_tid, (uint32_t)target_pid, (uint32_t)target_tid, 0, 0); }
int smk_create_shmem_direct( const unsigned char *name, int pages, unsigned int flags, uintptr_t location ) { return _sysenter( (SYS_SHMEM|SYS_ONE), (uint32_t)name, (uint32_t)pages, flags, 1, (uint32_t)location ); }
int smk_request_irq( irq_func fn, int irq_num, const char *name, void *data ) { int ans; uint32_t d[4]; d[0] = (uint32_t)fn; d[1] = (uint32_t)irq_num; d[2] = (uint32_t)data; d[3] = 0; // spawn a thread for the IRQ handler ans = _sysenter( (SYS_THREAD|SYS_ONE) , 5, (uint32_t)name, (uint32_t)&d, 0, (uint32_t)__irq_intro); if ( ans <= 0 ) return -1; ans = _sysenter( (SYS_IRQ|SYS_ONE), irq_num, ans, 0, 0, 0 ); return ans; }
int smk_spawn_thread( thread_func func, const char *name, int priority, void* data ) { int ans; uint32_t d[4]; d[0] = (uint32_t)func; d[1] = (uint32_t)data; d[2] = 0; d[3] = 0; ans = _sysenter( (SYS_THREAD|SYS_ONE) , priority, (uint32_t)name, (uint32_t)&d, 0, (uint32_t)__thread_intro); return ans; }
int smk_find_shmem( const unsigned char *name, int *pid ) { return _sysenter( (SYS_SHMEM|SYS_FIVE), (uint32_t)name, (uint32_t)pid,0,0,0 ); }
void smk_exit(int code) { _sysenter( (SYS_PROCESS|SYS_THREE), code, 0, 0,0,0 ); }
/** This request will put the thread into a dormant state * for the specified amount of milliseconds. It's not * removed from the scheduler queue but put into a * separate queue to allow for fast re-scheduling. Generally, * the thread will wake up at the millisecond requested. * The scheduler checks on every iteration for dormant * threads which need to be woken up. * * An IPC received by the thread will wake the thread up * prematurely. You can determine if the thread was woken * up prematurely because the system call returns the number * of milliseconds the thread was dormant. * * \return The number of milliseconds the thread was dormant. * */ int smk_go_dormant_t( int milliseconds ) { return _sysenter( (SYS_THREAD|SYS_FOUR) , milliseconds,0,0,0,0 ); }
/** This is a semi-permanent request to put the calling * thread into a dormant state. While the thread is in a * dormant state, it will be removed from the scheduler * queue and it won't run. The only way to wake it up * would be a state change request by another thread or * by sending it an IPC message which it is registered * to receive. * * \return 0 */ int smk_go_dormant() { return _sysenter( (SYS_THREAD|SYS_FOUR) , 0,0,0,0,0 ); }
/** This will abort the running of the current application with * the provided reason. Useful for asserts and stuff. * * \todo Evaluate permanence... */ void smk_abort( int rc, const char *reason ) { _sysenter( SYS_MISC | SYS_TWO, rc, (int)reason, 0,0,0 ); }
void smk_reboot() { _sysenter( SYS_MISC | SYS_ONE ,0,0,0,0,0 ); }
int smk_delete_shmem( int id ) { return _sysenter( (SYS_SHMEM|SYS_TWO), (uint32_t)id, 0, 0,0,0 ); }
int smk_release_shmem( int id ) { return _sysenter( (SYS_SHMEM|SYS_FOUR), 1, (uint32_t)id, 0, 0, 0 ); }
int32 smk_get_console( int pid ) { return _sysenter( (SYS_CONSOLE|SYS_FOUR), pid, 0, 0,0,0 ); }
char *smk_get_console_location() { return (char*)_sysenter((SYS_CONSOLE|SYS_ONE),0,0,0,0,0); }
int smk_switch_console( int pid, int console ) { return _sysenter( (SYS_CONSOLE|SYS_FIVE), pid, console, 0,0,0 ); }
int smk_active_pid( int id ) { return _sysenter( (SYS_CONSOLE|SYS_EIGHT), 1, id, 0,0,0 ); }
int smk_set_active_pid( int id, int pid ) { return _sysenter( (SYS_CONSOLE|SYS_EIGHT), 0, id, pid ,0,0 ); }