1 /****************************************************************************
2 * YABEL BIOS Emulator
3 *
4 * Copyright (c) 2008 Pattrick Hueper <phueper@hueper.net>
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 ****************************************************************************/
33
34 /* this file contains functions provided by SLOF, that the current biosemu implementation needs
35 * they should go away in the future...
36 */
37
38 #include <types.h>
39 #include <device/device.h>
40 #include "../debug.h"
41 #include "../biosemu.h"
42 #include <vbe.h>
43 #include "../compat/time.h"
44
45 #define VMEM_SIZE (1024 * 1024) /* 1 MB */
46
47 #if !CONFIG(YABEL_DIRECTHW)
48 #if CONFIG_YABEL_VIRTMEM_LOCATION
49 u8* vmem = (u8 *) CONFIG_YABEL_VIRTMEM_LOCATION;
50 #else
51 u8* vmem = (u8 *) (16*1024*1024); /* default to 16MB */
52 #endif
53 #else
54 u8* vmem = NULL;
55 #endif
56
57 extern u8 *biosmem;
58
run_bios(struct device * dev,unsigned long addr)59 void run_bios(struct device * dev, unsigned long addr)
60 {
61 biosmem = vmem;
62
63 biosemu(vmem, VMEM_SIZE, dev, addr);
64
65 #if CONFIG(FRAMEBUFFER_SET_VESA_MODE)
66 vbe_set_graphics();
67 #endif
68 }
69
70 unsigned long tb_freq = 0;
71
get_time(void)72 u64 get_time(void)
73 {
74 u64 act = 0;
75 #if ENV_X86
76 u32 eax, edx;
77
78 __asm__ __volatile__(
79 "rdtsc"
80 : "=a"(eax), "=d"(edx)
81 : /* no inputs, no clobber */);
82 act = ((u64) edx << 32) | eax;
83 #endif
84 return act;
85 }
86