--- /dev/null
+#!/bin/sh
+
+make DEBUG_ALL=1 world
+cp vmm.img iso
+mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
+
--- /dev/null
+# Makefile for GeekOS kernel, userspace, and tools
+#
+# Northwestern University
+# (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+# (c) 2008, Peter Dinda <pdinda@northwestern.edu>
+# (c) 2008, Lei Xia <xiaxlei@gmail.com>
+# (c) 2008, The V3VEE Project <http://www.v3vee.org>
+#
+# Based on GeekOS Makefile:
+# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
+# $Revision: 1.71 $
+
+
+# This is free software. You are permitted to use,
+# redistribute, and modify it as specified in the file "COPYING".
+
+# Required software to build GeekOS:
+# - GNU Make (http://www.gnu.org/software/make)
+# - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
+# - nasm (http://nasm.sourceforge.net)
+# - Perl5, AWK (any version), egrep
+#
+# Cygwin (http://cygwin.com) may be used to build GeekOS.
+# Make sure that gcc, binutils, nasm, and perl are installed.
+
+# NOTES:
+# - This makefile has been written carefully to work correctly
+# with the -j (parallel make) option. I regularly use "make -j 2"
+# to speed the build process on 2 processor systems.
+
+
+
+
+# ----------------------------------------------------------------------
+# Configuration -
+# Various options specifying how GeekOS should be built,
+# what source files to build, which user programs to build,
+# etc. This is generally the only section of the makefile
+# that will need to be modified.
+# ----------------------------------------------------------------------
+PROJECT_ROOT := ..
+PALACIOS_BUILD_DIR := $(PROJECT_ROOT)/palacios/build
+GEEKOS_BUILD_DIR := $(PROJECT_ROOT)/geekos/build
+GUEST_ISO_DIR := /opt/vmm-tools/isos
+
+# List of targets to build by default.
+# These targets encompass everything needed to boot
+# and run GeekOS.
+ALL_TARGETS := palacios geekos
+
+QEMU := /usr/local/qemu/bin/qemu-system-x86_64
+
+
+
+#when -DNDEBUG is set the kassert functions are disabled
+#JRLDEBUG=-DNDEBUG
+
+# DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
+# as are SERIAL_PRINT_DEBUG
+#
+DEBUG_SECTIONS := DEBUG=1
+
+ifeq ($(DEBUG_ALL),1)
+ DEBUG_SECTIONS:= $(DEBUG_SECTIONS) DEBUG_ALL=1
+endif
+
+ifeq ($(DEBUG_SHADOW_PAGING),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_SHADOW_PAGING=1
+else
+ifeq ($(DEBUG_SHADOW_PAGING),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_SHADOW_PAGING=0
+endif
+endif
+
+ifeq ($(DEBUG_CTRL_REGS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_CTRL_REGS=1
+else
+ifeq ($(DEBUG_CTRL_REGS),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_CTRL_REGS=0
+endif
+endif
+
+ifeq ($(DEBUG_INTERRUPTS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_INTERRUPTS=1
+else
+ifeq ($(DEBUG_INTERRUPTS),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_INTERRUPTS=0
+endif
+endif
+
+ifeq ($(DEBUG_IO),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_IO=1
+else
+ifeq ($(DEBUG_IO),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_IO=0
+endif
+endif
+
+ifeq ($(DEBUG_KEYBOARD),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_KEYBOARD=1
+else
+ifeq ($(DEBUG_KEYBOARD),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_KEYBOARD=0
+endif
+endif
+
+ifeq ($(DEBUG_PIC),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIC=1
+else
+ifeq ($(DEBUG_PIC),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIC=0
+endif
+endif
+
+ifeq ($(DEBUG_PIT),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIT=1
+else
+ifeq ($(DEBUG_PIT),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_PIT=0
+endif
+endif
+
+ifeq ($(DEBUG_NVRAM),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_NVRAM=1
+else
+ifeq ($(DEBUG_NVRAM),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_NVRAM=0
+endif
+endif
+
+ifeq ($(DEBUG_GENERIC),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_GENERIC=1
+else
+ifeq ($(DEBUG_GENERIC),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_GENERIC=0
+endif
+endif
+
+ifeq ($(DEBUG_EMULATOR),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_EMULATOR=1
+else
+ifeq ($(DEBUG_EMULATOR),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_EMULATOR=0
+endif
+endif
+
+ifeq ($(DEBUG_RAMDISK),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_RAMDISK=1
+else
+ifeq ($(DEBUG_RAMDISK),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) DEBUG_RAMDISK=0
+endif
+endif
+
+
+# ----------------------------------------------------------------------
+# Targets -
+# Specifies files to be built
+# ----------------------------------------------------------------------
+
+# Default target - see definition of ALL_TARGETS in Configuration section
+all : $(ALL_TARGETS)
+
+
+
+palacios:
+ (cd $(PALACIOS_BUILD_DIR) && make $(DEBUG_SECTIONS) world)
+
+
+geekos:
+ cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
+ cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
+ cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
+ (cd $(GEEKOS_BUILD_DIR) && make clean && make)
+
+
+
+
+# make ready to boot over PXE
+geekos-pxe: geekos
+ cp $(GEEKOS_BUILD_DIR)/vmm.img /tftpboot/vmm.img
+
+geekos-run: geekos
+ $(QEMU) -m 1024 -serial file:serial.out -cdrom $(GUEST_ISO_DIR)/puppy.iso -fda $(GEEKOS_BUILD_DIR)/vmm.img
+
+geekos-iso: geekos
+ cp $(GEEKOS_BUILD_DIR)/vmm.img iso/vmm.img
+ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
+
+
+
+force:
+
+
+
+
+# Clean build directories of generated files
+clean :
+ for d in $(GEEKOS_BUILD_DIR) $(PALACIOS_BUILD_DIR); do \
+ (cd $$d && make clean); \
+ done
+
+
--- /dev/null
+# Makefile for GeekOS kernel, userspace, and tools
+#
+# Northwestern University
+# (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+# (c) 2008, Peter Dinda <pdinda@northwestern.edu>
+# (c) 2008, Lei Xia <xiaxlei@gmail.com>
+# (c) 2008, The V3VEE Project <http://www.v3vee.org>
+#
+# Based on GeekOS Makefile:
+# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
+# $Revision: 1.71 $
+
+
+# This is free software. You are permitted to use,
+# redistribute, and modify it as specified in the file "COPYING".
+
+# Required software to build GeekOS:
+# - GNU Make (http://www.gnu.org/software/make)
+# - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
+# - nasm (http://nasm.sourceforge.net)
+# - Perl5, AWK (any version), egrep
+#
+# Cygwin (http://cygwin.com) may be used to build GeekOS.
+# Make sure that gcc, binutils, nasm, and perl are installed.
+
+# NOTES:
+# - This makefile has been written carefully to work correctly
+# with the -j (parallel make) option. I regularly use "make -j 2"
+# to speed the build process on 2 processor systems.
+
+
+# Base address of kernel
+#
+# Note: at top of memory minus three pages (GDT/TSS/IDT)
+# minus maximum size
+#
+#
+# Note that the code will initially load at 0x10000
+#
+# The setup code needs to copy it up to this address and jump there
+#
+KERNEL_BASE_ADDR := 0x00100000
+
+# Kernel entry point function
+KERNEL_ENTRY = $(SYM_PFX)Main
+
+
+PROJECT_ROOT := ..
+VPATH := $(PROJECT_ROOT)/src
+
+#when -DNDEBUG is set the kassert functions are disabled
+#JRLDEBUG=-DNDEBUG
+
+# DEBUG=1 means VMM_DEBUG, VMM_INFO, and VMM_TRACE are enabled
+# as are SERIAL_PRINT_DEBUG
+#
+DEBUG=1
+DEBUG_SECTIONS=
+
+ifeq ($(DEBUG_ALL),1)
+ DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_IO -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR -DDEBUG_GENERIC -DDEBUG_RAMDISK
+endif
+
+ifeq ($(DEBUG_SHADOW_PAGING),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
+else
+ifeq ($(DEBUG_SHADOW_PAGING),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_SHADOW_PAGING
+endif
+endif
+
+ifeq ($(DEBUG_CTRL_REGS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
+else
+ifeq ($(DEBUG_CTRL_REGS),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_CTRL_REGS
+endif
+endif
+
+ifeq ($(DEBUG_INTERRUPTS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
+else
+ifeq ($(DEBUG_DEBUG_INTERRUPTS),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_INTERRUPTS
+endif
+endif
+
+ifeq ($(DEBUG_IO),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
+else
+ifeq ($(DEBUG_IO),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_IO
+endif
+endif
+
+ifeq ($(DEBUG_KEYBOARD),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
+else
+ifeq ($(DEBUG_KEYBOARD),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_KEYBOARD
+endif
+endif
+
+ifeq ($(DEBUG_PIC),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
+else
+ifeq ($(DEBUG_PIC),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIC
+endif
+endif
+
+ifeq ($(DEBUG_PIT),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
+else
+ifeq ($(DEBUG_PIT),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_PIT
+endif
+endif
+
+ifeq ($(DEBUG_NVRAM),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
+else
+ifeq ($(DEBUG_NVRAM),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_NVRAM
+endif
+endif
+
+ifeq ($(DEBUG_GENERIC),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_GENERIC
+else
+ifeq ($(DEBUG_GENERIC),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_GENERIC
+endif
+endif
+
+ifeq ($(DEBUG_EMULATOR),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_EMULATOR
+else
+ifeq ($(DEBUG_EMULATOR),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_EMULATOR
+endif
+endif
+
+ifeq ($(DEBUG_RAMDISK),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_RAMDISK
+else
+ifeq ($(DEBUG_RAMDISK),0)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -UDEBUG_RAMDISK
+endif
+endif
+
+
+#DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DTEST_NE2K
+
+ifeq ($(DEBUG),1)
+ JRLDEBUG= -DSERIAL_PRINT_DEBUG=1 -DSERIAL_PRINT_DEBUG_LEVEL=10 -DSERIAL_PRINT=1 -DVMM_DEBUG=1 -DVMM_INFO=1 -DVMM_TRACE=1 $(DEBUG_SECTIONS)
+
+else
+ JRLDEBUG= -DSERIAL_PRINT_DEBUG=0 -DSERIAL_PRINT_DEBUG_LEVEL=999999 -DSERIAL_PRINT=0 -DVMM_DEBUG=0 -DVMM_INFO=0 -DVMM_TRACE=0
+endif
+
+
+#
+# DECODER is the decoder that will be used
+# currently we only support xed
+#
+DECODER=XED
+
+DECODER_FLAGS=
+DECODER_SRCS=
+DECODER_LIBS=
+
+ifeq ($(DECODER),XED)
+DECODER_SRCS := vmm_xed.c
+DECODER_FLAGS := -L../lib/xed
+DECODER_LIBS := -lxed
+else
+# This is an error
+endif
+
+#
+#TCPSTACK, uIP is used currently
+#
+TCPSTACK=UIP
+
+
+
+
+#
+# This is wrong for current cygwin - no changes needed
+#
+# Figure out if we're compiling with cygwin, http://cygwin.com
+#
+#
+#SYSTEM_NAME := $(shell uname -s)
+#ifeq ($(findstring CYGWIN,$(SYSTEM_NAME)),CYGWIN)
+#SYM_PFX := _
+#EXTRA_C_OPTS := -DNEED_UNDERSCORE -DGNU_WIN32
+#EXTRA_NASM_OPTS := -DNEED_UNDERSCORE
+#NON_ELF_SYSTEM := yes
+#EXTRA_CC_USER_OPTS := -Dmain=geekos_main
+#endif
+
+
+
+
+# ----------------------------------------------------------------------
+# Configuration -
+# Various options specifying how GeekOS should be built,
+# what source files to build, which user programs to build,
+# etc. This is generally the only section of the makefile
+# that will need to be modified.
+# ----------------------------------------------------------------------
+
+# List of targets to build by default.
+# These targets encompass everything needed to boot
+# and run GeekOS.
+ALL_TARGETS := vmm.img vm_kernel
+
+
+# Kernel source files
+KERNEL_C_SRCS := idt.c int.c trap.c irq.c io.c \
+ blockdev.c ide.c ne2k.c \
+ keyboard.c screen.c timer.c \
+ mem.c crc32.c \
+ gdt.c tss.c segment.c \
+ bget.c malloc.c \
+ synch.c kthread.c \
+ serial.c reboot.c \
+ paging.c \
+ debug.c vmm_stubs.c vm.c pci.c\
+ queue.c socket.c net.c ring_buffer.c \
+ main.c
+
+
+# Kernel object files built from C source files
+KERNEL_C_OBJS := $(KERNEL_C_SRCS:%.c=geekos/%.o)
+
+# Kernel assembly files
+KERNEL_ASM_SRCS := lowlevel.asm
+
+KERNEL_GAS_SRCS := testvm.s udivdi3.s
+
+# Kernel object files build from assembler source files
+KERNEL_ASM_OBJS := $(KERNEL_ASM_SRCS:%.asm=geekos/%.o)
+
+KERNEL_GAS_OBJS := $(KERNEL_GAS_SRCS:%.s=geekos/%.o)
+
+
+# All kernel object files
+KERNEL_OBJS := $(KERNEL_C_OBJS) \
+ $(KERNEL_ASM_OBJS) $(KERNEL_GAS_OBJS)
+
+# Common library source files.
+# This library is linked into both the kernel and user programs.
+# It provides string functions and generic printf()-style
+# formatted output.
+COMMON_C_SRCS := fmtout.c string.c memmove.c
+
+# Common library object files.
+COMMON_C_OBJS := $(COMMON_C_SRCS:%.c=common/%.o)
+
+VMM_ASM_SRCS := svm_lowlevel.asm \
+# vmx_lowlevel.asm
+
+VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
+
+
+VMM_C_SRCS := vm_guest.c \
+ svm.c svm_handler.c vmm.c vmm_util.c vmm_ctrl_regs.c \
+ vmcb.c vmm_mem.c vmm_paging.c vmm_io.c vmm_debug.c svm_io.c \
+ vmm_intr.c vmm_time.c \
+ vmm_shadow_paging.c vm_guest_mem.c \
+ vm_dev.c vmm_dev_mgr.c vmm_decoder.c \
+ svm_halt.c svm_pause.c svm_wbinvd.c \
+ vmm_config.c vmm_hashtable.c \
+ vmm_string.c vmm_emulator.c vmm_queue.c\
+ $(DECODER_SRCS)
+# vmx.c vmcs_gen.c vmcs.c
+
+VMM_C_OBJS := $(VMM_C_SRCS:%.c=palacios/%.o)
+
+VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
+
+
+
+
+DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c
+
+DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
+
+DEVICE_OBJS := $(DEVICE_C_OBJS)
+
+V3LIBS := $(DECODER_LIBS)
+
+
+TCPSTACK_C_SRCS := psock.c timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c resolv.c
+
+TCPSTACK_C_OBJS := $(TCPSTACK_C_SRCS:%.c=net/%.o)
+
+TCPSTACK_OBJS := $(TCPSTACK_C_OBJS)
+
+
+
+
+# ----------------------------------------------------------------------
+# Tools -
+# This section defines programs that are used to build GeekOS.
+# ----------------------------------------------------------------------
+
+# Uncomment if cross compiling
+TARGET_CC_PREFIX := $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
+#TARGET_CC_PREFIX := i386-elf-
+
+# Target C compiler. gcc 2.95.2 or later should work.
+TARGET_CC := $(TARGET_CC_PREFIX)gcc
+#TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
+
+# Host C compiler. This is used to compile programs to execute on
+# the host platform, not the target (x86) platform. On x86/ELF
+# systems, such as Linux and FreeBSD, it can generally be the same
+# as the target C compiler.
+HOST_CC := gcc
+
+# Target linker. GNU ld is probably to only one that will work.
+TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
+
+# Target archiver
+TARGET_AR := $(TARGET_CC_PREFIX)ar
+
+# Target ranlib
+TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
+
+# Target nm
+TARGET_NM := $(TARGET_CC_PREFIX)nm
+
+# Target objcopy
+TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
+
+# Nasm (http://nasm.sourceforge.net)
+NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
+#NASM := /opt/vmm-tools/bin/nasm
+
+AS = as --32
+
+# Tool to build PFAT filesystem images.
+BUILDFAT := tools/builtFat.exe
+
+# Perl5 or later
+PERL := perl
+
+# Pad a file so its size is a multiple of some unit (i.e., sector size)
+PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
+
+# Create a file filled with zeroes.
+ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
+
+# Calculate size of file in sectors
+NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
+
+
+FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
+
+
+# ----------------------------------------------------------------------
+# Definitions -
+# Options passed to the tools.
+# ----------------------------------------------------------------------
+
+# Flags used for all C source files
+GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) $(BOOT_FLAGS) -fPIC
+CC_GENERAL_OPTS := $(GENERAL_OPTS) -Werror
+
+# Flags used for kernel C source files
+CC_KERNEL_OPTS := -g -DGEEKOS -I$(PROJECT_ROOT)/include
+
+# Flags used for VMM C source files
+CC_VMM_OPTS := -g -I$(PROJECT_ROOT)/include -D__V3VEE__ -D__V3_32BIT__ $(DECODER_FLAGS) $(JRLDEBUG)
+
+# Flags used for VMM C ASM files
+NASM_VMM_OPTS := -I$(PROJECT_ROOT)/src/palacios/ -f elf $(EXTRA_NASM_OPTS)
+
+# Flags user for kernel assembly files
+NASM_KERNEL_OPTS := -I$(PROJECT_ROOT)/src/geekos/ -f elf $(EXTRA_NASM_OPTS)
+
+# Flags used for common library and libc source files
+CC_USER_OPTS := -I$(PROJECT_ROOT)/include -I$(PROJECT_ROOT)/include/libc \
+ $(EXTRA_CC_USER_OPTS)
+
+# Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
+OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
+
+# ----------------------------------------------------------------------
+# Rules -
+# Describes how to compile the source files.
+# ----------------------------------------------------------------------
+
+# Compilation of kernel C source files
+
+geekos/%.o : geekos/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) $< -o geekos/$*.o
+
+
+# Compilation of kernel assembly source files
+geekos/%.o : geekos/%.asm
+ $(NASM) $(NASM_KERNEL_OPTS) $< -o geekos/$*.o
+
+# Compilation of test VM
+geekos/%.o : geekos/%.s
+ $(AS) $< -o geekos/$*.o
+
+geekos/%.o : geekos/%.S
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) $< -o geekos/$*.o
+
+# Compilation of common library C source files
+common/%.o : common/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o common/$*.o
+
+palacios/%.o : palacios/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o palacios/$*.o
+
+palacios/%.o : palacios/%.asm
+ $(NASM) $(NASM_VMM_OPTS) $< -o palacios/$*.o
+
+devices/%.o : devices/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o devices/$*.o
+
+devices/%.o : devices/%.asm
+ $(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
+
+net/%.o : net/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o net/$*.o
+
+# ----------------------------------------------------------------------
+# Targets -
+# Specifies files to be built
+# ----------------------------------------------------------------------
+
+# Default target - see definition of ALL_TARGETS in Configuration section
+all : $(ALL_TARGETS)
+
+
+#geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
+# $(NASM) -O99 \
+# -f elf \
+# -I$(PROJECT_ROOT)/src/geekos/ \
+# $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
+# -o $@
+
+
+#geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o
+# $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o -o geekos/test
+
+# Standard floppy image - just boots the kernel
+fd.img : geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin
+ cat geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin > _temp
+ $(PAD) _temp 512
+ cp _temp fd.img
+
+vmm.img : fd.img
+ cp fd.img vmm.img
+ $(PAD) vmm.img 1474560
+
+rombios_link:
+ ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
+
+vgabios_link:
+ ln -s -f ../src/vmboot/vgabios/VGABIOS-lgpl-latest.bin vgabios
+
+force_rombios: rombios_link
+ (cd ../src/vmboot/rombios; make clean; make)
+
+force_vgabios: vgabios_link
+ (cd ../src/vmboot/vgabios; make clean; make)
+
+force_payload: force_rombios force_vgabios
+ ../scripts/make_payload.pl payload_layout.txt vm_kernel
+
+inter1: force_payload
+ -make clean
+
+world: inter1 vmm.img
+
+# make ready to boot over PXE
+pxe: vmm.img
+ cp vmm.img /tftpboot/vmm.img
+
+run: vmm.img
+ /usr/local/qemu/bin/qemu-system-x86_64 -m 1024 -serial file:serial.out -cdrom puppy.iso -fda vmm.img
+
+iso: vmm.img
+ cp vmm.img iso/vmm.img
+ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
+
+
+
+# Floppy boot sector (first stage boot loader).
+geekos/fd_boot.bin : geekos/setup.bin geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/fd_boot.asm
+ $(NASM) -f bin \
+ -I$(PROJECT_ROOT)/src/geekos/ \
+ -DNUM_SETUP_SECTORS=`$(NUMSECS) geekos/setup.bin` \
+ -DNUM_KERN_SECTORS=`$(NUMSECS) geekos/kernel.bin` \
+ -DSECTORS_PER_TRACK=`$(FD_SECTORS_PER_TRACK) geekos/kernel.bin geekos/setup.bin` \
+ $(PROJECT_ROOT)/src/geekos/fd_boot.asm \
+ -o $@
+
+# Setup program (second stage boot loader).
+geekos/setup.bin : geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/setup.asm
+ $(NASM) -f bin \
+ -I$(PROJECT_ROOT)/src/geekos/ \
+ -DENTRY_POINT=0x`egrep 'Main$$' geekos/kernel.syms |awk '{print $$1}'` \
+ -DVMM_SIZE=`$(NUMSECS) geekos/kernel.bin` \
+ $(PROJECT_ROOT)/src/geekos/setup.asm \
+ -o $@
+ $(PAD) $@ 2048
+
+# Loadable (flat) kernel image.
+geekos/kernel.bin : geekos/kernel.exe
+ $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary geekos/kernel.exe geekos/kernel.bin
+ $(PAD) $@ 512
+
+# The kernel executable and symbol map.
+geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) $(TCPSTACK_OBJS) vm_kernel
+ $(TARGET_LD) -o geekos/kernel.exe -Ttext $(KERNEL_BASE_ADDR) -e $(KERNEL_ENTRY) \
+ $(DECODER_FLAGS) \
+ $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) $(V3LIBS) $(TCPSTACK_OBJS) -b binary vm_kernel
+ $(TARGET_NM) geekos/kernel.exe > geekos/kernel.syms
+
+
+force:
+
+
+#vm_kernel: force
+# $(PAD) vm_kernel 512
+# @echo "VM kernel lives at 0x100000 and is" `$(NUMSECS) vm_kernel` "sectors long"
+
+
+
+
+# Clean build directories of generated files
+clean :
+ for d in geekos common libc user tools palacios devices net; do \
+ (cd $$d && rm -f *); \
+ done
+
+
+# Build header file dependencies, so source files are recompiled when
+# header files they depend on are modified.
+depend : $(GENERATED_LIBC_SRCS)
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
+ $(KERNEL_C_SRCS:%.c=$(PROJECT_ROOT)/src/geekos/%.c) \
+ | $(PERL) -n -e 's,^(\S),geekos/$$1,;print' \
+ > depend.mak
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_USER_OPTS) \
+ $(COMMON_C_SRCS:%.c=$(PROJECT_ROOT)/src/common/%.c) \
+ | $(PERL) -n -e 's,^(\S),common/$$1,;print' \
+ >> depend.mak
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
+ $(VMM_C_SRCS:%.c=$(PROJECT_ROOT)/src/palacios/%.c) \
+ | $(PERL) -n -e 's,^(\S),palacios/$$1,;print' \
+ >> depend.mak
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
+ $(DEVICE_C_SRCS:%.c=$(PROJECT_ROOT)/src/devices/%.c) \
+ | $(PERL) -n -e 's,^(\S),devices/$$1,;print' \
+ >> depend.mak
+
+# By default, there are no header file dependencies.
+depend.mak :
+ touch $@
+
+include depend.mak
--- /dev/null
+#!/bin/sh
+
+/usr/local/qemu/bin/qemu-system-x86_64 -serial file:serial.out -m 1024 -fda vmm.img -cdrom /opt/vmm-tools/isos/puppy.iso
--- /dev/null
+#!/bin/sh
+
+/usr/local/qemu/bin/qemu-system-x86_64 -serial file:serial.out -m 1024 -fda vmm.img -cdrom /opt/vmm-tools/isos/winxp.iso
--- /dev/null
+# Makefile for GeekOS kernel, userspace, and tools
+#
+# Northwestern University
+# (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+# (c) 2008, Peter Dinda <pdinda@northwestern.edu>
+# (c) 2008, Lei Xia <xiaxlei@gmail.com>
+# (c) 2008, The V3VEE Project <http://www.v3vee.org>
+#
+# Based on GeekOS Makefile:
+# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
+# $Revision: 1.71 $
+
+
+# This is free software. You are permitted to use,
+# redistribute, and modify it as specified in the file "COPYING".
+
+# Required software to build GeekOS:
+# - GNU Make (http://www.gnu.org/software/make)
+# - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
+# - nasm (http://nasm.sourceforge.net)
+# - Perl5, AWK (any version), egrep
+#
+# Cygwin (http://cygwin.com) may be used to build GeekOS.
+# Make sure that gcc, binutils, nasm, and perl are installed.
+
+# NOTES:
+# - This makefile has been written carefully to work correctly
+# with the -j (parallel make) option. I regularly use "make -j 2"
+# to speed the build process on 2 processor systems.
+
+
+# Base address of kernel
+#
+# Note: at top of memory minus three pages (GDT/TSS/IDT)
+# minus maximum size
+#
+#
+# Note that the code will initially load at 0x10000
+#
+# The setup code needs to copy it up to this address and jump there
+#
+KERNEL_BASE_ADDR := 0x00100000
+
+# Kernel entry point function
+KERNEL_ENTRY = $(SYM_PFX)Main
+
+
+PROJECT_ROOT := ..
+V3_ROOT := $(PROJECT_ROOT)/../palacios
+VPATH := $(PROJECT_ROOT)/src
+
+
+
+#
+#TCPSTACK, uIP is used currently
+#
+TCPSTACK=UIP
+
+
+
+
+#
+# This is wrong for current cygwin - no changes needed
+#
+# Figure out if we're compiling with cygwin, http://cygwin.com
+#
+#
+#SYSTEM_NAME := $(shell uname -s)
+#ifeq ($(findstring CYGWIN,$(SYSTEM_NAME)),CYGWIN)
+#SYM_PFX := _
+#EXTRA_C_OPTS := -DNEED_UNDERSCORE -DGNU_WIN32
+#EXTRA_NASM_OPTS := -DNEED_UNDERSCORE
+#NON_ELF_SYSTEM := yes
+#EXTRA_CC_USER_OPTS := -Dmain=geekos_main
+#endif
+
+
+
+
+# ----------------------------------------------------------------------
+# Configuration -
+# Various options specifying how GeekOS should be built,
+# what source files to build, which user programs to build,
+# etc. This is generally the only section of the makefile
+# that will need to be modified.
+# ----------------------------------------------------------------------
+
+# List of targets to build by default.
+# These targets encompass everything needed to boot
+# and run GeekOS.
+ALL_TARGETS := vmm.img
+
+
+# Kernel source files
+KERNEL_C_SRCS := idt.c int.c trap.c irq.c io.c \
+ blockdev.c ide.c ne2k.c \
+ keyboard.c screen.c timer.c \
+ mem.c crc32.c \
+ gdt.c tss.c segment.c \
+ bget.c malloc.c \
+ synch.c kthread.c \
+ serial.c reboot.c \
+ paging.c \
+ debug.c vmm_stubs.c vm.c pci.c\
+ queue.c socket.c net.c ring_buffer.c \
+ main.c
+
+
+# Kernel object files built from C source files
+KERNEL_C_OBJS := $(KERNEL_C_SRCS:%.c=geekos/%.o)
+
+# Kernel assembly files
+KERNEL_ASM_SRCS := lowlevel.asm
+
+KERNEL_GAS_SRCS :=
+
+# Kernel object files build from assembler source files
+KERNEL_ASM_OBJS := $(KERNEL_ASM_SRCS:%.asm=geekos/%.o)
+
+KERNEL_GAS_OBJS := $(KERNEL_GAS_SRCS:%.s=geekos/%.o)
+
+
+# All kernel object files
+KERNEL_OBJS := $(KERNEL_C_OBJS) \
+ $(KERNEL_ASM_OBJS) $(KERNEL_GAS_OBJS)
+
+# Common library source files.
+# This library is linked into both the kernel and user programs.
+# It provides string functions and generic printf()-style
+# formatted output.
+COMMON_C_SRCS := fmtout.c string.c memmove.c
+
+# Common library object files.
+COMMON_C_OBJS := $(COMMON_C_SRCS:%.c=common/%.o)
+
+
+
+
+V3_LD_FLAGS := -L./palacios/
+#V3_LIBS := -lxed -lv3vee
+V3_LIBS := ./palacios/libxed.a ./palacios/libv3vee.a ./palacios/libxed.a ./palacios/libv3vee.a
+
+
+
+TCPSTACK_C_SRCS := psock.c timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c resolv.c
+
+TCPSTACK_C_OBJS := $(TCPSTACK_C_SRCS:%.c=net/%.o)
+
+TCPSTACK_OBJS := $(TCPSTACK_C_OBJS)
+
+
+
+
+# ----------------------------------------------------------------------
+# Tools -
+# This section defines programs that are used to build GeekOS.
+# ----------------------------------------------------------------------
+
+# Uncomment if cross compiling
+TARGET_CC_PREFIX := $(PROJECT_ROOT)/../devtools/i386/bin/i386-elf-
+#TARGET_CC_PREFIX := i386-elf-
+
+# Target C compiler. gcc 2.95.2 or later should work.
+TARGET_CC := $(TARGET_CC_PREFIX)gcc
+#TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
+
+# Host C compiler. This is used to compile programs to execute on
+# the host platform, not the target (x86) platform. On x86/ELF
+# systems, such as Linux and FreeBSD, it can generally be the same
+# as the target C compiler.
+HOST_CC := gcc
+
+# Target linker. GNU ld is probably to only one that will work.
+TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
+
+# Target archiver
+TARGET_AR := $(TARGET_CC_PREFIX)ar
+
+# Target ranlib
+TARGET_RANLIB := $(TARGET_CC_PREFIX)ranlib
+
+# Target nm
+TARGET_NM := $(TARGET_CC_PREFIX)nm
+
+# Target objcopy
+TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
+
+# Nasm (http://nasm.sourceforge.net)
+NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
+#NASM := /opt/vmm-tools/bin/nasm
+
+AS = as --32
+
+# Tool to build PFAT filesystem images.
+BUILDFAT := tools/builtFat.exe
+
+# Perl5 or later
+PERL := perl
+
+# Pad a file so its size is a multiple of some unit (i.e., sector size)
+PAD := $(PERL) $(PROJECT_ROOT)/scripts/pad
+
+# Create a file filled with zeroes.
+ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
+
+# Calculate size of file in sectors
+NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
+
+
+FD_SECTORS_PER_TRACK := $(PERL) $(PROJECT_ROOT)/scripts/numsecs_per_track
+
+
+# ----------------------------------------------------------------------
+# Definitions -
+# Options passed to the tools.
+# ----------------------------------------------------------------------
+
+# Flags used for all C source files
+GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(BOOT_FLAGS) -fPIC
+CC_GENERAL_OPTS := $(GENERAL_OPTS) -Werror
+
+# Flags used for kernel C source files
+CC_KERNEL_OPTS := -g -DGEEKOS -I$(PROJECT_ROOT)/include -I$(V3_ROOT)/include
+
+
+# Flags user for kernel assembly files
+NASM_KERNEL_OPTS := -I$(PROJECT_ROOT)/src/geekos/ -f elf $(EXTRA_NASM_OPTS)
+
+# Flags used for common library and libc source files
+CC_USER_OPTS := -I$(PROJECT_ROOT)/include -I$(PROJECT_ROOT)/include/libc \
+ $(EXTRA_CC_USER_OPTS) -I$(V3_ROOT)/include
+
+# Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
+OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
+
+# ----------------------------------------------------------------------
+# Rules -
+# Describes how to compile the source files.
+# ----------------------------------------------------------------------
+
+# Compilation of kernel C source files
+
+geekos/%.o : geekos/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) $< -o geekos/$*.o
+
+
+# Compilation of kernel assembly source files
+geekos/%.o : geekos/%.asm
+ $(NASM) $(NASM_KERNEL_OPTS) $< -o geekos/$*.o
+
+
+# Compilation of common library C source files
+common/%.o : common/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o common/$*.o
+
+
+net/%.o : net/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o net/$*.o
+
+# ----------------------------------------------------------------------
+# Targets -
+# Specifies files to be built
+# ----------------------------------------------------------------------
+
+# Default target - see definition of ALL_TARGETS in Configuration section
+all : $(ALL_TARGETS)
+
+
+#geekos/vmx_lowlevel.o: $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm
+# $(NASM) -O99 \
+# -f elf \
+# -I$(PROJECT_ROOT)/src/geekos/ \
+# $(PROJECT_ROOT)/src/geekos/vmx_lowlevel.asm \
+# -o $@
+
+
+#geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o
+# $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o -o geekos/test
+
+# Standard floppy image - just boots the kernel
+fd.img : geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin
+ cat geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin > _temp
+ $(PAD) _temp 512
+ cp _temp fd.img
+
+
+vmm.img: fd.img
+ cp fd.img vmm.img
+ $(PAD) vmm.img 1474560
+
+
+
+
+
+
+# Floppy boot sector (first stage boot loader).
+geekos/fd_boot.bin : geekos/setup.bin geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/fd_boot.asm
+ $(NASM) -f bin \
+ -I$(PROJECT_ROOT)/src/geekos/ \
+ -DNUM_SETUP_SECTORS=`$(NUMSECS) geekos/setup.bin` \
+ -DNUM_KERN_SECTORS=`$(NUMSECS) geekos/kernel.bin` \
+ -DSECTORS_PER_TRACK=`$(FD_SECTORS_PER_TRACK) geekos/kernel.bin geekos/setup.bin` \
+ $(PROJECT_ROOT)/src/geekos/fd_boot.asm \
+ -o $@
+
+# Setup program (second stage boot loader).
+geekos/setup.bin : geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/setup.asm
+ $(NASM) -f bin \
+ -I$(PROJECT_ROOT)/src/geekos/ \
+ -DENTRY_POINT=0x`egrep 'Main$$' geekos/kernel.syms |awk '{print $$1}'` \
+ -DVMM_SIZE=`$(NUMSECS) geekos/kernel.bin` \
+ $(PROJECT_ROOT)/src/geekos/setup.asm \
+ -o $@
+ $(PAD) $@ 2048
+
+# Loadable (flat) kernel image.
+geekos/kernel.bin : geekos/kernel.exe
+ $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary geekos/kernel.exe geekos/kernel.bin
+ $(PAD) $@ 512
+
+# The kernel executable and symbol map.
+geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(TCPSTACK_OBJS)
+ $(TARGET_LD) -o geekos/kernel.exe -Ttext $(KERNEL_BASE_ADDR) -e $(KERNEL_ENTRY) \
+ $(V3_LD_FLAGS) \
+ $(KERNEL_OBJS) $(COMMON_C_OBJS) $(TCPSTACK_OBJS) $(V3_LIBS) -b binary ./palacios/vm_kernel
+ $(TARGET_NM) geekos/kernel.exe > geekos/kernel.syms
+
+
+force:
+
+
+#vm_kernel: force
+# $(PAD) vm_kernel 512
+# @echo "VM kernel lives at 0x100000 and is" `$(NUMSECS) vm_kernel` "sectors long"
+
+
+
+
+# Clean build directories of generated files
+clean :
+ for d in geekos common libc user tools net; do \
+ (cd $$d && rm -f *); \
+ done
+
+
+# Build header file dependencies, so source files are recompiled when
+# header files they depend on are modified.
+depend : $(GENERATED_LIBC_SRCS)
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
+ $(KERNEL_C_SRCS:%.c=$(PROJECT_ROOT)/src/geekos/%.c) \
+ | $(PERL) -n -e 's,^(\S),geekos/$$1,;print' \
+ > depend.mak
+ $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_USER_OPTS) \
+ $(COMMON_C_SRCS:%.c=$(PROJECT_ROOT)/src/common/%.c) \
+ | $(PERL) -n -e 's,^(\S),common/$$1,;print' \
+ >> depend.mak
+
+
+# By default, there are no header file dependencies.
+depend.mak :
+ touch $@
+
+include depend.mak
--- /dev/null
+#! /usr/bin/perl
+
+# Find the function name from the value of the EIP (instruction pointer)
+# register from a Bochs crash report. Uses the kernel symbol
+# map (kernel.syms) produced by compiling the kernel.
+
+use strict qw(refs vars);
+use FileHandle;
+
+if (scalar(@ARGV) != 2){
+ print STDERR "Usage: eipToFunction kernel.syms <eip value>\n";
+ print STDERR " eip value should be in hex\n";
+ exit 1;
+}
+
+my $syms = shift @ARGV;
+my $eip = hex(shift @ARGV);
+
+my @text = ();
+
+my $fh = new FileHandle("<$syms");
+(defined $fh) || die "Couldn't open $syms: $!\n";
+while (<$fh>) {
+ #print $_;
+ if (/^([0-9A-Fa-f]+)\s+[Tt]\s+(\S+)\s*$/) {
+ push @text, [hex($1), $2];
+ }
+}
+$fh->close();
+#print scalar(@text),"\n";
+
+@text = sort { $a->[0] <=> $b->[0] } @text;
+
+my $last = undef;
+
+foreach my $entry (@text) {
+ last if ($eip < $entry->[0]);
+ $last = $entry;
+}
+printf("%s\n",(defined $last) ? $last->[1] : "not found");
+
+# vim:ts=4
--- /dev/null
+#! /usr/bin/perl
+
+# Find the address of a symbol in the storage map.
+
+use strict qw(refs vars);
+use FileHandle;
+
+if ( scalar(@ARGV) != 2 ) {
+ print "Usage: findaddr <storage map> <symbol name>\n";
+ exit 1;
+}
+
+my $storage = shift @ARGV;
+my $symbol = shift @ARGV;
+
+my $fh = new FileHandle("<$storage");
+(defined $fh) || die "Couldn't open storage map: $!\n";
+
+while ( <$fh> ) {
+ if ( /^\s*(0x([0-9]|[a-f]|[A-F])+)\s+\Q$symbol\E\s*$/ ) {
+ print $1, "\n";
+ last;
+ }
+}
+
+$fh->close();
--- /dev/null
+#!/usr/bin/perl
+
+$#ARGV==0 or die "gimme a filename\n";
+
+$file=shift;
+
+@list=();
+
+open(HEADER,">$file.h");
+open(SOURCE,">$file.c");
+
+print HEADER "#ifndef $file\n";
+print HEADER "#define $file\n";
+print HEADER "#include <geekos/vmcs.h>\n";
+
+print SOURCE "#include <geekos/$file.h>\n";
+
+while (<STDIN>) {
+ if (/\#define\s+(\S+)\s+/) {
+ push @list, $1;
+ GenSerUnserCode($1);
+ }
+}
+
+GenPrintAllCode(@list);
+
+print HEADER "#endif\n";
+
+sub GenSerUnserCode {
+ my $name=shift;
+
+ print SOURCE <<END
+
+void Set_$name(uint_t val) { VMCS_WRITE($name,val); }
+uint_t Get_$name() { uint_t rc; VMCS_READ($name,&rc); return rc; }
+
+void Print_$name() { PrintTrace("$name = %x\\n", Get_$name()); }
+
+END
+
+;
+ print HEADER <<END2
+
+void Set_$name(uint_t val);
+uint_t Get_$name();
+
+void Print_$name();
+
+END2
+
+;
+
+}
+
+
+sub GenPrintAllCode {
+ print SOURCE "void PrintTrace_VMCS_ALL() {\n";
+ while (my $name=shift) {
+ print SOURCE " PrintTrace_$name();\n";
+ }
+ print SOURCE "}\n";
+ print HEADER "void PrintTrace_VMCS_ALL();\n";
+}
--- /dev/null
+#! /usr/bin/perl
+
+# Script to process include/geekos/errno.h to produce a table
+# of error description strings that can be compiled and
+# linked into libc.
+
+use strict qw(refs vars);
+
+my @errs = ();
+my @syms = ();
+
+$errs[0] = 'No error';
+
+while (<>) {
+ if (m,^#define\s*(\S+)\s*(-\d+)\s*/\*\s*(.*\S)\s*\*/\s*$,) {
+ $errs[- $2] = $3;
+ $syms[- $2] = $1;
+ }
+}
+
+print "const char *__strerrTable[] = {\n";
+for (my $i = 0; $i < scalar(@errs); $i++) {
+ print " \"", $errs[$i], "\", /* ", $syms[$i], " */\n";
+}
+print "};\n";
+print "const int __strerrTableSize = sizeof(__strerrTable) / sizeof(const char *);\n";
+
+# vim:ts=4
--- /dev/null
+#!/usr/bin/perl
+
+$file = $ARGV[0];
+
+while(1) {
+ open (FILE,">>$file");
+ $foo = <STDIN>;
+ chomp $foo;
+ print FILE pack("C", hex("0x$foo"));
+ close FILE;
+}
+
--- /dev/null
+#! /usr/bin/perl
+
+# A script to analyze the output of "objdump -h" on the
+# kernel executable file.
+
+use strict qw(vars refs);
+use FileHandle;
+
+my $kernfile = shift @ARGV;
+(defined $kernfile) || die "usage: kernsize <kernfile>\n";
+
+my $kern_fh = new FileHandle("<$kernfile");
+(defined $kern_fh) || die "can't open $kernfile: $!\n";
+
+my $objdump_fh = new FileHandle("objdump -h $kernfile|");
+while ( <$objdump_fh> ) {
+ chop;
+ s/^\s+//;
+ my @fields = split(/\s+/, $_);
+ if ( $fields[0] =~ /^[0-9]$/ ) {
+# print "text start is ", $fields[5], "\n" if $fields[0] eq '0';
+ my $size = hex($fields[2]);
+ my $offset = hex($fields[5]);
+
+ print $fields[0], " (", $fields[1], "): size=$size, offset=$offset\n";
+
+ printf("Word at beginning of section is %08x\n", ReadWord($kern_fh,$offset) );
+ }
+}
+$objdump_fh->close();
+
+sub ReadWord {
+ my ($fh, $offset) = @_;
+ seek $fh, $offset, SEEK_SET;
+ my $buf = 'X' x 4;
+ read $fh, $buf, 4;
+ return unpack('V',$buf);
+}
--- /dev/null
+#!/usr/bin/perl
+
+$magic = 0xf1e2d3c4;
+
+use FileHandle;
+
+if (scalar(@ARGV) != 2) {
+ print STDERR "usage: make_payload.pl <cfg-file> <out-file>\n";
+ exit 1;
+}
+
+my $config_file = shift @ARGV;
+my $out_file = shift @ARGV;
+
+open (CFGFILE, "$config_file");
+@cfg = <CFGFILE>;
+close CFGFILE;
+
+my $num_regions = 0;
+
+my @region_names = ();
+my %region_map = {};
+
+foreach $line (@cfg) {
+ chomp $line;
+ ($file, $dst) = split(/:/, $line);
+ push @region_names, $file;
+ $region_map{$file} = hex($dst); #unpack('N', pack("h8",$dst));
+ print "" . hex($dst) . "\n";
+ $num_regions++;
+}
+
+
+
+my $fh = new FileHandle(">$out_file");
+binmode $fh;
+
+syswrite $fh, pack('L', $magic), 4;
+syswrite $fh, pack('L', $num_regions), 4;
+
+foreach $file (@region_names) {
+ my $size = (-s $file);
+
+ print "$file to " . $region_map{$file}. " ($size bytes)\n";
+ syswrite $fh, pack('L', $size), 4;
+ syswrite $fh, pack('L', $region_map{$file}), 4;
+}
+
+
+my $file;
+while (($file = shift @region_names)) {
+ my $in_fh = new FileHandle("<$file");
+ (defined $in_fh) || die "Couldn't open $file: $!\n";
+ binmode $in_fh;
+
+ my $buf = chr(0) x 1024;
+ my $n;
+ while (($n = sysread($in_fh, $buf, 1024)) > 0) {
+ syswrite($fh, $buf, $n);
+ }
+ $in_fh->close();
+}
+
+
+$fh->close();
--- /dev/null
+#! /usr/bin/perl
+
+# Build a binary image containing a pseudo fat filesystem with the listed files
+
+# $Revision: 1.1 $
+use FileHandle;
+
+if ( scalar(@ARGV) < 2 ) {
+ print STDERR "usage: mkuprog <diskImage> <filenames>\n";
+ exit 1;
+}
+
+
+$filename = shift @ARGV;
+$filecount = scalar ( @ARGV );
+
+$fh = new FileHandle(">$filename");
+
+write
+
+while (scalar(@ARGV)) {
+ $filename = shift @ARGV;
+
+ print "got file ", $filename, "\n";
+}
--- /dev/null
+#! /usr/bin/perl
+
+# From a binary image containing a user program, generate
+# C code initializing a User_Program struct.
+
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+use FileHandle;
+
+if ( scalar(@ARGV) != 3 ) {
+ print STDERR "usage: mkuprog <filename> <progname> <entry addr>\n";
+ exit 1;
+}
+
+my $filename = shift @ARGV;
+my $progname = shift @ARGV;
+my $entryAddr = shift @ARGV;
+
+my $fh = new FileHandle("<$filename");
+(defined $fh) || die "Couldn't open $filename: $!\n";
+binmode $fh;
+
+my $dataArrayName = $progname . "Data";
+my $structName = $progname . "Prog";
+print "const unsigned char $dataArrayName"."[] = {\n";
+
+my $LINEWIDTH = 10;
+
+my $buf = chr(0) x $LINEWIDTH;
+my $n;
+my $size = 0;
+while ( ($n = read( $fh, $buf, $LINEWIDTH )) > 0 ) {
+ $size += $n;
+ my $i;
+ print " ";
+ for ( $i = 0; $i < $n; $i++ ) {
+ my $c = ord( substr($buf, $i, 1) );
+ printf( "0x%x,", $c );
+ }
+ print "\n";
+}
+
+print "};\n";
+
+$fh->close();
+
+print << "END";
+const struct User_Program $structName = {
+ "$progname",
+ $size,
+ $entryAddr,
+ $dataArrayName
+};
+END
--- /dev/null
+#! /usr/bin/perl
+
+# Find the number of 512-byte sectors needed to store
+# given file.
+
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+
+if ( scalar(@ARGV) != 1 ) {
+ print STDERR "Usage: numsecs <filename>\n";
+ exit 1;
+}
+
+my $filename = shift @ARGV;
+my $size = (-s $filename );
+die "Couldn't get size of $filename: $!" if ( !defined $size );
+
+my $result = int($size / 512);
+my $remainder = $size % 512;
+$result++ if ( $remainder > 0 );
+
+print "$result\n";
--- /dev/null
+#! /usr/bin/perl
+
+# Find the number of 512-byte sectors needed to store
+# given file.
+
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+
+my $sectors = 0;
+my $filename = "";
+
+foreach $filename (@ARGV) {
+
+ my $size = (-s $filename );
+ die "Couldn't get size of $filename: $!" if ( !defined $size );
+
+ my $result = int($size / 512);
+ my $remainder = $size % 512;
+ $result++ if ( $remainder > 0 );
+
+ $sectors += $result;
+}
+
+if ($sectors <= 2879) {
+ print "18\n";
+} else {
+ print "36\n";
+}
+
--- /dev/null
+#! /usr/bin/perl
+
+# Pad a file with zero bytes to make its length
+# an even multiple of some value.
+
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+use FileHandle;
+
+if ( scalar(@ARGV) != 2 ) {
+ print STDERR "usage: pad <filename> <multiple>\n";
+ exit 1;
+}
+
+my $filename = shift @ARGV;
+my $multiple = shift @ARGV;
+
+my $size = (-s $filename);
+die "Couldn't get size of $filename: $!" if ( !defined $size );
+
+my $num_pad = ($multiple - ($size % $multiple)) % $multiple;
+
+my $buf = chr(0) x $num_pad;
+
+my $fh = new FileHandle(">>$filename");
+die "Couldn't open $filename: $!" if ( !defined $fh );
+binmode $fh;
+syswrite $fh, $buf, $num_pad, 0;
+$fh->close();
--- /dev/null
+#! /usr/bin/perl
+
+# A version of cat written in perl.
+
+use strict qw(refs vars);
+use FileHandle;
+
+binmode STDOUT;
+
+my $buf = chr(0) x 1024;
+
+my $file;
+while ( ($file = shift @ARGV) ) {
+ my $fh = new FileHandle("<$file");
+ (defined $fh) || die "Couldn't open $file: $!\n";
+ binmode $fh;
+
+ my $n;
+ while ( ($n = sysread($fh, $buf, 1024)) > 0 ) {
+ syswrite( STDOUT, $buf, $n );
+ }
+ $fh->close();
+}
--- /dev/null
+#! /usr/bin/perl
+
+# Inspect a 32 word at a specified offset in a file.
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+use FileHandle;
+
+my $filename = shift @ARGV;
+my $offset = shift @ARGV;
+
+((defined $filename) && (defined $offset))
+ || die "Usage: pw <filename> <offset>\n";
+
+my $fh = new FileHandle("<$filename");
+printf( "%08x\n", ReadWord($fh, $offset) );
+
+sub ReadWord {
+ my ($fh, $offset) = @_;
+ seek $fh, $offset, SEEK_SET;
+ my $buf = 'X' x 4;
+ read $fh, $buf, 4;
+ return unpack('V',$buf);
+}
--- /dev/null
+#! /usr/bin/perl
+
+# Scan a file for a 32-bit word with a particular value.
+# $Revision: 1.1 $
+
+use strict qw(refs vars);
+use FileHandle;
+
+my $filename = shift @ARGV;
+my $word_value = shift @ARGV;
+
+((defined $filename) && (defined $word_value))
+ || die "Usage: scan <filename> <word value in hex>\n";
+
+my $fh = new FileHandle("<$filename");
+my $val = hex($word_value);
+
+my $buf = ' ' x 4;
+
+my $offset = 0;
+while ( read( $fh, $buf, 4) == 4 ) {
+ my $out = unpack "V", $buf;
+ if ( $out == $val ) {
+ print "Found value $word_value at offset $offset\n";
+ exit;
+ }
+ $offset += 4;
+}
+print "Didn't find value $word_value\n";
--- /dev/null
+#!/usr/bin/perl
+
+
+$file = $ARGV[0];
+$ofile = $ARGV[1];
+
+open(INFILE, "$file");
+@lines = <INFILE>;
+close INFILE;
+
+open(OUTFILE, ">$ofile");
+
+
+print OUTFILE "\%ifndef VMCS_FIELDS_ASM\n\%define VMCS_FIELDS_ASM\n\n";
+
+foreach $line (@lines) {
+
+ if ($line =~ /\#define\s+(\S+)\s+(\S+)*/) {
+ print OUTFILE $1 . " equ " . $2 . "\n";
+ }
+
+}
+
+
+print OUTFILE "\n\%endif\n\n";
+
+close OUTFILE;
+
+
--- /dev/null
+#! /usr/bin/perl
+
+# This script is used for creating a file full of zeroes,
+# which we use to create the hard disk image used by bochs.
+
+use strict qw(refs vars);
+use FileHandle;
+use IO::Seekable;
+
+if ( scalar(@ARGV) != 2 ) {
+ print "Usage: zerofile <output file> <num sectors>\n";
+ exit 1;
+}
+
+my $outfile = shift @ARGV;
+my $numsecs = shift @ARGV;
+
+my $buf = chr(0) x 1;
+
+my $fh = new FileHandle(">$outfile");
+(defined $fh) || die "Couldn't open $outfile: $!\n";
+binmode $fh;
+
+if ( !sysseek( $fh, ($numsecs * 512) - 1, SEEK_SET ) ) {
+ die "Couldn't seek in $outfile: $!\n";
+}
+if ( !syswrite( $fh, $buf, 1 ) ) {
+ die "Couldn't write to $outfile: $!\n";
+}
+
+$fh->close();
EXPORT Flush_TLB
; CPUID functions
-EXPORT cpuid_ecx
-EXPORT cpuid_eax
-EXPORT cpuid_edx
+;EXPORT cpuid_ecx
+;EXPORT cpuid_eax
+;EXPORT cpuid_edx
; Utility Functions
-EXPORT Set_MSR
-EXPORT Get_MSR
+;EXPORT Set_MSR
+;EXPORT Get_MSR
EXPORT Get_CR2
Init_V3(&os_hooks, &vmm_ops);
- extern char _binary_vm_kernel_start;
- PrintBoth(" Guest Load Addr: 0x%x\n", &_binary_vm_kernel_start);
-
- config_data = &_binary_vm_kernel_start;
+ extern char _binary___palacios_vm_kernel_start;
+ PrintBoth(" Guest Load Addr: 0x%x\n", &_binary___palacios_vm_kernel_start);
+
+ config_data = &_binary___palacios_vm_kernel_start;
+
vm_info = (vmm_ops).allocate_guest();
PrintBoth("Allocated Guest\n");
(vmm_ops).config_guest(vm_info, config_data);
PrintBoth("Configured guest\n");
-
+
//v3_hook_io_port(&vm_info, 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
#
# The setup code needs to copy it up to this address and jump there
#
-KERNEL_BASE_ADDR := 0x00100000
-# Kernel entry point function
-KERNEL_ENTRY = $(SYM_PFX)Main
+
PROJECT_ROOT := ..
ifeq ($(DECODER),XED)
DECODER_SRCS := vmm_xed.c
DECODER_FLAGS := -L../lib/xed
-DECODER_LIBS := -lxed
+DECODER_LIBS := $(PROJECT_ROOT)/lib/xed/libxed.a
else
# This is an error
endif
-#
-#TCPSTACK, uIP is used currently
-#
-TCPSTACK=UIP
+
# List of targets to build by default.
# These targets encompass everything needed to boot
# and run GeekOS.
-ALL_TARGETS := vmm.img vm_kernel
-
-
-# Kernel source files
-KERNEL_C_SRCS := idt.c int.c trap.c irq.c io.c \
- blockdev.c ide.c ne2k.c \
- keyboard.c screen.c timer.c \
- mem.c crc32.c \
- gdt.c tss.c segment.c \
- bget.c malloc.c \
- synch.c kthread.c \
- serial.c reboot.c \
- paging.c \
- debug.c vmm_stubs.c vm.c pci.c\
- queue.c socket.c net.c ring_buffer.c \
- main.c
-
-
-# Kernel object files built from C source files
-KERNEL_C_OBJS := $(KERNEL_C_SRCS:%.c=geekos/%.o)
-
-# Kernel assembly files
-KERNEL_ASM_SRCS := lowlevel.asm
-
-KERNEL_GAS_SRCS := testvm.s udivdi3.s
+ALL_TARGETS := vmm vm_kernel
-# Kernel object files build from assembler source files
-KERNEL_ASM_OBJS := $(KERNEL_ASM_SRCS:%.asm=geekos/%.o)
-KERNEL_GAS_OBJS := $(KERNEL_GAS_SRCS:%.s=geekos/%.o)
-# All kernel object files
-KERNEL_OBJS := $(KERNEL_C_OBJS) \
- $(KERNEL_ASM_OBJS) $(KERNEL_GAS_OBJS)
-# Common library source files.
-# This library is linked into both the kernel and user programs.
-# It provides string functions and generic printf()-style
-# formatted output.
-COMMON_C_SRCS := fmtout.c string.c memmove.c
-# Common library object files.
-COMMON_C_OBJS := $(COMMON_C_SRCS:%.c=common/%.o)
-
-VMM_ASM_SRCS := svm_lowlevel.asm \
+VMM_ASM_SRCS := svm_lowlevel.asm vmm_lowlevel.asm\
# vmx_lowlevel.asm
VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
+XED_C_SRCS := v3-xed-compat.c
-DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c
+XED_C_OBJS := $(XED_C_SRCS:%.c=xed/%.o)
-DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
+XED_GAS_SRCS := v3-udiv-compat.s
-DEVICE_OBJS := $(DEVICE_C_OBJS)
+XED_GAS_OBJS := $(XED_GAS_SRCS:%.s=xed/%.o)
-V3LIBS := $(DECODER_LIBS)
+XED_OBJS := $(XED_C_OBJS) $(XED_GAS_OBJS)
-TCPSTACK_C_SRCS := psock.c timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c resolv.c
+DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c
-TCPSTACK_C_OBJS := $(TCPSTACK_C_SRCS:%.c=net/%.o)
+DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
-TCPSTACK_OBJS := $(TCPSTACK_C_OBJS)
+DEVICE_OBJS := $(DEVICE_C_OBJS)
+
+V3LIBS := $(DECODER_LIBS)
TARGET_CC := $(TARGET_CC_PREFIX)gcc
#TARGET_CC := $(TARGET_CC_PREFIX)gcc34 -m32
-# Host C compiler. This is used to compile programs to execute on
-# the host platform, not the target (x86) platform. On x86/ELF
-# systems, such as Linux and FreeBSD, it can generally be the same
-# as the target C compiler.
-HOST_CC := gcc
# Target linker. GNU ld is probably to only one that will work.
TARGET_LD := $(TARGET_CC_PREFIX)ld -melf_i386
# ----------------------------------------------------------------------
# Flags used for all C source files
-GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) $(BOOT_FLAGS) -fPIC
+GENERAL_OPTS := -O -Wall $(EXTRA_C_OPTS) $(VMM_FLAGS) -fPIC #-fvisibility=hidden
CC_GENERAL_OPTS := $(GENERAL_OPTS) -Werror
-# Flags used for kernel C source files
-CC_KERNEL_OPTS := -g -DGEEKOS -I$(PROJECT_ROOT)/include
-
# Flags used for VMM C source files
CC_VMM_OPTS := -g -I$(PROJECT_ROOT)/include -D__V3VEE__ -D__V3_32BIT__ $(DECODER_FLAGS) $(JRLDEBUG)
# Flags used for VMM C ASM files
NASM_VMM_OPTS := -I$(PROJECT_ROOT)/src/palacios/ -f elf $(EXTRA_NASM_OPTS)
-# Flags user for kernel assembly files
-NASM_KERNEL_OPTS := -I$(PROJECT_ROOT)/src/geekos/ -f elf $(EXTRA_NASM_OPTS)
-# Flags used for common library and libc source files
-CC_USER_OPTS := -I$(PROJECT_ROOT)/include -I$(PROJECT_ROOT)/include/libc \
- $(EXTRA_CC_USER_OPTS)
+
+
# Flags passed to objcopy program (strip unnecessary sections from kernel.exe)
OBJCOPY_FLAGS := -R .dynamic -R .note -R .comment
# Describes how to compile the source files.
# ----------------------------------------------------------------------
-# Compilation of kernel C source files
-
-geekos/%.o : geekos/%.c
- $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) $< -o geekos/$*.o
-
-# Compilation of kernel assembly source files
-geekos/%.o : geekos/%.asm
- $(NASM) $(NASM_KERNEL_OPTS) $< -o geekos/$*.o
-# Compilation of test VM
-geekos/%.o : geekos/%.s
- $(AS) $< -o geekos/$*.o
-
-geekos/%.o : geekos/%.S
- $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) $< -o geekos/$*.o
-
-# Compilation of common library C source files
-common/%.o : common/%.c
- $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o common/$*.o
palacios/%.o : palacios/%.c
$(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o palacios/$*.o
devices/%.o : devices/%.asm
$(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
-net/%.o : net/%.c
- $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_USER_OPTS) $< -o net/$*.o
+
+xed/%.o : xed/%.c
+ $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o xed/$*.o
+
+xed/%.o : xed/%.s
+ $(AS) $< -o xed/$*.o
+
# ----------------------------------------------------------------------
# Targets -
#geekos/test: geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o
# $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o -o geekos/test
-# Standard floppy image - just boots the kernel
-fd.img : geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin
- cat geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin > _temp
- $(PAD) _temp 512
- cp _temp fd.img
-vmm.img : fd.img
- cp fd.img vmm.img
- $(PAD) vmm.img 1474560
rombios_link:
ln -s -f ../src/vmboot/rombios/BIOS-bochs-latest rombios
inter1: force_payload
-make clean
-world: inter1 vmm.img
+world: inter1 vmm
-# make ready to boot over PXE
-pxe: vmm.img
- cp vmm.img /tftpboot/vmm.img
+vmm: palacios/vmm.lib
-run: vmm.img
- /usr/local/qemu/bin/qemu-system-x86_64 -m 1024 -serial file:serial.out -cdrom puppy.iso -fda vmm.img
-iso: vmm.img
- cp vmm.img iso/vmm.img
- mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
-
-# Floppy boot sector (first stage boot loader).
-geekos/fd_boot.bin : geekos/setup.bin geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/fd_boot.asm
- $(NASM) -f bin \
- -I$(PROJECT_ROOT)/src/geekos/ \
- -DNUM_SETUP_SECTORS=`$(NUMSECS) geekos/setup.bin` \
- -DNUM_KERN_SECTORS=`$(NUMSECS) geekos/kernel.bin` \
- -DSECTORS_PER_TRACK=`$(FD_SECTORS_PER_TRACK) geekos/kernel.bin geekos/setup.bin` \
- $(PROJECT_ROOT)/src/geekos/fd_boot.asm \
- -o $@
-
-# Setup program (second stage boot loader).
-geekos/setup.bin : geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/setup.asm
- $(NASM) -f bin \
- -I$(PROJECT_ROOT)/src/geekos/ \
- -DENTRY_POINT=0x`egrep 'Main$$' geekos/kernel.syms |awk '{print $$1}'` \
- -DVMM_SIZE=`$(NUMSECS) geekos/kernel.bin` \
- $(PROJECT_ROOT)/src/geekos/setup.asm \
- -o $@
- $(PAD) $@ 2048
-
# Loadable (flat) kernel image.
-geekos/kernel.bin : geekos/kernel.exe
- $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary geekos/kernel.exe geekos/kernel.bin
- $(PAD) $@ 512
+palacios/vmm.bin : palacios/vmm.lib
+ $(TARGET_OBJCOPY) $(OBJCOPY_FLAGS) -S -O binary palacios/vmm.lib palacios/vmm.bin
+
# The kernel executable and symbol map.
-geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) $(TCPSTACK_OBJS) vm_kernel
- $(TARGET_LD) -o geekos/kernel.exe -Ttext $(KERNEL_BASE_ADDR) -e $(KERNEL_ENTRY) \
- $(DECODER_FLAGS) \
- $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) $(V3LIBS) $(TCPSTACK_OBJS) -b binary vm_kernel
- $(TARGET_NM) geekos/kernel.exe > geekos/kernel.syms
+palacios/vmm.lib: $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) vm_kernel
+# $(TARGET_LD) -o palacios/vmm.lib \
+# $(DECODER_FLAGS) \
+# $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS) $(V3LIBS) -b binary vm_kernel
+# $(TARGET_NM) palacios/vmm.lib > palacios/vmm.syms
+ $(TARGET_AR) rcs libv3vee.a \
+ $(VMM_OBJS) $(DEVICE_OBJS) $(XED_OBJS)
-force:
+force:
-#vm_kernel: force
-# $(PAD) vm_kernel 512
-# @echo "VM kernel lives at 0x100000 and is" `$(NUMSECS) vm_kernel` "sectors long"
# Clean build directories of generated files
clean :
- for d in geekos common libc user tools palacios devices net; do \
+ for d in palacios devices; do \
(cd $$d && rm -f *); \
done
# Build header file dependencies, so source files are recompiled when
# header files they depend on are modified.
depend : $(GENERATED_LIBC_SRCS)
- $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
- $(KERNEL_C_SRCS:%.c=$(PROJECT_ROOT)/src/geekos/%.c) \
- | $(PERL) -n -e 's,^(\S),geekos/$$1,;print' \
- > depend.mak
- $(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_USER_OPTS) \
- $(COMMON_C_SRCS:%.c=$(PROJECT_ROOT)/src/common/%.c) \
- | $(PERL) -n -e 's,^(\S),common/$$1,;print' \
- >> depend.mak
+
$(TARGET_CC) -M $(CC_GENERAL_OPTS) $(CC_KERNEL_OPTS) \
$(VMM_C_SRCS:%.c=$(PROJECT_ROOT)/src/palacios/%.c) \
| $(PERL) -n -e 's,^(\S),palacios/$$1,;print' \
ret; \
}) \
+#define V3_Yield(addr) \
+ do { \
+ extern struct vmm_os_hooks * os_hooks; \
+ if ((os_hooks) && (os_hooks)->yield_cpu) { \
+ (os_hooks)->yield_cpu(); \
+ } \
+ } while (0) \
+
+
+
+
/* ** */
void (*start_kernel_thread)(); // include pointer to function
-
+ void (*yield_cpu)();
};
--- /dev/null
+/* Copyright (C) 1989, 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* As a special exception, if you include this header file into source
+ files compiled by GCC, this header file does not by itself cause
+ the resulting executable to be covered by the GNU General Public
+ License. This exception does not however invalidate any other
+ reasons why the executable file might be covered by the GNU General
+ Public License. */
+
+/*
+ * ISO C Standard: 7.17 Common definitions <stddef.h>
+ */
+#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
+ && !defined(__STDDEF_H__)) \
+ || defined(__need_wchar_t) || defined(__need_size_t) \
+ || defined(__need_ptrdiff_t) || defined(__need_NULL) \
+ || defined(__need_wint_t)
+
+/* Any one of these symbols __need_* means that GNU libc
+ wants us just to define one data type. So don't define
+ the symbols that indicate this file's entire job has been done. */
+#if (!defined(__need_wchar_t) && !defined(__need_size_t) \
+ && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
+ && !defined(__need_wint_t))
+#define _STDDEF_H
+#define _STDDEF_H_
+/* snaroff@next.com says the NeXT needs this. */
+#define _ANSI_STDDEF_H
+/* Irix 5.1 needs this. */
+#define __STDDEF_H__
+#endif
+
+#ifndef __sys_stdtypes_h
+/* This avoids lossage on SunOS but only if stdtypes.h comes first.
+ There's no way to win with the other order! Sun lossage. */
+
+/* On 4.3bsd-net2, make sure ansi.h is included, so we have
+ one less case to deal with in the following. */
+#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)
+#include <machine/ansi.h>
+#endif
+/* On FreeBSD 5, machine/ansi.h does not exist anymore... */
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
+#include <sys/_types.h>
+#endif
+
+/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
+ defined if the corresponding type is *not* defined.
+ FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
+#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
+#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
+#define _SIZE_T
+#endif
+#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
+#define _PTRDIFF_T
+#endif
+/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
+ instead of _WCHAR_T_. */
+#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
+#ifndef _BSD_WCHAR_T_
+#define _WCHAR_T
+#endif
+#endif
+/* Undef _FOO_T_ if we are supposed to define foo_t. */
+#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
+#undef _PTRDIFF_T_
+#undef _BSD_PTRDIFF_T_
+#endif
+#if defined (__need_size_t) || defined (_STDDEF_H_)
+#undef _SIZE_T_
+#undef _BSD_SIZE_T_
+#endif
+#if defined (__need_wchar_t) || defined (_STDDEF_H_)
+#undef _WCHAR_T_
+#undef _BSD_WCHAR_T_
+#endif
+#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
+
+/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
+ Just ignore it. */
+#if defined (__sequent__) && defined (_PTRDIFF_T_)
+#undef _PTRDIFF_T_
+#endif
+
+/* On VxWorks, <type/vxTypesBase.h> may have defined macros like
+ _TYPE_size_t which will typedef size_t. fixincludes patched the
+ vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
+ not defined, and so that defining this macro defines _GCC_SIZE_T.
+ If we find that the macros are still defined at this point, we must
+ invoke them so that the type is defined as expected. */
+#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
+_TYPE_ptrdiff_t;
+#undef _TYPE_ptrdiff_t
+#endif
+#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
+_TYPE_size_t;
+#undef _TYPE_size_t
+#endif
+#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
+_TYPE_wchar_t;
+#undef _TYPE_wchar_t
+#endif
+
+/* In case nobody has defined these types, but we aren't running under
+ GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
+ __WCHAR_TYPE__ have reasonable values. This can happen if the
+ parts of GCC is compiled by an older compiler, that actually
+ include gstddef.h, such as collect2. */
+
+/* Signed type of difference of two pointers. */
+
+/* Define this type if we are doing the whole job,
+ or if we want this type in particular. */
+#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
+#ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
+#ifndef _T_PTRDIFF_
+#ifndef _T_PTRDIFF
+#ifndef __PTRDIFF_T
+#ifndef _PTRDIFF_T_
+#ifndef _BSD_PTRDIFF_T_
+#ifndef ___int_ptrdiff_t_h
+#ifndef _GCC_PTRDIFF_T
+#define _PTRDIFF_T
+#define _T_PTRDIFF_
+#define _T_PTRDIFF
+#define __PTRDIFF_T
+#define _PTRDIFF_T_
+#define _BSD_PTRDIFF_T_
+#define ___int_ptrdiff_t_h
+#define _GCC_PTRDIFF_T
+#ifndef __PTRDIFF_TYPE__
+#define __PTRDIFF_TYPE__ long int
+#endif
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#endif /* _GCC_PTRDIFF_T */
+#endif /* ___int_ptrdiff_t_h */
+#endif /* _BSD_PTRDIFF_T_ */
+#endif /* _PTRDIFF_T_ */
+#endif /* __PTRDIFF_T */
+#endif /* _T_PTRDIFF */
+#endif /* _T_PTRDIFF_ */
+#endif /* _PTRDIFF_T */
+
+/* If this symbol has done its job, get rid of it. */
+#undef __need_ptrdiff_t
+
+#endif /* _STDDEF_H or __need_ptrdiff_t. */
+
+/* Unsigned type of `sizeof' something. */
+
+/* Define this type if we are doing the whole job,
+ or if we want this type in particular. */
+#if defined (_STDDEF_H) || defined (__need_size_t)
+#ifndef __size_t__ /* BeOS */
+#ifndef __SIZE_T__ /* Cray Unicos/Mk */
+#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
+#ifndef _SYS_SIZE_T_H
+#ifndef _T_SIZE_
+#ifndef _T_SIZE
+#ifndef __SIZE_T
+#ifndef _SIZE_T_
+#ifndef _BSD_SIZE_T_
+#ifndef _SIZE_T_DEFINED_
+#ifndef _SIZE_T_DEFINED
+#ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */
+#ifndef _SIZE_T_DECLARED /* FreeBSD 5 */
+#ifndef ___int_size_t_h
+#ifndef _GCC_SIZE_T
+#ifndef _SIZET_
+#ifndef __size_t
+#define __size_t__ /* BeOS */
+#define __SIZE_T__ /* Cray Unicos/Mk */
+#define _SIZE_T
+#define _SYS_SIZE_T_H
+#define _T_SIZE_
+#define _T_SIZE
+#define __SIZE_T
+#define _SIZE_T_
+#define _BSD_SIZE_T_
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_ /* Darwin */
+#define _SIZE_T_DECLARED /* FreeBSD 5 */
+#define ___int_size_t_h
+#define _GCC_SIZE_T
+#define _SIZET_
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
+/* __size_t is a typedef on FreeBSD 5!, must not trash it. */
+#else
+#define __size_t
+#endif
+#ifndef __SIZE_TYPE__
+#define __SIZE_TYPE__ long unsigned int
+#endif
+#if !(defined (__GNUG__) && defined (size_t))
+typedef __SIZE_TYPE__ size_t;
+#ifdef __BEOS__
+typedef long ssize_t;
+#endif /* __BEOS__ */
+#endif /* !(defined (__GNUG__) && defined (size_t)) */
+#endif /* __size_t */
+#endif /* _SIZET_ */
+#endif /* _GCC_SIZE_T */
+#endif /* ___int_size_t_h */
+#endif /* _SIZE_T_DECLARED */
+#endif /* _BSD_SIZE_T_DEFINED_ */
+#endif /* _SIZE_T_DEFINED */
+#endif /* _SIZE_T_DEFINED_ */
+#endif /* _BSD_SIZE_T_ */
+#endif /* _SIZE_T_ */
+#endif /* __SIZE_T */
+#endif /* _T_SIZE */
+#endif /* _T_SIZE_ */
+#endif /* _SYS_SIZE_T_H */
+#endif /* _SIZE_T */
+#endif /* __SIZE_T__ */
+#endif /* __size_t__ */
+#undef __need_size_t
+#endif /* _STDDEF_H or __need_size_t. */
+
+
+/* Wide character type.
+ Locale-writers should change this as necessary to
+ be big enough to hold unique values not between 0 and 127,
+ and not (wchar_t) -1, for each defined multibyte character. */
+
+/* Define this type if we are doing the whole job,
+ or if we want this type in particular. */
+#if defined (_STDDEF_H) || defined (__need_wchar_t)
+#ifndef __wchar_t__ /* BeOS */
+#ifndef __WCHAR_T__ /* Cray Unicos/Mk */
+#ifndef _WCHAR_T
+#ifndef _T_WCHAR_
+#ifndef _T_WCHAR
+#ifndef __WCHAR_T
+#ifndef _WCHAR_T_
+#ifndef _BSD_WCHAR_T_
+#ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
+#ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
+#ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
+#ifndef _WCHAR_T_DEFINED_
+#ifndef _WCHAR_T_DEFINED
+#ifndef _WCHAR_T_H
+#ifndef ___int_wchar_t_h
+#ifndef __INT_WCHAR_T_H
+#ifndef _GCC_WCHAR_T
+#define __wchar_t__ /* BeOS */
+#define __WCHAR_T__ /* Cray Unicos/Mk */
+#define _WCHAR_T
+#define _T_WCHAR_
+#define _T_WCHAR
+#define __WCHAR_T
+#define _WCHAR_T_
+#define _BSD_WCHAR_T_
+#define _WCHAR_T_DEFINED_
+#define _WCHAR_T_DEFINED
+#define _WCHAR_T_H
+#define ___int_wchar_t_h
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+
+/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
+ instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
+ symbols in the _FOO_T_ family, stays defined even after its
+ corresponding type is defined). If we define wchar_t, then we
+ must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
+ we undef _WCHAR_T_, then we must also define rune_t, since
+ headers like runetype.h assume that if machine/ansi.h is included,
+ and _BSD_WCHAR_T_ is not defined, then rune_t is available.
+ machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
+ the same type." */
+#ifdef _BSD_WCHAR_T_
+#undef _BSD_WCHAR_T_
+#ifdef _BSD_RUNE_T_
+#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
+typedef _BSD_RUNE_T_ rune_t;
+#define _BSD_WCHAR_T_DEFINED_
+#define _BSD_RUNE_T_DEFINED_ /* Darwin */
+#if defined (__FreeBSD__) && (__FreeBSD__ < 5)
+/* Why is this file so hard to maintain properly? In constrast to
+ the comment above regarding BSD/386 1.1, on FreeBSD for as long
+ as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
+ redundant typedefs will occur when stdlib.h is included after this file. */
+#undef _BSD_RUNE_T_
+#endif
+#endif
+#endif
+#endif
+/* FreeBSD 5 can't be handled well using "traditional" logic above
+ since it no longer defines _BSD_RUNE_T_ yet still desires to export
+ rune_t in some cases... */
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
+#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
+#if __BSD_VISIBLE
+#ifndef _RUNE_T_DECLARED
+typedef __rune_t rune_t;
+#define _RUNE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+#ifndef __WCHAR_TYPE__
+#define __WCHAR_TYPE__ int
+#endif
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif /* _WCHAR_T_DECLARED */
+#endif /* _BSD_RUNE_T_DEFINED_ */
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif /* __WCHAR_T__ */
+#endif /* __wchar_t__ */
+#undef __need_wchar_t
+#endif /* _STDDEF_H or __need_wchar_t. */
+
+#if defined (__need_wint_t)
+#ifndef _WINT_T
+#define _WINT_T
+
+#ifndef __WINT_TYPE__
+#define __WINT_TYPE__ unsigned int
+#endif
+typedef __WINT_TYPE__ wint_t;
+#endif
+#undef __need_wint_t
+#endif
+
+/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
+ are already defined. */
+/* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */
+#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
+/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
+ are probably typos and should be removed before 2.8 is released. */
+#ifdef _GCC_PTRDIFF_T_
+#undef _PTRDIFF_T_
+#undef _BSD_PTRDIFF_T_
+#endif
+#ifdef _GCC_SIZE_T_
+#undef _SIZE_T_
+#undef _BSD_SIZE_T_
+#endif
+#ifdef _GCC_WCHAR_T_
+#undef _WCHAR_T_
+#undef _BSD_WCHAR_T_
+#endif
+/* The following ones are the real ones. */
+#ifdef _GCC_PTRDIFF_T
+#undef _PTRDIFF_T_
+#undef _BSD_PTRDIFF_T_
+#endif
+#ifdef _GCC_SIZE_T
+#undef _SIZE_T_
+#undef _BSD_SIZE_T_
+#endif
+#ifdef _GCC_WCHAR_T
+#undef _WCHAR_T_
+#undef _BSD_WCHAR_T_
+#endif
+#endif /* _ANSI_H_ || _MACHINE_ANSI_H_ */
+
+#endif /* __sys_stdtypes_h */
+
+/* A null pointer constant. */
+
+#if defined (_STDDEF_H) || defined (__need_NULL)
+#undef NULL /* in case <stdio.h> has defined it. */
+#ifdef __GNUG__
+#define NULL __null
+#else /* G++ */
+#ifndef __cplusplus
+#define NULL ((void *)0)
+#else /* C++ */
+#define NULL 0
+#endif /* C++ */
+#endif /* G++ */
+#endif /* NULL not defined and <stddef.h> or need NULL. */
+#undef __need_NULL
+
+#ifdef _STDDEF_H
+
+/* Offset of member MEMBER in a struct of type TYPE. */
+#ifndef __cplusplus
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#else
+/* The cast to "char &" below avoids problems with user-defined
+ "operator &", which can appear in a POD type. */
+#define offsetof(TYPE, MEMBER) \
+ (__offsetof__ (reinterpret_cast <size_t> \
+ (&reinterpret_cast <const volatile char &> \
+ (static_cast<TYPE *> (0)->MEMBER))))
+#endif /* C++ */
+#endif /* _STDDEF_H was defined this time */
+
+#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
+ || __need_XXX was not defined before */
#ifdef __V3VEE__
-#include <stddef.h>
+#include <palacios/vmm_stddef.h>
+
void* memset(void* s, int c, size_t n);
void* memcpy(void *dst, const void* src, size_t n);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t limit);
char *strcat(char *s1, const char *s2);
+char *strncat(char *s1, const char *s2, size_t limit);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t limit);
char *strdup(const char *s1);
double ceil(double x);
+
#endif // !__V3VEE__
#endif /* STRING_H */
#define __VMM_TYPES_H
#ifdef __V3VEE__
+#include <palacios/vmm_stddef.h>
typedef signed char schar_t;
typedef signed long slong_t;
typedef unsigned long ulong_t;
-typedef unsigned long size_t;
+//typedef unsigned long size_t;
#define false 0
--- /dev/null
+#ifndef __V3_XED_COMPAT_H__
+#define __V3_XED_COMPAT_H__
+
+#include <palacios/vmm_stddef.h>
+
+
+/* Definition of the control structure for streams
+*/
+typedef struct file_struct {
+ short level; /* fill/empty level of buffer */
+ unsigned flags; /* File status flags */
+ char fd; /* File descriptor */
+ unsigned char hold; /* Ungetc char if no buffer */
+ short bsize; /* Buffer size */
+ unsigned char *buffer; /* Data transfer buffer */
+ unsigned char *curp; /* Current active pointer */
+ unsigned istemp; /* Temporary file indicator */
+ short token; /* Used for validity checking */
+} FILE;
+
+
+
+int fprintf(FILE *file, char *fmt, ...);
+int printf(char *fmt, ...);
+int fflush(FILE *stream);
+void abort(void);
+
+
+#endif
#endif
-extern ulong_t g_ramdiskImage;
-extern ulong_t s_ramdiskSize;
+
+ulong_t g_ramdiskImage;
+ulong_t s_ramdiskSize;
static
void cdrom_init(struct cdrom_interface * cdrom)
return;
}
+
#include <palacios/vm_guest_mem.h>
#include <palacios/vmm_decoder.h>
+#include <palacios/vmm_string.h>
#include <palacios/svm_halt.h>
#include <palacios/vmm_intr.h>
-// From GeekOS
-void Yield(void);
+
//
PrintDebug("GeekOS Yield\n");
rdtscll(yield_start);
- Yield();
+ V3_Yield();
rdtscll(yield_stop);
SVM_ERROR equ 0xFFFFFFFF
SVM_SUCCESS equ 0x00000000
-EXPORT DisableInts
-EXPORT EnableInts
EXPORT exit_test
;CLGI equ db 0x0F,0x01,0xDD
-align 8
-DisableInts:
- cli
- ret
-
-align 8
-EnableInts:
- sti
- ret
-
align 8
CLGI:
EXPORT GetTR
+; CPUID functions
+EXPORT cpuid_ecx
+EXPORT cpuid_eax
+EXPORT cpuid_edx
+; Utility Functions
+EXPORT Set_MSR
+EXPORT Get_MSR
ret
+;
+; cpuid_edx - return the edx register from cpuid
+;
+align 8
+cpuid_edx:
+ push ebp
+ mov ebp, esp
+ push edx
+ push ecx
+ push ebx
+
+ mov eax, [ebp + 8]
+ cpuid
+ mov eax, edx
+
+ pop ebx
+ pop ecx
+ pop edx
+ pop ebp
+ ret
+
+
+;
+; cpuid_ecx - return the ecx register from cpuid
+;
+align 8
+cpuid_ecx:
+ push ebp
+ mov ebp, esp
+ push edx
+ push ecx
+ push ebx
+
+ mov eax, [ebp + 8]
+ cpuid
+ mov eax, ecx
+
+ pop ebx
+ pop ecx
+ pop edx
+ pop ebp
+ ret
+
+;
+; cpuid_eax - return the eax register from cpuid
+;
+align 8
+cpuid_eax:
+ push ebp
+ mov ebp, esp
+ push edx
+ push ecx
+ push ebx
+
+ mov eax, [esp+4]
+ cpuid
+
+ pop ebx
+ pop ecx
+ pop edx
+ pop ebp
+ ret
+
+;
+; Set_MSR - Set the value of a given MSR
+;
+align 8
+Set_MSR:
+ push ebp
+ mov ebp, esp
+ pusha
+ mov eax, [ebp+16]
+ mov edx, [ebp+12]
+ mov ecx, [ebp+8]
+ wrmsr
+ popa
+ pop ebp
+ ret
+
+
+
+;
+; Get_MSR - Get the value of a given MSR
+; void Get_MSR(int MSR, void * high_byte, void * low_byte);
+;
+align 8
+Get_MSR:
+ push ebp
+ mov ebp, esp
+ pusha
+ mov ecx, [ebp+8]
+ rdmsr
+ mov ebx, [ebp+12]
+ mov [ebx], edx
+ mov ebx, [ebp+16]
+ mov [ebx], eax
+ popa
+ pop ebp
+ ret
*/
+
+#define NEED_MEMSET 0
+#define NEED_MEMCPY 0
+#define NEED_MEMCMP 0
+#define NEED_STRLEN 0
+#define NEED_STRNLEN 0
+#define NEED_STRCMP 0
+#define NEED_STRNCMP 0
+#define NEED_STRCAT 0
+#define NEED_STRNCAT 0
+#define NEED_STRCPY 0
+#define NEED_STRNCPY 0
+#define NEED_STRDUP 0
+#define NEED_ATOI 0
+#define NEED_STRCHR 0
+#define NEED_STRRCHR 0
+#define NEED_STRPBRK 0
+
+
+
#include <palacios/vmm_string.h>
#include <palacios/vmm.h>
return (int)(x + e) + 1;
}
-#if 0
+
+#if NEED_MEMSET
void* memset(void* s, int c, size_t n)
{
unsigned char* p = (unsigned char*) s;
return s;
}
+#endif
-
+#if NEED_MEMCPY
void* memcpy(void *dst, const void* src, size_t n)
{
unsigned char* d = (unsigned char*) dst;
return dst;
}
+#endif
+#if NEED_CMP
int memcmp(const void *s1_, const void *s2_, size_t n)
{
const signed char *s1 = s1_, *s2 = s2_;
return 0;
}
+#endif
+
+#if NEED_STRLEN
size_t strlen(const char* s)
{
size_t len = 0;
++len;
return len;
}
+#endif
+
+
+#if NEED_STRNLEN
/*
* This it a GNU extension.
* It is like strlen(), but it will check at most maxlen
++len;
return len;
}
+#endif
+
+#if NEED_STRCMP
int strcmp(const char* s1, const char* s2)
{
while (1) {
++s2;
}
}
+#endif
+
+#if NEED_STRNCMP
int strncmp(const char* s1, const char* s2, size_t limit)
{
size_t i = 0;
/* limit reached and equal */
return 0;
}
+#endif
+
+#if NEED_STRCAT
char *strcat(char *s1, const char *s2)
{
char *t1;
return t1;
}
+#endif
+
+#if NEED_STRNCAT
+char *strncat(char *s1, const char *s2, size_t limit)
+{
+ size_t i = 0;
+ char *t1;
+ t1 = s1;
+ while (*s1) s1++;
+ while (i < limit) {
+ if(*s2 == '\0') break;
+ *s1++ = *s2++;
+ }
+ *s1 = '\0';
+ return t1;
+}
+#endif
+
+
+
+#if NEED_STRCPY
char *strcpy(char *dest, const char *src)
{
char *ret = dest;
return ret;
}
+#endif
+
+#if NEED_STRNCPY
char *strncpy(char *dest, const char *src, size_t limit)
{
char *ret = dest;
return ret;
}
+#endif
+
+
+#if NEED_STRDUP
char *strdup(const char *s1)
{
char *ret;
return ret;
}
+#endif
+
+
+
+#if NEED_ATOI
int atoi(const char *buf)
{
int ret = 0;
return ret;
}
+#endif
+
+#if NEED_STRCHR
char *strchr(const char *s, int c)
{
while (*s != '\0') {
}
return 0;
}
+#endif
+
+#if NEED_STRRCHR
char *strrchr(const char *s, int c)
{
size_t len = strlen(s);
}
return 0;
}
+#endif
+#if NEED_STRPBRK
char *strpbrk(const char *s, const char *accept)
{
size_t setLen = strlen(accept);
return 0;
}
-
#endif
+
--- /dev/null
+#include <xed/v3-xed-compat.h>
+
+
+/* Standard I/O predefined streams
+*/
+static FILE _streams = {0, 0, 0, 0, 0, NULL, NULL, 0, 0};
+FILE *stdin = (&_streams);
+FILE *stdout = (&_streams);
+FILE *stderr = (&_streams);
+
+int fprintf(FILE *file, char *fmt, ...)
+{
+ // PrintDebug("In fprintf!!\n");
+
+ return 0;
+
+}
+
+int printf(char *fmt, ...)
+{
+ // PrintDebug("In fprintf!!\n");
+
+ return 0;
+
+}
+
+int fflush(FILE *stream)
+{
+ //PrintDebug("In fflush!!\n");
+
+ return 0;
+}
+
+void abort(void)
+{
+ //PrintDebug("Abort!!\n");
+
+ //__asm__ __volatile__("trap");
+ //__builtin_unreached();
+
+
+ while(1);
+
+}