make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / i386-pc / cpu / cpu_init.c
blobb2e474b6b903bf82af2e592414069e9c9b489a22
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CPU Initialisation.
6 Lang: english
7 */
9 #include <aros/symbolsets.h>
10 #include "cpu_intern.h"
11 #include LC_LIBDEFS_FILE
13 void i386_CheckCPU_Type( struct i386_compat_intern *CPU_intern );
15 #define SMP_SUPPORT 1
17 static struct CPU_Definition *BootCPU; /* Pointer used by the exec launched boot cpu probe */
19 static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR CPUBase)
21 struct intel_mp_confblock *mpcfb = NULL;
22 struct CPU_Definition *AvailCPUs = NULL;
23 struct i386_compat_intern *BootCPU_intern = NULL;
24 struct ACPIBase *ACPIBase = NULL;
26 CPUBase->CPUB_BOOT_Physical = -1; /* set to a single cpu for now */
27 CPUBase->CPUB_BOOT_Logical = -1;
29 mpcfb = find_smp_config();
31 if ( mpcfb )
33 kprintf(DEBUG_NAME_STR ": Found SMP 1.4 MP table = 0x%p\n", mpcfb);
34 AllocAbs( 4096, mpcfb);
35 if (mpcfb->mpcf_physptr) AllocAbs( 4096, mpcfb->mpcf_physptr );
36 kprintf(DEBUG_NAME_STR ": SMP Table(s) protected\n");
38 else kprintf(DEBUG_NAME_STR ": NO compatable SMP hardware found.\n");
40 AvailCPUs = AllocMem( sizeof(struct CPU_Definition), MEMF_CLEAR | MEMF_PUBLIC ); /* Create our new CPU List */
42 if( AvailCPUs )
45 NEWLIST((struct List *)&(AvailCPUs->CPU_CPUList));
46 AvailCPUs->CPU_Physical = 1;
48 InitSemaphore( &CPUBase->CPUB_ListLock);
49 kprintf(DEBUG_NAME_STR ": Initialised CPU List Semaphore\n");
51 else
53 kprintf(DEBUG_NAME_STR ": ERROR - Couldnt allocate CPU list memory!\n");
54 return FALSE;
57 #warning TODO: Patch functions with suitable replacements (bug fixes/speed ups) - BEFORE SMP SETUP!
59 if ( mpcfb ) /* SMP? */
61 AllocAbs( 4096, smp_alloc_memory()); /* Create The Trampoline page..
62 Has to be in very low memory so we can execute
63 real-mode AP code. */
64 BootCPU->CPU_Private2 = mpcfb; /* Store the pointer to the SMP config block */
65 kprintf(DEBUG_NAME_STR ": SMP Trampoline page protected, SMP config stored.\n");
68 CPUBase->CPUB_Processors = AvailCPUs; // done !
70 AddTail(&AvailCPUs->CPU_CPUList,&BootCPU->CPU_CPUList);
71 kprintf(DEBUG_NAME_STR ": CPU List created = 0x%p, Boot CPU inserted..0x%p\n",AvailCPUs,BootCPU);
73 /* Parse the ACPI tables for possible boot-time SMP configuration. */
74 CPUBase->CPUB_ACPIBase = OpenResource("acpi.resource");
75 kprintf(DEBUG_NAME_STR ": acpi.resource @ %p\n",CPUBase->CPUB_ACPIBase);
77 ACPIBase = CPUBase->CPUB_ACPIBase;
78 ACPIBase->ACPIB_CPUBase = CPUBase; /* pass our base poiner over */
80 //ACPI_Init(); /* make sure ACPI is online .. */
82 if (mpcfb) get_smp_config( mpcfb, CPUBase );
84 return TRUE;
87 ADD2INITLIB(GM_UNIQUENAME(Init), 0)
89 /* WARNING!!! THIS NEXT FUNCTION RUS IN KERNEL LAND _ NO DEBUG OUTPUT ETC>> BE CAREFULL! */
91 void prepare_primary_cpu(struct ExecBase *SysBase)
93 struct i386_compat_intern *BootCPU_intern;
95 BootCPU = AllocMem( sizeof(struct CPU_Definition), MEMF_CLEAR | MEMF_PUBLIC ); /* Add the boot CPU to the CPU List */
96 if( BootCPU )
99 BootCPU->CPU_Family = CPU_Family_i386; /* we are i386 compatable.. */
100 BootCPU->CPU_Model = CPU_i386_386;
101 BootCPU->CPU_ID = 1; /* we are the only CPU at this time .. */
102 BootCPU->CPU_IsOnline = TRUE; /* CPU is online .. */
103 BootCPU->CPU_BootCPU = TRUE; /* CPU bootd system.. */
105 BootCPU_intern = AllocMem(sizeof(struct i386_compat_intern), MEMF_CLEAR | MEMF_PUBLIC ); /* Create its per CPU internal struct */
107 if( BootCPU_intern )
110 #warning TODO: The next line is broken - fix the checkcpu function
111 i386_CheckCPU_Type( BootCPU_intern );
113 BootCPU->CPU_Private1 = BootCPU_intern;
115 switch (BootCPU_intern->x86_model)
117 case 4:
118 BootCPU->CPU_Model = CPU_i386_486;
119 break;
120 case 5:
121 BootCPU->CPU_Model = CPU_i386_586;
122 break;
123 case 6:
124 BootCPU->CPU_Model = CPU_i386_686;
125 break;
126 case 7:
127 BootCPU->CPU_Model = CPU_i386_786;
128 break;
129 case 8:
130 BootCPU->CPU_Model = CPU_i386_886;
131 break;