summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
04ee277)
chore: clean up unused fields
#define proc_hanged(proc) (((proc)->state) & PS_BLOCKED)
#define proc_runnable(proc) (((proc)->state) & PS_PAUSED)
#define proc_hanged(proc) (((proc)->state) & PS_BLOCKED)
#define proc_runnable(proc) (((proc)->state) & PS_PAUSED)
-#define PROC_FINPAUSE 1
-
struct sigact
{
struct sigact* prev;
struct sigact
{
struct sigact* prev;
{
/*
Any change to *critical section*, including layout, size
{
/*
Any change to *critical section*, including layout, size
- must be reflected in kernel/asm/x86/interrupt.S to avoid
+ must be reflected in arch/x86/interrupt.S.inc to avoid
disaster!
*/
/* ---- critical section start ---- */
disaster!
*/
/* ---- critical section start ---- */
- pid_t pid; // offset = 0
- struct proc_info* parent; // offset = 4
- isr_param* intr_ctx; // offset = 8
- ptr_t ustack_top; // offset = 84 -> 56 -> 60 -> 12
- ptr_t page_table; // offset = 88 -> 60 -> 64 -> 16
+ pid_t pid;
+ struct proc_info* parent;
+ isr_param* intr_ctx;
+ ptr_t ustack_top;
+ ptr_t page_table;
/* ---- critical section end ---- */
/* ---- critical section end ---- */
u8_t state;
int32_t exit_code;
int32_t k_status;
u8_t state;
int32_t exit_code;
int32_t k_status;
struct sighail sigctx;
struct v_fdtable* fdtable;
struct v_dnode* cwd;
struct sighail sigctx;
struct v_fdtable* fdtable;
struct v_dnode* cwd;
void
proc_setsignal(struct proc_info* proc, int signum);
void
proc_setsignal(struct proc_info* proc, int signum);
+void
+proc_clear_signal(struct proc_info* proc);
+
#endif /* __LUNAIX_PROCESS_H */
#endif /* __LUNAIX_PROCESS_H */
.section .text
.global interrupt_wrapper
interrupt_wrapper:
.section .text
.global interrupt_wrapper
interrupt_wrapper:
- /*
- Stack layout (layout of struct isr_param)
- msa: [ss] > 76 -> 28
- [esp] > 72 -> 24
- eflags > 68 -> 20
- cs > 64 -> 16
- eip > 60 -> 12
- err_code > 56 -> 8
- vector > offset = 52 -> 4
- [saved_prev_ctx] > offset = 0
- ---
- esp > 12 * 4 = 48
- gs
- fs
- es
- ds > offset = 8 * 4 = 32
- esi
- ebp
- edi
- edx
- ecx
- ebx
- eax
- lsa: depth > offset = 0
-
- las: Least Significant Address
- msa: Most Significant Address
- */
movw %ax, %ds
movw %ax, %es
movw %ax, %ds
movw %ax, %es
- movl __current, %eax
-
- # 保存用户栈顶指针。因为我们允许同级中断的产生,所以需要该手段跟踪用户栈的地址。
- movl iuesp(%esp), %ebx # 取出esp
- movl %ebx, proc_ustack_top(%eax) # 存入__current->ustack_top
# Save x87 context to user stack, rather than kernel's memory.
# Save x87 context to user stack, rather than kernel's memory.
- # XXX: what will happen if we triggered a page fault during fxsave?
+ # XXX what will happen if we triggered a page fault during fxsave?
+ # FIXME can we remove this overhead?
movl iuesp(%esp), %eax
andl $stack_alignment, %eax
subl $512, %eax
fxsave (%eax)
movl iuesp(%esp), %eax
andl $stack_alignment, %eax
subl $512, %eax
fxsave (%eax)
+ # 保存用户栈顶指针。因为我们允许同级中断的产生,所以需要该手段跟踪用户栈的地址。
+ movl %eax, proc_ustack_top(%ebx) # 存入__current->ustack_top
+
/* kernel space same-level switch */
1:
movl %esp, %eax
/* kernel space same-level switch */
1:
movl %esp, %eax
movl exeip(%eax), %eax
movl %eax, (debug_resv + 4) # eip
#endif
movl exeip(%eax), %eax
movl %eax, (debug_resv + 4) # eip
#endif
- // movl __current, %eax
- // movl proc_fxstate(%eax), %eax
-
- // test %eax, %eax # do we have stored x87 context?
movl ics(%esp), %eax
andl $3, %eax
jz 1f
movl ics(%esp), %eax
andl $3, %eax
jz 1f
- movl iuesp(%esp), %eax
- andl $stack_alignment, %eax
- subl $512, %eax
+ movl __current, %eax
+ movl proc_ustack_top(%eax), %eax
+ test %eax, %eax
+ jz 1f
movl %eax, tmp_store
movl __current, %eax
movl %eax, tmp_store
movl __current, %eax
# nested intr: restore saved context
popl proc_intr_ctx(%eax)
# nested intr: restore saved context
popl proc_intr_ctx(%eax)
movl %ecx, (tss_esp0_off + _tss)
jmp handle_signal
movl %ecx, (tss_esp0_off + _tss)
jmp handle_signal
1:
movl proc_intr_ctx(%ebx), %eax
jmp soft_iret
1:
movl proc_intr_ctx(%ebx), %eax
jmp soft_iret
execp->esp = container.stack_top;
execp->eip = container.exe.entry;
execp->esp = container.stack_top;
execp->eip = container.exe.entry;
+ // these become meaningless once execved!
+ __current->ustack_top = 0;
+ proc_clear_signal(__current);
+
done:
// set return value
store_retval(DO_STATUS(errno));
done:
// set return value
store_retval(DO_STATUS(errno));
+void
+proc_clear_signal(struct proc_info* proc)
+{
+ memset(&proc->sigctx, 0, sizeof(proc->sigctx));
+}
+
void
proc_setsignal(struct proc_info* proc, int signum)
{
void
proc_setsignal(struct proc_info* proc, int signum)
{