Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 955 → Rev 952

/kernel/trunk/generic/include/errno.h
File deleted
/kernel/trunk/generic/include/ipc/ipc.h
File deleted
/kernel/trunk/generic/include/mm/page.h
32,7 → 32,6
#include <arch/mm/asid.h>
#include <arch/types.h>
#include <typedefs.h>
#include <memstr.h>
 
#define PAGE_CACHEABLE_SHIFT 0
#define PAGE_NOT_CACHEABLE_SHIFT PAGE_CACHEABLE_SHIFT
60,18 → 59,6
 
#define PAGE_GLOBAL (1<<PAGE_GLOBAL_SHIFT)
 
 
/* TODO - check that userspace is OK, platform specific functions etc */
static inline void copy_to_uspace(void *dst, void *src, count_t cnt)
{
memcpy(dst, src, cnt);
}
 
static inline void copy_to_kernel(void *dst, void *src, count_t cnt)
{
memcpy(dst, src, cnt);
}
 
/** Operations to manipulate page mappings. */
struct page_mapping_operations {
void (* mapping_insert)(as_t *as, __address page, __address frame, int flags);
/kernel/trunk/generic/include/proc/task.h
32,7 → 32,6
#include <typedefs.h>
#include <synch/spinlock.h>
#include <adt/list.h>
#include <ipc/ipc.h>
 
/** Task structure. */
struct task {
40,8 → 39,6
link_t th_head; /**< List of threads contained in this task. */
link_t tasks_link; /**< Link to other tasks within the system. */
as_t *as; /**< Address space. */
answerbox_t answerbox; /**< Communication endpoint */
phone_t phones[IPC_MAX_PHONES];
};
 
extern spinlock_t tasks_lock;
/kernel/trunk/generic/include/syscall/syscall.h
29,24 → 29,19
#ifndef __SYSCALL_H__
#define __SYSCALL_H__
 
#include <typedefs.h>
 
typedef enum {
SYS_CTL = 0,
SYS_IO = 1,
SYS_IPC_CALL = 2,
SYS_IPC_ANSWER = 3,
SYS_IPC_WAIT = 4,
SYSCALL_END
} syscall_t;
 
#ifdef KERNEL
typedef int (*syshandler_t)();
 
#include <arch/types.h>
#include <typedefs.h>
extern int sys_ctl(void);
extern int sys_io(int fd, const void *buf, size_t count);
 
typedef __native (*syshandler_t)();
 
extern syshandler_t syscall_table[SYSCALL_END];
 
#endif
 
#endif
/kernel/trunk/generic/src/ipc/ipc.c
File deleted
/kernel/trunk/generic/src/main/kinit.c
138,8 → 138,6
 
interrupts_enable();
 
ipc_create_phonecompany();
 
if (config.init_size > 0) {
/*
* Create the first user task.
/kernel/trunk/generic/src/main/main.c
54,7 → 54,6
#include <arch.h>
#include <arch/faddr.h>
#include <typedefs.h>
#include <ipc/ipc.h>
 
#ifdef CONFIG_SMP
#include <arch/smp/apic.h>
191,8 → 190,7
if (config.init_size > 0)
printf("config.init_addr=%P, config.init_size=%d\n", config.init_addr, config.init_size);
ipc_init();
 
/*
* Create kernel task.
*/
/kernel/trunk/generic/src/proc/task.c
35,8 → 35,6
#include <arch.h>
#include <panic.h>
#include <adt/list.h>
#include <ipc/ipc.h>
#include <memstr.h>
 
SPINLOCK_INITIALIZE(tasks_lock);
LIST_INITIALIZE(tasks_head);
72,11 → 70,6
list_initialize(&ta->th_head);
list_initialize(&ta->tasks_link);
ta->as = as;
 
ipc_answerbox_init(&ta->answerbox);
memsetb((__address)&ta->phones, sizeof(ta->phones[0])*IPC_MAX_PHONES, 0);
if (ipc_central_box)
ipc_phone_init(&ta->phones[0], ipc_central_box);
ipl = interrupts_disable();
spinlock_lock(&tasks_lock);
/kernel/trunk/generic/src/syscall/syscall.c
30,13 → 30,8
#include <proc/thread.h>
#include <print.h>
#include <putchar.h>
#include <ipc/ipc.h>
#include <errno.h>
#include <proc/task.h>
#include <arch.h>
#include <debug.h>
 
static __native sys_ctl(void) {
int sys_ctl(void) {
printf("Thread finished\n");
thread_exit();
/* Unreachable */
43,7 → 38,7
return 0;
}
 
static __native sys_io(int fd, const void * buf, size_t count) {
int sys_io(int fd, const void * buf, size_t count) {
// TODO: buf sanity checks and a lot of other stuff ...
 
55,76 → 50,7
return count;
}
 
/** Send a call over syscall
*
* @return Call identification, returns -1 on fatal error,
-2 on 'Too many async request, handle answers first
*/
static __native sys_ipc_call(__native phoneid, __native arg1, __native arg2)
{
call_t *call;
phone_t *phone;
 
if (phoneid >= IPC_MAX_PHONES)
return -ENOENT;
 
phone = &TASK->phones[phoneid];
if (!phone->callee)
return -ENOENT;
 
 
/* TODO: Check that we did not exceed system imposed maximum
* of asynchrnously sent messages
* - the userspace should be able to handle it correctly
*/
call = ipc_call_alloc();
call->data[0] = arg1;
call->data[1] = arg2;
ipc_call(phone, call);
 
return (__native) call;
}
 
/** Send IPC answer */
static __native sys_ipc_answer(__native callid, __native arg1, __native arg2)
{
call_t *call;
 
/* Check that the user is not sending us answer callid */
ASSERT(! (callid & 1));
/* TODO: Check that the callid is in the dispatch table */
call = (call_t *) callid;
 
call->data[0] = arg1;
call->data[1] = arg2;
 
ipc_answer(&TASK->answerbox, call);
return 0;
}
 
/** Wait for incoming ipc call or answer
*
* @param result
* @param flags
* @return Callid, if callid & 1, then the call is answer
*/
static __native sys_ipc_wait_for_call(__native *calldata, __native flags)
{
call_t *call;
call = ipc_wait_for_call(&TASK->answerbox, flags);
copy_to_uspace(calldata, &call->data, sizeof(__native) * IPC_CALL_LEN);
 
if (call->flags & IPC_CALL_ANSWERED)
return ((__native)call) | 1;
return (__native)call;
}
 
 
syshandler_t syscall_table[SYSCALL_END] = {
sys_ctl,
sys_io,
sys_ipc_call,
sys_ipc_answer,
sys_ipc_wait_for_call
sys_io
};
/kernel/trunk/arch/ia32/include/types.h
47,7 → 47,6
typedef __u32 ipl_t;
 
typedef __u32 __native;
typedef __s32 __native;
 
typedef struct page_specifier pte_t;
 
/kernel/trunk/arch/ia32/src/interrupt.c
114,13 → 114,11
void syscall(int n, void *st)
{
__native *stack = (__native *) st;
 
interrupts_enable();
if (stack[-2] < SYSCALL_END)
stack[-2] = syscall_table[stack[-2]](stack[-5], stack[-3], stack[-4]);
else
panic("Undefined syscall %d", stack[-2]);
interrupts_disable();
}
 
void tlb_shootdown_ipi(int n, void *stack)
/kernel/trunk/arch/ia64/include/types.h
1,4 → 1,4
 
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
47,7 → 47,6
typedef __u64 ipl_t;
 
typedef __u64 __native;
typedef __s64 __native;
 
typedef struct pte pte_t;
 
/kernel/trunk/arch/mips32/include/types.h
48,7 → 48,6
typedef __u32 ipl_t;
 
typedef __u32 __native;
typedef __s32 __snative;
 
typedef struct pte pte_t;
 
/kernel/trunk/arch/mips32/src/exception.c
133,7 → 133,6
/** Handle syscall userspace call */
static void syscall_exception(int n, struct exception_regdump *pstate)
{
interrupts_enable();
if (pstate->a3 < SYSCALL_END)
pstate->v0 = syscall_table[pstate->a3](pstate->a0,
pstate->a1,
140,7 → 139,6
pstate->a2);
else
panic("Undefined syscall %d", pstate->a3);
interrupts_disable();
pstate->epc += 4;
}
 
/kernel/trunk/arch/sparc64/include/types.h
47,7 → 47,6
typedef __u64 ipl_t;
 
typedef __u64 __native;
typedef __s64 __native;
 
typedef struct pte pte_t;
 
/kernel/trunk/arch/amd64/include/types.h
48,7 → 48,6
typedef __u64 ipl_t;
 
typedef __u64 __native;
typedef __s64 __snative;
 
typedef struct page_specifier pte_t;
 
/kernel/trunk/arch/amd64/src/asm_utils.S
207,11 → 207,9
# Switch back to remain consistent
swapgs
 
sti
movq %r9, %rcx # Exchange last parameter as a third
call syscall_handler
cli # We will be touching stack pointer
popq %r11
popq %rcx
movq 0(%rsp), %rsp
/kernel/trunk/arch/amd64/src/syscall.c
62,11 → 62,12
}
 
/** Dispatch system call */
__native syscall_handler(__native a1, __native a2, __native a3,
__native id)
__native syscall_handler(__native id, __native a1, __native a2, __native a3)
{
interrupts_enable();
if (id < SYSCALL_END)
return syscall_table[id](a1,a2,a3);
else
panic("Undefined syscall %d", id);
interrupts_disable();
}
/kernel/trunk/Makefile
44,7 → 44,7
## Common compiler flags
#
 
DEFS = -D$(ARCH) -DARCH=\"$(ARCH)\" -DRELEASE=\"$(RELEASE)\" "-DNAME=\"$(NAME)\"" -DKERNEL
DEFS = -D$(ARCH) -DARCH=\"$(ARCH)\" -DRELEASE=\"$(RELEASE)\" "-DNAME=\"$(NAME)\""
CFLAGS = -fno-builtin -fomit-frame-pointer -Wall -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/
LFLAGS = -M
AFLAGS =
133,8 → 133,7
generic/src/synch/mutex.c \
generic/src/synch/semaphore.c \
generic/src/synch/waitq.c \
generic/src/smp/ipi.c \
generic/src/ipc/ipc.c
generic/src/smp/ipi.c
 
## Test sources
#