db37fbc6f99d203610965750d932083c530fa571
[coreboot.git] / src / devices / oprom / yabel / compat / functions.c
1 /****************************************************************************
2  * YABEL BIOS Emulator
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Copyright (c) 2008 Pattrick Hueper <phueper@hueper.net>
10  ****************************************************************************/
11
12 /* this file contains functions provided by SLOF, that the current biosemu implementation needs
13  * they should go away  inthe future...
14  */
15
16 #include <types.h>
17 #include <string.h>
18 #include <device/device.h>
19 #include "../debug.h"
20 #include "../biosemu.h"
21 #include "../vbe.h"
22 #include "../compat/time.h"
23
24 #define VMEM_SIZE (1024 * 1024) /* 1 MB */
25
26 #if !CONFIG_YABEL_DIRECTHW
27 #if CONFIG_YABEL_VIRTMEM_LOCATION
28 u8* vmem = (u8 *) CONFIG_YABEL_VIRTMEM_LOCATION;
29 #else
30 u8* vmem = (u8 *) (16*1024*1024); /* default to 16MB */
31 #endif
32 #else
33 u8* vmem = NULL;
34 #endif
35
36 void run_bios(struct device * dev, unsigned long addr)
37 {
38
39         biosemu(vmem, VMEM_SIZE, dev, addr);
40
41 #if CONFIG_BOOTSPLASH
42         vbe_set_graphics();
43 #endif
44 }
45
46 unsigned long tb_freq = 0;
47
48 u64 get_time(void)
49 {
50     u64 act;
51     u32 eax, edx;
52
53     __asm__ __volatile__(
54         "rdtsc"
55         : "=a"(eax), "=d"(edx)
56         : /* no inputs, no clobber */);
57     act = ((u64) edx << 32) | eax;
58     return act;
59 }