improved uart character printing and poweroff/restart
This commit is contained in:
parent
10851eeb64
commit
8cd08165e0
6 changed files with 66 additions and 7 deletions
27
src/drivers/uart.c
Normal file
27
src/drivers/uart.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <drivers/uart.h>
|
||||
|
||||
void uart_put(size_t base_addr, uint8_t data) {
|
||||
*(volatile uint8_t *)base_addr = data;
|
||||
}
|
||||
|
||||
int kputchar(int ch) {
|
||||
uart_put(UART_ADDRESS, ch);
|
||||
return ch;
|
||||
}
|
||||
|
||||
void kprint(const char *str) {
|
||||
while (*str) {
|
||||
kputchar(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void knewline(void) {
|
||||
kputchar('\n');
|
||||
}
|
||||
|
||||
void kputs(const char *str) {
|
||||
kprint(str);
|
||||
knewline();
|
||||
}
|
||||
9
src/drivers/uart.h
Normal file
9
src/drivers/uart.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef UART_H
|
||||
#define UART_H
|
||||
|
||||
#define UART_ADDRESS 0x10000000
|
||||
void uart_put(size_t base_addr, uint8_t data);
|
||||
int kputchar(int ch);
|
||||
void kputs(const char *str);
|
||||
void kprint(const char *str);
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue