|
3 | 3 | #ifndef __ASM_ARM_SEMIHOSTING_H |
4 | 4 | #define __ASM_ARM_SEMIHOSTING_H |
5 | 5 |
|
6 | | -int semihosting_open(const char *fname, int flags); |
7 | | -int semihosting_close(int fd); |
8 | | -int semihosting_writec(char c); |
9 | | -int semihosting_write0(const char *str); |
10 | | -ssize_t semihosting_write(int fd, const void *buf, size_t count); |
11 | | -ssize_t semihosting_read(int fd, void *buf, size_t count); |
12 | | -int semihosting_readc(void); |
13 | | -int semihosting_isatty(int fd); |
14 | | -int semihosting_seek(int fd, loff_t pos); |
15 | | -int semihosting_flen(int fd); |
16 | | -int semihosting_remove(const char *fname); |
17 | | -int semihosting_rename(const char *fname1, const char *fname2); |
18 | | -int semihosting_errno(void); |
19 | | -int semihosting_system(const char *command); |
| 6 | +#include <asm-generic/semihosting.h> |
| 7 | +#include <asm/unified.h> |
| 8 | + |
| 9 | +static inline void semihosting_putc(void *unused, int c) |
| 10 | +{ |
| 11 | + /* We may not be relocated yet here, so we push |
| 12 | + * to stack and take address of that |
| 13 | + */ |
| 14 | +#ifdef CONFIG_CPU_64 |
| 15 | + asm volatile ( |
| 16 | + "stp %0, xzr, [sp, #-16]!\n" |
| 17 | + "mov x1, sp\n" |
| 18 | + "mov x0, #0x03\n" |
| 19 | + "hlt #0xf000\n" |
| 20 | + "add sp, sp, #16\n" |
| 21 | + : /* No outputs */ |
| 22 | + : "r" ((long)c) |
| 23 | + : "x0", "x1", "x2", "x3", "x12", "memory" |
| 24 | + ); |
| 25 | +#else |
| 26 | + asm volatile ( |
| 27 | + "push {%0}\n" |
| 28 | + "mov r1, sp\n" |
| 29 | + "mov r0, #0x03\n" |
| 30 | + ARM( "bkpt #0x123456\n") |
| 31 | + THUMB( "bkpt #0xAB\n") |
| 32 | + "pop {%0}\n" |
| 33 | + : /* No outputs */ |
| 34 | + : "r" (c) |
| 35 | + : "r0", "r1", "r2", "r3", "r12", "memory" |
| 36 | + ); |
| 37 | +#endif |
| 38 | +} |
20 | 39 |
|
21 | 40 | #endif |
0 commit comments