New developer version 0.6.8; added select () function; added demonstrating example...
[ZeXOS.git] / kernel / include / smp.h
blobbfff82ae7c25911d7cc33c284d0f62587b09b732
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 #ifndef _SMP_H
21 #define _SMP_H
23 #define SMP_ARCH_x86 0x1
24 #define SMP_ARCH_ARM 0x2
25 #define SMP_ARCH_PPC 0x3
26 #define SMP_ARCH_SPARC 0x4
27 #define SMP_ARCH_ALPHA 0x5
29 #define SMP_STATE_CPU_UP 0x1
30 #define SMP_STATE_CPU_DOWN 0x2
32 #define SMP_FLAGS_CPU_BS 0x1
33 #define SMP_FLAGS_CPU_AP 0x2
35 /* x86 specific cpu features */
36 #define SMP_ARCH_x86_FEATURE_FPU 0x00000001 // x87 fpu
37 #define SMP_ARCH_x86_FEATURE_VME 0x00000002 // virtual 8086
38 #define SMP_ARCH_x86_FEATURE_DE 0x00000004 // debugging extensions
39 #define SMP_ARCH_x86_FEATURE_PSE 0x00000008 // page size extensions
40 #define SMP_ARCH_x86_FEATURE_TSC 0x00000010 // rdtsc instruction
41 #define SMP_ARCH_x86_FEATURE_MSR 0x00000020 // rdmsr/wrmsr instruction
42 #define SMP_ARCH_x86_FEATURE_PAE 0x00000040 // extended 3 level page table addressing
43 #define SMP_ARCH_x86_FEATURE_MCE 0x00000080 // machine check exception
44 #define SMP_ARCH_x86_FEATURE_CX8 0x00000100 // cmpxchg8b instruction
45 #define SMP_ARCH_x86_FEATURE_APIC 0x00000200 // local apic on chip
46 #define SMP_ARCH_x86_FEATURE_SEP 0x00000800 // SYSENTER/SYSEXIT
47 #define SMP_ARCH_x86_FEATURE_MTRR 0x00001000 // MTRR
48 #define SMP_ARCH_x86_FEATURE_PGE 0x00002000 // paging global bit
49 #define SMP_ARCH_x86_FEATURE_MCA 0x00004000 // machine check architecture
50 #define SMP_ARCH_x86_FEATURE_CMOV 0x00008000 // cmov instruction
51 #define SMP_ARCH_x86_FEATURE_PAT 0x00010000 // page attribute table
52 #define SMP_ARCH_x86_FEATURE_PSE36 0x00020000 // page size extensions with 4MB pages
53 #define SMP_ARCH_x86_FEATURE_PSN 0x00040000 // processor serial number
54 #define SMP_ARCH_x86_FEATURE_CLFSH 0x00080000 // cflush instruction
55 #define SMP_ARCH_x86_FEATURE_DS 0x00200000 // debug store
56 #define SMP_ARCH_x86_FEATURE_ACPI 0x00400000 // thermal monitor and clock ctrl
57 #define SMP_ARCH_x86_FEATURE_MMX 0x00800000 // mmx instructions
58 #define SMP_ARCH_x86_FEATURE_FXSR 0x01000000 // FXSAVE/FXRSTOR instruction
59 #define SMP_ARCH_x86_FEATURE_SSE 0x02000000 // SSE
60 #define SMP_ARCH_x86_FEATURE_SSE2 0x04000000 // SSE2
61 #define SMP_ARCH_x86_FEATURE_SS 0x08000000 // self snoop
62 #define SMP_ARCH_x86_FEATURE_HTT 0x10000000 // hyperthreading
63 #define SMP_ARCH_x86_FEATURE_TM 0x20000000 // thermal monitor
64 #define SMP_ARCH_x86_FEATURE_PBE 0x80000000 // pending break enable
66 #define SMP_ARCH_x86_TRAMPOLINE 0x7000
68 /* x86 specific SMP attributes */
69 typedef struct {
70 unsigned char lapic_id;
71 unsigned char lapic_ver;
73 unsigned cpuid;
74 unsigned features;
75 } smp_arch_x86;
77 /* SMP CPU structure */
78 typedef struct smp_cpu_context {
79 struct smp_cpu_context *next, *prev;
81 unsigned char arch;
83 void *arch_spec;
85 unsigned char flags;
86 unsigned char state;
87 } smp_cpu_t;
90 /* externs */
91 extern smp_cpu_t *smp_cpu_getnextcpu (smp_cpu_t *cpu);
92 extern void smp_cpu_check ();
93 extern unsigned smp_cpu_register (unsigned char arch, unsigned char state, unsigned char flags, void *arch_spec);
94 extern unsigned int init_smp ();
96 #endif