aboutsummaryrefslogtreecommitdiff
path: root/devices/uart.h
blob: 53a4f4140484fc6ccbaf790bd1dee99a22087344 (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
#pragma once

#ifdef __ARCH__
#include <stdio.h>
#include <sys/io.h>

#else
// from stdio
typedef struct FILE {
  int id;
  void (*putc)(const struct FILE *, char);
  int (*puts)(const struct FILE *, const char *, int);
  void (*flush)(const struct FILE *);
} FILE;

// from sys/io
unsigned char inb(unsigned short);
void outb(unsigned char, unsigned short);

enum UART {
  COM1 = 0x3f8,
  COM2 = 0x2f8,
  COM3 = 0x3e8,
  COM4 = 0x2e8,
  COM5 = 0x5f8,
  COM6 = 0x4f8,
  COM7 = 0x5e8,
  COM8 = 0x4e8,
};
#endif

FILE *uart_init(unsigned short port);