root / Whitix / branches / hybrid / arch / i386 / kernel / smp.c

Revision 511, 2.4 kB (checked in by mwhitworth, 8 months ago)

Convert SMP to use new APIs.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19/* Just detects whether the system is or is not a SMP system */
20
21#include <console.h>
22#include <i386/smp.h>
23#include <typedefs.h>
24
25#define MP_FPS_SIG   (('_' << 24) | ('P' << 16) | ('M' << 8) | ('_'))
26
27struct MpConfig;
28
29struct MpFloating
30{
31        char sig[4];
32        struct MpConfig* config;
33        BYTE length; /* In 16 byte paragraphs */
34        BYTE version; /* 1 = 1.1, 4 = 1.4 */
35        BYTE checkSum; /* Should be zero */
36        BYTE mpFeatures1;
37        BYTE mpFeatures2;
38        BYTE reserved[3];
39};
40
41struct MpConfig
42{
43        char sig[4];
44        WORD length;
45        BYTE version,checkSum;
46        char oemId[8];
47        char productId[12];
48        DWORD tablePointer,tableSize;
49        BYTE entryCount;
50        DWORD apicAddress;
51        WORD extTableLength;
52        BYTE extTableCheckSum;
53};
54
55/* SmpDetectStruct - Searches an area of memory for the "_MP_" signature */
56DWORD SmpDetectStruct(DWORD addr,DWORD length)
57{
58        DWORD* i;
59        for (i=(DWORD*)addr; i<(DWORD*)(addr+length); i+=4)
60                if (*i == MP_FPS_SIG)
61                        return (DWORD)i;
62
63        return 0;
64}
65
66int SmpInit()
67{
68        DWORD addr;
69        extern DWORD ebdaAddr;
70
71        KePrint("Detecting SMP...");
72
73        /*
74         * The The MP Floating Pointer Structure is in one of four memory areas:
75         * (1) The first kilobyte of the Extended BIOS Data Area (EBDA).
76         * (2) The last kilobyte of base memory (639-640k).
77         * (3) The BIOS ROM address space (0xF0000-0xFFFFF).
78         * (4) The first kilobyte of memory.
79         * The OS should search for the ASCII string "_MP_" in these four areas
80         */
81
82//      if ((addr=SmpDetectStruct(0x0, 0x400)))
83//              goto found;
84
85        if ((addr=SmpDetectStruct(0x9FC00,0x400)))
86                goto found;
87
88        if ((addr=SmpDetectStruct(0xF0000,0xFFFF)))
89                goto found;
90
91        if (ebdaAddr && (addr=SmpDetectStruct(ebdaAddr,0x400)))
92                goto found;
93
94        KePrint("Not found\n");
95        return 0;
96
97found:
98        KePrint("Found at %#X\n",addr);
99        return 0;
100}
Note: See TracBrowser for help on using the browser.