Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1072 → Rev 1070

/kernel/trunk/generic/include/ipc/ipcrsc.h
File deleted
/kernel/trunk/generic/include/ipc/ipc.h
176,7 → 176,6
extern void task_print_list(void);
 
extern answerbox_t *ipc_phone_0;
extern void ipc_cleanup(task_t *task);
 
#endif
 
/kernel/trunk/generic/src/ipc/ipcrsc.c
File deleted
/kernel/trunk/generic/src/ipc/sysipc.c
35,7 → 35,6
#include <debug.h>
#include <ipc/ipc.h>
#include <ipc/sysipc.h>
#include <ipc/ipcrsc.h>
 
 
#include <print.h>
65,6 → 64,72
return 1;
}
 
/** Find call_t * in call table according to callid
*
* @return NULL on not found, otherwise pointer to call structure
*/
static inline call_t * get_call(__native callid)
{
/* TODO: Traverse list of dispatched calls and find one */
/* TODO: locking of call, ripping it from dispatched calls etc. */
return (call_t *) callid;
}
 
/** Return pointer to phone identified by phoneid or NULL if non-existent */
static phone_t * get_phone(__native phoneid)
{
phone_t *phone;
 
if (phoneid >= IPC_MAX_PHONES)
return NULL;
 
phone = &TASK->phones[phoneid];
if (!phone->callee)
return NULL;
return phone;
}
 
/** Allocate new phone slot in current TASK structure */
static int phone_alloc(void)
{
int i;
 
spinlock_lock(&TASK->lock);
for (i=0; i < IPC_MAX_PHONES; i++) {
if (!TASK->phones[i].busy) {
TASK->phones[i].busy = 1;
break;
}
}
spinlock_unlock(&TASK->lock);
 
if (i >= IPC_MAX_PHONES)
return -1;
return i;
}
 
/** Disconnect phone */
static void phone_dealloc(int phoneid)
{
spinlock_lock(&TASK->lock);
 
ASSERT(TASK->phones[phoneid].busy);
 
if (TASK->phones[phoneid].callee)
ipc_phone_destroy(&TASK->phones[phoneid]);
 
TASK->phones[phoneid].busy = 0;
spinlock_unlock(&TASK->lock);
}
 
static void phone_connect(int phoneid, answerbox_t *box)
{
phone_t *phone = &TASK->phones[phoneid];
ipc_phone_connect(phone, box);
}
 
/****************************************************/
/* Functions that preprocess answer before sending
* it to the recepient
147,13 → 212,13
call_t call;
phone_t *phone;
 
phone = get_phone(phoneid);
if (!phone)
return ENOENT;
 
if (is_system_method(method))
return EPERM;
 
phone = get_phone_and_lock(phoneid);
if (!phone)
return ENOENT;
 
ipc_call_init(&call);
IPC_SET_METHOD(call.data, method);
IPC_SET_ARG1(call.data, arg1);
172,6 → 237,10
call_t call;
phone_t *phone;
 
phone = get_phone(phoneid);
if (!phone)
return ENOENT;
 
ipc_call_init(&call);
copy_from_uspace(&call.data, question, sizeof(call.data));
 
178,10 → 247,6
if (is_system_method(IPC_GET_METHOD(call.data)))
return EPERM;
phone = get_phone_and_lock(phoneid);
if (!phone)
return ENOENT;
 
ipc_call_sync(phone, &call);
 
copy_to_uspace(reply, &call.data, sizeof(call.data));
213,6 → 278,10
call_t *call;
phone_t *phone;
 
phone = get_phone(phoneid);
if (!phone)
return IPC_CALLRET_FATAL;
 
if (is_system_method(method))
return IPC_CALLRET_FATAL;
 
219,10 → 288,6
if (check_call_limit())
return IPC_CALLRET_TEMPORARY;
 
phone = get_phone_and_lock(phoneid);
if (!phone)
return IPC_CALLRET_FATAL;
 
call = ipc_call_alloc();
IPC_SET_METHOD(call->data, method);
IPC_SET_ARG1(call->data, arg1);
242,13 → 307,13
call_t *call;
phone_t *phone;
 
phone = get_phone(phoneid);
if (!phone)
return IPC_CALLRET_FATAL;
 
if (check_call_limit())
return IPC_CALLRET_TEMPORARY;
 
phone = get_phone_and_lock(phoneid);
if (!phone)
return IPC_CALLRET_FATAL;
 
call = ipc_call_alloc();
copy_from_uspace(&call->data, data, sizeof(call->data));
 
279,7 → 344,7
if (!call)
return ENOENT;
 
phone = get_phone_and_lock(phoneid);
phone = get_phone(phoneid);
if (!phone) {
IPC_SET_RETVAL(call->data, EFORWARD);
ipc_answer(&TASK->answerbox, call);
371,15 → 436,15
call_t call;
phone_t *phone;
 
phone = get_phone(phoneid);
if (!phone)
return ENOENT;
 
ipc_call_init(&call);
IPC_SET_METHOD(call.data, IPC_M_CONNECTTOME);
IPC_SET_ARG1(call.data, arg1);
IPC_SET_ARG2(call.data, arg2);
phone = get_phone_and_lock(phoneid);
if (!phone)
return ENOENT;
 
ipc_call_sync(phone, &call);
 
if (!IPC_GET_RETVAL(call.data) && taskid)
401,7 → 466,7
phone_t *phone;
int newphid;
 
phone = get_phone_and_lock(phoneid);
phone = get_phone(phoneid);
if (!phone)
return ENOENT;
 
/kernel/trunk/generic/src/ipc/ipc.c
243,13 → 243,3
0,
NULL, NULL, 0);
}
 
/** Cleans up all IPC communication of the given task
*
*
*/
void ipc_cleanup(task_t *task)
{
/* Cancel all calls in my dispatch queue */
}
/kernel/trunk/generic/src/console/cmd.c
302,6 → 302,14
.argv = &zone_argv
};
 
static int cmd_hello(cmd_arg_t *argv);
static cmd_info_t hello_info = {
.name = "hello",
.description = "Hello Message",
.func = cmd_hello,
.argc = 0
};
 
/** Data and methods for 'cpus' command. */
static int cmd_cpus(cmd_arg_t *argv);
cmd_info_t cpus_info = {
344,6 → 352,7
&version_info,
&zones_info,
&zone_info,
&hello_info,
NULL
};
 
696,3 → 705,10
version_print();
return 1;
}
 
 
int cmd_hello(cmd_arg_t *argv)
{
printf("\nHello, World !!!\n");
return 1;
}
/kernel/trunk/arch/amd64/include/debugger.h
File deleted
/kernel/trunk/arch/amd64/include/interrupt.h
53,7 → 53,6
#error Wrong definition of VECTOR_APIC_SPUR
#endif
 
#define VECTOR_DEBUG 1
#define VECTOR_PIC_SPUR (IVT_IRQBASE+IRQ_PIC_SPUR)
#define VECTOR_CLK (IVT_IRQBASE+IRQ_CLK)
#define VECTOR_KBD (IVT_IRQBASE+IRQ_KBD)
/kernel/trunk/arch/amd64/include/asm.h
141,6 → 141,56
return v;
}
 
/** Read CR0
*
* Return value in CR0
*
* @return Value read.
*/
static inline __u64 read_cr0(void)
{
__u64 v;
__asm__ volatile ("movq %%cr0,%0\n" : "=r" (v));
return v;
}
 
/** Read CR2
*
* Return value in CR2
*
* @return Value read.
*/
static inline __u64 read_cr2(void)
{
__u64 v;
__asm__ volatile ("movq %%cr2,%0\n" : "=r" (v));
return v;
}
 
/** Write CR3
*
* Write value to CR3.
*
* @param v Value to be written.
*/
static inline void write_cr3(__u64 v)
{
__asm__ volatile ("movq %0,%%cr3\n" : : "r" (v));
}
 
/** Read CR3
*
* Return value in CR3
*
* @return Value read.
*/
static inline __u64 read_cr3(void)
{
__u64 v;
__asm__ volatile ("movq %%cr3,%0" : "=r" (v));
return v;
}
 
/** Write to MSR */
static inline void write_msr(__u32 msr, __u64 value)
{
200,38 → 250,6
__asm__ volatile ("invlpg %0\n" :: "m" (*((__native *)addr)));
}
 
#define GEN_READ_REG(reg) static inline __native read_ ##reg (void) \
{ \
__native res; \
__asm__ volatile ("movq %%" #reg ", %0" : "=r" (res) ); \
return res; \
}
 
#define GEN_WRITE_REG(reg) static inline void write_ ##reg (__native regn) \
{ \
__asm__ volatile ("movq %0, %%" #reg : : "r" (regn)); \
}
 
GEN_READ_REG(cr0);
GEN_READ_REG(cr2);
GEN_READ_REG(cr3);
GEN_WRITE_REG(cr3);
 
GEN_READ_REG(dr0);
GEN_READ_REG(dr1);
GEN_READ_REG(dr2);
GEN_READ_REG(dr3);
GEN_READ_REG(dr6);
GEN_READ_REG(dr7);
 
GEN_WRITE_REG(dr0);
GEN_WRITE_REG(dr1);
GEN_WRITE_REG(dr2);
GEN_WRITE_REG(dr3);
GEN_WRITE_REG(dr6);
GEN_WRITE_REG(dr7);
 
 
extern size_t interrupt_handler_size;
extern void interrupt_handlers(void);
 
/kernel/trunk/arch/amd64/include/cpu.h
29,7 → 29,6
#ifndef __amd64_CPU_H__
#define __amd64_CPU_H__
 
#define RFLAGS_RF (1 << 16)
 
#define EFER_MSR_NUM 0xc0000080
#define AMD_SCE_FLAG 0
/kernel/trunk/arch/amd64/src/debugger.c
File deleted
/kernel/trunk/arch/amd64/src/proc/scheduler.c
32,7 → 32,6
#include <arch.h>
#include <arch/context.h> /* SP_DELTA */
#include <arch/asm.h>
#include <arch/debugger.h>
 
void before_thread_runs_arch(void)
{
43,16 → 42,6
write_msr(AMD_MSR_GS,
(__u64)&THREAD->kstack);
swapgs();
 
 
#ifdef CONFIG_DEBUG_AS_WATCHPOINT
/* Set watchpoint on AS to ensure that nobody sets it to zero */
static int old_slot = -1;
if (old_slot >=0)
breakpoint_del(old_slot);
old_slot = breakpoint_add(&((the_t *) THREAD->kstack)->as,
BKPOINT_WRITE | BKPOINT_CHECK_ZERO);
#endif
}
 
void after_thread_ran_arch(void)
/kernel/trunk/arch/amd64/src/amd64.c
46,7 → 46,6
#include <panic.h>
#include <interrupt.h>
#include <arch/syscall.h>
#include <arch/debugger.h>
 
/** Disable I/O on non-privileged levels
*
130,12 → 129,10
{
if (config.cpu_active == 1) {
ega_init(); /* video */
/* Enable debugger */
debugger_init();
}
/* Setup fast SYSCALL/SYSRET */
syscall_setup_cpu();
 
}
 
void arch_pre_smp_init(void)
/kernel/trunk/arch/amd64/Makefile.inc
103,8 → 103,7
arch/$(ARCH)/src/cpu/cpu.c \
arch/$(ARCH)/src/proc/scheduler.c \
arch/$(ARCH)/src/userspace.c \
arch/$(ARCH)/src/syscall.c \
arch/$(ARCH)/src/debugger.c
arch/$(ARCH)/src/syscall.c
 
ifeq ($(CONFIG_SMP),y)
ARCH_SOURCES += \
/kernel/trunk/Makefile
69,9 → 69,6
ifeq ($(CONFIG_DEBUG_SPINLOCK),y)
DEFS += -DCONFIG_DEBUG_SPINLOCK
endif
ifeq ($(CONFIG_DEBUG_AS_WATCHPOINT),y)
DEFS += -DCONFIG_DEBUG_AS_WATCHPOINT
endif
ifeq ($(CONFIG_FPU_LAZY),y)
DEFS += -DCONFIG_FPU_LAZY
endif
138,8 → 135,7
generic/src/synch/waitq.c \
generic/src/smp/ipi.c \
generic/src/ipc/ipc.c \
generic/src/ipc/sysipc.c \
generic/src/ipc/ipcrsc.c
generic/src/ipc/sysipc.c
 
## Test sources
#
/kernel/trunk/kernel.config
70,9 → 70,6
# Deadlock detection support for spinlocks
! [CONFIG_DEBUG=y&CONFIG_SMP=y] CONFIG_DEBUG_SPINLOCK (y/n)
 
# Watchpoint on rewriting AS with zero
! [CONFIG_DEBUG=y&ARCH=amd64] CONFIG_DEBUG_AS_WATCHPOINT (y/n)
 
## Run-time configuration directives
 
# Kernel test type