From 9c5e60f6560e909effa2a5d31b3a630c23198aac Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 22 May 2012 07:03:56 -0500 Subject: [PATCH] rPi MMU: Fixes to hrev44189 * I had the wrong addresses, 0x20 was the physical address not a mapped one. * Attempt to map uart in mmu post mmu_init. --- headers/private/kernel/arch/arm/bcm2708.h | 11 +++++------ src/system/boot/platform/raspberrypi_arm/mmu.cpp | 16 +++++++++------- .../boot/platform/raspberrypi_arm/serial.cpp | 6 +++++- src/system/boot/platform/raspberrypi_arm/start.c | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/headers/private/kernel/arch/arm/bcm2708.h b/headers/private/kernel/arch/arm/bcm2708.h index 010851ccef..740837224b 100644 --- a/headers/private/kernel/arch/arm/bcm2708.h +++ b/headers/private/kernel/arch/arm/bcm2708.h @@ -36,10 +36,9 @@ * - BCM2835-ARM-Peripherals.pdf */ -// 1.2.2 notes that peripherals are remapped from 0x7e to 0x20 +// Section 1.2.2 #define BCM2708_SDRAM_BASE 0x00000000 -#define BCM2708_DEVICEHW_BASE 0x7E000000 // Real Hardware Base -#define BCM2708_DEVICEFW_BASE 0x20000000 // Firmware Mapped Base +#define BCM2708_PERIPHERAL_BASE 0x20000000 #define ST_BASE 0x3000 // System Timer, sec 12.0, page 172 @@ -77,11 +76,11 @@ #define ARM_CTRL_0_SBM_BASE (ARM_BASE + 0x800) // ARM Semaphores, Doorbells, and Mailboxes -#define VECT_BASE 0xffff0000 +#define VECT_BASE 0xFFFF0000 #define VECT_SIZE SIZE_4K -#define DEVICE_BASE BCM2708_DEVICEHW_BASE -#define DEVICE_SIZE 0x1000000 +#define PERIPHERAL_BASE BCM2708_PERIPHERAL_BASE +#define PERIPHERAL_SIZE 0xFFFFFF #define SDRAM_BASE BCM2708_SDRAM_BASE #define SDRAM_SIZE 0x4000000 diff --git a/src/system/boot/platform/raspberrypi_arm/mmu.cpp b/src/system/boot/platform/raspberrypi_arm/mmu.cpp index e628255c90..f5f0368dda 100644 --- a/src/system/boot/platform/raspberrypi_arm/mmu.cpp +++ b/src/system/boot/platform/raspberrypi_arm/mmu.cpp @@ -62,12 +62,16 @@ struct memblock { static struct memblock LOADER_MEMORYMAP[] = { { "devices", - DEVICE_BASE, - DEVICE_BASE + DEVICE_SIZE - 1, + PERIPHERAL_BASE, + PERIPHERAL_BASE + PERIPHERAL_SIZE, MMU_L2_FLAG_B, }, + // Device memory between 0x0 and 0x10000000 + // (0x0) Ram / Video ram (0x10000000) (256MB) + // We don't detect the split yet, se we have to be + // careful not to run into video ram. { - "RAM_loader", // 1MB loader + "RAM_loader", // 1MB for the loader SDRAM_BASE + 0, SDRAM_BASE + 0x0fffff, MMU_L2_FLAG_C, @@ -84,7 +88,6 @@ static struct memblock LOADER_MEMORYMAP[] = { SDRAM_BASE + 0x11FFFFF, MMU_L2_FLAG_C, }, -#if 0 { "RAM_stack", // stack SDRAM_BASE + 0x1200000, @@ -97,7 +100,7 @@ static struct memblock LOADER_MEMORYMAP[] = { SDRAM_BASE + 0x2500000, MMU_L2_FLAG_C, }, - + // (0x2500000 ~37MB) #ifdef FB_BASE { "framebuffer", // 2MB framebuffer ram @@ -106,7 +109,6 @@ static struct memblock LOADER_MEMORYMAP[] = { MMU_L2_FLAG_AP_RW|MMU_L2_FLAG_C, }, #endif -#endif }; @@ -585,7 +587,7 @@ mmu_init(void) { CALLED(); - mmu_write_C1(mmu_read_C1() & ~((1<<29)|(1<<28)|(1<<0))); + mmu_write_C1(mmu_read_C1() & ~((1 << 29) | (1 << 28) | (1 << 0))); // access flag disabled, TEX remap disabled, mmu disabled uint32 highestRAMAddress = SDRAM_BASE; diff --git a/src/system/boot/platform/raspberrypi_arm/serial.cpp b/src/system/boot/platform/raspberrypi_arm/serial.cpp index 3d58f87011..b97d0b7a6a 100644 --- a/src/system/boot/platform/raspberrypi_arm/serial.cpp +++ b/src/system/boot/platform/raspberrypi_arm/serial.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "mmu.h" #include @@ -87,7 +88,10 @@ serial_cleanup(void) extern "C" void serial_init(void) { - gUART = arch_get_uart_pl011(BOARD_UART_DEBUG, BOARD_UART_CLOCK); + addr_t uart0 = mmu_map_physical_memory(PERIPHERAL_BASE + BOARD_UART_DEBUG, + 0x00004000, kDefaultPageFlags); + + gUART = arch_get_uart_pl011(uart0, BOARD_UART_CLOCK); gUART->InitEarly(); gUART->InitPort(9600); diff --git a/src/system/boot/platform/raspberrypi_arm/start.c b/src/system/boot/platform/raspberrypi_arm/start.c index c7ee41ed85..6b3de48b38 100644 --- a/src/system/boot/platform/raspberrypi_arm/start.c +++ b/src/system/boot/platform/raspberrypi_arm/start.c @@ -112,7 +112,7 @@ pi_start(void) gpio_init(); // Flick on "OK" led, use pre-mmu firmware base - gpio_write(BCM2708_DEVICEFW_BASE + GPIO_BASE, 16, 0); + gpio_write(PERIPHERAL_BASE + GPIO_BASE, 16, 0); mmu_init();