[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lost] [Patch] sysinfo



Yet another one...


Index: src/modules/sysinfo/include/cpuid.h
===================================================================
--- src/modules/sysinfo/include/cpuid.h	(Revision 0)
+++ src/modules/sysinfo/include/cpuid.h	(Revision 0)
@@ -0,0 +1,246 @@
+/*  
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _CPUID_H_
+#define _CPUID_H_
+
+#include "types.h"
+#include "io.h"
+#include "syscall.h"
+
+// Strukturen
+
+/**
+ * Struktur fuer die Infos aus CPUID, Level 0
+ * Enthaelt max_level (maximaler level in cpuid) und die vendorID (Hersteller)
+ */
+typedef struct {
+    dword max_level;
+    char  vendorID[13];
+} cpuid_0;
+
+/**
+ * Struktur fuer die Infos aus CPUID, Level 1
+ * Enthaelt Infos ueber den APIC (ebx) sowie die Standardflags (edx, ecx)
+ */
+typedef struct {
+    dword eax;
+    union {
+        dword ebx;
+        struct  {
+            byte apic_id;
+            byte cpu_count;
+            byte clflush;
+            byte brand_id;
+        };
+    };
+    dword ecx;
+    dword edx;
+} cpuid_1;
+
+/**
+ * Struktur fuer die Infos aus CPUID, Extended Level 0
+ * Enthaelt max_level und vendorID, wie Level 0
+ */
+typedef struct {
+    dword max_level;
+    char vendorID[13];
+} cpuid_e0;
+
+/**
+ * Struktur fuer die Infos aus CPUID, Extended Level 1
+ * Enthaelt die erweiterten Flags in edx und ecx
+ */
+typedef struct {
+    dword eax;
+    dword ebx;
+    dword ecx;
+    dword edx;
+} cpuid_e1;
+
+/**
+ * Struktur fuer die Infos aus CPUID, Extended Level 2-4
+ * Enthaelt den Processor Brand String, eine Markenangabe des Prozessors.
+ */
+typedef struct {
+    dword eax;
+    char proc_brand_string[49];
+} cpuid_e2_e4;
+
+// Funktionen
+
+/**
+ * Prueft ob CPUID vorhanden ist.
+ *
+ * @return TRUE wenn cpuid funktioniert, sonst FALSE
+ */
+bool has_cpuid();
+
+/**
+ * Macht einen Aufruf an CPUID. Achtung, die Parameter werden auch zur Rueckgabe
+ * verwendet!
+ *
+ * @param eax Pointer auf Werte fuer eax. Eingangswert: Level von CPUID
+ * @param ebx Pointer auf Rueckgabewert fuer ebx
+ * @param ecx Pointer auf Rueckgabewert fuer ecx
+ * @param edx Pointer auf Rueckgabewert fuer edx
+ */
+void cpuid(dword* eax, dword* ebx, dword* ecx, dword* edx);
+
+/**
+ * Fragt CPUID Level 0 ab
+ *
+ * @see cpuid_0
+ * @return cpuid_0, enthaelt alle Infos von Level 0
+ */
+cpuid_0 cpuid_level_0();
+
+/**
+ * Fragt CPUID Level 1 ab
+ *
+ * @see cpuid_1
+ * @return cpuid_1, enthaelt alle Infos von Level 1 (APIC Infos, Flags)
+ */
+cpuid_1 cpuid_level_1();
+
+/**
+ * Fragt CPUID Extended Level 0 ab
+ *
+ * @see cpuid_e0
+ * @return cpuid_e0, enthaelt alle Infos von Extended Level 0 (aehnlich Level 0)
+ */
+cpuid_e0 cpuid_level_e0();
+
+/**
+ * Fragt CPUID Extended Level 1 ab
+ *
+ * @see cpuid_e1
+ * @return cpuid_e1, enthaelt alle Infos von Extended Level 1 (Flags)
+ */
+cpuid_e1 cpuid_level_e1();
+
+/**
+ * Fragt CPUID Extended Level 2 bis 4 ab
+ *
+ * @see cpuid_e2_e4
+ * @return cpuid_e2_e4, alle Infos dieser Level ( = den Processor Brand String)
+ */
+cpuid_e2_e4 cpuid_level_e2_e4();
+
+// Flags Level 1 - EDX - Alle CPUs
+
+#define CPUID_FLAG_FPU      ( 1 << 0 )
+#define CPUID_FLAG_VME      ( 1 << 1 )
+#define CPUID_FLAG_DE       ( 1 << 2 )
+#define CPUID_FLAG_PSE      ( 1 << 3 )
+#define CPUID_FLAG_TSC      ( 1 << 4 )
+#define CPUID_FLAG_MSR      ( 1 << 5 )
+#define CPUID_FLAG_PAE      ( 1 << 6 )
+#define CPUID_FLAG_MCE      ( 1 << 7 )
+#define CPUID_FLAG_CX8      ( 1 << 8 )
+#define CPUID_FLAG_APIC     ( 1 << 9 )
+#define CPUID_FLAG_SEP      ( 1 << 11 )
+#define CPUID_FLAG_MTRR     ( 1 << 12 )
+#define CPUID_FLAG_PGE      ( 1 << 13 )
+#define CPUID_FLAG_MCA      ( 1 << 14 )
+#define CPUID_FLAG_CMOV     ( 1 << 15 )
+#define CPUID_FLAG_PAT      ( 1 << 16 )
+#define CPUID_FLAG_PSE36    ( 1 << 17 )
+#define CPUID_FLAG_PSN      ( 1 << 18 )
+#define CPUID_FLAG_CLFL     ( 1 << 19 )
+#define CPUID_FLAG_DTES     ( 1 << 21 )
+#define CPUID_FLAG_ACPI     ( 1 << 22 )
+#define CPUID_FLAG_MMX      ( 1 << 23 )
+#define CPUID_FLAG_FXSR     ( 1 << 24 )
+#define CPUID_FLAG_SSE      ( 1 << 25 )
+#define CPUID_FLAG_SSE2     ( 1 << 26 )
+#define CPUID_FLAG_SS       ( 1 << 27 )
+#define CPUID_FLAG_HTT      ( 1 << 28 )
+#define CPUID_FLAG_TM1      ( 1 << 29 )
+#define CPUID_FLAG_IA64     ( 1 << 30 )
+#define CPUID_FLAG_PBE      ( 1 << 31 )
+
+// Flags Level 1 - ECX - Alle CPUs
+
+#define CPUID_FLAG_SSE3     ( 1 << 0 )
+#define CPUID_FLAG_MON      ( 1 << 3 )
+#define CPUID_FLAG_DSCPL    ( 1 << 4 )
+#define CPUID_FLAG_VMX      ( 1 << 5 )
+#define CPUID_FLAG_SMX      ( 1 << 6 )
+#define CPUID_FLAG_EST      ( 1 << 7 )
+#define CPUID_FLAG_TM2      ( 1 << 8 )
+#define CPUID_FLAG_SSSE3    ( 1 << 9 )
+#define CPUID_FLAG_CID      ( 1 << 10 )
+#define CPUID_FLAG_CX16     ( 1 << 13 )
+#define CPUID_FLAG_ETPRD    ( 1 << 14 )
+#define CPUID_FLAG_PDCM     ( 1 << 15 )
+#define CPUID_FLAG_DCA      ( 1 << 18 )
+#define CPUID_FLAG_SSE41    ( 1 << 19 )
+#define CPUID_FLAG_SSE42    ( 1 << 20 )
+#define CPUID_FLAG_X2APIC   ( 1 << 21 )
+#define CPUID_FLAG_POPCNT   ( 1 << 23 )
+
+// Flags Extended Level 1 - ECX - AMD (nicht angegebene reserviert)
+#define CPUID_FLAG_LAHFSAHF ( 1 << 0 )
+#define CPUID_FLAG_CMPLEGACY    ( 1 << 1 )
+#define CPUID_FLAG_SVM      ( 1 << 2 )
+#define CPUID_FLAG_EXTAPIC  ( 1 << 3 )
+#define CPUID_FLAG_ALTMOVCR8    ( 1 << 4 )
+#define CPUID_FLAG_ABM      ( 1 << 5 )
+#define CPUID_FLAG_SSE4A    ( 1 << 6 )
+#define CPUID_FLAG_MISALIGNSSE  ( 1 << 7 )
+#define CPUID_FLAG_3DNOWPREFETCH    ( 1 << 8 )
+#define CPUID_FLAG_OSVW     ( 1 << 9 )
+#define CPUID_FLAG_SKINIT   ( 1 << 12 )
+#define CPUID_FLAG_WDT      ( 1 << 13 )
+
+// Flags Extended Level 1 - EDX - AMD
+// (nicht angegebene reserviert oder identisch mit Level 1 EDX)
+#define CPUID_FLAG_NX       ( 1 << 20 )
+#define CPUID_FLAG_MMXEXT   ( 1 << 22 )
+#define CPUID_FLAG_FFXSR    ( 1 << 25 )
+#define CPUID_FLAG_PAGE1GB  ( 1 << 26 )
+#define CPUID_FLAG_RDTSCP   ( 1 << 27 )
+#define CPUID_FLAG_LM       ( 1 << 29 )
+#define CPUID_FLAG_3DNOWEXT ( 1 << 30 )
+#define CPUID_FLAG_3DNOW    ( 1 << 31 )
+
+// Strings (zur Verwendung in der Ausgabe)
+
+extern char flags_01_edx[32][6];
+extern char flags_01_ecx[32][6];
+extern char flags_e01_ecx_amd[32][20];
+extern char flags_e01_edx_amd[32][20];
+
+#endif
Index: src/modules/sysinfo/cpuid.c
===================================================================
--- src/modules/sysinfo/cpuid.c	(Revision 699)
+++ src/modules/sysinfo/cpuid.c	(Arbeitskopie)
@@ -1,12 +1,79 @@
-#define _USE_START_
-#include "init.h"
+/*  
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "types.h"
+#include "syscall.h"
+#include "stdlib.h"
 #include "stdio.h"
+#include "string.h"
 
-struct cpu {
-    int MHZ;
+#include "cpuid.h"
+
+#define DEBUG_MSG(s) printf("[ CPUID ] debug: %s() '%s'\n", __FUNCTION__, s)
+
+// Hier werden die Strings fuer die diversen Flags definiert
+
+// Basic Flags, auf allen Prozessoren identisch
+char flags_01_edx[32][6] = {
+    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "", "apic",
+    "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "psn", "clfl", "",
+    "dtes", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm1", "ia-64",
+    "pbe"
 };
+char flags_01_ecx[32][6] = {
+    "sse3", "", "", "mon", "dscpl", "vmx", "smx", "est", "tm2", "ssse3", "cid",
+    "", "", "cx16", "etprd", "pdcm", "", "", "dca", "sse4.1", "sse4.2",
+    "x2apic", "", "popcnt", "", "", "",  "", "", "", "", ""
+};
 
-bool cpuid_is()
+// Extended Flags fuer AMD-Prozessoren - unterscheiden sich von denen von Intel
+char flags_e01_ecx_amd[32][20] = {
+    "lahfsahf", "cmplegacy", "svm", "extapic", "altmovcr8", "abm", "sse4a",
+    "misalignsse", "3dnowprefetch", "osvw", "", "", "skinit", "wdt"
+};
+char flags_e01_edx_amd[32][20] = {
+    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+    "", "nx", "", "mmxext", "", "", "ffxsr", "page1gb", "rdtscp", "lm",
+    "3dnowext", "3dnow"
+};
+
+/**
+ * Prueft ob CPUID vorhanden ist.
+ *
+ * @return TRUE wenn cpuid funktioniert, sonst FALSE
+ */
+bool has_cpuid()
 {
     int result;
     asm (
@@ -24,26 +91,123 @@
     return result;
 }
 
+/**
+ * Macht einen Aufruf an CPUID. Achtung, die Parameter werden auch zur Rueckgabe
+ * verwendet!
+ *
+ * @param eax Pointer auf Werte fuer eax. Eingangswert: Level von CPUID
+ * @param ebx Pointer auf Rueckgabewert fuer ebx
+ * @param ecx Pointer auf Rueckgabewert fuer ecx
+ * @param edx Pointer auf Rueckgabewert fuer edx
+ */
 void cpuid(dword* eax, dword* ebx, dword* ecx, dword* edx)
 {
     asm volatile("cpuid"
-                : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
-                : "a"(eax), "b"(ebx), "c"(ecx), "d"(edx));
+        : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
+        : "a"(*eax), "b"(*ebx), "c"(*ecx), "d"(*edx)
+    );
 }
 
-int main(int argc, char* argv[])
+/**
+ * Fragt CPUID Level 0 ab
+ *
+ * @see cpuid_0
+ * @return cpuid_0, enthaelt alle Infos von Level 0
+ */
+cpuid_0 cpuid_level_0()
 {
-    puts("|CPUID| Module loaded.\n");
-    if(!cpuid_is())
-    {
-        puts("Sorry, der CPU unterstütz kein CPUID.\n");
+    cpuid_0 result;
+    result.max_level = 0;
+    result.vendorID[12] = '\0';
+    cpuid(&result.max_level,
+        (dword*)(&result.vendorID[0]),
+        (dword*)(&result.vendorID[8]),
+        (dword*)(&result.vendorID[4]));
+    return result;
+}
+
+/**
+ * Fragt CPUID Level 1 ab
+ *
+ * @see cpuid_1
+ * @return cpuid_1, enthaelt alle Infos von Level 1 (APIC Infos, Flags)
+ */
+cpuid_1 cpuid_level_1()
+{
+    cpuid_1 result;
+    result.eax = 1;
+    cpuid(&result.eax, &result.ebx, &result.ecx, &result.edx);
+    return result;
+}
+
+/**
+ * Fragt CPUID Extended Level 0 ab
+ *
+ * @see cpuid_e0
+ * @return cpuid_e0, enthaelt alle Infos von Extended Level 0 (aehnlich Level 0)
+ */
+cpuid_e0 cpuid_level_e0() 
+{
+    cpuid_e0 result;
+    result.max_level = 0x80000000;
+    result.vendorID[12] = '\0';
+    cpuid(&result.max_level,
+        (dword*)(&result.vendorID[0]),
+        (dword*)(&result.vendorID[8]),
+        (dword*)(&result.vendorID[4]));
+    // Wenn dieser Aufruf schon ungueltig war, (Level garnicht unterstuetzt)
+    // Maximalen Extended Level auf 0 setzen, um keine zufaelligen Werte
+    // zu hinterlassen.
+    if (result.max_level < 0x8000000) {
+        result.max_level = 0;
     }
-    else
-    {
-        puts("Yeah, der CPU unterstütz CPUID ;-).\n");
-    }
-    
-    while(1) {
-        wait_for_rpc();
-    }
+    return result;
 }
+
+/**
+ * Fragt CPUID Extended Level 1 ab
+ *
+ * @see cpuid_e1
+ * @return cpuid_e1, enthaelt alle Infos von Extended Level 1 (Flags)
+ */
+cpuid_e1 cpuid_level_e1()
+{
+    cpuid_e1 result;
+    result.eax = 0x80000001;
+    cpuid(&result.eax, &result.ebx, &result.ecx, &result.edx);
+    return result;
+}
+
+/**
+ * Fragt CPUID Extended Level 2 bis 4 ab
+ * Benennung ist so damit das ganze auch irgendwie zueinander passt.
+ *
+ * @see cpuid_e2_e4
+ * @return cpuid_e2_e4, alle Infos dieser Level (den Processor Brand String)
+ */
+cpuid_e2_e4 cpuid_level_e2_e4()
+{
+    cpuid_e2_e4 result;
+    result.eax = 0x80000002;
+    cpuid(&result.eax,
+        (dword*)(&result.proc_brand_string[0]),
+        (dword*)(&result.proc_brand_string[4]),
+        (dword*)(&result.proc_brand_string[8]));
+    result.eax++;
+    cpuid(&result.eax,
+        (dword*)(&result.proc_brand_string[12]),
+        (dword*)(&result.proc_brand_string[16]),
+        (dword*)(&result.proc_brand_string[24]));
+    result.eax++;
+    cpuid(&result.eax,
+        (dword*)(&result.proc_brand_string[28]),
+        (dword*)(&result.proc_brand_string[32]),
+        (dword*)(&result.proc_brand_string[36]));
+    result.eax++;
+    cpuid(&result.eax,
+        (dword*)(&result.proc_brand_string[40]),
+        (dword*)(&result.proc_brand_string[44]),
+        (dword*)(&result.proc_brand_string[48]));
+    result.proc_brand_string[49] = '\0';
+    return result;
+}
Index: src/modules/sysinfo/sysinfo.c
===================================================================
--- src/modules/sysinfo/sysinfo.c	(Revision 0)
+++ src/modules/sysinfo/sysinfo.c	(Revision 0)
@@ -0,0 +1,158 @@
+/*  
+ * Copyright (c) 2008 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "stdio.h"
+#include "types.h"
+#include "stdlib.h"
+#include "lostio.h"
+#include "string.h"
+
+#include "cpuid.h"
+
+#define _USE_START_
+#include "init.h"
+
+
+/**
+ * Legt /cpu im vfstree an, und fuellt die Datei mit Inhalt.
+ */
+void sysinfo_create_cpuid_file()
+{
+    char filename[] = "/cpu";
+    char* content = malloc(4096);
+    int size;
+    
+    cpuid_0 basic;
+    cpuid_1 basic_flags;
+    cpuid_e0 extended;
+    cpuid_e1 extended_flags;
+    cpuid_e2_e4 brand;
+    
+    // Alle Infos via cpuid abfragen
+    basic = cpuid_level_0();
+    basic_flags = cpuid_level_1();
+    extended = cpuid_level_e0();
+    extended_flags = cpuid_level_e1();
+    brand = cpuid_level_e2_e4();
+
+    // Wenn der extended level 0x8000004 gar nicht unterstuetzt ist, ist auch 
+    // der processorBrandString ungueltig. Dieser ist dann zu ueberschreiben, um 
+    // den Benutzer nicht mit einer leeren (oder gar zufaelligen) Ausgabe zu
+    // konfrontieren.
+    if (extended.max_level < 0x80000004) {
+        sprintf((char*)&brand.proc_brand_string,"Unsupported.\0");
+    }
+
+    // Infoblock schreiben.
+    size = sprintf(content, "%s: %s\n%s: %s\n%s: %i\n%s: 0x%#08X\n%s:",
+            "VendorID",  basic.vendorID,
+            "Brand Name", brand.proc_brand_string,
+            "Standardlevel", basic.max_level,
+            "Erweitertes Level", extended.max_level,
+            "Flags");
+
+    // Die Diversen Flags ausgeben
+    int i = 0;
+
+    // Basic Flags Register EDX ueberpruefen
+    for (i = 0; i < 32; i++) {
+        if ((basic_flags.edx & (1 << i)) == (1 << i)) {
+            size += sprintf(content+size, " %s", flags_01_edx[i]);
+        }
+    }
+
+    // Basic Flags Register ECX ueberpruefen
+    for (i = 0; i < 32; i++) {
+        if ((basic_flags.ecx & (1 << i)) == (1 << i)) {
+            size += sprintf(content+size, " %s", flags_01_ecx[i]);
+        }
+    } 
+
+    // Extended Flags abfragen
+
+    // Extended Flags von AMD
+    if (strncmp(basic.vendorID,"AuthenticAMD",12) == 0) {
+        // Register EDX
+        for (i = 0; i < 32; i++) {
+            if ((extended_flags.edx & (1 << i)) == (1 << i)) {
+                size += sprintf(content+size, " %s", flags_e01_edx_amd[i]);
+            }
+        } 
+
+        // Register ECX
+        for (i = 0; i < 32; i++) {
+            if ((extended_flags.ecx & (1 << i)) == (1 << i)) {
+                size += sprintf(content+size, " %s", flags_e01_ecx_amd[i]);
+            }
+        }
+    } 
+
+    // Neue Linie als Dateiende
+    size += sprintf(content+size,"\n");
+
+    // Datei registrieren, Groesse ist Laenge aller geschriebenen Daten.
+    vfstree_create_node(filename, LOSTIO_TYPES_RAMFILE, size, content, 0);
+}
+
+/**
+ * main von sysinfo. Initialisiert LostIO und exportiert alle vorhandenen
+ * Systeminfos nach aussen.
+ *
+ * @param argc Argumentzaehler. Hier Irrelevant.
+ * @param argv Argumente. Hier Irrelevant.
+ * @return Beendigungsstatus des Moduls.
+ */
+int main(int argc, char* argv[])
+{
+    // LostIO initialisieren
+    lostio_init();
+
+    // LostIO Standardtypen einbinden
+    lostio_type_ramfile_use();
+    lostio_type_directory_use();
+
+    // /cpu anlegen - enthaelt Infos ueber die CPU, Basis hierfuer ist cpuid.c
+    sysinfo_create_cpuid_file();
+
+    // Letztendlich bei Init registrieren
+    init_service_register("sysinfo");
+
+    // Warteschleife
+    while(1) {
+        wait_for_rpc();
+    }
+
+    return 0;
+}