Compare commits
5 changed files with 16 additions and 62 deletions
|
|
@ -40,66 +40,34 @@
|
||||||
.macro exception nr
|
.macro exception nr
|
||||||
.global _exception_\nr
|
.global _exception_\nr
|
||||||
_exception_\nr:
|
_exception_\nr:
|
||||||
push 0
|
push_all
|
||||||
push \nr
|
mov rdi, \nr
|
||||||
jmp exception_common
|
call exception_handler
|
||||||
|
pop_all
|
||||||
|
iretq
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro exception_err nr
|
.macro exception_err nr
|
||||||
.global _exception_\nr
|
.global _exception_\nr
|
||||||
_exception_\nr:
|
_exception_\nr:
|
||||||
push \nr
|
pop rsi
|
||||||
jmp exception_common
|
push_all
|
||||||
|
mov rdi, \nr
|
||||||
|
call exception_handler
|
||||||
|
pop_all
|
||||||
|
iretq
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro irq nr
|
.macro irq nr
|
||||||
.global _irq_\nr
|
.global _irq_\nr
|
||||||
_irq_\nr:
|
_irq_\nr:
|
||||||
push \nr
|
push_all
|
||||||
jmp irq_common
|
mov rdi, \nr
|
||||||
|
call irq_handler
|
||||||
|
pop_all
|
||||||
|
iretq
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
exception_common:
|
|
||||||
test qword ptr [rsp + 24], 3 /* is this from userspace? */
|
|
||||||
jz 1f
|
|
||||||
swapgs
|
|
||||||
1:
|
|
||||||
push_all /* pushes 15 registers */
|
|
||||||
mov rdi, [rsp + 120] /* vector: 15 regs up = 120 */
|
|
||||||
mov rsi, [rsp + 128] /* error code we pushed in the macro */
|
|
||||||
|
|
||||||
/* we skip storing the user stack in these interrupt entries because
|
|
||||||
* the iretq frame stores it
|
|
||||||
*/
|
|
||||||
|
|
||||||
call exception_handler
|
|
||||||
pop_all
|
|
||||||
test qword ptr [rsp + 24], 3 /* from userspace? */
|
|
||||||
jz 2f
|
|
||||||
swapgs
|
|
||||||
2:
|
|
||||||
add rsp, 16 /* the two pushed items, from the macro */
|
|
||||||
iretq
|
|
||||||
|
|
||||||
/* same as exception_common, but we don't get the error code */
|
|
||||||
irq_common:
|
|
||||||
test qword ptr [rsp + 24], 3 /* is this from userspace? */
|
|
||||||
jz 1f
|
|
||||||
swapgs
|
|
||||||
1:
|
|
||||||
push_all /* pushes 15 registers */
|
|
||||||
mov rdi, [rsp + 120] /* irq no */
|
|
||||||
|
|
||||||
call irq_handler
|
|
||||||
pop_all
|
|
||||||
test qword ptr [rsp + 24], 3 /* from userspace? */
|
|
||||||
jz 2f
|
|
||||||
swapgs
|
|
||||||
2:
|
|
||||||
add rsp, 8
|
|
||||||
iretq
|
|
||||||
|
|
||||||
|
|
||||||
.global _syscall_enter
|
.global _syscall_enter
|
||||||
_syscall_enter:
|
_syscall_enter:
|
||||||
swapgs
|
swapgs
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,5 @@ struct cpu_local *tls_get();
|
||||||
struct proc *get_cur_proc();
|
struct proc *get_cur_proc();
|
||||||
struct thread *get_cur_thread();
|
struct thread *get_cur_thread();
|
||||||
void enter_userspace_init(struct thread *thread, uaddr_t entry);
|
void enter_userspace_init(struct thread *thread, uaddr_t entry);
|
||||||
struct pt_regs *current_pt_regs();
|
|
||||||
|
|
||||||
#endif /* _ARCH_PROC_H_ */
|
#endif /* _ARCH_PROC_H_ */
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,6 @@
|
||||||
#include <kernel/syscall.h>
|
#include <kernel/syscall.h>
|
||||||
#include <arch/proc.h>
|
#include <arch/proc.h>
|
||||||
|
|
||||||
struct pt_regs *current_pt_regs()
|
|
||||||
{
|
|
||||||
return (struct pt_regs *)(tls_get()->kernel_rsp - sizeof(struct pt_regs));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline i64 _do_syscall(struct pt_regs *regs)
|
static inline i64 _do_syscall(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
syscall_t c = get_syscall(regs->rax);
|
syscall_t c = get_syscall(regs->rax);
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
#define ALLOC_KERN 0x1
|
#define ALLOC_KERN 0x1
|
||||||
#define ALLOC_USER 0x2
|
#define ALLOC_USER 0x2
|
||||||
|
|
||||||
#define CLEANUP_KFREE __attribute__((cleanup(_cleanup_kfree)))
|
|
||||||
|
|
||||||
typedef struct _mem_cache_t {
|
typedef struct _mem_cache_t {
|
||||||
char *name;
|
char *name;
|
||||||
size_t item_size;
|
size_t item_size;
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,3 @@ void slab_free(mem_cache_t *cache, void *ptr)
|
||||||
|
|
||||||
spinlock_release(&cache->lock);
|
spinlock_release(&cache->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cleanup_kfree(void **ptr)
|
|
||||||
{
|
|
||||||
if (ptr && *ptr)
|
|
||||||
kfree(ptr);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue