aboutsummaryrefslogtreecommitdiff
path: root/util/x86emu/yabel/compat
diff options
context:
space:
mode:
Diffstat (limited to 'util/x86emu/yabel/compat')
-rw-r--r--util/x86emu/yabel/compat/Config.lb1
-rw-r--r--util/x86emu/yabel/compat/functions.c96
-rw-r--r--util/x86emu/yabel/compat/of.h55
-rw-r--r--util/x86emu/yabel/compat/rtas.h45
-rw-r--r--util/x86emu/yabel/compat/time.h17
5 files changed, 214 insertions, 0 deletions
diff --git a/util/x86emu/yabel/compat/Config.lb b/util/x86emu/yabel/compat/Config.lb
new file mode 100644
index 0000000000..919526d16b
--- /dev/null
+++ b/util/x86emu/yabel/compat/Config.lb
@@ -0,0 +1 @@
+object functions.o
diff --git a/util/x86emu/yabel/compat/functions.c b/util/x86emu/yabel/compat/functions.c
new file mode 100644
index 0000000000..3b3d223b71
--- /dev/null
+++ b/util/x86emu/yabel/compat/functions.c
@@ -0,0 +1,96 @@
+/****************************************************************************
+ * YABEL BIOS Emulator
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Copyright (c) 2008 Pattrick Hueper <phueper@hueper.net>
+ ****************************************************************************/
+
+/* this file contains functions provided by SLOF, that the current biosemu implementation needs
+ * they should go away inthe future...
+ */
+
+#include <types.h>
+#ifndef CONFIG_COREBOOT_V2
+#include <config.h>
+#endif
+#include <device/device.h>
+
+#define VMEM_SIZE 1024 *1024 /* 1 MB */
+
+#ifdef CONFIG_YABEL_VIRTMEM_LOCATION
+u8* vmem = (u8 *) CONFIG_YABEL_VIRTMEM_LOCATION;
+#else
+u8* vmem = (u8 *) (16*1024*1024); /* default to 16MB */
+#endif
+
+u32 biosemu(u8 *biosmem, u32 biosmem_size, struct device *dev,
+ unsigned long rom_addr);
+
+void run_bios(struct device * dev, unsigned long addr)
+{
+ biosemu(vmem, VMEM_SIZE, dev, addr);
+}
+
+u64 get_time(void)
+{
+ u64 act;
+ u32 eax, edx;
+
+ __asm__ __volatile__(
+ "rdtsc"
+ : "=a"(eax), "=d"(edx)
+ : /* no inputs, no clobber */);
+ act = ((u64) edx << 32) | eax;
+ return act;
+}
+
+unsigned int
+read_io(void *addr, size_t sz)
+{
+ unsigned int ret;
+ /* since we are using inb instructions, we need the port number as 16bit value */
+ u16 port = (u16)(u32) addr;
+
+ switch (sz) {
+ case 1:
+ asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port));
+ break;
+ case 2:
+ asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port));
+ break;
+ case 4:
+ asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port));
+ break;
+ default:
+ ret = 0;
+ }
+
+ return ret;
+}
+
+int
+write_io(void *addr, unsigned int value, size_t sz)
+{
+ u16 port = (u16)(u32) addr;
+ switch (sz) {
+ /* since we are using inb instructions, we need the port number as 16bit value */
+ case 1:
+ asm volatile ("outb %b0, %1" : : "a"(value), "d" (port));
+ break;
+ case 2:
+ asm volatile ("outw %w0, %1" : : "a"(value), "d" (port));
+ break;
+ case 4:
+ asm volatile ("outl %0, %1" : : "a"(value), "d" (port));
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/util/x86emu/yabel/compat/of.h b/util/x86emu/yabel/compat/of.h
new file mode 100644
index 0000000000..907139951f
--- /dev/null
+++ b/util/x86emu/yabel/compat/of.h
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+
+#ifndef OF_H
+#define OF_H
+#define p32 int
+#define p32cast (int) (unsigned long) (void*)
+
+#define phandle_t p32
+#define ihandle_t p32
+
+typedef struct
+{
+ unsigned int serv;
+ int nargs;
+ int nrets;
+ unsigned int args[16];
+} of_arg_t;
+
+
+phandle_t of_finddevice (const char *);
+phandle_t of_peer (phandle_t);
+phandle_t of_child (phandle_t);
+phandle_t of_parent (phandle_t);
+int of_getprop (phandle_t, const char *, void *, int);
+void * of_call_method_3 (const char *, ihandle_t, int);
+
+
+ihandle_t of_open (const char *);
+void of_close(ihandle_t);
+int of_read (ihandle_t , void*, int);
+int of_write (ihandle_t, void*, int);
+int of_seek (ihandle_t, int, int);
+
+void * of_claim(void *, unsigned int , unsigned int );
+void of_release(void *, unsigned int );
+
+int of_yield(void);
+void * of_set_callback(void *);
+
+int vpd_read(unsigned int , unsigned int , char *);
+int vpd_write(unsigned int , unsigned int , char *);
+int write_mm_log(char *, unsigned int , unsigned short );
+
+#endif
diff --git a/util/x86emu/yabel/compat/rtas.h b/util/x86emu/yabel/compat/rtas.h
new file mode 100644
index 0000000000..25cabf4d6a
--- /dev/null
+++ b/util/x86emu/yabel/compat/rtas.h
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+
+#ifndef RTAS_H
+#define RTAS_H
+
+#include "of.h"
+
+typedef struct dtime {
+ unsigned int year;
+ unsigned int month;
+ unsigned int day;
+ unsigned int hour;
+ unsigned int minute;
+ unsigned int second;
+ unsigned int nano;
+} dtime;
+
+typedef void (*thread_t) (int);
+
+int rtas_token(const char *);
+int rtas_call(int, int, int, int *, ...);
+void rtas_init(void);
+int rtas_pci_config_read (long long, int, int, int, int);
+int rtas_pci_config_write (long long, int, int, int, int, int);
+int rtas_set_time_of_day(dtime *);
+int rtas_get_time_of_day(dtime *);
+int rtas_ibm_update_flash_64(long long, long long);
+int rtas_ibm_update_flash_64_and_reboot(long long, long long);
+int rtas_system_reboot(void);
+int rtas_start_cpu (int, thread_t, int);
+int rtas_stop_self (void);
+int rtas_ibm_manage_flash(int);
+
+#endif
diff --git a/util/x86emu/yabel/compat/time.h b/util/x86emu/yabel/compat/time.h
new file mode 100644
index 0000000000..c8432eca43
--- /dev/null
+++ b/util/x86emu/yabel/compat/time.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ * YABEL BIOS Emulator
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Copyright (c) 2008 Pattrick Hueper <phueper@hueper.net>
+ ****************************************************************************/
+
+#ifndef _BIOSEMU_COMPAT_TIME_H
+#define _BIOSEMU_COMPAT_TIME_H
+
+/* TODO: check how this works in x86 */
+static unsigned long tb_freq = 0;
+#endif