2 * This file is part of the libpayload project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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
35 #include <arch/types.h>
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]))
44 /* Some NVRAM byte definitions */
45 #define NVRAM_RTC_SECONDS 0
46 #define NVRAM_RTC_MINUTES 2
47 #define NVRAM_RTC_HOURS 4
48 #define NVRAM_RTC_DAY 7
49 #define NVRAM_RTC_MONTH 8
50 #define NVRAM_RTC_YEAR 9
53 u8 nvram_read(u8 addr);
54 void nvram_write(u8 val, u8 addr);
56 /* drivers/keyboard.c */
57 int keyboard_havechar(void);
58 unsigned char keyboard_get_scancode(void);
59 int keyboard_getchar(void);
61 /* drivers/serial.c */
62 void serial_init(void);
63 void serial_putchar(unsigned char c);
64 int serial_havechar(void);
65 int serial_getchar(void);
67 /* drivers/serial.c */
68 void vga_cursor_enable(int state);
69 void vga_clear_line(uint8_t row, uint8_t ch, uint8_t attr);
70 void vga_fill(uint8_t ch, uint8_t attr);
72 void vga_putc(uint8_t row, uint8_t col, unsigned int c);
73 void vga_putchar(unsigned int ch);
74 void vga_move_cursor(int x, int y);
78 void console_init(void);
80 int puts(const char *s);
84 extern int last_putchar;
86 #define havechar havekey
93 /* libc/ipchecksum.c */
94 unsigned short ipchksum(const unsigned short *ptr, unsigned long nbytes);
98 void *malloc(size_t size);
99 void *calloc(size_t nmemb, size_t size);
100 void *realloc(void *ptr, size_t size);
107 void *memset(void *s, int c, size_t n);
108 void *memcpy(void *dst, const void *src, size_t n);
109 void *memmove(void *dst, const void *src, size_t n);
110 int memcmp(const char *s1, const char *s2, size_t len);
113 int sprintf(char *str, const char *fmt, ...);
114 int vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
115 int vsprintf(char *str, const char *fmt, va_list ap);
116 int printf(const char *fmt, ...);
117 int vprintf(const char *fmt, va_list ap);
120 size_t strnlen(const char *str, size_t maxlen);
121 size_t strlen(const char *str);
122 int strcmp(const char *s1, const char *s2);
123 int strncmp(const char *s1, const char *s2, int maxlen);
124 char *strncpy(char *d, const char *s, int n);
125 char *strcpy(char *d, const char *s);
126 char *strncat(char *d, const char *s, int n);
127 char *strchr(const char *s, int c);
128 char *strdup(const char *s);
129 char *strstr(const char *h, const char *n);
131 /* i386/coreboot.c */
132 int get_coreboot_info(struct sysinfo_t *info);
135 void lib_get_sysinfo(void);
138 /* Timer functions - defined by each architecture. */
139 unsigned int get_cpu_speed(void);
140 void ndelay(unsigned int n);
141 void mdelay(unsigned int n);
142 void delay(unsigned int n);
145 #define abort() halt()
146 void halt(void) __attribute__ ((noreturn));