summaryrefslogtreecommitdiff
path: root/sysutils/memtestplus/patches/patch-ab
blob: 6c1a0eed8095a27183c7e517ac84822487f9c580 (plain)
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
$NetBSD: patch-ab,v 1.5 2013/12/08 00:35:28 jakllsch Exp $

--- test.c.orig	2013-08-10 02:29:44.000000000 +0000
+++ test.c
@@ -14,7 +14,6 @@
 #include "stdint.h"
 #include "cpuid.h"
 #include "smp.h"
-#include <sys/io.h>
 
 extern struct cpu_ident cpu_id;
 extern volatile int    mstr_cpu;
@@ -29,6 +28,36 @@ void rand_seed( unsigned int seed1, unsi
 ulong rand(int me);
 void poll_errors();
 
+static inline void outb(unsigned char value, unsigned short int port)
+{
+	asm __volatile__ (
+		"outb %b0,%w1\n\t"
+		: :"a" (value), "Nd" (port)
+	);
+}
+
+static __inline void outb_p(unsigned char value, unsigned short int port)
+{
+	asm __volatile__ (
+		"outb %b0,%w1\n\t"
+		"outb %%al,$0x80\n\t"
+		: : "a" (value), "Nd" (port)
+	);
+}
+
+static __inline unsigned char inb_p(unsigned short int port)
+{
+	unsigned char v;
+
+  	asm __volatile__ (
+		"inb %w1,%0\n\t"
+		"outb %%al,$0x80\n\t"
+		: "=a" (v)
+		: "Nd" (port)
+	);
+	return v;
+}
+
 static inline ulong roundup(ulong value, ulong mask)
 {
 	return (value + mask) & ~mask;