OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [m68hc11/] [syscalls.c] - Blame information for rev 422

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* pseudo system calls for M68HC11 & M68HC12.
2
 * Copyright (C) 1999, 2000, 2001, 2002 Stephane Carrez (stcarrez@nerim.fr)
3
 *
4
 * The authors hereby grant permission to use, copy, modify, distribute,
5
 * and license this software and its documentation for any purpose, provided
6
 * that existing copyright notices are retained in all copies and that this
7
 * notice is included verbatim in any distributions. No written agreement,
8
 * license, or royalty fee is required for any of the authorized uses.
9
 * Modifications to this software may be copyrighted by their authors
10
 * and need not follow the licensing terms described here, provided that
11
 * the new terms are clearly indicated on the first page of each file where
12
 * they apply.
13
 */
14
 
15
#include <sys/types.h>
16
#include <sys/stat.h>
17
#include <unistd.h>
18
 
19
extern void outbyte(char c);
20
extern char inbyte(void);
21
 
22
int
23
read(int file, void *p, size_t nbytes)
24
{
25
  int i = 0;
26
  char* buf = (char*) p;
27
 
28
  for (i = 0; i < nbytes; i++) {
29
    *(buf + i) = inbyte();
30
    if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
31
      i++;
32
      break;
33
    }
34
  }
35
  return (i);
36
}
37
 
38
int
39
write(int file, const void *p, size_t len)
40
{
41
  const char *ptr = (const char*) p;
42
  int todo;
43
 
44
  for (todo = len; todo; --todo)
45
    {
46
      outbyte (*ptr++);
47
    }
48
  return(len);
49
}
50
 
51
void *
52
sbrk(ptrdiff_t incr)
53
{
54
  extern char _end;             /* Defined by the linker */
55
  static char *heap_end;
56
  char *prev_heap_end;
57
 
58
  register char *stack_ptr asm ("sp");
59
 
60
  if (heap_end == 0)
61
    {
62
      heap_end = &_end;
63
    }
64
  prev_heap_end = heap_end;
65
  if (heap_end + incr > stack_ptr)
66
    {
67
      write (1, "Heap and stack collision\n", 25);
68
      abort ();
69
    }
70
  heap_end += incr;
71
  return ((void*) prev_heap_end);
72
}
73
 
74
/* end of syscalls.c */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.