X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=kernel%2Farch%2Fx86%2Fentry.S;h=3483893d93f4c9c642d7244bc493eff25cff6cf2;hp=f8cf68420facff66239e57ee1b6a7d1109683134;hb=0601614ebbcc48b961a2f0613281e6e629af29b1;hpb=292f369387f0b1018b3cfc59ad555698d75d6d46 diff --git a/kernel/arch/x86/entry.S b/kernel/arch/x86/entry.S index f8cf684..3483893 100644 --- a/kernel/arch/x86/entry.S +++ b/kernel/arch/x86/entry.S @@ -139,10 +139,25 @@ no_pentium_str: no_multiboot_str: .string "Unrecognized bootloader; a multiboot-compliant loader is required." + + .macro enterkernel, reg + pushl %es + pushl %ds + movl $8, \reg + cld + movl \reg, %ds + movl \reg, %es + .endm + + .macro exitkernel + popl %ds + popl %es + .endm .macro pushvolatilesnoeax pushl %ecx pushl %edx + enterkernel %ecx .endm .macro pushvolatiles @@ -151,6 +166,7 @@ no_multiboot_str: .endm .macro popvolatiles + exitkernel popl %edx popl %ecx popl %eax @@ -164,11 +180,11 @@ no_multiboot_str: .macro pushall pushl %esi pushl %ebp - pushl %esp pushl %ebx pushl %edx pushl %ecx pushl %eax + enterkernel %esi .endm .macro pushallnoerr @@ -177,11 +193,11 @@ no_multiboot_str: .endm .macro popall + exitkernel popl %eax popl %ecx popl %edx popl %ebx - addl $4, %esp popl %ebp popl %esi popl %edi @@ -261,17 +277,44 @@ x86_page_fault: popall iret + .global x86_int98_entry +x86_int98_entry: + pushl $0 + pushl %eax + enterkernel %ecx + + pushl %esp + call x86_invoke_method + addl $4, %esp + + exitkernel + popl %eax + xorl %ecx, %ecx + popl %edx + xorl %ebx, %ebx + xorl %ebp, %ebp + xorl %esi, %esi + xorl %edi, %edi + iret + .global x86_int99_entry x86_int99_entry: - pushl %edx - pushl 4(%esp) - pushl %edx pushl %ecx pushl %eax - call invoke_method - addl $16, %esp - xorl %ecx, %ecx - popl %edx + enterkernel %edx + + pushl %esp + call x86_return_from_method + addl $4, %esp + + exitkernel + popl %eax + popl %ecx + xorl %edx, %edx + xorl %ebx, %ebx + xorl %ebp, %ebp + xorl %esi, %esi + xorl %edi, %edi iret .global x86_irq @@ -342,16 +385,47 @@ x86_new_thread: .section ".roshared","x" - // The syscall pointer must be the first thing in roshared - // (at vaddr 0x7fff0000), so that user code can make method - // invocations to find out where other stuff is. + // The vsyscall table must be the first thing in roshared (at + // vaddr 0x7fff0000). + +#define PTR(x) (x - x86_syscall_ptr + 0x7fff0000) .global x86_syscall_ptr x86_syscall_ptr: - .long x86_shared_int99 - x86_syscall_ptr + 0x7fff0000 - - .global x86_shared_int99 + .long PTR(x86_shared_int98) + + .global x86_sysret_ptr +x86_sysret_ptr: + .long PTR(x86_shared_int99) + +x86_shared_int98: + // FIXME: This must be unpreemptible by traps + pushl %gs + pushl %fs + pushl %ebp + pushl %edi + pushl %esi + pushl %ebx + int $0x98 + popl %ebx + popl %esi + popl %edi + popl %ebp + popl %fs + popl %gs + ret + x86_shared_int99: int $0x99 - // FIXME: search for exception handler ret + + .section ".rwshared","" + + // Userspace must set this to an appropriate entry point + // prior to registering objects with the kernel. It should + // not be modified while an object is registered (the kernel + // won't mind, but there's no mechanism to wait until no more + // upcalls to the old entry point are in progress). + .global x86_upcall_entry +x86_upcall_entry: + .long 0