File: getMB-isa.c

package info (click to toggle)
xmbmon 2.05-8
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 928 kB
  • ctags: 910
  • sloc: ansic: 6,089; sh: 2,151; perl: 87; makefile: 79
file content (77 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (5)
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

/* ISA IO port method for accessing Hardware Monitor Chip */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "methods.h"

/* ioport_base, global */
int isa_port_base  = IOP_ADDR;

#include <fcntl.h>
#include <unistd.h>

#include "io_static.c"


#define INDEX_REG_PORT (isa_port_base + 0x05)
#define DATA_PORT      (isa_port_base + 0x06)

static int ReadByte(int addr)
{
	int ret;
	OUTb(INDEX_REG_PORT, addr); WAIT;
	ret = INb(DATA_PORT); WAIT;
	return (ret & 0xFF);
}

static void WriteByte(int addr, int value)
{
	OUTb(INDEX_REG_PORT, addr); WAIT;
	OUTb(DATA_PORT, value); WAIT;
}

static int ReadWord(int addr)
{
	int ret;
	OUTb(INDEX_REG_PORT, addr); WAIT;
	ret = INw(DATA_PORT); WAIT;
	return (ret & 0xFFFF);
}

static void WriteWord(int addr, int value)
{
	OUTb(INDEX_REG_PORT, addr); WAIT;
	OUTw(DATA_PORT, value); WAIT;
}

static int ReadTemp1()
{
	int ret;
	WriteByte(0x4E, 0x01);	/* changing to bank 1 */
	ret = ReadByte(0x50) | (ReadByte(0x51) << 8);
	WriteByte(0x4E, 0x00);	/* returning to bank 0 */
	return ret;
}

static int ReadTemp2()
{
	int ret;
	WriteByte(0x4E, 0x02);	/* changing to bank 2 */
	ret = ReadByte(0x50) | (ReadByte(0x51) << 8);
	WriteByte(0x4E, 0x00);	/* returning to bank 0 */
	return ret;
}

struct lm_methods method_isa = {
	OpenIO,
	CloseIO,
	ReadByte,
	WriteByte,
	ReadWord,
	WriteWord,
	ReadTemp1,
	ReadTemp2
};