Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / kernel / arch / i386 / task.c
blob3c38a12306dd02aa724ca3c51fcd6f5808e94e00
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <task.h>
23 unsigned arch_task_init (task_t *task, unsigned entry)
25 (void) setjmp (task->state);
26 // ...especially the stack pointer
27 unsigned adr = (unsigned) (task->stacks + USER_STACK_SIZE);
28 task->state[0].JMPBUF_SP = adr;
29 // ...and program counter
30 task->state[0].JMPBUF_IP = entry;
31 // set EFLAGS value to enable interrupts
32 task->state[0].JMPBUF_FLAGS = 0x200;
34 return 1;
37 unsigned arch_task_set (task_t *task)
39 return setjmp (task->state);
42 unsigned arch_task_switch (task_t *task)
44 /* fake long jump (register switch) to task function */
45 longjmp (task->state, 1);
47 return 1;