Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the libpayload project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * 3. The name of the author may not be used to endorse or promote products |
| 15 | * derived from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 30 | #ifndef LIBPAYLOAD_H |
| 31 | #define LIBPAYLOAD_H |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 32 | |
| 33 | #include <autoconf.h> |
| 34 | #include <stddef.h> |
| 35 | #include <arch/types.h> |
| 36 | #include <arch/io.h> |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 37 | #include <sysinfo.h> |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 38 | #include <stdarg.h> |
| 39 | |
| 40 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
| 41 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
| 42 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 43 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 44 | /* drivers/keyboard.c */ |
| 45 | int keyboard_havechar(void); |
| 46 | unsigned char keyboard_get_scancode(void); |
| 47 | int keyboard_getchar(void); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 48 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 49 | /* drivers/serial.c */ |
| 50 | void serial_init(void); |
| 51 | void serial_putchar(unsigned char c); |
| 52 | int serial_havechar(void); |
| 53 | int serial_getchar(void); |
| 54 | |
| 55 | /* drivers/serial.c */ |
| 56 | void vga_cursor_enable(int state); |
| 57 | void vga_clear_line(uint8_t row, uint8_t ch, uint8_t attr); |
| 58 | void vga_fill(uint8_t ch, uint8_t attr); |
| 59 | void vga_clear(void); |
| 60 | void vga_putc(uint8_t row, uint8_t col, unsigned int c); |
| 61 | void vga_putchar(unsigned int ch); |
| 62 | int vga_move_cursor(int x, int y); |
| 63 | void vga_init(void); |
| 64 | |
| 65 | /* libc/console.c */ |
| 66 | void console_init(void); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 67 | int putchar(int c); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 68 | int puts(const char *s); |
| 69 | int havekey(void); |
| 70 | int getchar(void); |
| 71 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 72 | extern int last_putchar; |
| 73 | |
| 74 | #define havechar havekey |
| 75 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 76 | /* libc/ctype.c */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 77 | int isspace(int c); |
| 78 | int isdigit(int c); |
| 79 | int tolower(int c); |
| 80 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 81 | /* libc/ipchecksum.c */ |
| 82 | unsigned short ipchksum(const unsigned short *ptr, unsigned long nbytes); |
| 83 | |
| 84 | /* libc/malloc.c */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 85 | void free(void *ptr); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 86 | void *malloc(size_t size); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 87 | void *calloc(size_t nmemb, size_t size); |
| 88 | void *realloc(void *ptr, size_t size); |
| 89 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 90 | /* libc/memory.c */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 91 | void *memset(void *s, int c, size_t n); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 92 | void *memcpy(void *dst, const void *src, size_t n); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 93 | void *memmove(void *dst, const void *src, size_t n); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 94 | int memcmp(const char *s1, const char *s2, size_t len); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 95 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 96 | /* libc/printf.c */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 97 | int sprintf(char *str, const char *fmt, ...); |
| 98 | int vsnprintf(char *str, size_t size, const char *fmt, va_list ap); |
| 99 | int vsprintf(char *str, const char *fmt, va_list ap); |
| 100 | int printf(const char *fmt, ...); |
| 101 | int vprintf(const char *fmt, va_list ap); |
| 102 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 103 | /* libc/string.c */ |
| 104 | size_t strnlen(const char *str, size_t maxlen); |
| 105 | size_t strlen(const char *str); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 106 | int strcmp(const char *s1, const char *s2); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 107 | int strncmp(const char *s1, const char *s2, int maxlen); |
| 108 | char *strncpy(char *d, const char *s, int n); |
| 109 | char *strcpy(char *d, const char *s); |
| 110 | char *strncat(char *d, const char *s, int n); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 111 | char *strchr(const char *s, int c); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 112 | char *strdup(const char *s); |
| 113 | char *strstr(const char *h, const char *n); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 114 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 115 | /* i386/coreboot.c */ |
| 116 | int get_coreboot_info(struct sysinfo_t *info); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 117 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame^] | 118 | /* i386/sysinfo.c */ |
| 119 | void lib_get_sysinfo(void); |
| 120 | |
| 121 | /* i386/timer.c */ |
| 122 | /* Timer functions - defined by each arcitecture. */ |
| 123 | unsigned int get_cpu_speed(void); |
| 124 | void ndelay(unsigned int n); |
| 125 | void mdelay(unsigned int n); |
| 126 | void delay(unsigned int n); |
| 127 | |
| 128 | /* i386/util.S */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 129 | #define abort() halt() |
| 130 | void halt(void) __attribute__ ((noreturn)); |
| 131 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 132 | #endif |