stdlibc: \!perror()
[meinos.git] / kernel2 / include / cpu.h
blob98eb88eacb5c129032cbf1cd771ef9b699754bd9
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
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/>.
19 #ifndef _CPU_H_
20 #define _CPU_H_
22 #include <sys/types.h>
23 #include <stdint.h>
24 #include <llist.h>
25 #include <malloc.h>
26 #include <tss.h>
28 #define cpu_getid() 0
29 #define cpu_this ((cpu_t*)llist_get(cpus,cpu_getid()))
31 struct cpu_registers {
32 uint32_t *eax;
33 uint32_t *ebx;
34 uint32_t *ecx;
35 uint32_t *edx;
36 uint32_t *esi;
37 uint32_t *edi;
38 uint32_t *ebp;
39 uint32_t *esp;
40 uint32_t *eip;
41 uint32_t *efl;
42 uint32_t *cs;
43 uint32_t *ds;
44 uint32_t *es;
45 uint32_t *fs;
46 uint32_t *gs;
47 uint32_t *ss;
50 typedef struct {
51 unsigned int id;
52 int enabled;
53 void *stack;
54 size_t stacksize;
55 struct cpu_registers regs;
56 tss_t *tss;
57 int uselapic;
58 clock_t interval; // all 10 ms
59 clock_t ticks;
60 } cpu_t;
62 llist_t cpus;
64 static inline void cpu_halt() {
65 asm("hlt");
68 int cpu_init();
69 int cpu_stack_create(cpu_t *cpu,size_t size);
70 void cpu_id(uint32_t seax,uint32_t *deax,uint32_t *debx,uint32_t *decx,uint32_t *dedx);
71 void cpu_shutdown();
73 #endif