Add detection/dump support for ServerEngines SE-SM 4210-P01.
[coreboot.git] / util / romcc / tests / simple_test76.c
1 struct syscall_result {
2         long val;
3         int errno;
4 };
5
6 static struct syscall_result syscall_return(long result)
7 {
8         struct syscall_result res;
9         if (((unsigned long)result) >= ((unsigned long)-125)) {
10                 res.errno = - result;
11                 res.val = -1;
12         } else {
13                 res.errno = 0;
14                 res.val = result;
15         }
16         return res;
17 }
18 static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
19 {
20         long res;
21         asm volatile(
22                 "int $0x80"
23                 : "=a" (res)
24                 : "a" (nr), "b" (arg1));
25         return syscall_return(res);
26
27 }
28
29 static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
30         unsigned long arg3)
31 {
32         long res;
33         asm volatile(
34                 "int $0x80"
35                 : "=a" (res)
36                 : "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
37         return syscall_return(res);
38
39 }
40
41 #define NR_exit                 1
42 #define NR_write                4
43 /* Standard file descriptors */
44 #define STDIN_FILENO    0  /* Standard input */
45 #define STDOUT_FILENO   1  /* Standard output */
46 #define STDERR_FILENO   2  /* Standard error output */
47
48 typedef long ssize_t;
49 typedef unsigned long size_t;
50
51 static ssize_t write(int fd, const void *buf, size_t count)
52 {
53         struct syscall_result res;
54         res = syscall3(NR_write, fd, (unsigned long)buf, count);
55         return res.val;
56 }
57
58 static void _exit(int status)
59 {
60         struct syscall_result res;
61         res = syscall1(NR_exit, status);
62 }
63
64 static void main(void)
65 {
66         static const char msg[] = "hello world\r\n";
67         write(STDOUT_FILENO, msg, sizeof(msg));
68         _exit(0);
69 }