aboutsummaryrefslogtreecommitdiff
path: root/libgloss/arc/uart-8250-stub.c
blob: ab69d6354388ca5125b6d7fe5da490101dfc7618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * uart-8250-stub.c -- various stubs for 8250 UART libgloss.
 *
 * Copyright (c) 2024 Synopsys Inc.
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 */
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include "glue.h"


/* Always return character device with 1024 bytes block.  */
int
_fstat (int fd __attribute__ ((unused)), struct stat *buf)
{
  memset (buf, 0, sizeof (*buf));
  buf->st_mode = S_IFCHR;
  buf->st_blksize = 1024;

  return 0;
}

/* ARC UART is actually console so just return 1.  */
int
_isatty (int fildes __attribute__ ((unused)))
{
  return 1;
}

/* Should be provided by crt0.S.  */
extern void __attribute__((noreturn)) _exit_halt (int ret);

void
__attribute__((noreturn))
_exit (int ret)
{
  _exit_halt (ret);
}

/* Not implemented.  */
off_t
_lseek (int fd __attribute__ ((unused)),
	off_t offset __attribute__ ((unused)),
	int whence __attribute__ ((unused)))
{
  errno = ENOSYS;
  return -1;
}

/* Not implemented.  */
int
_close (int fd __attribute__ ((unused)))
{
  errno = ENOSYS;
  return -1;
}

/* Not implemented.  */
int
_open (const char *path __attribute__ ((unused)),
       int flags __attribute__ ((unused)), ...)
{
  errno = ENOSYS;
  return -1;
}

/* If PID is equal to __MYPID, exit with sig as retcode.  */
int
_kill (int pid, int sig)
{
  if (pid == __MYPID)
    _exit (sig);

  errno = ENOSYS;
  return -1;
}

/* Return __MYPID.  */
int
_getpid (void)
{
  return __MYPID;
}

/* No arguments.  */
int
_argc (void)
{
  return 0;
}

/* No arguments.  */
uint32_t
_argvlen (int a __attribute__ ((unused)))
{
  return 0;
}

/* No arguments.  */
int
_argv (int a __attribute__ ((unused)), char *arg __attribute__ ((unused)))
{
  return -1;
}