blob: 344803e4f3696f049e7a5c2e12f5192be63c34c1 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// Definitions for X86 IO port access.
2//
3// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4//
5// This file may be distributed under the terms of the GNU GPLv3 license.
6#ifndef __IOPORT_H
7#define __IOPORT_H
8
9#include "types.h" // u8
10
11#define PORT_DMA_ADDR_2 0x0004
12#define PORT_DMA_CNT_2 0x0005
13#define PORT_DMA1_MASK_REG 0x000a
14#define PORT_DMA1_MODE_REG 0x000b
15#define PORT_DMA1_CLEAR_FF_REG 0x000c
16#define PORT_DMA1_MASTER_CLEAR 0x000d
17#define PORT_PIC1 0x0020
18#define PORT_PIC1_DATA 0x0021
19#define PORT_PIT_COUNTER0 0x0040
20#define PORT_PIT_COUNTER1 0x0041
21#define PORT_PIT_COUNTER2 0x0042
22#define PORT_PIT_MODE 0x0043
23#define PORT_KBD_CTRLB 0x0061
24#define PORT_CMOS_INDEX 0x0070
25#define PORT_CMOS_DATA 0x0071
26#define PORT_DMA_PAGE_2 0x0081
27#define PORT_A20 0x0092
28#define PORT_PIC2 0x00a0
29#define PORT_PIC2_DATA 0x00a1
30#define PORT_DMA2_MASK_REG 0x00d4
31#define PORT_DMA2_MODE_REG 0x00d6
32#define PORT_DMA2_MASTER_CLEAR 0x00da
33#define PORT_FD_DOR 0x03f2
34#define PORT_FD_STATUS 0x03f4
35#define PORT_FD_DATA 0x03f5
36
37// PORT_PIC1 bitdefs
38#define PIC1_IRQ5 (1<<5)
39// PORT_PIC2 bitdefs
40#define PIC2_IRQ8 (1<<0)
41#define PIC2_IRQ13 (1<<5)
42
43// PORT_KBD_CTRLB bitdefs
44#define KBD_REFRESH (1<<4)
45
46
47static inline void outb(u8 value, u16 port) {
48 __asm__ __volatile__("outb %b0, %w1" : : "a"(value), "Nd"(port));
49}
50static inline u8 inb(u16 port) {
51 u8 value;
52 __asm__ __volatile__("inb %w1, %b0" : "=a"(value) : "Nd"(port));
53 return value;
54}
55
56#endif // ioport.h