source: trunk/libs/newlib/src/libgloss/xstormy16/eva_app.c @ 514

Last change on this file since 514 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.9 KB
Line 
1/* eva_app.c -- Glue code for linking apps to run under GDB debugger control.
2 *
3 * Copyright (c) 2001 Red Hat, Inc.
4 *
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.
14 */
15#include "glue.h"
16
17typedef void (*write_proc_t)(char *buf, int nbytes);
18typedef int  (*read_proc_t)(char *buf, int nbytes);
19
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))
24
25/*
26 * print -- do a raw print of a string
27 */ 
28void
29print(char *ptr)
30{
31  STUB_WRITE(ptr, strlen(ptr));
32}
33
34/*
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.
38 */
39int
40_write (int fd, char *buf, int nbytes)
41{
42  STUB_WRITE(buf, nbytes);
43  return (nbytes);
44}
45
46int
47_read (int fd, char *buf, int nbytes)
48{
49  return STUB_READ(buf, nbytes);
50}
51
52extern char _end[];
53#define HEAP_LIMIT ((char *)0xffff)
54
55void *
56_sbrk(int inc)
57{
58  static char *heap_ptr = _end;
59  void *base;
60
61  if (inc > (HEAP_LIMIT - heap_ptr))
62    return (void *)-1;
63
64  base = heap_ptr;
65  heap_ptr += inc;
66
67  return base;
68}
69
70void
71_exit(int n)
72{
73  while (1)
74   {
75     asm volatile ("nop");
76     asm volatile (".hword 0x0006");  /* breakpoint (special illegal insn) */
77   }
78}
Note: See TracBrowser for help on using the repository browser.