17 #include <sys/types.h> 23 _ssize_t _read_r(
struct _reent *r,
int file,
void *ptr,
size_t len)
28 _ssize_t _write_r(
struct _reent *r,
int file,
const void *ptr,
size_t len)
31 const unsigned char *p;
33 p = (
const unsigned char *)ptr;
35 for(i = 0; i < len; i++) {
50 int _close_r(
struct _reent *r,
int file)
56 _off_t _lseek_r(
struct _reent *r,
int file, _off_t ptr,
int dir)
62 int _fstat_r(
struct _reent *r,
int file,
struct stat *st)
65 st->st_mode = S_IFCHR;
72 extern char _heap_end[];
73 static char *heap_ptr = NULL;
75 void * _sbrk_r(
struct _reent *_s_r, ptrdiff_t nbytes)
80 DKPRINTF(0x01,
"_sbrk_r reqest bytes %d\n", nbytes);
88 if((heap_ptr + nbytes) > _heap_end) {
90 SYSERR_PRINT(
"No Left Memory\n");
91 SYSERR_PRINT(
"Request %8d, Left %p-%p(%d)\n", nbytes, base, _heap_end,
92 (
unsigned int)_heap_end - (
unsigned int)base);
98 DKPRINTF(0x01,
"_sbrk_r %8d %p-%p(%d)\n", nbytes, base, _heap_end,
99 (
unsigned int)_heap_end - (
unsigned int)base);
108 return (
unsigned int)_heap_end - (
unsigned int)heap_ptr;
111 unsigned int system_heap_total_size(
void)
113 tkprintf(
"Heap area : %p - %p (%d)\n", end, _heap_end,
114 (
unsigned int)_heap_end - (
unsigned int)end);
116 return (
unsigned int)_heap_end - (
unsigned int)end;
125 int _getpid(
int file)
137 void * _sbrk(ptrdiff_t incr)
147 if((heap_ptr + incr) > _heap_end) {
157 int _open(
const char *path,
int flags, ...)
169 int _fstat(
int fd,
struct stat *st)
171 st->st_mode = S_IFCHR;
175 int _lseek(
int fd, off_t pos,
int whence)
180 int _read(
int fd,
char *buf,
size_t cnt)
186 int _write(
int fd,
const char *buf,
size_t cnt)
190 for (i = 0; i < cnt; i++)
201 int _times(
struct tms *buf)
207 int _init(
struct tms *buf)
213 int _link(
char *old,
char *
new)
219 int _unlink(
char *name)
225 int _wait(
int *status)
231 int _execve(
char *name,
char **argv,
char **env)
249 int _kill(
int pid,
int sig)
int tkprintf(const char *fmt,...)
非タスクコンテキスト実行用メッセージ出力
int cputc(unsigned char td)
標準出力より1文字を出力する
unsigned int system_heap_size(void)
< $gsc ヒープメモリ管理をnewlibで行う