Move uart into its own translation unit
This commit is contained in:
parent
f48e74bebe
commit
74fdd26759
3 changed files with 20 additions and 11 deletions
9
lib/uart.c
Normal file
9
lib/uart.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/* QEMU memory maps a UART device here. */
|
||||||
|
#define UART_BASE ((volatile char *)0x10000000)
|
||||||
|
|
||||||
|
void uart_putc(char c) { *UART_BASE = c; }
|
||||||
|
|
||||||
|
void uart_puts(const char *s) {
|
||||||
|
while (*s) uart_putc(*s++);
|
||||||
|
}
|
||||||
|
|
10
lib/uart.h
Normal file
10
lib/uart.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef UART_KERNEL_H
|
||||||
|
#define UART_KERNEL_H
|
||||||
|
|
||||||
|
/** Send a single character to the UART device */
|
||||||
|
void uart_putc(char c);
|
||||||
|
|
||||||
|
/** Send a **NULL TERMINATED** string to the UART device */
|
||||||
|
void uart_puts(const char *s);
|
||||||
|
|
||||||
|
#endif
|
12
start.c
12
start.c
|
@ -2,17 +2,7 @@
|
||||||
#include <riscv.h>
|
#include <riscv.h>
|
||||||
#include <spinlock.h>
|
#include <spinlock.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
#include <uart.h>
|
||||||
/* QEMU memory maps a UART device here. */
|
|
||||||
#define UART_BASE ((volatile char *)0x10000000)
|
|
||||||
|
|
||||||
/** Send a single character to the UART device */
|
|
||||||
void uart_putc(char c) { *UART_BASE = c; }
|
|
||||||
|
|
||||||
/** Send a **NULL TERMINATED** string to the UART device */
|
|
||||||
void uart_puts(const char *s) {
|
|
||||||
while (*s) uart_putc(*s++);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate one stack per CPU (hart).
|
* Allocate one stack per CPU (hart).
|
||||||
|
|
Loading…
Add table
Reference in a new issue