baseport/syborg/soundsc/virtio_defs.h
author Gareth Long <garethl@symbian.org>
Tue, 29 Jun 2010 15:10:15 +0100
branchnvmemory
changeset 80 e9514b7eeead
parent 45 01c1ffcc4fca
permissions -rw-r--r--
RAM size change for full UI, modified syborg.dt*, included mouse pointer fix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     1
/*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     2
* This component and the accompanying materials are made available
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     3
* under the terms of the License "Eclipse Public License v1.0"
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     4
* which accompanies this distribution, and is available
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     5
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     6
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     7
* Initial Contributors:
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     8
* Accenture Ltd
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
     9
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    10
* Contributors:
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    11
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    12
* Description: This file is a part of sound driver for Syborg adaptation.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    13
*
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    14
*/
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    15
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    16
#ifndef VIRTIO_DEFS_H
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    17
#define VIRTIO_DEFS_H
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    18
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    19
#include <e32def.h>
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    20
#include <kernel.h> // fot TPhysAddr
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    21
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    22
/// @file virtio_defs.h
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    23
/// most of definitions here come from VirtIo spec
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    24
/// and was made compatible to the qemu backend (which means diverged from spec)
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    25
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    26
namespace VirtIo
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    27
{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    28
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    29
#define POW2ALIGN1(x) ((x)|((x)>>1))
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    30
#define POW2ALIGN2(x) ((x)|((x)>>2))
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    31
#define POW2ALIGN4(x) ((x)|((x)>>4))
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    32
#define POW2ALIGN8(x) ((x)|((x)>>8))
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    33
#define POW2ALIGN16(x) ((x)|((x)>>16))
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    34
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    35
///@brief Alignes \a x to the closest bigger or equal power2 value
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    36
#define POW2ALIGN(x) (POW2ALIGN16(POW2ALIGN8(POW2ALIGN4(POW2ALIGN2(POW2ALIGN1((x)-1)))))+1)
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    37
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    38
static const TUint KVirtIoAlignment = 0x1000;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    39
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    40
enum 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    41
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    42
	EStatusReset = 0,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    43
	EStatusAcknowledge = 1,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    44
	EStatusDriverFound = 2,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    45
	EStatusDriverInitialised = 4,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    46
	EStatusFailed = 0x80
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    47
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    48
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    49
enum 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    50
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    51
    EIoID             = 0,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    52
    EIoDevType        = 1,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    53
    EIoHostFeatures  = 2,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    54
    EIoGuestFeatures = 3,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    55
    EIoQueueBase     = 4,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    56
    EIoQueueSize      = 5,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    57
    EIoQueueSelect      = 6,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    58
    EIoQueueNotify   = 7,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    59
    EIoStatus	  	  = 8,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    60
    EIoInterruptEnable     = 9,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    61
    EIoInterruptStatus     = 10
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    62
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    63
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    64
struct TRingDesc
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    65
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    66
	enum 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    67
		{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    68
		EFlagNext = 1,
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    69
		EFlagWrite = 2
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    70
		};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    71
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    72
	TUint64 iAddr;	// physical address
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    73
	TUint32 iLen;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    74
	TUint16 iFlags;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    75
	TUint16 iNext;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    76
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    77
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    78
struct TRingAvail
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    79
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    80
	enum { EFlagInhibitNotifications = 1 };
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    81
	TUint16 iFlags;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    82
	TUint16 iIdx;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    83
	TUint16 iRing[1];
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    84
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    85
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    86
struct TRingUsed
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    87
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    88
	enum { EFlagInhibitNotifications = 1 };
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    89
	TUint16 iFlags;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    90
	TUint16 iIdx;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    91
		struct 
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    92
		{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    93
		TUint32 iId;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    94
		TUint32 iLen;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    95
		} iRing[1];
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    96
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    97
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    98
/// @brief Represents element of scatter gather list
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
    99
struct TAddrLen
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   100
	{
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   101
	TPhysAddr iAddr;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   102
	TUint32 iLen;
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   103
	};
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   104
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   105
/// Gives a pointer resulting with aliging \a v with \a a.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   106
/// @note \a a must be power of 2.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   107
template <typename T> T* Align( T* v, TUint a )
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   108
	{ return (T*)( ((TUint8*)v) + ((-(TUint)v)&(a-1)) ); }
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   109
	
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   110
/// Gives a pointer resulting with aliging \a v with \a a.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   111
/// @note \a a must be power of 2.
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   112
template <typename T> T Align( T v, TUint a )
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   113
	{ return (v)+((-v)&(a-1)); }
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   114
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   115
}
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   116
01c1ffcc4fca Audio driver for qemu simulator
Maciej Jablonski <maciej.jablonski@accenture.com>
parents:
diff changeset
   117
#endif