rPi MMU: Working towards mapped memory

* BCM2708 defines no longer assume 0x20 address
  We will be throwing away the blob memory mapping
  and using our own.
* Use existing blob mapping to turn GPIO led on pre mmu_init
* Remap MMU hardware addresses from 0x7E. We could map each device,
  however the kernel will throw away the mappings again anyway. For
  now we just map the whole range and use offsets.
* Serial uart no longer works, however at least
  we know why now :). Serial driver now needs to
  use mapped address.
This commit is contained in:
Alexander von Gluck IV 2012-05-18 10:16:02 -05:00
parent 80cbddc9f7
commit b8733e36c7
3 changed files with 24 additions and 54 deletions

View File

@ -37,32 +37,33 @@
*/
// 1.2.2 notes that peripherals are remapped from 0x7e to 0x20
#define BCM2708_SDRAM_BASE 0x00000000
#define BCM2708_PERI_BASE 0x20000000
#define BCM2708_SDRAM_BASE 0x00000000
#define BCM2708_DEVICEHW_BASE 0x7E000000 // Real Hardware Base
#define BCM2708_DEVICEFW_BASE 0x20000000 // Firmware Mapped Base
#define ST_BASE (BCM2708_PERI_BASE + 0x3000)
#define ST_BASE 0x3000
// System Timer, sec 12.0, page 172
#define DMA_BASE (BCM2708_PERI_BASE + 0x7000)
#define DMA_BASE 0x7000
// DMA Controller, sec 4.2, page 39
#define ARM_BASE (BCM2708_PERI_BASE + 0xB000)
#define ARM_BASE 0xB000
// BCM2708 ARM Control Block, sec 7.5, page 112
#define PM_BASE (BCM2708_PERI_BASE + 0x100000)
#define PM_BASE 0x100000
// Power Management, Reset controller and Watchdog registers
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
#define GPIO_BASE 0x200000
// GPIO, sec 6.1, page 90
#define UART0_BASE (BCM2708_PERI_BASE + 0x201000)
#define UART0_BASE 0x201000
// UART 0, sec 13.4, page 177
#define MMCI0_BASE (BCM2708_PERI_BASE + 0x202000)
#define MMCI0_BASE 0x202000
// MMC
#define UART1_BASE (BCM2708_PERI_BASE + 0x215000)
#define UART1_BASE 0x215000
// UART 1, sec 2.1, page 65
#define EMMC_BASE (BCM2708_PERI_BASE + 0x300000)
#define EMMC_BASE 0x300000
// eMMC interface, sec 5, page 66
#define SMI_BASE (BCM2708_PERI_BASE + 0x600000)
#define SMI_BASE 0x600000
// SMI Base
#define USB_BASE (BCM2708_PERI_BASE + 0x980000)
#define USB_BASE 0x980000
// USB Controller, 15.2, page 202
#define FB_BASE (BCM2708_PERI_BASE + 0x0000)
#define FB_BASE 0x000000
// Fake frame buffer
#define FB_SIZE SIZE_4K
@ -79,8 +80,8 @@
#define VECT_BASE 0xffff0000
#define VECT_SIZE SIZE_4K
#define PERIPHERAL_BASE BCM2708_PERI_BASE
#define PERIPHERAL_SIZE 0x1000000
#define DEVICE_BASE BCM2708_DEVICEHW_BASE
#define DEVICE_SIZE 0x1000000
#define SDRAM_BASE BCM2708_SDRAM_BASE
#define SDRAM_SIZE 0x4000000

View File

@ -14,9 +14,7 @@
#include <boot/stage2.h>
#include <arch/cpu.h>
#include <arch_kernel.h>
#ifdef __ARM__
#include <arm_mmu.h>
#endif
#include <kernel.h>
#include <board_config.h>
@ -28,7 +26,7 @@
#define TRACE_MMU
#ifdef TRACE_MMU
# define TRACE(x...) dprintf("mmu: " x)
# define TRACE(x...) dprintf("mmu: " x)
# define CALLED() dprintf("%s()\n", __func__)
#else
# define TRACE(x) ;
@ -46,29 +44,6 @@ extern uint8 __stack_start;
extern uint8 __stack_end;
#ifdef __ARM__
/*
TODO:
-recycle bit!
*/
/*! The (physical) memory layout of the boot loader is currently as follows:
0x00000000 u-boot (run from NOR flash)
0xa0000000 u-boot stuff like kernel arguments afaik
0xa0100000 - 0xa0ffffff boot.tgz (up to 15MB probably never needed so big...)
0xa1000000 - 0xa1ffffff pagetables
0xa2000000 - ? code (up to 1MB)
0xa2100000 boot loader heap / free physical memory
The kernel is mapped at KERNEL_BASE, all other stuff mapped by the
loader (kernel args, modules, driver settings, ...) comes after
0x80020000 which means that there is currently only 2 MB reserved for
the kernel itself (see kMaxKernelSize).
*/
/*
*defines a block in memory
*/
@ -87,8 +62,8 @@ struct memblock {
static struct memblock LOADER_MEMORYMAP[] = {
{
"devices",
PERIPHERAL_BASE,
PERIPHERAL_BASE + PERIPHERAL_SIZE - 1,
DEVICE_BASE,
DEVICE_BASE + DEVICE_SIZE - 1,
MMU_L2_FLAG_B,
},
{
@ -554,7 +529,6 @@ mmu_free(void *virtualAddress, size_t size)
sNextVirtualAddress -= size;
}
}
#endif
/*! Sets up the final and kernel accessible GDT and IDT tables.

View File

@ -111,19 +111,14 @@ pi_start(void)
cpu_init();
gpio_init();
// Flick on "OK" led
gpio_write(GPIO_BASE, 16, 0);
// Flick on "OK" led, use pre-mmu firmware base
gpio_write(BCM2708_DEVICEFW_BASE + GPIO_BASE, 16, 0);
mmu_init();
serial_init();
console_init();
/*
* TODO: Move befpre gpio_init
* Once memory mapping is working, uart + gpio should
* use mapped peripheral addresses
*/
mmu_init();
args.heap_size = HEAP_SIZE;
args.arguments = NULL;