Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 1 | /* |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
| 28 | |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 29 | /** |
| 30 | * @mainpage |
| 31 | * |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 32 | * @section intro Introduction |
| 33 | * libpayload is a small BSD-licensed static library (a lightweight |
| 34 | * implementation of common and useful functions) intended to be used |
| 35 | * as a basis for coreboot payloads. |
| 36 | * |
| 37 | * @section example Example |
| 38 | * Here is an example of a very simple payload: |
| 39 | * @include sample/hello.c |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 40 | */ |
| 41 | |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 42 | #ifndef _LIBPAYLOAD_H |
| 43 | #define _LIBPAYLOAD_H |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 44 | |
Nico Huber | d9e543a | 2020-10-24 17:19:15 +0200 | [diff] [blame] | 45 | #include <stdbool.h> |
Stefan Reinauer | e5d30b7 | 2010-03-25 22:15:19 +0000 | [diff] [blame] | 46 | #include <libpayload-config.h> |
Daisuke Nojiri | 3f66398 | 2015-07-29 16:03:52 -0700 | [diff] [blame] | 47 | #include <cbgfx.h> |
Hsuan Ting Chen | 607b39c | 2022-03-25 17:23:21 +0800 | [diff] [blame] | 48 | #include <commonlib/bsd/elog.h> |
Jakub Czapiga | 8fac662 | 2021-11-12 13:45:29 +0000 | [diff] [blame] | 49 | #include <commonlib/bsd/fmap_serialized.h> |
Jakub Czapiga | 9760264 | 2022-03-18 14:13:29 +0100 | [diff] [blame] | 50 | #include <commonlib/bsd/helpers.h> |
Julius Werner | 177aee2 | 2024-01-30 17:22:34 -0800 | [diff] [blame] | 51 | #include <commonlib/bsd/ipchksum.h> |
Ravi Kumar Bokka | 42fcb2a | 2021-11-10 05:22:47 +0530 | [diff] [blame] | 52 | #include <commonlib/bsd/mem_chip_info.h> |
Patrick Georgi | 980a69b | 2010-06-24 11:16:10 +0000 | [diff] [blame] | 53 | #include <ctype.h> |
Gabe Black | 7c7b5ff | 2013-11-23 00:38:49 -0800 | [diff] [blame] | 54 | #include <die.h> |
Julius Werner | 8a1d11f | 2014-07-17 10:43:15 -0700 | [diff] [blame] | 55 | #include <endian.h> |
Jakub Czapiga | 8fac662 | 2021-11-12 13:45:29 +0000 | [diff] [blame] | 56 | #include <fmap.h> |
Daisuke Nojiri | e0a8a88 | 2015-06-29 13:33:34 -0700 | [diff] [blame] | 57 | #include <kconfig.h> |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 58 | #include <stddef.h> |
Patrick Georgi | 980a69b | 2010-06-24 11:16:10 +0000 | [diff] [blame] | 59 | #include <stdio.h> |
| 60 | #include <stdarg.h> |
| 61 | #include <stdlib.h> |
| 62 | #include <string.h> |
Stef van Os | c012428 | 2016-04-20 15:22:00 +0200 | [diff] [blame] | 63 | #include <time.h> |
Nico Huber | 1653cc7 | 2018-12-10 15:10:58 +0100 | [diff] [blame] | 64 | #include <sys/types.h> |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 65 | #include <arch/types.h> |
| 66 | #include <arch/io.h> |
Stefan Reinauer | 99c0856 | 2008-08-19 17:49:53 +0000 | [diff] [blame] | 67 | #include <arch/virtual.h> |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 68 | #include <sysinfo.h> |
Uwe Hermann | 83233d0 | 2008-08-04 21:00:49 +0000 | [diff] [blame] | 69 | #include <pci.h> |
Daisuke Nojiri | 6d2c722 | 2015-11-05 10:05:38 -0800 | [diff] [blame] | 70 | #include <archive.h> |
Thomas Heijligen | 303a895 | 2022-11-29 19:53:31 +0100 | [diff] [blame] | 71 | #include <delay.h> |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 72 | |
satya priya | 5c44c4a | 2019-11-25 15:10:08 +0530 | [diff] [blame] | 73 | #define BIT(x) (1ul << (x)) |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 74 | |
Julius Werner | 6df355d | 2015-07-09 15:47:07 -0700 | [diff] [blame] | 75 | static inline u32 div_round_up(u32 n, u32 d) { return (n + d - 1) / d; } |
Julius Werner | 68bdd00 | 2015-05-22 18:18:46 -0700 | [diff] [blame] | 76 | |
Uwe Hermann | 3995593 | 2008-04-03 23:01:23 +0000 | [diff] [blame] | 77 | #define LITTLE_ENDIAN 1234 |
| 78 | #define BIG_ENDIAN 4321 |
Uwe Hermann | 3995593 | 2008-04-03 23:01:23 +0000 | [diff] [blame] | 79 | |
Uwe Hermann | be504d1 | 2008-04-11 20:16:24 +0000 | [diff] [blame] | 80 | #define EXIT_SUCCESS 0 |
| 81 | #define EXIT_FAILURE 1 |
| 82 | |
Uwe Hermann | 4eb5089 | 2008-04-07 23:33:50 +0000 | [diff] [blame] | 83 | #define RAND_MAX 0x7fffffff |
| 84 | |
Jeremy Compostella | bf618cb | 2016-11-18 13:40:32 +0100 | [diff] [blame] | 85 | #define MAX_ARGC_COUNT 32 |
Jordan Crouse | 20c9cf1 | 2008-10-20 16:51:43 +0000 | [diff] [blame] | 86 | |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 87 | /* |
| 88 | * Payload information parameters - these are used to pass information |
| 89 | * to the entity loading the payload. |
| 90 | * Usage: PAYLOAD_INFO(key, value) |
| 91 | * Example: PAYLOAD_INFO(name, "CoreInfo!") |
Jordan Crouse | fc697ad | 2008-05-27 20:06:54 +0000 | [diff] [blame] | 92 | */ |
Jordan Crouse | fc697ad | 2008-05-27 20:06:54 +0000 | [diff] [blame] | 93 | #define _pstruct(key) __pinfo_ ##key |
| 94 | #define PAYLOAD_INFO(key, value) \ |
| 95 | static const char _pstruct(key)[] \ |
| 96 | __attribute__((__used__)) \ |
| 97 | __attribute__((section(".note.pinfo"),unused)) = #key "=" value |
| 98 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 99 | /** |
| 100 | * @defgroup nvram NVRAM and RTC functions |
| 101 | * @{ |
| 102 | */ |
Jordan Crouse | e2ad806 | 2008-08-28 23:10:55 +0000 | [diff] [blame] | 103 | |
| 104 | #define NVRAM_RTC_SECONDS 0 /**< RTC Seconds offset in CMOS */ |
| 105 | #define NVRAM_RTC_MINUTES 2 /**< RTC Minutes offset in CMOS */ |
| 106 | #define NVRAM_RTC_HOURS 4 /**< RTC Hours offset in CMOS */ |
| 107 | #define NVRAM_RTC_DAY 7 /**< RTC Days offset in CMOS */ |
| 108 | #define NVRAM_RTC_MONTH 8 /**< RTC Month offset in CMOS */ |
| 109 | #define NVRAM_RTC_YEAR 9 /**< RTC Year offset in CMOS */ |
| 110 | #define NVRAM_RTC_FREQ_SELECT 10 /**< RTC Update Status Register */ |
| 111 | #define NVRAM_RTC_UIP 0x80 |
Patrick Rudolph | 9f3e734 | 2017-02-25 09:56:53 +0100 | [diff] [blame] | 112 | #define NVRAM_RTC_STATUSB 11 /**< RTC Status Register B */ |
| 113 | #define NVRAM_RTC_FORMAT_24HOUR 0x02 |
| 114 | #define NVRAM_RTC_FORMAT_BINARY 0x04 |
Jordan Crouse | e2ad806 | 2008-08-28 23:10:55 +0000 | [diff] [blame] | 115 | |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 116 | /** Broken down time structure */ |
Jordan Crouse | e227143 | 2008-04-25 23:11:02 +0000 | [diff] [blame] | 117 | struct tm { |
Jordan Crouse | e2ad806 | 2008-08-28 23:10:55 +0000 | [diff] [blame] | 118 | int tm_sec; /**< Number of seconds after the minute */ |
| 119 | int tm_min; /**< Number of minutes after the hour */ |
| 120 | int tm_hour; /**< Number of hours past midnight */ |
| 121 | int tm_mday; /**< The day of the month */ |
| 122 | int tm_mon; /**< The month of the year */ |
| 123 | int tm_year; /**< The number of years since 1900 */ |
| 124 | int tm_wday; /**< The day of the week */ |
| 125 | int tm_yday; /**< The number of days since January 1 */ |
| 126 | int tm_isdst; /**< A flag indicating daylight savings time */ |
Jordan Crouse | e227143 | 2008-04-25 23:11:02 +0000 | [diff] [blame] | 127 | }; |
Uwe Hermann | 8cc38d2 | 2008-03-27 23:26:40 +0000 | [diff] [blame] | 128 | |
Uwe Hermann | c16d24e | 2008-03-31 15:17:39 +0000 | [diff] [blame] | 129 | u8 nvram_read(u8 addr); |
| 130 | void nvram_write(u8 val, u8 addr); |
Jordan Crouse | e227143 | 2008-04-25 23:11:02 +0000 | [diff] [blame] | 131 | int nvram_updating(void); |
| 132 | void rtc_read_clock(struct tm *tm); |
Patrick Rudolph | 77e0baa | 2018-02-03 11:50:56 +0100 | [diff] [blame] | 133 | void rtc_write_clock(const struct tm *tm); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 134 | /** @} */ |
Uwe Hermann | 8cc38d2 | 2008-03-27 23:26:40 +0000 | [diff] [blame] | 135 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 136 | /** |
Nico Huber | 1f6bd94 | 2012-08-30 15:36:57 +0200 | [diff] [blame] | 137 | * @defgroup storage driver functions |
| 138 | * @{ |
| 139 | */ |
| 140 | void storage_initialize(void); |
| 141 | /** @} */ |
| 142 | |
| 143 | /** |
Stefan Reinauer | 4151439 | 2008-09-26 18:42:40 +0000 | [diff] [blame] | 144 | * @defgroup usb USB functions |
| 145 | * @{ |
| 146 | */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 147 | int usb_initialize(void); |
Patrick Georgi | bbc5231 | 2011-11-04 12:06:06 +0100 | [diff] [blame] | 148 | int usb_exit (void); |
Patrick Georgi | 4727c07 | 2008-10-16 19:20:51 +0000 | [diff] [blame] | 149 | int usbhid_havechar(void); |
| 150 | int usbhid_getchar(void); |
Patrick Rudolph | 1f5ebf7 | 2017-03-06 18:37:00 +0100 | [diff] [blame] | 151 | int usbhid_getmodifiers(void); |
Stefan Reinauer | 4151439 | 2008-09-26 18:42:40 +0000 | [diff] [blame] | 152 | /** @} */ |
| 153 | |
| 154 | /** |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 155 | * @defgroup input Device functions |
| 156 | * @{ @} |
| 157 | */ |
| 158 | |
Stefan Reinauer | 1beabe1 | 2010-03-25 18:52:24 +0000 | [diff] [blame] | 159 | extern void (*reset_handler)(void); |
| 160 | int add_reset_handler(void (*new_handler)(void)); |
| 161 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 162 | /** |
| 163 | * @defgroup keyboard Keyboard functions |
| 164 | * @ingroup input |
| 165 | * @{ |
| 166 | */ |
Jordan Crouse | 63f181f | 2008-04-25 23:09:39 +0000 | [diff] [blame] | 167 | void keyboard_init(void); |
Martin Roth | 3ee59f7 | 2013-07-26 16:31:21 -0600 | [diff] [blame] | 168 | void keyboard_disconnect(void); |
Nico Huber | d9e543a | 2020-10-24 17:19:15 +0200 | [diff] [blame] | 169 | bool keyboard_havechar(void); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 170 | unsigned char keyboard_get_scancode(void); |
| 171 | int keyboard_getchar(void); |
Stefan Reinauer | d84ef1e | 2008-09-26 18:37:26 +0000 | [diff] [blame] | 172 | int keyboard_set_layout(char *country); |
Patrick Rudolph | ae2cb2d | 2017-03-05 17:29:18 +0100 | [diff] [blame] | 173 | int keyboard_getmodifier(void); |
Thejaswani Putta | 3557f12 | 2019-11-05 17:51:58 -0800 | [diff] [blame] | 174 | void initialize_keyboard_media_key_mapping_callback(int (*media_key_mapper)(char)); |
Patrick Rudolph | ae2cb2d | 2017-03-05 17:29:18 +0100 | [diff] [blame] | 175 | |
| 176 | enum KEYBOARD_MODIFIERS { |
| 177 | KB_MOD_SHIFT = (1 << 0), |
| 178 | KB_MOD_ALT = (1 << 1), |
| 179 | KB_MOD_CTRL = (1 << 2), |
| 180 | KB_MOD_CAPSLOCK = (1 << 3), |
| 181 | }; |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 182 | /** @} */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 183 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 184 | /** |
Patrick Rudolph | 837da6a | 2017-02-06 15:02:25 +0100 | [diff] [blame] | 185 | * @defgroup mouse Mouse cursor functions |
| 186 | * @ingroup input |
| 187 | * @{ |
| 188 | */ |
| 189 | void mouse_cursor_poll(void); |
| 190 | void mouse_cursor_get_rel(int *x, int *y, int *z); |
| 191 | u32 mouse_cursor_get_buttons(void); |
| 192 | void mouse_cursor_set_speed(u32 val); |
| 193 | u32 mouse_cursor_get_speed(void); |
| 194 | void mouse_cursor_set_acceleration(u8 val); |
| 195 | u8 mouse_cursor_get_acceleration(void); |
| 196 | /** @} */ |
| 197 | |
| 198 | /** |
Patrick Rudolph | e6a3821 | 2017-03-01 19:07:37 +0100 | [diff] [blame] | 199 | * @defgroup i8042 controller functions |
| 200 | * @ingroup input |
| 201 | * @{ |
| 202 | */ |
| 203 | size_t i8042_has_ps2(void); |
| 204 | size_t i8042_has_aux(void); |
| 205 | |
| 206 | u8 i8042_probe(void); |
| 207 | void i8042_close(void); |
| 208 | |
| 209 | int i8042_cmd(u8 cmd); |
| 210 | void i8042_write_data(u8 data); |
| 211 | |
| 212 | u8 i8042_data_ready_ps2(void); |
| 213 | u8 i8042_data_ready_aux(void); |
| 214 | |
| 215 | u8 i8042_read_data_ps2(void); |
Nico Huber | 4f7b687 | 2020-11-08 23:22:32 +0100 | [diff] [blame] | 216 | u8 i8042_peek_data_ps2(void); |
Patrick Rudolph | e6a3821 | 2017-03-01 19:07:37 +0100 | [diff] [blame] | 217 | u8 i8042_read_data_aux(void); |
| 218 | |
| 219 | int i8042_wait_read_ps2(void); |
| 220 | int i8042_wait_read_aux(void); |
| 221 | |
Nico Huber | 0e1d19b | 2020-11-08 14:04:39 +0100 | [diff] [blame] | 222 | int i8042_get_kbd_translation(void); |
| 223 | int i8042_set_kbd_translation(bool xlate); |
| 224 | |
Patrick Rudolph | e6a3821 | 2017-03-01 19:07:37 +0100 | [diff] [blame] | 225 | /** @} */ |
| 226 | |
| 227 | /** |
Patrick Rudolph | 5afc293 | 2017-02-06 15:26:58 +0100 | [diff] [blame] | 228 | * @defgroup i8042 PS2 Mouse functions |
| 229 | * @ingroup input |
| 230 | * @{ |
| 231 | */ |
| 232 | void i8042_mouse_init(void); |
| 233 | void i8042_mouse_disconnect(void); |
| 234 | /** @} */ |
| 235 | |
| 236 | /** |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 237 | * @defgroup serial Serial functions |
| 238 | * @ingroup input |
| 239 | * @{ |
| 240 | */ |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 241 | void serial_init(void); |
Gabe Black | 9ed8a82 | 2013-12-03 21:25:35 -0800 | [diff] [blame] | 242 | void serial_console_init(void); |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 243 | void serial_putchar(unsigned int c); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 244 | int serial_havechar(void); |
| 245 | int serial_getchar(void); |
Jordan Crouse | 3b47065 | 2008-06-20 00:01:42 +0000 | [diff] [blame] | 246 | void serial_clear(void); |
| 247 | void serial_start_bold(void); |
| 248 | void serial_end_bold(void); |
Stefan Reinauer | e75c3d8 | 2008-09-26 18:36:26 +0000 | [diff] [blame] | 249 | void serial_start_reverse(void); |
| 250 | void serial_end_reverse(void); |
Ulf Jordan | b4d4bac | 2008-08-11 20:34:28 +0000 | [diff] [blame] | 251 | void serial_start_altcharset(void); |
| 252 | void serial_end_altcharset(void); |
Ulf Jordan | d57a680 | 2008-09-03 19:59:44 +0000 | [diff] [blame] | 253 | void serial_set_color(short fg, short bg); |
Stefan Reinauer | e75c3d8 | 2008-09-26 18:36:26 +0000 | [diff] [blame] | 254 | void serial_cursor_enable(int state); |
Jordan Crouse | 3b47065 | 2008-06-20 00:01:42 +0000 | [diff] [blame] | 255 | void serial_set_cursor(int y, int x); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 256 | /** @} */ |
Jordan Crouse | 3b47065 | 2008-06-20 00:01:42 +0000 | [diff] [blame] | 257 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 258 | /** |
| 259 | * @defgroup speaker Speaker functions |
| 260 | * @ingroup input |
| 261 | * @{ |
| 262 | */ |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 263 | void speaker_enable(u16 freq); |
| 264 | void speaker_disable(void); |
| 265 | void speaker_tone(u16 freq, unsigned int duration); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 266 | /** @} */ |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 267 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 268 | /** |
| 269 | * @defgroup video Video functions |
| 270 | * @ingroup input |
| 271 | * @{ |
| 272 | */ |
Gabe Black | dd9e4e5 | 2012-10-05 23:35:04 -0700 | [diff] [blame] | 273 | int video_init(void); |
Jordan Crouse | 30939bd | 2008-04-10 22:49:02 +0000 | [diff] [blame] | 274 | int video_console_init(void); |
Gabe Black | 8e7d7fd | 2012-10-05 23:43:37 -0700 | [diff] [blame] | 275 | void video_get_rows_cols(unsigned int *rows, unsigned int *cols); |
Jordan Crouse | 30939bd | 2008-04-10 22:49:02 +0000 | [diff] [blame] | 276 | void video_console_putchar(unsigned int ch); |
| 277 | void video_console_putc(u8 row, u8 col, unsigned int ch); |
| 278 | void video_console_clear(void); |
| 279 | void video_console_cursor_enable(int state); |
Stefan Reinauer | 59fb9a2b | 2008-08-19 17:44:49 +0000 | [diff] [blame] | 280 | void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en); |
| 281 | void video_console_set_cursor(unsigned int cursorx, unsigned int cursory); |
Eran Mitrani | a63a56d | 2023-09-14 14:57:10 -0700 | [diff] [blame] | 282 | void video_console_move_cursor(int x, int y); |
Daisuke Nojiri | abe03d2 | 2015-07-31 15:22:58 -0700 | [diff] [blame] | 283 | /* |
| 284 | * print characters on video console with colors. note that there is a size |
| 285 | * restriction for the internal buffer. so, output string can be truncated. |
| 286 | */ |
Daisuke Nojiri | ccda446 | 2015-08-12 18:49:50 -0700 | [diff] [blame] | 287 | enum video_printf_align { |
| 288 | VIDEO_PRINTF_ALIGN_KEEP = 0, |
| 289 | VIDEO_PRINTF_ALIGN_LEFT, |
| 290 | VIDEO_PRINTF_ALIGN_CENTER, |
| 291 | VIDEO_PRINTF_ALIGN_RIGHT, |
| 292 | }; |
| 293 | void video_printf(int foreground, int background, enum video_printf_align align, |
| 294 | const char *fmt, ...); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 295 | /** @} */ |
Stefan Reinauer | 59fb9a2b | 2008-08-19 17:44:49 +0000 | [diff] [blame] | 296 | |
Gabe Black | a54b6a6 | 2012-09-29 00:21:27 -0700 | [diff] [blame] | 297 | /** |
| 298 | * @defgroup cbmem_console CBMEM memory console. |
| 299 | * @ingroup input |
| 300 | * @{ |
| 301 | */ |
| 302 | void cbmem_console_init(void); |
Julius Werner | 2fe505b | 2014-04-17 20:00:20 -0700 | [diff] [blame] | 303 | void cbmem_console_write(const void *buffer, size_t count); |
Yu-Ping Wu | 41956b5 | 2019-12-02 11:11:53 +0800 | [diff] [blame] | 304 | /** |
| 305 | * Take a snapshot of the CBMEM memory console. This function will allocate a |
| 306 | * range of memory. Callers must free the returned buffer by themselves. |
| 307 | * |
| 308 | * @return The allocated buffer on success, NULL on failure. |
| 309 | */ |
| 310 | char *cbmem_console_snapshot(void); |
Gabe Black | a54b6a6 | 2012-09-29 00:21:27 -0700 | [diff] [blame] | 311 | /** @} */ |
| 312 | |
Stefan Reinauer | 59fb9a2b | 2008-08-19 17:44:49 +0000 | [diff] [blame] | 313 | /* drivers/option.c */ |
Patrick Georgi | 317ca0d | 2012-01-16 10:14:24 +0100 | [diff] [blame] | 314 | struct nvram_accessor { |
| 315 | u8 (*read)(u8 reg); |
| 316 | void (*write)(u8 val, u8 reg); |
| 317 | }; |
| 318 | |
Patrick Georgi | 5febb00 | 2012-02-02 15:51:29 +0100 | [diff] [blame] | 319 | extern u8 *mem_accessor_base; |
| 320 | extern struct nvram_accessor *use_nvram, *use_mem; |
Patrick Georgi | 317ca0d | 2012-01-16 10:14:24 +0100 | [diff] [blame] | 321 | |
| 322 | struct cb_cmos_option_table *get_system_option_table(void); |
Patrick Georgi | 56f468d | 2012-01-16 15:03:11 +0100 | [diff] [blame] | 323 | int options_checksum_valid(const struct nvram_accessor *nvram); |
Patrick Georgi | 317ca0d | 2012-01-16 10:14:24 +0100 | [diff] [blame] | 324 | void fix_options_checksum_with(const struct nvram_accessor *nvram); |
Stefan Reinauer | 59a1b7f | 2010-08-17 10:14:50 +0000 | [diff] [blame] | 325 | void fix_options_checksum(void); |
Patrick Georgi | 08ed5a8 | 2012-09-24 20:06:27 +0200 | [diff] [blame] | 326 | |
Patrick Georgi | 0a59511 | 2012-01-16 15:39:57 +0100 | [diff] [blame] | 327 | struct cb_cmos_entries *first_cmos_entry(struct cb_cmos_option_table *option_table); |
| 328 | struct cb_cmos_entries *next_cmos_entry(struct cb_cmos_entries *cur); |
Patrick Georgi | 08ed5a8 | 2012-09-24 20:06:27 +0200 | [diff] [blame] | 329 | |
| 330 | struct cb_cmos_enums *first_cmos_enum(struct cb_cmos_option_table *option_table); |
| 331 | struct cb_cmos_enums *next_cmos_enum(struct cb_cmos_enums *cmos_enum); |
| 332 | struct cb_cmos_enums *first_cmos_enum_of_id(struct cb_cmos_option_table *option_table, int id); |
| 333 | struct cb_cmos_enums *next_cmos_enum_of_id(struct cb_cmos_enums *cmos_enum, int id); |
| 334 | |
Mathias Krause | d6a6eef | 2012-02-17 12:02:47 +0100 | [diff] [blame] | 335 | int get_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, void *dest, const char *name); |
| 336 | int get_option_from(struct cb_cmos_option_table *option_table, void *dest, const char *name); |
| 337 | int get_option(void *dest, const char *name); |
| 338 | int set_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const void *value, const char *name); |
| 339 | int set_option(const void *value, const char *name); |
| 340 | int get_option_as_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, char **dest, const char *name); |
| 341 | int set_option_from_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const char *value, const char *name); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 342 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 343 | /** |
| 344 | * @defgroup console Console functions |
| 345 | * @{ |
| 346 | */ |
Luigi Semenzato | 562db3b | 2014-01-13 17:45:54 -0800 | [diff] [blame] | 347 | typedef enum { |
| 348 | CONSOLE_INPUT_TYPE_UNKNOWN = 0, |
| 349 | CONSOLE_INPUT_TYPE_USB, |
Matt Delco | a20e59d | 2019-04-22 13:38:13 -0700 | [diff] [blame] | 350 | CONSOLE_INPUT_TYPE_EC, |
| 351 | CONSOLE_INPUT_TYPE_UART, |
| 352 | CONSOLE_INPUT_TYPE_GPIO, |
Luigi Semenzato | 562db3b | 2014-01-13 17:45:54 -0800 | [diff] [blame] | 353 | } console_input_type; |
| 354 | |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 355 | void console_init(void); |
Julius Werner | 2fe505b | 2014-04-17 20:00:20 -0700 | [diff] [blame] | 356 | void console_write(const void *buffer, size_t count); |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 357 | int putchar(unsigned int c); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 358 | int puts(const char *s); |
| 359 | int havekey(void); |
| 360 | int getchar(void); |
Jordan Crouse | 672d0ae | 2008-04-08 23:21:33 +0000 | [diff] [blame] | 361 | int getchar_timeout(int *ms); |
Luigi Semenzato | 562db3b | 2014-01-13 17:45:54 -0800 | [diff] [blame] | 362 | console_input_type last_key_input_type(void); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 363 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 364 | extern int last_putchar; |
| 365 | |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 366 | struct console_input_driver; |
| 367 | struct console_input_driver { |
| 368 | struct console_input_driver *next; |
| 369 | int (*havekey) (void); |
| 370 | int (*getchar) (void); |
Luigi Semenzato | 562db3b | 2014-01-13 17:45:54 -0800 | [diff] [blame] | 371 | console_input_type input_type; |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 372 | }; |
| 373 | |
| 374 | struct console_output_driver; |
| 375 | struct console_output_driver { |
| 376 | struct console_output_driver *next; |
| 377 | void (*putchar) (unsigned int); |
Julius Werner | 2fe505b | 2014-04-17 20:00:20 -0700 | [diff] [blame] | 378 | void (*write) (const void *, size_t); |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 379 | }; |
| 380 | |
| 381 | void console_add_output_driver(struct console_output_driver *out); |
| 382 | void console_add_input_driver(struct console_input_driver *in); |
Julius Werner | 43e1030 | 2014-06-02 20:13:51 -0700 | [diff] [blame] | 383 | int console_remove_output_driver(void *function); |
Patrick Georgi | 657a6dc | 2008-10-21 15:08:18 +0000 | [diff] [blame] | 384 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 385 | #define havechar havekey |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 386 | /** @} */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 387 | |
Patrick Rudolph | 837da6a | 2017-02-06 15:02:25 +0100 | [diff] [blame] | 388 | /** |
| 389 | * @defgroup mouse_cursor Mouse cursor functions |
| 390 | * @{ |
| 391 | */ |
| 392 | typedef enum { |
| 393 | CURSOR_INPUT_TYPE_UNKNOWN = 0, |
| 394 | CURSOR_INPUT_TYPE_USB, |
| 395 | CURSOR_INPUT_TYPE_PS2, |
| 396 | } cursor_input_type; |
| 397 | |
| 398 | void mouse_cursor_init(void); |
| 399 | |
| 400 | struct mouse_cursor_input_driver; |
| 401 | struct mouse_cursor_input_driver { |
| 402 | struct mouse_cursor_input_driver *next; |
| 403 | /* X,Y,Z axis and buttons */ |
| 404 | void (*get_state)(int *, int *, int *, u32 *); |
| 405 | cursor_input_type input_type; |
| 406 | }; |
| 407 | |
| 408 | void mouse_cursor_add_input_driver(struct mouse_cursor_input_driver *in); |
| 409 | |
| 410 | /** @} */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 411 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 412 | /** |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 413 | * @defgroup exec Execution functions |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 414 | * @{ |
| 415 | */ |
Jordan Crouse | 9dac1b4 | 2008-05-20 20:10:49 +0000 | [diff] [blame] | 416 | int exec(long addr, int argc, char **argv); |
Jakub Czapiga | b2163ea | 2023-09-08 13:19:00 +0000 | [diff] [blame] | 417 | |
| 418 | /* |
| 419 | * reboot() handles reboot requests made by libpayload. It has weak implementation |
| 420 | * which should be overridden by payload. |
| 421 | */ |
| 422 | void __noreturn reboot(void); |
| 423 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 424 | /** @} */ |
Jordan Crouse | 9dac1b4 | 2008-05-20 20:10:49 +0000 | [diff] [blame] | 425 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 426 | /** |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 427 | * @defgroup misc Misc functions |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 428 | * @{ |
| 429 | */ |
Uwe Hermann | 8cc38d2 | 2008-03-27 23:26:40 +0000 | [diff] [blame] | 430 | int bcd2dec(int b); |
| 431 | int dec2bcd(int d); |
Uwe Hermann | b103345 | 2008-04-11 18:38:04 +0000 | [diff] [blame] | 432 | u8 bin2hex(u8 b); |
| 433 | u8 hex2bin(u8 h); |
Paul Menzel | ccf53af | 2014-03-24 00:42:36 +0100 | [diff] [blame] | 434 | void hexdump(const void *memory, size_t length); |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 435 | void fatal(const char *msg) __attribute__((noreturn)); |
Julius Werner | 7a8a4ab | 2015-05-22 16:26:40 -0700 | [diff] [blame] | 436 | |
Angel Pons | e0ce60c | 2020-10-14 17:48:05 +0200 | [diff] [blame] | 437 | /* Population Count: number of bits that are one */ |
| 438 | static inline int popcnt(u32 x) { return __builtin_popcount(x); } |
Julius Werner | 7a8a4ab | 2015-05-22 16:26:40 -0700 | [diff] [blame] | 439 | /* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */ |
Patrick Georgi | d8cd2e9 | 2019-04-04 18:07:52 +0200 | [diff] [blame] | 440 | static inline int clz(u32 x) |
| 441 | { |
| 442 | return x ? __builtin_clz(x) : (int)sizeof(x) * 8; |
| 443 | } |
Julius Werner | 7a8a4ab | 2015-05-22 16:26:40 -0700 | [diff] [blame] | 444 | /* Integer binary logarithm (rounding down): log2(0) == -1, log2(5) == 2 */ |
Patrick Georgi | d8cd2e9 | 2019-04-04 18:07:52 +0200 | [diff] [blame] | 445 | static inline int log2(u32 x) { return (int)sizeof(x) * 8 - clz(x) - 1; } |
Julius Werner | 7a8a4ab | 2015-05-22 16:26:40 -0700 | [diff] [blame] | 446 | /* Find First Set: __ffs(0xf) == 0, __ffs(0) == -1, __ffs(1 << 31) == 31 */ |
| 447 | static inline int __ffs(u32 x) { return log2(x & (u32)(-(s32)x)); } |
Jianjun Wang | 8bb59ca | 2021-11-30 10:51:53 +0800 | [diff] [blame] | 448 | /* Find Last Set: __fls(1) == 0, __fls(5) == 2, __fls(1 << 31) == 31 */ |
| 449 | static inline int __fls(u32 x) { return log2(x); } |
Tim Wawrzynczak | 7ded1af | 2020-10-01 15:36:42 -0600 | [diff] [blame] | 450 | |
Angel Pons | e0ce60c | 2020-10-14 17:48:05 +0200 | [diff] [blame] | 451 | static inline int popcnt64(u64 x) { return __builtin_popcountll(x); } |
Tim Wawrzynczak | 7ded1af | 2020-10-01 15:36:42 -0600 | [diff] [blame] | 452 | static inline int clz64(u64 x) |
| 453 | { |
| 454 | return x ? __builtin_clzll(x) : sizeof(x) * 8; |
| 455 | } |
| 456 | |
| 457 | static inline int log2_64(u64 x) { return sizeof(x) * 8 - clz64(x) - 1; } |
| 458 | static inline int __ffs64(u64 x) { return log2_64(x & (u64)(-(s64)x)); } |
Jianjun Wang | 8bb59ca | 2021-11-30 10:51:53 +0800 | [diff] [blame] | 459 | static inline int __fls64(u64 x) { return log2_64(x); } |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 460 | /** @} */ |
Uwe Hermann | 8cc38d2 | 2008-03-27 23:26:40 +0000 | [diff] [blame] | 461 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 462 | /** |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 463 | * @defgroup mmio MMIO helper functions |
| 464 | * @{ |
| 465 | */ |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 466 | void buffer_from_fifo32(void *buffer, size_t size, void *fifo, |
| 467 | int fifo_stride, int fifo_width); |
Julius Werner | ea03d00 | 2021-09-16 15:53:32 -0700 | [diff] [blame] | 468 | void buffer_to_fifo32_prefix(const void *buffer, u32 prefix, int prefsz, size_t size, |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 469 | void *fifo, int fifo_stride, int fifo_width); |
Julius Werner | ea03d00 | 2021-09-16 15:53:32 -0700 | [diff] [blame] | 470 | static inline void buffer_to_fifo32(const void *buffer, size_t size, void *fifo, |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 471 | int fifo_stride, int fifo_width) |
| 472 | { |
Julius Werner | 9f19dd9 | 2019-11-18 18:21:27 -0800 | [diff] [blame] | 473 | buffer_to_fifo32_prefix(buffer, 0, 0, size, fifo, |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 474 | fifo_stride, fifo_width); |
| 475 | } |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 476 | /** @} */ |
| 477 | |
Julius Werner | db7f6fb | 2019-08-12 16:45:21 -0700 | [diff] [blame] | 478 | /** |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 479 | * @defgroup hash Hashing functions |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 480 | * @{ |
| 481 | */ |
Uwe Hermann | 3995593 | 2008-04-03 23:01:23 +0000 | [diff] [blame] | 482 | #define SHA1_BLOCK_LENGTH 64 |
| 483 | #define SHA1_DIGEST_LENGTH 20 |
| 484 | typedef struct { |
| 485 | u32 state[5]; |
| 486 | u64 count; |
| 487 | u8 buffer[SHA1_BLOCK_LENGTH]; |
| 488 | } SHA1_CTX; |
| 489 | void SHA1Init(SHA1_CTX *context); |
| 490 | void SHA1Transform(u32 state[5], const u8 buffer[SHA1_BLOCK_LENGTH]); |
| 491 | void SHA1Update(SHA1_CTX *context, const u8 *data, size_t len); |
Patrick Georgi | 7f96583 | 2011-04-21 18:57:16 +0200 | [diff] [blame] | 492 | void SHA1Pad(SHA1_CTX *context); |
Uwe Hermann | 3995593 | 2008-04-03 23:01:23 +0000 | [diff] [blame] | 493 | void SHA1Final(u8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context); |
| 494 | u8 *sha1(const u8 *data, size_t len, u8 *buf); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 495 | /** @} */ |
Uwe Hermann | 3995593 | 2008-04-03 23:01:23 +0000 | [diff] [blame] | 496 | |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 497 | /** |
Jordan Crouse | 6c6e433 | 2008-11-11 19:51:14 +0000 | [diff] [blame] | 498 | * @defgroup info System information functions |
| 499 | * This module contains functions that return information about the system |
| 500 | * @{ |
| 501 | */ |
| 502 | |
| 503 | int sysinfo_have_multiboot(unsigned long *addr); |
| 504 | /** @} */ |
| 505 | |
| 506 | /** |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 507 | * @defgroup arch Architecture specific functions |
| 508 | * This module contains global architecture specific functions. |
Jordan Crouse | b746178 | 2008-08-28 23:12:22 +0000 | [diff] [blame] | 509 | * All architectures are expected to define these functions. |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 510 | * @{ |
| 511 | */ |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 512 | int get_coreboot_info(struct sysinfo_t *info); |
Jordan Crouse | 20c9cf1 | 2008-10-20 16:51:43 +0000 | [diff] [blame] | 513 | int get_multiboot_info(struct sysinfo_t *info); |
Furquan Shaikh | 943d623 | 2014-09-11 14:20:35 -0700 | [diff] [blame] | 514 | void *get_cb_header_ptr(void); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 515 | |
Philip Prindeville | 44bf6fc | 2011-12-23 18:33:05 -0700 | [diff] [blame] | 516 | int lib_get_sysinfo(void); |
Furquan Shaikh | 8e15963 | 2014-09-04 15:21:12 -0700 | [diff] [blame] | 517 | void lib_sysinfo_get_memranges(struct memrange **ranges, |
| 518 | uint64_t *nranges); |
Uwe Hermann | dc69e05 | 2008-03-20 01:53:30 +0000 | [diff] [blame] | 519 | |
Gabe Black | 5c0b7ab | 2013-02-22 16:38:53 -0800 | [diff] [blame] | 520 | /* Timer functions. */ |
| 521 | /* Defined by each architecture. */ |
Julius Werner | 5ec3dea | 2024-02-06 22:52:06 -0800 | [diff] [blame^] | 522 | uint64_t timer_hz(void); |
Gabe Black | 5c0b7ab | 2013-02-22 16:38:53 -0800 | [diff] [blame] | 523 | uint64_t timer_raw_value(void); |
Gabe Black | 125a6a2 | 2013-12-06 23:30:10 -0800 | [diff] [blame] | 524 | uint64_t timer_us(uint64_t base); |
Gabe Black | 5c0b7ab | 2013-02-22 16:38:53 -0800 | [diff] [blame] | 525 | /* Generic. */ |
Raul E Rangel | d63627f | 2018-08-20 12:47:19 -0600 | [diff] [blame] | 526 | |
| 527 | /** |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 528 | * @defgroup readline Readline functions |
| 529 | * This interface provides a simple implementation of the standard readline() |
| 530 | * and getline() functions. They read a line of input from the console. |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 531 | * @{ |
| 532 | */ |
Uwe Hermann | 3153863 | 2008-08-31 22:10:35 +0000 | [diff] [blame] | 533 | char *readline(const char *prompt); |
Jakob Bornecrantz | b0d3e71 | 2008-08-23 12:17:46 +0000 | [diff] [blame] | 534 | int getline(char *buffer, int len); |
Jordan Crouse | 3a48bdc | 2008-08-28 16:53:24 +0000 | [diff] [blame] | 535 | /** @} */ |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 536 | |
Vadim Bendebury | 66fdbce | 2014-05-23 14:37:10 -0700 | [diff] [blame] | 537 | /* Defined in arch/${ARCH}/selfboot.c */ |
| 538 | void selfboot(void *entry); |
| 539 | |
Patrick Georgi | 89f73dc | 2015-07-09 13:57:00 +0200 | [diff] [blame] | 540 | /* look for area "name" in "fmap", setting offset and size to describe it. |
| 541 | Returns 0 on success, < 0 on error. */ |
| 542 | int fmap_region_by_name(const uint32_t fmap_offset, const char * const name, |
| 543 | uint32_t * const offset, uint32_t * const size); |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 544 | #endif |