Make syscalls accept their interrupt frame, remove useless intr_eoi() param
This commit is contained in:
@ -17,8 +17,6 @@
|
|||||||
#include "proc/ps2kbproc/ps2kbproc.h"
|
#include "proc/ps2kbproc/ps2kbproc.h"
|
||||||
#include "rbuf/rbuf.h"
|
#include "rbuf/rbuf.h"
|
||||||
|
|
||||||
IntrStackFrame *INTR_CURRENT_FRAME;
|
|
||||||
|
|
||||||
typedef struct BackTraceFrame {
|
typedef struct BackTraceFrame {
|
||||||
struct BackTraceFrame *rbp;
|
struct BackTraceFrame *rbp;
|
||||||
uint64_t rip;
|
uint64_t rip;
|
||||||
@ -182,7 +180,7 @@ void hal_syscalldispatch(IntrStackFrame *frame) {
|
|||||||
}
|
}
|
||||||
uint64_t cr3;
|
uint64_t cr3;
|
||||||
asm volatile("mov %%cr3, %0" : "=r"(cr3));
|
asm volatile("mov %%cr3, %0" : "=r"(cr3));
|
||||||
int32_t ret = fn(frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
|
int32_t ret = fn(frame, frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
|
||||||
frame->regs.r10, frame->regs.r8, frame->regs.r9);
|
frame->regs.r10, frame->regs.r8, frame->regs.r9);
|
||||||
|
|
||||||
if (ret == E_DOSCHEDULING) {
|
if (ret == E_DOSCHEDULING) {
|
||||||
@ -192,14 +190,12 @@ void hal_syscalldispatch(IntrStackFrame *frame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void intr_eoi(uint8_t irq) {
|
void intr_eoi() {
|
||||||
io_out8(PIC2_CMD, PIC_EOI);
|
io_out8(PIC2_CMD, PIC_EOI);
|
||||||
io_out8(PIC1_CMD, PIC_EOI);
|
io_out8(PIC1_CMD, PIC_EOI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void intr_handleintr(IntrStackFrame *frame) {
|
void intr_handleintr(IntrStackFrame *frame) {
|
||||||
INTR_CURRENT_FRAME = frame;
|
|
||||||
|
|
||||||
if (frame->trapnum <= 31) {
|
if (frame->trapnum <= 31) {
|
||||||
kprintf("ERROR %s, 0x%lX\n", exceptions[frame->trapnum], frame->errnum);
|
kprintf("ERROR %s, 0x%lX\n", exceptions[frame->trapnum], frame->errnum);
|
||||||
intr_dumpframe(frame);
|
intr_dumpframe(frame);
|
||||||
@ -214,7 +210,7 @@ void intr_handleintr(IntrStackFrame *frame) {
|
|||||||
switch (frame->trapnum) {
|
switch (frame->trapnum) {
|
||||||
case INTR_IRQBASE+0:
|
case INTR_IRQBASE+0:
|
||||||
PIT_TICKS++;
|
PIT_TICKS++;
|
||||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
intr_eoi();
|
||||||
proc_sched((void *)frame);
|
proc_sched((void *)frame);
|
||||||
break;
|
break;
|
||||||
case INTR_IRQBASE+1:
|
case INTR_IRQBASE+1:
|
||||||
@ -225,7 +221,7 @@ void intr_handleintr(IntrStackFrame *frame) {
|
|||||||
rbuf_push(&PS2KB_BUF.rbuf, b);
|
rbuf_push(&PS2KB_BUF.rbuf, b);
|
||||||
spinlock_release(&PS2KB_BUF.spinlock);
|
spinlock_release(&PS2KB_BUF.spinlock);
|
||||||
}
|
}
|
||||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
intr_eoi();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (frame->trapnum == 0x80) {
|
} else if (frame->trapnum == 0x80) {
|
||||||
|
@ -35,6 +35,4 @@ typedef struct {
|
|||||||
|
|
||||||
void intr_init(void);
|
void intr_init(void);
|
||||||
|
|
||||||
IntrStackFrame *INTR_CURRENT_FRAME;
|
|
||||||
|
|
||||||
#endif // HAL_INTR_H_
|
#endif // HAL_INTR_H_
|
||||||
|
@ -11,9 +11,7 @@ int32_t SYSCALL0(sys_schedrelease) {
|
|||||||
Proc *proc = PROCS.current;
|
Proc *proc = PROCS.current;
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
if (INTR_CURRENT_FRAME != NULL) {
|
proc_sched((void *)frame);
|
||||||
proc_sched((void *)INTR_CURRENT_FRAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "compiler/attr.h"
|
#include "compiler/attr.h"
|
||||||
|
#include "hal/hal.h"
|
||||||
|
|
||||||
#define SYSCALLS_MAX 0xff
|
#define SYSCALLS_MAX 0xff
|
||||||
|
|
||||||
#define SYSCALL0(name) \
|
#define SYSCALL0(name) \
|
||||||
name(UNUSED uint64_t _1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
UNUSED uint64_t _1, \
|
||||||
UNUSED uint64_t _2, \
|
UNUSED uint64_t _2, \
|
||||||
UNUSED uint64_t _3, \
|
UNUSED uint64_t _3, \
|
||||||
UNUSED uint64_t _4, \
|
UNUSED uint64_t _4, \
|
||||||
@ -16,7 +18,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL1(name, arg1) \
|
#define SYSCALL1(name, arg1) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
UNUSED uint64_t _2, \
|
UNUSED uint64_t _2, \
|
||||||
UNUSED uint64_t _3, \
|
UNUSED uint64_t _3, \
|
||||||
UNUSED uint64_t _4, \
|
UNUSED uint64_t _4, \
|
||||||
@ -25,7 +28,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL2(name, arg1, arg2) \
|
#define SYSCALL2(name, arg1, arg2) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
uint64_t arg2, \
|
uint64_t arg2, \
|
||||||
UNUSED uint64_t _3, \
|
UNUSED uint64_t _3, \
|
||||||
UNUSED uint64_t _4, \
|
UNUSED uint64_t _4, \
|
||||||
@ -34,7 +38,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL3(name, arg1, arg2, arg3) \
|
#define SYSCALL3(name, arg1, arg2, arg3) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
uint64_t arg2, \
|
uint64_t arg2, \
|
||||||
uint64_t arg3, \
|
uint64_t arg3, \
|
||||||
UNUSED uint64_t _4, \
|
UNUSED uint64_t _4, \
|
||||||
@ -43,7 +48,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL4(name, arg1, arg2, arg3, arg4) \
|
#define SYSCALL4(name, arg1, arg2, arg3, arg4) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
uint64_t arg2, \
|
uint64_t arg2, \
|
||||||
uint64_t arg3, \
|
uint64_t arg3, \
|
||||||
uint64_t arg4, \
|
uint64_t arg4, \
|
||||||
@ -52,7 +58,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \
|
#define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
uint64_t arg2, \
|
uint64_t arg2, \
|
||||||
uint64_t arg3, \
|
uint64_t arg3, \
|
||||||
uint64_t arg4, \
|
uint64_t arg4, \
|
||||||
@ -61,7 +68,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
|
#define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||||
name(uint64_t arg1, \
|
name(IntrStackFrame *frame, \
|
||||||
|
uint64_t arg1, \
|
||||||
uint64_t arg2, \
|
uint64_t arg2, \
|
||||||
uint64_t arg3, \
|
uint64_t arg3, \
|
||||||
uint64_t arg4, \
|
uint64_t arg4, \
|
||||||
@ -69,7 +77,7 @@
|
|||||||
uint64_t arg6 \
|
uint64_t arg6 \
|
||||||
)
|
)
|
||||||
|
|
||||||
typedef int32_t (*SyscallFn)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
|
typedef int32_t (*SyscallFn)(IntrStackFrame *, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
|
||||||
|
|
||||||
extern SyscallFn SYSCALL_TABLE[SYSCALLS_MAX];
|
extern SyscallFn SYSCALL_TABLE[SYSCALLS_MAX];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user