blob: c67c6596844f1254c9a236d4f7d88b4edc280d60 [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>
Jordan Crousef6145c32008-03-19 23:56:58 +000048#include <stddef.h>
Patrick Georgi980a69b2010-06-24 11:16:10 +000049#include <stdio.h>
50#include <stdarg.h>
51#include <stdlib.h>
52#include <string.h>
Jordan Crousef6145c32008-03-19 23:56:58 +000053#include <arch/types.h>
54#include <arch/io.h>
Stefan Reinauer99c08562008-08-19 17:49:53 +000055#include <arch/virtual.h>
Uwe Hermanndc69e052008-03-20 01:53:30 +000056#include <sysinfo.h>
Uwe Hermann83233d02008-08-04 21:00:49 +000057#include <pci.h>
Stefan Reinauere5d30b72010-03-25 22:15:19 +000058#ifdef CONFIG_LAR
59#include <lar.h>
60#endif
Jordan Crousef6145c32008-03-19 23:56:58 +000061
62#define MIN(a,b) ((a) < (b) ? (a) : (b))
63#define MAX(a,b) ((a) > (b) ? (a) : (b))
64#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
65
Uwe Hermann39955932008-04-03 23:01:23 +000066#define LITTLE_ENDIAN 1234
67#define BIG_ENDIAN 4321
Uwe Hermann39955932008-04-03 23:01:23 +000068
Uwe Hermannbe504d12008-04-11 20:16:24 +000069#define EXIT_SUCCESS 0
70#define EXIT_FAILURE 1
71
Uwe Hermann4eb50892008-04-07 23:33:50 +000072#define RAND_MAX 0x7fffffff
73
Jordan Crouse20c9cf12008-10-20 16:51:43 +000074#define MAX_ARGC_COUNT 10
75
Uwe Hermann31538632008-08-31 22:10:35 +000076/*
77 * Payload information parameters - these are used to pass information
78 * to the entity loading the payload.
79 * Usage: PAYLOAD_INFO(key, value)
80 * Example: PAYLOAD_INFO(name, "CoreInfo!")
Jordan Crousefc697ad2008-05-27 20:06:54 +000081 */
Jordan Crousefc697ad2008-05-27 20:06:54 +000082#define _pstruct(key) __pinfo_ ##key
83#define PAYLOAD_INFO(key, value) \
84static const char _pstruct(key)[] \
85 __attribute__((__used__)) \
86 __attribute__((section(".note.pinfo"),unused)) = #key "=" value
87
Jordan Crouse3a48bdc2008-08-28 16:53:24 +000088/**
89 * @defgroup nvram NVRAM and RTC functions
90 * @{
91 */
Jordan Crousee2ad8062008-08-28 23:10:55 +000092
93#define NVRAM_RTC_SECONDS 0 /**< RTC Seconds offset in CMOS */
94#define NVRAM_RTC_MINUTES 2 /**< RTC Minutes offset in CMOS */
95#define NVRAM_RTC_HOURS 4 /**< RTC Hours offset in CMOS */
96#define NVRAM_RTC_DAY 7 /**< RTC Days offset in CMOS */
97#define NVRAM_RTC_MONTH 8 /**< RTC Month offset in CMOS */
98#define NVRAM_RTC_YEAR 9 /**< RTC Year offset in CMOS */
99#define NVRAM_RTC_FREQ_SELECT 10 /**< RTC Update Status Register */
100#define NVRAM_RTC_UIP 0x80
101
Uwe Hermann31538632008-08-31 22:10:35 +0000102/** Broken down time structure */
Jordan Crousee2271432008-04-25 23:11:02 +0000103struct tm {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000104 int tm_sec; /**< Number of seconds after the minute */
105 int tm_min; /**< Number of minutes after the hour */
106 int tm_hour; /**< Number of hours past midnight */
107 int tm_mday; /**< The day of the month */
108 int tm_mon; /**< The month of the year */
109 int tm_year; /**< The number of years since 1900 */
110 int tm_wday; /**< The day of the week */
111 int tm_yday; /**< The number of days since January 1 */
112 int tm_isdst; /**< A flag indicating daylight savings time */
Jordan Crousee2271432008-04-25 23:11:02 +0000113};
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000114
Uwe Hermannc16d24e2008-03-31 15:17:39 +0000115u8 nvram_read(u8 addr);
116void nvram_write(u8 val, u8 addr);
Jordan Crousee2271432008-04-25 23:11:02 +0000117int nvram_updating(void);
118void rtc_read_clock(struct tm *tm);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000119/** @} */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000120
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000121/**
Stefan Reinauer41514392008-09-26 18:42:40 +0000122 * @defgroup usb USB functions
123 * @{
124 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000125int usb_initialize(void);
Patrick Georgibbc52312011-11-04 12:06:06 +0100126int usb_exit (void);
Patrick Georgi4727c072008-10-16 19:20:51 +0000127int usbhid_havechar(void);
128int usbhid_getchar(void);
Stefan Reinauer41514392008-09-26 18:42:40 +0000129/** @} */
130
131/**
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000132 * @defgroup input Device functions
133 * @{ @}
134 */
135
Stefan Reinauer1beabe12010-03-25 18:52:24 +0000136extern void (*reset_handler)(void);
137int add_reset_handler(void (*new_handler)(void));
138
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000139/**
140 * @defgroup keyboard Keyboard functions
141 * @ingroup input
142 * @{
143 */
Jordan Crouse63f181f2008-04-25 23:09:39 +0000144void keyboard_init(void);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000145int keyboard_havechar(void);
146unsigned char keyboard_get_scancode(void);
147int keyboard_getchar(void);
Stefan Reinauerd84ef1e2008-09-26 18:37:26 +0000148int keyboard_set_layout(char *country);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000149/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000150
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000151/**
152 * @defgroup serial Serial functions
153 * @ingroup input
154 * @{
155 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000156void serial_init(void);
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000157void serial_putchar(unsigned int c);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000158int serial_havechar(void);
159int serial_getchar(void);
Jordan Crouse3b470652008-06-20 00:01:42 +0000160void serial_clear(void);
161void serial_start_bold(void);
162void serial_end_bold(void);
Stefan Reinauere75c3d82008-09-26 18:36:26 +0000163void serial_start_reverse(void);
164void serial_end_reverse(void);
Ulf Jordanb4d4bac2008-08-11 20:34:28 +0000165void serial_start_altcharset(void);
166void serial_end_altcharset(void);
Ulf Jordand57a6802008-09-03 19:59:44 +0000167void serial_set_color(short fg, short bg);
Stefan Reinauere75c3d82008-09-26 18:36:26 +0000168void serial_cursor_enable(int state);
Jordan Crouse3b470652008-06-20 00:01:42 +0000169void serial_set_cursor(int y, int x);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000170/** @} */
Jordan Crouse3b470652008-06-20 00:01:42 +0000171
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000172/**
173 * @defgroup speaker Speaker functions
174 * @ingroup input
175 * @{
176 */
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000177void speaker_enable(u16 freq);
178void speaker_disable(void);
179void speaker_tone(u16 freq, unsigned int duration);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000180/** @} */
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000181
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000182/**
183 * @defgroup video Video functions
184 * @ingroup input
185 * @{
186 */
Jordan Crouse30939bd2008-04-10 22:49:02 +0000187int video_console_init(void);
188void video_console_putchar(unsigned int ch);
189void video_console_putc(u8 row, u8 col, unsigned int ch);
190void video_console_clear(void);
191void video_console_cursor_enable(int state);
Stefan Reinauer59fb9a2b2008-08-19 17:44:49 +0000192void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en);
193void video_console_set_cursor(unsigned int cursorx, unsigned int cursory);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000194/** @} */
Stefan Reinauer59fb9a2b2008-08-19 17:44:49 +0000195
196/* drivers/option.c */
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100197struct nvram_accessor {
198 u8 (*read)(u8 reg);
199 void (*write)(u8 val, u8 reg);
200};
201
Patrick Georgi5febb002012-02-02 15:51:29 +0100202extern u8 *mem_accessor_base;
203extern struct nvram_accessor *use_nvram, *use_mem;
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100204
205struct cb_cmos_option_table *get_system_option_table(void);
Patrick Georgi56f468d2012-01-16 15:03:11 +0100206int options_checksum_valid(const struct nvram_accessor *nvram);
Patrick Georgi317ca0d2012-01-16 10:14:24 +0100207void fix_options_checksum_with(const struct nvram_accessor *nvram);
Stefan Reinauer59a1b7f2010-08-17 10:14:50 +0000208void fix_options_checksum(void);
Patrick Georgi0a595112012-01-16 15:39:57 +0100209struct cb_cmos_entries *first_cmos_entry(struct cb_cmos_option_table *option_table);
210struct cb_cmos_entries *next_cmos_entry(struct cb_cmos_entries *cur);
Mathias Kraused6a6eef2012-02-17 12:02:47 +0100211int get_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, void *dest, const char *name);
212int get_option_from(struct cb_cmos_option_table *option_table, void *dest, const char *name);
213int get_option(void *dest, const char *name);
214int set_option_with(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, const void *value, const char *name);
215int set_option(const void *value, const char *name);
216int get_option_as_string(const struct nvram_accessor *nvram, struct cb_cmos_option_table *option_table, char **dest, const char *name);
217int 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 +0000218
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000219/**
220 * @defgroup console Console functions
221 * @{
222 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000223void console_init(void);
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000224int putchar(unsigned int c);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000225int puts(const char *s);
226int havekey(void);
227int getchar(void);
Jordan Crouse672d0ae2008-04-08 23:21:33 +0000228int getchar_timeout(int *ms);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000229
Jordan Crousef6145c32008-03-19 23:56:58 +0000230extern int last_putchar;
231
Patrick Georgi657a6dc2008-10-21 15:08:18 +0000232struct console_input_driver;
233struct console_input_driver {
234 struct console_input_driver *next;
235 int (*havekey) (void);
236 int (*getchar) (void);
237};
238
239struct console_output_driver;
240struct console_output_driver {
241 struct console_output_driver *next;
242 void (*putchar) (unsigned int);
243};
244
245void console_add_output_driver(struct console_output_driver *out);
246void console_add_input_driver(struct console_input_driver *in);
247
Jordan Crousef6145c32008-03-19 23:56:58 +0000248#define havechar havekey
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000249/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000250
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000251/**
Uwe Hermann31538632008-08-31 22:10:35 +0000252 * @defgroup ipchecksum IP checksum functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000253 * @{
254 */
Stefan Reinauer11e45cd2008-08-16 15:16:36 +0000255unsigned short ipchksum(const void *ptr, unsigned long nbytes);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000256/** @} */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000257
Jordan Crousef6145c32008-03-19 23:56:58 +0000258
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000259/**
Uwe Hermann31538632008-08-31 22:10:35 +0000260 * @defgroup exec Execution functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000261 * @{
262 */
Jordan Crouse9dac1b42008-05-20 20:10:49 +0000263int exec(long addr, int argc, char **argv);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000264/** @} */
Jordan Crouse9dac1b42008-05-20 20:10:49 +0000265
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000266/**
Uwe Hermann31538632008-08-31 22:10:35 +0000267 * @defgroup misc Misc functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000268 * @{
269 */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000270int bcd2dec(int b);
271int dec2bcd(int d);
Uwe Hermannb1033452008-04-11 18:38:04 +0000272int abs(int j);
273long int labs(long int j);
274long long int llabs(long long int j);
275u8 bin2hex(u8 b);
276u8 hex2bin(u8 h);
Uwe Hermann31538632008-08-31 22:10:35 +0000277void fatal(const char *msg) __attribute__ ((noreturn));
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000278/** @} */
Uwe Hermann8cc38d22008-03-27 23:26:40 +0000279
Uwe Hermannc5a78ac2008-04-08 23:38:15 +0000280
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000281/**
Uwe Hermann31538632008-08-31 22:10:35 +0000282 * @defgroup hash Hashing functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000283 * @{
284 */
Uwe Hermann39955932008-04-03 23:01:23 +0000285#define SHA1_BLOCK_LENGTH 64
286#define SHA1_DIGEST_LENGTH 20
287typedef struct {
288 u32 state[5];
289 u64 count;
290 u8 buffer[SHA1_BLOCK_LENGTH];
291} SHA1_CTX;
292void SHA1Init(SHA1_CTX *context);
293void SHA1Transform(u32 state[5], const u8 buffer[SHA1_BLOCK_LENGTH]);
294void SHA1Update(SHA1_CTX *context, const u8 *data, size_t len);
Patrick Georgi7f965832011-04-21 18:57:16 +0200295void SHA1Pad(SHA1_CTX *context);
Uwe Hermann39955932008-04-03 23:01:23 +0000296void SHA1Final(u8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context);
297u8 *sha1(const u8 *data, size_t len, u8 *buf);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000298/** @} */
Uwe Hermann39955932008-04-03 23:01:23 +0000299
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000300/**
Uwe Hermann31538632008-08-31 22:10:35 +0000301 * @defgroup time Time functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000302 * @{
303 */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000304
Uwe Hermann31538632008-08-31 22:10:35 +0000305/** System time structure */
Jordan Crousee2271432008-04-25 23:11:02 +0000306struct timeval {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000307 time_t tv_sec; /**< Seconds */
308 suseconds_t tv_usec; /**< Microseconds */
Jordan Crousee2271432008-04-25 23:11:02 +0000309};
310
311int gettimeofday(struct timeval *tv, void *tz);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000312/** @} */
Jordan Crousee2271432008-04-25 23:11:02 +0000313
Stefan Reinauere5d30b72010-03-25 22:15:19 +0000314#ifdef CONFIG_LAR
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000315/**
Uwe Hermann31538632008-08-31 22:10:35 +0000316 * @defgroup lar LAR functions
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000317 * @{
318 */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000319
Uwe Hermann31538632008-08-31 22:10:35 +0000320/** LAR file header */
Jordan Crouse681ec272008-05-07 20:34:02 +0000321struct LAR {
Uwe Hermann31538632008-08-31 22:10:35 +0000322 void *start; /**< Location of the LAR in memory */
Jordan Crousee2ad8062008-08-28 23:10:55 +0000323 int cindex; /**< Next file to return in readlar() */
324 int count; /**< Number of entries in the header cache */
325 int alloc; /**< Number of slots in the header cache */
326 int eof; /**< Last entry in the header cache */
327 void **headers; /**< Pointer to the header cache */
Jordan Crouse681ec272008-05-07 20:34:02 +0000328};
329
Uwe Hermann31538632008-08-31 22:10:35 +0000330/** A structure representing the next LAR entry */
Jordan Crouse681ec272008-05-07 20:34:02 +0000331struct larent {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000332 u8 name[LAR_MAX_PATHLEN]; /**< The name of the next LAR entry */
Jordan Crouse681ec272008-05-07 20:34:02 +0000333};
334
Uwe Hermann31538632008-08-31 22:10:35 +0000335/** A structure containing information about a LAR file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000336struct larstat {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000337 u32 len; /**< Length of the file in the LAR */
338 u32 reallen; /**< Length of the uncompressed file */
339 u32 checksum; /**< Checksum of the uncompressed file */
340 u32 compchecksum; /**< Checksum of the compressed file in the LAR */
341 u32 offset; /**< Offset of the file in the LAR */
342 u32 compression; /**< Compression type of the file */
343 u64 entry; /**< Entry point of the file for executables */
344 u64 loadaddress; /**< Address in memory to put the uncompressed file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000345};
346
Uwe Hermann31538632008-08-31 22:10:35 +0000347/** A structure representing a LAR file */
Jordan Crouse681ec272008-05-07 20:34:02 +0000348struct LFILE {
Jordan Crousee2ad8062008-08-28 23:10:55 +0000349 struct LAR *lar; /**< Pointer to the LAR struct */
350 struct lar_header *header; /**< Pointer to the header struct */
351 u32 size; /**< Size of the file */
352 void *start; /**< Start of the file in memory */
353 u32 offset; /**< Offset of the file in the LAR */
Jordan Crouse681ec272008-05-07 20:34:02 +0000354};
355
356struct LAR *openlar(void *addr);
357int closelar(struct LAR *lar);
358struct larent *readlar(struct LAR *lar);
359void rewindlar(struct LAR *lar);
360int larstat(struct LAR *lar, const char *path, struct larstat *buf);
Jordan Crouse50698082008-05-20 20:09:42 +0000361void *larfptr(struct LAR *lar, const char *filename);
Jordan Crouse9e734c22008-05-27 19:57:53 +0000362int lfverify(struct LAR *lar, const char *filename);
Uwe Hermann31538632008-08-31 22:10:35 +0000363struct LFILE *lfopen(struct LAR *lar, const char *filename);
Jordan Crouse681ec272008-05-07 20:34:02 +0000364int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream);
365
Jordan Crouse681ec272008-05-07 20:34:02 +0000366int lfseek(struct LFILE *stream, long offset, int whence);
367int lfclose(struct LFILE *file);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000368/** @} */
Stefan Reinauere5d30b72010-03-25 22:15:19 +0000369#endif
Jordan Crouse681ec272008-05-07 20:34:02 +0000370
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000371/**
Jordan Crouse6c6e4332008-11-11 19:51:14 +0000372 * @defgroup info System information functions
373 * This module contains functions that return information about the system
374 * @{
375 */
376
377int sysinfo_have_multiboot(unsigned long *addr);
378/** @} */
379
380/**
Uwe Hermann31538632008-08-31 22:10:35 +0000381 * @defgroup arch Architecture specific functions
382 * This module contains global architecture specific functions.
Jordan Crouseb7461782008-08-28 23:12:22 +0000383 * All architectures are expected to define these functions.
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000384 * @{
385 */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000386int get_coreboot_info(struct sysinfo_t *info);
Jordan Crouse20c9cf12008-10-20 16:51:43 +0000387int get_multiboot_info(struct sysinfo_t *info);
Jordan Crousef6145c32008-03-19 23:56:58 +0000388
Philip Prindeville44bf6fc2011-12-23 18:33:05 -0700389int lib_get_sysinfo(void);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000390
Uwe Hermann661e3802008-03-21 18:37:23 +0000391/* Timer functions - defined by each architecture. */
Uwe Hermanndc69e052008-03-20 01:53:30 +0000392unsigned int get_cpu_speed(void);
393void ndelay(unsigned int n);
Jordan Crouse234e87f2008-04-10 22:50:44 +0000394void udelay(unsigned int n);
Uwe Hermanndc69e052008-03-20 01:53:30 +0000395void mdelay(unsigned int n);
396void delay(unsigned int n);
397
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000398/**
Uwe Hermann31538632008-08-31 22:10:35 +0000399 * @defgroup readline Readline functions
400 * This interface provides a simple implementation of the standard readline()
401 * and getline() functions. They read a line of input from the console.
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000402 * @{
403 */
Uwe Hermann31538632008-08-31 22:10:35 +0000404char *readline(const char *prompt);
Jakob Bornecrantzb0d3e712008-08-23 12:17:46 +0000405int getline(char *buffer, int len);
Jordan Crouse3a48bdc2008-08-28 16:53:24 +0000406/** @} */
Jordan Crousef6145c32008-03-19 23:56:58 +0000407
Jordan Crousef6145c32008-03-19 23:56:58 +0000408#endif