1 /****************************************************************************
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
9 * Copyright (c) 2008 Pattrick Hueper <phueper@hueper.net>
10 ****************************************************************************/
12 /* this file contains functions provided by SLOF, that the current biosemu implementation needs
13 * they should go away inthe future...
18 #include <device/device.h>
21 #define VMEM_SIZE (1024 * 1024) /* 1 MB */
23 #if !defined(CONFIG_YABEL_DIRECTHW) || (!CONFIG_YABEL_DIRECTHW)
24 #ifdef CONFIG_YABEL_VIRTMEM_LOCATION
25 u8* vmem = (u8 *) CONFIG_YABEL_VIRTMEM_LOCATION;
27 u8* vmem = (u8 *) (16*1024*1024); /* default to 16MB */
33 u32 biosemu(u8 *biosmem, u32 biosmem_size, struct device *dev,
34 unsigned long rom_addr);
36 void vbe_set_graphics(void);
39 void run_bios(struct device * dev, unsigned long addr)
42 biosemu(vmem, VMEM_SIZE, dev, addr);
49 printf("Copying legacy memory from 0x%08x to the lower 1MB\n", vmem);
50 memcpy(0x00000, vmem + 0x00000, 0x400); // IVT
51 memcpy(0x00400, vmem + 0x00400, 0x100); // BDA
52 memcpy(0xc0000, vmem + 0xc0000, 0x10000); // VGA OPROM
63 : "=a"(eax), "=d"(edx)
64 : /* no inputs, no clobber */);
65 act = ((u64) edx << 32) | eax;
70 read_io(void *addr, size_t sz)
73 /* since we are using inb instructions, we need the port number as 16bit value */
74 u16 port = (u16)(u32) addr;
78 asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port));
81 asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port));
84 asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port));
94 write_io(void *addr, unsigned int value, size_t sz)
96 u16 port = (u16)(u32) addr;
98 /* since we are using inb instructions, we need the port number as 16bit value */
100 asm volatile ("outb %b0, %1" : : "a"(value), "d" (port));
103 asm volatile ("outw %w0, %1" : : "a"(value), "d" (port));
106 asm volatile ("outl %0, %1" : : "a"(value), "d" (port));