sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: #include "plat_priv.h" sl@0: #include "d_mstim.h" sl@0: sl@0: #if defined(__X86__) sl@0: typedef TUint TCounter; sl@0: TUint32* TickCountPtr; sl@0: sl@0: const TLinAddr NTimerQ_TimerAddress = (TLinAddr)&NTimerQ::TimerAddress; sl@0: sl@0: __NAKED__ TCounter TIMER() sl@0: { sl@0: asm("mov eax, [%a0]": :"i"(&TickCountPtr)); sl@0: asm("pushfd"); sl@0: asm("mov eax, [eax]"); sl@0: asm("cli"); sl@0: asm("shl eax, 16"); sl@0: asm("mov al, 0x80"); // channel 2 latch cmd sl@0: asm("out 0x43, al"); sl@0: asm("in al, 0x42"); // get ls byte sl@0: asm("mov ah, al"); sl@0: asm("in al, 0x42"); // get ms byte sl@0: asm("xchg al, ah"); sl@0: asm("popfd"); sl@0: asm("ret"); sl@0: } sl@0: sl@0: __NAKED__ void SetUpTimerChannel2() sl@0: { sl@0: asm("pushfd"); sl@0: asm("cli"); sl@0: asm("in al, 0x61"); sl@0: asm("and al, 0xfc"); // disable speaker sl@0: asm("or al, 1"); // enable timer channel 2 sl@0: asm("out 0x61, al"); sl@0: asm("mov al, 0xb4"); sl@0: asm("out 0x43, al"); // timer chan 2 mode 2 sl@0: asm("mov al, 0"); sl@0: asm("out 0x42, al"); // initial count 0 = free running sl@0: asm("out 0x42, al"); sl@0: asm("popfd"); sl@0: asm("call %a0": :"i"(NTimerQ_TimerAddress)); sl@0: asm("lea eax, [eax+%0]": :"i"_FOFF(NTimerQ,iMsCount)); sl@0: asm("mov [%a0], eax": :"i"(&TickCountPtr)); sl@0: asm("ret"); sl@0: } sl@0: #endif