blob: 8e03c0b5b5d55ddabb3c0c18938b2748fb3ea86a [file] [log] [blame]
Jordan Crousef6145c32008-03-19 23:56:58 +00001/*
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 Hermann31538632008-08-31 22:10:35 +000030/**
31 * @mainpage
32 *
Jordan Crouse3a48bdc2008-08-28 16:53:24 +000033 * @section intro Introduction
34 * libpayload is a small BSD-licensed static library (a lightweight
35 * implementation of common and useful functions) intended to be used
36 * as a basis for coreboot payloads.
37 *
38 * @section example Example
39 * Here is an example of a very simple payload:
40 * @include sample/hello.c
Jordan Crouse3a48bdc2008-08-28 16:53:24 +000041 */
42
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000043#ifndef _LIBPAYLOAD_H
44#define _LIBPAYLOAD_H
Jordan Crousef6145c32008-03-19 23:56:58 +000045
Stefan Reinauere5d30b72010-03-25 22:15:19 +000046#include <libpayload-config.h>
Patrick Georgi980a69b2010-06-24 11:16:10 +000047#include <ctype.h>
Gabe Black54c800a2012-08-28 16:31:09 -070048#include <ipchksum.h>
Jordan Crousef6145c32008-03-19 23:56:58 +000049#include <stddef.h>
Patrick Georgi980a69b2010-06-24 11:16:10 +000050#include <stdio.h>
51#include <stdarg.h>
52#include <stdlib.h>
53#include <string.h>
Jordan Crousef6145c32008-03-19 23:56:58 +000054#include <arch/types.h>
55#include <arch/io.h>
Stefan Reinauer99c08562008-08-19 17:49:53 +000056#include <arch/virtual.h>
Uwe Hermanndc69e052008-03-20 01:53:30 +000057#include <sysinfo.h>
Uwe Hermann83233d02008-08-04 21:00:49 +000058#include <pci.h>
Stefan Reinauere5d30b72010-03-25 22:15:19 +000059#ifdef CONFIG_LAR
60#include <lar.h>
61#endif
Jordan Crousef6145c32008-03-19 23:56:58 +000062
63#define MIN(a,b) ((a) < (b) ? (a) : (b))
64#define MAX(a,b) ((a) > (b) ? (a) : (b))
65#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
66
Uwe Hermann39955932008-04-03 23:01:23 +000067#define LITTLE_ENDIAN 1234
68#define BIG_ENDIAN 4321
Uwe Hermann39955932008-04-03 23:01:23 +000069
Uwe Hermannbe504d12008-04-11 20:16:24 +000070#define EXIT_SUCCESS 0
71#define EXIT_FAILURE 1
72
Uwe Hermann4eb50892008-04-07 23:33:50 +000073#define RAND_MAX 0x7fffffff
74
Jordan Crouse20c9cf12008-10-20 16:51:43 +000075#define MAX_ARGC_COUNT 10
76
Uwe Hermann31538632008-08-31 22:10:35 +000077/*
78 * Payload information parameters - these are used to pass information
79 * to the entity loading the payload.
80 * Usage: PAYLOAD_INFO(key, value)
81 * Example: PAYLOAD_INFO(name, "CoreInfo!")
Jordan Crousefc697ad2008-05-27 20:06:54 +000082 */
Jordan Crousefc697ad2008-05-27 20:06:54 +000083#define _pstruct(key) __pinfo_ ##key
84#define PAYLOAD_INFO(key, value) \
85static const char _pstruct(key)[] \
86 __attribute__((__used__)) \
87 __attribute__((section(".note.pinfo"),unused)) = #key "=" value
88
Jordan Crouse3a48bdc2008-08-28 16:53:24 +000089/**
90 * @defgroup nvram NVRAM and RTC functions
91 * @{
92 */
Jordan Crousee2ad8062008-08-28 23:10:55 +000093
94#define NVRAM_RTC_SECONDS 0 /**< RTC Seconds offset in CMOS */
95#define NVRAM_RTC_MINUTES 2 /**< RTC Minutes offset in CMOS */
96#define NVRAM_RTC_HOURS 4 /**< RTC Hours offset in CMOS */
97#define NVRAM_RTC_DAY 7 /**< RTC Days offset in CMOS */
98#define NVRAM_RTC_MONTH 8 /**< RTC Month offset in CMOS */
99#define NVRAM_RTC_YEAR 9 /**< RTC Year offset in CMOS */
100#define NVRAM_RTC_FREQ_SELECT 10 /**< RTC Update Status Register */
101#define NVRAM_RTC_UIP 0x80
102
Uwe Hermann31538632008-08-31 22:10:35 +0000103/** Broken down time structure */
Jordan Crousee2271432008-04-25 23:11:02 +0000104struct tm {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000105 int tm_sec; /**< Number of seconds after the minute */
106 int tm_min; /**< Number of minutes after the hour */
107 int tm_hour; /**< Number of hours past midnight */
108 int tm_mday; /**< The day of the month */
109 int tm_mon; /**< The month of the year */
110 int tm_year; /**< The number of years since 1900 */
111 int tm_wday; /**< The day of the week */
112 int tm_yday; /**< The number of days since January 1 */
113 int tm_isdst; /**< A flag indicating daylight savings time */
Jordan Crousee2271432008-04-25 23:11:02 +0000114};
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000115
Uwe Hermannc16d24e2008-03-31 15:17:39 +0000116u8 nvram_read(u8 addr);
117void nvram_write(u8 val, u8 addr);
Jordan Crousee2271432008-04-25 23:11:02 +0000118int nvram_updating(void);
119void rtc_read_clock(struct tm *tm);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000120/** @} */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000121
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000122/**
Nico Huber1f6bd942012-08-30 15:36:57 +0200123 * @defgroup storage driver functions
124 * @{
125 */
126void storage_initialize(void);
127/** @} */
128
129/**
Stefan Reinauer41514392008-09-26 18:42:40 +0000130 * @defgroup usb USB functions
131 * @{
132 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000133int usb_initialize(void);
Patrick Georgibbc52312011-11-04 12:06:06 +0100134int usb_exit (void);
Patrick Georgi4727c072008-10-16 19:20:51 +0000135int usbhid_havechar(void);
136int usbhid_getchar(void);
Stefan Reinauer41514392008-09-26 18:42:40 +0000137/** @} */
138
139/**
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000140 * @defgroup input Device functions
141 * @{ @}
142 */
143
Stefan Reinauer1beabe12010-03-25 18:52:24 +0000144extern void (*reset_handler)(void);
145int add_reset_handler(void (*new_handler)(void));
146
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000147/**
148 * @defgroup keyboard Keyboard functions
149 * @ingroup input
150 * @{
151 */
Jordan Crouse63f181f2008-04-25 23:09:39 +0000152void keyboard_init(void);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000153int keyboard_havechar(void);
154unsigned char keyboard_get_scancode(void);
155int keyboard_getchar(void);
Stefan Reinauerd84ef1e2008-09-26 18:37:26 +0000156int keyboard_set_layout(char *country);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000157/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000158
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000159/**
160 * @defgroup serial Serial functions
161 * @ingroup input
162 * @{
163 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000164void serial_init(void);
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000165void serial_putchar(unsigned int c);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000166int serial_havechar(void);
167int serial_getchar(void);
Jordan Crouse3b470652008-06-20 00:01:42 +0000168void serial_clear(void);
169void serial_start_bold(void);
170void serial_end_bold(void);
Stefan Reinauere75c3d82008-09-26 18:36:26 +0000171void serial_start_reverse(void);
172void serial_end_reverse(void);
Ulf Jordanb4d4bac2008-08-11 20:34:28 +0000173void serial_start_altcharset(void);
174void serial_end_altcharset(void);
Ulf Jordand57a6802008-09-03 19:59:44 +0000175void serial_set_color(short fg, short bg);
Stefan Reinauere75c3d82008-09-26 18:36:26 +0000176void serial_cursor_enable(int state);
Jordan Crouse3b470652008-06-20 00:01:42 +0000177void serial_set_cursor(int y, int x);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000178/** @} */
Jordan Crouse3b470652008-06-20 00:01:42 +0000179
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000180/**
181 * @defgroup speaker Speaker functions
182 * @ingroup input
183 * @{
184 */
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000185void speaker_enable(u16 freq);
186void speaker_disable(void);
187void speaker_tone(u16 freq, unsigned int duration);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000188/** @} */
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000189
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000190/**
191 * @defgroup video Video functions
192 * @ingroup input
193 * @{
194 */
Gabe Blackdd9e4e52012-10-05 23:35:04 -0700195int video_init(void);
Jordan Crouse30939bd2008-04-10 22:49:02 +0000196int video_console_init(void);
Gabe Black8e7d7fd2012-10-05 23:43:37 -0700197void video_get_rows_cols(unsigned int *rows, unsigned int *cols);
Jordan Crouse30939bd2008-04-10 22:49:02 +0000198void video_console_putchar(unsigned int ch);
199void video_console_putc(u8 row, u8 col, unsigned int ch);
200void video_console_clear(void);
201void video_console_cursor_enable(int state);
Stefan Reinauer59fb9a2b2008-08-19 17:44:49 +0000202void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en);
203void video_console_set_cursor(unsigned int cursorx, unsigned int cursory);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000204/** @} */
Stefan Reinauer59fb9a2b2008-08-19 17:44:49 +0000205
Gabe Blacka54b6a62012-09-29 00:21:27 -0700206/**
207 * @defgroup cbmem_console CBMEM memory console.
208 * @ingroup input
209 * @{
210 */
211void cbmem_console_init(void);
212void cbmem_console_putc(unsigned int data);
213/** @} */
214
Stefan Reinauer59fb9a2b2008-08-19 17:44:49 +0000215/* drivers/option.c */
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100216struct nvram_accessor {
217 u8 (*read)(u8 reg);
218 void (*write)(u8 val, u8 reg);
219};
220
Patrick Georgi5febb002012-02-02 15:51:29 +0100221extern u8 *mem_accessor_base;
222extern struct nvram_accessor *use_nvram, *use_mem;
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100223
224struct cb_cmos_option_table *get_system_option_table(void);
Patrick Georgi56f468d2012-01-16 15:03:11 +0100225int options_checksum_valid(const struct nvram_accessor *nvram);
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100226void fix_options_checksum_with(const struct nvram_accessor *nvram);
Stefan Reinauer59a1b7f2010-08-17 10:14:50 +0000227void fix_options_checksum(void);
Patrick Georgi08ed5a82012-09-24 20:06:27 +0200228
Patrick Georgi0a595112012-01-16 15:39:57 +0100229struct cb_cmos_entries *first_cmos_entry(struct cb_cmos_option_table *option_table);
230struct cb_cmos_entries *next_cmos_entry(struct cb_cmos_entries *cur);
Patrick Georgi08ed5a82012-09-24 20:06:27 +0200231
232struct cb_cmos_enums *first_cmos_enum(struct cb_cmos_option_table *option_table);
233struct cb_cmos_enums *next_cmos_enum(struct cb_cmos_enums *cmos_enum);
234struct cb_cmos_enums *first_cmos_enum_of_id(struct cb_cmos_option_table *option_table, int id);
235struct cb_cmos_enums *next_cmos_enum_of_id(struct cb_cmos_enums *cmos_enum, int id);
236
Mathias Kraused6a6eef2012-02-17 12:02:47 +0100237int get_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, void *dest, const char *name);
238int get_option_from(struct cb_cmos_option_table *option_table, void *dest, const char *name);
239int get_option(void *dest, const char *name);
240int set_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const void *value, const char *name);
241int set_option(const void *value, const char *name);
242int get_option_as_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, char **dest, const char *name);
243int set_option_from_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const char *value, const char *name);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000244
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000245/**
246 * @defgroup console Console functions
247 * @{
248 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000249void console_init(void);
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000250int putchar(unsigned int c);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000251int puts(const char *s);
252int havekey(void);
253int getchar(void);
Jordan Crouse672d0ae2008-04-08 23:21:33 +0000254int getchar_timeout(int *ms);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000255
Jordan Crousef6145c32008-03-19 23:56:58 +0000256extern int last_putchar;
257
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000258struct console_input_driver;
259struct console_input_driver {
260 struct console_input_driver *next;
261 int (*havekey) (void);
262 int (*getchar) (void);
263};
264
265struct console_output_driver;
266struct console_output_driver {
267 struct console_output_driver *next;
268 void (*putchar) (unsigned int);
269};
270
271void console_add_output_driver(struct console_output_driver *out);
272void console_add_input_driver(struct console_input_driver *in);
273
Jordan Crousef6145c32008-03-19 23:56:58 +0000274#define havechar havekey
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000275/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000276
Jordan Crousef6145c32008-03-19 23:56:58 +0000277
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000278/**
Uwe Hermann31538632008-08-31 22:10:35 +0000279 * @defgroup exec Execution functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000280 * @{
281 */
Jordan Crouse9dac1b42008-05-20 20:10:49 +0000282int exec(long addr, int argc, char **argv);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000283/** @} */
Jordan Crouse9dac1b42008-05-20 20:10:49 +0000284
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000285/**
Uwe Hermann31538632008-08-31 22:10:35 +0000286 * @defgroup misc Misc functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000287 * @{
288 */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000289int bcd2dec(int b);
290int dec2bcd(int d);
Uwe Hermannb1033452008-04-11 18:38:04 +0000291int abs(int j);
292long int labs(long int j);
293long long int llabs(long long int j);
294u8 bin2hex(u8 b);
295u8 hex2bin(u8 h);
Ronald G. Minnich86545f72013-12-16 06:46:00 +0100296void hexdump(void *memory, int length);
Uwe Hermann31538632008-08-31 22:10:35 +0000297void fatal(const char *msg) __attribute__ ((noreturn));
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000298/** @} */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000299
Uwe Hermannc5a78ac2008-04-08 23:38:15 +0000300
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000301/**
Uwe Hermann31538632008-08-31 22:10:35 +0000302 * @defgroup hash Hashing functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000303 * @{
304 */
Uwe Hermann39955932008-04-03 23:01:23 +0000305#define SHA1_BLOCK_LENGTH 64
306#define SHA1_DIGEST_LENGTH 20
307typedef struct {
308 u32 state[5];
309 u64 count;
310 u8 buffer[SHA1_BLOCK_LENGTH];
311} SHA1_CTX;
312void SHA1Init(SHA1_CTX *context);
313void SHA1Transform(u32 state[5], const u8 buffer[SHA1_BLOCK_LENGTH]);
314void SHA1Update(SHA1_CTX *context, const u8 *data, size_t len);
Patrick Georgi7f965832011-04-21 18:57:16 +0200315void SHA1Pad(SHA1_CTX *context);
Uwe Hermann39955932008-04-03 23:01:23 +0000316void SHA1Final(u8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context);
317u8 *sha1(const u8 *data, size_t len, u8 *buf);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000318/** @} */
Uwe Hermann39955932008-04-03 23:01:23 +0000319
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000320/**
Uwe Hermann31538632008-08-31 22:10:35 +0000321 * @defgroup time Time functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000322 * @{
323 */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000324
Uwe Hermann31538632008-08-31 22:10:35 +0000325/** System time structure */
Jordan Crousee2271432008-04-25 23:11:02 +0000326struct timeval {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000327 time_t tv_sec; /**< Seconds */
328 suseconds_t tv_usec; /**< Microseconds */
Jordan Crousee2271432008-04-25 23:11:02 +0000329};
330
331int gettimeofday(struct timeval *tv, void *tz);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000332/** @} */
Jordan Crousee2271432008-04-25 23:11:02 +0000333
Stefan Reinauere5d30b72010-03-25 22:15:19 +0000334#ifdef CONFIG_LAR
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000335/**
Uwe Hermann31538632008-08-31 22:10:35 +0000336 * @defgroup lar LAR functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000337 * @{
338 */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000339
Uwe Hermann31538632008-08-31 22:10:35 +0000340/** LAR file header */
Jordan Crouse681ec272008-05-07 20:34:02 +0000341struct LAR {
Uwe Hermann31538632008-08-31 22:10:35 +0000342 void *start; /**< Location of the LAR in memory */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000343 int cindex; /**< Next file to return in readlar() */
344 int count; /**< Number of entries in the header cache */
345 int alloc; /**< Number of slots in the header cache */
346 int eof; /**< Last entry in the header cache */
347 void **headers; /**< Pointer to the header cache */
Jordan Crouse681ec272008-05-07 20:34:02 +0000348};
349
Uwe Hermann31538632008-08-31 22:10:35 +0000350/** A structure representing the next LAR entry */
Jordan Crouse681ec272008-05-07 20:34:02 +0000351struct larent {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000352 u8 name[LAR_MAX_PATHLEN]; /**< The name of the next LAR entry */
Jordan Crouse681ec272008-05-07 20:34:02 +0000353};
354
Uwe Hermann31538632008-08-31 22:10:35 +0000355/** A structure containing information about a LAR file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000356struct larstat {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000357 u32 len; /**< Length of the file in the LAR */
358 u32 reallen; /**< Length of the uncompressed file */
359 u32 checksum; /**< Checksum of the uncompressed file */
360 u32 compchecksum; /**< Checksum of the compressed file in the LAR */
361 u32 offset; /**< Offset of the file in the LAR */
362 u32 compression; /**< Compression type of the file */
363 u64 entry; /**< Entry point of the file for executables */
364 u64 loadaddress; /**< Address in memory to put the uncompressed file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000365};
366
Uwe Hermann31538632008-08-31 22:10:35 +0000367/** A structure representing a LAR file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000368struct LFILE {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000369 struct LAR *lar; /**< Pointer to the LAR struct */
370 struct lar_header *header; /**< Pointer to the header struct */
371 u32 size; /**< Size of the file */
372 void *start; /**< Start of the file in memory */
373 u32 offset; /**< Offset of the file in the LAR */
Jordan Crouse681ec272008-05-07 20:34:02 +0000374};
375
376struct LAR *openlar(void *addr);
377int closelar(struct LAR *lar);
378struct larent *readlar(struct LAR *lar);
379void rewindlar(struct LAR *lar);
380int larstat(struct LAR *lar, const char *path, struct larstat *buf);
Jordan Crouse50698082008-05-20 20:09:42 +0000381void *larfptr(struct LAR *lar, const char *filename);
Jordan Crouse9e734c22008-05-27 19:57:53 +0000382int lfverify(struct LAR *lar, const char *filename);
Uwe Hermann31538632008-08-31 22:10:35 +0000383struct LFILE *lfopen(struct LAR *lar, const char *filename);
Jordan Crouse681ec272008-05-07 20:34:02 +0000384int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream);
385
Jordan Crouse681ec272008-05-07 20:34:02 +0000386int lfseek(struct LFILE *stream, long offset, int whence);
387int lfclose(struct LFILE *file);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000388/** @} */
Stefan Reinauere5d30b72010-03-25 22:15:19 +0000389#endif
Jordan Crouse681ec272008-05-07 20:34:02 +0000390
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000391/**
Jordan Crouse6c6e4332008-11-11 19:51:14 +0000392 * @defgroup info System information functions
393 * This module contains functions that return information about the system
394 * @{
395 */
396
397int sysinfo_have_multiboot(unsigned long *addr);
398/** @} */
399
400/**
Uwe Hermann31538632008-08-31 22:10:35 +0000401 * @defgroup arch Architecture specific functions
402 * This module contains global architecture specific functions.
Jordan Crouseb7461782008-08-28 23:12:22 +0000403 * All architectures are expected to define these functions.
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000404 * @{
405 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000406int get_coreboot_info(struct sysinfo_t *info);
Jordan Crouse20c9cf12008-10-20 16:51:43 +0000407int get_multiboot_info(struct sysinfo_t *info);
Jordan Crousef6145c32008-03-19 23:56:58 +0000408
Philip Prindeville44bf6fc2011-12-23 18:33:05 -0700409int lib_get_sysinfo(void);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000410
Gabe Black5c0b7ab2013-02-22 16:38:53 -0800411/* Timer functions. */
412/* Defined by each architecture. */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000413unsigned int get_cpu_speed(void);
Gabe Black5c0b7ab2013-02-22 16:38:53 -0800414uint64_t timer_hz(void);
415uint64_t timer_raw_value(void);
416/* Generic. */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000417void ndelay(unsigned int n);
Jordan Crouse234e87f2008-04-10 22:50:44 +0000418void udelay(unsigned int n);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000419void mdelay(unsigned int n);
420void delay(unsigned int n);
421
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000422/**
Uwe Hermann31538632008-08-31 22:10:35 +0000423 * @defgroup readline Readline functions
424 * This interface provides a simple implementation of the standard readline()
425 * and getline() functions. They read a line of input from the console.
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000426 * @{
427 */
Uwe Hermann31538632008-08-31 22:10:35 +0000428char *readline(const char *prompt);
Jakob Bornecrantzb0d3e712008-08-23 12:17:46 +0000429int getline(char *buffer, int len);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000430/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000431
Jordan Crousef6145c32008-03-19 23:56:58 +0000432#endif