--- qemu/roms/openbios/arch/sparc64/openbios.c 2018/04/24 19:19:39 1.1.1.1 +++ qemu/roms/openbios/arch/sparc64/openbios.c 2018/04/24 19:37:57 1.1.1.2 @@ -21,7 +21,8 @@ #include "../../drivers/timer.h" // XXX #define NO_QEMU_PROTOS #include "arch/common/fw_cfg.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc64/ofmem_sparc64.h" +#include "spitfire.h" #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" @@ -34,8 +35,6 @@ #define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */ -static ucell *memory; - // XXX #define NVRAM_SIZE 0x2000 #define NVRAM_IDPROM 0x1fd8 @@ -64,7 +63,7 @@ static const struct hwdef hwdefs[] = { .cfg_base = APB_SPECIAL_BASE, .cfg_len = 0x2000000, .host_mem_base = APB_MEM_BASE, - .pci_mem_base = 0, + .pci_mem_base = 0x100000, /* avoid VGA at 0xa0000 */ .mem_len = 0x10000000, .io_base = APB_SPECIAL_BASE + 0x2000000ULL, // PCI Bus I/O space .io_len = 0x10000, @@ -553,17 +552,28 @@ void udelay(unsigned int usecs) static void init_memory(void) { - memory = malloc(MEMORY_SIZE); - if (!memory) - printk("panic: not enough memory on host system.\n"); + phys_addr_t phys; + ucell virt; + + /* Claim the memory from OFMEM (align to 512K so we only take 1 TLB slot) */ + phys = ofmem_claim_phys(-1, MEMORY_SIZE, PAGE_SIZE_512K); + if (!phys) + printk("panic: not enough physical memory on host system.\n"); + + virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE_512K); + if (!virt) + printk("panic: not enough virtual memory on host system.\n"); + + /* Generate the mapping (and lock translation into the TLBs) */ + ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys) | SPITFIRE_TTE_LOCKED); /* we push start and end of memory to the stack * so that it can be used by the forth word QUIT * to initialize the memory allocator */ - - PUSH((ucell)memory); - PUSH((ucell)memory + (ucell)MEMORY_SIZE); + + PUSH(virt); + PUSH(virt + MEMORY_SIZE); } static void