kerneltest/e32test/system/d_mstim.cia
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include "plat_priv.h"
       
    18 #include "d_mstim.h"
       
    19 
       
    20 #if defined(__X86__)
       
    21 typedef TUint TCounter;
       
    22 TUint32* TickCountPtr;
       
    23 
       
    24 const TLinAddr NTimerQ_TimerAddress = (TLinAddr)&NTimerQ::TimerAddress;
       
    25 
       
    26 __NAKED__ TCounter TIMER()
       
    27 	{
       
    28 	asm("mov eax, [%a0]": :"i"(&TickCountPtr));
       
    29 	asm("pushfd");
       
    30 	asm("mov eax, [eax]");
       
    31 	asm("cli");
       
    32 	asm("shl eax, 16");
       
    33 	asm("mov al, 0x80");	// channel 2 latch cmd
       
    34 	asm("out 0x43, al");
       
    35 	asm("in al, 0x42");		// get ls byte
       
    36 	asm("mov ah, al");
       
    37 	asm("in al, 0x42");		// get ms byte
       
    38 	asm("xchg al, ah");
       
    39 	asm("popfd");
       
    40 	asm("ret");
       
    41 	}
       
    42 
       
    43 __NAKED__ void SetUpTimerChannel2()
       
    44 	{
       
    45 	asm("pushfd");
       
    46 	asm("cli");
       
    47 	asm("in al, 0x61");
       
    48 	asm("and al, 0xfc");	// disable speaker
       
    49 	asm("or al, 1");		// enable timer channel 2
       
    50 	asm("out 0x61, al");
       
    51 	asm("mov al, 0xb4");
       
    52 	asm("out 0x43, al");	// timer chan 2 mode 2
       
    53 	asm("mov al, 0");
       
    54 	asm("out 0x42, al");	// initial count 0 = free running
       
    55 	asm("out 0x42, al");
       
    56 	asm("popfd");
       
    57 	asm("call %a0": :"i"(NTimerQ_TimerAddress));
       
    58 	asm("lea eax, [eax+%0]": :"i"_FOFF(NTimerQ,iMsCount));
       
    59 	asm("mov [%a0], eax": :"i"(&TickCountPtr));
       
    60 	asm("ret");
       
    61 	}
       
    62 #endif