diff --git a/hello.c b/hello.c index 6631ada..75514e4 100644 --- a/hello.c +++ b/hello.c @@ -2,5 +2,6 @@ int kernelmain(void) { init_uart(); + puts("Hello world\n"); return 0; } diff --git a/mmio.h b/mmio.h index 3f98913..88f7034 100644 --- a/mmio.h +++ b/mmio.h @@ -3,11 +3,32 @@ // IO mapping #define IO_BASE 0x3f000000 -// Mini-UART mapping -#define MU_BASE (IO_BASE + 0x215000) +// System Timer +#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 #define GP_BASE (IO_BASE + 0x200000) -// videocore mbox system -#define VCORE_MBOX (IO_BASE + 0x0000B880) +// UART0 +#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) diff --git a/uart.c b/uart.c index e3d1ca9..838708b 100644 --- a/uart.c +++ b/uart.c @@ -43,3 +43,8 @@ void putc(char c){ UART0_DR = c; } + +void puts(const char *s){ + while(*s) + putc(*s++); +} diff --git a/uart.h b/uart.h index c0d4777..2fa910e 100644 --- a/uart.h +++ b/uart.h @@ -2,14 +2,15 @@ #include "mmio.h" /* PL011 UART */ -#define UART0_DR (*(volatile unsigned *)(IO_BASE + 0x00201000)) -#define UART0_FR (*(volatile unsigned *)(IO_BASE + 0x00201018)) -#define UART0_IBRD (*(volatile unsigned *)(IO_BASE + 0x00201024)) -#define UART0_FBRD (*(volatile unsigned *)(IO_BASE + 0x00201028)) -#define UART0_LCRH (*(volatile unsigned *)(IO_BASE + 0x0020102C)) -#define UART0_CR (*(volatile unsigned *)(IO_BASE + 0x00201030)) -#define UART0_IMSC (*(volatile unsigned *)(IO_BASE + 0x00201038)) -#define UART0_ICR (*(volatile unsigned *)(IO_BASE + 0x00201044)) +#define UART0_DR (*(volatile unsigned *)(UART0_BASE + 0x0)) +#define UART0_FR (*(volatile unsigned *)(UART0_BASE + 0x18)) +#define UART0_IBRD (*(volatile unsigned *)(UART0_BASE + 0x24)) +#define UART0_FBRD (*(volatile unsigned *)(UART0_BASE + 0x28)) +#define UART0_LCRH (*(volatile unsigned *)(UART0_BASE + 0x2C)) +#define UART0_CR (*(volatile unsigned *)(UART0_BASE + 0x30)) +#define UART0_IMSC (*(volatile unsigned *)(UART0_BASE + 0x38)) +#define UART0_ICR (*(volatile unsigned *)(UART0_BASE + 0x44)) void init_uart(void); void putc(char c); +void puts(const char *s);