Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\nkernsmp\x86\nk_plat.h
16 // WARNING: This file contains some APIs which are internal and are subject
17 // to change without notice. Such APIs should therefore not be used
18 // outside the Kernel and Hardware Services package.
30 // TSubScheduler member data
31 #define i_IrqCount iExtras[9] // count of interrupts handled
32 #define i_ExcInfo iExtras[10] // pointer to exception info for crash debugger
33 #define i_CrashState iExtras[11] // 0=normal, 1=this CPU faulted, 2=this CPU has received an NMI and halted
34 #define i_APICID iExtras[12] // Local APIC ID for this CPU (starts at -1)
35 #define i_IrqNestCount iExtras[13] // IRQ nest count for this CPU (starts at -1)
36 #define i_IrqStackTop iExtras[14] // Top of IRQ stack for this CPU
37 #define i_Tss iExtras[15] // Address of TSS for this CPU
38 #define i_TimerMultF iExtras[16] // Timer frequency / Max Timer frequency * 2^32
39 #define i_TimerMultI iExtras[17] // Max Timer frequency / Timer frequency * 2^24
40 #define i_CpuMult iExtras[18] // CPU frequency / Max CPU frequency * 2^32
41 #define i_TimestampOffset iExtras[20] // 64 bit value to add to CPU TSC to give NKern::Timestamp()
42 #define i_TimestampOffsetL iExtras[20] //
43 #define i_TimestampOffsetH iExtras[21] //
45 // TScheduler member data
46 #define i_TimerMax iExtras[16] // Maximum per-CPU timer frequency (after prescaling)
48 #define CRASH_IPI_VECTOR 0x27
49 #define RESCHED_IPI_VECTOR 0x28
50 #define TIMESLICE_VECTOR 0x29
51 #define GENERIC_IPI_VECTOR 0x2A
52 #define TRANSFERRED_IRQ_VECTOR 0x2E
53 #define SPURIOUS_INTERRUPT_VECTOR 0x2F
55 extern "C" TSubScheduler* SubSchedulerLookupTable[256]; // look up subscheduler from APIC ID
57 #define IRQ_STACK_SIZE 1024
59 //#define __SCHEDULER_MACHINE_CODED__
60 //#define __DFC_MACHINE_CODED__
61 //#define __MSTIM_MACHINE_CODED__
62 //#define __PRI_LIST_MACHINE_CODED__
63 //#define __FAST_SEM_MACHINE_CODED__
64 //#define __FAST_MUTEX_MACHINE_CODED__
67 class NThread : public NThreadBase
70 TInt Create(SNThreadCreateInfo& anInfo, TBool aInitial);
71 inline void Stillborn()
73 void GetUserContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
74 void SetUserContext(const TX86RegSet& aContext, TUint32& aRegMask);
75 void GetSystemContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
76 void CompleteContextSave();
78 TUint64 iCoprocessorState[64]; // state of FPU, SSE, SSE2
81 __ASSERT_COMPILE(!(_FOFF(NThread,iCoprocessorState)&7));
84 // Positions of registers on stack, relative to saved SP
85 struct SThreadReschedStack
93 // Registers pushed on stack for all exceptions other than slow exec
94 struct SThreadExcStack
112 TUint32 iEsp3; // only if iCs does not indicate CPL=0
113 TUint32 iSs3; // only if iCs does not indicate CPL=0
116 // Registers pushed on stack for slow exec
117 struct SThreadSlowExecStack
130 TUint32 iArgs[8]; // space for extra arguments copied from user side
136 TUint32 iEsp3; // only if iCs does not indicate CPL=0
137 TUint32 iSs3; // only if iCs does not indicate CPL=0
140 // Top of stack after thread creation for threads with parameter block passed
142 struct SThreadStackStub
144 enum {EVector=0xffffffffu};
145 TLinAddr iPBlock; // pointer to parameter block
153 // Stack structure at thread creation either at top of stack (if parameter block
154 // passed by reference) or below parameter block if passed by value.
155 struct SThreadInitStack
157 enum {EVector=0xfffffffeu};
158 SThreadReschedStack iR;
164 GLREF_D TLinAddr X86_IrqHandler;
165 GLREF_D SCpuIdleHandler CpuIdleHandler;
166 GLREF_D TUint32 X86_CPUID;
167 GLREF_D TBool X86_UseGlobalPTEs;
168 GLREF_D TUint64 DefaultCoprocessorState[64];
171 /** Ensure the ordering of explicit memory writes
173 On x86 this is a no-op
176 #define smp_wmb() wmb()
178 /** Ensure the ordering of explicit memory accesses
180 On x86 any instruction with the LOCK prefix does this
183 #define mb() __asm__ __volatile__("lock add dword ptr [esp], 0" : : : "memory")
185 #define mb() do { _asm lock add dword ptr [esp], 0 } while (0)
187 #define smp_mb() mb()