m68k pull request 20220120
Fix virt-m68k reboot -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmHpHuYSHGxhdXJlbnRA dml2aWVyLmV1AAoJEPMMOL0/L748TnEP/jZI+yoGPq9uD/mkTH88+s4XjfRbN65G dN9oyPP8UznPtg6rVlG2JXgqrGHLXRVYZVHAUYJUwnHHUJyLUvklmgs/wKDSzlBq Mr6h1fPMCgF/+zj7eQBMa5jMdG2uIgPtJ2/9A6ypHYjjs86ZHR/63dPs3vEZtwW9 y49Qod3PAjw25qQdrlx1sk0I+rMpaiAWJn72O6C5lYCtlBonDZRaZYFulpBWEbg3 oi7+640dN/KKOvAME9XHw+IScHT4pdIzp0S44xJzKMHzjnkHedh3qDlUtoquQixX 1qLR2FtCXO4oMgpMz0YFRiCp1Qx1MyahAhwvIbIkzp1agwJ3gCZxsrKfxkBbRwR8 ePPguFWayNuaHXLOwwlow45gPeJ5pZ7VKW5CqlPA1iC0UUYlv5y0ZPV2rEHoaaN4 awJZ8vyOiEnl3VNOWCYkEZZ+rYAENAsaFMWsWiHT+OusLskceQMLiW3d+UWLAQK4 XdAM+ZZLRjqW1r+Egj8ldST2ASzgo0LBxe+rOzxJvLipFOQi7IfZN7oDCSBKnVaa ul/ypLja6S3jZbg0HMTbgU4q1+GVd36ji+ydoZlHzWrKdJOInVq4ZK7uui808J0q SCiLTk6sgO9Y7FuPpM9mebmznDOk+tNWFV74oZl0JGTFhMQRb8oVK3Mn+qkQzEwF 4e/MJE47vyrX =W9Fg -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-7.0-pull-request' into staging m68k pull request 20220120 Fix virt-m68k reboot # gpg: Signature made Thu 20 Jan 2022 08:35:50 GMT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier/tags/m68k-for-7.0-pull-request: m68k: virt: correctly set the initial PC hw/elf_ops: clear uninitialized segment space exec/memory: Extract address_space_set() from dma_memory_set() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
47fa1ad534
@ -1164,9 +1164,13 @@ static void rom_reset(void *unused)
|
|||||||
if (rom->mr) {
|
if (rom->mr) {
|
||||||
void *host = memory_region_get_ram_ptr(rom->mr);
|
void *host = memory_region_get_ram_ptr(rom->mr);
|
||||||
memcpy(host, rom->data, rom->datasize);
|
memcpy(host, rom->data, rom->datasize);
|
||||||
|
memset(host + rom->datasize, 0, rom->romsize - rom->datasize);
|
||||||
} else {
|
} else {
|
||||||
address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED,
|
address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED,
|
||||||
rom->data, rom->datasize);
|
rom->data, rom->datasize);
|
||||||
|
address_space_set(rom->as, rom->addr + rom->datasize, 0,
|
||||||
|
rom->romsize - rom->datasize,
|
||||||
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
if (rom->isrom) {
|
if (rom->isrom) {
|
||||||
/* rom needs to be written only once */
|
/* rom needs to be written only once */
|
||||||
|
@ -85,14 +85,21 @@
|
|||||||
#define VIRT_VIRTIO_MMIO_BASE 0xff010000 /* MMIO: 0xff010000 - 0xff01ffff */
|
#define VIRT_VIRTIO_MMIO_BASE 0xff010000 /* MMIO: 0xff010000 - 0xff01ffff */
|
||||||
#define VIRT_VIRTIO_IRQ_BASE PIC_IRQ(2, 1) /* PIC: 2, 3, 4, 5, IRQ: ALL */
|
#define VIRT_VIRTIO_IRQ_BASE PIC_IRQ(2, 1) /* PIC: 2, 3, 4, 5, IRQ: ALL */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
M68kCPU *cpu;
|
||||||
|
hwaddr initial_pc;
|
||||||
|
hwaddr initial_stack;
|
||||||
|
} ResetInfo;
|
||||||
|
|
||||||
static void main_cpu_reset(void *opaque)
|
static void main_cpu_reset(void *opaque)
|
||||||
{
|
{
|
||||||
M68kCPU *cpu = opaque;
|
ResetInfo *reset_info = opaque;
|
||||||
|
M68kCPU *cpu = reset_info->cpu;
|
||||||
CPUState *cs = CPU(cpu);
|
CPUState *cs = CPU(cpu);
|
||||||
|
|
||||||
cpu_reset(cs);
|
cpu_reset(cs);
|
||||||
cpu->env.aregs[7] = ldl_phys(cs->as, 0);
|
cpu->env.aregs[7] = reset_info->initial_stack;
|
||||||
cpu->env.pc = ldl_phys(cs->as, 4);
|
cpu->env.pc = reset_info->initial_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virt_init(MachineState *machine)
|
static void virt_init(MachineState *machine)
|
||||||
@ -113,6 +120,7 @@ static void virt_init(MachineState *machine)
|
|||||||
SysBusDevice *sysbus;
|
SysBusDevice *sysbus;
|
||||||
hwaddr io_base;
|
hwaddr io_base;
|
||||||
int i;
|
int i;
|
||||||
|
ResetInfo *reset_info;
|
||||||
|
|
||||||
if (ram_size > 3399672 * KiB) {
|
if (ram_size > 3399672 * KiB) {
|
||||||
/*
|
/*
|
||||||
@ -124,9 +132,13 @@ static void virt_init(MachineState *machine)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_info = g_malloc0(sizeof(ResetInfo));
|
||||||
|
|
||||||
/* init CPUs */
|
/* init CPUs */
|
||||||
cpu = M68K_CPU(cpu_create(machine->cpu_type));
|
cpu = M68K_CPU(cpu_create(machine->cpu_type));
|
||||||
qemu_register_reset(main_cpu_reset, cpu);
|
|
||||||
|
reset_info->cpu = cpu;
|
||||||
|
qemu_register_reset(main_cpu_reset, reset_info);
|
||||||
|
|
||||||
/* RAM */
|
/* RAM */
|
||||||
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
|
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
|
||||||
@ -206,7 +218,7 @@ static void virt_init(MachineState *machine)
|
|||||||
error_report("could not load kernel '%s'", kernel_filename);
|
error_report("could not load kernel '%s'", kernel_filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
stl_phys(cs->as, 4, elf_entry); /* reset initial PC */
|
reset_info->initial_pc = elf_entry;
|
||||||
parameters_base = (high + 1) & ~1;
|
parameters_base = (high + 1) & ~1;
|
||||||
|
|
||||||
BOOTINFO1(cs->as, parameters_base, BI_MACHTYPE, MACH_VIRT);
|
BOOTINFO1(cs->as, parameters_base, BI_MACHTYPE, MACH_VIRT);
|
||||||
|
@ -2908,6 +2908,22 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* address_space_set: Fill address space with a constant byte.
|
||||||
|
*
|
||||||
|
* Return a MemTxResult indicating whether the operation succeeded
|
||||||
|
* or failed (eg unassigned memory, device rejected the transaction,
|
||||||
|
* IOMMU fault).
|
||||||
|
*
|
||||||
|
* @as: #AddressSpace to be accessed
|
||||||
|
* @addr: address within that address space
|
||||||
|
* @c: constant byte to fill the memory
|
||||||
|
* @len: the number of bytes to fill with the constant byte
|
||||||
|
* @attrs: memory transaction attributes
|
||||||
|
*/
|
||||||
|
MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
|
||||||
|
uint8_t c, hwaddr len, MemTxAttrs attrs);
|
||||||
|
|
||||||
#ifdef NEED_CPU_H
|
#ifdef NEED_CPU_H
|
||||||
/* enum device_endian to MemOp. */
|
/* enum device_endian to MemOp. */
|
||||||
static inline MemOp devend_memop(enum device_endian end)
|
static inline MemOp devend_memop(enum device_endian end)
|
||||||
|
@ -555,6 +555,19 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
|
|||||||
if (res != MEMTX_OK) {
|
if (res != MEMTX_OK) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* We need to zero'ify the space that is not copied
|
||||||
|
* from file
|
||||||
|
*/
|
||||||
|
if (file_size < mem_size) {
|
||||||
|
res = address_space_set(as ? as : &address_space_memory,
|
||||||
|
addr + file_size, 0,
|
||||||
|
mem_size - file_size,
|
||||||
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
|
if (res != MEMTX_OK) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,20 +23,7 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr,
|
|||||||
{
|
{
|
||||||
dma_barrier(as, DMA_DIRECTION_FROM_DEVICE);
|
dma_barrier(as, DMA_DIRECTION_FROM_DEVICE);
|
||||||
|
|
||||||
#define FILLBUF_SIZE 512
|
return address_space_set(as, addr, c, len, attrs);
|
||||||
uint8_t fillbuf[FILLBUF_SIZE];
|
|
||||||
int l;
|
|
||||||
MemTxResult error = MEMTX_OK;
|
|
||||||
|
|
||||||
memset(fillbuf, c, FILLBUF_SIZE);
|
|
||||||
while (len > 0) {
|
|
||||||
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
|
|
||||||
error |= address_space_write(as, addr, attrs, fillbuf, l);
|
|
||||||
len -= l;
|
|
||||||
addr += l;
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint,
|
void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint,
|
||||||
|
@ -2927,6 +2927,25 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
|
||||||
|
uint8_t c, hwaddr len, MemTxAttrs attrs)
|
||||||
|
{
|
||||||
|
#define FILLBUF_SIZE 512
|
||||||
|
uint8_t fillbuf[FILLBUF_SIZE];
|
||||||
|
int l;
|
||||||
|
MemTxResult error = MEMTX_OK;
|
||||||
|
|
||||||
|
memset(fillbuf, c, FILLBUF_SIZE);
|
||||||
|
while (len > 0) {
|
||||||
|
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
|
||||||
|
error |= address_space_write(as, addr, attrs, fillbuf, l);
|
||||||
|
len -= l;
|
||||||
|
addr += l;
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
void cpu_physical_memory_rw(hwaddr addr, void *buf,
|
void cpu_physical_memory_rw(hwaddr addr, void *buf,
|
||||||
hwaddr len, bool is_write)
|
hwaddr len, bool is_write)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user