Xtensa updates for v5.13:

- switch to generic syscall generation scripts
 - new GDBIO implementation for xtensa semihosting interface
 - various small code fixes and cleanups
 - a few typo fixes in comments and Kconfig help text
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEK2eFS5jlMn3N6xfYUfnMkfg/oEQFAmCLCQsTHGpjbXZia2Jj
 QGdtYWlsLmNvbQAKCRBR+cyR+D+gRFWrD/4ijI7NzdK+u3VmRIwpsq7quG8cYtc8
 +x+XLWABAeOx6KagShfIGnjZs0Pvqew2n8De8a/SU1SwstthfDdG4VrPIrCnSXHH
 vGEaeIkOqkIsEGxYCVzNi2PGxWPlKej0miAXQqxSm+YX2cTcnJt8HEEPPJ39c0vb
 cy6g1TBeZrf2znqgoQkp2G2bxdh5yMv6Lwmgp4abFZhP87GOps9WJTpJ95DFLwHJ
 pAO9Cil9+W6mDA31VN34p0ypVePYf+qu5DVCEzo70MEdOwozjh8hHthubqy+UE/5
 ywQ90iqHNA1299tYvW8mzsQupPFuofgRhPqFZH50CM9EUTEdjvYi2LAwFEyiYB6R
 RZekdboSGVBjiTw5nl98EBaFFkmebKNk/QJkG6BYfjYefD9RzYR5J5BdUwc+UH7n
 tzAWTm49wLKviPbHaTywK63f7gS4X3BIpjy9YqjhezWyg1TPIvgnGBIHYJ8Q56em
 8E1dDziuohZNzL6PG0KgrEzUY8DJee1yU41hW6hz/BqWw/xRMHN+F1jFCGqG0Kvn
 rlTfGmVRBMovcuPkbOxi2TGyB4Bq4kIIlbXlKbpxLzjfh2KFtZLKn6J5YYGguMeo
 m4F7RdU2Jv1lcAifrZW+IZtvThce5zcv9xhEpFoSWlXY8H+lcNIm933jIXkIjTOi
 thtjKtwklJdslw==
 =3fyY
 -----END PGP SIGNATURE-----

Merge tag 'xtensa-20210429' of git://github.com/jcmvbkbc/linux-xtensa

Pull Xtensa updates from Max Filippov:

 - switch to generic syscall generation scripts

 - new GDBIO implementation for xtensa semihosting interface

 - various small code fixes and cleanups

 - a few typo fixes in comments and Kconfig help text

* tag 'xtensa-20210429' of git://github.com/jcmvbkbc/linux-xtensa:
  xtensa: ISS: add GDBIO implementation to semihosting interface
  xtensa: ISS: split simcall implementation from semihosting interface
  xtensa: simcall.h: Change compitible to compatible
  xtensa: Couple of typo fixes
  xtensa: drop extraneous register load from initialize_mmu
  xtensa: fix pgprot_noncached assumptions
  xtensa: simplify coherent_kvaddr logic
  xtensa: syscalls: switch to generic syscallhdr.sh
  xtensa: syscalls: switch to generic syscalltbl.sh
  xtensa: stop filling syscall array with sys_ni_syscall
  xtensa: remove unneeded export in boot-elf/Makefile
  xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
  xtensa: fix warning comparing pointer to 0
  xtensa: fix spelling mistake in Kconfig "wont" -> "won't"
This commit is contained in:
Linus Torvalds 2021-04-30 12:09:28 -07:00
commit 437d1a5b66
18 changed files with 198 additions and 220 deletions

View File

@ -84,6 +84,12 @@ config KASAN_SHADOW_OFFSET
hex hex
default 0x6e400000 default 0x6e400000
config CPU_BIG_ENDIAN
def_bool $(success,test "$(shell,echo __XTENSA_EB__ | $(CC) -E -P -)" = 1)
config CPU_LITTLE_ENDIAN
def_bool !CPU_BIG_ENDIAN
menu "Processor type and features" menu "Processor type and features"
choice choice
@ -387,6 +393,28 @@ config PARSE_BOOTPARAM
If unsure, say Y. If unsure, say Y.
choice
prompt "Semihosting interface"
default XTENSA_SIMCALL_ISS
depends on XTENSA_PLATFORM_ISS
help
Choose semihosting interface that will be used for serial port,
block device and networking.
config XTENSA_SIMCALL_ISS
bool "simcall"
help
Use simcall instruction. simcall is only available on simulators,
it does nothing on hardware.
config XTENSA_SIMCALL_GDBIO
bool "GDBIO"
help
Use break instruction. It is available on real hardware when GDB
is attached to it via JTAG.
endchoice
config BLK_DEV_SIMDISK config BLK_DEV_SIMDISK
tristate "Host file-based simulated block device support" tristate "Host file-based simulated block device support"
default n default n
@ -466,7 +494,7 @@ config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
then enter your normal kernel breakpoints once the MMU was mapped then enter your normal kernel breakpoints once the MMU was mapped
to the kernel mappings (0XC0000000). to the kernel mappings (0XC0000000).
This unfortunately won't work for U-Boot and likely also wont This unfortunately won't work for U-Boot and likely also won't
work for using KEXEC to have a hot kernel ready for doing a work for using KEXEC to have a hot kernel ready for doing a
KDUMP. KDUMP.

View File

@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
KBUILD_LDFLAGS := --no-relax KBUILD_LDFLAGS := --no-relax
endif endif
ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1) CHECKFLAGS += -D$(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__)
CHECKFLAGS += -D__XTENSA_EB__
KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
endif
ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
CHECKFLAGS += -D__XTENSA_EL__
KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
endif
vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y)) vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))
plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y)) plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y))

View File

@ -12,10 +12,6 @@
KBUILD_CFLAGS += -fno-builtin -Iarch/$(ARCH)/boot/include KBUILD_CFLAGS += -fno-builtin -Iarch/$(ARCH)/boot/include
HOSTFLAGS += -Iarch/$(ARCH)/boot/include HOSTFLAGS += -Iarch/$(ARCH)/boot/include
BIG_ENDIAN := $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
export BIG_ENDIAN
subdir-y := lib subdir-y := lib
targets += vmlinux.bin vmlinux.bin.gz targets += vmlinux.bin vmlinux.bin.gz
targets += uImage xipImage targets += uImage xipImage

View File

@ -4,15 +4,10 @@
# for more details. # for more details.
# #
ifeq ($(BIG_ENDIAN),1) OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
OBJCOPY_ARGS := -O elf32-xtensa-be
else
OBJCOPY_ARGS := -O elf32-xtensa-le
endif
export OBJCOPY_ARGS CPPFLAGS_boot.lds += -P -C
export CPPFLAGS_boot.lds += -P -C KBUILD_AFLAGS += -mtext-section-literals
export KBUILD_AFLAGS += -mtext-section-literals
boot-y := bootstrap.o boot-y := bootstrap.o
targets += $(boot-y) boot.lds targets += $(boot-y) boot.lds

View File

@ -4,11 +4,7 @@
# for more details. # for more details.
# #
ifeq ($(BIG_ENDIAN),1) OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
OBJCOPY_ARGS := -O elf32-xtensa-be
else
OBJCOPY_ARGS := -O elf32-xtensa-le
endif
LD_ARGS = -T $(srctree)/$(obj)/boot.ld LD_ARGS = -T $(srctree)/$(obj)/boot.ld

View File

@ -73,7 +73,7 @@
_j 2f _j 2f
.align 4 .align 4
1: movi a2, 0x10000000 1:
#if CONFIG_KERNEL_LOAD_ADDRESS < 0x40000000ul #if CONFIG_KERNEL_LOAD_ADDRESS < 0x40000000ul
#define TEMP_MAPPING_VADDR 0x40000000 #define TEMP_MAPPING_VADDR 0x40000000

View File

@ -280,7 +280,9 @@ static inline pte_t pte_mkyoung(pte_t pte)
static inline pte_t pte_mkwrite(pte_t pte) static inline pte_t pte_mkwrite(pte_t pte)
{ pte_val(pte) |= _PAGE_WRITABLE; return pte; } { pte_val(pte) |= _PAGE_WRITABLE; return pte; }
#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) & ~_PAGE_CA_MASK)) #define pgprot_noncached(prot) \
((__pgprot((pgprot_val(prot) & ~_PAGE_CA_MASK) | \
_PAGE_CA_BYPASS)))
/* /*
* Conversion functions: convert a page and protection to a page entry, * Conversion functions: convert a page and protection to a page entry,

View File

@ -212,7 +212,7 @@ ENTRY(_startup)
* *
* The linker script used to build the Linux kernel image * The linker script used to build the Linux kernel image
* creates a table located at __boot_reloc_table_start * creates a table located at __boot_reloc_table_start
* that contans the information what data needs to be unpacked. * that contains the information what data needs to be unpacked.
* *
* Uses a2-a7. * Uses a2-a7.
*/ */
@ -222,7 +222,7 @@ ENTRY(_startup)
1: beq a2, a3, 3f # no more entries? 1: beq a2, a3, 3f # no more entries?
l32i a4, a2, 0 # start destination (in RAM) l32i a4, a2, 0 # start destination (in RAM)
l32i a5, a2, 4 # end desination (in RAM) l32i a5, a2, 4 # end destination (in RAM)
l32i a6, a2, 8 # start source (in ROM) l32i a6, a2, 8 # start source (in ROM)
addi a2, a2, 12 # next entry addi a2, a2, 12 # next entry
beq a4, a5, 1b # skip, empty entry beq a4, a5, 1b # skip, empty entry

View File

@ -76,7 +76,7 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma)
struct pci_controller *pci_ctrl = (struct pci_controller*) pdev->sysdata; struct pci_controller *pci_ctrl = (struct pci_controller*) pdev->sysdata;
resource_size_t ioaddr = pci_resource_start(pdev, bar); resource_size_t ioaddr = pci_resource_start(pdev, bar);
if (pci_ctrl == 0) if (!pci_ctrl)
return -EINVAL; /* should never happen */ return -EINVAL; /* should never happen */
/* Convert to an offset within this PCI controller */ /* Convert to an offset within this PCI controller */

View File

@ -17,7 +17,6 @@
*/ */
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/syscall.h> #include <asm/syscall.h>
#include <asm/unistd.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/errno.h> #include <linux/errno.h>
@ -28,12 +27,9 @@
#include <linux/sched/mm.h> #include <linux/sched/mm.h>
#include <linux/shm.h> #include <linux/shm.h>
syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= { syscall_t sys_call_table[] /* FIXME __cacheline_aligned */= {
[0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall, #define __SYSCALL(nr, entry) (syscall_t)entry,
#define __SYSCALL(nr, entry, nargs)[nr] = (syscall_t)entry,
#include <asm/syscall_table.h> #include <asm/syscall_table.h>
#undef __SYSCALL
}; };
#define COLOUR_ALIGN(addr, pgoff) \ #define COLOUR_ALIGN(addr, pgoff) \

View File

@ -6,20 +6,14 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/$(src)/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh
systbl := $(srctree)/$(src)/syscalltbl.sh systbl := $(srctree)/scripts/syscalltbl.sh
quiet_cmd_syshdr = SYSHDR $@ quiet_cmd_syshdr = SYSHDR $@
cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr $< $@
'$(syshdr_abis_$(basetarget))' \
'$(syshdr_pfx_$(basetarget))' \
'$(syshdr_offset_$(basetarget))'
quiet_cmd_systbl = SYSTBL $@ quiet_cmd_systbl = SYSTBL $@
cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@
'$(systbl_abis_$(basetarget))' \
'$(systbl_abi_$(basetarget))' \
'$(systbl_offset_$(basetarget))'
$(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE $(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE
$(call if_changed,syshdr) $(call if_changed,syshdr)

View File

@ -1,36 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
in="$1"
out="$2"
my_abis=`echo "($3)" | tr ',' '|'`
prefix="$4"
offset="$5"
fileguard=_UAPI_ASM_XTENSA_`basename "$out" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
-e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
printf "#ifndef %s\n" "${fileguard}"
printf "#define %s\n" "${fileguard}"
printf "\n"
nxt=0
while read nr abi name entry ; do
if [ -z "$offset" ]; then
printf "#define __NR_%s%s\t%s\n" \
"${prefix}" "${name}" "${nr}"
else
printf "#define __NR_%s%s\t(%s + %s)\n" \
"${prefix}" "${name}" "${offset}" "${nr}"
fi
nxt=$((nr+1))
done
printf "\n"
printf "#ifdef __KERNEL__\n"
printf "#define __NR_syscalls\t%s\n" "${nxt}"
printf "#endif\n"
printf "\n"
printf "#endif /* %s */\n" "${fileguard}"
) > "$out"

View File

@ -1,32 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
in="$1"
out="$2"
my_abis=`echo "($3)" | tr ',' '|'`
my_abi="$4"
offset="$5"
emit() {
t_nxt="$1"
t_nr="$2"
t_entry="$3"
while [ $t_nxt -lt $t_nr ]; do
printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}"
t_nxt=$((t_nxt+1))
done
printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}"
}
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
nxt=0
if [ -z "$offset" ]; then
offset=0
fi
while read nr abi name entry ; do
emit $((nxt+offset)) $((nr+offset)) $entry
nxt=$((nr+1))
done
) > "$out"

View File

@ -81,13 +81,8 @@ static inline void kmap_invalidate_coherent(struct page *page,
static inline void *coherent_kvaddr(struct page *page, unsigned long base, static inline void *coherent_kvaddr(struct page *page, unsigned long base,
unsigned long vaddr, unsigned long *paddr) unsigned long vaddr, unsigned long *paddr)
{ {
if (PageHighMem(page) || !DCACHE_ALIAS_EQ(page_to_phys(page), vaddr)) { *paddr = page_to_phys(page);
*paddr = page_to_phys(page); return (void *)(base + (vaddr & DCACHE_ALIAS_MASK));
return (void *)(base + (vaddr & DCACHE_ALIAS_MASK));
} else {
*paddr = 0;
return page_to_virt(page);
}
} }
void clear_user_highpage(struct page *page, unsigned long vaddr) void clear_user_highpage(struct page *page, unsigned long vaddr)

View File

@ -118,20 +118,13 @@ ENTRY(clear_page_alias)
abi_entry_default abi_entry_default
/* Skip setting up a temporary DTLB if not aliased low page. */
movi a5, PAGE_OFFSET movi a5, PAGE_OFFSET
movi a6, 0
beqz a3, 1f
/* Setup a temporary DTLB for the addr. */
addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE) addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
mov a4, a2 mov a4, a2
wdtlb a6, a2 wdtlb a6, a2
dsync dsync
1: movi a3, 0 movi a3, 0
__loopi a2, a7, PAGE_SIZE, 32 __loopi a2, a7, PAGE_SIZE, 32
s32i a3, a2, 0 s32i a3, a2, 0
s32i a3, a2, 4 s32i a3, a2, 4
@ -143,12 +136,9 @@ ENTRY(clear_page_alias)
s32i a3, a2, 28 s32i a3, a2, 28
__endla a2, a7, 32 __endla a2, a7, 32
bnez a6, 1f /* We need to invalidate the temporary dtlb entry. */
abi_ret_default
/* We need to invalidate the temporary idtlb entry, if any. */ idtlb a4
1: idtlb a4
dsync dsync
abi_ret_default abi_ret_default
@ -166,22 +156,12 @@ ENTRY(copy_page_alias)
abi_entry_default abi_entry_default
/* Skip setting up a temporary DTLB for destination if not aliased. */
movi a6, 0
movi a7, 0
beqz a4, 1f
/* Setup a temporary DTLB for destination. */ /* Setup a temporary DTLB for destination. */
addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE) addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE)
wdtlb a6, a2 wdtlb a6, a2
dsync dsync
/* Skip setting up a temporary DTLB for source if not aliased. */
1: beqz a5, 1f
/* Setup a temporary DTLB for source. */ /* Setup a temporary DTLB for source. */
addi a7, a5, PAGE_KERNEL addi a7, a5, PAGE_KERNEL
@ -219,17 +199,11 @@ ENTRY(copy_page_alias)
/* We need to invalidate any temporary mapping! */ /* We need to invalidate any temporary mapping! */
bnez a6, 1f addi a2, a2, -PAGE_SIZE
bnez a7, 2f
abi_ret_default
1: addi a2, a2, -PAGE_SIZE
idtlb a2 idtlb a2
dsync dsync
bnez a7, 2f
abi_ret_default
2: addi a3, a3, -PAGE_SIZE+1 addi a3, a3, -PAGE_SIZE+1
idtlb a3 idtlb a3
dsync dsync

View File

@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2021 Cadence Design Systems Inc. */
#ifndef _XTENSA_PLATFORM_ISS_SIMCALL_GDBIO_H
#define _XTENSA_PLATFORM_ISS_SIMCALL_GDBIO_H
/*
* System call like services offered by the GDBIO host.
*/
#define SYS_open -2
#define SYS_close -3
#define SYS_read -4
#define SYS_write -5
#define SYS_lseek -6
static int errno;
static inline int __simc(int a, int b, int c, int d)
{
register int a1 asm("a2") = a;
register int b1 asm("a6") = b;
register int c1 asm("a3") = c;
register int d1 asm("a4") = d;
__asm__ __volatile__ (
"break 1, 14\n"
: "+r"(a1), "+r"(c1)
: "r"(b1), "r"(d1)
: "memory");
errno = c1;
return a1;
}
#endif /* _XTENSA_PLATFORM_ISS_SIMCALL_GDBIO_H */

View File

@ -0,0 +1,73 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2021 Cadence Design Systems Inc. */
#ifndef _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H
#define _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H
/*
* System call like services offered by the simulator host.
*/
#define SYS_nop 0 /* unused */
#define SYS_exit 1 /*x*/
#define SYS_fork 2
#define SYS_read 3 /*x*/
#define SYS_write 4 /*x*/
#define SYS_open 5 /*x*/
#define SYS_close 6 /*x*/
#define SYS_rename 7 /*x 38 - waitpid */
#define SYS_creat 8 /*x*/
#define SYS_link 9 /*x (not implemented on WIN32) */
#define SYS_unlink 10 /*x*/
#define SYS_execv 11 /* n/a - execve */
#define SYS_execve 12 /* 11 - chdir */
#define SYS_pipe 13 /* 42 - time */
#define SYS_stat 14 /* 106 - mknod */
#define SYS_chmod 15
#define SYS_chown 16 /* 202 - lchown */
#define SYS_utime 17 /* 30 - break */
#define SYS_wait 18 /* n/a - oldstat */
#define SYS_lseek 19 /*x*/
#define SYS_getpid 20
#define SYS_isatty 21 /* n/a - mount */
#define SYS_fstat 22 /* 108 - oldumount */
#define SYS_time 23 /* 13 - setuid */
#define SYS_gettimeofday 24 /*x 78 - getuid (not implemented on WIN32) */
#define SYS_times 25 /*X 43 - stime (Xtensa-specific implementation) */
#define SYS_socket 26
#define SYS_sendto 27
#define SYS_recvfrom 28
#define SYS_select_one 29 /* not compatible select, one file descriptor at the time */
#define SYS_bind 30
#define SYS_ioctl 31
#define SYS_iss_argc 1000 /* returns value of argc */
#define SYS_iss_argv_size 1001 /* bytes needed for argv & arg strings */
#define SYS_iss_set_argv 1002 /* saves argv & arg strings at given addr */
/*
* SYS_select_one specifiers
*/
#define XTISS_SELECT_ONE_READ 1
#define XTISS_SELECT_ONE_WRITE 2
#define XTISS_SELECT_ONE_EXCEPT 3
static int errno;
static inline int __simc(int a, int b, int c, int d)
{
register int a1 asm("a2") = a;
register int b1 asm("a3") = b;
register int c1 asm("a4") = c;
register int d1 asm("a5") = d;
__asm__ __volatile__ (
"simcall\n"
: "+r"(a1), "+r"(b1)
: "r"(c1), "r"(d1)
: "memory");
errno = b1;
return a1;
}
#endif /* _XTENSA_PLATFORM_ISS_SIMCALL_ISS_H */

View File

@ -6,82 +6,29 @@
* for more details. * for more details.
* *
* Copyright (C) 2001 Tensilica Inc. * Copyright (C) 2001 Tensilica Inc.
* Copyright (C) 2017 Cadence Design Systems Inc. * Copyright (C) 2017 - 2021 Cadence Design Systems Inc.
*/ */
#ifndef _XTENSA_PLATFORM_ISS_SIMCALL_H #ifndef _XTENSA_PLATFORM_ISS_SIMCALL_H
#define _XTENSA_PLATFORM_ISS_SIMCALL_H #define _XTENSA_PLATFORM_ISS_SIMCALL_H
#include <linux/bug.h>
/* #ifdef CONFIG_XTENSA_SIMCALL_ISS
* System call like services offered by the simulator host. #include <platform/simcall-iss.h>
*/ #endif
#ifdef CONFIG_XTENSA_SIMCALL_GDBIO
#define SYS_nop 0 /* unused */ #include <platform/simcall-gdbio.h>
#define SYS_exit 1 /*x*/ #endif
#define SYS_fork 2
#define SYS_read 3 /*x*/
#define SYS_write 4 /*x*/
#define SYS_open 5 /*x*/
#define SYS_close 6 /*x*/
#define SYS_rename 7 /*x 38 - waitpid */
#define SYS_creat 8 /*x*/
#define SYS_link 9 /*x (not implemented on WIN32) */
#define SYS_unlink 10 /*x*/
#define SYS_execv 11 /* n/a - execve */
#define SYS_execve 12 /* 11 - chdir */
#define SYS_pipe 13 /* 42 - time */
#define SYS_stat 14 /* 106 - mknod */
#define SYS_chmod 15
#define SYS_chown 16 /* 202 - lchown */
#define SYS_utime 17 /* 30 - break */
#define SYS_wait 18 /* n/a - oldstat */
#define SYS_lseek 19 /*x*/
#define SYS_getpid 20
#define SYS_isatty 21 /* n/a - mount */
#define SYS_fstat 22 /* 108 - oldumount */
#define SYS_time 23 /* 13 - setuid */
#define SYS_gettimeofday 24 /*x 78 - getuid (not implemented on WIN32) */
#define SYS_times 25 /*X 43 - stime (Xtensa-specific implementation) */
#define SYS_socket 26
#define SYS_sendto 27
#define SYS_recvfrom 28
#define SYS_select_one 29 /* not compitible select, one file descriptor at the time */
#define SYS_bind 30
#define SYS_ioctl 31
#define SYS_iss_argc 1000 /* returns value of argc */
#define SYS_iss_argv_size 1001 /* bytes needed for argv & arg strings */
#define SYS_iss_set_argv 1002 /* saves argv & arg strings at given addr */
/*
* SYS_select_one specifiers
*/
#define XTISS_SELECT_ONE_READ 1
#define XTISS_SELECT_ONE_WRITE 2
#define XTISS_SELECT_ONE_EXCEPT 3
static int errno;
static inline int __simc(int a, int b, int c, int d)
{
register int a1 asm("a2") = a;
register int b1 asm("a3") = b;
register int c1 asm("a4") = c;
register int d1 asm("a5") = d;
__asm__ __volatile__ (
"simcall\n"
: "+r"(a1), "+r"(b1)
: "r"(c1), "r"(d1)
: "memory");
errno = b1;
return a1;
}
static inline int simc_exit(int exit_code) static inline int simc_exit(int exit_code)
{ {
#ifdef SYS_exit
return __simc(SYS_exit, exit_code, 0, 0); return __simc(SYS_exit, exit_code, 0, 0);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
return -1;
#endif
} }
static inline int simc_open(const char *file, int flags, int mode) static inline int simc_open(const char *file, int flags, int mode)
@ -96,7 +43,12 @@ static inline int simc_close(int fd)
static inline int simc_ioctl(int fd, int request, void *arg) static inline int simc_ioctl(int fd, int request, void *arg)
{ {
#ifdef SYS_ioctl
return __simc(SYS_ioctl, fd, request, (int) arg); return __simc(SYS_ioctl, fd, request, (int) arg);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
return -1;
#endif
} }
static inline int simc_read(int fd, void *buf, size_t count) static inline int simc_read(int fd, void *buf, size_t count)
@ -111,9 +63,14 @@ static inline int simc_write(int fd, const void *buf, size_t count)
static inline int simc_poll(int fd) static inline int simc_poll(int fd)
{ {
#ifdef SYS_select_one
long timeval[2] = { 0, 0 }; long timeval[2] = { 0, 0 };
return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&timeval); return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&timeval);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
return -1;
#endif
} }
static inline int simc_lseek(int fd, uint32_t off, int whence) static inline int simc_lseek(int fd, uint32_t off, int whence)
@ -123,18 +80,31 @@ static inline int simc_lseek(int fd, uint32_t off, int whence)
static inline int simc_argc(void) static inline int simc_argc(void)
{ {
#ifdef SYS_iss_argc
return __simc(SYS_iss_argc, 0, 0, 0); return __simc(SYS_iss_argc, 0, 0, 0);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
return 0;
#endif
} }
static inline int simc_argv_size(void) static inline int simc_argv_size(void)
{ {
#ifdef SYS_iss_argv_size
return __simc(SYS_iss_argv_size, 0, 0, 0); return __simc(SYS_iss_argv_size, 0, 0, 0);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
return 0;
#endif
} }
static inline void simc_argv(void *buf) static inline void simc_argv(void *buf)
{ {
#ifdef SYS_iss_set_argv
__simc(SYS_iss_set_argv, (int)buf, 0, 0); __simc(SYS_iss_set_argv, (int)buf, 0, 0);
#else
WARN_ONCE(1, "%s: not implemented\n", __func__);
#endif
} }
#endif /* _XTENSA_PLATFORM_ISS_SIMCALL_H */ #endif /* _XTENSA_PLATFORM_ISS_SIMCALL_H */