- Timestamp:
- 2006-03-13T19:39:30Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45d6add
- Parents:
- 78a95d6f
- Location:
- generic
- Files:
-
- 3 added
- 7 edited
-
include/errno.h (added)
-
include/ipc/ipc.h (added)
-
include/mm/page.h (modified) (2 diffs)
-
include/proc/task.h (modified) (2 diffs)
-
include/syscall/syscall.h (modified) (1 diff)
-
src/ipc/ipc.c (added)
-
src/main/kinit.c (modified) (1 diff)
-
src/main/main.c (modified) (2 diffs)
-
src/proc/task.c (modified) (2 diffs)
-
src/syscall/syscall.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
generic/include/mm/page.h
r78a95d6f r6d9c49a 33 33 #include <arch/types.h> 34 34 #include <typedefs.h> 35 #include <memstr.h> 35 36 36 37 #define PAGE_CACHEABLE_SHIFT 0 … … 60 61 #define PAGE_GLOBAL (1<<PAGE_GLOBAL_SHIFT) 61 62 63 64 /* TODO - check that userspace is OK, platform specific functions etc */ 65 static inline void copy_to_uspace(void *dst, void *src, count_t cnt) 66 { 67 memcpy(dst, src, cnt); 68 } 69 70 static inline void copy_to_kernel(void *dst, void *src, count_t cnt) 71 { 72 memcpy(dst, src, cnt); 73 } 74 62 75 /** Operations to manipulate page mappings. */ 63 76 struct page_mapping_operations { -
generic/include/proc/task.h
r78a95d6f r6d9c49a 33 33 #include <synch/spinlock.h> 34 34 #include <adt/list.h> 35 #include <ipc/ipc.h> 35 36 36 37 /** Task structure. */ … … 40 41 link_t tasks_link; /**< Link to other tasks within the system. */ 41 42 as_t *as; /**< Address space. */ 43 answerbox_t answerbox; /**< Communication endpoint */ 44 phone_t phones[IPC_MAX_PHONES]; 42 45 }; 43 46 -
generic/include/syscall/syscall.h
r78a95d6f r6d9c49a 30 30 #define __SYSCALL_H__ 31 31 32 #include <typedefs.h>33 34 32 typedef enum { 35 33 SYS_CTL = 0, 36 34 SYS_IO = 1, 35 SYS_IPC_CALL = 2, 36 SYS_IPC_ANSWER = 3, 37 SYS_IPC_WAIT = 4, 37 38 SYSCALL_END 38 39 } syscall_t; 39 40 40 typedef int (*syshandler_t)(); 41 #ifdef KERNEL 41 42 42 extern int sys_ctl(void); 43 extern int sys_io(int fd, const void *buf, size_t count); 43 #include <arch/types.h> 44 #include <typedefs.h> 45 46 typedef __native (*syshandler_t)(); 44 47 45 48 extern syshandler_t syscall_table[SYSCALL_END]; 46 49 47 50 #endif 51 52 #endif -
generic/src/main/kinit.c
r78a95d6f r6d9c49a 139 139 interrupts_enable(); 140 140 141 ipc_create_phonecompany(); 142 141 143 if (config.init_size > 0) { 142 144 /* -
generic/src/main/main.c
r78a95d6f r6d9c49a 55 55 #include <arch/faddr.h> 56 56 #include <typedefs.h> 57 #include <ipc/ipc.h> 57 58 58 59 #ifdef CONFIG_SMP … … 191 192 if (config.init_size > 0) 192 193 printf("config.init_addr=%P, config.init_size=%d\n", config.init_addr, config.init_size); 193 194 195 ipc_init(); 194 196 /* 195 197 * Create kernel task. -
generic/src/proc/task.c
r78a95d6f r6d9c49a 36 36 #include <panic.h> 37 37 #include <adt/list.h> 38 #include <ipc/ipc.h> 39 #include <memstr.h> 38 40 39 41 SPINLOCK_INITIALIZE(tasks_lock); … … 71 73 list_initialize(&ta->tasks_link); 72 74 ta->as = as; 75 76 ipc_answerbox_init(&ta->answerbox); 77 memsetb((__address)&ta->phones, sizeof(ta->phones[0])*IPC_MAX_PHONES, 0); 78 if (ipc_central_box) 79 ipc_phone_init(&ta->phones[0], ipc_central_box); 73 80 74 81 ipl = interrupts_disable(); -
generic/src/syscall/syscall.c
r78a95d6f r6d9c49a 31 31 #include <print.h> 32 32 #include <putchar.h> 33 #include <ipc/ipc.h> 34 #include <errno.h> 35 #include <proc/task.h> 36 #include <arch.h> 37 #include <debug.h> 33 38 34 intsys_ctl(void) {39 static __native sys_ctl(void) { 35 40 printf("Thread finished\n"); 36 41 thread_exit(); … … 39 44 } 40 45 41 intsys_io(int fd, const void * buf, size_t count) {46 static __native sys_io(int fd, const void * buf, size_t count) { 42 47 43 48 // TODO: buf sanity checks and a lot of other stuff ... … … 51 56 } 52 57 58 /** Send a call over syscall 59 * 60 * @return Call identification, returns -1 on fatal error, 61 -2 on 'Too many async request, handle answers first 62 */ 63 static __native sys_ipc_call(__native phoneid, __native arg1, __native arg2) 64 { 65 call_t *call; 66 phone_t *phone; 67 68 if (phoneid >= IPC_MAX_PHONES) 69 return -ENOENT; 70 71 phone = &TASK->phones[phoneid]; 72 if (!phone->callee) 73 return -ENOENT; 74 75 76 /* TODO: Check that we did not exceed system imposed maximum 77 * of asynchrnously sent messages 78 * - the userspace should be able to handle it correctly 79 */ 80 call = ipc_call_alloc(); 81 call->data[0] = arg1; 82 call->data[1] = arg2; 83 ipc_call(phone, call); 84 85 return (__native) call; 86 } 87 88 /** Send IPC answer */ 89 static __native sys_ipc_answer(__native callid, __native arg1, __native arg2) 90 { 91 call_t *call; 92 93 /* Check that the user is not sending us answer callid */ 94 ASSERT(! (callid & 1)); 95 /* TODO: Check that the callid is in the dispatch table */ 96 call = (call_t *) callid; 97 98 call->data[0] = arg1; 99 call->data[1] = arg2; 100 101 ipc_answer(&TASK->answerbox, call); 102 return 0; 103 } 104 105 /** Wait for incoming ipc call or answer 106 * 107 * @param result 108 * @param flags 109 * @return Callid, if callid & 1, then the call is answer 110 */ 111 static __native sys_ipc_wait_for_call(__native *calldata, __native flags) 112 { 113 call_t *call; 114 115 call = ipc_wait_for_call(&TASK->answerbox, flags); 116 copy_to_uspace(calldata, &call->data, sizeof(__native) * IPC_CALL_LEN); 117 118 if (call->flags & IPC_CALL_ANSWERED) 119 return ((__native)call) | 1; 120 return (__native)call; 121 } 122 123 53 124 syshandler_t syscall_table[SYSCALL_END] = { 54 125 sys_ctl, 55 sys_io 126 sys_io, 127 sys_ipc_call, 128 sys_ipc_answer, 129 sys_ipc_wait_for_call 56 130 };
Note:
See TracChangeset
for help on using the changeset viewer.
