From 7f5d3d3799955d4ef380bb9199a8e32c6dc72ae1 Mon Sep 17 00:00:00 2001 From: bernie Date: Fri, 24 Feb 2006 01:17:44 +0000 Subject: [PATCH] Update for new emulator. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@555 38d2e660-2303-0410-9eaa-f027e97ec537 --- kern/monitor.c | 24 ++++++++++++++---------- kern/monitor.h | 7 +++++-- kern/proc.c | 7 ++++++- kern/sem.c | 14 ++++++++------ kern/signal.c | 9 ++++++--- kern/switch_dsp56k.c | 7 +++++-- kern/switch_x86_64.s | 25 ++++++++++--------------- mware/event.h | 5 ++++- 8 files changed, 58 insertions(+), 40 deletions(-) diff --git a/kern/monitor.c b/kern/monitor.c index a64fceb2..babdb72f 100755 --- a/kern/monitor.c +++ b/kern/monitor.c @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.6 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.5 2005/11/04 16:20:02 bernie *#* Fix reference to README.devlib in header. *#* @@ -79,9 +82,9 @@ void monitor_rename(Process *proc, const char* name) } #define MONITOR_NODE_TO_PROCESS(node) \ - (struct Process*)((char*)(node) - offsetof(struct Process, monitor.link)) + (struct Process *)((char *)(node) - offsetof(struct Process, monitor.link)) -size_t monitor_check_stack(cpustack_t* stack_base, size_t stack_size) +size_t monitor_checkStack(cpustack_t* stack_base, size_t stack_size) { cpustack_t* beg; cpustack_t* cur; @@ -120,38 +123,39 @@ void monitor_report(void) struct Process* p; int i; - if (ISLISTEMPTY(&MonitorProcs)) + if (LIST_EMPTY(&MonitorProcs)) { kputs("No stacks registered in the monitor\n"); return; } - kprintf("%-24s %-6s%-8s%-8s%-8s\n", "Process name", "TCB", "SPbase", "SPsize", "SPfree"); + kprintf("%-24s%-8s%-8s%-8s%-8s\n", "Process name", "TCB", "SPbase", "SPsize", "SPfree"); for (i=0;i<56;i++) kputchar('-'); kputchar('\n'); - for (p = MONITOR_NODE_TO_PROCESS(MonitorProcs.head); + for (p = MONITOR_NODE_TO_PROCESS(LIST_HEAD(&MonitorProcs)); p->monitor.link.succ; p = MONITOR_NODE_TO_PROCESS(p->monitor.link.succ)) { - size_t free = monitor_check_stack(p->monitor.stack_base, p->monitor.stack_size); - kprintf("%-24s %04x %04x %4x %4x\n", p->monitor.name, (uint16_t)p, (uint16_t)p->monitor.stack_base, (uint16_t)p->monitor.stack_size, (uint16_t)free); + size_t free = monitor_checkStack(p->monitor.stack_base, p->monitor.stack_size); + kprintf("%-24s%8p%8p%8lx%8lx\n", + p->monitor.name, p, p->monitor.stack_base, p->monitor.stack_size, free); } } -static void monitor(void) +static void NORETURN monitor(void) { struct Process* p; while (1) { - for (p = MONITOR_NODE_TO_PROCESS(MonitorProcs.head); + for (p = MONITOR_NODE_TO_PROCESS(LIST_HEAD(&MonitorProcs)); p->monitor.link.succ; p = MONITOR_NODE_TO_PROCESS(p->monitor.link.succ)) { - size_t free = monitor_check_stack(p->monitor.stack_base, p->monitor.stack_size); + size_t free = monitor_checkStack(p->monitor.stack_base, p->monitor.stack_size); if (free < 0x20) { diff --git a/kern/monitor.h b/kern/monitor.h index 352d83b7..3703641f 100755 --- a/kern/monitor.h +++ b/kern/monitor.h @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.4 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.3 2005/11/04 16:20:02 bernie *#* Fix reference to README.devlib in header. *#* @@ -33,7 +36,7 @@ #define KERN_MONITOR_H #include -#include +#include #if CONFIG_KERN_MONITOR @@ -58,7 +61,7 @@ void monitor_start(size_t stacksize, cpustack_t *stack); * \note For this function to work, the stack must have been filled at startup with * CONFIG_KERN_STACKFILLCODE. */ -size_t monitor_check_stack(cpustack_t* stack_base, size_t stack_size); +size_t monitor_checkStack(cpustack_t *stack_base, size_t stack_size); /*! Print a report of the stack status through kdebug */ diff --git a/kern/proc.c b/kern/proc.c index 24f93d48..495ca735 100755 --- a/kern/proc.c +++ b/kern/proc.c @@ -17,6 +17,9 @@ /*#* *#* $Log$ + *#* Revision 1.29 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.28 2006/02/21 16:06:55 bernie *#* Cleanup/update process scheduling. *#* @@ -308,12 +311,14 @@ void proc_schedule(void) /* Remember old process to save its context later */ old_process = CurrentProcess; +#ifdef IRQ_RUNNING /* Scheduling in interrupts is a nono. */ ASSERT(!IRQ_RUNNING()); +#endif /* Poll on the ready queue for the first ready process */ IRQ_SAVE_DISABLE(flags); - while (!(CurrentProcess = (struct Process *)REMHEAD(&ProcReadyList))) + while (!(CurrentProcess = (struct Process *)list_remHead(&ProcReadyList))) { /* * Make sure we physically reenable interrupts here, no matter what diff --git a/kern/sem.c b/kern/sem.c index 6f1a773f..7b3b4729 100755 --- a/kern/sem.c +++ b/kern/sem.c @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.11 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.10 2005/11/04 16:20:02 bernie *#* Fix reference to README.devlib in header. *#* @@ -47,10 +50,9 @@ *#*/ #include "sem.h" -#include "proc.h" -#include "proc_p.h" -#include "signal.h" -#include "hw.h" +#include +#include +#include #include INLINE void sem_verify(struct Semaphore *s) @@ -139,7 +141,7 @@ void sem_obtain(struct Semaphore *s) } else { - ASSERT(ISLISTEMPTY(&s->wait_queue)); + ASSERT(LIST_EMPTY(&s->wait_queue)); /* The semaphore was free: lock it */ s->owner = CurrentProcess; @@ -181,7 +183,7 @@ void sem_release(struct Semaphore *s) s->owner = NULL; /* Give semaphore to the first applicant, if any */ - if (UNLIKELY((proc = (Process *)REMHEAD(&s->wait_queue)))) + if (UNLIKELY((proc = (Process *)list_remHead(&s->wait_queue)))) { s->nest_count = 1; s->owner = proc; diff --git a/kern/signal.c b/kern/signal.c index e4e0522a..841ac6eb 100755 --- a/kern/signal.c +++ b/kern/signal.c @@ -66,6 +66,9 @@ /*#* *#* $Log$ + *#* Revision 1.13 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.12 2005/11/04 16:20:02 bernie *#* Fix reference to README.devlib in header. *#* @@ -107,9 +110,9 @@ *#*/ #include "signal.h" -#include "proc.h" -#include "proc_p.h" -#include "hw.h" + +#include +#include #include #if CONFIG_KERN_SIGNALS diff --git a/kern/switch_dsp56k.c b/kern/switch_dsp56k.c index 988fb138..59f9788f 100755 --- a/kern/switch_dsp56k.c +++ b/kern/switch_dsp56k.c @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.6 2006/02/24 01:17:05 bernie + *#* Update for new emulator. + *#* *#* Revision 1.5 2005/11/04 16:20:02 bernie *#* Fix reference to README.devlib in header. *#* @@ -63,8 +66,8 @@ asm void asm_switch_context(void ** new_sp, void ** save_sp) move y1,x:(SP)+ move x:<$3F,y1 move y1,x:(SP) - - ; + + ; ; Switch stacks nop move SP, x:(R3) diff --git a/kern/switch_x86_64.s b/kern/switch_x86_64.s index 60a31e28..339c6676 100755 --- a/kern/switch_x86_64.s +++ b/kern/switch_x86_64.s @@ -15,6 +15,9 @@ /* * $Log$ + * Revision 1.2 2006/02/24 01:17:05 bernie + * Update for new emulator. + * * Revision 1.1 2005/11/27 03:06:15 bernie * Add x86_64 task switching (to be updated to new-style scheduler). * @@ -29,12 +32,11 @@ * */ -!!!!!! THIS FILE HAS NOT BEEN REVISED FOR THE NEW SCHEDULER API !!!!!! - /* I know it's ugly... */ #.intel_syntax -/* void AsmSwitchContext(void * new_sp, void ** save_sp) */ +/* void AsmSwitchContext(void **new_sp, void **save_sp) */ +/* %rdi %rsi .globl AsmSwitchContext AsmSwitchContext: pushq %rax @@ -45,7 +47,7 @@ AsmSwitchContext: pushq %rdi pushq %rbp movq %rsp,(%rsi) /* *save_sp = rsp */ - movq %rdi,%rsp /* rsp = new_sp */ + movq (%rdi),%rsp /* rsp = *new_sp */ popq %rbp popq %rdi popq %rsi @@ -55,16 +57,9 @@ AsmSwitchContext: popq %rax ret -/* void AsmReplaceContext(void * new_sp, void ** dummy) */ -.globl AsmReplaceContext -AsmReplaceContext: - movq %rdi,%rsp /* rsp = new_sp */ - popq %rbp - popq %rdi - popq %rsi - popq %rdx - popq %rcx - popq %rbx - popq %rax +/* int asm_switch_version(void) */ +.globl asm_switch_version +asm_switch_version: + mov $1,%rax ret diff --git a/mware/event.h b/mware/event.h index 23c1e9b8..25981380 100755 --- a/mware/event.h +++ b/mware/event.h @@ -18,6 +18,9 @@ /*#* *#* $Log$ + *#* Revision 1.6 2006/02/24 01:17:44 bernie + *#* Update for new emulator. + *#* *#* Revision 1.5 2006/02/24 00:26:21 bernie *#* Fix header name. *#* @@ -77,7 +80,7 @@ #if CONFIG_KERNEL #include #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS - #include "signal.h" + #include #endif #endif -- 2.34.1