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