Skip to content

Commit

Permalink
misc/goldfish: Compatible with x86_64 goldfish pipe
Browse files Browse the repository at this point in the history
x86_64 uses 4-5G virtual addresses, we need to convert them into physical addresses and pass them to qemu, otherwise qemu will fail to map

Signed-off-by: liwenxiang1 <[email protected]>
  • Loading branch information
xianglyc authored and xiaoxiang781216 committed Sep 15, 2024
1 parent 908cd1b commit 868b17b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/misc/goldfish_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@
#define goldfish_pipe_putreg32(v, x) (*(FAR volatile uint32_t *)(x) = (v))
#define goldfish_pipe_getreg32(x) (*(FAR volatile uint32_t *)(x))

#define goldfish_pipe_getupper32(n) ((uint32_t)(((n) >> 16) >> 16))
#define goldfish_pipe_getlower32(n) ((uint32_t)(n))

#define BIT(nr) (1 << (nr))

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down Expand Up @@ -288,7 +283,7 @@ static ssize_t goldfish_pipe_transfer_one(FAR struct goldfish_pipe_s *pipe,
return ret;
}

pipe->command.rw_params.ptrs[0] = (uintptr_t)buffer;
pipe->command.rw_params.ptrs[0] = up_addrenv_va_to_pa(buffer);
pipe->command.rw_params.sizes[0] = buflen;
pipe->command.rw_params.buffers_count = 1;

Expand Down Expand Up @@ -487,7 +482,7 @@ static int goldfish_pipe_open(FAR struct file *filep)

/* Now tell the emulator we're opening a new pipe. */

dev->open_params.command_buffer_ptr = (uintptr_t)&pipe->command;
dev->open_params.command_buffer_ptr = up_addrenv_va_to_pa(&pipe->command);
dev->open_params.rw_params_max_count = GOLDFISH_PIPE_MAX_COMMAND_BUFFERS;

ret = goldfish_pipe_command_locked(pipe, GOLDFISH_PIPE_CMD_OPEN);
Expand Down Expand Up @@ -612,8 +607,9 @@ static int goldfish_pipe_interrupt(int irq, FAR void *context, FAR void *arg)
static void goldfish_pipe_write_addr(FAR void *addr,
FAR void *portl, FAR void *porth)
{
goldfish_pipe_putreg32(goldfish_pipe_getupper32((uintptr_t)addr), porth);
goldfish_pipe_putreg32(goldfish_pipe_getlower32((uintptr_t)addr), portl);
uintptr_t paddr = up_addrenv_va_to_pa(addr);
goldfish_pipe_putreg32((paddr >> 16) >> 16, porth);
goldfish_pipe_putreg32(paddr, portl);
}

/****************************************************************************
Expand Down

0 comments on commit 868b17b

Please sign in to comment.