NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
console_serial.h
1/*
2 * Serial Console
3 *
4 * Copyright (C) 2009-2011 Udo Steinberg <udo@hypervisor.org>
5 * Economic rights: Technische Universitaet Dresden (Germany)
6 *
7 * This file is part of the NOVA microhypervisor.
8 *
9 * NOVA is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * NOVA is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License version 2 for more details.
17 */
18
19#pragma once
20
21#include "compiler.h"
22#include "console.h"
23#include "io.h"
24
25class Console_serial : public Console
26{
27 private:
28 enum Reg
29 {
30 RHR = 0, // Receive Holding Register (read)
31 THR = 0, // Transmit Holding Register (write)
32 IER = 1, // Interrupt Enable Register (write)
33 ISR = 2, // Interrupt Status Register (read)
34 FCR = 2, // FIFO Control Register (write)
35 LCR = 3, // Line Control Register (write)
36 MCR = 4, // Modem Control Register (write)
37 LSR = 5, // Line Status Register (read)
38 MSR = 6, // Modem Status Register (read)
39 SPR = 7, // Scratchpad Register (read/write)
40 DLR_LO = 0,
41 DLR_HI = 1,
42 };
43
44 unsigned base;
45
46 ALWAYS_INLINE
47 inline unsigned in (Reg reg) { return Io::in<uint8>(base + reg); }
48
49 ALWAYS_INLINE
50 inline void out (Reg reg, unsigned val) { Io::out (base + reg, static_cast<uint8>(val)); }
51
52 void putc (int c);
53
54 public:
55 INIT
56 void init();
57};
Definition console_serial.h:26