hrev44197 adds 3 changesets to branch 'master' old head: d6e724d5494b490ad4ea27ce0ea7a13e17cd8411 new head: 9b2efb1ad5aac036f622dd71e677b6f876a1e0da ---------------------------------------------------------------------------- 1630793: rPi: Fix missing % 361ec26: rPi MMU: Cleanup, add gPeripheralBase * gPeripheralBase keeps track of the device peripherals before and after mmu_init * Add ability to disable mmu for troubleshooting * Remove static FB_BASE, we actually don't know where the FB is yet. (depends on firmware used) 9b2efb1: rPi Console: Fix console vt100 calls * Use correct clear screen escape codes * Use correct set cursor location escape codes * Use correct set color escape codes [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- 5 files changed, 50 insertions(+), 33 deletions(-) headers/private/kernel/arch/arm/bcm2708.h | 4 +- .../boot/platform/raspberrypi_arm/console.cpp | 29 ++++++------ src/system/boot/platform/raspberrypi_arm/mmu.cpp | 37 +++++++++++----- .../boot/platform/raspberrypi_arm/serial.cpp | 7 ++- src/system/boot/platform/raspberrypi_arm/start.c | 6 ++- ############################################################################ Commit: 16307934faf5d843947d6eeae50c8e602aba5f85 URL: http://cgit.haiku-os.org/haiku/commit/?id=1630793 Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> Date: Tue May 22 14:51:52 2012 UTC rPi: Fix missing % ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/raspberrypi_arm/mmu.cpp b/src/system/boot/platform/raspberrypi_arm/mmu.cpp index f01bacc..aa486f2 100644 --- a/src/system/boot/platform/raspberrypi_arm/mmu.cpp +++ b/src/system/boot/platform/raspberrypi_arm/mmu.cpp @@ -242,7 +242,7 @@ static uint32 * get_next_page_table(uint32 type) { TRACE("%s: sNextPageTableAddress %p, kPageTableRegionEnd %p, " - "type 0x" B_PRIX32 "\n", __func__, sNextPageTableAddress, + "type 0x%" B_PRIX32 "\n", __func__, sNextPageTableAddress, kPageTableRegionEnd, type); size_t size = 0; ############################################################################ Commit: 361ec26f1029f32f21641431c135e12dac68d1d4 URL: http://cgit.haiku-os.org/haiku/commit/?id=361ec26 Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> Date: Thu May 24 10:48:10 2012 UTC rPi MMU: Cleanup, add gPeripheralBase * gPeripheralBase keeps track of the device peripherals before and after mmu_init * Add ability to disable mmu for troubleshooting * Remove static FB_BASE, we actually don't know where the FB is yet. (depends on firmware used) ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/arch/arm/bcm2708.h b/headers/private/kernel/arch/arm/bcm2708.h index 7408372..e124ae6 100644 --- a/headers/private/kernel/arch/arm/bcm2708.h +++ b/headers/private/kernel/arch/arm/bcm2708.h @@ -62,9 +62,7 @@ // SMI Base #define USB_BASE 0x980000 // USB Controller, 15.2, page 202 -#define FB_BASE 0x000000 - // Fake frame buffer -#define FB_SIZE SIZE_4K +// FB_BASE will depend on memory split // 7.5, page 112 diff --git a/src/system/boot/platform/raspberrypi_arm/mmu.cpp b/src/system/boot/platform/raspberrypi_arm/mmu.cpp index aa486f2..b80ad8b 100644 --- a/src/system/boot/platform/raspberrypi_arm/mmu.cpp +++ b/src/system/boot/platform/raspberrypi_arm/mmu.cpp @@ -40,9 +40,14 @@ // You also need to define ENABLE_SERIAL in serial.cpp // for output to work. +//#define DEBUG_DISABLE_MMU + + extern uint8 __stack_start; extern uint8 __stack_end; +extern addr_t gPeripheralBase; + /* *defines a block in memory @@ -60,6 +65,7 @@ struct memblock { static struct memblock LOADER_MEMORYMAP[] = { + // We map this first so we can always find peripherals { "devices", PERIPHERAL_BASE, @@ -114,20 +120,20 @@ static struct memblock LOADER_MEMORYMAP[] = { //static const uint32 kDefaultPageTableFlags = MMU_FLAG_READWRITE; // not cached not buffered, R/W -static const size_t kMaxKernelSize = 0x200000; // 2 MB for the kernel +static const size_t kMaxKernelSize = 0x200000; // 2 MB for the kernel -static addr_t sNextPhysicalAddress = 0; //will be set by mmu_init +static addr_t sNextPhysicalAddress = 0; // will be set by mmu_init static addr_t sNextVirtualAddress = KERNEL_BASE + kMaxKernelSize; static addr_t sMaxVirtualAddress = KERNEL_BASE + kMaxKernelSize; static addr_t sNextPageTableAddress = 0; -//the page directory is in front of the pagetable +// the page directory is in front of the pagetable static uint32 kPageTableRegionEnd = 0; // working page directory and page table static uint32 *sPageDirectory = 0 ; -//page directory has to be on a multiple of 16MB for -//some arm processors +// page directory has to be on a multiple of 16MB for +// some arm processors static addr_t @@ -141,11 +147,13 @@ get_next_virtual_address(size_t size) static addr_t -get_next_virtual_address_alligned (size_t size, uint32 mask) +get_next_virtual_address_alligned(size_t size, uint32 mask) { - addr_t address = (sNextVirtualAddress) & mask; + addr_t address = sNextVirtualAddress & mask; sNextVirtualAddress = address + size; + TRACE("%s: %p\n", __func__, (void*)address); + return address; } @@ -190,7 +198,7 @@ get_next_physical_page(size_t pagesize) void mmu_set_TTBR(uint32 ttb) { - TRACE("%s: Set Translation Table Base to 0x%lx\n", __func__); + TRACE("%s: Set Translation Table Base to 0x%" B_PRIx32 "\n", __func__, ttb); ttb &= 0xffffc000; asm volatile("MRC p15, 0, %[adr], c2, c0, 0"::[adr] "r" (ttb)); } @@ -233,7 +241,8 @@ mmu_write_C1(uint32 value) void mmu_write_DACR(uint32 value) { - TRACE("%s: Set Domain Access Register to 0x%lx\n", __func__); + TRACE("%s: Set Domain Access Register to 0x%" B_PRIx32 "\n", + __func__, value); asm volatile("MCR p15, 0, %[c1in], c3, c0, 0"::[c1in] "r" (value)); } @@ -242,7 +251,7 @@ static uint32 * get_next_page_table(uint32 type) { TRACE("%s: sNextPageTableAddress %p, kPageTableRegionEnd %p, " - "type 0x%" B_PRIX32 "\n", __func__, sNextPageTableAddress, + "type 0x%" B_PRIx32 "\n", __func__, sNextPageTableAddress, kPageTableRegionEnd, type); size_t size = 0; @@ -289,7 +298,7 @@ init_page_directory() sPageDirectory[i] = 0; uint32 *pageTable = NULL; - for (uint32 i = 0; i < ARRAY_SIZE(LOADER_MEMORYMAP);i++) { + for (uint32 i = 0; i < ARRAY_SIZE(LOADER_MEMORYMAP); i++) { pageTable = get_next_page_table(MMU_L1_TYPE_COARSE); TRACE("BLOCK: %s START: %lx END %lx\n", LOADER_MEMORYMAP[i].name, @@ -328,12 +337,16 @@ init_page_directory() // TLB Flush mmu_flush_TLB(); - // Set domain access register + // Set domain access register, manager access to all mmu_write_DACR(0xFFFFFFFF); + #ifndef DEBUG_DISABLE_MMU TRACE("%s: Enable MMU...\n", __func__); mmu_write_C1(mmu_read_C1() | 0x1); + gPeripheralBase = sNextVirtualAddress; + #endif + TRACE("%s: Complete\n", __func__); } diff --git a/src/system/boot/platform/raspberrypi_arm/serial.cpp b/src/system/boot/platform/raspberrypi_arm/serial.cpp index b97d0b7..c64f45b 100644 --- a/src/system/boot/platform/raspberrypi_arm/serial.cpp +++ b/src/system/boot/platform/raspberrypi_arm/serial.cpp @@ -23,6 +23,7 @@ DebugUART *gUART; static bool sSerialEnabled = false; +extern addr_t gPeripheralBase; static void @@ -88,10 +89,8 @@ serial_cleanup(void) extern "C" void serial_init(void) { - addr_t uart0 = mmu_map_physical_memory(PERIPHERAL_BASE + BOARD_UART_DEBUG, - 0x00004000, kDefaultPageFlags); - - gUART = arch_get_uart_pl011(uart0, BOARD_UART_CLOCK); + gUART = arch_get_uart_pl011(gPeripheralBase + BOARD_UART_DEBUG, + 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 6b3de48..8887e34 100644 --- a/src/system/boot/platform/raspberrypi_arm/start.c +++ b/src/system/boot/platform/raspberrypi_arm/start.c @@ -37,6 +37,9 @@ extern uint8 __stack_end; extern int main(stage2_args *args); void _start(void); +// Adjusted during mmu_init +addr_t gPeripheralBase = PERIPHERAL_BASE; + static void clear_bss(void) @@ -112,8 +115,9 @@ pi_start(void) gpio_init(); // Flick on "OK" led, use pre-mmu firmware base - gpio_write(PERIPHERAL_BASE + GPIO_BASE, 16, 0); + gpio_write(gPeripheralBase + GPIO_BASE, 16, 0); + // To debug mmu, enable serial_init above me! mmu_init(); serial_init(); ############################################################################ Revision: hrev44197 Commit: 9b2efb1ad5aac036f622dd71e677b6f876a1e0da URL: http://cgit.haiku-os.org/haiku/commit/?id=9b2efb1 Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> Date: Thu May 24 11:17:22 2012 UTC rPi Console: Fix console vt100 calls * Use correct clear screen escape codes * Use correct set cursor location escape codes * Use correct set color escape codes ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/raspberrypi_arm/console.cpp b/src/system/boot/platform/raspberrypi_arm/console.cpp index 5a12a31..a3c7f1f 100644 --- a/src/system/boot/platform/raspberrypi_arm/console.cpp +++ b/src/system/boot/platform/raspberrypi_arm/console.cpp @@ -98,38 +98,41 @@ VTConsole::VTConsole() void VTConsole::ClearScreen() { - WriteAt(NULL, 0LL, "\033E", 2); + WriteAt(NULL, 0LL, "\033[2J", 4); } void VTConsole::SetCursor(int32 x, int32 y) { - char buff[] = "\033Y "; + char buffer[8]; x = MIN(79, MAX(0, x)); y = MIN(24, MAX(0, y)); - buff[3] += (char)x; - buff[2] += (char)y; - WriteAt(NULL, 0LL, buff, 4); + int len = snprintf(buffer, sizeof(buffer), + "\033[%" B_PRId32 ";%" B_PRId32 "H", y, x); + WriteAt(NULL, 0LL, buffer, len); } void VTConsole::SetColor(int32 foreground, int32 background) { + return; static const char cmap[] = { - 15, 4, 2, 6, 1, 5, 3, 7, - 8, 12, 10, 14, 9, 13, 11, 0 }; - char buff[] = "\033b \033c "; + 0, 4, 2, 6, 1, 5, 3, 7 }; + char buffer[12]; - if (foreground < 0 && foreground >= 16) + if (foreground < 0 && foreground >= 8) return; - if (background < 0 && background >= 16) + if (background < 0 && background >= 8) return; - buff[2] += cmap[foreground]; - buff[5] += cmap[background]; - WriteAt(NULL, 0LL, buff, 6); + // We assume normal display attributes here + int len = snprintf(buffer, sizeof(buffer), + "\033[#0;3%" B_PRId32 ";4%" B_PRId32 "m", + cmap[foreground], cmap[background]); + + WriteAt(NULL, 0LL, buffer, len); }