POK(kernelpart)
|
00001 /* 00002 * POK header 00003 * 00004 * The following file is a part of the POK project. Any modification should 00005 * made according to the POK licence. You CANNOT use this file or a part of 00006 * this file is this part of a file for your own project 00007 * 00008 * For more information on the POK licence, please see our LICENCE FILE 00009 * 00010 * Please follow the coding guidelines described in doc/CODING_GUIDELINES 00011 * 00012 * Copyright (c) 2007-2009 POK team 00013 * 00014 * Created by julien on Thu Jan 15 23:34:13 2009 00015 */ 00016 00023 #include <errno.h> 00024 #include <core/debug.h> 00025 #include <core/syscall.h> 00026 #include <core/partition.h> 00027 00028 #include <types.h> 00029 #include <libc.h> 00030 00031 #include "thread.h" 00032 #include "context_offset.h" 00033 #include "traps.h" 00034 #include "arch.h" 00035 00039 void pok_arch_sc_int(void) 00040 { 00041 uint8_t *ctx = (uint8_t *)pok_arch_sp; 00042 uint32_t num = *(uint32_t *)((char *)ctx - I0_OFFSET); 00043 uint8_t part_id; 00044 pok_syscall_info_t syscall_info; 00045 pok_ret_t syscall_ret; 00046 pok_syscall_args_t syscall_args; 00047 pok_syscall_id_t syscall_id; 00048 00049 00050 part_id = pok_current_partition; 00051 00052 /* prepare syscall_info */ 00053 syscall_info.partition = part_id; 00054 syscall_info.base_addr = pok_partitions[part_id].base_addr; 00055 syscall_info.thread = POK_SCHED_CURRENT_THREAD; 00056 00057 /* prepare syscall_args */ 00058 syscall_args.arg1 = *(uint32_t *)(ctx - I1_OFFSET); 00059 syscall_args.arg2 = *(uint32_t *)(ctx - I2_OFFSET); 00060 syscall_args.arg3 = *(uint32_t *)(ctx - I3_OFFSET); 00061 syscall_args.arg4 = *(uint32_t *)(ctx - I4_OFFSET); 00062 syscall_args.arg5 = *(uint32_t *)(ctx - I5_OFFSET); 00063 00064 syscall_args.nargs = 5; 00065 00066 /* prepare syscall_id */ 00067 syscall_id = (pok_syscall_id_t) num; 00068 00069 /* 00070 * No pointer check needed, syscall_args is allocated in kernel stack. 00071 */ 00072 syscall_ret = pok_core_syscall (syscall_id, &syscall_args, &syscall_info); 00073 00074 *(uint32_t *)(ctx - I0_OFFSET) = syscall_ret; 00075 *(uint32_t *)(ctx - PC_OFFSET) += 4; // skip "ta" instruction 00076 *(uint32_t *)(ctx - NPC_OFFSET) += 4; 00077 } 00078 00083 void pok_syscalls_init(void) 00084 { 00085 pok_arch_event_register(SPARC_TRAP_SYSCALL_BASE + 0x2, pok_arch_sc_int); 00086 }