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/>.
26 smp_cpu_t smp_cpu_list
;
28 smp_cpu_t
*smp_cpu_getnextcpu (smp_cpu_t
*cpu
)
31 return smp_cpu_list
.next
;
33 smp_cpu_t
*nextcpu
= cpu
->next
;
35 if (cpu
== &smp_cpu_list
)
45 /*char *str = (char *) kmalloc (sizeof (char) * (cpu_cnt * 256));
57 for (cpu = smp_cpu_list.next; cpu != &smp_cpu_list; cpu = cpu->next) {*/
58 /*if (cpu->arch == SMP_ARCH_x86)
59 strcpy (cpuarch, "x86");
60 else if (cpu->arch == SMP_ARCH_ARM)
61 strcpy (cpuarch, "ARM");
62 else if (cpu->arch != SMP_ARCH_x86)
63 strcpy (cpuarch, "unknown");
65 sprintf (strcpu, "CPU %d (%s)\n\tarch: %s\n\tstate: %s\n\tfeatures: ", cpu_cnt, (cpu->flags == SMP_FLAGS_CPU_BS ) ? "BS" : "AP",
66 cpuarch, (cpu->state == SMP_STATE_CPU_UP ) ? "running" : "down");
70 smp_arch_x86 *arch_spec = cpu->arch_spec;
77 if (arch_spec->features & SMP_ARCH_x86_FEATURE_FPU)
79 if (arch_spec->features & SMP_ARCH_x86_FEATURE_VME)
81 if (arch_spec->features & SMP_ARCH_x86_FEATURE_DE)
83 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PSE)
85 if (arch_spec->features & SMP_ARCH_x86_FEATURE_TSC)
87 if (arch_spec->features & SMP_ARCH_x86_FEATURE_MSR)
89 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PAE)
91 if (arch_spec->features & SMP_ARCH_x86_FEATURE_MCE)
93 if (arch_spec->features & SMP_ARCH_x86_FEATURE_CX8)
95 if (arch_spec->features & SMP_ARCH_x86_FEATURE_APIC)
96 strcat (str, "apic ");
97 if (arch_spec->features & SMP_ARCH_x86_FEATURE_SEP)
99 if (arch_spec->features & SMP_ARCH_x86_FEATURE_MTRR)
100 strcat (str, "mttr ");
101 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PGE)
102 strcat (str, "pge ");
103 if (arch_spec->features & SMP_ARCH_x86_FEATURE_MCA)
104 strcat (str, "mca ");
105 if (arch_spec->features & SMP_ARCH_x86_FEATURE_CMOV)
106 strcat (str, "cmov ");
107 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PAT)
108 strcat (str, "pat ");
109 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PSE36)
110 strcat (str, "pse36 ");
111 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PSN)
112 strcat (str, "psn ");
113 if (arch_spec->features & SMP_ARCH_x86_FEATURE_CLFSH)
114 strcat (str, "clfsh ");
115 if (arch_spec->features & SMP_ARCH_x86_FEATURE_DS)
117 if (arch_spec->features & SMP_ARCH_x86_FEATURE_ACPI)
118 strcat (str, "acpi ");
119 if (arch_spec->features & SMP_ARCH_x86_FEATURE_MMX)
120 strcat (str, "mmx ");
121 if (arch_spec->features & SMP_ARCH_x86_FEATURE_FXSR)
122 strcat (str, "fxsr ");
123 if (arch_spec->features & SMP_ARCH_x86_FEATURE_SSE)
124 strcat (str, "sse ");
125 if (arch_spec->features & SMP_ARCH_x86_FEATURE_SSE2)
126 strcat (str, "sse2 ");
127 if (arch_spec->features & SMP_ARCH_x86_FEATURE_SS)
129 if (arch_spec->features & SMP_ARCH_x86_FEATURE_HTT)
130 strcat (str, "htt ");
131 if (arch_spec->features & SMP_ARCH_x86_FEATURE_TM)
133 if (arch_spec->features & SMP_ARCH_x86_FEATURE_PBE)
134 strcat (str, "pbe ");
141 //vfs_list_add ("cpuinfo", VFS_FILEATTR_FILE | VFS_FILEATTR_READ | VFS_FILEATTR_SYSTEM, "/proc/");
143 /*vfs_content_t content;
147 //vfs_mmap ("/proc/cpuinfo", 13, &content);
150 /* mostly x86 stuff */
151 unsigned smp_cpu_register (unsigned char arch
, unsigned char state
, unsigned char flags
, void *arch_spec
)
155 /* alloc and init context */
156 cpu
= (smp_cpu_t
*) kmalloc (sizeof (smp_cpu_t
));
162 cpu
->arch_spec
= arch_spec
;
167 cpu
->next
= &smp_cpu_list
;
168 cpu
->prev
= smp_cpu_list
.prev
;
169 cpu
->prev
->next
= cpu
;
170 cpu
->next
->prev
= cpu
;
175 unsigned int init_smp ()
177 smp_cpu_list
.next
= &smp_cpu_list
;
178 smp_cpu_list
.prev
= &smp_cpu_list
;
180 return arch_smp_init ();