Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
internal commit: 0ab1ea615e5cfbb0687a9d593a86a7b774386076

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
  • Loading branch information
Anthony Xu authored and lijinxia committed May 11, 2018
1 parent b966397 commit bd31b1c
Show file tree
Hide file tree
Showing 93 changed files with 37,861 additions and 0 deletions.
35 changes: 35 additions & 0 deletions devicemodel/MAINTAINERS
@@ -0,0 +1,35 @@
ACRN Device Model Maintainers
===========================

This file provides information about the primary maintainers for
ACRN Device Model Maintainers.

In general, you should not privately email the maintainer. You should
email the acrn-dev list, but you can also Cc the maintainer.

Descriptions of section entries:

L: Mailing list that is relevant to this area (default is acrn-dev)
Patches and questions should be sent to the email list.
M: Cc address for patches and questions (ie, the package maintainer)
W: Web-page with status/info
T: SCM tree type and location. Type is one of: git, svn.
S: Status, one of the following:
Supported: Someone is actually paid to look after this.
Maintained: Someone actually looks after it.
Odd Fixes: It has a maintainer but they don't have time to do
much other than throw the odd patch in. See below.
Orphan: No current maintainer [but maybe you could take the
role as you write your new code].
Obsolete: Old code. Something tagged obsolete generally means
it has been replaced by a better system and you
should be using that.

Maintainers List
----------------
W: N/A
S: Supported
L: https://lists.projectacrn.org/g/acrn-dev
T: git - https://github.com/projectacrn/acrn-devicemodel.git
M: Anthony Xu <anthony.xu@intel.com>
M: Hao Li <hao.l.li@intel.com>
121 changes: 121 additions & 0 deletions devicemodel/Makefile
@@ -0,0 +1,121 @@
#
# ACRN-DM
#
MAJOR_VERSION=0
MINOR_VERSION=1
BASEDIR := $(shell pwd)
DM_OBJDIR ?= $(CURDIR)/build

ifneq ($(TARGET_YOCTO), TRUE)
CC := gcc
endif

CFLAGS := -g -O0 -std=gnu11
CFLAGS += -D_GNU_SOURCE
CFLAGS += -DNO_OPENSSL
CFLAGS += -m64
CFLAGS += -Wall -ffunction-sections
CFLAGS += -Werror

CFLAGS += -I$(BASEDIR)/include
CFLAGS += -I$(BASEDIR)/include/public

LIBS = -lrt
LIBS += -lpthread
LIBS += -lcrypto
LIBS += -lpciaccess
LIBS += -lz
LIBS += -luuid

# hw
SRCS += hw/pci/virtio/virtio.c
SRCS += hw/pci/virtio/virtio_kernel.c
SRCS += hw/platform/usb_mouse.c
SRCS += hw/platform/usb_core.c
SRCS += hw/platform/atkbdc.c
SRCS += hw/platform/ps2mouse.c
SRCS += hw/platform/rtc.c
SRCS += hw/platform/ps2kbd.c
SRCS += hw/platform/pm.c
SRCS += hw/platform/uart_core.c
SRCS += hw/platform/block_if.c
SRCS += hw/platform/ioapic.c
SRCS += hw/platform/cmos_io.c
SRCS += hw/pci/wdt_i6300esb.c
SRCS += hw/pci/lpc.c
SRCS += hw/pci/xhci.c
SRCS += hw/pci/core.c
SRCS += hw/pci/virtio/virtio_console.c
SRCS += hw/pci/virtio/virtio_block.c
SRCS += hw/pci/ahci.c
SRCS += hw/pci/hostbridge.c
SRCS += hw/pci/passthrough.c
SRCS += hw/pci/virtio/virtio_net.c
SRCS += hw/pci/virtio/virtio_rnd.c
SRCS += hw/pci/virtio/virtio_hyper_dmabuf.c
SRCS += hw/pci/irq.c
SRCS += hw/pci/uart.c
SRCS += hw/acpi/acpi.c

# core
#SRCS += core/bootrom.c
SRCS += core/sw_load.c
SRCS += core/smbiostbl.c
SRCS += core/mevent.c
SRCS += core/gc.c
SRCS += core/console.c
SRCS += core/inout.c
SRCS += core/mem.c
SRCS += core/post.c
SRCS += core/consport.c
SRCS += core/vmmapi.c
SRCS += core/mptbl.c
SRCS += core/main.c


OBJS := $(patsubst %.c,$(DM_OBJDIR)/%.o,$(SRCS))

HEADERS := $(shell find $(BASEDIR) -name '*.h')
DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o')

PROGRAM := acrn-dm

all: include/version.h $(PROGRAM)
@echo -n ""

$(PROGRAM): $(OBJS)
$(CC) -o $(DM_OBJDIR)/$@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)

clean:
rm -f $(OBJS)
rm -f include/version.h
rm -f $(OBJS)
rm -rf $(DM_OBJDIR)
if test -f $(PROGRAM); then rm $(PROGRAM); fi

distclean:
rm -f $(DISTCLEAN_OBJS)
rm -f include/version.h
rm -f $(OBJS)
rm -rf $(DM_OBJDIR)
rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS

include/version.h:
touch include/version.h
@COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\
DIRTY=`git diff-index --name-only HEAD`;\
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
TIME=`date "+%Y-%m-%d %H:%M:%S"`;\
cat license_header > include/version.h;\
echo "#define DM_MAJOR_VERSION $(MAJOR_VERSION)" >> include/version.h;\
echo "#define DM_MINOR_VERSION $(MINOR_VERSION)" >> include/version.h;\
echo "#define DM_BUILD_VERSION "\""$$PATCH"\""" >> include/version.h;\
echo "#define DM_BUILD_TIME "\""$$TIME"\""" >> include/version.h;\
echo "#define DM_BUILD_USER "\""$(USER)"\""" >> include/version.h

$(DM_OBJDIR)/%.o: %.c $(HEADERS)
[ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(CFLAGS) -c $< -o $@

install: $(DM_OBJDIR)/$(PROGRAM)
install -D $(DM_OBJDIR)/$(PROGRAM) $(DESTDIR)/usr/bin/$(PROGRAM)
18 changes: 18 additions & 0 deletions devicemodel/README
@@ -0,0 +1,18 @@
BUILD DEPENDANCE

for CentOS
yum install libuuid-devel

BUILD
make

CLEAN
make clean


RUN DEPENDANCE

for CentOS
yum install openssl-libs
yum install zlib
yum install libuuid
116 changes: 116 additions & 0 deletions devicemodel/core/console.c
@@ -0,0 +1,116 @@
/*-
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#include <sys/cdefs.h>
#include <sys/types.h>

#include "gc.h"
#include "console.h"

static struct {
struct gfx_ctx *gc;

fb_render_func_t fb_render_cb;
void *fb_arg;

kbd_event_func_t kbd_event_cb;
void *kbd_arg;
int kbd_priority;

ptr_event_func_t ptr_event_cb;
void *ptr_arg;
int ptr_priority;
} console;

void
console_init(int w, int h, void *fbaddr)
{
console.gc = gc_init(w, h, fbaddr);
}

void
console_set_fbaddr(void *fbaddr)
{
gc_set_fbaddr(console.gc, fbaddr);
}

struct gfx_ctx_image *
console_get_image(void)
{
struct gfx_ctx_image *image;

image = gc_get_image(console.gc);

return image;
}

void
console_fb_register(fb_render_func_t render_cb, void *arg)
{
console.fb_render_cb = render_cb;
console.fb_arg = arg;
}

void
console_refresh(void)
{
if (console.fb_render_cb)
(*console.fb_render_cb)(console.gc, console.fb_arg);
}

void
console_kbd_register(kbd_event_func_t event_cb, void *arg, int pri)
{
if (pri > console.kbd_priority) {
console.kbd_event_cb = event_cb;
console.kbd_arg = arg;
console.kbd_priority = pri;
}
}

void
console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri)
{
if (pri > console.ptr_priority) {
console.ptr_event_cb = event_cb;
console.ptr_arg = arg;
console.ptr_priority = pri;
}
}

void
console_key_event(int down, uint32_t keysym)
{
if (console.kbd_event_cb)
(*console.kbd_event_cb)(down, keysym, console.kbd_arg);
}

void
console_ptr_event(uint8_t button, int x, int y)
{
if (console.ptr_event_cb)
(*console.ptr_event_cb)(button, x, y, console.ptr_arg);
}

0 comments on commit bd31b1c

Please sign in to comment.