#ifndef SEMIHOSTING_SYSCALLS_H
#define SEMIHOSTING_SYSCALLS_H
-#include "exec/cpu-defs.h"
+#include "exec/vaddr.h"
#include "gdbstub/syscalls.h"
/*
typedef struct GuestFD GuestFD;
void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode);
void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete,
int fd);
void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len);
+ int fd, vaddr buf, uint64_t len);
void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len);
+ GuestFD *gf, vaddr buf, uint64_t len);
void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len);
+ int fd, vaddr buf, uint64_t len);
void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len);
+ GuestFD *gf, vaddr buf, uint64_t len);
void semihost_sys_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
int fd, int64_t off, int gdb_whence);
void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
gdb_syscall_complete_cb flen_cb,
- int fd, target_ulong fstat_addr);
+ int fd, vaddr fstat_addr);
void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong addr);
+ int fd, vaddr addr);
void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr);
+ vaddr fname, uint64_t fname_len,
+ vaddr addr);
void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len);
+ vaddr fname, uint64_t fname_len);
void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len);
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len);
void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len);
+ vaddr cmd, uint64_t cmd_len);
void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr);
+ vaddr tv_addr, vaddr tz_addr);
void semihost_sys_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
int fd, GIOCondition cond, int timeout);
#include "qemu/osdep.h"
#include "qemu/log.h"
-#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/guestfd.h"
#include "semihosting/syscalls.h"
/*
* Validate or compute the length of the string (including terminator).
*/
-static int validate_strlen(CPUState *cs, target_ulong str, target_ulong tlen)
+static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char c;
}
static int validate_lock_user_string(char **pstr, CPUState *cs,
- target_ulong tstr, target_ulong tlen)
+ uint64_t tstr, uint64_t tlen)
{
int ret = validate_strlen(cs, tstr, tlen);
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
* big-endian. Until we do something with gdb, also produce the
* same big-endian result from the host.
*/
-static int copy_stat_to_user(CPUState *cs, target_ulong addr,
+static int copy_stat_to_user(CPUState *cs, uint64_t addr,
const struct stat *s)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
}
static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ uint64_t fname, uint64_t fname_len,
int gdb_flags, int mode)
{
int len = validate_strlen(cs, fname, fname_len);
}
static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
gdb_do_syscall(complete, "read,%x,%lx,%lx",
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
}
static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
gdb_do_syscall(complete, "write,%x,%lx,%lx",
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
}
static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
gdb_do_syscall(complete, "fstat,%x,%lx",
(uint32_t)gf->hostfd, (uint64_t)addr);
}
static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ uint64_t fname, uint64_t fname_len,
+ uint64_t addr)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
}
static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ uint64_t fname, uint64_t fname_len)
{
int len = validate_strlen(cs, fname, fname_len);
if (len < 0) {
}
static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ uint64_t oname, uint64_t oname_len,
+ uint64_t nname, uint64_t nname_len)
{
int olen, nlen;
}
static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ uint64_t cmd, uint64_t cmd_len)
{
int len = validate_strlen(cs, cmd, cmd_len);
if (len < 0) {
}
static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ uint64_t tv_addr, uint64_t tz_addr)
{
gdb_do_syscall(complete, "gettimeofday,%lx,%lx",
(uint64_t)tv_addr, (uint64_t)tz_addr);
*/
static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ uint64_t fname, uint64_t fname_len,
int gdb_flags, int mode)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
}
static void host_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_WRITE, buf, len, 0);
}
static void host_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
void *ptr = lock_user(VERIFY_READ, buf, len, 1);
}
static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
struct stat buf;
int ret;
}
static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ uint64_t fname, uint64_t fname_len,
+ uint64_t addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct stat buf;
}
static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ uint64_t fname, uint64_t fname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
}
static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ uint64_t oname, uint64_t oname_len,
+ uint64_t nname, uint64_t nname_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ostr, *nstr;
}
static void host_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ uint64_t cmd, uint64_t cmd_len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *p;
}
static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ uint64_t tv_addr, uint64_t tz_addr)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
struct gdb_timeval *p;
*/
static void staticfile_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
- target_ulong rest = gf->staticfile.len - gf->staticfile.off;
+ uint64_t rest = gf->staticfile.len - gf->staticfile.off;
void *ptr;
if (len > rest) {
*/
static void console_read(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr;
}
static void console_write(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, uint64_t buf, uint64_t len)
{
CPUArchState *env G_GNUC_UNUSED = cpu_env(cs);
char *ptr = lock_user(VERIFY_READ, buf, len, 1);
}
static void console_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong addr)
+ GuestFD *gf, uint64_t addr)
{
static const struct stat tty_buf = {
.st_mode = 020666, /* S_IFCHR, ugo+rw */
*/
void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
+ vaddr fname, uint64_t fname_len,
int gdb_flags, int mode)
{
if (use_gdb_syscalls()) {
}
void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
/*
* Bound length for 64-bit guests on 32-bit hosts, not overflowing ssize_t.
}
void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len)
+ int fd, vaddr buf, uint64_t len)
{
GuestFD *gf = get_guestfd(fd);
}
void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
- GuestFD *gf, target_ulong buf, target_ulong len)
+ GuestFD *gf, vaddr buf, uint64_t len)
{
/*
* Bound length for 64-bit guests on 32-bit hosts, not overflowing ssize_t.
}
void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong buf, target_ulong len)
+ int fd, vaddr buf, uint64_t len)
{
GuestFD *gf = get_guestfd(fd);
void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
gdb_syscall_complete_cb flen_cb, int fd,
- target_ulong fstat_addr)
+ vaddr fstat_addr)
{
GuestFD *gf = get_guestfd(fd);
}
void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
- int fd, target_ulong addr)
+ int fd, vaddr addr)
{
GuestFD *gf = get_guestfd(fd);
}
void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len,
- target_ulong addr)
+ vaddr fname, uint64_t fname_len,
+ vaddr addr)
{
if (use_gdb_syscalls()) {
gdb_stat(cs, complete, fname, fname_len, addr);
}
void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong fname, target_ulong fname_len)
+ vaddr fname, uint64_t fname_len)
{
if (use_gdb_syscalls()) {
gdb_remove(cs, complete, fname, fname_len);
}
void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong oname, target_ulong oname_len,
- target_ulong nname, target_ulong nname_len)
+ vaddr oname, uint64_t oname_len,
+ vaddr nname, uint64_t nname_len)
{
if (use_gdb_syscalls()) {
gdb_rename(cs, complete, oname, oname_len, nname, nname_len);
}
void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong cmd, target_ulong cmd_len)
+ vaddr cmd, uint64_t cmd_len)
{
if (use_gdb_syscalls()) {
gdb_system(cs, complete, cmd, cmd_len);
}
void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
- target_ulong tv_addr, target_ulong tz_addr)
+ vaddr tv_addr, vaddr tz_addr)
{
if (use_gdb_syscalls()) {
gdb_gettimeofday(cs, complete, tv_addr, tz_addr);