Annotation of ports/devel/openocd/patches/patch-src_jtag_gw16012_c, Revision 1.1.1.1
1.1 yason 1: $OpenBSD$
2: --- src/jtag/gw16012.c.orig Wed May 27 12:38:08 2009
3: +++ src/jtag/gw16012.c Wed May 27 12:50:08 2009
4: @@ -31,7 +31,7 @@
5:
6: /* system includes */
7: /* -ino: 060521-1036 */
8: -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
9: +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
10:
11: #include <sys/types.h>
12: #include <machine/sysarch.h>
13: @@ -45,7 +45,7 @@
14: #include "errno.h"
15: #endif /* _WIN32 */
16:
17: -#endif /* __FreeBSD__, __FreeBSD_kernel__ */
18: +#endif /* __FreeBSD__, __FreeBSD_kernel__, __OpenBSD__ */
19:
20: #include <string.h>
21: #include <stdlib.h>
22: @@ -63,7 +63,7 @@
23: #include <fcntl.h>
24: #include <sys/ioctl.h>
25: #else /* not PARPORT_USE_PPDEV */
26: -#ifndef _WIN32
27: +#if !defined(_WIN32) && !defined(__OpenBSD__)
28: #include <sys/io.h>
29: #endif
30: #endif
31: @@ -129,7 +129,7 @@ void gw16012_data(u8 value)
32: #if PARPORT_USE_PPDEV == 1
33: ioctl(device_handle, PPWDATA, &value);
34: #else
35: - #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
36: + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
37: outb(gw16012_port, value);
38: #else
39: outb(value, gw16012_port);
40: @@ -150,7 +150,7 @@ void gw16012_control(u8 value)
41: #if PARPORT_USE_PPDEV == 1
42: ioctl(device_handle, PPWCONTROL, &gw16012_control_value);
43: #else
44: - #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
45: + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
46: outb(gw16012_port + 2, gw16012_control_value);
47: #else
48: outb(gw16012_control_value, gw16012_port + 2);
49: @@ -469,6 +469,13 @@ int gw16012_init(void)
50: #endif
51: u8 status_port;
52:
53: +#ifdef __OpenBSD__
54: + u_long iopermtable[32] = {};
55: +
56: + /* get current i/o permission table */
57: + i386_get_ioperm(iopermtable);
58: +#endif /* __OpenBSD__ */
59: +
60: #if PARPORT_USE_PPDEV == 1
61: if (device_handle>0)
62: {
63: @@ -530,7 +537,16 @@ int gw16012_init(void)
64: #if PARPORT_USE_GIVEIO == 1
65: if (gw16012_get_giveio_access() != 0)
66: #else /* PARPORT_USE_GIVEIO */
67: +#ifdef __FreeBSD__
68: if (ioperm(gw16012_port, 3, 1) != 0)
69: +#endif /* __FreeBSD__ */
70: +#ifdef __OpenBSD__
71: + /* request access to desired i/o port */
72: + iopermtable[gw16012_port / 32] &= ~(1 << gw16012_port % 32);
73: + iopermtable[gw16012_port / 32] &= ~(1 << gw16012_port % 32 + 1);
74: + iopermtable[gw16012_port / 32] &= ~(1 << gw16012_port % 32 + 2);
75: + if (i386_set_ioperm(iopermtable) != 0)
76: +#endif /* __OpenBSD__ */
77: #endif /* PARPORT_USE_GIVEIO */
78: {
79: LOG_ERROR("missing privileges for direct i/o");
80: @@ -539,7 +555,7 @@ int gw16012_init(void)
81: LOG_DEBUG("...privileges granted");
82:
83: /* make sure parallel port is in right mode (clear tristate and interrupt */
84: -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
85: +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
86: outb(gw16012_port + 2, 0x0);
87: #else
88: outb(0x0, gw16012_port + 2);
CVSweb