X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/bb793d5c6918efee6a86de442463a7c9aaa4ecdd..b91be0033265b5b6bd716bd39cb0971da41906c4:/lunaix-os/kernel/asm/i386/proc.c?ds=sidebyside diff --git a/lunaix-os/kernel/asm/i386/proc.c b/lunaix-os/kernel/asm/i386/proc.c new file mode 100644 index 0000000..67f3f73 --- /dev/null +++ b/lunaix-os/kernel/asm/i386/proc.c @@ -0,0 +1,28 @@ +#include + +void +proc_init_transfer(struct proc_info* proc, + ptr_t stack_top, + ptr_t target, + int flags) +{ + struct exec_param* execp = + (struct exec_param*)(stack_top - sizeof(struct exec_param)); + isr_param* isrp = (isr_param*)((ptr_t)execp - sizeof(isr_param)); + + *execp = (struct exec_param){ + .cs = KCODE_SEG, .ss = KDATA_SEG, .eip = target, .eflags = cpu_ldstate() + }; + + *isrp = (isr_param){ .registers = { .ds = KDATA_SEG, + .es = KDATA_SEG, + .fs = KDATA_SEG, + .gs = KDATA_SEG }, + .execp = execp }; + + if ((flags & TRANSFER_IE)) { + execp->eflags |= 0x200; + } + + proc->intr_ctx = isrp; +} \ No newline at end of file