Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 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> |
Stefan Reinauer | 074356e | 2009-10-25 19:50:47 +0000 | [diff] [blame] | 17 | #include <string.h> |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 18 | #include <device/device.h> |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 19 | #include "../debug.h" |
Uwe Hermann | 01ce601 | 2010-03-05 10:03:50 +0000 | [diff] [blame] | 20 | #include "../biosemu.h" |
Stefan Reinauer | 3c486f8 | 2010-03-17 04:04:20 +0000 | [diff] [blame^] | 21 | #include "../vbe.h" |
Myles Watson | b025911 | 2010-03-05 18:27:19 +0000 | [diff] [blame] | 22 | #include "../compat/time.h" |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 23 | |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 24 | #define VMEM_SIZE (1024 * 1024) /* 1 MB */ |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 25 | |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 26 | #if !defined(CONFIG_YABEL_DIRECTHW) || (!CONFIG_YABEL_DIRECTHW) |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 27 | #ifdef 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 |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 32 | #else |
| 33 | u8* vmem = NULL; |
| 34 | #endif |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 35 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 36 | void run_bios(struct device * dev, unsigned long addr) |
| 37 | { |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 38 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 39 | biosemu(vmem, VMEM_SIZE, dev, addr); |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 40 | |
| 41 | #if CONFIG_BOOTSPLASH |
| 42 | vbe_set_graphics(); |
| 43 | #endif |
| 44 | |
| 45 | if (vmem != NULL) { |
Uwe Hermann | 01ce601 | 2010-03-05 10:03:50 +0000 | [diff] [blame] | 46 | printf("Copying legacy memory from %p to the lower 1MB\n", vmem); |
| 47 | memcpy((void *)0x00000, vmem + 0x00000, 0x400); // IVT |
| 48 | memcpy((void *)0x00400, vmem + 0x00400, 0x100); // BDA |
| 49 | memcpy((void *)0xc0000, vmem + 0xc0000, 0x10000); // VGA OPROM |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 50 | } |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Myles Watson | b025911 | 2010-03-05 18:27:19 +0000 | [diff] [blame] | 53 | unsigned long tb_freq = 0; |
| 54 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 55 | u64 get_time(void) |
| 56 | { |
| 57 | u64 act; |
| 58 | u32 eax, edx; |
| 59 | |
| 60 | __asm__ __volatile__( |
| 61 | "rdtsc" |
| 62 | : "=a"(eax), "=d"(edx) |
| 63 | : /* no inputs, no clobber */); |
| 64 | act = ((u64) edx << 32) | eax; |
| 65 | return act; |
| 66 | } |