Libpayload: Difference between revisions
Jump to navigation
Jump to search
Whiterocker (talk | contribs) (→Libc Coverage: reflect reduction in coverage as per SVN commit) |
Whiterocker (talk | contribs) (→Libc Coverage: part 2) |
||
Line 58: | Line 58: | ||
|- | |- | ||
| <code>int isdigit(int character)</code> | | <code>int isdigit(int character)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 78: | Line 78: | ||
|- | |- | ||
| <code>int isspace(int character)</code> | | <code>int isspace(int character)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 299: | Line 299: | ||
|- | |- | ||
| <code>int sprintf(char* s, const char* format, ...)</code> | | <code>int sprintf(char* s, const char* format, ...)</code> | ||
| style="background: | | style="background:yellow" | partial | ||
|- | |- | ||
Line 307: | Line 307: | ||
|- | |- | ||
| <code>int vprintf(const char* format, va_list arg)</code> | | <code>int vprintf(const char* format, va_list arg)</code> | ||
| style="background: | | style="background:yellow" | partial | ||
|- | |- | ||
| <code>int vsprintf(char* s, const char* format, va_list arg)</code> | | <code>int vsprintf(char* s, const char* format, va_list arg)</code> | ||
| style="background: | | style="background:yellow" | partial | ||
|- | |- | ||
Line 347: | Line 347: | ||
|- | |- | ||
| <code>int getchar(void)</code> | | <code>int getchar(void)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 363: | Line 363: | ||
|- | |- | ||
| <code>int puts(const char* s)</code> | | <code>int puts(const char* s)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 458: | Line 458: | ||
|- | |- | ||
| <code>void* calloc(size_t nobj, size_t size)</code> | | <code>void* calloc(size_t nobj, size_t size)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 466: | Line 466: | ||
|- | |- | ||
| <code>void* realloc(void* p, size_t size)</code> | | <code>void* realloc(void* p, size_t size)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 513: | Line 513: | ||
|- | |- | ||
| <code>char* strcpy(char* s, const char* ct)</code> | | <code>char* strcpy(char* s, const char* ct)</code> | ||
| style="background: | | style="background:green" | yes | ||
|- | |- | ||
| <code>char* strncpy(char* s, const char* ct, size_t n)</code> | | <code>char* strncpy(char* s, const char* ct, size_t n)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 525: | Line 525: | ||
|- | |- | ||
| <code>char* strncat(char* s, const char* ct, size_t n)</code> | | <code>char* strncat(char* s, const char* ct, size_t n)</code> | ||
| style="background: | | style="background:green" | yes | ||
|- | |- | ||
Line 533: | Line 533: | ||
|- | |- | ||
| <code>int strncmp(const char* cs, const char* ct, size_t n)</code> | | <code>int strncmp(const char* cs, const char* ct, size_t n)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 541: | Line 541: | ||
|- | |- | ||
| <code>char* strchr(const char* cs, int c)</code> | | <code>char* strchr(const char* cs, int c)</code> | ||
| style="background: | | style="background:green" | yes | ||
|- | |- | ||
Line 561: | Line 561: | ||
|- | |- | ||
| <code>char* strstr(const char* cs, const char* ct)</code> | | <code>char* strstr(const char* cs, const char* ct)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
| <code>size_t strlen(const char* cs)</code> | | <code>size_t strlen(const char* cs)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 585: | Line 585: | ||
|- | |- | ||
| <code>void* memmove(void* s, const void* ct, size_t n)</code> | | <code>void* memmove(void* s, const void* ct, size_t n)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
| <code>int memcmp(const void* cs, const void* ct, size_t n)</code> | | <code>int memcmp(const void* cs, const void* ct, size_t n)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- | |- | ||
Line 597: | Line 597: | ||
|- | |- | ||
| <code>void* memset(void* s, int c, size_t n)</code> | | <code>void* memset(void* s, int c, size_t n)</code> | ||
| style="background: | | style="background:lime" | yes | ||
|- bgcolor="red" | |- bgcolor="red" |
Revision as of 05:34, 20 March 2008
libpayload is a small BSD-licensed "library" (a lightweight implementation of common and useful functions) intended to be used as a basis for coreboot payloads.
Overview
The benefits of linking a coreboot payload against libpayload are:
- Payloads do not have to implement and maintain low-level code for I/O, common functions, etc.
- Payloads can be recompiled and deployed for CPU architectures supported by coreboot in the future.
- The libpayload functions can be tested and scrutinized outside payload development.
- Payloads themselves may be partly host-tested, e.g. against an emulation libpayload.
- Leads to the possibility of payloads using dynamic linking, reducing total payload footprint.
Just give us a main() and a pocket full of dreams and we'll do the rest.
Download
$ svn co svn://coreboot.org/repos/trunk/payloads/libpayload
Feature Wish List
- Basics
- coreboot services and structures (e.g. read CMOS, device tree)
- subset of C-library functions (e.g. printf, puts, getch)
- light ncurses from the Google Summer Of Code project
- Fancies
- directFB
- TWIN
Libc Coverage
Function/Macro/Variable | Status |
---|---|
assert.h | |
assert( ) (macro)
|
no |
ctype.h | |
int isalnum(int character)
|
no |
int isalpha(int character)
|
no |
int iscntrl(int character)
|
no |
int isdigit(int character)
|
yes |
int isgraph(int character)
|
no |
int islower(int character)
|
no |
int isprint(int character)
|
no |
int ispunct(int character)
|
no |
int isspace(int character)
|
yes |
int isupper(int character)
|
no |
int isxdigit(int character)
|
no |
errno.h | |
errno (global)
|
no |
float.h | |
limits.h | |
locale.h | |
char *setlocale(int category, const char *locale)
|
no |
struct lconv *localeconv(void)
|
no |
math.h | |
double exp(double x)
|
no |
double log(double x)
|
no |
double log10(double x)
|
no |
double pow(double x, double y)
|
no |
double sqrt(double x)
|
no |
double ceil(double x)
|
no |
double floor(double x)
|
no |
double fabs(double x)
|
no |
double ldexp(double x, int n)
|
no |
double frexp(double x, int* exp)
|
no |
double modf(double x, double* ip)
|
no |
double fmod(double x, double y)
|
no |
double sin(double x)
|
no |
double cos(double x)
|
no |
double tan(double x)
|
no |
double asin(double x)
|
no |
double acos(double x)
|
no |
double atan(double x)
|
no |
double atan2(double y, double x)
|
no |
double sinh(double x)
|
no |
double cosh(double x)
|
no |
double tanh(double x)
|
no |
setjmp.h | |
int setjmp(jmp_buf env)
|
no |
void longjmp(jmp_buf env, int val)
|
no |
signal.h | |
void (*signal(int sig, void (*handler)(int)))(int)
|
no |
int raise(int sig)
|
no |
stdarg.h | |
void va_start(va_list ap, lastarg)
|
no |
type va_arg(va_list ap, type)
|
no |
void va_end(va_list ap)
|
no |
stddef.h | |
TODO | |
stdio.h | |
FILE* fopen(const char* filename, const char* mode)
|
no |
FILE* freopen(const char* filename, const char* mode, FILE* stream)
|
no |
int fflush(FILE* stream)
|
no |
int fclose(FILE* stream)
|
no |
int remove(const char* filename)
|
no |
int rename(const char* oldname, const char* newname)
|
no |
FILE* tmpfile()
|
no |
char* tmpnam(char s[L_tmpnam])
|
no |
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
|
no |
void setbuf(FILE* stream, char* buf)
|
no |
int fprintf(FILE* stream, const char* format, ...)
|
no |
int printf(const char* format, ...)
|
partial |
int sprintf(char* s, const char* format, ...)
|
partial |
int vfprintf(FILE* stream, const char* format, va_list arg)
|
no |
int vprintf(const char* format, va_list arg)
|
partial |
int vsprintf(char* s, const char* format, va_list arg)
|
partial |
int fscanf(FILE* stream, const char* format, ...)
|
no |
int scanf(const char* format, ...)
|
no |
int sscanf(char* s, const char* format, ...)
|
no |
int fgetc(FILE* stream)
|
no |
char* fgets(char* s, int n, FILE* stream)
|
no |
int fputc(int c, FILE* stream)
|
no |
char* fputs(const char* s, FILE* stream)
|
no |
int getc(FILE* stream)
|
no |
int getchar(void)
|
yes |
char* gets(char* s)
|
no |
int putc(int c, FILE* stream)
|
no |
int putchar(int c)
|
yes |
int puts(const char* s)
|
yes |
int ungetc(int c, FILE* stream)
|
no |
size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream)
|
no |
size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream)
|
no |
int fseek(FILE* stream, long offset, int origin)
|
no |
long ftell(FILE* stream)
|
no |
void rewind(FILE* stream)
|
no |
int fgetpos(FILE* stream, fpos_t* ptr)
|
no |
int fsetpos(FILE* stream, const fpos_t* ptr)
|
no |
void clearerr(FILE* stream)
|
no |
int feof(FILE* stream)
|
no |
int ferror(FILE* stream)
|
no |
void perror(const char* s)
|
no |
stdlib.h | |
int abs(int n)
|
no |
long labs(long n)
|
no |
div_t div(int num, int denom)
|
no |
ldiv_t ldiv(long num, long denom)
|
no |
double atof(const char* s)
|
no |
int atoi(const char* s)
|
no |
long atol(const char* s)
|
no |
double strtod(const char* s, char** endp)
|
no |
long strtol(const char* s, char** endp, int base)
|
no |
unsigned long strtoul(const char* s, char** endp, int base)
|
no |
void* calloc(size_t nobj, size_t size)
|
yes |
void* malloc(size_t size)
|
yes |
void* realloc(void* p, size_t size)
|
yes |
void free(void* p)
|
yes |
void abort()
|
yes as halt()
|
void exit(int status)
|
no |
int atexit(void (*fcm)(void))
|
no |
int system(const char* s)
|
no |
char* getenv(const char* name)
|
no |
void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum))
|
no |
void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*))
|
no |
int rand(void)
|
no |
void srand(unsigned int seed)
|
no |
string.h | |
char* strcpy(char* s, const char* ct)
|
yes |
char* strncpy(char* s, const char* ct, size_t n)
|
yes |
char* strcat(char* s, const char* ct)
|
no |
char* strncat(char* s, const char* ct, size_t n)
|
yes |
int strcmp(const char* cs, const char* ct)
|
yes |
int strncmp(const char* cs, const char* ct, size_t n)
|
yes |
int strcoll(const char* cs, const char* ct)
|
no |
char* strchr(const char* cs, int c)
|
yes |
char* strrchr(const char* cs, int c)
|
no |
size_t strspn(const char* cs, const char* ct)
|
no |
size_t strcspn(const char* cs, const char* ct)
|
no |
char* strpbrk(const char* cs, const char* ct)
|
no |
char* strstr(const char* cs, const char* ct)
|
yes |
size_t strlen(const char* cs)
|
yes |
char* strerror(int n)
|
no |
char* strtok(char* s, const char* t)
|
no |
size_t strxfrm(char* s, const char* ct, size_t n)
|
no |
void* memcpy(void* s, const void* ct, size_t n)
|
yes |
void* memmove(void* s, const void* ct, size_t n)
|
yes |
int memcmp(const void* cs, const void* ct, size_t n)
|
yes |
void* memchr(const void* cs, int c, size_t n)
|
no |
void* memset(void* s, int c, size_t n)
|
yes |
time.h | |
clock_t clock(void)
|
no |
time_t time(time_t* tp)
|
no |
double difftime(time_t time2, time_t time1)
|
no |
time_t mktime(struct tm* tp)
|
no |
char* asctime(const struct tm* tp)
|
no |
char* ctime(const time_t* tp)
|
no |
struct tm* gmtime(const time_t* tp)
|
no |
struct tm* localtime(const time_t* tp)
|
no |
size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp)
|
no |
No Support |
Partial Support |
Full Support |
Usage Example
hello_payload.c:
#include <libpayload.h> int main(void) { printf("Hello, world!\n"); halt(); return 0; }
Build example (basic idea):
gcc -o hello_payload hello_payload.c
I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.
In case this is not legally possible: |