1/* 2 * This file is part of the coreboot project. 3 * 4 * Copyright (C) 2007 coresystems GmbH 5 * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH) 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; version 2 of the License. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21#ifndef LIB_H 22#define LIB_H 23#include <shared.h> 24 25/** 26 * Return the size of a given array, no matter of which data type 27 * the individual array elements are. 28 */ 29#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 30 31/* you have to explicity pick logc2 (ceiling) or log2f (floor) 32 * it is a no-op if you KNOW that your number is a power of 2. 33 * It is important to know what you are doing otherwise. 34 * example: log2c(72) is 7, log2f(72) is 6! 35 */ 36int log2c(unsigned int n); 37int log2f(unsigned int n); 38 39void udelay(unsigned int usecs); 40void mdelay(unsigned int msecs); 41void delay(unsigned int secs); 42 43/* all architectures must implement a 64-bit time counter 44 * that is compiled into stage1 45 * rdtsc is usually fine. 46 */ 47u64 cycles(void); 48 49void beep_short(void); 50void beep_long(void); 51 52/* Optional ramtest. */ 53int ram_check(unsigned long start, unsigned long stop); 54 55/* required: a way to tell if this is a: 56 * power-on/reset (coldboot) OR 57 * coreboot has initiated a reset (warmboot). 58 */ 59int is_coldboot(void); 60 61#endif /* LIB_H */ 62

