xref: /openbmc/qemu/tests/multiboot/libc.h (revision 4a09d0bb)
1 /*
2  * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef LIBC_H
24 #define LIBC_H
25 
26 /* Integer types */
27 
28 typedef unsigned long long uint64_t;
29 typedef unsigned int uint32_t;
30 typedef unsigned short uint16_t;
31 typedef unsigned char uint8_t;
32 
33 typedef signed long long int64_t;
34 typedef signed int int32_t;
35 typedef signed short int16_t;
36 typedef signed char int8_t;
37 
38 typedef uint32_t uintptr_t;
39 
40 
41 /* stdarg.h */
42 
43 typedef __builtin_va_list       va_list;
44 #define va_start(ap, X)         __builtin_va_start(ap, X)
45 #define va_arg(ap, type)        __builtin_va_arg(ap, type)
46 #define va_end(ap)              __builtin_va_end(ap)
47 
48 
49 /* Port I/O functions */
50 
51 static inline void outb(uint16_t port, uint8_t data)
52 {
53     asm volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
54 }
55 
56 
57 /* Misc functions */
58 
59 void printf(const char *fmt, ...);
60 void* memcpy(void *dest, const void *src, int n);
61 
62 #endif
63