This commit is contained in:
Mathieu Maret 2022-03-14 20:28:46 +01:00
parent 27e11dd6c7
commit 757c27c8a6
4 changed files with 40 additions and 12 deletions

View File

@ -2,5 +2,6 @@
int kernelmain(void) { int kernelmain(void) {
init_uart(); init_uart();
puts("Hello world\n");
return 0; return 0;
} }

29
mmio.h
View File

@ -3,11 +3,32 @@
// IO mapping // IO mapping
#define IO_BASE 0x3f000000 #define IO_BASE 0x3f000000
// Mini-UART mapping // System Timer
#define MU_BASE (IO_BASE + 0x215000) #define TIMER_BASE (IO_BASE + 0x3000)
// Intr mapping
#define INTERUPT_BASE (IO_BASE + 0xB000)
// Videocore mbox system
#define VCORE_MBOX (IO_BASE + 0x0000B880)
// Power manager
#define POWER_BASE (IO_BASE + 0x100000)
//Random gen
#define RANDOM_BASE (IO_BASE + 0x104000)
// GPIO mapping // GPIO mapping
#define GP_BASE (IO_BASE + 0x200000) #define GP_BASE (IO_BASE + 0x200000)
// videocore mbox system // UART0
#define VCORE_MBOX (IO_BASE + 0x0000B880) #define UART0_BASE (IO_BASE + 0x201000)
// Mini-UART mapping or UART1
#define MU_BASE (IO_BASE + 0x215000)
// External Mass Media Controller
#define SD_BASE (IO_BASE + 0x300000)
// USB
#define USB_BASE (IO_BASE + 0x980000)

5
uart.c
View File

@ -43,3 +43,8 @@ void putc(char c){
UART0_DR = c; UART0_DR = c;
} }
void puts(const char *s){
while(*s)
putc(*s++);
}

17
uart.h
View File

@ -2,14 +2,15 @@
#include "mmio.h" #include "mmio.h"
/* PL011 UART */ /* PL011 UART */
#define UART0_DR (*(volatile unsigned *)(IO_BASE + 0x00201000)) #define UART0_DR (*(volatile unsigned *)(UART0_BASE + 0x0))
#define UART0_FR (*(volatile unsigned *)(IO_BASE + 0x00201018)) #define UART0_FR (*(volatile unsigned *)(UART0_BASE + 0x18))
#define UART0_IBRD (*(volatile unsigned *)(IO_BASE + 0x00201024)) #define UART0_IBRD (*(volatile unsigned *)(UART0_BASE + 0x24))
#define UART0_FBRD (*(volatile unsigned *)(IO_BASE + 0x00201028)) #define UART0_FBRD (*(volatile unsigned *)(UART0_BASE + 0x28))
#define UART0_LCRH (*(volatile unsigned *)(IO_BASE + 0x0020102C)) #define UART0_LCRH (*(volatile unsigned *)(UART0_BASE + 0x2C))
#define UART0_CR (*(volatile unsigned *)(IO_BASE + 0x00201030)) #define UART0_CR (*(volatile unsigned *)(UART0_BASE + 0x30))
#define UART0_IMSC (*(volatile unsigned *)(IO_BASE + 0x00201038)) #define UART0_IMSC (*(volatile unsigned *)(UART0_BASE + 0x38))
#define UART0_ICR (*(volatile unsigned *)(IO_BASE + 0x00201044)) #define UART0_ICR (*(volatile unsigned *)(UART0_BASE + 0x44))
void init_uart(void); void init_uart(void);
void putc(char c); void putc(char c);
void puts(const char *s);