source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/ddk/ioaccess.h@ 1194

Last change on this file since 1194 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 2.4 KB
Line 
1/*
2 * ioaccess.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * THIS SOFTWARE IS NOT COPYRIGHTED
9 *
10 * This source code is offered for use in the public domain. You may
11 * use, modify or distribute it freely.
12 *
13 * This code is distributed in the hope that it will be useful but
14 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15 * DISCLAIMED. This includes but is not limited to warranties of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 *
18 */
19#ifndef __IOACCESS_H
20#define __IOACCESS_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define H2I(p) PtrToUshort(p)
27
28#ifndef NO_PORT_MACROS
29
30#if defined(_X86_) || defined(_M_AMD64)
31#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR *)(r))
32#define READ_REGISTER_USHORT(r) (*(volatile USHORT *)(r))
33#define READ_REGISTER_ULONG(r) (*(volatile ULONG *)(r))
34#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR *)(r) = (v))
35#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
36#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
37#define READ_PORT_UCHAR(p) (UCHAR)(__inbyte (H2I(p)))
38#define READ_PORT_USHORT(p) (USHORT)(__inword (H2I(p)))
39#define READ_PORT_ULONG(p) (ULONG)(__indword (H2I(p)))
40#define WRITE_PORT_UCHAR(p, v) __outbyte (H2I(p), (v))
41#define WRITE_PORT_USHORT(p, v) __outword (H2I(p), (v))
42#define WRITE_PORT_ULONG(p, v) __outdword (H2I(p), (v))
43
44#define MEMORY_BARRIER()
45
46#elif defined(_PPC_) || defined(_MIPS_) || defined(_ARM_)
47
48#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR * const)(r))
49#define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r))
50#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
51#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR * const)(r) = (v))
52#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT * const)(r) = (v))
53#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG * const)(r) = (v))
54#define READ_PORT_UCHAR(r) READ_REGISTER_UCHAR(r)
55#define READ_PORT_USHORT(r) READ_REGISTER_USHORT(r)
56#define READ_PORT_ULONG(r) READ_REGISTER_ULONG(r)
57#define WRITE_PORT_UCHAR(p, v) WRITE_REGISTER_UCHAR(p, (UCHAR) (v))
58#define WRITE_PORT_USHORT(p, v) WRITE_REGISTER_USHORT(p, (USHORT) (v))
59#define WRITE_PORT_ULONG(p, v) WRITE_REGISTER_ULONG(p, (ULONG) (v))
60
61#else
62
63#error Unsupported architecture
64
65#endif
66
67#endif /* NO_PORT_MACROS */
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* __IOACCESS_H */
Note: See TracBrowser for help on using the repository browser.