Author: blueswirl Date: 2008-12-23 21:36:45 +0100 (Tue, 23 Dec 2008) New Revision: 322
Modified: openbios-devel/arch/ppc/qemu/init.c openbios-devel/arch/ppc/qemu/start.S Log: Get ram size from the configuration device
Modified: openbios-devel/arch/ppc/qemu/init.c =================================================================== --- openbios-devel/arch/ppc/qemu/init.c 2008-12-23 18:32:42 UTC (rev 321) +++ openbios-devel/arch/ppc/qemu/init.c 2008-12-23 20:36:45 UTC (rev 322) @@ -152,6 +152,9 @@
printk("CPUs: %x\n", temp);
+ temp = fw_cfg_read_i32(FW_CFG_RAM_SIZE); + printk("Memory: %dM\n", temp / 1024 / 1024); + fw_cfg_read(FW_CFG_UUID, qemu_uuid, 16);
printk("UUID: " UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], qemu_uuid[2],
Modified: openbios-devel/arch/ppc/qemu/start.S =================================================================== --- openbios-devel/arch/ppc/qemu/start.S 2008-12-23 18:32:42 UTC (rev 321) +++ openbios-devel/arch/ppc/qemu/start.S 2008-12-23 20:36:45 UTC (rev 322) @@ -356,43 +356,30 @@ isync blr
- /* compute RAM size - * - * Exception vectors are beween 0x00000000 and 0x00004000 - * RAM size is limited to 2 MB (0x80000000) - * MMIO and IO are after 0x80000000. - * ROM is at 0xfff00000 - * so we can scan from 0x4000 to 0x80000000 - * - */ + /* Get RAM size from Qemu configuration device */
+#define CFG_ADDR 0xf0000510 +#define FW_CFG_RAM_SIZE 0x03 + compute_ramsize: - li r3, 0x4000 /* start address */ + lis r9,HA(CFG_ADDR) + ori r9,r9,LO(CFG_ADDR) + li r0,FW_CFG_RAM_SIZE + sth r0,0(r9) + lis r9,HA(CFG_ADDR + 2) + ori r9,r9,LO(CFG_ADDR + 2) + lbz r1,0(r9) + lbz r0,0(r9) + slwi r0,r0,8 + or r1,r1,r0 + lbz r0,0(r9) + slwi r0,r0,16 + or r1,r1,r0 + lbz r0,0(r9) + slwi r0,r0,24 + or r3,r1,r0 + blr
- /* how many pages between 0x4000 and 0x80000000 */ - - lis r4, 0x0007 - ori r4, r4, 0xfffc - mtctr r4 - - /* pattern to write in memory */ - - lis r4, 0x55aa - ori r4, r4, 0x55aa - -memloop: - /* store and re-read pattern */ - - stw r4, 0(r3) - sync - lwz r0, 0(r3) - cmpw cr7, r0, r4 - bne cr7, exit_memloop - addi r3, r3, 4096 /* add page size */ - bdnz memloop -exit_memloop: - blr - /* Hard reset vector */ .section .romentry,"ax" bl _start