entry: clean up assembly
This commit is contained in:
parent
37518aea81
commit
8cb6d80f8c
2 changed files with 68 additions and 110 deletions
|
|
@ -74,6 +74,15 @@ void console_input(char c)
|
||||||
}
|
}
|
||||||
} else if (c == '\n' || c == '\r') {
|
} else if (c == '\n' || c == '\r') {
|
||||||
console_write('\n');
|
console_write('\n');
|
||||||
|
if (strlen(console.line) >= 4 && !memcmp("exec", console.line, 4)) {
|
||||||
|
/* because this one doesn't return. i know it's bad, it will be changed later */
|
||||||
|
void lapic_eoi();
|
||||||
|
char line[512];
|
||||||
|
strcpy(line, console.line);
|
||||||
|
memset(console.line, 0, sizeof(console.line));
|
||||||
|
lapic_eoi();
|
||||||
|
kexec(line);
|
||||||
|
}
|
||||||
kexec(console.line);
|
kexec(console.line);
|
||||||
memset(console.line, 0, sizeof(console.line));
|
memset(console.line, 0, sizeof(console.line));
|
||||||
console.l_line = 0;
|
console.l_line = 0;
|
||||||
|
|
|
||||||
169
sched/entry.S
169
sched/entry.S
|
|
@ -3,6 +3,62 @@
|
||||||
#define __ASM__
|
#define __ASM__
|
||||||
#include <dev/serial.h>
|
#include <dev/serial.h>
|
||||||
|
|
||||||
|
.macro save_context
|
||||||
|
pushq %rax
|
||||||
|
pushq %rcx
|
||||||
|
pushq %rdx
|
||||||
|
pushq %rsi
|
||||||
|
pushq %rdi
|
||||||
|
pushq %r8
|
||||||
|
pushq %r9
|
||||||
|
pushq %r10
|
||||||
|
pushq %r11
|
||||||
|
|
||||||
|
/* get current task registers */
|
||||||
|
call proc_current_regs
|
||||||
|
|
||||||
|
/* save current task registers */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 80(%rax) /* r11 */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 72(%rax) /* r10 */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 64(%rax) /* r9 */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 56(%rax) /* r8 */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 40(%rax) /* rdi */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 32(%rax) /* rsi */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 24(%rax) /* rdx */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 16(%rax) /* rcx */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 0(%rax) /* rax */
|
||||||
|
|
||||||
|
/* save remaining registers */
|
||||||
|
movq %rbx, 8(%rax)
|
||||||
|
movq %rbp, 48(%rax)
|
||||||
|
movq %r12, 88(%rax)
|
||||||
|
movq %r13, 96(%rax)
|
||||||
|
movq %r14, 104(%rax)
|
||||||
|
movq %r15, 112(%rax)
|
||||||
|
|
||||||
|
/* save IRETQ frame */
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 120(%rax)
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 128(%rax)
|
||||||
|
popq %rdi
|
||||||
|
/* enable interrupts */
|
||||||
|
movq %rdi, 136(%rax)
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 144(%rax)
|
||||||
|
popq %rdi
|
||||||
|
movq %rdi, 152(%rax)
|
||||||
|
.endm
|
||||||
|
|
||||||
.macro push_regs
|
.macro push_regs
|
||||||
pushq %rax
|
pushq %rax
|
||||||
pushq %rbx
|
pushq %rbx
|
||||||
|
|
@ -69,60 +125,7 @@
|
||||||
.global _irq_\nr
|
.global _irq_\nr
|
||||||
_irq_\nr:
|
_irq_\nr:
|
||||||
cli
|
cli
|
||||||
/* push scratch registers */
|
save_context
|
||||||
pushq %rax
|
|
||||||
pushq %rcx
|
|
||||||
pushq %rdx
|
|
||||||
pushq %rsi
|
|
||||||
pushq %rdi
|
|
||||||
pushq %r8
|
|
||||||
pushq %r9
|
|
||||||
pushq %r10
|
|
||||||
pushq %r11
|
|
||||||
|
|
||||||
/* get current task registers */
|
|
||||||
call proc_current_regs
|
|
||||||
|
|
||||||
/* save current task registers */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 80(%rax) /* r11 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 72(%rax) /* r10 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 64(%rax) /* r9 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 56(%rax) /* r8 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 40(%rax) /* rdi */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 32(%rax) /* rsi */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 24(%rax) /* rdx */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 16(%rax) /* rcx */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 0(%rax) /* rax */
|
|
||||||
|
|
||||||
/* save remaining registers */
|
|
||||||
movq %rbx, 8(%rax)
|
|
||||||
movq %rbp, 48(%rax)
|
|
||||||
movq %r12, 88(%rax)
|
|
||||||
movq %r13, 96(%rax)
|
|
||||||
movq %r14, 104(%rax)
|
|
||||||
movq %r15, 112(%rax)
|
|
||||||
|
|
||||||
/* save IRETQ frame */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 120(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 128(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 136(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 144(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 152(%rax)
|
|
||||||
|
|
||||||
/* call irq handler */
|
/* call irq handler */
|
||||||
movq $\nr, %rdi
|
movq $\nr, %rdi
|
||||||
call irq
|
call irq
|
||||||
|
|
@ -193,65 +196,11 @@ irq 0x0F
|
||||||
.global gate_syscall
|
.global gate_syscall
|
||||||
gate_syscall:
|
gate_syscall:
|
||||||
cli
|
cli
|
||||||
/* push scratch registers */
|
save_context
|
||||||
pushq %rax
|
|
||||||
pushq %rcx
|
|
||||||
pushq %rdx
|
|
||||||
pushq %rsi
|
|
||||||
pushq %rdi
|
|
||||||
pushq %r8
|
|
||||||
pushq %r9
|
|
||||||
pushq %r10
|
|
||||||
pushq %r11
|
|
||||||
|
|
||||||
/* get current task registers */
|
|
||||||
call proc_current_regs
|
|
||||||
|
|
||||||
/* save current task registers */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 80(%rax) /* r11 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 72(%rax) /* r10 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 64(%rax) /* r9 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 56(%rax) /* r8 */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 40(%rax) /* rdi */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 32(%rax) /* rsi */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 24(%rax) /* rdx */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 16(%rax) /* rcx */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 0(%rax) /* rax */
|
|
||||||
|
|
||||||
/* save remaining registers */
|
|
||||||
movq %rbx, 8(%rax)
|
|
||||||
movq %rbp, 48(%rax)
|
|
||||||
movq %r12, 88(%rax)
|
|
||||||
movq %r13, 96(%rax)
|
|
||||||
movq %r14, 104(%rax)
|
|
||||||
movq %r15, 112(%rax)
|
|
||||||
|
|
||||||
/* save IRETQ frame */
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 120(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 128(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 136(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 144(%rax)
|
|
||||||
popq %rdi
|
|
||||||
movq %rdi, 152(%rax)
|
|
||||||
|
|
||||||
movq 0(%rax), %rdi /* syscall number */
|
movq 0(%rax), %rdi /* syscall number */
|
||||||
|
|
||||||
movq 40(%rax), %rsi /* arguments */
|
movq 40(%rax), %rsi /* arguments */
|
||||||
call syscall
|
|
||||||
|
|
||||||
|
call syscall
|
||||||
call schedule
|
call schedule
|
||||||
|
|
||||||
/* void return_from_irq(struct procregs *regs, paddr_t cr3); */
|
/* void return_from_irq(struct procregs *regs, paddr_t cr3); */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue