···38763876F: arch/powerpc/platforms/52xx/3877387738783878LINUX FOR POWERPC EMBEDDED PPC4XX38793879-M: Josh Boyer <jwboyer@linux.vnet.ibm.com>38793879+M: Josh Boyer <jwboyer@gmail.com>38803880M: Matt Porter <mporter@kernel.crashing.org>38813881W: http://www.penguinppc.org/38823882L: linuxppc-dev@lists.ozlabs.org
+1-1
arch/powerpc/Kconfig
···842842843843config RELOCATABLE844844 bool "Build a relocatable kernel (EXPERIMENTAL)"845845- depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE845845+ depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && (FSL_BOOKE || PPC_47x)846846 help847847 This builds a kernel image that is capable of running at the848848 location the kernel is loaded at (some alignment restrictions may
···34343535BSS_STACK(4096);36363737+static u32 ibm4xx_memstart;3838+3739static void iss_4xx_fixups(void)3840{3939- ibm4xx_sdram_fixup_memsize();4141+ void *memory;4242+ u32 reg[3];4343+4444+ memory = finddevice("/memory");4545+ if (!memory)4646+ fatal("Can't find memory node\n");4747+ /* This assumes #address-cells = 2, #size-cells =1 and that */4848+ getprop(memory, "reg", reg, sizeof(reg));4949+ if (reg[2])5050+ /* If the device tree specifies the memory range, use it */5151+ ibm4xx_memstart = reg[1];5252+ else5353+ /* othersize, read it from the SDRAM controller */5454+ ibm4xx_sdram_fixup_memsize();5555+}5656+5757+static void *iss_4xx_vmlinux_alloc(unsigned long size)5858+{5959+ return (void *)ibm4xx_memstart;4060}41614262#define SPRN_PIR 0x11E /* Processor Indentification Register */···68486949 simple_alloc_init(_end, avail_ram, 128, 64);7050 platform_ops.fixups = iss_4xx_fixups;5151+ platform_ops.vmlinux_alloc = iss_4xx_vmlinux_alloc;7152 platform_ops.exit = ibm44x_dbcr_reset;7253 pir_reg = mfspr(SPRN_PIR);7354 fdt_set_boot_cpuid_phys(_dtb_start, pir_reg);
+3-3
arch/powerpc/configs/44x/iss476-smp_defconfig
···33CONFIG_EXPERIMENTAL=y44CONFIG_SYSVIPC=y55CONFIG_POSIX_MQUEUE=y66+CONFIG_SPARSE_IRQ=y67CONFIG_LOG_BUF_SHIFT=1477-CONFIG_SYSFS_DEPRECATED_V2=y88CONFIG_BLK_DEV_INITRD=y99# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set1010CONFIG_EXPERT=y···2121CONFIG_HZ_100=y2222CONFIG_MATH_EMULATION=y2323CONFIG_IRQ_ALL_CPUS=y2424-CONFIG_SPARSE_IRQ=y2524CONFIG_CMDLINE_BOOL=y2625CONFIG_CMDLINE="root=/dev/issblk0"2726# CONFIG_PCI is not set2727+CONFIG_ADVANCED_OPTIONS=y2828+CONFIG_RELOCATABLE=y2829CONFIG_NET=y2930CONFIG_PACKET=y3031CONFIG_UNIX=y···6867# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set6968CONFIG_EXT3_FS_POSIX_ACL=y7069CONFIG_EXT3_FS_SECURITY=y7171-CONFIG_INOTIFY=y7270CONFIG_PROC_KCORE=y7371CONFIG_TMPFS=y7472CONFIG_CRAMFS=y
···93939494 bl early_init95959696+#ifdef CONFIG_RELOCATABLE9797+ /*9898+ * r25 will contain RPN/ERPN for the start address of memory9999+ *100100+ * Add the difference between KERNELBASE and PAGE_OFFSET to the101101+ * start of physical memory to get kernstart_addr.102102+ */103103+ lis r3,kernstart_addr@ha104104+ la r3,kernstart_addr@l(r3)105105+106106+ lis r4,KERNELBASE@h107107+ ori r4,r4,KERNELBASE@l108108+ lis r5,PAGE_OFFSET@h109109+ ori r5,r5,PAGE_OFFSET@l110110+ subf r4,r5,r4111111+112112+ rlwinm r6,r25,0,28,31 /* ERPN */113113+ rlwinm r7,r25,0,0,3 /* RPN - assuming 256 MB page size */114114+ add r7,r7,r4115115+116116+ stw r6,0(r3)117117+ stw r7,4(r3)118118+#endif119119+96120/*97121 * Decide what sort of machine this is and initialize the MMU.98122 */···10251001 lis r3,PAGE_OFFSET@h10261002 ori r3,r3,PAGE_OFFSET@l1027100310281028- /* Kernel is at the base of RAM */10291029- li r4, 0 /* Load the kernel physical address */10301030-10311004 /* Load the kernel PID = 0 */10321005 li r0,010331006 mtspr SPRN_PID,r0···10341013 clrrwi r3,r3,12 /* Mask off the effective page number */10351014 ori r3,r3,PPC47x_TLB0_VALID | PPC47x_TLB0_256M1036101510371037- /* Word 1 */10381038- clrrwi r4,r4,12 /* Mask off the real page number */10391039- /* ERPN is 0 for first 4GB page */10161016+ /* Word 1 - use r25. RPN is the same as the original entry */10171017+10401018 /* Word 2 */10411019 li r5,010421020 ori r5,r5,PPC47x_TLB2_S_RWX···10461026 /* We write to way 0 and bolted 0 */10471027 lis r0,0x880010481028 tlbwe r3,r0,010491049- tlbwe r4,r0,110291029+ tlbwe r25,r0,110501030 tlbwe r5,r0,21051103110521032/*···11441124 lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */11451125 mtspr SPRN_IVPR,r41146112611471147- addis r22,r22,KERNELBASE@h11271127+ /*11281128+ * If the kernel was loaded at a non-zero 256 MB page, we need to11291129+ * mask off the most significant 4 bits to get the relative address11301130+ * from the start of physical memory11311131+ */11321132+ rlwinm r22,r22,0,4,3111331133+ addis r22,r22,PAGE_OFFSET@h11481134 mtlr r2211491135 isync11501136 blr
+2
arch/powerpc/kernel/setup_32.c
···127127 /* Do some early initialization based on the flat device tree */128128 early_init_devtree(__va(dt_ptr));129129130130+ early_init_mmu();131131+130132 probe_machine();131133132134 setup_kdump_trampoline();
+10-3
arch/powerpc/mm/44x_mmu.c
···186186unsigned long __init mmu_mapin_ram(unsigned long top)187187{188188 unsigned long addr;189189+ unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);189190190191 /* Pin in enough TLBs to cover any lowmem not covered by the191192 * initial 256M mapping established in head_44x.S */192192- for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;193193+ for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;193194 addr += PPC_PIN_SIZE) {194195 if (mmu_has_feature(MMU_FTR_TYPE_47x))195196 ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);···219218void setup_initial_memory_limit(phys_addr_t first_memblock_base,220219 phys_addr_t first_memblock_size)221220{221221+ u64 size;222222+223223+#ifndef CONFIG_RELOCATABLE222224 /* We don't currently support the first MEMBLOCK not mapping 0223225 * physical on those processors224226 */225227 BUG_ON(first_memblock_base != 0);228228+#endif226229227230 /* 44x has a 256M TLB entry pinned at boot */228228- memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));231231+ size = (min_t(u64, first_memblock_size, PPC_PIN_SIZE));232232+ memblock_set_current_limit(first_memblock_base + size);229233}230234231235#ifdef CONFIG_SMP232236void __cpuinit mmu_init_secondary(int cpu)233237{234238 unsigned long addr;239239+ unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);235240236241 /* Pin in enough TLBs to cover any lowmem not covered by the237242 * initial 256M mapping established in head_44x.S···248241 * stack. current (r2) isn't initialized, smp_processor_id()249242 * will not work, current thread info isn't accessible, ...250243 */251251- for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;244244+ for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;252245 addr += PPC_PIN_SIZE) {253246 if (mmu_has_feature(MMU_FTR_TYPE_47x))254247 ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);