summaryrefslogtreecommitdiffstats
path: root/private/ntos/fw/ppc/ioaccess.h
blob: e6db7c06bd1c8c5d57dccb66c4f9962238ea1a80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*++

Copyright (c) 1990  Microsoft Corporation

Module Name:

    ioaccess.h

Abstract:

    This file contains the definitions to read and write IO registers.

Author:

    Lluis Abello (lluis) 1-May-91

Environment:

    Kernel mode

Revision History:

--*/

#ifndef _IOACCESS
#define _IOACCESS
//
// I/O space read and write macros.
//
#ifdef R4000
#undef READ_REGISTER_UCHAR
#undef READ_REGISTER_USHORT
#undef READ_REGISTER_ULONG
#undef WRITE_REGISTER_UCHAR
#undef WRITE_REGISTER_USHORT
#undef WRITE_REGISTER_ULONG
//    #define READ_REGISTER_UCHAR(x)  NtReadByte(x)
//    #define READ_REGISTER_USHORT(x) NtReadShort(x)
//    #define READ_REGISTER_ULONG(x)  NtReadLong(x)
//    #define WRITE_REGISTER_UCHAR(x, y)  NtFlushByteBuffer(x,y)
//    #define WRITE_REGISTER_USHORT(x, y) NtFlushShortBuffer(x,y)
//    #define WRITE_REGISTER_ULONG(x, y) NtFlushLongBuffer(x,y)
#define READ_REGISTER_UCHAR(x)   *(volatile UCHAR * const)(x)
#define READ_REGISTER_USHORT(x)  *(volatile USHORT * const)(x)
#define READ_REGISTER_ULONG(x)   *(volatile ULONG * const)(x)

#define WRITE_REGISTER_UCHAR(x, y)  *(volatile UCHAR * const)(x) = y
#define WRITE_REGISTER_USHORT(x, y) *(volatile USHORT * const)(x) = y
#define WRITE_REGISTER_ULONG(x, y)  *(volatile ULONG * const)(x) = y

#endif //R4000

#ifdef R3000
#undef READ_REGISTER_UCHAR
#undef READ_REGISTER_USHORT
#undef READ_REGISTER_ULONG
#undef WRITE_REGISTER_UCHAR
#undef WRITE_REGISTER_USHORT
#undef WRITE_REGISTER_ULONG

#define READ_REGISTER_UCHAR(x) \
    *(volatile UCHAR * const)(x)

#define READ_REGISTER_USHORT(x) \
    *(volatile USHORT * const)(x)

#define READ_REGISTER_ULONG(x) \
    *(volatile ULONG * const)(x)

#define WRITE_REGISTER_UCHAR(x, y) \
    *(volatile UCHAR * const)(x) = y; FlushWriteBuffer()

#define WRITE_REGISTER_USHORT(x, y) \
    *(volatile USHORT * const)(x) = y; FlushWriteBuffer()

#define WRITE_REGISTER_ULONG(x, y) \
    *(volatile ULONG * const)(x) = y; FlushWriteBuffer()
#endif //R3000
#endif //_IOACCESS