Commit d0ecd2aaf9ecc2c434eed4c5de7917787476223e

Authored by bellard
1 parent b3783731

added cpu_physical_memory_write_rom()


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1833 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 41 additions and 0 deletions
cpu-all.h
... ... @@ -857,6 +857,8 @@ void stw_phys(target_phys_addr_t addr, uint32_t val);
857 857 void stl_phys(target_phys_addr_t addr, uint32_t val);
858 858 void stq_phys(target_phys_addr_t addr, uint64_t val);
859 859  
  860 +void cpu_physical_memory_write_rom(target_phys_addr_t addr,
  861 + const uint8_t *buf, int len);
860 862 int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
861 863 uint8_t *buf, int len, int is_write);
862 864  
... ...
... ... @@ -2080,6 +2080,45 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
2080 2080 }
2081 2081 }
2082 2082  
  2083 +/* used for ROM loading : can write in RAM and ROM */
  2084 +void cpu_physical_memory_write_rom(target_phys_addr_t addr,
  2085 + const uint8_t *buf, int len)
  2086 +{
  2087 + int l;
  2088 + uint8_t *ptr;
  2089 + target_phys_addr_t page;
  2090 + unsigned long pd;
  2091 + PhysPageDesc *p;
  2092 +
  2093 + while (len > 0) {
  2094 + page = addr & TARGET_PAGE_MASK;
  2095 + l = (page + TARGET_PAGE_SIZE) - addr;
  2096 + if (l > len)
  2097 + l = len;
  2098 + p = phys_page_find(page >> TARGET_PAGE_BITS);
  2099 + if (!p) {
  2100 + pd = IO_MEM_UNASSIGNED;
  2101 + } else {
  2102 + pd = p->phys_offset;
  2103 + }
  2104 +
  2105 + if ((pd & ~TARGET_PAGE_MASK) != IO_MEM_RAM &&
  2106 + (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM) {
  2107 + /* do nothing */
  2108 + } else {
  2109 + unsigned long addr1;
  2110 + addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
  2111 + /* ROM/RAM case */
  2112 + ptr = phys_ram_base + addr1;
  2113 + memcpy(ptr, buf, l);
  2114 + }
  2115 + len -= l;
  2116 + buf += l;
  2117 + addr += l;
  2118 + }
  2119 +}
  2120 +
  2121 +
2083 2122 /* warning: addr must be aligned */
2084 2123 uint32_t ldl_phys(target_phys_addr_t addr)
2085 2124 {
... ...