fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / libgloss / xstormy16 / eva_app.c
blobf6069fc7c8a52f280f77e2cb5bc6e65e37b667df
1 /* eva_app.c -- Glue code for linking apps to run under GDB debugger control.
3 * Copyright (c) 2001 Red Hat, Inc.
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
13 * they apply.
15 #include "glue.h"
17 typedef void (*write_proc_t)(char *buf, int nbytes);
18 typedef int (*read_proc_t)(char *buf, int nbytes);
20 /* There is no "syscall", so we just call directly into the stub code
21 at fixed addresses. */
22 #define STUB_WRITE(p,n) ((write_proc_t)0x8084)((p),(n))
23 #define STUB_READ(p,n) ((read_proc_t)0x8088)((p),(n))
26 * print -- do a raw print of a string
27 */
28 void
29 print(char *ptr)
31 STUB_WRITE(ptr, strlen(ptr));
35 * write -- write bytes to the serial port. Ignore fd, since
36 * stdout and stderr are the same. Since we have no filesystem,
37 * open will only return an error.
39 int
40 _write (int fd, char *buf, int nbytes)
42 STUB_WRITE(buf, nbytes);
43 return (nbytes);
46 int
47 _read (int fd, char *buf, int nbytes)
49 return STUB_READ(buf, nbytes);
52 extern char _end[];
53 #define HEAP_LIMIT ((char *)0xffff)
55 void *
56 _sbrk(int inc)
58 static char *heap_ptr = _end;
59 void *base;
61 if (inc > (HEAP_LIMIT - heap_ptr))
62 return (void *)-1;
64 base = heap_ptr;
65 heap_ptr += inc;
67 return base;
70 void
71 _exit(int n)
73 while (1)
75 asm volatile ("nop");
76 asm volatile (".hword 0x0006"); /* breakpoint (special illegal insn) */