kernel/eka/include/nkernsmp/x86/nk_plat.h
changeset 90 947f0dc9f7a8
parent 0 a41df078684a
child 177 a232af6b0b1f
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
    25 
    25 
    26 #ifndef __NK_X86_H__
    26 #ifndef __NK_X86_H__
    27 #define __NK_X86_H__
    27 #define __NK_X86_H__
    28 #include <nk_cpu.h>
    28 #include <nk_cpu.h>
    29 
    29 
       
    30 class TSubScheduler;
       
    31 class TScheduler;
       
    32 struct TX86Tss;
       
    33 
    30 // TSubScheduler member data
    34 // TSubScheduler member data
    31 #define	i_IrqCount			iExtras[9]		// count of interrupts handled
    35 struct TSubSchedulerX
    32 #define	i_ExcInfo			iExtras[10]		// pointer to exception info for crash debugger
    36 	{
    33 #define	i_CrashState		iExtras[11]		// 0=normal, 1=this CPU faulted, 2=this CPU has received an NMI and halted
    37 	TUint32				iSSXP[9];
    34 #define	i_APICID			iExtras[12]		// Local APIC ID for this CPU (starts at -1)
    38 	volatile TUint32	iIrqCount;				// count of interrupts handled
    35 #define	i_IrqNestCount		iExtras[13]		// IRQ nest count for this CPU (starts at -1)
    39 	TAny*				iExcInfo;				// pointer to exception info for crash debugger
    36 #define	i_IrqStackTop		iExtras[14]		// Top of IRQ stack for this CPU
    40 	volatile TInt		iCrashState;			// 0=normal, 1=this CPU faulted, 2=this CPU has received an NMI and halted
    37 #define	i_Tss				iExtras[15]		// Address of TSS for this CPU
    41 	TUint32				iAPICID;				// Local APIC ID for this CPU (starts at -1)
    38 #define	i_TimerMultF		iExtras[16]		// Timer frequency / Max Timer frequency * 2^32
    42 	volatile TInt		iIrqNestCount;			// IRQ nest count for this CPU (starts at -1)
    39 #define	i_TimerMultI		iExtras[17]		// Max Timer frequency / Timer frequency * 2^24
    43 	TLinAddr			iIrqStackTop;			// Top of IRQ stack for this CPU
    40 #define	i_CpuMult			iExtras[18]		// CPU frequency / Max CPU frequency * 2^32
    44 	TX86Tss*			iTss;					// Address of TSS for this CPU
    41 #define	i_TimestampOffset	iExtras[20]		// 64 bit value to add to CPU TSC to give NKern::Timestamp()
    45 	volatile TUint32	iCpuFreqM;				// CPU frequency / Max CPU frequency (mantissa, bit 31=1) f/fmax=M/2^(S+32) <=1
    42 #define	i_TimestampOffsetL	iExtras[20]		// 
    46 	volatile TInt		iCpuFreqS;				// CPU frequency / Max CPU frequency (shift)
    43 #define	i_TimestampOffsetH	iExtras[21]		// 
    47 	volatile TUint32	iCpuPeriodM;			// Max CPU frequency / CPU frequency (mantissa, bit 31=1) fmax/f=M/2^S >=1
       
    48 	volatile TInt		iCpuPeriodS;			// Max CPU frequency / CPU frequency (shift)
       
    49 	volatile TUint32	iNTimerFreqM;			// Nominal Timer frequency / Max Timer frequency (mantissa, bit 31=1) f/fmax=M/2^(S+32) <=1
       
    50 	volatile TInt		iNTimerFreqS;			// Nominal Timer frequency / Max Timer frequency (shift)
       
    51 	volatile TUint32	iNTimerPeriodM;			// Nominal Max Timer frequency / Timer frequency (mantissa, bit 31=1) fmax/f=M/2^S >=1
       
    52 	volatile TInt		iNTimerPeriodS;			// Nominal Max Timer frequency / Timer frequency (shift)
       
    53 	volatile TUint32	iTimerFreqM;			// Timer frequency / Max Timer frequency (mantissa, bit 31=1) f/fmax=M/2^(S+32) <=1
       
    54 	volatile TInt		iTimerFreqS;			// Timer frequency / Max Timer frequency (shift)
       
    55 	volatile TUint32	iTimerPeriodM;			// Max Timer frequency / Timer frequency (mantissa, bit 31=1) fmax/f=M/2^S >=1
       
    56 	volatile TInt		iTimerPeriodS;			// Max Timer frequency / Timer frequency (shift)
       
    57 	volatile TUint64HL	iTimestampOffset;		// 64 bit value to add to CPU TSC to give NKern::Timestamp()
       
    58 
       
    59 	TUint32				iSSXP2[32];
       
    60 	TUint64				iSSXP3;					// one 64 bit value to guarantee alignment
       
    61 	};
    44 
    62 
    45 // TScheduler member data
    63 // TScheduler member data
    46 #define	i_TimerMax		iExtras[16]		// Maximum per-CPU timer frequency (after prescaling)
    64 struct TSchedulerX
       
    65 	{
       
    66 	TUint64				iTimerMax;				// Maximum per-CPU timer frequency (after prescaling)
       
    67 	TUint32				iSXP[14];
       
    68 	};
       
    69 
    47 
    70 
    48 #define CRASH_IPI_VECTOR			0x27
    71 #define CRASH_IPI_VECTOR			0x27
    49 #define RESCHED_IPI_VECTOR			0x28
    72 #define RESCHED_IPI_VECTOR			0x28
    50 #define TIMESLICE_VECTOR			0x29
    73 #define TIMESLICE_VECTOR			0x29
    51 #define GENERIC_IPI_VECTOR			0x2A
    74 #define GENERIC_IPI_VECTOR			0x2A
    66 class TX86RegSet;
    89 class TX86RegSet;
    67 class NThread : public NThreadBase
    90 class NThread : public NThreadBase
    68 	{
    91 	{
    69 public:
    92 public:
    70 	TInt Create(SNThreadCreateInfo& anInfo, TBool aInitial);
    93 	TInt Create(SNThreadCreateInfo& anInfo, TBool aInitial);
    71 	inline void Stillborn()
    94 	void Stillborn();
    72 		{}
       
    73 	void GetUserContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
    95 	void GetUserContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
    74 	void SetUserContext(const TX86RegSet& aContext, TUint32& aRegMask);
    96 	void SetUserContext(const TX86RegSet& aContext, TUint32& aRegMask);
    75 	void GetSystemContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
    97 	void GetSystemContext(TX86RegSet& aContext, TUint32& aAvailRegMask);
    76 	void CompleteContextSave();
    98 	void CompleteContextSave();
    77 public:
    99 public:
   185 #define	mb()	do { _asm lock add dword ptr [esp], 0 } while (0)
   207 #define	mb()	do { _asm lock add dword ptr [esp], 0 } while (0)
   186 #endif
   208 #endif
   187 #define smp_mb()	mb()
   209 #define smp_mb()	mb()
   188 
   210 
   189 
   211 
       
   212 /**
       
   213 @internalComponent
       
   214 */
       
   215 extern "C" void send_resched_ipis(TUint32 aMask);
       
   216 
   190 
   217 
   191 // End of file
   218 // End of file
   192 #endif
   219 #endif