/* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. ChibiOS/RT 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 3 of the License, or (at your option) any later version. ChibiOS/RT 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 this program. If not, see . */ #include "ch.h" #include "hal.h" static VirtualTimer vt1, vt2; static void restart(void *p) { (void)p; chSysLockFromIsr(); uartStartSendI(&UARTD1, 14, "Hello World!\r\n"); chSysUnlockFromIsr(); } static void ledoff(void *p) { (void)p; palClearPad(GPIOB, GPIOB_LED4); } /* * This callback is invoked when a transmission buffer has been completely * read by the driver. */ static void txend1(UARTDriver *uartp) { (void)uartp; palSetPad(GPIOB, GPIOB_LED4); } /* * This callback is invoked when a transmission has physically completed. */ static void txend2(UARTDriver *uartp) { (void)uartp; palClearPad(GPIOB, GPIOB_LED4); chSysLockFromIsr(); if (chVTIsArmedI(&vt1)) chVTResetI(&vt1); chVTSetI(&vt1, MS2ST(5000), restart, NULL); chSysUnlockFromIsr(); } /* * This callback is invoked on a receive error, the errors mask is passed * as parameter. */ static void rxerr(UARTDriver *uartp, uartflags_t e) { (void)uartp; (void)e; } /* * This callback is invoked when a character is received but the application * was not ready to receive it, the character is passed as parameter. */ static void rxchar(UARTDriver *uartp, uint16_t c) { (void)uartp; (void)c; /* Flashing the LED each time a character is received.*/ palSetPad(GPIOB, GPIOB_LED4); chSysLockFromIsr(); if (chVTIsArmedI(&vt2)) chVTResetI(&vt2); chVTSetI(&vt2, MS2ST(200), ledoff, NULL); chSysUnlockFromIsr(); } /* * This callback is invoked when a receive buffer has been completely written. */ static void rxend(UARTDriver *uartp) { (void)uartp; } /* * UART driver configuration structure. */ static UARTConfig uart_cfg_1 = { txend1, txend2, rxend, rxchar, rxerr, 38400, 0, USART_CR2_LINEN, 0 }; /* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1, PA9 and PA10 are routed to USART1. */ uartStart(&UARTD1, &uart_cfg_1); palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); /* * Starts the transmission, it will be handled entirely in background. */ uartStartSend(&UARTD1, 13, "Starting...\r\n"); /* * Normal main() thread activity, in this demo it does nothing. */ while (TRUE) { chThdSleepMilliseconds(500); } } a> 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Rules.mk

CFLAGS   += -Werror
CFLAGS   += -fno-strict-aliasing
CFLAGS   += -I. $(CFLAGS_libxenctrl)

CPPFLAGS += -MMD -MF .$*.d
PROG_DEPS = .*.d

XML2VERSION = $(shell xml2-config --version )
CFLAGS     += $(shell xml2-config --cflags )
CFLAGS     += $(shell if [[ $(XML2VERSION) < 2.6.20 ]]; then echo ""; else echo "-DVALIDATE_SCHEMA"; fi )
LDFLAGS    += $(shell xml2-config --libs ) # if this does not work, try -L/usr/lib -lxml2 -lz -lpthread -lm

SRCS_TOOL     = secpol_tool.c
OBJS_TOOL    := $(patsubst %.c,%.o,$(filter %.c,$(SRCS_TOOL)))

ACM_INST_TOOLS    = xensec_tool xensec_gen
ACM_EZPOLICY      = xensec_ezpolicy
ACM_OBJS          = $(OBJS_TOOL) $(OBJS_GETD)
ACM_SCRIPTS       = python/xensec_tools/acm_getlabel

ACM_CONFIG_DIR    = /etc/xen/acm-security
ACM_POLICY_DIR    = $(ACM_CONFIG_DIR)/policies
ACM_SCRIPT_DIR    = $(ACM_CONFIG_DIR)/scripts

ACM_INST_HTML     = python/xensec_gen/index.html
ACM_INST_CGI      = python/xensec_gen/cgi-bin/policy.cgi
ACM_SECGEN_HTMLDIR= /var/lib/xensec_gen
ACM_SECGEN_CGIDIR = $(ACM_SECGEN_HTMLDIR)/cgi-bin

ACM_SCHEMA        = security_policy.xsd
ACM_EXAMPLES      = client_v1 test
ACM_DEF_POLICIES  =
ACM_POLICY_SUFFIX = security_policy.xml

ifeq ($(ACM_SECURITY),y)
.PHONY: all
all: build

.PHONY: install
ifndef XEN_PYTHON_NATIVE_INSTALL
install: LIBPATH=$(shell PYTHONPATH=../python/xen/util python -c "import auxbin; print auxbin.libpath()")
endif
install: all $(ACM_CONFIG_FILE)
	$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
	$(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)$(SBINDIR)
	$(INSTALL_PROG) $(ACM_EZPOLICY) $(DESTDIR)$(SBINDIR)
	$(INSTALL_DIR) $(DESTDIR)$(ACM_CONFIG_DIR)
	$(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)
	$(INSTALL_DATA) policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
	$(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)/example
	set -e; for i in $(ACM_EXAMPLES); do \
		$(INSTALL_DATA) policies/example/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/example/; \
	done
	set -e; for i in $(ACM_DEF_POLICIES); do \
		$(INSTALL_DATA) policies/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR); \
	done
	$(INSTALL_DIR) $(DESTDIR)$(ACM_SCRIPT_DIR)
	$(INSTALL_PROG) $(ACM_SCRIPTS) $(DESTDIR)$(ACM_SCRIPT_DIR)
	$(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
	$(INSTALL_DATA) $(ACM_INST_HTML) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
	$(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
	$(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
ifndef XEN_PYTHON_NATIVE_INSTALL
	python python/setup.py install --install-lib="$(DESTDIR)$(LIBPATH)/python"
else
	python python/setup.py install --root="$(DESTDIR)"
endif
else
.PHONY: all
all:

.PHONY: install
install:
endif

.PHONY: build
build: $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
	python python/setup.py build
	chmod 700 $(ACM_SCRIPTS)

xensec_tool: $(OBJS_TOOL)
	$(CC) -g $(CFLAGS) $(LDFLAGS) -O0 -o $@ $^ $(LDFLAGS_libxenctrl)

xensec_gen: xensec_gen.py
	cp -f $^ $@

.PHONY: clean
clean:
	$(RM) $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
	$(RM) $(ACM_OBJS)
	$(RM) $(PROG_DEPS)
	$(RM) -r build

.PHONY: mrproper
mrproper: clean

-include $(PROG_DEPS)